@danielsimonjr/repo-tools 2.2.5 → 2.2.6

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/CHANGELOG.md CHANGED
@@ -6,6 +6,24 @@ All notable changes to this project are recorded in this file. The format follow
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [2.2.6] - 2026-10-22
10
+
11
+ ### Fixed
12
+
13
+ - `repo-tools map` finds the entry roots of an app whose build output is not `dist/` and whose sources are not
14
+ only under `src/`. On an Electron app (main process built to `dist-electron/`, CLI built to `dist-cli/`, renderer
15
+ loaded from `src/index.html`) it reported 74 dormant files, among them 11 orphans, and now reports 5 dormant files,
16
+ among them 3 orphans. Four sources of roots were missing or broken:
17
+ - A `tsc -p <tsconfig>` script of the root package in a repository without workspaces seeds the files of that
18
+ tsconfig. Only a workspace package did this before.
19
+ - A tsconfig that holds comments or trailing commas is read. `JSON.parse` rejected it and the whole tsconfig was
20
+ ignored without a message.
21
+ - A root build or test config names entry files with an `entry`, `input`, `setupFiles`, `globalSetup` or
22
+ `globalTeardown` key (for example `path.resolve(__dirname, 'electron/main.ts')`). Each such file is a root.
23
+ Only `new URL(...)` was read before.
24
+ - The module script of `index.html` or `src/index.html` is a root.
25
+ The ambient declaration files (`vite-env.d.ts`) stay in the list of files without an importer, as before.
26
+
9
27
  ## [2.2.5] - 2026-10-22
10
28
 
11
29
  ### Changed
package/README.md CHANGED
@@ -13,7 +13,7 @@
13
13
  | `query` | Answers structural questions from the graph of `map`, and writes two derived reports. |
14
14
  | `ste` | Checks Markdown or docstring prose against Simplified Technical English. |
15
15
 
16
- Status: version 2.2.5.
16
+ Status: version 2.2.6.
17
17
 
18
18
  - `map`, `check` and `query` read their settings from `repo-tools.config.json` in the root. The
19
19
  section of `map` is `map` (its old name, `depgraph`, is also read). `--config=<file>` makes any
@@ -41,7 +41,7 @@ repo-tools --version
41
41
 
42
42
  The executable holds the tool and the Bun runtime. It needs no Bun, Node or `node_modules`.
43
43
  Download the file for your platform and `SHA256SUMS` from the
44
- [GitHub release](https://github.com/danielsimonjr/repo-tools/releases/tag/v2.2.5):
44
+ [GitHub release](https://github.com/danielsimonjr/repo-tools/releases/tag/v2.2.6):
45
45
 
46
46
  | Platform | File |
47
47
  |---|---|
package/dist/cli.js CHANGED
@@ -2,7 +2,7 @@
2
2
  // package.json
3
3
  var package_default = {
4
4
  name: "@danielsimonjr/repo-tools",
5
- version: "2.2.5",
5
+ version: "2.2.6",
6
6
  description: "One CLI for repository analysis: dependency graphs creation and query with per-export API facts, file chunking, and context compression. TypeScript on Bun, compiled to a single executable.",
7
7
  type: "module",
8
8
  license: "MIT",
@@ -2066,13 +2066,55 @@ function tsupConfigEntries(root, pkgDir) {
2066
2066
  }
2067
2067
  return out2;
2068
2068
  }
2069
+ function stringEnd(text, start2) {
2070
+ let j = start2 + 1;
2071
+ while (j < text.length && text.charAt(j) !== '"')
2072
+ j += text.charAt(j) === "\\" ? 2 : 1;
2073
+ return Math.min(j + 1, text.length);
2074
+ }
2075
+ function stripJsonc(text) {
2076
+ let plain = "";
2077
+ for (let i2 = 0;i2 < text.length; ) {
2078
+ const c = text.charAt(i2);
2079
+ if (c === '"') {
2080
+ const end = stringEnd(text, i2);
2081
+ plain += text.slice(i2, end);
2082
+ i2 = end;
2083
+ } else if (c === "/" && text.charAt(i2 + 1) === "/") {
2084
+ while (i2 < text.length && text.charAt(i2) !== `
2085
+ `)
2086
+ i2++;
2087
+ } else if (c === "/" && text.charAt(i2 + 1) === "*") {
2088
+ const end = text.indexOf("*/", i2 + 2);
2089
+ i2 = end === -1 ? text.length : end + 2;
2090
+ } else {
2091
+ plain += c;
2092
+ i2++;
2093
+ }
2094
+ }
2095
+ let out2 = "";
2096
+ for (let i2 = 0;i2 < plain.length; ) {
2097
+ const c = plain.charAt(i2);
2098
+ if (c === '"') {
2099
+ const end = stringEnd(plain, i2);
2100
+ out2 += plain.slice(i2, end);
2101
+ i2 = end;
2102
+ } else if (c === "," && /^\s*[}\]]/.test(plain.slice(i2 + 1))) {
2103
+ i2++;
2104
+ } else {
2105
+ out2 += c;
2106
+ i2++;
2107
+ }
2108
+ }
2109
+ return out2;
2110
+ }
2069
2111
  function seedTsconfigEntries(root, pkgDir, cfgRel, add) {
2070
2112
  const cfgPath = join7(root, pkgDir, cfgRel);
2071
2113
  if (!existsSync4(cfgPath))
2072
2114
  return;
2073
2115
  let cfg;
2074
2116
  try {
2075
- cfg = JSON.parse(readFileSync3(cfgPath, "utf-8"));
2117
+ cfg = JSON.parse(stripJsonc(readFileSync3(cfgPath, "utf-8")));
2076
2118
  } catch {
2077
2119
  return;
2078
2120
  }
@@ -2226,6 +2268,8 @@ function selfPackage(root) {
2226
2268
  entryFiles: packageEntryFiles(root, pkg)
2227
2269
  };
2228
2270
  }
