mirror of
https://github.com/pnpm/action-setup.git
synced 2026-06-27 15:38:01 +00:00
refactor: upgrade Zod to v4
Signed-off-by: Akihiro Nagai <77012577+314systems@users.noreply.github.com>
This commit is contained in:
parent
0ebf47130e
commit
2f88ccb3db
BIN
dist/index.js
vendored
BIN
dist/index.js
vendored
Binary file not shown.
@ -15,7 +15,7 @@
|
|||||||
"@types/node": "^22.0.0",
|
"@types/node": "^22.0.0",
|
||||||
"expand-tilde": "^2.0.2",
|
"expand-tilde": "^2.0.2",
|
||||||
"yaml": "^2.3.4",
|
"yaml": "^2.3.4",
|
||||||
"zod": "^3.22.4"
|
"zod": "^4.4.3"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"esbuild": "^0.27.4",
|
"esbuild": "^0.27.4",
|
||||||
|
|||||||
@ -33,8 +33,8 @@ importers:
|
|||||||
specifier: ^2.3.4
|
specifier: ^2.3.4
|
||||||
version: 2.7.0
|
version: 2.7.0
|
||||||
zod:
|
zod:
|
||||||
specifier: ^3.22.4
|
specifier: ^4.4.3
|
||||||
version: 3.24.1
|
version: 4.4.3
|
||||||
devDependencies:
|
devDependencies:
|
||||||
esbuild:
|
esbuild:
|
||||||
specifier: ^0.27.4
|
specifier: ^0.27.4
|
||||||
@ -493,6 +493,7 @@ packages:
|
|||||||
|
|
||||||
uuid@8.3.2:
|
uuid@8.3.2:
|
||||||
resolution: {integrity: sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==}
|
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
|
hasBin: true
|
||||||
|
|
||||||
webidl-conversions@3.0.1:
|
webidl-conversions@3.0.1:
|
||||||
@ -514,8 +515,8 @@ packages:
|
|||||||
engines: {node: '>= 14'}
|
engines: {node: '>= 14'}
|
||||||
hasBin: true
|
hasBin: true
|
||||||
|
|
||||||
zod@3.24.1:
|
zod@4.4.3:
|
||||||
resolution: {integrity: sha512-muH7gBL9sI1nciMZV67X5fTKKBLtwpZ5VBp1vsOQzj1MhrBZ4wlVCm3gedKZWLp0Oyel8sIGfeiz54Su+OVT+A==}
|
resolution: {integrity: sha512-ytENFjIJFl2UwYglde2jchW2Hwm4GJFLDiSXWdTrJQBIN9Fcyp7n4DhxJEiWNAJMV1/BqWfW/kkg71UDcHJyTQ==}
|
||||||
|
|
||||||
snapshots:
|
snapshots:
|
||||||
|
|
||||||
@ -993,4 +994,4 @@ snapshots:
|
|||||||
|
|
||||||
yaml@2.7.0: {}
|
yaml@2.7.0: {}
|
||||||
|
|
||||||
zod@3.24.1: {}
|
zod@4.4.3: {}
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import { getInput, error } from '@actions/core'
|
import { getInput, error } from '@actions/core'
|
||||||
import { parse as parseYaml } from 'yaml'
|
import { parse as parseYaml } from 'yaml'
|
||||||
import { z, ZodError } from 'zod'
|
import * as z from 'zod'
|
||||||
|
|
||||||
const RunInstallSchema = z.object({
|
const RunInstallSchema = z.object({
|
||||||
recursive: z.boolean().optional(),
|
recursive: z.boolean().optional(),
|
||||||
@ -15,27 +15,22 @@ const RunInstallInputSchema = z.union([
|
|||||||
z.array(RunInstallSchema),
|
z.array(RunInstallSchema),
|
||||||
])
|
])
|
||||||
|
|
||||||
export type RunInstallInput = z.infer<typeof RunInstallInputSchema>
|
|
||||||
export type RunInstall = z.infer<typeof RunInstallSchema>
|
export type RunInstall = z.infer<typeof RunInstallSchema>
|
||||||
|
|
||||||
export function parseRunInstall(inputName: string): RunInstall[] {
|
export function parseRunInstall(inputName: string): RunInstall[] {
|
||||||
const input = getInput(inputName, { required: true })
|
const input = getInput(inputName, { required: true })
|
||||||
const parsedInput: unknown = parseYaml(input)
|
const parsedInput: unknown = parseYaml(input)
|
||||||
|
|
||||||
try {
|
const result = RunInstallInputSchema.safeParse(parsedInput)
|
||||||
const result: RunInstallInput = RunInstallInputSchema.parse(parsedInput)
|
if (!result.success) {
|
||||||
if (!result) return []
|
|
||||||
if (result === true) return [{ recursive: true }]
|
|
||||||
if (Array.isArray(result)) return result
|
|
||||||
return [result]
|
|
||||||
} catch (exception: unknown) {
|
|
||||||
error(`Error for input "${inputName}" = ${input}`)
|
error(`Error for input "${inputName}" = ${input}`)
|
||||||
|
error(z.prettifyError(result.error))
|
||||||
if (exception instanceof ZodError) {
|
|
||||||
error(`Errors: ${exception.errors}`)
|
|
||||||
} else {
|
|
||||||
error(`Exception: ${exception}`)
|
|
||||||
}
|
|
||||||
process.exit(1)
|
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