From 1ab9c09fc60d6397e745882ebef1ff2c3a4db3d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20Herna=CC=81ndez?= Date: Mon, 4 Dec 2023 09:13:09 +0100 Subject: [PATCH] Update project to node20 --- .github/workflows/ci.yml | 2 +- .github/workflows/release_auto.yml | 2 +- action.yml | 2 +- package-lock.json | 21 ++++++++++++--------- package.json | 13 ++++++++----- src/modules/workspace.ts | 21 ++++++++++++++------- src/utils/docs.ts | 11 +++++++---- 7 files changed, 44 insertions(+), 28 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 553679c9..90468435 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,7 +11,7 @@ jobs: - uses: actions/setup-node@8f152de45cc393bb48ce5d89d36b731f54556e65 # v4.0.0 with: - node-version: '16' + node-version: '20' - name: Run `npm install` run: npm install diff --git a/.github/workflows/release_auto.yml b/.github/workflows/release_auto.yml index 49880cf1..3437f257 100644 --- a/.github/workflows/release_auto.yml +++ b/.github/workflows/release_auto.yml @@ -26,7 +26,7 @@ jobs: - uses: actions/setup-node@8f152de45cc393bb48ce5d89d36b731f54556e65 # v4.0.0 with: - node-version: '16' + node-version: '20' - name: Run `npm install` run: npm install diff --git a/action.yml b/action.yml index 3be6adec..b1562110 100644 --- a/action.yml +++ b/action.yml @@ -171,7 +171,7 @@ inputs: required: false runs: - using: node16 + using: node20 pre: dist/pre.js main: dist/main.js post: dist/post.js diff --git a/package-lock.json b/package-lock.json index 15be34b2..279e72a3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -22,7 +22,7 @@ }, "devDependencies": { "@ava/typescript": "^4.1.0", - "@tsconfig/recommended": "^1.0.3", + "@tsconfig/node20": "^20.1.2", "@types/js-yaml": "^4.0.5", "@types/node": "^20.4.5", "@vercel/ncc": "^0.36.1", @@ -36,6 +36,9 @@ "ts-pattern": "^5.0.5", "typescript": "^5.2.2", "xo": "^0.54.2" + }, + "engines": { + "node": ">=20" } }, "node_modules/@actions/cache": { @@ -1317,10 +1320,10 @@ "integrity": "sha512-eZxlbI8GZscaGS7kkc/trHTT5xgrjH3/1n2JDwusC9iahPKWMRvRjJSAN5mCXviuTGQ/lHnhvv8Q1YTpnfz9gA==", "dev": true }, - "node_modules/@tsconfig/recommended": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/@tsconfig/recommended/-/recommended-1.0.3.tgz", - "integrity": "sha512-+jby/Guq9H8O7NWgCv6X8VAiQE8Dr/nccsCtL74xyHKhu2Knu5EAKmOZj3nLCnLm1KooUzKY+5DsnGVqhM8/wQ==", + "node_modules/@tsconfig/node20": { + "version": "20.1.2", + "resolved": "https://registry.npmjs.org/@tsconfig/node20/-/node20-20.1.2.tgz", + "integrity": "sha512-madaWq2k+LYMEhmcp0fs+OGaLFk0OenpHa4gmI4VEmCKX4PJntQ6fnnGADVFrVkBj0wIdAlQnK/MrlYTHsa1gQ==", "dev": true }, "node_modules/@types/btoa-lite": { @@ -10685,10 +10688,10 @@ "integrity": "sha512-eZxlbI8GZscaGS7kkc/trHTT5xgrjH3/1n2JDwusC9iahPKWMRvRjJSAN5mCXviuTGQ/lHnhvv8Q1YTpnfz9gA==", "dev": true }, - "@tsconfig/recommended": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/@tsconfig/recommended/-/recommended-1.0.3.tgz", - "integrity": "sha512-+jby/Guq9H8O7NWgCv6X8VAiQE8Dr/nccsCtL74xyHKhu2Knu5EAKmOZj3nLCnLm1KooUzKY+5DsnGVqhM8/wQ==", + "@tsconfig/node20": { + "version": "20.1.2", + "resolved": "https://registry.npmjs.org/@tsconfig/node20/-/node20-20.1.2.tgz", + "integrity": "sha512-madaWq2k+LYMEhmcp0fs+OGaLFk0OenpHa4gmI4VEmCKX4PJntQ6fnnGADVFrVkBj0wIdAlQnK/MrlYTHsa1gQ==", "dev": true }, "@types/btoa-lite": { diff --git a/package.json b/package.json index 3985c5b3..0354cabe 100644 --- a/package.json +++ b/package.json @@ -2,11 +2,11 @@ "name": "scala-steward-action", "description": "A GitHub Action to launch Scala Steward in your repository", "scripts": { - "tsconfig": "echo '{ \"extends\": \"@tsconfig/recommended/tsconfig.json\" }' > tsconfig.json", + "tsconfig": "echo '{ \"extends\": \"@tsconfig/node20/tsconfig.json\" }' > tsconfig.json", "build": "npm run tsconfig && npm run build-pre && npm run build-main && npm run build-post", - "build-pre": "ncc build --target es2019 src/action/pre.ts && mv dist/index.js dist/pre.js", - "build-main": "ncc build --target es2019 src/action/main.ts && mv dist/index.js dist/main.js", - "build-post": "ncc build --target es2019 src/action/post.ts && mv dist/index.js dist/post.js", + "build-pre": "ncc build --target es2022 src/action/pre.ts && mv dist/index.js dist/pre.js", + "build-main": "ncc build --target es2022 src/action/main.ts && mv dist/index.js dist/main.js", + "build-post": "ncc build --target es2022 src/action/post.ts && mv dist/index.js dist/post.js", "docs": "ts-node src/utils/docs.ts && markdown-toc-gen update README.md", "contributors:add": "all-contributors add", "contributors:generate": "all-contributors generate", @@ -15,6 +15,9 @@ "report": "c8 report", "all": "npm run build && npm test && npm run report" }, + "engines": { + "node": ">=20" + }, "repository": { "type": "git", "url": "git+https://github.com/scala-steward-org/scala-steward-action.git" @@ -43,7 +46,7 @@ }, "devDependencies": { "@ava/typescript": "^4.1.0", - "@tsconfig/recommended": "^1.0.3", + "@tsconfig/node20": "^20.1.2", "@types/js-yaml": "^4.0.5", "@types/node": "^20.4.5", "@vercel/ncc": "^0.36.1", diff --git a/src/modules/workspace.ts b/src/modules/workspace.ts index 482d930b..01c19ef1 100644 --- a/src/modules/workspace.ts +++ b/src/modules/workspace.ts @@ -17,19 +17,26 @@ export class Workspace { return new Workspace(logger, files, os, cache) } - readonly directory = path.join(this.os.homedir(), 'scala-steward') - readonly workspace = mandatory(path.join(this.directory, 'workspace')) - readonly repos_md = mandatory(path.join(this.directory, 'repos.md')) - readonly app_pem = mandatory(path.join(this.directory, 'app.pem')) - readonly askpass_sh = mandatory(path.join(this.directory, 'askpass.sh')) - readonly runSummary_md: string = path.join(this.workspace.value, 'run-summary.md') + readonly directory: string + readonly workspace: NonEmptyString + readonly repos_md: NonEmptyString + readonly app_pem: NonEmptyString + readonly askpass_sh: NonEmptyString + readonly runSummary_md: string constructor( private readonly logger: Logger, private readonly files: Files, private readonly os: OSInfo, private readonly cache: ActionCache, - ) {} + ) { + this.directory = path.join(this.os.homedir(), 'scala-steward') + this.workspace = mandatory(path.join(this.directory, 'workspace')) + this.repos_md = mandatory(path.join(this.directory, 'repos.md')) + this.app_pem = mandatory(path.join(this.directory, 'app.pem')) + this.askpass_sh = mandatory(path.join(this.directory, 'askpass.sh')) + this.runSummary_md = path.join(this.workspace.value, 'run-summary.md') + } /** * Tries to restore the Scala Steward workspace build from the cache, if any. diff --git a/src/utils/docs.ts b/src/utils/docs.ts index 9ea13ee2..f6e38ecd 100644 --- a/src/utils/docs.ts +++ b/src/utils/docs.ts @@ -10,10 +10,13 @@ type ActionYaml = {inputs: Record [''] - .concat(...input[1].description.trimEnd().split('\n').map(line => ` # ${line}`)) - .concat(input[1].default ? [' #', ` # Default: ${input[1].default}`] : []) - .concat(` ${input[0]}: ''`), +const inputs = Object.entries(actionYaml.inputs).flatMap(input => + [ + '', + ...input[1].description.trimEnd().split('\n').map(line => ` # ${line}`), + ...(input[1].default ? [' #', ` # Default: ${input[1].default}`] : []), + ` ${input[0]}: ''`, + ], ) /**