mirror of
https://github.com/renovatebot/renovate.git
synced 2026-10-25 23:11:31 +00:00
c41b46bac3
* ci(linter): add renovate/logger-static-message rule Adds a custom oxlint rule that enforces a static msg component for logger.warn/error/fatal calls (including logger.once variants) so the messages can be grouped in metrics and error catching services, per docs/development/best-practices.md. It also flags metadata properties named 'error' that hold error-ish values, because the bunyan serializer only handles the 'err' key. The rule is enabled as an error for lib/ production code and disabled for spec files. All 33 pre-existing violations are fixed by moving interpolated values into the metadata object, making messages static, and renaming 'error' metadata keys to 'err'. Affected log-message assertions in co-located specs are updated accordingly. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * ci: ignore validator output * fixup new merged in log messages --------- Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
78 lines
2.1 KiB
TypeScript
78 lines
2.1 KiB
TypeScript
import { GlobalConfig } from '../../../config/global.ts';
|
|
import { TEMPORARY_ERROR } from '../../../constants/error-messages.ts';
|
|
import { logger } from '../../../logger/index.ts';
|
|
import { exec } from '../../../util/exec/index.ts';
|
|
import type { ExecOptions } from '../../../util/exec/types.ts';
|
|
import { deleteLocalFile, readLocalFile } from '../../../util/fs/index.ts';
|
|
import { getRepoStatus } from '../../../util/git/index.ts';
|
|
import type { UpdateArtifactsResult } from '../types.ts';
|
|
|
|
export async function updateBazelLockfile(
|
|
lockFileName: string,
|
|
cwdFile: string,
|
|
isLockFileMaintenance: boolean | undefined,
|
|
bazeliskConstraint: string | undefined,
|
|
): Promise<UpdateArtifactsResult[] | null> {
|
|
try {
|
|
const allowlist = GlobalConfig.get('allowedUnsafeExecutions');
|
|
|
|
const command = 'bazel mod deps --lockfile_mode=update';
|
|
|
|
if (!allowlist.includes('bazelModDeps')) {
|
|
logger.once.warn(
|
|
{ command },
|
|
'Bazel command was requested to run, but `bazelModDeps` is not permitted in the allowedUnsafeExecutions',
|
|
);
|
|
return null;
|
|
}
|
|
|
|
if (isLockFileMaintenance) {
|
|
await deleteLocalFile(lockFileName);
|
|
}
|
|
|
|
const execOptions: ExecOptions = {
|
|
cwdFile,
|
|
docker: {},
|
|
toolConstraints: [
|
|
{ toolName: 'bazelisk', constraint: bazeliskConstraint },
|
|
],
|
|
};
|
|
await exec(command, execOptions);
|
|
|
|
const status = await getRepoStatus();
|
|
if (
|
|
!status.modified.includes(lockFileName) &&
|
|
!status.not_added?.includes(lockFileName)
|
|
) {
|
|
return null;
|
|
}
|
|
|
|
const newLockContent = await readLocalFile(lockFileName, 'utf8');
|
|
return [
|
|
{
|
|
file: {
|
|
type: 'addition',
|
|
path: lockFileName,
|
|
contents: newLockContent,
|
|
},
|
|
},
|
|
];
|
|
} catch (err) {
|
|
if (err.message === TEMPORARY_ERROR) {
|
|
throw err;
|
|
}
|
|
logger.warn(
|
|
{ lockFile: lockFileName, err },
|
|
'Failed to update MODULE.bazel.lock',
|
|
);
|
|
return [
|
|
{
|
|
artifactError: {
|
|
fileName: lockFileName,
|
|
stderr: err.message,
|
|
},
|
|
},
|
|
];
|
|
}
|
|
}
|