mirror of
https://github.com/pnpm/action-setup.git
synced 2024-11-12 12:38:05 +00:00
Use ajv to validate schema
This commit is contained in:
parent
bb24f595c2
commit
e373fffa0a
BIN
dist/index.js
vendored
BIN
dist/index.js
vendored
Binary file not shown.
@ -10,6 +10,7 @@
|
|||||||
"node-fetch": "^2.6.0",
|
"node-fetch": "^2.6.0",
|
||||||
"expand-tilde": "^2.0.2",
|
"expand-tilde": "^2.0.2",
|
||||||
"js-yaml": "^3.13.1",
|
"js-yaml": "^3.13.1",
|
||||||
|
"ajv": "^6.12.0",
|
||||||
"@actions/core": "^1.2.4",
|
"@actions/core": "^1.2.4",
|
||||||
"@types/expand-tilde": "^2.0.0",
|
"@types/expand-tilde": "^2.0.0",
|
||||||
"@types/node-fetch": "^2.5.7",
|
"@types/node-fetch": "^2.5.7",
|
||||||
|
@ -4,6 +4,7 @@ dependencies:
|
|||||||
'@types/js-yaml': 3.12.3
|
'@types/js-yaml': 3.12.3
|
||||||
'@types/node': 13.13.5
|
'@types/node': 13.13.5
|
||||||
'@types/node-fetch': 2.5.7
|
'@types/node-fetch': 2.5.7
|
||||||
|
ajv: 6.12.0
|
||||||
expand-tilde: 2.0.2
|
expand-tilde: 2.0.2
|
||||||
js-yaml: 3.13.1
|
js-yaml: 3.13.1
|
||||||
node-fetch: 2.6.0
|
node-fetch: 2.6.0
|
||||||
@ -212,7 +213,6 @@ packages:
|
|||||||
fast-json-stable-stringify: 2.1.0
|
fast-json-stable-stringify: 2.1.0
|
||||||
json-schema-traverse: 0.4.1
|
json-schema-traverse: 0.4.1
|
||||||
uri-js: 4.2.2
|
uri-js: 4.2.2
|
||||||
dev: true
|
|
||||||
resolution:
|
resolution:
|
||||||
integrity: sha512-D6gFiFA0RRLyUbvijN74DWAjXSFxWKaWP7mldxkVhyhAV3+SWA9HEJPHQ2c9soIeTFJqcSdFDGFgdqs1iUU2Hw==
|
integrity: sha512-D6gFiFA0RRLyUbvijN74DWAjXSFxWKaWP7mldxkVhyhAV3+SWA9HEJPHQ2c9soIeTFJqcSdFDGFgdqs1iUU2Hw==
|
||||||
/ansi-regex/4.1.0:
|
/ansi-regex/4.1.0:
|
||||||
@ -369,11 +369,9 @@ packages:
|
|||||||
resolution:
|
resolution:
|
||||||
integrity: sha1-l+gBqgUt8CRU3kawK/YhZCzchQI=
|
integrity: sha1-l+gBqgUt8CRU3kawK/YhZCzchQI=
|
||||||
/fast-deep-equal/3.1.1:
|
/fast-deep-equal/3.1.1:
|
||||||
dev: true
|
|
||||||
resolution:
|
resolution:
|
||||||
integrity: sha512-8UEa58QDLauDNfpbrX55Q9jrGHThw2ZMdOky5Gl1CDtVeJDPVrG4Jxx1N8jw2gkWaff5UUuX1KJd+9zGe2B+ZA==
|
integrity: sha512-8UEa58QDLauDNfpbrX55Q9jrGHThw2ZMdOky5Gl1CDtVeJDPVrG4Jxx1N8jw2gkWaff5UUuX1KJd+9zGe2B+ZA==
|
||||||
/fast-json-stable-stringify/2.1.0:
|
/fast-json-stable-stringify/2.1.0:
|
||||||
dev: true
|
|
||||||
resolution:
|
resolution:
|
||||||
integrity: sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==
|
integrity: sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==
|
||||||
/fast-traverse/0.1.6:
|
/fast-traverse/0.1.6:
|
||||||
@ -484,7 +482,6 @@ packages:
|
|||||||
resolution:
|
resolution:
|
||||||
integrity: sha512-YfbcO7jXDdyj0DGxYVSlSeQNHbD7XPWvrVWeVUujrQEoZzWJIRrCPoyk6kL6IAjAG2IolMK4T0hNUe0HOUs5Jw==
|
integrity: sha512-YfbcO7jXDdyj0DGxYVSlSeQNHbD7XPWvrVWeVUujrQEoZzWJIRrCPoyk6kL6IAjAG2IolMK4T0hNUe0HOUs5Jw==
|
||||||
/json-schema-traverse/0.4.1:
|
/json-schema-traverse/0.4.1:
|
||||||
dev: true
|
|
||||||
resolution:
|
resolution:
|
||||||
integrity: sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==
|
integrity: sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==
|
||||||
/json-stable-stringify/1.0.1:
|
/json-stable-stringify/1.0.1:
|
||||||
@ -607,7 +604,6 @@ packages:
|
|||||||
resolution:
|
resolution:
|
||||||
integrity: sha1-F0uSaHNVNP+8es5r9TpanhtcX18=
|
integrity: sha1-F0uSaHNVNP+8es5r9TpanhtcX18=
|
||||||
/punycode/2.1.1:
|
/punycode/2.1.1:
|
||||||
dev: true
|
|
||||||
engines:
|
engines:
|
||||||
node: '>=6'
|
node: '>=6'
|
||||||
resolution:
|
resolution:
|
||||||
@ -696,7 +692,6 @@ packages:
|
|||||||
/uri-js/4.2.2:
|
/uri-js/4.2.2:
|
||||||
dependencies:
|
dependencies:
|
||||||
punycode: 2.1.1
|
punycode: 2.1.1
|
||||||
dev: true
|
|
||||||
resolution:
|
resolution:
|
||||||
integrity: sha512-KY9Frmirql91X2Qgjry0Wd4Y+YTdrdZheS8TFwvkbLWf/G5KNJDCh6pKL5OZctEW4+0Baa5idK2ZQuELRwPznQ==
|
integrity: sha512-KY9Frmirql91X2Qgjry0Wd4Y+YTdrdZheS8TFwvkbLWf/G5KNJDCh6pKL5OZctEW4+0Baa5idK2ZQuELRwPznQ==
|
||||||
/utility-types/3.10.0:
|
/utility-types/3.10.0:
|
||||||
@ -795,6 +790,7 @@ specifiers:
|
|||||||
'@types/node': ^13.13.5
|
'@types/node': ^13.13.5
|
||||||
'@types/node-fetch': ^2.5.7
|
'@types/node-fetch': ^2.5.7
|
||||||
'@zeit/ncc': ^0.22.1
|
'@zeit/ncc': ^0.22.1
|
||||||
|
ajv: ^6.12.0
|
||||||
expand-tilde: ^2.0.2
|
expand-tilde: ^2.0.2
|
||||||
js-yaml: ^3.13.1
|
js-yaml: ^3.13.1
|
||||||
node-fetch: ^2.6.0
|
node-fetch: ^2.6.0
|
||||||
|
@ -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 expandTilde from 'expand-tilde'
|
||||||
import { safeLoad } from 'js-yaml'
|
import { safeLoad } from 'js-yaml'
|
||||||
|
import Ajv from 'ajv'
|
||||||
|
import runInstallSchema from './run-install-input.schema.json'
|
||||||
|
|
||||||
interface RunInstall {
|
interface RunInstall {
|
||||||
readonly recursive?: boolean
|
readonly recursive?: boolean
|
||||||
@ -30,6 +33,17 @@ const parseInputPath = (name: string) => expandTilde(getInput(name, options))
|
|||||||
|
|
||||||
function parseRunInstall(name: string): RunInstall[] {
|
function parseRunInstall(name: string): RunInstall[] {
|
||||||
const result: RunInstallInput = safeLoad(getInput(name, options))
|
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) return []
|
||||||
if (result === true) return [{ recursive: true }]
|
if (result === true) return [{ recursive: true }]
|
||||||
if (Array.isArray(result)) return result
|
if (Array.isArray(result)) return result
|
||||||
|
@ -3,7 +3,16 @@
|
|||||||
"instruction": {
|
"instruction": {
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"strict": true,
|
"strict": true,
|
||||||
"esModuleInterop": true
|
"target": "ES2018",
|
||||||
|
"lib": [
|
||||||
|
"ES2018",
|
||||||
|
"ES2019",
|
||||||
|
"ES2020",
|
||||||
|
"ESNext"
|
||||||
|
],
|
||||||
|
"moduleResolution": "Node",
|
||||||
|
"esModuleInterop": true,
|
||||||
|
"resolveJsonModule": true
|
||||||
},
|
},
|
||||||
"input": "index.ts",
|
"input": "index.ts",
|
||||||
"symbol": "RunInstallInput",
|
"symbol": "RunInstallInput",
|
||||||
|
Loading…
Reference in New Issue
Block a user