mirror of
https://github.com/renovatebot/renovate.git
synced 2026-11-01 10:09:50 +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
63 lines
1.6 KiB
TypeScript
63 lines
1.6 KiB
TypeScript
import { isString } from '@sindresorhus/is';
|
|
import { z } from 'zod/v4';
|
|
import { MavenDatasource } from '../../../datasource/maven/index.ts';
|
|
import { id as versioning } from '../../../versioning/gradle/index.ts';
|
|
import type { PackageDependency } from '../../types.ts';
|
|
|
|
export const mavenRules = ['maven_install', '_maven_install'] as const;
|
|
|
|
const ArtifactSpec = z.union([
|
|
z.object({
|
|
group: z.string(),
|
|
artifact: z.string(),
|
|
version: z.string(),
|
|
}),
|
|
z
|
|
.object({
|
|
'0': z.string(),
|
|
'1': z.string(),
|
|
'2': z.string(),
|
|
})
|
|
.transform((x) => ({ group: x[0], artifact: x[1], version: x[2] })),
|
|
]);
|
|
type ArtifactSpec = z.infer<typeof ArtifactSpec>;
|
|
|
|
export const MavenTarget = z
|
|
.object({
|
|
rule: z.enum(mavenRules),
|
|
artifacts: z
|
|
.union([z.string(), ArtifactSpec])
|
|
.array()
|
|
.transform((xs) => {
|
|
const result: ArtifactSpec[] = [];
|
|
for (const x of xs) {
|
|
if (isString(x)) {
|
|
const [group, artifact, version] = x.split(':');
|
|
if (group && artifact && version) {
|
|
result.push({ group, artifact, version });
|
|
}
|
|
} else {
|
|
result.push(x);
|
|
}
|
|
}
|
|
|
|
return result;
|
|
}),
|
|
repositories: z.array(z.string()).optional(),
|
|
})
|
|
.transform(
|
|
({
|
|
rule: depType,
|
|
artifacts,
|
|
repositories: registryUrls,
|
|
}): PackageDependency[] =>
|
|
artifacts.map(({ group, artifact, version: currentValue }) => ({
|
|
datasource: MavenDatasource.id,
|
|
versioning,
|
|
depName: `${group}:${artifact}`,
|
|
currentValue,
|
|
depType,
|
|
registryUrls,
|
|
})),
|
|
);
|