mirror of
https://github.com/pnpm/action-setup.git
synced 2026-06-16 16:23:54 +00:00
Merge 24d83a90d8 into 0e279bb959
This commit is contained in:
commit
917cf9d84b
BIN
dist/index.js
vendored
BIN
dist/index.js
vendored
Binary file not shown.
@ -15,7 +15,7 @@
|
||||
"@types/node": "^22.0.0",
|
||||
"expand-tilde": "^2.0.2",
|
||||
"yaml": "^2.3.4",
|
||||
"zod": "^3.22.4"
|
||||
"zod": "^4.4.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"esbuild": "^0.27.4",
|
||||
|
||||
@ -33,8 +33,8 @@ importers:
|
||||
specifier: ^2.3.4
|
||||
version: 2.7.0
|
||||
zod:
|
||||
specifier: ^3.22.4
|
||||
version: 3.24.1
|
||||
specifier: ^4.4.3
|
||||
version: 4.4.3
|
||||
devDependencies:
|
||||
esbuild:
|
||||
specifier: ^0.27.4
|
||||
@ -493,6 +493,7 @@ packages:
|
||||
|
||||
uuid@8.3.2:
|
||||
resolution: {integrity: sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==}
|
||||
deprecated: uuid@10 and below is no longer supported. For ESM codebases, update to uuid@latest. For CommonJS codebases, use uuid@11 (but be aware this version will likely be deprecated in 2028).
|
||||
hasBin: true
|
||||
|
||||
webidl-conversions@3.0.1:
|
||||
@ -514,8 +515,8 @@ packages:
|
||||
engines: {node: '>= 14'}
|
||||
hasBin: true
|
||||
|
||||
zod@3.24.1:
|
||||
resolution: {integrity: sha512-muH7gBL9sI1nciMZV67X5fTKKBLtwpZ5VBp1vsOQzj1MhrBZ4wlVCm3gedKZWLp0Oyel8sIGfeiz54Su+OVT+A==}
|
||||
zod@4.4.3:
|
||||
resolution: {integrity: sha512-ytENFjIJFl2UwYglde2jchW2Hwm4GJFLDiSXWdTrJQBIN9Fcyp7n4DhxJEiWNAJMV1/BqWfW/kkg71UDcHJyTQ==}
|
||||
|
||||
snapshots:
|
||||
|
||||
@ -993,4 +994,4 @@ snapshots:
|
||||
|
||||
yaml@2.7.0: {}
|
||||
|
||||
zod@3.24.1: {}
|
||||
zod@4.4.3: {}
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { getInput, error } from '@actions/core'
|
||||
import { parse as parseYaml } from 'yaml'
|
||||
import { z, ZodError } from 'zod'
|
||||
import * as z from 'zod'
|
||||
|
||||
const RunInstallSchema = z.object({
|
||||
recursive: z.boolean().optional(),
|
||||
@ -15,27 +15,22 @@ const RunInstallInputSchema = z.union([
|
||||
z.array(RunInstallSchema),
|
||||
])
|
||||
|
||||
export type RunInstallInput = z.infer<typeof RunInstallInputSchema>
|
||||
export type RunInstall = z.infer<typeof RunInstallSchema>
|
||||
|
||||
export function parseRunInstall(inputName: string): RunInstall[] {
|
||||
const input = getInput(inputName, { required: true })
|
||||
const parsedInput: unknown = parseYaml(input)
|
||||
|
||||
try {
|
||||
const result: RunInstallInput = RunInstallInputSchema.parse(parsedInput)
|
||||
if (!result) return []
|
||||
if (result === true) return [{ recursive: true }]
|
||||
if (Array.isArray(result)) return result
|
||||
return [result]
|
||||
} catch (exception: unknown) {
|
||||
const result = RunInstallInputSchema.safeParse(parsedInput)
|
||||
if (!result.success) {
|
||||
error(`Error for input "${inputName}" = ${input}`)
|
||||
|
||||
if (exception instanceof ZodError) {
|
||||
error(`Errors: ${exception.errors}`)
|
||||
} else {
|
||||
error(`Exception: ${exception}`)
|
||||
}
|
||||
error(z.prettifyError(result.error))
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
const { data } = result
|
||||
if (!data) return []
|
||||
if (data === true) return [{ recursive: true }]
|
||||
if (Array.isArray(data)) return data
|
||||
return [data]
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user