@biffo/cli 0.311.0 → 0.312.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/dist/index.js +58 -8
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -13699,25 +13699,70 @@ var OWNERSHIP_HEADER_SWEEP_DIRS = [
13699
13699
  "infra"
13700
13700
  ];
13701
13701
  var STRICT_MARKER = /(?<!`)(?:INSTANCE-OWNED|NOT a template file)(?!`)/;
13702
- var SELF_REFERENTIAL_CLAIM = /\b(?:[Tt]his|[Ii]t)\b(?:\s+\S+){0,3}\s+(?:is|are|stays|remains)\s+(?:\*\*)?(template-owned|user-owned)\b/;
13702
+ var SELF_REFERENTIAL_CLAIM = /\b(?:[Tt]his|[Ii]t)\b((?:\s+\S+){0,3})\s+(?:is|are|stays|remains)\s+(?:\*\*)?(template-owned|user-owned)\b/g;
13703
+ var PATH_TOKEN = /`{0,2}([A-Za-z0-9_.-]+\/[A-Za-z0-9_./-]*)`{0,2}/g;
13704
+ function stripPathPunctuation(token) {
13705
+ return token.replace(/^[(,;:]+/, "").replace(/[),;:.]+$/, "");
13706
+ }
13707
+ function pathSegments(path) {
13708
+ return path.split("/").filter((segment) => segment.length > 0);
13709
+ }
13710
+ function isSameOrAncestorPath(token, ownPath) {
13711
+ const tokenSegments = pathSegments(token);
13712
+ const ownSegments = pathSegments(ownPath);
13713
+ const shorter = tokenSegments.length <= ownSegments.length ? tokenSegments : ownSegments;
13714
+ const longer = tokenSegments.length <= ownSegments.length ? ownSegments : tokenSegments;
13715
+ return shorter.length > 0 && shorter.every((segment, i) => segment === longer[i]);
13716
+ }
13717
+ function textNamesOtherPath(text, ownPath) {
13718
+ PATH_TOKEN.lastIndex = 0;
13719
+ let tokenMatch;
13720
+ while (tokenMatch = PATH_TOKEN.exec(text)) {
13721
+ const token = stripPathPunctuation(tokenMatch[1]);
13722
+ if (!token.includes("/")) continue;
13723
+ if (isSameOrAncestorPath(token, ownPath)) continue;
13724
+ return true;
13725
+ }
13726
+ return false;
13727
+ }
13728
+ function otherPathPrecedesBarePronoun(text, pronounIndex, ownPath) {
13729
+ const before = text.slice(0, pronounIndex);
13730
+ const paragraphBreak = /\n\s*\n/g;
13731
+ let paragraphStart = 0;
13732
+ let breakMatch;
13733
+ while (breakMatch = paragraphBreak.exec(before)) {
13734
+ paragraphStart = breakMatch.index + breakMatch[0].length;
13735
+ }
13736
+ const paragraph = text.slice(paragraphStart, pronounIndex);
13737
+ return textNamesOtherPath(paragraph, ownPath);
13738
+ }
13703
13739
  var EM_DASH_FIRST_LINE_CLAIM = /[—–]\s*(template-owned|user-owned)\b/;
13704
13740
  var MAX_HEADER_LINES = 10;
13705
13741
  function claimFor(matchedPhrase) {
13706
13742
  return /^template-owned$/i.test(matchedPhrase) ? "template" : "user";
13707
13743
  }
13708
- function claimInText(text) {
13744
+ function claimInText(text, ownPath) {
13709
13745
  const candidates = [];
13710
13746
  const strict = STRICT_MARKER.exec(text);
13711
13747
  if (strict)
13712
13748
  candidates.push({ matchedPhrase: strict[0], claim: claimFor(strict[0]), index: strict.index });
13713
- const grammatical = SELF_REFERENTIAL_CLAIM.exec(text);
13714
- if (grammatical) {
13715
- const phrase = grammatical[1];
13749
+ SELF_REFERENTIAL_CLAIM.lastIndex = 0;
13750
+ let grammatical;
13751
+ while (grammatical = SELF_REFERENTIAL_CLAIM.exec(text)) {
13752
+ const qualifier = grammatical[1];
13753
+ const isBarePronoun = qualifier === "";
13754
+ if (isBarePronoun) {
13755
+ if (otherPathPrecedesBarePronoun(text, grammatical.index, ownPath)) continue;
13756
+ } else if (textNamesOtherPath(qualifier, ownPath)) {
13757
+ continue;
13758
+ }
13759
+ const phrase = grammatical[2];
13716
13760
  candidates.push({ matchedPhrase: phrase, claim: claimFor(phrase), index: grammatical.index });
13761
+ break;
13717
13762
  }
13718
13763
  const firstLine = text.split("\n", 1)[0] ?? "";
13719
13764
  const emDash = EM_DASH_FIRST_LINE_CLAIM.exec(firstLine);
13720
- if (emDash) {
13765
+ if (emDash && !textNamesOtherPath(firstLine.slice(0, emDash.index), ownPath)) {
13721
13766
  const phrase = emDash[1];
13722
13767
  candidates.push({ matchedPhrase: phrase, claim: claimFor(phrase), index: emDash.index });
13723
13768
  }
@@ -13840,7 +13885,7 @@ function findHeaderClaim(path, content) {
13840
13885
  if (!range) return null;
13841
13886
  const [start, end] = range;
13842
13887
  const windowText = lines.slice(start, end).join("\n");
13843
- const found = claimInText(windowText);
13888
+ const found = claimInText(windowText, path);
13844
13889
  if (!found) return null;
13845
13890
  const line = start + windowText.slice(0, found.index).split("\n").length;
13846
13891
  return { path, claim: found.claim, matchedPhrase: found.matchedPhrase, line };
@@ -13862,8 +13907,13 @@ function sweepOwnershipHeaderClaims(root, options = {}) {
13862
13907
  }
13863
13908
  return hits;
13864
13909
  }
13910
+ function pathspecCovers(pathspec, relPath) {
13911
+ if (relPath === pathspec) return true;
13912
+ const dir = pathspec.endsWith("/") ? pathspec : `${pathspec}/`;
13913
+ return relPath.startsWith(dir);
13914
+ }
13865
13915
  function matchesReleased(relPath, manifest) {
13866
- return (manifest.released ?? []).some((p) => relPath === p || relPath.startsWith(p));
13916
+ return (manifest.released ?? []).some((p) => pathspecCovers(p, relPath));
13867
13917
  }
13868
13918
  function checkOwnershipHeaderClaims(hits, manifest) {
13869
13919
  const out = [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@biffo/cli",
3
- "version": "0.311.0",
3
+ "version": "0.312.1",
4
4
  "description": "Biffo project scaffolding CLI",
5
5
  "license": "MIT",
6
6
  "type": "module",