mirror of
https://github.com/renovatebot/renovate.git
synced 2024-12-22 05:28:35 +00:00
95efd9f6fe
Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
67 lines
1.6 KiB
TypeScript
67 lines
1.6 KiB
TypeScript
import { z } from 'zod';
|
|
|
|
const UrlSchema = z.record(
|
|
z.string(),
|
|
z.union([z.string(), z.array(z.string())]),
|
|
);
|
|
|
|
export const MonorepoSchema = z.object({
|
|
repoGroups: UrlSchema,
|
|
orgGroups: UrlSchema,
|
|
patternGroups: UrlSchema,
|
|
});
|
|
|
|
const PackageRuleSchema = z.object({
|
|
matchCurrentVersion: z.string().optional(),
|
|
matchDatasources: z.array(z.string()),
|
|
matchPackageNames: z.array(z.string()),
|
|
replacementName: z.string().optional(),
|
|
replacementVersion: z.string().optional(),
|
|
description: z.string().optional(),
|
|
replacementNameTemplate: z.string().optional(),
|
|
});
|
|
|
|
const RuleSetSchema = z.object({
|
|
description: z.string(),
|
|
packageRules: z
|
|
.array(PackageRuleSchema)
|
|
.min(1)
|
|
.refine(
|
|
(rules) =>
|
|
rules.some(
|
|
(rule) =>
|
|
rule.replacementName !== undefined ||
|
|
rule.replacementNameTemplate !== undefined,
|
|
),
|
|
{
|
|
message:
|
|
'At least one package rule must use either the replacementName config option, or the replacementNameTemplate config option',
|
|
},
|
|
),
|
|
});
|
|
|
|
const AllSchema = z.object({
|
|
description: z.string(),
|
|
extends: z.array(z.string()),
|
|
ignoreDeps: z.array(z.string()).optional(),
|
|
});
|
|
|
|
export const ReplacementsSchema = z
|
|
.object({
|
|
$schema: z.string(),
|
|
all: AllSchema,
|
|
})
|
|
.catchall(RuleSetSchema);
|
|
|
|
export const ChangelogUrlsSchema = z
|
|
.object({
|
|
$schema: z.string(),
|
|
})
|
|
.catchall(z.record(z.string(), z.string().url()));
|
|
|
|
export const SourceUrlsSchema = z
|
|
.object({
|
|
$schema: z.string(),
|
|
})
|
|
.catchall(z.record(z.string(), z.string().url()));
|