Skip to content

Commit

Permalink
use ESM and update most dependencies (#1003)
Browse files Browse the repository at this point in the history
  • Loading branch information
jetersen committed Jan 12, 2022
1 parent e3aebd9 commit 1f825d3
Show file tree
Hide file tree
Showing 33 changed files with 80,306 additions and 109,531 deletions.
9 changes: 6 additions & 3 deletions .eslintrc
@@ -1,13 +1,16 @@
{
"extends": ["eslint:recommended", "prettier"],
"extends": ["eslint:recommended", "prettier", "plugin:unicorn/recommended"],
"plugins": ["prettier"],
"parserOptions": {
"ecmaVersion": 9
"ecmaVersion": 12,
"sourceType": "module"
},
"env": { "node": true, "es6": true },
"rules": {
"prettier/prettier": "warn",
"no-console": "off",
"no-unused-vars": "warn"
"no-unused-vars": "warn",
"unicorn/no-null": "off",
"unicorn/prevent-abbreviations": "off"
}
}
3 changes: 2 additions & 1 deletion .github/workflows/tests.yml
Expand Up @@ -13,7 +13,8 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: '13'
node-version: '16'
cache: 'yarn'
- run: yarn install --frozen-lockfile
- run: yarn test
- run: yarn lint --fix
Expand Down
36 changes: 19 additions & 17 deletions .vscode/launch.json
Expand Up @@ -8,40 +8,42 @@
"type": "node",
"request": "launch",
"name": "Jest All",
"program": "${workspaceFolder}/node_modules/.bin/jest",
"args": ["--runInBand"],
"args": [
"--experimental-vm-modules",
"${workspaceFolder}/node_modules/.bin/jest",
"--runInBand"
],
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
"disableOptimisticBPs": true,
"windows": {
"program": "${workspaceFolder}/node_modules/jest/bin/jest"
}
"disableOptimisticBPs": true
},
{
"type": "node",
"request": "launch",
"name": "Jest Current File",
"program": "${workspaceFolder}/node_modules/.bin/jest",
"args": ["${fileBasenameNoExtension}"],
"args": [
"--experimental-vm-modules",
"${workspaceFolder}/node_modules/.bin/jest",
"${fileBasenameNoExtension}"
],
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
"disableOptimisticBPs": true,
"windows": {
"program": "${workspaceFolder}/node_modules/jest/bin/jest"
}
"disableOptimisticBPs": true
},
{
"type": "node",
"request": "launch",
"name": "Jest Run Selected Test",
"program": "${workspaceFolder}/node_modules/.bin/jest",
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
"disableOptimisticBPs": true,
"windows": {
"program": "${workspaceFolder}/node_modules/jest/bin/jest"
},
"args": ["${fileBasenameNoExtension}", "-t", "${selectedText}"]
"args": [
"--experimental-vm-modules",
"${workspaceFolder}/node_modules/.bin/jest",
"${fileBasenameNoExtension}",
"-t",
"${selectedText}"
]
}
]
}
10 changes: 5 additions & 5 deletions action.js
@@ -1,7 +1,7 @@
const core = require('@actions/core')
const { run } = require('@probot/adapter-github-actions')
const app = require('./index')
import core from '@actions/core'
import { run } from '@probot/adapter-github-actions'
import { app } from './index'

run(app).catch((err) => {
core.setFailed(`💥 Release drafter failed with error: ${err.message}`)
run(app).catch((error) => {
core.setFailed(`💥 Release drafter failed with error: ${error.message}`)
})
2 changes: 1 addition & 1 deletion action.yml
@@ -1,7 +1,7 @@
name: 'Release Drafter'
description: 'Drafts your next release notes as pull requests are merged into master.'
runs:
using: 'node12'
using: 'node16'
main: 'dist/index.js'
branding:
icon: edit-2
Expand Down
15 changes: 8 additions & 7 deletions bin/generate-fixtures.js
@@ -1,9 +1,10 @@
#!/usr/bin/env node

const fs = require('fs')
const path = require('path')
const fetch = require('node-fetch')
const { findCommitsWithAssociatedPullRequestsQuery } = require('../lib/commits')
import fs from 'node:fs'
import path from 'node:path'
import url from 'node:url'
import fetch from 'node-fetch'
import { findCommitsWithAssociatedPullRequestsQuery } from '../lib/commits'

const REPO_NAME = 'release-drafter-test-repo'
const GITHUB_GRAPHQL_API_ENDPOINT = 'https://api.github.com/graphql'
Expand Down Expand Up @@ -38,7 +39,7 @@ const repos = [
},
]

repos.forEach((repo) => {
for (const repo of repos) {
const options = {
method: 'POST',
headers: {
Expand Down Expand Up @@ -68,12 +69,12 @@ repos.forEach((repo) => {
)
fs.writeFileSync(
path.resolve(
__dirname,
path.dirname(url.fileURLToPath(import.meta.url)),
'../test/fixtures/__generated__',
`graphql-commits-${repo.branch}.json`
),
string + '\n'
)
})
.catch(console.error)
})
}
24 changes: 12 additions & 12 deletions bin/generate-schema.js
@@ -1,28 +1,28 @@
// joi-to-json-schema currently does not support v16 of Joi (https://github.com/lightsofapollo/joi-to-json-schema/issues/57)
const convert = require('joi-to-json-schema')
const fs = require('fs')
const { schema } = require('../lib/schema')
const args = process.argv.slice(2) || []
import convert from 'joi-to-json-schema'
import fs from 'node:fs'
import { schema } from '../lib/schema'
const inputArguments = process.argv.slice(2) || []

const jsonSchema = {
export const jsonSchema = {
title: 'JSON schema for Release Drafter yaml files',
id:
'https://github.com/release-drafter/release-drafter/blob/master/schema.json',
id: 'https://github.com/release-drafter/release-drafter/blob/master/schema.json',
$schema: 'http://json-schema.org/draft-04/schema#',
...convert(schema()),
}

// template is only required after deep merged, should not be required in the JSON schema
// we should also remove the required field in case nothing remains after the filtering to keep draft04 compatibility
const requiredField = jsonSchema.required.filter((item) => item !== 'template')
if (requiredField.length) {
if (requiredField.length > 0) {
jsonSchema.required = requiredField
} else {
delete jsonSchema.required
}

if (args[0] === 'print') {
fs.writeFileSync('./schema.json', `${JSON.stringify(jsonSchema, null, 2)}\n`)
if (inputArguments[0] === 'print') {
fs.writeFileSync(
'./schema.json',
`${JSON.stringify(jsonSchema, undefined, 2)}\n`
)
}

module.exports.jsonSchema = jsonSchema

0 comments on commit 1f825d3

Please sign in to comment.