diff --git a/dist/index.js b/dist/index.js index 1dd407f..f7c7a06 100644 Binary files a/dist/index.js and b/dist/index.js differ diff --git a/package.json b/package.json index 89ef23d..8decc8c 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,7 @@ "node-fetch": "^2.6.0", "expand-tilde": "^2.0.2", "js-yaml": "^3.13.1", + "ajv": "^6.12.0", "@actions/core": "^1.2.4", "@types/expand-tilde": "^2.0.0", "@types/node-fetch": "^2.5.7", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 3cc7d9c..2a988b1 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -4,6 +4,7 @@ dependencies: '@types/js-yaml': 3.12.3 '@types/node': 13.13.5 '@types/node-fetch': 2.5.7 + ajv: 6.12.0 expand-tilde: 2.0.2 js-yaml: 3.13.1 node-fetch: 2.6.0 @@ -212,7 +213,6 @@ packages: fast-json-stable-stringify: 2.1.0 json-schema-traverse: 0.4.1 uri-js: 4.2.2 - dev: true resolution: integrity: sha512-D6gFiFA0RRLyUbvijN74DWAjXSFxWKaWP7mldxkVhyhAV3+SWA9HEJPHQ2c9soIeTFJqcSdFDGFgdqs1iUU2Hw== /ansi-regex/4.1.0: @@ -369,11 +369,9 @@ packages: resolution: integrity: sha1-l+gBqgUt8CRU3kawK/YhZCzchQI= /fast-deep-equal/3.1.1: - dev: true resolution: integrity: sha512-8UEa58QDLauDNfpbrX55Q9jrGHThw2ZMdOky5Gl1CDtVeJDPVrG4Jxx1N8jw2gkWaff5UUuX1KJd+9zGe2B+ZA== /fast-json-stable-stringify/2.1.0: - dev: true resolution: integrity: sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw== /fast-traverse/0.1.6: @@ -484,7 +482,6 @@ packages: resolution: integrity: sha512-YfbcO7jXDdyj0DGxYVSlSeQNHbD7XPWvrVWeVUujrQEoZzWJIRrCPoyk6kL6IAjAG2IolMK4T0hNUe0HOUs5Jw== /json-schema-traverse/0.4.1: - dev: true resolution: integrity: sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg== /json-stable-stringify/1.0.1: @@ -607,7 +604,6 @@ packages: resolution: integrity: sha1-F0uSaHNVNP+8es5r9TpanhtcX18= /punycode/2.1.1: - dev: true engines: node: '>=6' resolution: @@ -696,7 +692,6 @@ packages: /uri-js/4.2.2: dependencies: punycode: 2.1.1 - dev: true resolution: integrity: sha512-KY9Frmirql91X2Qgjry0Wd4Y+YTdrdZheS8TFwvkbLWf/G5KNJDCh6pKL5OZctEW4+0Baa5idK2ZQuELRwPznQ== /utility-types/3.10.0: @@ -795,6 +790,7 @@ specifiers: '@types/node': ^13.13.5 '@types/node-fetch': ^2.5.7 '@zeit/ncc': ^0.22.1 + ajv: ^6.12.0 expand-tilde: ^2.0.2 js-yaml: ^3.13.1 node-fetch: ^2.6.0 diff --git a/src/inputs/index.ts b/src/inputs/index.ts index 44da578..6f9bdac 100644 --- a/src/inputs/index.ts +++ b/src/inputs/index.ts @@ -1,6 +1,9 @@ -import { getInput, InputOptions } from '@actions/core' +import process from 'process' +import { getInput, error, InputOptions } from '@actions/core' import expandTilde from 'expand-tilde' import { safeLoad } from 'js-yaml' +import Ajv from 'ajv' +import runInstallSchema from './run-install-input.schema.json' interface RunInstall { readonly recursive?: boolean @@ -30,6 +33,17 @@ const parseInputPath = (name: string) => expandTilde(getInput(name, options)) function parseRunInstall(name: string): RunInstall[] { const result: RunInstallInput = safeLoad(getInput(name, options)) + const ajv = new Ajv({ + allErrors: true, + async: false, + }) + const validate = ajv.compile(runInstallSchema) + if (!validate(result)) { + for (const errorItem of validate.errors!) { + error(`${errorItem.dataPath}: ${errorItem.message}`) + } + return process.exit(1) + } if (!result) return [] if (result === true) return [{ recursive: true }] if (Array.isArray(result)) return result diff --git a/src/inputs/run-install-input.schema.autogen.json b/src/inputs/run-install-input.schema.autogen.json index f9f9305..c42a1d7 100644 --- a/src/inputs/run-install-input.schema.autogen.json +++ b/src/inputs/run-install-input.schema.autogen.json @@ -3,7 +3,16 @@ "instruction": { "compilerOptions": { "strict": true, - "esModuleInterop": true + "target": "ES2018", + "lib": [ + "ES2018", + "ES2019", + "ES2020", + "ESNext" + ], + "moduleResolution": "Node", + "esModuleInterop": true, + "resolveJsonModule": true }, "input": "index.ts", "symbol": "RunInstallInput",