Files
renovate/lib/modules/manager/flux/artifacts.ts
Jamie Tanna a36eed3365 chore(manager/flux): don't use shell execution to flux install (#45109)
As this is the only place in the codebase we're currently doing this, we
should remove the usage of `shell` semantics for file redirection, which
isn't needed.

Co-authored-by: Claude Sonnet 5 <jamie.tanna+claude-code@mend.io>
2026-08-06 10:02:30 +00:00

75 lines
2.1 KiB
TypeScript

import { logger } from '../../../logger/index.ts';
import { exec } from '../../../util/exec/index.ts';
import type { ExecOptions } from '../../../util/exec/types.ts';
import { readLocalFile, writeLocalFile } from '../../../util/fs/index.ts';
import type { UpdateArtifact, UpdateArtifactsResult } from '../types.ts';
import { isSystemManifest } from './common.ts';
import type { FluxManagerData } from './types.ts';
export async function updateArtifacts({
packageFileName,
updatedDeps,
}: UpdateArtifact<FluxManagerData>): Promise<UpdateArtifactsResult[] | null> {
const systemDep = updatedDeps[0];
if (!isSystemManifest(packageFileName) || !systemDep?.newVersion) {
return null;
}
const existingFileContent = await readLocalFile(packageFileName, 'utf8');
try {
logger.debug(`Updating Flux system manifests`);
const args: string[] = ['--export'];
if (systemDep.managerData?.components) {
args.push('--components', systemDep.managerData.components);
}
const cmd = [{ command: ['flux', 'install', ...args] }];
const execOptions: ExecOptions = {
docker: {},
toolConstraints: [
{
toolName: 'flux',
constraint: updatedDeps[0].newVersion,
},
],
};
const result = await exec(cmd, execOptions);
if (!result.stdout) {
logger.debug('Cannot read new flux file content');
return [
{
artifactError: {
fileName: packageFileName,
stderr: result.stderr,
},
},
];
}
await writeLocalFile(packageFileName, result.stdout);
const newFileContent = result.stdout;
if (newFileContent === existingFileContent) {
logger.debug('Flux contents are unchanged');
return null;
}
return [
{
file: {
type: 'addition',
path: packageFileName,
contents: newFileContent,
},
},
];
} catch (err) {
logger.debug({ err }, 'Error generating new Flux system manifests');
return [
{
artifactError: {
fileName: packageFileName,
stderr: err.message,
},
},
];
}
}