Files
renovate/lib/modules/manager/pep621/artifacts.ts
Sergei Zharinov 930cf6633c refactor: Rewrite imports with .ts extensions (#40700)
fix: Additional vi.mock path corrections and prettier formatting
2026-01-26 22:48:17 +00:00

39 lines
1.1 KiB
TypeScript

import { isArray, isNullOrUndefined } from '@sindresorhus/is';
import { writeLocalFile } from '../../../util/fs/index.ts';
import type { UpdateArtifact, UpdateArtifactsResult } from '../types.ts';
import { parsePyProject } from './extract.ts';
import { processors } from './processors/index.ts';
export async function updateArtifacts(
updateArtifact: UpdateArtifact,
): Promise<UpdateArtifactsResult[] | null> {
const { packageFileName, newPackageFileContent } = updateArtifact;
await writeLocalFile(packageFileName, newPackageFileContent);
const project = parsePyProject(newPackageFileContent, packageFileName);
if (isNullOrUndefined(project)) {
return [
{
artifactError: {
stderr: 'Failed to parse new package file content',
},
},
];
}
// process specific tool sets
const result: UpdateArtifactsResult[] = [];
for (const processor of processors) {
const artifactUpdates = await processor.updateArtifacts(
updateArtifact,
project,
);
if (isArray(artifactUpdates)) {
result.push(...artifactUpdates);
}
}
return result.length > 0 ? result : null;
}