specshield 3.2.3 → 3.2.4

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "specshield",
3
- "version": "3.2.3",
3
+ "version": "3.2.4",
4
4
  "description": "CLI for OpenAPI breaking change detection and bi-directional contract verification — with can-i-deploy gating, GitHub PR checks, and a first-run setup wizard.",
5
5
  "main": "src/cli.js",
6
6
  "bin": {
@@ -70,6 +70,8 @@ function hr() {
70
70
  return chalk.gray(' ─────────────────────────────────────────────────────');
71
71
  }
72
72
 
73
+ const { stripVersionPrefix } = require('../util/versionStrip');
74
+
73
75
  /**
74
76
  * Flatten a verification result's mismatches.
75
77
  * Current backend returns `resultJson` (JSON string of [{endpoint,status,mismatches:[...]}]).
@@ -275,6 +277,11 @@ const verifyCommand = new Command('verify')
275
277
  const token = await resolveApiToken(opts);
276
278
  requireToken(token);
277
279
 
280
+ // Tolerate a leading `v` on either version (see can-i-deploy for the
281
+ // full rationale — readers paste back display values like `v1.0.0`).
282
+ opts.consumerVersion = stripVersionPrefix(opts.consumerVersion);
283
+ opts.providerVersion = stripVersionPrefix(opts.providerVersion);
284
+
278
285
  const spinner = opts.json ? null : ora(`Verifying ${opts.consumer} → ${opts.provider}...`).start();
279
286
 
280
287
  try {
@@ -361,6 +368,13 @@ const canIDeployCommand = new Command('can-i-deploy')
361
368
  const token = await resolveApiToken(opts);
362
369
  requireToken(token);
363
370
 
371
+ // Both the UI and the CLI render versions as `v<version>` for readability.
372
+ // When a user reads that and pastes it back into `--version`, the query
373
+ // silently matches nothing (the stored value never has a leading `v`).
374
+ // Strip a `v` that's followed by a digit, then use the cleaned version
375
+ // for the network call AND the human display so we never print `vv…`.
376
+ opts.version = stripVersionPrefix(opts.version);
377
+
364
378
  const spinner = opts.json ? null : ora(`Checking deployment safety for ${opts.service}@${opts.version}...`).start();
365
379
 
366
380
  try {
@@ -380,11 +394,15 @@ const canIDeployCommand = new Command('can-i-deploy')
380
394
  process.exit(deployable ? 0 : 1);
381
395
  }
382
396
 
397
+ // Idempotent `v` prefix on display — don't double it when the stored
398
+ // version legitimately starts with `v` (e.g. `vendor-tag-99`). Mirrors
399
+ // the UI pill at `BdctCanIDeploy.jsx:392`.
400
+ const vDisplay = /^v/i.test(opts.version) ? opts.version : `v${opts.version}`;
383
401
  process.stdout.write('\n');
384
402
  if (deployable) {
385
- process.stdout.write(chalk.green.bold(' ✔ PASS') + chalk.white(`: ${opts.service} v${opts.version} is deployable${envLabel}\n`));
403
+ process.stdout.write(chalk.green.bold(' ✔ PASS') + chalk.white(`: ${opts.service} ${vDisplay} is deployable${envLabel}\n`));
386
404
  } else {
387
- process.stdout.write(chalk.red.bold(' ✖ FAIL') + chalk.white(`: ${opts.service} v${opts.version} is NOT deployable${envLabel}\n`));
405
+ process.stdout.write(chalk.red.bold(' ✖ FAIL') + chalk.white(`: ${opts.service} ${vDisplay} is NOT deployable${envLabel}\n`));
388
406
  }
389
407
  process.stdout.write(hr() + '\n');
390
408
 
@@ -0,0 +1,24 @@
1
+ 'use strict';
2
+
3
+ /**
4
+ * Tolerate a leading `v` on user-supplied versions.
5
+ *
6
+ * The UI pill and several CLI displays render versions as `v<version>` for
7
+ * readability; readers routinely paste those back into lookup flags
8
+ * (`--version`, `--consumer-version`, `--provider-version`) where the leading
9
+ * `v` then silently makes the query miss every record because the stored
10
+ * value never has one.
11
+ *
12
+ * Strip a `v` (case-insensitive) ONLY when it sits in front of a digit, so
13
+ * legitimate strings that start with `v` followed by a letter (`vendor-tag`,
14
+ * `vNext`) pass through untouched.
15
+ *
16
+ * Applied at the entry of every LOOKUP action (`verify`, `can-i-deploy`).
17
+ * NOT applied to publish actions — the publisher's version is whatever they
18
+ * chose to store, including a literal `v` prefix if they want one.
19
+ */
20
+ function stripVersionPrefix(v) {
21
+ return typeof v === 'string' ? v.replace(/^v(?=\d)/i, '') : v;
22
+ }
23
+
24
+ module.exports = { stripVersionPrefix };