@vcmap/plugin-cli 3.1.4 → 3.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/update.js +17 -4
package/package.json
CHANGED
package/src/update.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { logger } from '@vcsuite/cli-logger';
|
|
2
|
-
import { validRange } from 'semver';
|
|
2
|
+
import { maxSatisfying, validRange } from 'semver';
|
|
3
3
|
import {
|
|
4
4
|
checkVcMapVersion,
|
|
5
5
|
DepType,
|
|
@@ -32,13 +32,26 @@ export async function updatePeerDependencies(
|
|
|
32
32
|
);
|
|
33
33
|
options.mapVersion = 'latest';
|
|
34
34
|
}
|
|
35
|
-
let viewCmd = 'npm view @vcmap/ui --json';
|
|
35
|
+
let viewCmd = 'npm view @vcmap/ui --json peerDependencies version name';
|
|
36
36
|
if (options.mapVersion) {
|
|
37
|
-
viewCmd = `npm view @vcmap/ui@${options.mapVersion} --json`;
|
|
37
|
+
viewCmd = `npm view @vcmap/ui@${options.mapVersion} --json peerDependencies version name`;
|
|
38
38
|
}
|
|
39
39
|
const { stdout, stderr } = await promiseExec(viewCmd);
|
|
40
40
|
logger.error(stderr);
|
|
41
|
-
const
|
|
41
|
+
const npmVersions = JSON.parse(stdout);
|
|
42
|
+
let npmVersion = null;
|
|
43
|
+
if (Array.isArray(npmVersions)) {
|
|
44
|
+
const versions = npmVersions.map((v) => v.version);
|
|
45
|
+
const versionToUse = maxSatisfying(versions, options.mapVersion);
|
|
46
|
+
npmVersion = npmVersions.find((v) => v.version === versionToUse);
|
|
47
|
+
} else {
|
|
48
|
+
npmVersion = npmVersions;
|
|
49
|
+
}
|
|
50
|
+
if (!npmVersion) {
|
|
51
|
+
console.log(`could not find @vcmap/ui version for ${options.mapVersion}`);
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
const { name: mapName, peerDependencies: mapPeer } = npmVersion;
|
|
42
55
|
const peerDeps = [`${mapName}@${options.mapVersion || 'latest'}`]; // @vcmap/ui is a required peer dep and will be updated in any case
|
|
43
56
|
if (pluginPeer) {
|
|
44
57
|
const pluginPeerDeps = Object.keys(pluginPeer)
|