mirror of
https://github.com/pnpm/action-setup.git
synced 2025-03-15 07:04:34 +08:00
remove usage of ts-schema-autogen
This commit is contained in:
parent
cd44942e14
commit
7b9ebc12e6
@ -16,10 +16,9 @@
|
|||||||
"ajv": "^8.12.0",
|
"ajv": "^8.12.0",
|
||||||
"expand-tilde": "^2.0.2",
|
"expand-tilde": "^2.0.2",
|
||||||
"fs-extra": "^11.2.0",
|
"fs-extra": "^11.2.0",
|
||||||
"js-yaml": "^4.1.0"
|
"yaml": "^2.3.4"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@ts-schema-autogen/cli": "^0.1.2",
|
|
||||||
"@vercel/ncc": "^0.38.1",
|
"@vercel/ncc": "^0.38.1",
|
||||||
"typescript": "^5.3.3"
|
"typescript": "^5.3.3"
|
||||||
}
|
}
|
||||||
|
@ -1,21 +0,0 @@
|
|||||||
{
|
|
||||||
"$schema": "https://raw.githubusercontent.com/ksxnodeapps/ts-schema-autogen/master/packages/schemas/config.schema.json",
|
|
||||||
"instruction": {
|
|
||||||
"compilerOptions": {
|
|
||||||
"strict": true,
|
|
||||||
"target": "ES2018",
|
|
||||||
"lib": [
|
|
||||||
"ES2018",
|
|
||||||
"ES2019",
|
|
||||||
"ES2020",
|
|
||||||
"ESNext"
|
|
||||||
],
|
|
||||||
"moduleResolution": "Node",
|
|
||||||
"esModuleInterop": true,
|
|
||||||
"resolveJsonModule": true
|
|
||||||
},
|
|
||||||
"input": "run-install.ts",
|
|
||||||
"symbol": "RunInstallInput",
|
|
||||||
"output": "run-install-input.schema.json"
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,39 +0,0 @@
|
|||||||
{
|
|
||||||
"anyOf": [
|
|
||||||
{
|
|
||||||
"$ref": "#/definitions/RunInstall"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "array",
|
|
||||||
"items": {
|
|
||||||
"$ref": "#/definitions/RunInstall"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": [
|
|
||||||
"null",
|
|
||||||
"boolean"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"definitions": {
|
|
||||||
"RunInstall": {
|
|
||||||
"type": "object",
|
|
||||||
"properties": {
|
|
||||||
"recursive": {
|
|
||||||
"type": "boolean"
|
|
||||||
},
|
|
||||||
"cwd": {
|
|
||||||
"type": "string"
|
|
||||||
},
|
|
||||||
"args": {
|
|
||||||
"type": "array",
|
|
||||||
"items": {
|
|
||||||
"type": "string"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"$schema": "http://json-schema.org/draft-07/schema#"
|
|
||||||
}
|
|
@ -1,8 +1,5 @@
|
|||||||
import { getInput, error, InputOptions } from '@actions/core'
|
import { getInput,InputOptions } from '@actions/core'
|
||||||
import Ajv from 'ajv'
|
import { parse } from 'yaml'
|
||||||
import { load } from 'js-yaml'
|
|
||||||
import process from 'process'
|
|
||||||
import runInstallSchema from './run-install-input.schema.json'
|
|
||||||
|
|
||||||
export interface RunInstall {
|
export interface RunInstall {
|
||||||
readonly recursive?: boolean
|
readonly recursive?: boolean
|
||||||
@ -21,19 +18,43 @@ const options: InputOptions = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function parseRunInstall(name: string): RunInstall[] {
|
export function parseRunInstall(name: string): RunInstall[] {
|
||||||
const result: RunInstallInput = load(getInput(name, options)) as any
|
const input: any = parse(getInput(name, options))
|
||||||
const ajv = new Ajv({
|
|
||||||
allErrors: true,
|
if (!input) return []
|
||||||
})
|
if (input === true) return [{ recursive: true }]
|
||||||
const validate = ajv.compile(runInstallSchema)
|
|
||||||
if (!validate(result)) {
|
validateRunInstallInput(input)
|
||||||
for (const errorItem of validate.errors!) {
|
|
||||||
error(`with.run_install${errorItem.dataPath}: ${errorItem.message}`)
|
if (Array.isArray(input)) return input
|
||||||
}
|
|
||||||
return process.exit(1)
|
return input;
|
||||||
}
|
|
||||||
if (!result) return []
|
|
||||||
if (result === true) return [{ recursive: true }]
|
|
||||||
if (Array.isArray(result)) return result
|
|
||||||
return [result]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function validateRunInstallInput(input: any) {
|
||||||
|
if (Array.isArray(input)) {
|
||||||
|
for (const entry of input) {
|
||||||
|
validateRunInstallEntry(entry)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
validateRunInstallEntry(input)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function validateRunInstallEntry(input: any) {
|
||||||
|
if (typeof input !== 'object') {
|
||||||
|
throw new Error('Invalid input for run_install')
|
||||||
|
}
|
||||||
|
|
||||||
|
if (input.recursive !== undefined && typeof input.recursive !== 'boolean') {
|
||||||
|
throw new Error('Invalid input for run_install.recursive')
|
||||||
|
}
|
||||||
|
|
||||||
|
if (input.cwd !== undefined && typeof input.cwd !== 'string') {
|
||||||
|
throw new Error('Invalid input for run_install.cwd')
|
||||||
|
}
|
||||||
|
|
||||||
|
if (input.args !== undefined && !Array.isArray(input.args)) {
|
||||||
|
throw new Error('Invalid input for run_install.args')
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user