Skip to content

Commit

Permalink
fix: resolve the lockFileMaintenance not working
Browse files Browse the repository at this point in the history
  • Loading branch information
kayw-geek committed Nov 21, 2024
1 parent fa947a8 commit 0877eb2
Show file tree
Hide file tree
Showing 13 changed files with 16 additions and 17 deletions.
4 changes: 2 additions & 2 deletions lib/modules/manager/bundler/artifacts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export async function updateArtifacts(

const commands: string[] = [];

if (config.isLockFileMaintenance) {
if (config.updateType === 'lockFileMaintenance') {
commands.push('bundler lock --update');
} else {
const bundlerUpgraded = updatedDeps
Expand Down Expand Up @@ -289,7 +289,7 @@ export async function updateArtifacts(
if (
recursionLimit > 0 &&
resolveMatches.length &&
!config.isLockFileMaintenance
config.updateType !== 'lockFileMaintenance'
) {
logger.debug(
{ resolveMatches, updatedDeps },
Expand Down
2 changes: 1 addition & 1 deletion lib/modules/manager/composer/artifacts.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -725,8 +725,8 @@ describe('modules/manager/composer/artifacts', () => {
updatedDeps: [],
newPackageFileContent: '{}',
config: {
updateType:"lockFileMaintenance",
...config,
isLockFileMaintenance: true,
},
}),
).toEqual([
Expand Down
3 changes: 2 additions & 1 deletion lib/modules/manager/composer/artifacts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ export async function updateArtifacts({

const file = Json.pipe(PackageFile).parse(newPackageFileContent);

const isLockFileMaintenance = config.updateType === 'lockFileMaintenance';
const lockFileName = packageFileName.replace(regEx(/\.json$/), '.lock');
const lockfile = await z
.string()
Expand Down Expand Up @@ -174,7 +175,7 @@ export async function updateArtifacts({

const cmd = 'composer';
let args: string;
if (config.isLockFileMaintenance) {
if (isLockFileMaintenance) {
args = 'update';
} else {
args =
Expand Down
4 changes: 2 additions & 2 deletions lib/modules/manager/gradle/artifacts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ export async function updateArtifacts({
}

if (
config.isLockFileMaintenance &&
config.updateType === 'lockFileMaintenance' &&
(!isGradleBuildFile(packageFileName) ||
dirname(packageFileName) !== dirname(gradlewFile))
) {
Expand Down Expand Up @@ -205,7 +205,7 @@ export async function updateArtifacts({
.join(' ')}`;

if (
config.isLockFileMaintenance === true ||
config.updateType === 'lockFileMaintenance' ||
!updatedDeps.length ||
isGcvPropsFile(packageFileName)
) {
Expand Down
2 changes: 1 addition & 1 deletion lib/modules/manager/jsonnet-bundler/artifacts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export async function updateArtifacts(
};

try {
if (config.isLockFileMaintenance) {
if (config.updateType === 'lockFileMaintenance') {
await exec('jb update', execOptions);
} else {
const dependencyUrls = updatedDeps.map(dependencyUrl);
Expand Down
3 changes: 1 addition & 2 deletions lib/modules/manager/nix/artifacts.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ const dockerAdminConfig = {
process.env.CONTAINERBASE = 'true';

const config: UpdateArtifactsConfig = {};
const lockMaintenanceConfig = { ...config, isLockFileMaintenance: true };
const updateInputCmd = `nix \
--extra-experimental-features 'nix-command flakes' \
flake lock --update-input nixpkgs`;
Expand Down Expand Up @@ -294,7 +293,7 @@ describe('modules/manager/nix/artifacts', () => {
packageFileName: 'flake.nix',
updatedDeps: [{ depName: 'nixpkgs' }],
newPackageFileContent: '{}',
config: lockMaintenanceConfig,
config: { updateType:"lockFileMaintenance",...config },
});

expect(res).toEqual([
Expand Down
4 changes: 3 additions & 1 deletion lib/modules/manager/nix/artifacts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ export async function updateArtifacts({
}: UpdateArtifact): Promise<UpdateArtifactsResult[] | null> {
const lockFileName = packageFileName.replace(regEx(/\.nix$/), '.lock');
const existingLockFileContent = await readLocalFile(lockFileName, 'utf8');
const isLockFileMaintenance = config.updateType === 'lockFileMaintenance';

if (!existingLockFileContent) {
logger.debug('No flake.lock found');
return null;
Expand All @@ -35,7 +37,7 @@ export async function updateArtifacts({
cmd += `--extra-access-tokens github.com=${token} `;
}

if (config.isLockFileMaintenance) {
if (isLockFileMaintenance) {
cmd += 'flake update';
} else {
const inputs = updatedDeps
Expand Down
2 changes: 1 addition & 1 deletion lib/modules/manager/nuget/artifacts.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ describe('modules/manager/nuget/artifacts', () => {
newPackageFileContent: '{}',
config: {
...config,
isLockFileMaintenance: true,
updateType:"lockFileMaintenance"
},
}),
).toEqual([
Expand Down
2 changes: 1 addition & 1 deletion lib/modules/manager/nuget/artifacts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ export async function updateArtifacts({
}

try {
if (updatedDeps.length === 0 && config.isLockFileMaintenance !== true) {
if (updatedDeps.length === 0 && config.updateType !== 'lockFileMaintenance') {
logger.debug(
`Not updating lock file because no deps changed and no lock file maintenance.`,
);
Expand Down
2 changes: 1 addition & 1 deletion lib/modules/manager/pip-compile/artifacts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ export async function updateArtifacts({
try {
await writeLocalFile(inputFileName, newInputContent);
// TODO(not7cd): use --upgrade option instead deleting
if (config.isLockFileMaintenance) {
if (config.updateType === 'lockFileMaintenance') {
await deleteLocalFile(outputFileName);
}
const compileArgs = extractHeaderCommand(existingOutput, outputFileName);
Expand Down
2 changes: 1 addition & 1 deletion lib/modules/manager/pipenv/artifacts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ export async function updateArtifacts({
}
try {
await writeLocalFile(pipfileName, newPipfileContent);
if (config.isLockFileMaintenance) {
if (config.updateType === 'lockFileMaintenance') {
await deleteLocalFile(lockFileName);
}
const cmd = 'pipenv lock';
Expand Down
2 changes: 0 additions & 2 deletions lib/modules/manager/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ export interface ExtractConfig extends CustomExtractConfig {
}

export interface UpdateArtifactsConfig {
isLockFileMaintenance?: boolean;
constraints?: Record<string, string>;
composerIgnorePlatformReqs?: string[];
goGetDirs?: string[];
Expand Down Expand Up @@ -175,7 +174,6 @@ export interface Upgrade<T = Record<string, any>> extends PackageDependency<T> {
newVersion?: string;
updateType?: UpdateType;
version?: string;
isLockFileMaintenance?: boolean;
isRemediation?: boolean;
isVulnerabilityAlert?: boolean;
vulnerabilitySeverity?: string;
Expand Down
1 change: 0 additions & 1 deletion lib/workers/repository/updates/flatten.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,6 @@ export async function flattenUpdates(
packageFileConfig.lockFileMaintenance,
);
lockFileConfig.updateType = 'lockFileMaintenance';
lockFileConfig.isLockFileMaintenance = true;
lockFileConfig = await applyPackageRules(
lockFileConfig,
'lock-file-maintenance-merge',
Expand Down

0 comments on commit 0877eb2

Please sign in to comment.