Skill Tracer
Skills › gstack › gstack › detect-bump.ts

detect-bump.ts

31 lines · scripts/detect-bump.ts at 3f79d81

1#!/usr/bin/env -S bun --no-env-file --config=/dev/null
2// detect-bump — crude heuristic for picking a bump level from a VERSION pair.
3// Used by CI's version-gate job to re-run the util with the "same" level that
4// /ship used, without needing persisted bump-intent.
5//
6// Input: two VERSION strings via argv: current (base) and target (branch).
7// Output: a single word: major|minor|patch|micro
8//
9// Heuristic: compare slot-by-slot. The first slot that differs IS the level.
10// If nothing differs (shouldn't happen when called by CI gate — the whole point
11// is the branch bumped VERSION), default to "patch".
13function detect(a: string, b: string): string {
14 const pa = a.trim().match(/^(\d+)\.(\d+)\.(\d+)\.(\d+)$/);
15 const pb = b.trim().match(/^(\d+)\.(\d+)\.(\d+)\.(\d+)$/);
16 if (!pa || !pb) return "patch";
17 const [, a1, a2, a3, a4] = pa;
18 const [, b1, b2, b3, b4] = pb;
19 if (a1 !== b1) return "major";
20 if (a2 !== b2) return "minor";
21 if (a3 !== b3) return "patch";
22 if (a4 !== b4) return "micro";
23 return "patch";
26const [, , base, target] = process.argv;
27if (!base || !target) {
28 console.error("Usage: detect-bump <base-version> <branch-version>");
29 process.exit(2);
31console.log(detect(base, target));