renovate
Version:
Automated dependency updates. Flexible so you don't need to be.
67 lines (66 loc) • 2.45 kB
JavaScript
import "../../../constants/error-messages.js";
import { GlobalConfig } from "../../../config/global.js";
import { logger } from "../../../logger/index.js";
import { deleteLocalFile, ensureCacheDir, getSiblingFileName, readLocalFile, writeLocalFile } from "../../../util/fs/index.js";
import { exec } from "../../../util/exec/index.js";
import { isNonEmptyArray } from "@sindresorhus/is";
//#region lib/modules/manager/pixi/lockfile.ts
const commandLock = "pixi lock --no-progress --color=never --quiet";
/**
* Regenerate the sibling `pixi.lock` of a package file by running `pixi lock`.
*
* Shared by the standalone `pixi` manager and the `pep621` pixi processor.
*/
async function updatePixiLockfile({ packageFileName, updatedDeps, isLockFileMaintenance, constraint, newPackageFileContent }) {
if (!isNonEmptyArray(updatedDeps) && !isLockFileMaintenance) {
logger.debug("No updated pixi deps - returning null");
return null;
}
const lockFileName = getSiblingFileName(packageFileName, "pixi.lock");
const existingLockFileContent = await readLocalFile(lockFileName, "utf8");
if (!existingLockFileContent) {
logger.debug("No pixi.lock found");
return null;
}
if (!GlobalConfig.get("allowedUnsafeExecutions").includes("pixi")) {
logger.once.warn("`pixi lock` was requested to run, but `pixi` is not permitted in the allowedUnsafeExecutions");
return null;
}
try {
if (newPackageFileContent !== void 0) await writeLocalFile(packageFileName, newPackageFileContent);
if (isLockFileMaintenance) await deleteLocalFile(lockFileName);
const PIXI_CACHE_DIR = await ensureCacheDir("pixi");
await exec([commandLock], {
cwdFile: packageFileName,
extraEnv: {
PIXI_CACHE_DIR,
RATTLER_CACHE_DIR: PIXI_CACHE_DIR
},
docker: {},
toolConstraints: [{
toolName: "pixi",
constraint
}]
});
const newPixiLockContent = await readLocalFile(lockFileName, "utf8");
if (existingLockFileContent === newPixiLockContent) {
logger.debug(`${lockFileName} is unchanged`);
return null;
}
return [{ file: {
type: "addition",
path: lockFileName,
contents: newPixiLockContent
} }];
} catch (err) {
if (err.message === "temporary-error") throw err;
logger.debug({ err }, `Failed to update ${lockFileName} file`);
return [{ artifactError: {
fileName: lockFileName,
stderr: `${err}`
} }];
}
}
//#endregion
export { commandLock, updatePixiLockfile };
//# sourceMappingURL=lockfile.js.map