mirror of
https://github.com/renovatebot/renovate.git
synced 2024-12-22 13:38:32 +00:00
dcaf51c9f7
Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
30 lines
876 B
TypeScript
30 lines
876 B
TypeScript
import is from '@sindresorhus/is';
|
|
import { z } from 'zod';
|
|
import { Toml } from '../../../util/schema-utils';
|
|
import { depTypes, pep508ToPackageDependency } from '../pep621/utils';
|
|
import type { PackageFileContent } from '../types';
|
|
|
|
const Pep723Dep = z
|
|
.string()
|
|
.transform((dep) => pep508ToPackageDependency(depTypes.dependencies, dep));
|
|
|
|
export const Pep723Schema = Toml.pipe(
|
|
z
|
|
.object({
|
|
'requires-python': z.string().optional(),
|
|
dependencies: z
|
|
.array(Pep723Dep)
|
|
.transform((deps) => deps.filter((dep) => !!dep))
|
|
.optional(),
|
|
})
|
|
.transform(({ 'requires-python': requiresPython, dependencies }) => {
|
|
const res: PackageFileContent = { deps: dependencies ?? [] };
|
|
|
|
if (is.nonEmptyString(requiresPython)) {
|
|
res.extractedConstraints = { python: requiresPython };
|
|
}
|
|
|
|
return res;
|
|
}),
|
|
);
|