mirror of
https://github.com/renovatebot/renovate.git
synced 2026-11-01 02:00:10 +00:00
46bb8f2ddc
As per a follow-up change that will use `getWithSchemaFields` and `determineDependencyToUpdate` from a future built-in Actions table generator. Co-Authored-By: Claude Sonnet 5 <jamie.tanna+claude-code@mend.io>
33 lines
995 B
TypeScript
33 lines
995 B
TypeScript
import { z } from 'zod/v4';
|
|
import type { CommunityActionConfig } from '../../../../lib/modules/manager/github-actions/types.ts';
|
|
|
|
export function getWithSchemaFields(
|
|
schema: CommunityActionConfig['withSchema'],
|
|
): string[] {
|
|
if (!schema) {
|
|
return ['version'];
|
|
}
|
|
// `z.object({...}).transform(...)` produces a ZodPipe in Zod v4, where
|
|
// `def.in` is the source ZodObject. Walk through any pipes until we hit it.
|
|
let current: z.ZodType = schema;
|
|
while ('in' in current.def) {
|
|
current = current.def.in as z.ZodType;
|
|
}
|
|
if (current instanceof z.ZodObject) {
|
|
return Object.keys(current.shape);
|
|
}
|
|
return ['version'];
|
|
}
|
|
|
|
export function determineDependencyToUpdate({
|
|
depName,
|
|
packageName,
|
|
}: CommunityActionConfig): string {
|
|
if (!depName && !packageName) {
|
|
// some actions determine the depName and packageName dynamically
|
|
return '(determined from `with` input(s))';
|
|
}
|
|
|
|
return `[\`${depName ?? packageName}\`](https://github.com/${packageName})`;
|
|
}
|