Skip to content

Commit

Permalink
fix(cli): extend --ignore-version-check [release-1.4] (#2619)
Browse files Browse the repository at this point in the history
fix(cli): extend --ignore-version-check

This change updates the cli's --ignore-version-check flag to also ignore
the check performed on a embedded transitive dependencies that are moved
to peer dependencies, when it is known that the mismatch is runtime
compatible.

Signed-off-by: Stan Lewis <[email protected]>
Co-authored-by: Stan Lewis <[email protected]>
  • Loading branch information
openshift-cherrypick-robot and gashcrumb authored Jan 21, 2025
1 parent 4ad8ab4 commit 374eef5
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 18 deletions.
7 changes: 7 additions & 0 deletions .changeset/stale-penguins-tan.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@janus-idp/cli": patch
---

fix(cli): extend --ignore-version-check

This change updates the cli's --ignore-version-check flag to also ignore the check performed on an embedded transitive dependencies that are moved to peer dependencies, when it is known that the mismatch is runtime compatible.
Original file line number Diff line number Diff line change
Expand Up @@ -168,14 +168,14 @@ export async function backend(
embedModules({
filter: filter,
addDependency: (embeddedModule, dependencyName, newDependencyVersion) =>
addToDependenciesForModule(
{
addToDependenciesForModule({
dependency: {
name: dependencyName,
version: newDependencyVersion,
},
dependenciesToAdd,
embeddedModule,
),
dependencies: dependenciesToAdd,
module: embeddedModule,
}),
}),
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,11 +221,12 @@ throw new Error(
if (embeddedPkg.peerDependencies) {
Object.entries(embeddedPkg.peerDependencies).forEach(
([name, version]) => {
addToDependenciesForModule(
{ name, version },
embeddedPeerDependencies,
embeddedPkg.name,
);
addToDependenciesForModule({
dependency: { name, version },
dependencies: embeddedPeerDependencies,
ignoreVersionCheck,
module: embeddedPkg.name,
});
},
);
}
Expand Down
28 changes: 20 additions & 8 deletions packages/cli/src/commands/export-dynamic-plugin/backend-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,17 @@ import path from 'path';

import { Task } from '../../lib/tasks';

export function addToDependenciesForModule(
dependency: { name: string; version: string },
dependencies: { [key: string]: string },
module: string,
): void {
export function addToDependenciesForModule({
dependency,
dependencies,
ignoreVersionCheck = [],
module,
}: {
dependency: { name: string; version: string };
dependencies: { [key: string]: string };
ignoreVersionCheck?: string[];
module: string;
}): void {
const existingDependencyVersion = dependencies[dependency.name];
if (existingDependencyVersion === undefined) {
dependencies[dependency.name] = dependency.version;
Expand Down Expand Up @@ -61,9 +67,15 @@ export function addToDependenciesForModule(
);
return;
}
throw new Error(
`Several incompatible versions ('${existingDependencyVersion}', '${dependency.version}') of the same transitive dependency ('${dependency.name}') for embedded module ('${module}')`,
);
if (!ignoreVersionCheck.includes(dependency.name)) {
throw new Error(
`Several incompatible versions ('${existingDependencyVersion}', '${dependency.version}') of the same transitive dependency ('${dependency.name}') for embedded module ('${module}')`,
);
} else {
Task.log(
`Several incompatible versions ('${existingDependencyVersion}', '${dependency.version}') of the same transitive dependency ('${dependency.name}') for embedded module ('${module}') however this has been overridden to use '${dependency.version}'`,
);
}
}

export function addToMainDependencies(
Expand Down

0 comments on commit 374eef5

Please sign in to comment.