mirror of
https://github.com/renovatebot/renovate.git
synced 2026-10-25 23:11:31 +00:00
4a2578d18d
* build(deps): update dependency zod to v4 | datasource | package | from | to | | ---------- | ------- | ------- | ----- | | npm | zod | 3.25.76 | 4.3.6 | * fix: zod migration --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
73 lines
1.9 KiB
TypeScript
73 lines
1.9 KiB
TypeScript
import { z } from 'zod/v3';
|
|
import { logger } from '../../../logger/index.ts';
|
|
import {
|
|
Jsonc,
|
|
LooseArray,
|
|
LooseRecord,
|
|
withDebugMessage,
|
|
} from '../../../util/schema-utils/index.ts';
|
|
import { DevboxDatasource } from '../../datasource/devbox/index.ts';
|
|
import { api } from '../../versioning/devbox/index.ts';
|
|
import type { PackageDependency } from '../types.ts';
|
|
import { devboxToolVersioning } from './tool-versioning.ts';
|
|
|
|
const DevboxEntry = z
|
|
.array(z.string())
|
|
.min(1)
|
|
.transform(([depName, currentValue]) => {
|
|
const dep: PackageDependency = {
|
|
datasource: DevboxDatasource.id,
|
|
depName,
|
|
};
|
|
|
|
if (!currentValue) {
|
|
logger.trace(
|
|
{ depName },
|
|
'Devbox: skipping invalid devbox dependency in devbox JSON file.',
|
|
);
|
|
dep.skipReason = 'not-a-version';
|
|
return dep;
|
|
}
|
|
|
|
dep.currentValue = currentValue;
|
|
|
|
const versioning = devboxToolVersioning[depName];
|
|
if (versioning) {
|
|
dep.versioning = versioning.id;
|
|
}
|
|
|
|
if (
|
|
!(versioning?.api ?? api).isValid(currentValue) ||
|
|
!(versioning?.api ?? api).isSingleVersion(currentValue)
|
|
) {
|
|
logger.debug(
|
|
{ depName },
|
|
'Devbox: skipping invalid devbox dependency in devbox JSON file.',
|
|
);
|
|
dep.skipReason = 'invalid-version';
|
|
return dep;
|
|
}
|
|
|
|
return dep;
|
|
});
|
|
|
|
export const Devbox = Jsonc.pipe(
|
|
z.object({
|
|
packages: z
|
|
.union([
|
|
LooseArray(z.string().transform((pkg) => pkg.split('@'))),
|
|
LooseRecord(
|
|
z.union([
|
|
z.string(),
|
|
z
|
|
.object({ version: z.string() })
|
|
.transform(({ version }) => version),
|
|
]),
|
|
).transform((obj) => Object.entries(obj)),
|
|
])
|
|
.pipe(LooseArray(DevboxEntry)),
|
|
}),
|
|
)
|
|
.transform(({ packages }) => packages)
|
|
.catch(withDebugMessage([], 'Devbox: does not match schema'));
|