mirror of
https://github.com/pnpm/action-setup
synced 2026-11-07 13:07:57 +01:00
Use ajv to validate schema
This commit is contained in:
1 parent
bb24f595c2
commit
e373fffa0a
5 files changed
+29
-9
No files matched your search
Vendored
+1
-1
@@ -1 +1 @@
|
||||
module.exports=function(r,n){"use strict";var e={};function __webpack_require__(n){if(e[n]){return e[n].exports}var i=e[n]={i:n,l:false,exports:{}};r[n].call(i.exports,i,i.exports,__webpack_require__);i.l=true;return i.exports}__webpack_require__.ab=__dirname+"/";function startup(){return __webpack_require__(803)}return startup()}({0:function(r,n){"use strict";Object.defineProperty(n,"__esModule",{value:true});n.ref="301414cec74a2b6b63c95b42f2ad1790ccb980ed";n.url=`https://raw.githubusercontent.com/pnpm/self-installer/${n.ref}/install.js`;n.default=n.url},34:function(r){r.exports=require("https")},87:function(r){r.exports=require("os")},89:function(r,n,e){"use strict";var i=this&&this.__awaiter||function(r,n,e,i){function adopt(r){return r instanceof e?r:new e(function(n){n(r)})}return new(e||(e=Promise))(function(e,o){function fulfilled(r){try{step(i.next(r))}catch(r){o(r)}}function rejected(r){try{step(i["throw"](r))}catch(r){o(r)}}function step(r){r.done?e(r.value):adopt(r.value).then(fulfilled,rejected)}step((i=i.apply(r,n||[])).next())})};var o=this&&this.__importStar||function(r){if(r&&r.__esModule)return r;var n={};if(r!=null)for(var e in r)if(Object.hasOwnProperty.call(r,e))n[e]=r[e];n["default"]=r;return n};Object.defineProperty(n,"__esModule",{value:true});const u=e(486);const f=o(e(87));const t=o(e(622));var c;(function(r){r[r["Success"]=0]="Success";r[r["Failure"]=1]="Failure"})(c=n.ExitCode||(n.ExitCode={}));function exportVariable(r,n){const e=u.toCommandValue(n);process.env[r]=e;u.issueCommand("set-env",{name:r},e)}n.exportVariable=exportVariable;function setSecret(r){u.issueCommand("add-mask",{},r)}n.setSecret=setSecret;function addPath(r){u.issueCommand("add-path",{},r);process.env["PATH"]=`${r}${t.delimiter}${process.env["PATH"]}`}n.addPath=addPath;function getInput(r,n){const e=process.env[`INPUT_${r.replace(/ /g,"_").toUpperCase()}`]||"";if(n&&n.required&&!e){throw new Error(`Input required and not supplied: ${r}`)}return e.trim()}n.getInput=getInput;function setOutput(r,n){u.issueCommand("set-output",{name:r},n)}n.setOutput=setOutput;function setCommandEcho(r){u.issue("echo",r?"on":"off")}n.setCommandEcho=setCommandEcho;function setFailed(r){process.exitCode=c.Failure;error(r)}n.setFailed=setFailed;function isDebug(){return process.env["RUNNER_DEBUG"]==="1"}n.isDebug=isDebug;function debug(r){u.issueCommand("debug",{},r)}n.debug=debug;function error(r){u.issue("error",r instanceof Error?r.toString():r)}n.error=error;function warning(r){u.issue("warning",r instanceof Error?r.toString():r)}n.warning=warning;function info(r){process.stdout.write(r+f.EOL)}n.info=info;function startGroup(r){u.issue("group",r)}n.startGroup=startGroup;function endGroup(){u.issue("endgroup")}n.endGroup=endGroup;function group(r,n){return i(this,void 0,void 0,function*(){startGroup(r);let e;try{e=yield n()}finally{endGroup()}return e})}n.group=group;function saveState(r,n){u.issueCommand("save-state",{name:r},n)}n.saveState=saveState;function getState(r){return process.env[`STATE_${r}`]||""}n.getState=getState},90:function(r,n,e){"use strict";var i=e(205);function resolveJavascriptRegExp(r){if(r===null)return false;if(r.length===0)return false;var n=r,e=/\/([gim]*)$/.exec(r),i="";if(n[0]==="/"){if(e)i=e[1];if(i.length>3)return false;if(n[n.length-i.length-1]!=="/")return false}return true}function constructJavascriptRegExp(r){var n=r,e=/\/([gim]*)$/.exec(r),i="";if(n[0]==="/"){if(e)i=e[1];n=n.slice(1,n.length-i.length-1)}return new RegExp(n,i)}function representJavascriptRegExp(r){var n="/"+r.source+"/";if(r.global)n+="g";if(r.multiline)n+="m";if(r.ignoreCase)n+="i";return n}function isRegExp(r){return Object.prototype.toString.call(r)==="[object RegExp]"}r.exports=new i("tag:yaml.org,2002:js/regexp",{kind:"scalar",resolve:resolveJavascriptRegExp,construct:constructJavascriptRegExp,predicate:isRegExp,represent:representJavascriptRegExp})},129:function(r){r.exports=require("child_process")},147:function(r,n,e){"use strict";var i=e(205);r.exports=new i("tag:yaml.org,2002:seq",{kind:"sequence",construct:function(r){return r!==null?r:[]}})},191:function(r,n,e){"use strict";var i=e(87);if(typeof i.homedir!=="undefined"){r.exports=i.homedir}else{r.exports=e(394)}},203:function(r,n,e){"use strict";Object.defineProperty(n,"__esModule",{value:true});function _interopDefault(r){return r&&typeof r==="object"&&"default"in r?r["default"]:r}var i=_interopDefault(e(413));var o=_interopDefault(e(605));var u=_interopDefault(e(835));var f=_interopDefault(e(34));var t=_interopDefault(e(761));const c=i.Readable;const s=Symbol("buffer");const l=Symbol("type");class Blob{constructor(){this[l]="";const r=arguments[0];const n=arguments[1];const e=[];let i=0;if(r){const n=r;const o=Number(n.length);for(let r=0;r<o;r++){const o=n[r];let u;if(o instanceof Buffer){u=o}else if(ArrayBuffer.isView(o)){u=Buffer.from(o.buffer,o.byteOffset,o.byteLength)}else if(o instanceof ArrayBuffer){u=Buffer.from(o)}else if(o instanceof Blob){u=o[s]}else{u=Line truncated
|
||||
module.exports=function(n,e){"use strict";var f={};function __webpack_require__(e){if(f[e]){return f[e].exports}var r=f[e]={i:e,l:false,exports:{}};n[e].call(r.exports,r,r.exports,__webpack_require__);r.l=true;return r.exports}__webpack_require__.ab=__dirname+"/";function startup(){return __webpack_require__(803)}return startup()}({0:function(n,e){"use strict";Object.defineProperty(e,"__esModule",{value:true});e.ref="301414cec74a2b6b63c95b42f2ad1790ccb980ed";e.url=`https://raw.githubusercontent.com/pnpm/self-installer/${e.ref}/install.js`;e.default=e.url},17:function(n){"use strict";n.exports=function generate__limitItems(n,e,f){var r=" ";var l=n.level;var s=n.dataLevel;var v=n.schema[e];var c=n.schemaPath+n.util.getProperty(e);var p=n.errSchemaPath+"/"+e;var g=!n.opts.allErrors;var b;var w="data"+(s||"");var d=n.opts.$data&&v&&v.$data,i;if(d){r+=" var schema"+l+" = "+n.util.getData(v.$data,s,n.dataPathArr)+"; ";i="schema"+l}else{i=v}var A=e=="maxItems"?">":"<";r+="if ( ";if(d){r+=" ("+i+" !== undefined && typeof "+i+" != 'number') || "}r+=" "+w+".length "+A+" "+i+") { ";var b=e;var j=j||[];j.push(r);r="";if(n.createErrors!==false){r+=" { keyword: '"+(b||"_limitItems")+"' , dataPath: (dataPath || '') + "+n.errorPath+" , schemaPath: "+n.util.toQuotedString(p)+" , params: { limit: "+i+" } ";if(n.opts.messages!==false){r+=" , message: 'should NOT have ";if(e=="maxItems"){r+="more"}else{r+="fewer"}r+=" than ";if(d){r+="' + "+i+" + '"}else{r+=""+v}r+=" items' "}if(n.opts.verbose){r+=" , schema: ";if(d){r+="validate.schema"+c}else{r+=""+v}r+=" , parentSchema: validate.schema"+n.schemaPath+" , data: "+w+" "}r+=" } "}else{r+=" {} "}var E=r;r=j.pop();if(!n.compositeRule&&g){if(n.async){r+=" throw new ValidationError(["+E+"]); "}else{r+=" validate.errors = ["+E+"]; return false; "}}else{r+=" var err = "+E+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; "}r+="} ";if(g){r+=" else { "}return r}},34:function(n){n.exports=require("https")},87:function(n){n.exports=require("os")},89:function(n,e,f){"use strict";var r=this&&this.__awaiter||function(n,e,f,r){function adopt(n){return n instanceof f?n:new f(function(e){e(n)})}return new(f||(f=Promise))(function(f,l){function fulfilled(n){try{step(r.next(n))}catch(n){l(n)}}function rejected(n){try{step(r["throw"](n))}catch(n){l(n)}}function step(n){n.done?f(n.value):adopt(n.value).then(fulfilled,rejected)}step((r=r.apply(n,e||[])).next())})};var l=this&&this.__importStar||function(n){if(n&&n.__esModule)return n;var e={};if(n!=null)for(var f in n)if(Object.hasOwnProperty.call(n,f))e[f]=n[f];e["default"]=n;return e};Object.defineProperty(e,"__esModule",{value:true});const s=f(486);const v=l(f(87));const c=l(f(622));var p;(function(n){n[n["Success"]=0]="Success";n[n["Failure"]=1]="Failure"})(p=e.ExitCode||(e.ExitCode={}));function exportVariable(n,e){const f=s.toCommandValue(e);process.env[n]=f;s.issueCommand("set-env",{name:n},f)}e.exportVariable=exportVariable;function setSecret(n){s.issueCommand("add-mask",{},n)}e.setSecret=setSecret;function addPath(n){s.issueCommand("add-path",{},n);process.env["PATH"]=`${n}${c.delimiter}${process.env["PATH"]}`}e.addPath=addPath;function getInput(n,e){const f=process.env[`INPUT_${n.replace(/ /g,"_").toUpperCase()}`]||"";if(e&&e.required&&!f){throw new Error(`Input required and not supplied: ${n}`)}return f.trim()}e.getInput=getInput;function setOutput(n,e){s.issueCommand("set-output",{name:n},e)}e.setOutput=setOutput;function setCommandEcho(n){s.issue("echo",n?"on":"off")}e.setCommandEcho=setCommandEcho;function setFailed(n){process.exitCode=p.Failure;error(n)}e.setFailed=setFailed;function isDebug(){return process.env["RUNNER_DEBUG"]==="1"}e.isDebug=isDebug;function debug(n){s.issueCommand("debug",{},n)}e.debug=debug;function error(n){s.issue("error",n instanceof Error?n.toString():n)}e.error=error;function warning(n){s.issue("warning",n instanceof Error?n.toString():n)}e.warning=warning;function info(n){process.stdout.write(n+v.EOL)}e.info=info;function startGroup(n){s.issue("group",n)}e.startGroup=startGroup;function endGroup(){s.issue("endgroup")}e.endGroup=endGroup;function group(n,e){return r(this,void 0,void 0,function*(){startGroup(n);let f;try{f=yield e()}finally{endGroup()}return f})}e.group=group;function saveState(n,e){s.issueCommand("save-state",{name:n},e)}e.saveState=saveState;function getState(n){return process.env[`STATE_${n}`]||""}e.getState=getState},90:function(n,e,f){"use strict";var r=f(205);function resolveJavascriptRegExp(n){if(n===null)return false;if(n.length===0)return false;var e=n,f=/\/([gim]*)$/.exec(n),r="";if(e[0]==="/"){if(f)r=f[1];if(r.length>3)return false;if(e[e.length-r.length-1]!=="/")return false}return true}function constructJavascriptRegExp(n){var e=n,f=/\/([gim]*)$/.exec(n),r="";if(e[0]==="/"){if(f)r=f[1];e=e.slice(1,e.length-r.length-1)}return new RegExp(e,r)}function representJavascriptRegExp(n){var e="/"+n.source+"/";if(n.global)e+="g";if(n.multiline)e+="m";ifLine truncated
|
||||
@@ -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",
|
||||
|
||||
Generated
+2
-6
@@ -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
|
||||
|
||||
+15
-1
@@ -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
|
||||
|
||||
@@ -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",
|
||||
|
||||
Reference in new issue
Block a user