@vcmap/plugin-cli 4.0.0 → 4.0.1

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/update.js +18 -4
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vcmap/plugin-cli",
3
- "version": "4.0.0",
3
+ "version": "4.0.1",
4
4
  "description": "A CLI to help develop and build plugins for the VC Map",
5
5
  "main": "index.js",
6
6
  "type": "module",
package/src/update.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { logger } from '@vcsuite/cli-logger';
2
- import { validRange, prerelease } from 'semver';
2
+ import { validRange, maxSatisfying, prerelease } from 'semver';
3
3
  import {
4
4
  checkVcMapVersion,
5
5
  DepType,
@@ -36,17 +36,31 @@ export async function updatePeerDependencies(
36
36
  );
37
37
  options.mapVersion = 'latest';
38
38
  }
39
- let viewCmd = 'npm view @vcmap/ui --json';
39
+ let viewCmd =
40
+ 'npm view @vcmap/ui --json peerDependencies devDependencies version name';
40
41
  if (options.mapVersion) {
41
- viewCmd = `npm view @vcmap/ui@${options.mapVersion} --json`;
42
+ viewCmd = `npm view @vcmap/ui@${options.mapVersion} --json peerDependencies devDependencies version name`;
42
43
  }
43
44
  const { stdout, stderr } = await promiseExec(viewCmd);
44
45
  logger.error(stderr);
46
+ const npmVersions = JSON.parse(stdout);
47
+ let npmVersion = null;
48
+ if (Array.isArray(npmVersions)) {
49
+ const versions = npmVersions.map((v) => v.version);
50
+ const versionToUse = maxSatisfying(versions, options.mapVersion);
51
+ npmVersion = npmVersions.find((v) => v.version === versionToUse);
52
+ } else {
53
+ npmVersion = npmVersions;
54
+ }
55
+ if (!npmVersion) {
56
+ console.log(`could not find @vcmap/ui version for ${options.mapVersion}`);
57
+ return;
58
+ }
45
59
  const {
46
60
  name: mapName,
47
61
  peerDependencies: mapPeer,
48
62
  devDependencies: mapDev,
49
- } = JSON.parse(stdout);
63
+ } = npmVersion;
50
64
  const peerDeps = [`${mapName}@${options.mapVersion || 'latest'}`]; // @vcmap/ui is a required peer dep and will be updated in any case
51
65
  if (pluginPeer) {
52
66
  const pluginPeerDeps = Object.keys(pluginPeer)