diff --git a/dist/index.js b/dist/index.js index 601bcd6..1f4fca0 100644 --- a/dist/index.js +++ b/dist/index.js @@ -26804,42 +26804,43 @@ module.exports = parseParams /******/ /************************************************************************/ var __webpack_exports__ = {}; -// This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk. +// This entry need to be wrapped in an IIFE because it need to be in strict mode. (() => { -const core = __nccwpck_require__(2186); +"use strict"; +var exports = __webpack_exports__; +Object.defineProperty(exports, "__esModule", ({ value: true })); +const core_1 = __nccwpck_require__(2186); function parseJsonInput(param_name) { - const param_val = core.getInput(param_name); + const param_val = (0, core_1.getInput)(param_name); try { return JSON.parse(param_val); - } catch (error) { + } + catch (error) { throw new Error(`Invalid '${param_name}' input ${param_val}: ${error.message}`); } } - - function main() { - const needs = parseJsonInput('needs'); - const skippable = core.getMultilineInput('skippable'); - + const needs = parseJsonInput("needs"); + const skippable = (0, core_1.getMultilineInput)("skippable"); console.debug(`needs: ${JSON.stringify(needs)}`); console.debug(`skippable: ${JSON.stringify(skippable)}`); for (const job_id of Object.keys(needs)) { const result = needs[job_id].result; console.log(`Job ${job_id} returned ${result}`); - if (result == 'skipped' && skippable.includes(job_id)) { + if (result == "skipped" && skippable.includes(job_id)) { continue; } - if (result != 'success') { + if (result != "success") { throw new Error(`Job ${job_id} returned ${result}`); } } } - try { main(); -} catch (error) { - core.setFailed(error.message); +} +catch (error) { + (0, core_1.setFailed)(error.message); } })(); diff --git a/index.js b/index.js deleted file mode 100644 index 3f4d072..0000000 --- a/index.js +++ /dev/null @@ -1,35 +0,0 @@ -const core = require('@actions/core'); - -function parseJsonInput(param_name) { - const param_val = core.getInput(param_name); - try { - return JSON.parse(param_val); - } catch (error) { - throw new Error(`Invalid '${param_name}' input ${param_val}: ${error.message}`); - } -} - - -function main() { - const needs = parseJsonInput('needs'); - const skippable = core.getMultilineInput('skippable'); - - console.debug(`needs: ${JSON.stringify(needs)}`); - console.debug(`skippable: ${JSON.stringify(skippable)}`); - for (const job_id of Object.keys(needs)) { - const result = needs[job_id].result; - console.log(`Job ${job_id} returned ${result}`); - if (result == 'skipped' && skippable.includes(job_id)) { - continue; - } - if (result != 'success') { - throw new Error(`Job ${job_id} returned ${result}`); - } - } -} - -try { - main(); -} catch (error) { - core.setFailed(error.message); -} diff --git a/index.ts b/index.ts new file mode 100644 index 0000000..52971b2 --- /dev/null +++ b/index.ts @@ -0,0 +1,36 @@ +import { getInput, getMultilineInput, setFailed } from "@actions/core"; + +function parseJsonInput(param_name: string) { + const param_val = getInput(param_name); + try { + return JSON.parse(param_val); + } catch (error) { + throw new Error( + `Invalid '${param_name}' input ${param_val}: ${(error as Error).message}`, + ); + } +} + +function main() { + const needs = parseJsonInput("needs"); + const skippable = getMultilineInput("skippable"); + + console.debug(`needs: ${JSON.stringify(needs)}`); + console.debug(`skippable: ${JSON.stringify(skippable)}`); + for (const job_id of Object.keys(needs)) { + const result = needs[job_id].result; + console.log(`Job ${job_id} returned ${result}`); + if (result == "skipped" && skippable.includes(job_id)) { + continue; + } + if (result != "success") { + throw new Error(`Job ${job_id} returned ${result}`); + } + } +} + +try { + main(); +} catch (error) { + setFailed((error as Error).message); +} diff --git a/package-lock.json b/package-lock.json index d37ad4d..3caea2a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,7 +12,10 @@ "@actions/core": "^1.10.1" }, "devDependencies": { - "@vercel/ncc": "^0.38.1" + "@tsconfig/node20": "^20.1.4", + "@types/node": "^20.14.9", + "@vercel/ncc": "^0.38.1", + "typescript": "^5.5.2" } }, "node_modules/@actions/core": { @@ -41,6 +44,21 @@ "node": ">=14" } }, + "node_modules/@tsconfig/node20": { + "version": "20.1.4", + "resolved": "https://registry.npmjs.org/@tsconfig/node20/-/node20-20.1.4.tgz", + "integrity": "sha512-sqgsT69YFeLWf5NtJ4Xq/xAF8p4ZQHlmGW74Nu2tD4+g5fAsposc4ZfaaPixVu4y01BEiDCWLRDCvDM5JOsRxg==", + "dev": true + }, + "node_modules/@types/node": { + "version": "20.14.9", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.14.9.tgz", + "integrity": "sha512-06OCtnTXtWOZBJlRApleWndH4JsRVs1pDCc8dLSQp+7PpUpX3ePdHyeNSFTeSe7FtKyQkrlPvHwJOW3SLd8Oyg==", + "dev": true, + "dependencies": { + "undici-types": "~5.26.4" + } + }, "node_modules/@vercel/ncc": { "version": "0.38.1", "resolved": "https://registry.npmjs.org/@vercel/ncc/-/ncc-0.38.1.tgz", @@ -58,6 +76,19 @@ "node": ">=0.6.11 <=0.7.0 || >=0.7.3" } }, + "node_modules/typescript": { + "version": "5.5.2", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.5.2.tgz", + "integrity": "sha512-NcRtPEOsPFFWjobJEtfihkLCZCXZt/os3zf8nTxjVH3RvTSxjrCamJpbExGvYOF+tFHc3pA65qpdwPbzjohhew==", + "dev": true, + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=14.17" + } + }, "node_modules/undici": { "version": "5.28.4", "resolved": "https://registry.npmjs.org/undici/-/undici-5.28.4.tgz", @@ -69,6 +100,12 @@ "node": ">=14.0" } }, + "node_modules/undici-types": { + "version": "5.26.5", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz", + "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==", + "dev": true + }, "node_modules/uuid": { "version": "8.3.2", "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", @@ -102,6 +139,21 @@ "resolved": "https://registry.npmjs.org/@fastify/busboy/-/busboy-2.1.1.tgz", "integrity": "sha512-vBZP4NlzfOlerQTnba4aqZoMhE/a9HY7HRqoOPaETQcSQuWEIyZMHGfVu6w9wGtGK5fED5qRs2DteVCjOH60sA==" }, + "@tsconfig/node20": { + "version": "20.1.4", + "resolved": "https://registry.npmjs.org/@tsconfig/node20/-/node20-20.1.4.tgz", + "integrity": "sha512-sqgsT69YFeLWf5NtJ4Xq/xAF8p4ZQHlmGW74Nu2tD4+g5fAsposc4ZfaaPixVu4y01BEiDCWLRDCvDM5JOsRxg==", + "dev": true + }, + "@types/node": { + "version": "20.14.9", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.14.9.tgz", + "integrity": "sha512-06OCtnTXtWOZBJlRApleWndH4JsRVs1pDCc8dLSQp+7PpUpX3ePdHyeNSFTeSe7FtKyQkrlPvHwJOW3SLd8Oyg==", + "dev": true, + "requires": { + "undici-types": "~5.26.4" + } + }, "@vercel/ncc": { "version": "0.38.1", "resolved": "https://registry.npmjs.org/@vercel/ncc/-/ncc-0.38.1.tgz", @@ -113,6 +165,12 @@ "resolved": "https://registry.npmjs.org/tunnel/-/tunnel-0.0.6.tgz", "integrity": "sha512-1h/Lnq9yajKY2PEbBadPXj3VxsDDu844OnaAo52UVmIzIvwwtBPIuNvkjuzBlTWpfJyUbG3ez0KSBibQkj4ojg==" }, + "typescript": { + "version": "5.5.2", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.5.2.tgz", + "integrity": "sha512-NcRtPEOsPFFWjobJEtfihkLCZCXZt/os3zf8nTxjVH3RvTSxjrCamJpbExGvYOF+tFHc3pA65qpdwPbzjohhew==", + "dev": true + }, "undici": { "version": "5.28.4", "resolved": "https://registry.npmjs.org/undici/-/undici-5.28.4.tgz", @@ -121,6 +179,12 @@ "@fastify/busboy": "^2.0.0" } }, + "undici-types": { + "version": "5.26.5", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz", + "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==", + "dev": true + }, "uuid": { "version": "8.3.2", "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", diff --git a/package.json b/package.json index 00e259b..91fb3a0 100644 --- a/package.json +++ b/package.json @@ -2,9 +2,9 @@ "name": "done-action", "version": "1.0.0", "description": "", - "main": "index.js", + "main": "dist/index.js", "scripts": { - "build": "ncc build index.js --license licenses.txt" + "build": "ncc build index.ts --license licenses.txt" }, "repository": { "type": "git", @@ -21,6 +21,9 @@ "@actions/core": "^1.10.1" }, "devDependencies": { - "@vercel/ncc": "^0.38.1" + "@tsconfig/node20": "^20.1.4", + "@types/node": "^20.14.9", + "@vercel/ncc": "^0.38.1", + "typescript": "^5.5.2" } } diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..b994545 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,3 @@ +{ + "extends": "@tsconfig/node20/tsconfig.json" +}