@biffo/cli 0.224.3 → 0.225.0

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/dist/index.js +35 -4
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -9168,6 +9168,7 @@ import { existsSync as existsSync31, readdirSync as readdirSync13, readFileSync
9168
9168
  import { join as join31 } from "path";
9169
9169
  var ADR_FILENAME = /^(\d{4})-.+\.md$/;
9170
9170
  var ALLOWLIST_FILENAME = ".numbering-allowlist";
9171
+ var TEMPLATE_ADR_RESERVED_UPTO = "0099";
9171
9172
  function readAdrNumberingAllowlist(adrDir) {
9172
9173
  const path = join31(adrDir, ALLOWLIST_FILENAME);
9173
9174
  if (!existsSync31(path)) return /* @__PURE__ */ new Set();
@@ -9199,10 +9200,24 @@ function findAdrNumberCollisions(adrDir) {
9199
9200
  }
9200
9201
  return collisions;
9201
9202
  }
9202
- function findStaleAdrNumberingAllowlistEntries(adrDir) {
9203
+ function findAdrReservedRangeViolations(adrDir, reservedUpTo = TEMPLATE_ADR_RESERVED_UPTO) {
9204
+ const allowlist = readAdrNumberingAllowlist(adrDir);
9205
+ const violations = [];
9206
+ for (const [number, files] of [...adrNumbersIn(adrDir).entries()].sort()) {
9207
+ if (number > reservedUpTo || allowlist.has(number)) continue;
9208
+ for (const file of files) violations.push({ number, file });
9209
+ }
9210
+ return violations;
9211
+ }
9212
+ function findStaleAdrNumberingAllowlistEntries(adrDir, options = {}) {
9203
9213
  const allowlist = readAdrNumberingAllowlist(adrDir);
9204
9214
  const claims = adrNumbersIn(adrDir);
9205
- return [...allowlist].filter((number) => (claims.get(number)?.length ?? 0) < 2).sort();
9215
+ return [...allowlist].filter((number) => {
9216
+ const count = claims.get(number)?.length ?? 0;
9217
+ const stillColliding = count >= 2;
9218
+ const stillInReservedRange = options.isInstance === true && count >= 1 && number <= (options.reservedUpTo ?? TEMPLATE_ADR_RESERVED_UPTO);
9219
+ return !stillColliding && !stillInReservedRange;
9220
+ }).sort();
9206
9221
  }
9207
9222
  function formatAdrNumberCollisions(collisions) {
9208
9223
  return collisions.map(
@@ -9211,6 +9226,12 @@ function formatAdrNumberCollisions(collisions) {
9211
9226
  ambiguous while both exist.`
9212
9227
  ).join("\n");
9213
9228
  }
9229
+ function formatAdrReservedRangeViolations(violations, reservedUpTo = TEMPLATE_ADR_RESERVED_UPTO) {
9230
+ return violations.map(
9231
+ (v) => ` ${v.file} claims ADR-${v.number}, inside 0001-${reservedUpTo} \u2014 reserved for the template's own series.
9232
+ Renumber it above ADR-${reservedUpTo}, or if it is meant to be there (e.g. inherited at biffo init), list ${v.number} in docs/ADR/${ALLOWLIST_FILENAME}.`
9233
+ ).join("\n");
9234
+ }
9214
9235
 
9215
9236
  // src/scripts/check-adr-numbering.ts
9216
9237
  async function runAdrNumberingCheck() {
@@ -9220,8 +9241,10 @@ async function runAdrNumberingCheck() {
9220
9241
  console.log("\u2713 ADR numbering guard: no docs/ADR/ directory \u2014 nothing to compare");
9221
9242
  return;
9222
9243
  }
9244
+ const instance = isInstanceRepo(root);
9223
9245
  const collisions = findAdrNumberCollisions(adrDir);
9224
- const stale = findStaleAdrNumberingAllowlistEntries(adrDir);
9246
+ const reservedRangeViolations = instance ? findAdrReservedRangeViolations(adrDir) : [];
9247
+ const stale = findStaleAdrNumberingAllowlistEntries(adrDir, { isInstance: instance });
9225
9248
  let failed = false;
9226
9249
  if (collisions.length > 0) {
9227
9250
  failed = true;
@@ -9232,10 +9255,18 @@ async function runAdrNumberingCheck() {
9232
9255
  Already accepted? List it in docs/ADR/${ALLOWLIST_FILENAME} instead of leaving this red forever. See tabsii-platform#449 for how this class of collision happens.`
9233
9256
  );
9234
9257
  }
9258
+ if (reservedRangeViolations.length > 0) {
9259
+ failed = true;
9260
+ console.error(
9261
+ "\u2717 ADR numbering guard: docs/ADR/ has an ADR inside the template's reserved range\n"
9262
+ );
9263
+ console.error(formatAdrReservedRangeViolations(reservedRangeViolations));
9264
+ console.error("\nSee #1105 for why this range is reserved.");
9265
+ }
9235
9266
  if (stale.length > 0) {
9236
9267
  failed = true;
9237
9268
  console.error(
9238
- `\u2717 ADR numbering guard: docs/ADR/${ALLOWLIST_FILENAME} names a number that no longer collides: ${stale.join(", ")}
9269
+ `\u2717 ADR numbering guard: docs/ADR/${ALLOWLIST_FILENAME} names a number that neither check needs any more: ${stale.join(", ")}
9239
9270
  Remove the stale entry \u2014 an allowlist nothing checks against just hides the next real one.`
9240
9271
  );
9241
9272
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@biffo/cli",
3
- "version": "0.224.3",
3
+ "version": "0.225.0",
4
4
  "description": "Biffo project scaffolding CLI",
5
5
  "license": "MIT",
6
6
  "type": "module",