mirror of
https://github.com/renovatebot/renovate.git
synced 2026-10-25 23:11:31 +00:00
2d1e57532f
As `fileName` makes more sense (as it's not always a lock file we're updating). Also, if you set `fileName`, it would never actually output the filename. This renames the usages of `lockFile` to `fileName`. Co-authored-by: Claude Sonnet 4.5 <jamie.tanna+github-copilot@mend.io>
48 lines
1.2 KiB
TypeScript
48 lines
1.2 KiB
TypeScript
import { logger } from '../../../logger/index.ts';
|
|
import { Http } from '../../../util/http/index.ts';
|
|
import type { UpdateArtifact, UpdateArtifactsResult } from '../types.ts';
|
|
|
|
const http = new Http('batect-wrapper');
|
|
|
|
async function updateArtifact(
|
|
path: string,
|
|
fileName: string,
|
|
version: string,
|
|
): Promise<UpdateArtifactsResult> {
|
|
const url = `https://github.com/batect/batect/releases/download/${version}/${fileName}`;
|
|
|
|
try {
|
|
const response = await http.getText(url);
|
|
const contents = response.body;
|
|
|
|
return {
|
|
file: { type: 'addition', path, contents },
|
|
};
|
|
} catch (err) {
|
|
const errorDescription: string = err.toString();
|
|
|
|
return {
|
|
artifactError: {
|
|
fileName: path,
|
|
stderr: `HTTP GET ${url} failed: ${errorDescription}`,
|
|
},
|
|
};
|
|
}
|
|
}
|
|
|
|
export async function updateArtifacts({
|
|
packageFileName,
|
|
config,
|
|
}: UpdateArtifact): Promise<UpdateArtifactsResult[] | null> {
|
|
const version = config.newVersion!;
|
|
|
|
logger.debug(
|
|
`Updating Batect wrapper scripts for ${packageFileName} to ${version}`,
|
|
);
|
|
|
|
return [
|
|
await updateArtifact(packageFileName, 'batect', version),
|
|
await updateArtifact(`${packageFileName}.cmd`, 'batect.cmd', version),
|
|
];
|
|
}
|