attempt to unbreak the duplicated versions problem in master

Signed-off-by: Fredrik Adelöw <freben@gmail.com>
This commit is contained in:
Fredrik Adelöw
2022-12-21 14:03:24 +01:00
parent deb0e83ead
commit 47c10706df
2 changed files with 13 additions and 3 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/cli': patch
---
Fixing the error `Error: No existing version was accepted for range ^0.12.0, searching through 0.11.2,0.0.0-use.local, for package @backstage/core-components`, which can happen when there are multiple matching versions for a package, and one of them uses `workspace:^` as its range.
+8 -3
View File
@@ -190,9 +190,14 @@ export class Lockfile {
}
// Find all versions currently in use
const versions = Array.from(new Set(entries.map(e => e.version))).sort(
(v1, v2) => semver.rcompare(v1, v2),
);
const versions = Array.from(new Set(entries.map(e => e.version)))
.map(v => {
// Translate workspace:^ references to the actual version
return v === '0.0.0-use.local'
? require(`${name}/package.json`).version
: v;
})
.sort((v1, v2) => semver.rcompare(v1, v2));
// If we're not using at least 2 different versions we're done
if (versions.length < 2) {