mirror of
https://github.com/renovatebot/renovate.git
synced 2026-10-27 07:50:47 +00:00
15f4bd8eff
* chore: migrate from zod/v3 to zod/v4 This commit contains the logic changes * chore: migrate imports from zod/v3 to zod/v4 This contains import updates and adds explicit record keys as zod/v4 requires these now * ci: enforce usage of zod/v4
64 lines
1.7 KiB
TypeScript
64 lines
1.7 KiB
TypeScript
import { z } from 'zod/v4';
|
|
import {
|
|
LooseArray,
|
|
LooseRecord,
|
|
Yaml,
|
|
} from '../../../util/schema-utils/index.ts';
|
|
import { GitTagsDatasource } from '../../datasource/git-tags/index.ts';
|
|
import { id as semverVersioning } from '../../versioning/semver/index.ts';
|
|
import { getDep } from '../dockerfile/extract.ts';
|
|
import type { PackageDependency } from '../types.ts';
|
|
|
|
export const BatectConfig = Yaml.pipe(
|
|
z.object({
|
|
containers: LooseRecord(
|
|
z.string(),
|
|
z.object({ image: z.string() }).transform(({ image }) => image),
|
|
)
|
|
.transform((x) => Object.values(x))
|
|
.catch([]),
|
|
include: LooseArray(
|
|
z.union([
|
|
z.object({
|
|
type: z.literal('git'),
|
|
repo: z.string(),
|
|
ref: z.string(),
|
|
}),
|
|
z.object({
|
|
type: z.literal('file'),
|
|
path: z.string(),
|
|
}),
|
|
z.string().transform((path) => ({ type: 'file' as const, path })),
|
|
]),
|
|
).catch([]),
|
|
}),
|
|
).transform(({ containers, include }) => {
|
|
// TODO: @zharinov How to pass `registryAliases` to `getDep`?
|
|
const imageDependencies = containers.map((image) => getDep(image));
|
|
|
|
const bundleDependencies: PackageDependency[] = [];
|
|
const fileIncludes: string[] = [];
|
|
|
|
for (const item of include) {
|
|
if (item.type === 'git') {
|
|
bundleDependencies.push({
|
|
depName: item.repo,
|
|
currentValue: item.ref,
|
|
versioning: semverVersioning,
|
|
datasource: GitTagsDatasource.id,
|
|
commitMessageTopic: 'bundle {{depName}}',
|
|
});
|
|
} else {
|
|
fileIncludes.push(item.path);
|
|
}
|
|
}
|
|
|
|
return {
|
|
imageDependencies,
|
|
bundleDependencies,
|
|
fileIncludes,
|
|
};
|
|
});
|
|
|
|
export type BatectConfig = z.infer<typeof BatectConfig>;
|