ShtukbaseStandard
package file→ .shtukbase/packages/std-semver/checks/sv03_tags.ts

checks/sv03_tags.ts

13 lines, 688 B.

  1. // SV-R03: a tag that looks like a release (`<tagPrefix>` and a digit) carries a valid SemVer 2.0.0 version.
  2. import { config, PKG, SEMVER } from './semverlib.ts';
  3. import { finish, git, norm } from './lib/std.ts';
  4. const n = norm(PKG, 'SV-R03', 'enforce');
  5. const cfg = config();
  6. const out: string[] = [];
  7. const tags = n.active ? (git(['tag']) ?? '').split('\n').map((t) => t.trim()).filter(Boolean) : [];
  8. for (const t of tags) {
  9. if (!t.startsWith(cfg.tagPrefix) || !/^\d/.test(t.slice(cfg.tagPrefix.length))) continue;
  10. if (!SEMVER.test(t.slice(cfg.tagPrefix.length))) out.push(`tag ${t}: after "${cfg.tagPrefix}" there is no SemVer 2.0.0 version (X.Y.Z is needed)`);
  11. }
  12. finish(n, out);