mirror of
https://github.com/pnpm/action-setup.git
synced 2025-03-15 15:05:12 +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",
|
||||
"expand-tilde": "^2.0.2",
|
||||
"fs-extra": "^11.2.0",
|
||||
"js-yaml": "^4.1.0"
|
||||
"yaml": "^2.3.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@ts-schema-autogen/cli": "^0.1.2",
|
||||
"@vercel/ncc": "^0.38.1",
|
||||
"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 Ajv from 'ajv'
|
||||
import { load } from 'js-yaml'
|
||||
import process from 'process'
|
||||
import runInstallSchema from './run-install-input.schema.json'
|
||||
import { getInput,InputOptions } from '@actions/core'
|
||||
import { parse } from 'yaml'
|
||||
|
||||
export interface RunInstall {
|
||||
readonly recursive?: boolean
|
||||
@ -21,19 +18,43 @@ const options: InputOptions = {
|
||||
}
|
||||
|
||||
export function parseRunInstall(name: string): RunInstall[] {
|
||||
const result: RunInstallInput = load(getInput(name, options)) as any
|
||||
const ajv = new Ajv({
|
||||
allErrors: true,
|
||||
})
|
||||
const validate = ajv.compile(runInstallSchema)
|
||||
if (!validate(result)) {
|
||||
for (const errorItem of validate.errors!) {
|
||||
error(`with.run_install${errorItem.dataPath}: ${errorItem.message}`)
|
||||
}
|
||||
return process.exit(1)
|
||||
}
|
||||
if (!result) return []
|
||||
if (result === true) return [{ recursive: true }]
|
||||
if (Array.isArray(result)) return result
|
||||
return [result]
|
||||
const input: any = parse(getInput(name, options))
|
||||
|
||||
if (!input) return []
|
||||
if (input === true) return [{ recursive: true }]
|
||||
|
||||
validateRunInstallInput(input)
|
||||
|
||||
if (Array.isArray(input)) return input
|
||||
|
||||
return input;
|
||||
}
|
||||
|
||||
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