dir-analysis-tool 3.5.3 → 3.5.4
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/README.md +2 -2
- package/dist/cli.js +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +1 -1
- package/dist/{shared-BJ-V9aTZ.js → shared-c7R0EX5i.js} +26 -9
- package/package.json +1 -1
- package/report.schema.json +4 -0
package/README.md
CHANGED
|
@@ -253,7 +253,7 @@ build/keep/k.txt: excluded
|
|
|
253
253
|
Note Git's global excludes file (core.excludesFile, usually ~/.config/git/ignore) is not read; Git may ignore more than dat does.
|
|
254
254
|
```
|
|
255
255
|
|
|
256
|
-
Without a path, it runs one scan and groups everything left out by the rule that skipped it: default excludes, each exclude pattern, each `.gitignore` line, size and date filters, `--max-depth`, and symbolic links that were not followed. Counts are complete and equal `summary.excluded` and `summary.filtered` from `analyze`; each group lists its first 20 entries in path order.
|
|
256
|
+
Without a path, it runs one scan and groups everything left out by the rule that skipped it: default excludes, each exclude pattern, each `.gitignore` line, size and date filters, `--max-depth`, and symbolic links that were not followed. With `-L`, links that can't be followed are grouped by why: `ENOENT` (the target is missing) or `ELOOP` (the link loops); they count in `summary.symlinks`, not in `errors`, and the group's `code` field says which. Counts are complete and equal `summary.excluded` and `summary.filtered` from `analyze`; each group lists its first 20 entries in path order.
|
|
257
257
|
|
|
258
258
|
```text
|
|
259
259
|
$ dat explain -g
|
|
@@ -280,7 +280,7 @@ Sizes inside skipped directories are unknown. Measure one with: dat <dir> --all
|
|
|
280
280
|
|
|
281
281
|
All scan options are accepted, as are `--si`, `--color`, `--no-color`, `--no-progress`, and `-q`. The path is relative to the current directory and must be inside the root.
|
|
282
282
|
|
|
283
|
-
- **Decisions:** `included`, `excluded` (a default, a pattern, `.gitignore`, or `.git/info/exclude`), `filtered` (size or date), `skipped` (beyond `--max-depth`, a symbolic link that is not followed, a socket or device, or an unreadable folder), and `not-found`. The exit code is `0` for all of them, so read `decision`; `1` means an error, such as a path outside the root.
|
|
283
|
+
- **Decisions:** `included`, `excluded` (a default, a pattern, `.gitignore`, or `.git/info/exclude`), `filtered` (size or date), `skipped` (beyond `--max-depth`, a symbolic link that is not followed or, with `-L`, leads nowhere, a socket or device, or an unreadable folder), and `not-found`. The exit code is `0` for all of them, so read `decision`; `1` means an error, such as a path outside the root.
|
|
284
284
|
- **What it cannot know** is said, not guessed. dat never enters an excluded directory, so the size and count below one stay unknown (`descendants` is always `null`). Notes flag a negation that cannot work (`!build/keep/` under an ignored `build/`, `-e '!node_modules'`, or `-e '!x.log'` against a `.gitignore` rule), a scan root that Git ignores, nested repositories, matches that depend on the platform's case-insensitivity, and counts that depend on scan order (hard links, followed symlinks).
|
|
285
285
|
- **Not read:** Git's global excludes file (`core.excludesFile`, usually `~/.config/git/ignore`). Every `-g` explanation inside a repository says so. A `.git` file, which links a worktree or submodule to its repository, is counted as an ordinary file, because default excludes only skip directories.
|
|
286
286
|
- `--max-depth` skips are reported only here (`totals.depthSkipped`); `analyze` does not count them.
|
package/dist/cli.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { $ as errorCode, C as MAX_EXPLAIN_LIMIT, D as outsideRootError, E as isOutside, F as listDirectories, G as formatBytes, J as VERSION, K as parseSize, L as Excluder, M as analyze, O as compare, P as assertDirectory, Q as DatError, R as joinRelative, T as explainSkips, U as formatBudgetActual, W as parseBudget, X as parsePointInTime, Z as AbortError, a as renderComparisonCsv, c as renderAnalysis, d as escapeControlInLines, et as errorMessage, f as formatCount, h as supportsColor, i as renderAnalysisCsv, k as compactAnalysis, l as renderComparison, m as createStyle, n as renderSkipsExplanation, o as renderAnalysisMarkdown, p as stringifyJson, r as renderAnalysisHtml, s as renderComparisonMarkdown, t as renderPathExplanation, u as escapeControl, v as loadConfig, w as explainPath } from "./shared-
|
|
2
|
+
import { $ as errorCode, C as MAX_EXPLAIN_LIMIT, D as outsideRootError, E as isOutside, F as listDirectories, G as formatBytes, J as VERSION, K as parseSize, L as Excluder, M as analyze, O as compare, P as assertDirectory, Q as DatError, R as joinRelative, T as explainSkips, U as formatBudgetActual, W as parseBudget, X as parsePointInTime, Z as AbortError, a as renderComparisonCsv, c as renderAnalysis, d as escapeControlInLines, et as errorMessage, f as formatCount, h as supportsColor, i as renderAnalysisCsv, k as compactAnalysis, l as renderComparison, m as createStyle, n as renderSkipsExplanation, o as renderAnalysisMarkdown, p as stringifyJson, r as renderAnalysisHtml, s as renderComparisonMarkdown, t as renderPathExplanation, u as escapeControl, v as loadConfig, w as explainPath } from "./shared-c7R0EX5i.js";
|
|
3
3
|
import { constants, existsSync, watch } from "node:fs";
|
|
4
4
|
import { access, mkdir, realpath, stat, writeFile } from "node:fs/promises";
|
|
5
5
|
import { basename, dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
|
package/dist/index.d.ts
CHANGED
|
@@ -475,6 +475,8 @@ interface ExplainGroup {
|
|
|
475
475
|
rule: string | null;
|
|
476
476
|
index: number | null;
|
|
477
477
|
limit: number | string | null;
|
|
478
|
+
/** `symlink` with followSymlinks: `ENOENT` (target missing) or `ELOOP` (a loop); else `null`. */
|
|
479
|
+
code: string | null;
|
|
478
480
|
count: number;
|
|
479
481
|
/** The first entries in path order, at most `limit` of them. */
|
|
480
482
|
entries: string[];
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { Z as AbortError, V as BUDGET_METRICS, q as CATEGORIES, g as CONFIG_FILE_NAMES, N as DEFAULT_CONCURRENCY, I as DEFAULT_EXCLUDES, x as DEFAULT_EXPLAIN_LIMIT, A as DEFAULT_LARGE_FILE_THRESHOLD, j as DEFAULT_STALE_AGE, Q as DatError, S as EXPLAIN_VERSION, C as MAX_EXPLAIN_LIMIT, J as VERSION, M as analyze, y as buildJsonSchema, z as classify, k as compactAnalysis, O as compare, m as createStyle, H as evaluateBudgets, w as explainPath, T as explainSkips, B as extensionOf, _ as findConfigFile, G as formatBytes, F as listDirectories, v as loadConfig, W as parseBudget, Y as parseDuration, X as parsePointInTime, K as parseSize, c as renderAnalysis, i as renderAnalysisCsv, r as renderAnalysisHtml, o as renderAnalysisMarkdown, l as renderComparison, a as renderComparisonCsv, s as renderComparisonMarkdown, t as renderPathExplanation, n as renderSkipsExplanation, b as validateConfig } from "./shared-
|
|
1
|
+
export { Z as AbortError, V as BUDGET_METRICS, q as CATEGORIES, g as CONFIG_FILE_NAMES, N as DEFAULT_CONCURRENCY, I as DEFAULT_EXCLUDES, x as DEFAULT_EXPLAIN_LIMIT, A as DEFAULT_LARGE_FILE_THRESHOLD, j as DEFAULT_STALE_AGE, Q as DatError, S as EXPLAIN_VERSION, C as MAX_EXPLAIN_LIMIT, J as VERSION, M as analyze, y as buildJsonSchema, z as classify, k as compactAnalysis, O as compare, m as createStyle, H as evaluateBudgets, w as explainPath, T as explainSkips, B as extensionOf, _ as findConfigFile, G as formatBytes, F as listDirectories, v as loadConfig, W as parseBudget, Y as parseDuration, X as parsePointInTime, K as parseSize, c as renderAnalysis, i as renderAnalysisCsv, r as renderAnalysisHtml, o as renderAnalysisMarkdown, l as renderComparison, a as renderComparisonCsv, s as renderComparisonMarkdown, t as renderPathExplanation, n as renderSkipsExplanation, b as validateConfig } from "./shared-c7R0EX5i.js";
|
|
@@ -1000,6 +1000,12 @@ var Scanner = class {
|
|
|
1000
1000
|
const code = errorCode(error);
|
|
1001
1001
|
if (isSymlink && (code === "ENOENT" || code === "ELOOP")) {
|
|
1002
1002
|
this.counters.symlinks++;
|
|
1003
|
+
this.#options.onSkip?.({
|
|
1004
|
+
kind: "broken-symlink",
|
|
1005
|
+
dir: dirIndex,
|
|
1006
|
+
name,
|
|
1007
|
+
code
|
|
1008
|
+
});
|
|
1003
1009
|
return;
|
|
1004
1010
|
}
|
|
1005
1011
|
this.recordError(this.relativePath(dirIndex, name), error);
|
|
@@ -2357,7 +2363,7 @@ var Collector = class {
|
|
|
2357
2363
|
if (this.#scanner.dirs[dir].depth < features.tree.depth) {
|
|
2358
2364
|
let heap = this.#treeFiles.get(dir);
|
|
2359
2365
|
if (!heap) {
|
|
2360
|
-
heap = new TopK(features.tree.limit, (a, b) => a.name
|
|
2366
|
+
heap = new TopK(features.tree.limit, (a, b) => comparePaths(a.name, b.name));
|
|
2361
2367
|
this.#treeFiles.set(dir, heap);
|
|
2362
2368
|
}
|
|
2363
2369
|
if (heap.accepts(bytes)) heap.push(bytes, makeRef());
|
|
@@ -2452,7 +2458,7 @@ var Collector = class {
|
|
|
2452
2458
|
extensions: [...this.#extensions].map(([extension, stat]) => ({
|
|
2453
2459
|
extension,
|
|
2454
2460
|
...stat
|
|
2455
|
-
})).sort((a, b) => b.bytes - a.bytes || b.files - a.files || a.extension
|
|
2461
|
+
})).sort((a, b) => b.bytes - a.bytes || b.files - a.files || comparePaths(a.extension, b.extension)),
|
|
2456
2462
|
largestDirectories: this.#largestDirectories(scanner),
|
|
2457
2463
|
largestFiles: this.#topFiles.sorted().map(toEntry),
|
|
2458
2464
|
errors: [...scanner.errors].sort((a, b) => comparePaths(a.path, b.path))
|
|
@@ -2533,7 +2539,7 @@ var Collector = class {
|
|
|
2533
2539
|
};
|
|
2534
2540
|
}
|
|
2535
2541
|
});
|
|
2536
|
-
candidates.sort((a, b) => b.bytes - a.bytes || a.key
|
|
2542
|
+
candidates.sort((a, b) => b.bytes - a.bytes || comparePaths(a.key, b.key));
|
|
2537
2543
|
const shown = candidates.slice(0, limit);
|
|
2538
2544
|
result.children = shown.map((c) => c.build());
|
|
2539
2545
|
const omittedEntries = (subdirs?.length ?? 0) + node.ownFiles - shown.length;
|
|
@@ -3416,7 +3422,8 @@ async function explainSkips(root, options = {}) {
|
|
|
3416
3422
|
line: null,
|
|
3417
3423
|
rule: null,
|
|
3418
3424
|
index: null,
|
|
3419
|
-
limit: null
|
|
3425
|
+
limit: null,
|
|
3426
|
+
code: null
|
|
3420
3427
|
});
|
|
3421
3428
|
let scanner = null;
|
|
3422
3429
|
const onSkip = (event) => {
|
|
@@ -3474,6 +3481,12 @@ async function explainSkips(root, options = {}) {
|
|
|
3474
3481
|
case "symlink":
|
|
3475
3482
|
groupFor("symlink", () => base("symlink")).add(rel);
|
|
3476
3483
|
return;
|
|
3484
|
+
case "broken-symlink":
|
|
3485
|
+
groupFor(`symlink\0${event.code}`, () => ({
|
|
3486
|
+
...base("symlink"),
|
|
3487
|
+
code: event.code
|
|
3488
|
+
})).add(rel);
|
|
3489
|
+
return;
|
|
3477
3490
|
}
|
|
3478
3491
|
};
|
|
3479
3492
|
scanner = new Scanner({
|
|
@@ -3500,7 +3513,7 @@ async function explainSkips(root, options = {}) {
|
|
|
3500
3513
|
count: sample.count,
|
|
3501
3514
|
entries: sample.items,
|
|
3502
3515
|
truncated: sample.count > sample.items.length
|
|
3503
|
-
})).toSorted((a, b) => b.count - a.count || SOURCE_ORDER.indexOf(a.source) - SOURCE_ORDER.indexOf(b.source) || comparePaths(a.file ?? "", b.file ?? "") || (a.line ?? 0) - (b.line ?? 0) || (a.index ?? 0) - (b.index ?? 0) || comparePaths(a.rule ?? "", b.rule ?? ""));
|
|
3516
|
+
})).toSorted((a, b) => b.count - a.count || SOURCE_ORDER.indexOf(a.source) - SOURCE_ORDER.indexOf(b.source) || comparePaths(a.file ?? "", b.file ?? "") || (a.line ?? 0) - (b.line ?? 0) || (a.index ?? 0) - (b.index ?? 0) || comparePaths(a.rule ?? "", b.rule ?? "") || comparePaths(a.code ?? "", b.code ?? ""));
|
|
3504
3517
|
return {
|
|
3505
3518
|
explainVersion: 1,
|
|
3506
3519
|
root: absRoot,
|
|
@@ -4864,7 +4877,7 @@ function ruleLabel(group, units) {
|
|
|
4864
4877
|
case "size": return `${flagOf(group.rule)} ${sizeOf(group.limit, units)}`;
|
|
4865
4878
|
case "date": return `${flagOf(group.rule)} ${String(group.limit)}`;
|
|
4866
4879
|
case "max-depth": return `--max-depth ${String(group.limit)}`;
|
|
4867
|
-
case "symlink": return "symbolic links (not followed)"
|
|
4880
|
+
case "symlink": return group.code === null ? "symbolic links (not followed)" : group.code === "ELOOP" ? `symbolic links in a loop (${group.code})` : `symbolic links to nothing (${escapeControl(group.code)})`;
|
|
4868
4881
|
case "special-file": return "special files";
|
|
4869
4882
|
case "error": return "unreadable";
|
|
4870
4883
|
case "unknown": return "no single rule identified";
|
|
@@ -4896,7 +4909,7 @@ function reasonLines(reason, units, s) {
|
|
|
4896
4909
|
rows.push(["Rule", `--max-depth ${String(reason.limit)}; ${at} is at depth ${String(reason.actual)}`]);
|
|
4897
4910
|
break;
|
|
4898
4911
|
case "symlink":
|
|
4899
|
-
rows.push(["Rule", reason.code ? `symbolic link to nothing (${reason.code}); counted, not followed` : "symbolic link; counted, not followed (use -L to follow)"]);
|
|
4912
|
+
rows.push(["Rule", reason.code === "ELOOP" ? `symbolic link in a loop (${reason.code}); counted, not followed` : reason.code ? `symbolic link to nothing (${escapeControl(reason.code)}); counted, not followed` : "symbolic link; counted, not followed (use -L to follow)"]);
|
|
4900
4913
|
break;
|
|
4901
4914
|
case "special-file":
|
|
4902
4915
|
rows.push(["Rule", "special file (socket, FIFO, or device); never counted"]);
|
|
@@ -4946,8 +4959,11 @@ function renderSkipsExplanation(result, options = {}) {
|
|
|
4946
4959
|
if (totals.excluded > 0) parts.push(`${plural(totals.excluded, "entry", "entries")} excluded`);
|
|
4947
4960
|
if (totals.filtered > 0) parts.push(`${plural(totals.filtered, "file")} filtered`);
|
|
4948
4961
|
if (totals.depthSkipped > 0) parts.push(`${plural(totals.depthSkipped, "directory", "directories")} beyond --max-depth`);
|
|
4949
|
-
const
|
|
4962
|
+
const links = result.groups.filter((g) => g.source === "symlink");
|
|
4963
|
+
const unfollowed = links.find((g) => g.code === null)?.count ?? 0;
|
|
4964
|
+
const broken = links.reduce((sum, g) => sum + (g.code === null ? 0 : g.count), 0);
|
|
4950
4965
|
if (unfollowed > 0) parts.push(`${plural(unfollowed, "symbolic link")} not followed`);
|
|
4966
|
+
if (broken > 0) parts.push(plural(broken, "broken symbolic link"));
|
|
4951
4967
|
if (totals.errors > 0) parts.push(`${plural(totals.errors, "entry", "entries")} unreadable`);
|
|
4952
4968
|
const lines = [];
|
|
4953
4969
|
lines.push(parts.length > 0 ? s.bold(`Skipped: ${parts.join(", ")}`) : s.bold("Nothing was skipped: every entry is counted."));
|
|
@@ -4970,7 +4986,8 @@ function renderSkipsExplanation(result, options = {}) {
|
|
|
4970
4986
|
for (const error of result.errors) lines.push(` ${fitPath(error.path, width - 20)} ${s.dim(error.code)}`);
|
|
4971
4987
|
}
|
|
4972
4988
|
const notes = result.notes.map(noteText);
|
|
4973
|
-
|
|
4989
|
+
const skipsDirectories = (g) => g.source !== "size" && g.source !== "date" && !(g.source === "symlink" && g.code !== null);
|
|
4990
|
+
if (result.groups.some(skipsDirectories)) notes.push("Sizes inside skipped directories are unknown. Measure one with: dat <dir> --all");
|
|
4974
4991
|
if (notes.length > 0) {
|
|
4975
4992
|
lines.push("");
|
|
4976
4993
|
for (const note of notes) lines.push(s.dim(note));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dir-analysis-tool",
|
|
3
|
-
"version": "3.5.
|
|
3
|
+
"version": "3.5.4",
|
|
4
4
|
"description": "Fast, zero-dependency directory analysis for your terminal and CI: largest folders and files, type and extension breakdowns, staged duplicate detection, size budgets, directory diffs, and self-contained HTML, Markdown, JSON, and CSV reports.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
package/report.schema.json
CHANGED
|
@@ -1012,6 +1012,10 @@
|
|
|
1012
1012
|
"limit": {
|
|
1013
1013
|
"type": ["number", "string", "null"]
|
|
1014
1014
|
},
|
|
1015
|
+
"code": {
|
|
1016
|
+
"type": ["string", "null"],
|
|
1017
|
+
"description": "For a symlink group with --follow-symlinks: ENOENT (the target is missing) or ELOOP (the link loops). Null otherwise. Added in 3.5.4."
|
|
1018
|
+
},
|
|
1015
1019
|
"count": {
|
|
1016
1020
|
"type": "integer",
|
|
1017
1021
|
"minimum": 0
|