@macrulez/devtoolz 0.1.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.
- package/LICENSE +21 -0
- package/README.md +262 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +330 -0
- package/dist/cli.js.map +1 -0
- package/dist/commands/case-check/core.d.ts +17 -0
- package/dist/commands/case-check/core.js +46 -0
- package/dist/commands/case-check/core.js.map +1 -0
- package/dist/commands/case-check/parse.d.ts +10 -0
- package/dist/commands/case-check/parse.js +52 -0
- package/dist/commands/case-check/parse.js.map +1 -0
- package/dist/commands/case-check/report.d.ts +3 -0
- package/dist/commands/case-check/report.js +38 -0
- package/dist/commands/case-check/report.js.map +1 -0
- package/dist/commands/case-check/resolve-case.d.ts +14 -0
- package/dist/commands/case-check/resolve-case.js +163 -0
- package/dist/commands/case-check/resolve-case.js.map +1 -0
- package/dist/commands/case-check/run.d.ts +31 -0
- package/dist/commands/case-check/run.js +72 -0
- package/dist/commands/case-check/run.js.map +1 -0
- package/dist/commands/case-check/tsconfig-paths.d.ts +19 -0
- package/dist/commands/case-check/tsconfig-paths.js +119 -0
- package/dist/commands/case-check/tsconfig-paths.js.map +1 -0
- package/dist/commands/case-check/vue.d.ts +8 -0
- package/dist/commands/case-check/vue.js +26 -0
- package/dist/commands/case-check/vue.js.map +1 -0
- package/dist/commands/console-strip/core.d.ts +23 -0
- package/dist/commands/console-strip/core.js +104 -0
- package/dist/commands/console-strip/core.js.map +1 -0
- package/dist/commands/console-strip/report.d.ts +3 -0
- package/dist/commands/console-strip/report.js +47 -0
- package/dist/commands/console-strip/report.js.map +1 -0
- package/dist/commands/console-strip/run.d.ts +30 -0
- package/dist/commands/console-strip/run.js +55 -0
- package/dist/commands/console-strip/run.js.map +1 -0
- package/dist/commands/console-strip/vue.d.ts +8 -0
- package/dist/commands/console-strip/vue.js +28 -0
- package/dist/commands/console-strip/vue.js.map +1 -0
- package/dist/commands/dead-exports/core.d.ts +19 -0
- package/dist/commands/dead-exports/core.js +136 -0
- package/dist/commands/dead-exports/core.js.map +1 -0
- package/dist/commands/dead-exports/entry.d.ts +2 -0
- package/dist/commands/dead-exports/entry.js +93 -0
- package/dist/commands/dead-exports/entry.js.map +1 -0
- package/dist/commands/dead-exports/parse.d.ts +30 -0
- package/dist/commands/dead-exports/parse.js +174 -0
- package/dist/commands/dead-exports/parse.js.map +1 -0
- package/dist/commands/dead-exports/report.d.ts +3 -0
- package/dist/commands/dead-exports/report.js +27 -0
- package/dist/commands/dead-exports/report.js.map +1 -0
- package/dist/commands/dead-exports/resolve.d.ts +10 -0
- package/dist/commands/dead-exports/resolve.js +58 -0
- package/dist/commands/dead-exports/resolve.js.map +1 -0
- package/dist/commands/dead-exports/run.d.ts +21 -0
- package/dist/commands/dead-exports/run.js +51 -0
- package/dist/commands/dead-exports/run.js.map +1 -0
- package/dist/commands/dead-exports/workspace.d.ts +14 -0
- package/dist/commands/dead-exports/workspace.js +99 -0
- package/dist/commands/dead-exports/workspace.js.map +1 -0
- package/dist/commands/exports-doctor/core.d.ts +13 -0
- package/dist/commands/exports-doctor/core.js +85 -0
- package/dist/commands/exports-doctor/core.js.map +1 -0
- package/dist/commands/exports-doctor/parse.d.ts +20 -0
- package/dist/commands/exports-doctor/parse.js +80 -0
- package/dist/commands/exports-doctor/parse.js.map +1 -0
- package/dist/commands/exports-doctor/report.d.ts +3 -0
- package/dist/commands/exports-doctor/report.js +36 -0
- package/dist/commands/exports-doctor/report.js.map +1 -0
- package/dist/commands/exports-doctor/resolve-path.d.ts +10 -0
- package/dist/commands/exports-doctor/resolve-path.js +46 -0
- package/dist/commands/exports-doctor/resolve-path.js.map +1 -0
- package/dist/commands/exports-doctor/run.d.ts +13 -0
- package/dist/commands/exports-doctor/run.js +25 -0
- package/dist/commands/exports-doctor/run.js.map +1 -0
- package/dist/commands/readme-check/core.d.ts +22 -0
- package/dist/commands/readme-check/core.js +92 -0
- package/dist/commands/readme-check/core.js.map +1 -0
- package/dist/commands/readme-check/extract.d.ts +9 -0
- package/dist/commands/readme-check/extract.js +48 -0
- package/dist/commands/readme-check/extract.js.map +1 -0
- package/dist/commands/readme-check/lang.d.ts +8 -0
- package/dist/commands/readme-check/lang.js +21 -0
- package/dist/commands/readme-check/lang.js.map +1 -0
- package/dist/commands/readme-check/report.d.ts +3 -0
- package/dist/commands/readme-check/report.js +31 -0
- package/dist/commands/readme-check/report.js.map +1 -0
- package/dist/commands/readme-check/run.d.ts +19 -0
- package/dist/commands/readme-check/run.js +34 -0
- package/dist/commands/readme-check/run.js.map +1 -0
- package/dist/commands/readme-check/tsconfig.d.ts +9 -0
- package/dist/commands/readme-check/tsconfig.js +26 -0
- package/dist/commands/readme-check/tsconfig.js.map +1 -0
- package/dist/commands/readme-check/typecheck.d.ts +31 -0
- package/dist/commands/readme-check/typecheck.js +82 -0
- package/dist/commands/readme-check/typecheck.js.map +1 -0
- package/dist/commands/strip-comments/apply-deletions.d.ts +17 -0
- package/dist/commands/strip-comments/apply-deletions.js +74 -0
- package/dist/commands/strip-comments/apply-deletions.js.map +1 -0
- package/dist/commands/strip-comments/core.d.ts +15 -0
- package/dist/commands/strip-comments/core.js +111 -0
- package/dist/commands/strip-comments/core.js.map +1 -0
- package/dist/commands/strip-comments/report.d.ts +6 -0
- package/dist/commands/strip-comments/report.js +30 -0
- package/dist/commands/strip-comments/report.js.map +1 -0
- package/dist/commands/strip-comments/run.d.ts +28 -0
- package/dist/commands/strip-comments/run.js +50 -0
- package/dist/commands/strip-comments/run.js.map +1 -0
- package/dist/commands/strip-comments/vue.d.ts +6 -0
- package/dist/commands/strip-comments/vue.js +65 -0
- package/dist/commands/strip-comments/vue.js.map +1 -0
- package/dist/format/colors.d.ts +8 -0
- package/dist/format/colors.js +14 -0
- package/dist/format/colors.js.map +1 -0
- package/dist/format/diff-render.d.ts +2 -0
- package/dist/format/diff-render.js +35 -0
- package/dist/format/diff-render.js.map +1 -0
- package/dist/format/file-list.d.ts +14 -0
- package/dist/format/file-list.js +26 -0
- package/dist/format/file-list.js.map +1 -0
- package/dist/format/findings-list.d.ts +14 -0
- package/dist/format/findings-list.js +23 -0
- package/dist/format/findings-list.js.map +1 -0
- package/dist/format/vibes.d.ts +10 -0
- package/dist/format/vibes.js +67 -0
- package/dist/format/vibes.js.map +1 -0
- package/dist/index.d.ts +47 -0
- package/dist/index.js +29 -0
- package/dist/index.js.map +1 -0
- package/dist/utils/diff.d.ts +1 -0
- package/dist/utils/diff.js +13 -0
- package/dist/utils/diff.js.map +1 -0
- package/dist/utils/walk.d.ts +19 -0
- package/dist/utils/walk.js +96 -0
- package/dist/utils/walk.js.map +1 -0
- package/package.json +57 -0
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { isFancyOutputEnabled } from './vibes.js';
|
|
2
|
+
import { BOLD, CYAN, colorize, GREEN, RED } from './colors.js';
|
|
3
|
+
const RULE_CHAR = '─';
|
|
4
|
+
const DEFAULT_WIDTH = 70;
|
|
5
|
+
// `unifiedDiff()` (utils/diff.ts) produces a plain, colorless string with
|
|
6
|
+
// git's own "Index: x / ===.../ --- x / +++ x" preamble — fine as data
|
|
7
|
+
// (that's what --json returns verbatim), but with several files' diffs
|
|
8
|
+
// printed back to back it's genuinely hard to tell where one ends and the
|
|
9
|
+
// next begins, and +/- lines all look the same. This renders that same
|
|
10
|
+
// diff for a human terminal instead: the boilerplate preamble is replaced
|
|
11
|
+
// with one clear, colored rule bearing the file name (and its comment/
|
|
12
|
+
// statement count, so it doesn't need re-reading from the list above),
|
|
13
|
+
// and +/- lines get their usual red/green.
|
|
14
|
+
export function renderDiffForHumans(file, count, unit, patch, options = {}) {
|
|
15
|
+
const fancy = isFancyOutputEnabled(options);
|
|
16
|
+
const lines = patch.split('\n');
|
|
17
|
+
const firstHunkIndex = lines.findIndex((l) => l.startsWith('@@'));
|
|
18
|
+
const body = firstHunkIndex === -1 ? lines : lines.slice(firstHunkIndex);
|
|
19
|
+
const width = (fancy && process.stdout.isTTY && process.stdout.columns) || DEFAULT_WIDTH;
|
|
20
|
+
const label = ` ${file} (${count} ${unit}) `;
|
|
21
|
+
const ruleWidth = Math.max(0, width - label.length - 2);
|
|
22
|
+
const headerText = `${RULE_CHAR}${RULE_CHAR}${label}${RULE_CHAR.repeat(ruleWidth)}`;
|
|
23
|
+
const header = fancy ? colorize(BOLD + CYAN, headerText) : headerText;
|
|
24
|
+
const renderedBody = body.map((line) => {
|
|
25
|
+
if (line.startsWith('@@'))
|
|
26
|
+
return fancy ? colorize(CYAN, line) : line;
|
|
27
|
+
if (line.startsWith('+') && !line.startsWith('+++'))
|
|
28
|
+
return fancy ? colorize(GREEN, line) : line;
|
|
29
|
+
if (line.startsWith('-') && !line.startsWith('---'))
|
|
30
|
+
return fancy ? colorize(RED, line) : line;
|
|
31
|
+
return line;
|
|
32
|
+
});
|
|
33
|
+
return [header, ...renderedBody].join('\n');
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=diff-render.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diff-render.js","sourceRoot":"","sources":["../../src/format/diff-render.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAqB,MAAM,YAAY,CAAA;AACpE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,aAAa,CAAA;AAE9D,MAAM,SAAS,GAAG,GAAG,CAAA;AACrB,MAAM,aAAa,GAAG,EAAE,CAAA;AAExB,0EAA0E;AAC1E,uEAAuE;AACvE,uEAAuE;AACvE,0EAA0E;AAC1E,uEAAuE;AACvE,0EAA0E;AAC1E,uEAAuE;AACvE,uEAAuE;AACvE,2CAA2C;AAC3C,MAAM,UAAU,mBAAmB,CACjC,IAAY,EACZ,KAAa,EACb,IAAY,EACZ,KAAa,EACb,UAAwB,EAAE;IAE1B,MAAM,KAAK,GAAG,oBAAoB,CAAC,OAAO,CAAC,CAAA;IAE3C,MAAM,KAAK,GAAG,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,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAA;QAChG,IAAI,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC;YAAE,OAAO,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAA;QAC9F,OAAO,IAAI,CAAA;IACb,CAAC,CAAC,CAAA;IAEF,OAAO,CAAC,MAAM,EAAE,GAAG,YAAY,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;AAC7C,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type VibesOptions } from './vibes.js';
|
|
2
|
+
export interface FileCountEntry {
|
|
3
|
+
file: string;
|
|
4
|
+
count: number;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Renders a `file count` list as two aligned columns — file path on the
|
|
8
|
+
* left (white when fancy output is on), count on the right (dim), no
|
|
9
|
+
* parens around it. Padding is computed on the PLAIN text first and only
|
|
10
|
+
* wrapped in color codes afterward — padding a string that already has
|
|
11
|
+
* ANSI escapes in it counts those invisible bytes toward the width and
|
|
12
|
+
* throws the alignment off.
|
|
13
|
+
*/
|
|
14
|
+
export declare function formatFileCountRows(entries: FileCountEntry[], unit: (count: number) => string, options?: VibesOptions): string[];
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { isFancyOutputEnabled } from './vibes.js';
|
|
2
|
+
import { colorize, DIM, WHITE } from './colors.js';
|
|
3
|
+
/**
|
|
4
|
+
* Renders a `file count` list as two aligned columns — file path on the
|
|
5
|
+
* left (white when fancy output is on), count on the right (dim), no
|
|
6
|
+
* parens around it. Padding is computed on the PLAIN text first and only
|
|
7
|
+
* wrapped in color codes afterward — padding a string that already has
|
|
8
|
+
* ANSI escapes in it counts those invisible bytes toward the width and
|
|
9
|
+
* throws the alignment off.
|
|
10
|
+
*/
|
|
11
|
+
export function formatFileCountRows(entries, unit, options = {}) {
|
|
12
|
+
if (entries.length === 0)
|
|
13
|
+
return [];
|
|
14
|
+
const fancy = isFancyOutputEnabled(options);
|
|
15
|
+
const fileWidth = Math.max(...entries.map((e) => e.file.length));
|
|
16
|
+
const countTexts = entries.map((e) => `${e.count} ${unit(e.count)}`);
|
|
17
|
+
const countWidth = Math.max(...countTexts.map((t) => t.length));
|
|
18
|
+
return entries.map((entry, i) => {
|
|
19
|
+
const filePart = entry.file.padEnd(fileWidth);
|
|
20
|
+
const countPart = countTexts[i].padStart(countWidth);
|
|
21
|
+
const styledFile = fancy ? colorize(WHITE, filePart) : filePart;
|
|
22
|
+
const styledCount = fancy ? colorize(DIM, countPart) : countPart;
|
|
23
|
+
return ` ${styledFile} ${styledCount}`;
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=file-list.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file-list.js","sourceRoot":"","sources":["../../src/format/file-list.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAqB,MAAM,YAAY,CAAA;AACpE,OAAO,EAAE,QAAQ,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AAOlD;;;;;;;GAOG;AACH,MAAM,UAAU,mBAAmB,CACjC,OAAyB,EACzB,IAA+B,EAC/B,UAAwB,EAAE;IAE1B,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAAE,CAAA;IAEnC,MAAM,KAAK,GAAG,oBAAoB,CAAC,OAAO,CAAC,CAAA;IAC3C,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAA;IAChE,MAAM,UAAU,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC,KAAK,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC,CAAA;IACpE,MAAM,UAAU,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAA;IAE/D,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,CAAC,EAAE,EAAE;QAC9B,MAAM,QAAQ,GAAG,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAA;QAC7C,MAAM,SAAS,GAAI,UAAU,CAAC,CAAC,CAAY,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAA;QAChE,MAAM,UAAU,GAAG,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAA;QAC/D,MAAM,WAAW,GAAG,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS,CAAA;QAChE,OAAO,KAAK,UAAU,KAAK,WAAW,EAAE,CAAA;IAC1C,CAAC,CAAC,CAAA;AACJ,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type VibesOptions } from './vibes.js';
|
|
2
|
+
export interface FindingRow {
|
|
3
|
+
/** e.g. "src/foo.ts:12" */
|
|
4
|
+
location: string;
|
|
5
|
+
name: string;
|
|
6
|
+
/** e.g. "(type)", "(default)" — empty string for a plain named export */
|
|
7
|
+
tag: string;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Three aligned columns — location (white), symbol name (cyan), trailing
|
|
11
|
+
* tag (dim) — same padding-before-color rule as file-list.ts: widths are
|
|
12
|
+
* computed on the plain text first, colors wrapped on afterward.
|
|
13
|
+
*/
|
|
14
|
+
export declare function formatFindingsRows(entries: FindingRow[], options?: VibesOptions): string[];
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { isFancyOutputEnabled } from './vibes.js';
|
|
2
|
+
import { colorize, CYAN, DIM, WHITE } from './colors.js';
|
|
3
|
+
/**
|
|
4
|
+
* Three aligned columns — location (white), symbol name (cyan), trailing
|
|
5
|
+
* tag (dim) — same padding-before-color rule as file-list.ts: widths are
|
|
6
|
+
* computed on the plain text first, colors wrapped on afterward.
|
|
7
|
+
*/
|
|
8
|
+
export function formatFindingsRows(entries, options = {}) {
|
|
9
|
+
if (entries.length === 0)
|
|
10
|
+
return [];
|
|
11
|
+
const fancy = isFancyOutputEnabled(options);
|
|
12
|
+
const locationWidth = Math.max(...entries.map((e) => e.location.length));
|
|
13
|
+
const nameWidth = Math.max(...entries.map((e) => e.name.length));
|
|
14
|
+
return entries.map((entry) => {
|
|
15
|
+
const locationPart = entry.location.padEnd(locationWidth);
|
|
16
|
+
const namePart = entry.name.padEnd(nameWidth);
|
|
17
|
+
const styledLocation = fancy ? colorize(WHITE, locationPart) : locationPart;
|
|
18
|
+
const styledName = fancy ? colorize(CYAN, namePart) : namePart;
|
|
19
|
+
const styledTag = entry.tag && fancy ? colorize(DIM, entry.tag) : entry.tag;
|
|
20
|
+
return ` ${styledLocation} ${styledName} ${styledTag}`.trimEnd();
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=findings-list.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"findings-list.js","sourceRoot":"","sources":["../../src/format/findings-list.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAqB,MAAM,YAAY,CAAA;AACpE,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AAUxD;;;;GAIG;AACH,MAAM,UAAU,kBAAkB,CAAC,OAAqB,EAAE,UAAwB,EAAE;IAClF,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC;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
|
+
quiet?: boolean;
|
|
4
|
+
/** --plain: force plain output even in a real TTY (explicit opt-out) */
|
|
5
|
+
plain?: boolean;
|
|
6
|
+
}
|
|
7
|
+
export declare function isFancyOutputEnabled(options?: VibesOptions): boolean;
|
|
8
|
+
export declare function banner(): string;
|
|
9
|
+
export declare function cleanCelebration(options?: VibesOptions): string;
|
|
10
|
+
export declare function firstRunAside(options?: VibesOptions): string | null;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
// Centralized pool of the CLI's "personality" moments — see features.md
|
|
2
|
+
// "Тон вывода" for the ground rules this exists to enforce: humor only at
|
|
3
|
+
// bookending moments (banner, all-clean celebration), never inside the
|
|
4
|
+
// actual findings list, and only when there's a real human at a real
|
|
5
|
+
// terminal to appreciate it. Every command imports from here instead of
|
|
6
|
+
// hardcoding a joke inline, so the tone can be tuned in one place.
|
|
7
|
+
// Fancy output (color, banner, celebration copy) only makes sense for a
|
|
8
|
+
// human watching a real terminal in real time — auto-off the moment any of
|
|
9
|
+
// that isn't true, no flag required. `--json`/`--quiet`/`--plain` are
|
|
10
|
+
// additional explicit opt-outs on top of this auto-detection.
|
|
11
|
+
export function isFancyOutputEnabled(options = {}) {
|
|
12
|
+
if (options.quiet || options.plain)
|
|
13
|
+
return false;
|
|
14
|
+
if (process.env.NO_COLOR)
|
|
15
|
+
return false;
|
|
16
|
+
if (process.env.CI)
|
|
17
|
+
return false;
|
|
18
|
+
if (!process.stdout.isTTY)
|
|
19
|
+
return false;
|
|
20
|
+
return true;
|
|
21
|
+
}
|
|
22
|
+
function pick(pool) {
|
|
23
|
+
const item = pool[Math.floor(Math.random() * pool.length)];
|
|
24
|
+
// pool is always non-empty at every call site below — see the arrays
|
|
25
|
+
// themselves, not worth threading `| undefined` through every caller.
|
|
26
|
+
return item;
|
|
27
|
+
}
|
|
28
|
+
const BANNERS = [
|
|
29
|
+
'🧰 devtoolz',
|
|
30
|
+
'🧰 devtoolz — chores, automated',
|
|
31
|
+
'🧰 devtoolz, reporting for duty',
|
|
32
|
+
];
|
|
33
|
+
// One compact line, shown once per invocation — never a multi-line ASCII
|
|
34
|
+
// block. That's reserved for the all-clean celebration below, where it's
|
|
35
|
+
// actually earned.
|
|
36
|
+
export function banner() {
|
|
37
|
+
return pick(BANNERS);
|
|
38
|
+
}
|
|
39
|
+
const CLEAN_LINES = [
|
|
40
|
+
'Nothing to see here. Suspiciously clean, even.',
|
|
41
|
+
'Spotless. Go treat yourself.',
|
|
42
|
+
'0 findings. The codebase gods are pleased.',
|
|
43
|
+
'Clean sweep. No notes.',
|
|
44
|
+
"All clear — didn't even break a sweat.",
|
|
45
|
+
'Nothing found. Somebody already did their homework.',
|
|
46
|
+
];
|
|
47
|
+
const CLEAN_ART = [
|
|
48
|
+
[' ✨', ' ( ノ^ヮ^)ノ', ' good stuff'].join('\n'),
|
|
49
|
+
[' ┏(^0^)┛', ' nothing to fix here'].join('\n'),
|
|
50
|
+
[' ( •_•)>⌐■-■', ' (⌐■_■)', ' deal with it'].join('\n'),
|
|
51
|
+
];
|
|
52
|
+
// The one moment ASCII art is allowed at all — a command found ZERO
|
|
53
|
+
// issues. Small, a few lines max, never on a run that actually found
|
|
54
|
+
// something (see features.md: don't joke over a real problem report).
|
|
55
|
+
export function cleanCelebration(options = {}) {
|
|
56
|
+
const line = pick(CLEAN_LINES);
|
|
57
|
+
if (!isFancyOutputEnabled(options))
|
|
58
|
+
return line;
|
|
59
|
+
return `${line}\n${pick(CLEAN_ART)}`;
|
|
60
|
+
}
|
|
61
|
+
const FIRST_RUN_LINES = ["First time here? Let's see what we've got.", 'Taking a look...'];
|
|
62
|
+
export function firstRunAside(options = {}) {
|
|
63
|
+
if (!isFancyOutputEnabled(options))
|
|
64
|
+
return null;
|
|
65
|
+
return pick(FIRST_RUN_LINES);
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=vibes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vibes.js","sourceRoot":"","sources":["../../src/format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AC,IAAI,CAAC;IACnD,CAAC,gBAAgB,EAAE,WAAW,EAAE,iBAAiB,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;CAC9D,CAAA;AAED,oEAAoE;AACpE,qEAAqE;AACrE,sEAAsE;AACtE,MAAM,UAAU,gBAAgB,CAAC,UAAwB,EAAE;IACzD,MAAM,IAAI,GAAG,IAAI,CAAC,WAAW,CAAC,CAAA;IAC9B,IAAI,CAAC,oBAAoB,CAAC,OAAO,CAAC;QAAE,OAAO,IAAI,CAAA;IAC/C,OAAO,GAAG,IAAI,KAAK,IAAI,CAAC,SAAS,CAAC,EAAE,CAAA;AACtC,CAAC;AAED,MAAM,eAAe,GAAG,CAAC,4CAA4C,EAAE,kBAAkB,CAAC,CAAA;AAE1F,MAAM,UAAU,aAAa,CAAC,UAAwB,EAAE;IACtD,IAAI,CAAC,oBAAoB,CAAC,OAAO,CAAC;QAAE,OAAO,IAAI,CAAA;IAC/C,OAAO,IAAI,CAAC,eAAe,CAAC,CAAA;AAC9B,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
export { stripComments } from './commands/strip-comments/core.js';
|
|
2
|
+
export type { StripCommentsOptions, StripCommentsResult } from './commands/strip-comments/core.js';
|
|
3
|
+
export { stripVueComments } from './commands/strip-comments/vue.js';
|
|
4
|
+
export { runStripComments } from './commands/strip-comments/run.js';
|
|
5
|
+
export type { StripCommentsRunOptions, StripCommentsFileChange, StripCommentsReport, } from './commands/strip-comments/run.js';
|
|
6
|
+
export { renderStripCommentsReport } from './commands/strip-comments/report.js';
|
|
7
|
+
export { stripConsole } from './commands/console-strip/core.js';
|
|
8
|
+
export type { StripConsoleOptions, StripConsoleResult, SkippedCall, SkipReason, } from './commands/console-strip/core.js';
|
|
9
|
+
export { stripConsoleVue } from './commands/console-strip/vue.js';
|
|
10
|
+
export { runConsoleStrip } from './commands/console-strip/run.js';
|
|
11
|
+
export type { ConsoleStripRunOptions, ConsoleStripFileChange, ConsoleStripSkipped, ConsoleStripReport, } from './commands/console-strip/run.js';
|
|
12
|
+
export { renderConsoleStripReport } from './commands/console-strip/report.js';
|
|
13
|
+
export { analyzeDeadExports } from './commands/dead-exports/core.js';
|
|
14
|
+
export type { DeadExportFinding, DeadExportsAnalysis, AnalyzeOptions, } from './commands/dead-exports/core.js';
|
|
15
|
+
export { runDeadExports } from './commands/dead-exports/run.js';
|
|
16
|
+
export type { DeadExportsRunOptions, DeadExportsReport } from './commands/dead-exports/run.js';
|
|
17
|
+
export { renderDeadExportsReport } from './commands/dead-exports/report.js';
|
|
18
|
+
export { detectWorkspace } from './commands/dead-exports/workspace.js';
|
|
19
|
+
export type { WorkspaceInfo, WorkspacePackage } from './commands/dead-exports/workspace.js';
|
|
20
|
+
export { resolvePublicEntries, findNearestPackageDir } from './commands/dead-exports/entry.js';
|
|
21
|
+
export { checkSpecifierCase } from './commands/case-check/resolve-case.js';
|
|
22
|
+
export type { CaseCheckOutcome } from './commands/case-check/resolve-case.js';
|
|
23
|
+
export { checkFile } from './commands/case-check/core.js';
|
|
24
|
+
export type { CaseCheckFinding } from './commands/case-check/core.js';
|
|
25
|
+
export { runCaseCheck } from './commands/case-check/run.js';
|
|
26
|
+
export type { CaseCheckRunOptions, CaseCheckFileFinding, CaseCheckFileChange, CaseCheckReport, } from './commands/case-check/run.js';
|
|
27
|
+
export { renderCaseCheckReport } from './commands/case-check/report.js';
|
|
28
|
+
export { findTsconfig, loadTsconfigPaths, resolveAlias, } from './commands/case-check/tsconfig-paths.js';
|
|
29
|
+
export type { TsconfigPaths } from './commands/case-check/tsconfig-paths.js';
|
|
30
|
+
export { checkPackage } from './commands/exports-doctor/core.js';
|
|
31
|
+
export type { ExportsDoctorFinding, ExportsDoctorResult, FindingKind, } from './commands/exports-doctor/core.js';
|
|
32
|
+
export { runExportsDoctor } from './commands/exports-doctor/run.js';
|
|
33
|
+
export type { ExportsDoctorRunOptions, ExportsDoctorReport } from './commands/exports-doctor/run.js';
|
|
34
|
+
export { renderExportsDoctorReport } from './commands/exports-doctor/report.js';
|
|
35
|
+
export { extractCodeBlocks } from './commands/readme-check/extract.js';
|
|
36
|
+
export type { CodeBlock } from './commands/readme-check/extract.js';
|
|
37
|
+
export { typecheckBlock } from './commands/readme-check/typecheck.js';
|
|
38
|
+
export type { BlockDiagnostic } from './commands/readme-check/typecheck.js';
|
|
39
|
+
export { loadCompilerOptions } from './commands/readme-check/tsconfig.js';
|
|
40
|
+
export type { LoadedCompilerOptions, LoadCompilerOptionsResult, } from './commands/readme-check/tsconfig.js';
|
|
41
|
+
export { checkMarkdownFile } from './commands/readme-check/core.js';
|
|
42
|
+
export type { ReadmeCheckFinding, ReadmeCheckFileResult } from './commands/readme-check/core.js';
|
|
43
|
+
export { runReadmeCheck } from './commands/readme-check/run.js';
|
|
44
|
+
export type { ReadmeCheckRunOptions, ReadmeCheckReport } from './commands/readme-check/run.js';
|
|
45
|
+
export { renderReadmeCheckReport } from './commands/readme-check/report.js';
|
|
46
|
+
export { walk } from './utils/walk.js';
|
|
47
|
+
export type { WalkOptions } from './utils/walk.js';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export { stripComments } from './commands/strip-comments/core.js';
|
|
2
|
+
export { stripVueComments } from './commands/strip-comments/vue.js';
|
|
3
|
+
export { runStripComments } from './commands/strip-comments/run.js';
|
|
4
|
+
export { renderStripCommentsReport } from './commands/strip-comments/report.js';
|
|
5
|
+
export { stripConsole } from './commands/console-strip/core.js';
|
|
6
|
+
export { stripConsoleVue } from './commands/console-strip/vue.js';
|
|
7
|
+
export { runConsoleStrip } from './commands/console-strip/run.js';
|
|
8
|
+
export { renderConsoleStripReport } from './commands/console-strip/report.js';
|
|
9
|
+
export { analyzeDeadExports } from './commands/dead-exports/core.js';
|
|
10
|
+
export { runDeadExports } from './commands/dead-exports/run.js';
|
|
11
|
+
export { renderDeadExportsReport } from './commands/dead-exports/report.js';
|
|
12
|
+
export { detectWorkspace } from './commands/dead-exports/workspace.js';
|
|
13
|
+
export { resolvePublicEntries, findNearestPackageDir } from './commands/dead-exports/entry.js';
|
|
14
|
+
export { checkSpecifierCase } from './commands/case-check/resolve-case.js';
|
|
15
|
+
export { checkFile } from './commands/case-check/core.js';
|
|
16
|
+
export { runCaseCheck } from './commands/case-check/run.js';
|
|
17
|
+
export { renderCaseCheckReport } from './commands/case-check/report.js';
|
|
18
|
+
export { findTsconfig, loadTsconfigPaths, resolveAlias, } from './commands/case-check/tsconfig-paths.js';
|
|
19
|
+
export { checkPackage } from './commands/exports-doctor/core.js';
|
|
20
|
+
export { runExportsDoctor } from './commands/exports-doctor/run.js';
|
|
21
|
+
export { renderExportsDoctorReport } from './commands/exports-doctor/report.js';
|
|
22
|
+
export { extractCodeBlocks } from './commands/readme-check/extract.js';
|
|
23
|
+
export { typecheckBlock } from './commands/readme-check/typecheck.js';
|
|
24
|
+
export { loadCompilerOptions } from './commands/readme-check/tsconfig.js';
|
|
25
|
+
export { checkMarkdownFile } from './commands/readme-check/core.js';
|
|
26
|
+
export { runReadmeCheck } from './commands/readme-check/run.js';
|
|
27
|
+
export { renderReadmeCheckReport } from './commands/readme-check/report.js';
|
|
28
|
+
export { walk } from './utils/walk.js';
|
|
29
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAA;AAGjE,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAA;AAEnE,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAA;AAOnE,OAAO,EAAE,yBAAyB,EAAE,MAAM,qCAAqC,CAAA;AAE/E,OAAO,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAA;AAQ/D,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAA;AAEjE,OAAO,EAAE,eAAe,E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(file: string, before: string, after: string): string;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { createTwoFilesPatch } from 'diff';
|
|
2
|
+
// A real unified diff, not a hand-rolled approximation — this is the
|
|
3
|
+
// output someone reviews BEFORE trusting a tool that deletes code from
|
|
4
|
+
// their files, it has to be right, not "close enough".
|
|
5
|
+
export function unifiedDiff(file, before, after) {
|
|
6
|
+
const patch = createTwoFilesPatch(file, file, before, after, '', '', { context: 2 });
|
|
7
|
+
// createTwoFilesPatch always appends a tab after the file name on the
|
|
8
|
+
// --- / +++ header lines (meant to separate it from a timestamp), even
|
|
9
|
+
// when no timestamp is given — trims the resulting trailing tab so the
|
|
10
|
+
// header doesn't end in invisible whitespace.
|
|
11
|
+
return patch.replace(/^(--- .+?|\+\+\+ .+?)\t$/gm, '$1');
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=diff.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diff.js","sourceRoot":"","sources":["../../src/utils/diff.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,MAAM,CAAA;AAE1C,qEAAqE;AACrE,uEAAuE;AACvE,uDAAuD;AACvD,MAAM,UAAU,WAAW,CAAC,IAAY,EAAE,MAAc,EAAE,KAAa;IACrE,MAAM,KAAK,GAAG,mBAAmB,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC,CAAA;IACpF,sEAAsE;IACtE,uEAAuE;IACvE,uEAAuE;IACvE,8CAA8C;IAC9C,OAAO,KAAK,CAAC,OAAO,CAAC,4BAA4B,EAAE,IAAI,CAAC,CAAA;AAC1D,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export interface WalkOptions {
|
|
2
|
+
cwd: string;
|
|
3
|
+
/** file extensions to include, each with its leading dot, e.g. ['.ts', '.vue'] */
|
|
4
|
+
extensions: string[];
|
|
5
|
+
/** extra gitignore-syntax patterns, on top of DEFAULT_IGNORES and the real .gitignore */
|
|
6
|
+
ignoreGlobs?: string[];
|
|
7
|
+
/** default true — also honor <cwd>/.gitignore, root-level only (see features.md case-check/walk caveats) */
|
|
8
|
+
respectGitignore?: boolean;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Resolves `inputPaths` (files and/or directories, as given on the CLI)
|
|
12
|
+
* into a flat, deduplicated list of absolute file paths matching
|
|
13
|
+
* `options.extensions` — directories are walked recursively, honoring
|
|
14
|
+
* DEFAULT_IGNORES + the real `.gitignore` + any extra `--ignore` globs.
|
|
15
|
+
* An explicitly-named file is included even if its extension wouldn't
|
|
16
|
+
* otherwise match (the caller asked for it by name) but is still subject
|
|
17
|
+
* to ignore-matching, so `--ignore` can still exclude it.
|
|
18
|
+
*/
|
|
19
|
+
export declare function walk(inputPaths: string[], options: WalkOptions): string[];
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { readFileSync, readdirSync, statSync } from 'node:fs';
|
|
2
|
+
import { basename, join, relative, resolve } from 'node:path';
|
|
3
|
+
import { createRequire } from 'node:module';
|
|
4
|
+
// `ignore` is CJS with no "exports" map in its package.json — under
|
|
5
|
+
// `moduleResolution: NodeNext` (which this project uses because it
|
|
6
|
+
// matches Node's actual runtime resolution, unlike "Bundler"), TS's
|
|
7
|
+
// default-export interop for exactly that shape of package breaks: `import
|
|
8
|
+
// ignore from 'ignore'` type-checks as the raw module namespace, not the
|
|
9
|
+
// callable factory (reproduced in isolation, not a config mistake here).
|
|
10
|
+
// Loading it via the real CJS loader sidesteps the broken interop
|
|
11
|
+
// entirely — arguably the more honest way to consume a CJS module from
|
|
12
|
+
// ESM anyway.
|
|
13
|
+
const require = createRequire(import.meta.url);
|
|
14
|
+
const ignore = require('ignore');
|
|
15
|
+
// Every dev-toolz command that scans a tree agrees on this default —
|
|
16
|
+
// listed once here instead of copy-pasted per command. `--ignore` (per
|
|
17
|
+
// command) adds to this, it never has to re-list these.
|
|
18
|
+
const DEFAULT_IGNORES = ['node_modules', 'dist', 'build', '.git', 'coverage'];
|
|
19
|
+
function buildMatcher(options) {
|
|
20
|
+
const matcher = ignore();
|
|
21
|
+
matcher.add(DEFAULT_IGNORES);
|
|
22
|
+
if (options.respectGitignore !== false) {
|
|
23
|
+
try {
|
|
24
|
+
const gitignoreText = readFileSync(join(options.cwd, '.gitignore'), 'utf8');
|
|
25
|
+
matcher.add(gitignoreText);
|
|
26
|
+
}
|
|
27
|
+
catch {
|
|
28
|
+
// no .gitignore at cwd root — nothing extra to add, not an error
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
if (options.ignoreGlobs?.length)
|
|
32
|
+
matcher.add(options.ignoreGlobs);
|
|
33
|
+
return matcher;
|
|
34
|
+
}
|
|
35
|
+
// `ignore` requires a path that's genuinely relative to its root (no `..`
|
|
36
|
+
// segments) and throws otherwise — true for everything under a normal
|
|
37
|
+
// `--cwd`-rooted scan, but a caller can point `walk()` at a path outside
|
|
38
|
+
// `--cwd` entirely (an unusual invocation, but not one that should crash).
|
|
39
|
+
// There's no `.gitignore`/`--ignore` rule that meaningfully applies
|
|
40
|
+
// outside the root they were read relative to, so falls back to just the
|
|
41
|
+
// hardcoded default-noise-directory names for anything out there.
|
|
42
|
+
function isIgnored(absPath, cwd, matcher) {
|
|
43
|
+
const relPath = relative(cwd, absPath).split('\\').join('/');
|
|
44
|
+
if (relPath === '')
|
|
45
|
+
return false;
|
|
46
|
+
if (relPath.startsWith('..'))
|
|
47
|
+
return DEFAULT_IGNORES.includes(basename(absPath));
|
|
48
|
+
return matcher.ignores(relPath);
|
|
49
|
+
}
|
|
50
|
+
function walkDir(absDir, cwd, matcher, extensions, out) {
|
|
51
|
+
for (const entry of readdirSync(absDir, { withFileTypes: true })) {
|
|
52
|
+
const absPath = join(absDir, entry.name);
|
|
53
|
+
if (isIgnored(absPath, cwd, matcher))
|
|
54
|
+
continue;
|
|
55
|
+
if (entry.isDirectory()) {
|
|
56
|
+
walkDir(absPath, cwd, matcher, extensions, out);
|
|
57
|
+
}
|
|
58
|
+
else if (entry.isFile()) {
|
|
59
|
+
const dot = entry.name.lastIndexOf('.');
|
|
60
|
+
const ext = dot === -1 ? '' : entry.name.slice(dot);
|
|
61
|
+
if (extensions.has(ext))
|
|
62
|
+
out.push(absPath);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Resolves `inputPaths` (files and/or directories, as given on the CLI)
|
|
68
|
+
* into a flat, deduplicated list of absolute file paths matching
|
|
69
|
+
* `options.extensions` — directories are walked recursively, honoring
|
|
70
|
+
* DEFAULT_IGNORES + the real `.gitignore` + any extra `--ignore` globs.
|
|
71
|
+
* An explicitly-named file is included even if its extension wouldn't
|
|
72
|
+
* otherwise match (the caller asked for it by name) but is still subject
|
|
73
|
+
* to ignore-matching, so `--ignore` can still exclude it.
|
|
74
|
+
*/
|
|
75
|
+
export function walk(inputPaths, options) {
|
|
76
|
+
const matcher = buildMatcher(options);
|
|
77
|
+
const extensions = new Set(options.extensions);
|
|
78
|
+
const roots = inputPaths.length > 0 ? inputPaths : ['.'];
|
|
79
|
+
const out = [];
|
|
80
|
+
for (const inputPath of roots) {
|
|
81
|
+
const absPath = resolve(options.cwd, inputPath);
|
|
82
|
+
if (isIgnored(absPath, options.cwd, matcher))
|
|
83
|
+
continue;
|
|
84
|
+
const stat = statSync(absPath, { throwIfNoEntry: false });
|
|
85
|
+
if (!stat)
|
|
86
|
+
continue;
|
|
87
|
+
if (stat.isDirectory()) {
|
|
88
|
+
walkDir(absPath, options.cwd, matcher, extensions, out);
|
|
89
|
+
}
|
|
90
|
+
else if (stat.isFile()) {
|
|
91
|
+
out.push(absPath);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
return [...new Set(out)];
|
|
95
|
+
}
|
|
96
|
+
//# sourceMappingURL=walk.js.map
|
|
@@ -0,0 +1 @@
|
|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AAC1B,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@macrulez/devtoolz",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "A small toolbox of CLI commands that automate routine dev chores — strip comments/console.log, find dead exports, catch case-sensitivity import bugs before Linux CI does",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"author": "macrulez <macrulezru@gmail.com> (https://macrulez.ru/en)",
|
|
8
|
+
"homepage": "https://github.com/macrulezru/devtoolz",
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://github.com/macrulezru/devtoolz.git"
|
|
12
|
+
},
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/macrulezru/devtoolz/issues"
|
|
15
|
+
},
|
|
16
|
+
"engines": {
|
|
17
|
+
"node": ">=20"
|
|
18
|
+
},
|
|
19
|
+
"publishConfig": {
|
|
20
|
+
"access": "public"
|
|
21
|
+
},
|
|
22
|
+
"bin": {
|
|
23
|
+
"devtoolz": "dist/cli.js"
|
|
24
|
+
},
|
|
25
|
+
"files": [
|
|
26
|
+
"dist"
|
|
27
|
+
],
|
|
28
|
+
"exports": {
|
|
29
|
+
".": "./dist/index.js"
|
|
30
|
+
},
|
|
31
|
+
"scripts": {
|
|
32
|
+
"build": "tsc -p tsconfig.json",
|
|
33
|
+
"dev": "tsx src/cli.ts",
|
|
34
|
+
"test": "vitest run",
|
|
35
|
+
"test:watch": "vitest",
|
|
36
|
+
"typecheck": "tsc --noEmit",
|
|
37
|
+
"lint": "eslint .",
|
|
38
|
+
"format": "prettier --check .",
|
|
39
|
+
"format:fix": "prettier --write ."
|
|
40
|
+
},
|
|
41
|
+
"dependencies": {
|
|
42
|
+
"commander": "^13.1.0",
|
|
43
|
+
"diff": "^7.0.0",
|
|
44
|
+
"ignore": "^6.0.2",
|
|
45
|
+
"typescript": "^5.7.3"
|
|
46
|
+
},
|
|
47
|
+
"devDependencies": {
|
|
48
|
+
"@eslint/js": "^9.20.0",
|
|
49
|
+
"@types/diff": "^6.0.0",
|
|
50
|
+
"@types/node": "^20.14.0",
|
|
51
|
+
"eslint": "^9.20.0",
|
|
52
|
+
"prettier": "^3.9.8",
|
|
53
|
+
"tsx": "^4.19.2",
|
|
54
|
+
"typescript-eslint": "^8.23.0",
|
|
55
|
+
"vitest": "^3.0.5"
|
|
56
|
+
}
|
|
57
|
+
}
|