Skip to content
This repository was archived by the owner on Jan 27, 2026. It is now read-only.

Commit 2acb6e0

Browse files
fix(cli): add a flag to relax version checks (#2589)
This change adds an `--ignore-version-check` flag to the CLI to allow for selectively ignoring the semver check the CLI performs when evaluating the plugin package dependencies. This can be used to work around issues where a plugin has not been updated for awhile but it is known to work because it relies on interfaces and functions that have not changed. Signed-off-by: Stan Lewis <gashcrumb@gmail.com> Co-authored-by: Stan Lewis <gashcrumb@gmail.com>
1 parent 4fc79cf commit 2acb6e0

File tree

4 files changed

+30
-10
lines changed

4 files changed

+30
-10
lines changed

.changeset/dull-pillows-unite.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@janus-idp/cli": patch
3+
---
4+
5+
fix(cli): add a flag to relax semver checks. This change updates the CLI to add an option to relax the semver checks on a per-package basis to cater for plugins where it is known there should be runtime compabability due to no interface changes.

packages/cli/src/commands/export-dynamic-plugin/backend-embed-as-dependencies.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ export async function backend(opts: OptionValues): Promise<string> {
6060
const packagesToEmbed = (opts.embedPackage || []) as string[];
6161
const allowNative = (opts.allowNativePackage || []) as string[];
6262
const suppressNative = (opts.suppressNativePackage || []) as string[];
63+
const ignoreVersionCheck = (opts.ignoreVersionCheck || []) as string[];
6364
const monoRepoPackages = await getPackages(paths.targetDir);
6465
const embeddedResolvedPackages = await searchEmbedded(
6566
pkg,
@@ -299,7 +300,11 @@ throw new Error(
299300
`Hoisting peer dependencies of embedded packages to the main package`,
300301
);
301302
const mainPeerDependencies = mainPkg.peerDependencies || {};
302-
addToMainDependencies(embeddedPeerDependencies, mainPeerDependencies);
303+
addToMainDependencies(
304+
embeddedPeerDependencies,
305+
mainPeerDependencies,
306+
ignoreVersionCheck,
307+
);
303308
if (Object.keys(mainPeerDependencies).length > 0) {
304309
mainPkg.peerDependencies = mainPeerDependencies;
305310
}

packages/cli/src/commands/export-dynamic-plugin/backend-utils.ts

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ import semver from 'semver';
2121

2222
import path from 'path';
2323

24+
import { Task } from '../../lib/tasks';
25+
2426
export function addToDependenciesForModule(
2527
dependency: { name: string; version: string },
2628
dependencies: { [key: string]: string },
@@ -43,24 +45,22 @@ export function addToDependenciesForModule(
4345
existingDependencyMinVersion &&
4446
semver.satisfies(existingDependencyMinVersion, dependency.version)
4547
) {
46-
console.log(
48+
Task.log(
4749
`Several compatible versions ('${existingDependencyVersion}', '${dependency.version}') of the same transitive dependency ('${dependency.name}') for embedded module ('${module}'): keeping '${existingDependencyVersion}'`,
4850
);
4951
return;
5052
}
51-
5253
const newDependencyMinVersion = semver.minVersion(dependency.version);
5354
if (
5455
newDependencyMinVersion &&
5556
semver.satisfies(newDependencyMinVersion, existingDependencyVersion)
5657
) {
5758
dependencies[dependency.name] = dependency.version;
58-
console.log(
59+
Task.log(
5960
`Several compatible versions ('${existingDependencyVersion}', '${dependency.version}') of the same transitive dependency ('${dependency.name}') for embedded module ('${module}'): keeping '${dependency.version}'`,
6061
);
6162
return;
6263
}
63-
6464
throw new Error(
6565
`Several incompatible versions ('${existingDependencyVersion}', '${dependency.version}') of the same transitive dependency ('${dependency.name}') for embedded module ('${module}')`,
6666
);
@@ -69,6 +69,7 @@ export function addToDependenciesForModule(
6969
export function addToMainDependencies(
7070
dependenciesToAdd: { [key: string]: string },
7171
mainDependencies: { [key: string]: string },
72+
ignoreVersionCheck: string[] = [],
7273
): void {
7374
for (const dep in dependenciesToAdd) {
7475
if (!Object.prototype.hasOwnProperty.call(dependenciesToAdd, dep)) {
@@ -81,18 +82,23 @@ export function addToMainDependencies(
8182
}
8283
if (existingVersion !== dependenciesToAdd[dep]) {
8384
const existingMinVersion = semver.minVersion(existingVersion);
84-
8585
if (
8686
existingMinVersion &&
8787
semver.satisfies(existingMinVersion, dependenciesToAdd[dep])
8888
) {
89-
console.log(
89+
Task.log(
9090
`The version of a dependency ('${dep}') of an embedded module differs from the main module's dependencies: '${dependenciesToAdd[dep]}', '${existingVersion}': keeping it as it is compatible`,
9191
);
9292
} else {
93-
throw new Error(
94-
`The version of a dependency ('${dep}') of an embedded module conflicts with main module dependencies: '${dependenciesToAdd[dep]}', '${existingVersion}': cannot proceed!`,
95-
);
93+
if (!ignoreVersionCheck.includes(dep)) {
94+
throw new Error(
95+
`The version of a dependency ('${dep}') of an embedded module conflicts with main module dependencies: '${dependenciesToAdd[dep]}', '${existingVersion}': cannot proceed!`,
96+
);
97+
} else {
98+
Task.log(
99+
`The version of a dependency ('${dep}') of an embedded module conflicts with the main module's dependencies: '${dependenciesToAdd[dep]}', '${existingVersion}': however this has been overridden`,
100+
);
101+
}
96102
}
97103
}
98104
}

packages/cli/src/commands/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,10 @@ export function registerScriptCommand(program: Command) {
113113
'--suppress-native-package [package-name...]',
114114
'Optional list of native package names to be excluded from the exported plugin',
115115
)
116+
.option(
117+
'--ignore-version-check [packageName...]',
118+
'Optional list of package names to ignore when doing semver dependency checks',
119+
)
116120
.option(
117121
'--no-install',
118122
'Do not run `yarn install` to fill the dynamic plugin `node_modules` folder (backend plugin only).',

0 commit comments

Comments
 (0)