2271
+ var CONFIG_ENTRY_KEY = /\b(?:entry|input|setupFiles|globalSetup|globalTeardown)["']?\s*:\s*(\[[^\]]*\]|\{[^}]*\}|[\w$.]+\([^)]*\)|['"`][^'"`]*['"`])/g;
2272
+ var SOURCE_LITERAL = /['"`]([^'"`]+\.[cm]?[jt]sx?)['"`]/g;
2229
2273
  function configReferencedEntries(root) {
2230
2274
  const out2 = new Set;
2231
2275
  let names;
@@ -2247,9 +2291,36 @@ function configReferencedEntries(root) {
2247
2291
  for (const m of code.matchAll(/new\s+URL\(\s*['"`]([^'"`]*?src\/[\w./-]+\.ts)['"`]/g)) {
2248
2292
  out2.add((m[1] ?? "").replace(/^\.\//, ""));
2249
2293
  }
2294
+ for (const key of code.matchAll(CONFIG_ENTRY_KEY)) {
2295
+ for (const lit of (key[1] ?? "").matchAll(SOURCE_LITERAL)) {
2296
+ out2.add(toPosix(lit[1] ?? "").replace(/^\.\//, ""));
2297
+ }
2298
+ }
2250
2299
  }
2251
2300
  return [...out2];
2252
2301
  }
2302
+ function htmlReferencedEntries(root) {
2303
+ const out2 = [];
2304
+ for (const page of ["index.html", "src/index.html"]) {
2305
+ let html;
2306
+ try {
2307
+ html = readFileSync3(join7(root, page), "utf-8");
2308
+ } catch {
2309
+ continue;
2310
+ }
2311
+ for (const m of html.matchAll(/<script\b[^>]*?\bsrc\s*=\s*["']([^"']+)["']/gi)) {
2312
+ const src = m[1] ?? "";
2313
+ if (/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i.test(src) || !/\.[cm]?[jt]sx?$/.test(src))
2314
+ continue;
2315
+ const fromPage = toPosix(join7(dirname4(page), src)).replace(/^\.\//, "");
2316
+ const candidates = src.startsWith("/") ? [src.slice(1), fromPage] : [fromPage];
2317
+ const found = candidates.find((c) => existsSync4(join7(root, c)));
2318
+ if (found !== undefined && !out2.includes(found))
2319
+ out2.push(found);
2320
+ }
2321
+ }
2322
+ return out2;
2323
+ }
2253
2324
  function runtimeLaunchedEntries(root, parsed) {
2254
2325
  const known = new Set(parsed.map((f) => f.path));
2255
2326
  const out2 = new Set;
@@ -12513,7 +12584,8 @@ function findRoots(root, known, language) {
12513
12584
  return rustRoots(known);
12514
12585
  const [rootRoots, rootWarnings] = packageJsonRoots(root, known);
12515
12586
  const [wsRoots, wsWarnings] = workspaceRoots(root, known);
12516
- const roots = [...new Set([...rootRoots, ...wsRoots])];
12587
+ const scriptRoots = detectWorkspaces(root).size === 0 ? rootPackageEntries(root).filter((e) => known.has(e)) : [];
12588
+ const roots = [...new Set([...rootRoots, ...wsRoots, ...scriptRoots])];
12517
12589
  const warnings = [...rootWarnings, ...wsWarnings];
12518
12590
  if (roots.length > 0)
12519
12591
  return [roots, warnings];
@@ -12689,7 +12761,7 @@ async function buildGraph(root) {
12689
12761
  const [declaredRoots, rootWarnings] = findRoots(root, known, language);
12690
12762
  const roots = [...declaredRoots];
12691
12763
  if (language === "typescript") {
12692
- for (const entry of configReferencedEntries(root)) {
12764
+ for (const entry of [...configReferencedEntries(root), ...htmlReferencedEntries(root)]) {
12693
12765
  if (known.has(entry) && !roots.includes(entry))
12694
12766
  roots.push(entry);
12695
12767
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@danielsimonjr/repo-tools",
3
- "version": "2.2.5",
3
+ "version": "2.2.6",
4
4
  "description": "One CLI for repository analysis: dependency graphs creation and query with per-export API facts, file chunking, and context compression. TypeScript on Bun, compiled to a single executable.",
5
5
  "type": "module",
6
6
  "license": "MIT",