mirror of
https://github.com/renovatebot/renovate.git
synced 2026-10-25 23:11:31 +00:00
bf5ff94d28
Migrate apm, bun, cargo, cocoapods, composer, conan, copier, deno,
devbox, gomod, helmv3, jsonnet-bundler, kustomize, mix, nuget and vendir
onto `fileAddition()`, `artifactError()` and `artifactErrorResult()`.
copier's private `artifactError()` is replaced by the shared one.
Behaviour change: artifact error text now comes from
`artifactErrorMessageFromExecError` everywhere, i.e. a non-blank
`err.stderr`, else a non-blank `err.stdout`, else `err.message`.
Previously apm used `${err}` ("Error: " prefix), cocoapods used a
nullish coalesce that kept an empty stderr, nuget preferred stdout over
stderr, and jsonnet-bundler emitted an undefined stderr with no
fallback. The rest used `err.message` only and are unchanged for errors
without output.
112 lines
3.0 KiB
TypeScript
112 lines
3.0 KiB
TypeScript
import { quote } from 'shlex';
|
|
import { TEMPORARY_ERROR } from '../../../constants/error-messages.ts';
|
|
import { logger } from '../../../logger/index.ts';
|
|
import type { ExecOptions } from '../../../util/exec/types.ts';
|
|
import {
|
|
findLocalSiblingOrParent,
|
|
readLocalFile,
|
|
writeLocalFile,
|
|
} from '../../../util/fs/index.ts';
|
|
import { withGitEnvironment } from '../../../util/git/exec.ts';
|
|
import type { UpdateArtifact, UpdateArtifactsResult } from '../types.ts';
|
|
import {
|
|
artifactErrorResult,
|
|
fileAddition,
|
|
resolveToolConstraint,
|
|
} from '../util.ts';
|
|
|
|
const gitExec = withGitEnvironment(['conan']);
|
|
|
|
async function conanLockUpdate(
|
|
conanFilePath: string,
|
|
isLockFileMaintenance: boolean | undefined,
|
|
conanConstraint?: string,
|
|
pythonConstraint?: string,
|
|
): Promise<void> {
|
|
const command = `conan lock create ${quote(conanFilePath)}${isLockFileMaintenance ? ' --lockfile=""' : ''}`;
|
|
|
|
const execOptions: ExecOptions = {
|
|
toolConstraints: [
|
|
{
|
|
toolName: 'python',
|
|
constraint: pythonConstraint,
|
|
},
|
|
{
|
|
toolName: 'conan',
|
|
constraint: conanConstraint,
|
|
},
|
|
],
|
|
docker: {},
|
|
};
|
|
|
|
await gitExec(command, execOptions);
|
|
}
|
|
|
|
export async function updateArtifacts(
|
|
updateArtifact: UpdateArtifact,
|
|
): Promise<UpdateArtifactsResult[] | null> {
|
|
const { packageFileName, updatedDeps, newPackageFileContent, config } =
|
|
updateArtifact;
|
|
|
|
logger.trace(`conan.updateArtifacts(${packageFileName})`);
|
|
|
|
const { isLockFileMaintenance } = config;
|
|
|
|
if (updatedDeps.length === 0 && !isLockFileMaintenance) {
|
|
logger.trace('No conan.lock dependencies to update');
|
|
return null;
|
|
}
|
|
|
|
const lockFileName = await findLocalSiblingOrParent(
|
|
packageFileName,
|
|
'conan.lock',
|
|
);
|
|
if (!lockFileName) {
|
|
logger.trace('No conan.lock found');
|
|
return null;
|
|
}
|
|
|
|
const existingLockFileContent = await readLocalFile(lockFileName);
|
|
if (!existingLockFileContent) {
|
|
logger.debug(`${lockFileName} read operation failed`);
|
|
return null;
|
|
}
|
|
|
|
try {
|
|
await writeLocalFile(packageFileName, newPackageFileContent);
|
|
|
|
logger.trace(`Updating ${lockFileName}`);
|
|
await conanLockUpdate(
|
|
packageFileName,
|
|
isLockFileMaintenance,
|
|
await resolveToolConstraint(config, 'conan'),
|
|
await resolveToolConstraint(config, 'python'),
|
|
);
|
|
|
|
const newLockFileContent = await readLocalFile(lockFileName);
|
|
if (!newLockFileContent) {
|
|
logger.debug(`New ${lockFileName} read operation failed`);
|
|
return null;
|
|
}
|
|
|
|
if (existingLockFileContent === newLockFileContent) {
|
|
logger.trace(`${lockFileName} is unchanged`);
|
|
return null;
|
|
}
|
|
|
|
logger.trace(`Returning updated ${lockFileName}`);
|
|
return [fileAddition(lockFileName, newLockFileContent)];
|
|
} catch (err) {
|
|
if (err.message === TEMPORARY_ERROR) {
|
|
throw err;
|
|
}
|
|
|
|
logger.debug(
|
|
{ err, packageFileName, lockFileName },
|
|
'Lockfile update failed',
|
|
);
|
|
|
|
return artifactErrorResult(lockFileName, err);
|
|
}
|
|
}
|