mirror of
https://github.com/renovatebot/renovate.git
synced 2025-05-12 23:51:55 +00:00

Co-authored-by: Nicolas Bender <nicolas.bender@sap.com> Co-authored-by: HonkingGoose <34918129+HonkingGoose@users.noreply.github.com> Co-authored-by: Michael Kriese <michael.kriese@visualon.de> Co-authored-by: Pavel Busko <pavel.busko@sap.com> Co-authored-by: Johannes Dillmann <j.dillmann@sap.com> Co-authored-by: Michael Kriese <michael.kriese@gmx.de>
48 lines
1.1 KiB
TypeScript
48 lines
1.1 KiB
TypeScript
import { z } from 'zod';
|
|
import { Toml } from '../../../util/schema-utils';
|
|
|
|
const BuildpackByName = z.object({
|
|
id: z.string(),
|
|
version: z.string().optional(),
|
|
});
|
|
|
|
const BuildpackByURI = z.object({
|
|
uri: z.string(),
|
|
});
|
|
|
|
const BuildpackGroup = BuildpackByName.or(BuildpackByURI);
|
|
|
|
type BuildpackByName = z.infer<typeof BuildpackByName>;
|
|
type BuildpackByURI = z.infer<typeof BuildpackByURI>;
|
|
type BuildpackGroup = z.infer<typeof BuildpackGroup>;
|
|
|
|
export function isBuildpackByName(
|
|
group: BuildpackGroup,
|
|
): group is BuildpackByName {
|
|
return 'id' in group;
|
|
}
|
|
|
|
export function isBuildpackByURI(
|
|
group: BuildpackGroup,
|
|
): group is BuildpackByURI {
|
|
return 'uri' in group;
|
|
}
|
|
|
|
const IoBuildpacks = z.object({
|
|
builder: z.string().optional(),
|
|
group: z.array(BuildpackGroup).optional(),
|
|
});
|
|
|
|
export const ProjectDescriptor = z.object({
|
|
_: z.object({
|
|
'schema-version': z.string(),
|
|
}),
|
|
io: z
|
|
.object({
|
|
buildpacks: IoBuildpacks.optional(),
|
|
})
|
|
.optional(),
|
|
});
|
|
|
|
export type ProjectDescriptor = z.infer<typeof ProjectDescriptor>;
|
|
export const ProjectDescriptorToml = Toml.pipe(ProjectDescriptor);
|