0
0
mirror of https://github.com/renovatebot/renovate.git synced 2024-12-22 13:38:32 +00:00
renovatebot_renovate/lib/modules/manager/pep621/artifacts.ts
2023-11-07 15:50:29 +00:00

39 lines
1.1 KiB
TypeScript

import is from '@sindresorhus/is';
import { writeLocalFile } from '../../../util/fs';
import type { UpdateArtifact, UpdateArtifactsResult } from '../types';
import { processors } from './processors';
import { parsePyProject } from './utils';
export async function updateArtifacts(
updateArtifact: UpdateArtifact,
): Promise<UpdateArtifactsResult[] | null> {
const { packageFileName, newPackageFileContent } = updateArtifact;
await writeLocalFile(packageFileName, newPackageFileContent);
const project = parsePyProject(packageFileName, newPackageFileContent);
if (is.nullOrUndefined(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 (is.array(artifactUpdates)) {
result.push(...artifactUpdates);
}
}
return result.length > 0 ? result : null;
}