@codefast/cli 0.9.0 → 0.11.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/CHANGELOG.md +61 -0
- package/README.md +345 -151
- package/dist/arrange/command.d.ts +7 -0
- package/dist/arrange/command.js +96 -132
- package/dist/arrange/domain/ast/ast-node.d.ts +394 -0
- package/dist/arrange/domain/ast/collectors-cn.d.ts +26 -0
- package/dist/arrange/domain/ast/collectors-jsx.d.ts +8 -0
- package/dist/arrange/domain/ast/collectors-tv.d.ts +34 -0
- package/dist/arrange/domain/ast/helpers.d.ts +36 -0
- package/dist/arrange/domain/ast/helpers.js +1 -0
- package/dist/arrange/domain/ast/simplify-targets.d.ts +22 -0
- package/dist/arrange/domain/ast/simplify-targets.js +18 -23
- package/dist/arrange/domain/ast/targets.d.ts +20 -0
- package/dist/arrange/domain/ast/translator.d.ts +32 -0
- package/dist/arrange/{typescript-ast-translator.js → domain/ast/translator.js} +19 -22
- package/dist/arrange/domain/constants.d.ts +111 -0
- package/dist/arrange/domain/grouping-service.d.ts +100 -0
- package/dist/arrange/domain/grouping.d.ts +21 -0
- package/dist/arrange/domain/imports.d.ts +14 -0
- package/dist/arrange/domain/source-text-formatters.d.ts +33 -0
- package/dist/arrange/domain/tailwind-token.d.ts +24 -0
- package/dist/arrange/domain/token-classifier.d.ts +47 -0
- package/dist/arrange/domain/types.d.ts +208 -0
- package/dist/arrange/group/cli-result.d.ts +7 -0
- package/dist/arrange/group/cli-result.js +12 -0
- package/dist/arrange/group/cli-schema.d.ts +17 -0
- package/dist/arrange/group/cli-schema.js +13 -0
- package/dist/arrange/group/output.d.ts +7 -0
- package/dist/arrange/group/output.js +10 -0
- package/dist/arrange/group/suggest.d.ts +8 -0
- package/dist/arrange/inspect/cli-result.d.ts +7 -0
- package/dist/arrange/inspect/cli-result.js +8 -0
- package/dist/arrange/inspect/cli-schema.d.ts +15 -0
- package/dist/arrange/inspect/cli-schema.js +9 -0
- package/dist/arrange/inspect/domain/analyze-service.d.ts +18 -0
- package/dist/arrange/inspect/output.d.ts +7 -0
- package/dist/arrange/inspect/output.js +42 -0
- package/dist/arrange/inspect/run.d.ts +10 -0
- package/dist/arrange/{analyze.js → inspect/run.js} +2 -2
- package/dist/arrange/prepare.d.ts +13 -0
- package/dist/arrange/{workspace.js → prepare.js} +5 -8
- package/dist/arrange/regroup/cli-result.d.ts +13 -0
- package/dist/arrange/regroup/cli-result.js +23 -0
- package/dist/arrange/regroup/cli-schema.d.ts +20 -0
- package/dist/arrange/regroup/cli-schema.js +14 -0
- package/dist/arrange/regroup/output.d.ts +14 -0
- package/dist/arrange/regroup/output.js +72 -0
- package/dist/arrange/regroup/process-file.d.ts +11 -0
- package/dist/arrange/regroup/run.d.ts +11 -0
- package/dist/arrange/{sync.js → regroup/run.js} +2 -2
- package/dist/arrange/resolve-target.d.ts +10 -0
- package/dist/arrange/resolve-target.js +3 -16
- package/dist/arrange/scan-target.d.ts +7 -0
- package/dist/arrange/simplify/cli-result.d.ts +7 -0
- package/dist/arrange/simplify/cli-result.js +8 -0
- package/dist/arrange/simplify/cli-schema.d.ts +17 -0
- package/dist/arrange/simplify/cli-schema.js +11 -0
- package/dist/arrange/simplify/fold-targets.d.ts +13 -0
- package/dist/arrange/simplify/fold-targets.js +139 -0
- package/dist/arrange/simplify/output.d.ts +7 -0
- package/dist/arrange/simplify/output.js +15 -0
- package/dist/arrange/simplify/process-file.d.ts +13 -0
- package/dist/arrange/simplify/process-file.js +49 -0
- package/dist/arrange/simplify/run.d.ts +14 -0
- package/dist/arrange/simplify/run.js +38 -0
- package/dist/arrange/simplify/variant-classname-probe.d.ts +35 -0
- package/dist/arrange/simplify/variant-classname-probe.js +95 -0
- package/dist/arrange/source-parse.d.ts +7 -0
- package/dist/arrange/source-parse.js +1 -1
- package/dist/audit/command.d.ts +8 -0
- package/dist/audit/command.js +134 -211
- package/dist/audit/comments/cli-result.d.ts +13 -0
- package/dist/audit/comments/cli-result.js +22 -0
- package/dist/audit/comments/cli-schema.d.ts +19 -0
- package/dist/audit/comments/cli-schema.js +13 -0
- package/dist/audit/comments/domain/comment-content.d.ts +26 -0
- package/dist/audit/comments/domain/comment-dividers.d.ts +62 -0
- package/dist/audit/comments/domain/link-references.d.ts +40 -0
- package/dist/audit/comments/domain/since-versions.d.ts +26 -0
- package/dist/audit/comments/domain/tsdoc-syntax.d.ts +20 -0
- package/dist/audit/comments/output.d.ts +7 -0
- package/dist/audit/comments/output.js +27 -0
- package/dist/audit/comments/prepare.d.ts +16 -0
- package/dist/audit/comments/prepare.js +12 -0
- package/dist/audit/comments/run.d.ts +17 -0
- package/dist/audit/{run-comments.js → comments/run.js} +5 -5
- package/dist/audit/display-names/cli-result.d.ts +13 -0
- package/dist/audit/display-names/cli-result.js +22 -0
- package/dist/audit/display-names/cli-schema.d.ts +18 -0
- package/dist/audit/display-names/cli-schema.js +12 -0
- package/dist/audit/display-names/domain/display-names.d.ts +11 -0
- package/dist/audit/display-names/output.d.ts +7 -0
- package/dist/audit/display-names/output.js +21 -0
- package/dist/audit/display-names/prepare.d.ts +16 -0
- package/dist/audit/display-names/prepare.js +12 -0
- package/dist/audit/display-names/run.d.ts +14 -0
- package/dist/audit/{run-display-names.js → display-names/run.js} +1 -1
- package/dist/audit/domain/types.d.ts +171 -0
- package/dist/audit/imports/cli-result.d.ts +13 -0
- package/dist/audit/imports/cli-result.js +22 -0
- package/dist/audit/imports/cli-schema.d.ts +18 -0
- package/dist/audit/imports/cli-schema.js +12 -0
- package/dist/audit/imports/domain/import-policy.d.ts +34 -0
- package/dist/audit/imports/domain/import-policy.js +140 -0
- package/dist/audit/imports/output.d.ts +7 -0
- package/dist/audit/imports/output.js +21 -0
- package/dist/audit/imports/prepare.d.ts +16 -0
- package/dist/audit/imports/prepare.js +12 -0
- package/dist/audit/imports/run.d.ts +14 -0
- package/dist/audit/{run-react.js → imports/run.js} +15 -5
- package/dist/audit/links/cli-result.d.ts +13 -0
- package/dist/audit/links/cli-result.js +22 -0
- package/dist/audit/links/cli-schema.d.ts +18 -0
- package/dist/audit/links/cli-schema.js +12 -0
- package/dist/audit/links/domain/markdown-links.d.ts +44 -0
- package/dist/audit/links/output.d.ts +7 -0
- package/dist/audit/links/output.js +21 -0
- package/dist/audit/links/prepare.d.ts +16 -0
- package/dist/audit/links/prepare.js +12 -0
- package/dist/audit/links/run.d.ts +14 -0
- package/dist/audit/{run-links.js → links/run.js} +1 -1
- package/dist/audit/prepare.d.ts +31 -0
- package/dist/audit/prepare.js +11 -134
- package/dist/audit/rtl/cli-result.d.ts +13 -0
- package/dist/audit/rtl/cli-result.js +22 -0
- package/dist/audit/rtl/cli-schema.d.ts +18 -0
- package/dist/audit/rtl/cli-schema.js +12 -0
- package/dist/audit/rtl/domain/audit-file.d.ts +7 -0
- package/dist/audit/{domain → rtl/domain}/audit-file.js +2 -2
- package/dist/audit/rtl/domain/mappings.d.ts +45 -0
- package/dist/audit/rtl/domain/tokenize.d.ts +14 -0
- package/dist/audit/rtl/output.d.ts +7 -0
- package/dist/audit/rtl/output.js +21 -0
- package/dist/audit/rtl/prepare.d.ts +13 -0
- package/dist/audit/rtl/prepare.js +41 -0
- package/dist/audit/rtl/run.d.ts +14 -0
- package/dist/audit/{run.js → rtl/run.js} +1 -1
- package/dist/bin.d.ts +2 -0
- package/dist/cli.d.ts +6 -0
- package/dist/core/cli/command-pipeline.d.ts +91 -0
- package/dist/core/cli/command-pipeline.js +83 -0
- package/dist/core/cli/format-error.d.ts +7 -0
- package/dist/core/cli/global-options.d.ts +15 -0
- package/dist/core/cli/global-options.js +1 -1
- package/dist/core/cli/positional.d.ts +6 -0
- package/dist/core/cli/resolve-root.d.ts +9 -0
- package/dist/core/cli/resolve-root.js +16 -0
- package/dist/core/cli/result-handle.d.ts +13 -0
- package/dist/core/cli/result-handle.js +0 -13
- package/dist/core/config/define-config.d.ts +7 -0
- package/dist/core/config/define-config.js +8 -0
- package/dist/core/config/loader.d.ts +18 -0
- package/dist/core/config/loader.js +2 -7
- package/dist/core/config/schema.d.ts +99 -0
- package/dist/core/config/schema.js +8 -86
- package/dist/core/config/warnings.d.ts +6 -0
- package/dist/core/config.d.ts +12 -0
- package/dist/core/errors.d.ts +25 -0
- package/dist/core/exit-codes.d.ts +18 -0
- package/dist/core/filesystem/filesystem.d.ts +44 -0
- package/dist/core/filesystem/node.d.ts +7 -0
- package/dist/core/filesystem/node.js +2 -1
- package/dist/core/glob.d.ts +19 -0
- package/dist/core/logger.d.ts +9 -0
- package/dist/core/result.d.ts +30 -0
- package/dist/core/schema-parse.d.ts +9 -0
- package/dist/core/source-text-edit.d.ts +47 -0
- package/dist/core/source-text-edit.js +22 -0
- package/dist/core/verbose-diagnostics.d.ts +6 -0
- package/dist/core/workspace/ancestor-directories.d.ts +12 -0
- package/dist/core/workspace/ancestor-directories.js +30 -0
- package/dist/core/workspace/markdown-walk.d.ts +7 -0
- package/dist/core/workspace/markdown-walk.js +2 -20
- package/dist/core/workspace/package-version.d.ts +9 -0
- package/dist/core/workspace/package-version.js +8 -12
- package/dist/core/workspace/resolver.d.ts +39 -0
- package/dist/core/workspace/resolver.js +58 -75
- package/dist/core/workspace/skip-directories.d.ts +6 -0
- package/dist/core/workspace/source-walk.d.ts +16 -0
- package/dist/core/workspace/source-walk.js +2 -19
- package/dist/core/workspace/typescript-walk.d.ts +7 -0
- package/dist/core/workspace/typescript-walk.js +2 -23
- package/dist/core/workspace/walk-files.d.ts +7 -0
- package/dist/core/workspace/walk-files.js +27 -0
- package/dist/core/workspace/well-known-files.d.ts +18 -0
- package/dist/core/workspace/well-known-files.js +18 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +5 -0
- package/dist/mirror/cli-result.d.ts +13 -0
- package/dist/mirror/cli-schema.d.ts +8 -0
- package/dist/mirror/cli-schema.js +1 -1
- package/dist/mirror/command.d.ts +7 -0
- package/dist/mirror/command.js +31 -60
- package/dist/mirror/dist-filesystem-node.d.ts +8 -0
- package/dist/mirror/{dist-filesystem-impl.js → dist-filesystem-node.js} +1 -1
- package/dist/mirror/domain/constants.d.ts +18 -0
- package/dist/mirror/domain/constants.js +0 -12
- package/dist/mirror/domain/dirent-guard.d.ts +10 -0
- package/dist/mirror/domain/dist-filesystem.d.ts +9 -0
- package/dist/mirror/domain/errors.d.ts +24 -0
- package/dist/mirror/domain/exports.d.ts +36 -0
- package/dist/mirror/domain/package-display-name.d.ts +8 -0
- package/dist/mirror/domain/path-normalizer.d.ts +6 -0
- package/dist/mirror/domain/types.d.ts +188 -0
- package/dist/mirror/output.d.ts +21 -0
- package/dist/mirror/output.js +126 -1
- package/dist/mirror/package-path.d.ts +19 -0
- package/dist/mirror/prepare.d.ts +15 -0
- package/dist/mirror/prepare.js +6 -10
- package/dist/mirror/run.d.ts +12 -0
- package/dist/mirror/{sync.js → run.js} +5 -3
- package/dist/mirror/supplement-exports.d.ts +27 -0
- package/dist/mirror/supplement-exports.js +2 -2
- package/dist/mirror/sync-workspace-package.d.ts +9 -0
- package/dist/mirror/sync-workspace-package.js +4 -4
- package/dist/mirror/write-exports.d.ts +15 -0
- package/dist/pack-slim/cli-result.d.ts +13 -0
- package/dist/pack-slim/cli-schema.d.ts +17 -0
- package/dist/pack-slim/cli-schema.js +1 -1
- package/dist/pack-slim/command.d.ts +7 -0
- package/dist/pack-slim/command.js +31 -66
- package/dist/pack-slim/domain/transform.d.ts +69 -0
- package/dist/pack-slim/domain/types.d.ts +46 -0
- package/dist/pack-slim/output.d.ts +15 -0
- package/dist/pack-slim/prepare.d.ts +21 -0
- package/dist/pack-slim/prepare.js +14 -0
- package/dist/pack-slim/run.d.ts +23 -0
- package/dist/pack-slim/{sync.js → run.js} +4 -4
- package/dist/pack-slim/working-tree.d.ts +20 -0
- package/dist/tag/cli-result.d.ts +13 -0
- package/dist/tag/cli-result.js +14 -1
- package/dist/tag/cli-schema.d.ts +8 -0
- package/dist/tag/cli-schema.js +3 -4
- package/dist/tag/command.d.ts +7 -0
- package/dist/tag/command.js +33 -60
- package/dist/tag/domain/skip-filter.d.ts +13 -0
- package/dist/tag/domain/skip-filter.js +29 -0
- package/dist/tag/domain/types.d.ts +131 -0
- package/dist/tag/domain/version-summary.d.ts +13 -0
- package/dist/tag/domain/version-summary.js +24 -0
- package/dist/tag/output.d.ts +17 -0
- package/dist/tag/output.js +6 -9
- package/dist/tag/prepare.d.ts +13 -0
- package/dist/tag/prepare.js +4 -4
- package/dist/tag/run.d.ts +10 -0
- package/dist/tag/{sync.js → run.js} +20 -50
- package/dist/tag/target/candidates.d.ts +8 -0
- package/dist/tag/{target-candidates.js → target/candidates.js} +2 -2
- package/dist/tag/target/resolve-path.d.ts +10 -0
- package/dist/tag/target/runner.d.ts +8 -0
- package/dist/tag/{target-runner.js → target/runner.js} +2 -2
- package/dist/tag/writer/since-writer.d.ts +32 -0
- package/dist/tag/writer/version-resolver.d.ts +7 -0
- package/package.json +21 -2
- package/dist/arrange/cli-schema.js +0 -34
- package/dist/arrange/output.js +0 -127
- package/dist/arrange/simplify-process-file.js +0 -30
- package/dist/arrange/simplify-sync.js +0 -30
- package/dist/audit/cli-schema.js +0 -66
- package/dist/audit/domain/react-imports.js +0 -91
- package/dist/audit/output.js +0 -213
- package/dist/mirror/sync-reporter.js +0 -124
- package/dist/mirror/sync-types.js +0 -1
- /package/dist/arrange/{suggest.js → group/suggest.js} +0 -0
- /package/dist/arrange/{domain → inspect/domain}/analyze-service.js +0 -0
- /package/dist/arrange/{process-file.js → regroup/process-file.js} +0 -0
- /package/dist/audit/{domain → comments/domain}/comment-content.js +0 -0
- /package/dist/audit/{domain → comments/domain}/comment-dividers.js +0 -0
- /package/dist/audit/{domain → comments/domain}/link-references.js +0 -0
- /package/dist/audit/{domain → comments/domain}/since-versions.js +0 -0
- /package/dist/audit/{domain → comments/domain}/tsdoc-syntax.js +0 -0
- /package/dist/audit/{domain → display-names/domain}/display-names.js +0 -0
- /package/dist/audit/{domain → links/domain}/markdown-links.js +0 -0
- /package/dist/audit/{domain → rtl/domain}/mappings.js +0 -0
- /package/dist/audit/{domain → rtl/domain}/tokenize.js +0 -0
- /package/dist/core/filesystem/{port.js → filesystem.js} +0 -0
- /package/dist/tag/{resolve-target-path.js → target/resolve-path.js} +0 -0
- /package/dist/tag/{since-writer.js → writer/since-writer.js} +0 -0
- /package/dist/tag/{version-resolver.js → writer/version-resolver.js} +0 -0
package/dist/arrange/output.js
DELETED
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
import path from "node:path";
|
|
2
|
-
import { lineOf } from "#/arrange/domain/ast/helpers";
|
|
3
|
-
import { LONG_STRING_TOKEN_THRESHOLD, MAX_REPORT_LINES } from "#/arrange/domain/constants";
|
|
4
|
-
import { logger } from "#/core/logger";
|
|
5
|
-
/**
|
|
6
|
-
* Prints the human-readable summary of an `arrange analyze` report.
|
|
7
|
-
*
|
|
8
|
-
* @since 0.3.16-canary.0
|
|
9
|
-
*/
|
|
10
|
-
export function printAnalyzeReport(resolvedTargetPath, report) {
|
|
11
|
-
logger.out(`Path: ${path.resolve(resolvedTargetPath)}`);
|
|
12
|
-
logger.out(`.ts/.tsx files: ${report.files}`);
|
|
13
|
-
logger.out(`cn(...) call sites: ${report.cnCallExpressions}`);
|
|
14
|
-
logger.out(`tv(...) call sites: ${report.tvCallExpressions}`);
|
|
15
|
-
logger.out(`\nLong cn(...) string literals (≥${LONG_STRING_TOKEN_THRESHOLD} tokens — consider splitting arguments): ${report.longCnStringLiterals.length}`);
|
|
16
|
-
for (const findingEntry of report.longCnStringLiterals.slice(0, MAX_REPORT_LINES)) {
|
|
17
|
-
logger.out(` ${findingEntry.file}:${findingEntry.line} (${findingEntry.tokenCount} tokens) ${findingEntry.preview}`);
|
|
18
|
-
}
|
|
19
|
-
if (report.longCnStringLiterals.length > MAX_REPORT_LINES) {
|
|
20
|
-
logger.out(` … and ${report.longCnStringLiterals.length - MAX_REPORT_LINES} more`);
|
|
21
|
-
}
|
|
22
|
-
logger.out(`\nLong tv({...}) string literals in base/variants/… (≥${LONG_STRING_TOKEN_THRESHOLD} tokens): ${report.longTvStringLiterals.length}`);
|
|
23
|
-
for (const findingEntry of report.longTvStringLiterals.slice(0, MAX_REPORT_LINES)) {
|
|
24
|
-
logger.out(` ${findingEntry.file}:${findingEntry.line} (${findingEntry.tokenCount} tokens) ${findingEntry.preview}`);
|
|
25
|
-
}
|
|
26
|
-
if (report.longTvStringLiterals.length > MAX_REPORT_LINES) {
|
|
27
|
-
logger.out(` … and ${report.longTvStringLiterals.length - MAX_REPORT_LINES} more`);
|
|
28
|
-
}
|
|
29
|
-
logger.out(`\nJSX className="..." or className={'...'} (static strings, ≥${LONG_STRING_TOKEN_THRESHOLD} tokens): ${report.longJsxClassNameLiterals.length}`);
|
|
30
|
-
for (const findingEntry of report.longJsxClassNameLiterals.slice(0, MAX_REPORT_LINES)) {
|
|
31
|
-
logger.out(` ${findingEntry.file}:${findingEntry.line} (${findingEntry.tokenCount} tokens) ${findingEntry.preview}`);
|
|
32
|
-
}
|
|
33
|
-
if (report.longJsxClassNameLiterals.length > MAX_REPORT_LINES) {
|
|
34
|
-
logger.out(` … and ${report.longJsxClassNameLiterals.length - MAX_REPORT_LINES} more`);
|
|
35
|
-
}
|
|
36
|
-
logger.out(`\ncn(...) nested inside tv({...}) (prefer a string or array — preview/apply can rewrite): ${report.cnInsideTvCalls.length}`);
|
|
37
|
-
for (const findingEntry of report.cnInsideTvCalls.slice(0, MAX_REPORT_LINES)) {
|
|
38
|
-
logger.out(` ${findingEntry.file}:${findingEntry.line} (${findingEntry.argCount} args) ${findingEntry.preview}`);
|
|
39
|
-
}
|
|
40
|
-
if (report.cnInsideTvCalls.length > MAX_REPORT_LINES) {
|
|
41
|
-
logger.out(` … and ${report.cnInsideTvCalls.length - MAX_REPORT_LINES} more`);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Prints the totals and follow-up hints for an `arrange` run.
|
|
46
|
-
*
|
|
47
|
-
* @since 0.3.16-canary.0
|
|
48
|
-
*/
|
|
49
|
-
export function printSyncResult(result, write) {
|
|
50
|
-
logger.out(`\nTotal: ${result.filePaths.length} file(s), ${result.totalFound} site(s) (cn/tv/JSX className) to review.`);
|
|
51
|
-
if (write) {
|
|
52
|
-
logger.out(`Applied: ${result.totalChanged} site(s) updated.`);
|
|
53
|
-
}
|
|
54
|
-
else {
|
|
55
|
-
logger.out(`(Re-run without --dry-run to write changes, or "pnpm cli:arrange" / "pnpm exec codefast arrange")`);
|
|
56
|
-
}
|
|
57
|
-
const shouldShowCascadeHint = write ? result.totalChanged > 0 : result.totalFound > 0;
|
|
58
|
-
if (shouldShowCascadeHint) {
|
|
59
|
-
logger.out("Note: class order may change across concern groups — smoke-test the UI if you rely on cascade order.");
|
|
60
|
-
}
|
|
61
|
-
if (result.hookError !== null) {
|
|
62
|
-
logger.err(result.hookError);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* Prints the totals for an `arrange simplify` run.
|
|
67
|
-
*
|
|
68
|
-
* @since 0.3.16-canary.0
|
|
69
|
-
*/
|
|
70
|
-
export function printSimplifyResult(result, write) {
|
|
71
|
-
logger.out(`\nTotal: ${result.filePaths.length} file(s), ${result.totalFound} site(s) to simplify.`);
|
|
72
|
-
if (write) {
|
|
73
|
-
logger.out(`Applied: ${result.totalChanged} site(s) updated.`);
|
|
74
|
-
}
|
|
75
|
-
else {
|
|
76
|
-
logger.out(`(Run "simplify" to write changes, or "pnpm cli:arrange-simplify" / "pnpm exec codefast arrange simplify")`);
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
|
-
* Prints the per-file preview of a work plan's unwrap and grouping edits.
|
|
81
|
-
*
|
|
82
|
-
* @since 0.3.16-canary.0
|
|
83
|
-
*/
|
|
84
|
-
export function printGroupFilePreviewFromWork(work) {
|
|
85
|
-
printGroupFilePreviewBody({
|
|
86
|
-
filePath: work.filePath,
|
|
87
|
-
reportTotal: work.reportTotal,
|
|
88
|
-
cnInTvNoReplacement: work.cnInTvNoReplacement,
|
|
89
|
-
cnInTvCalls: work.cnInTvCalls,
|
|
90
|
-
unwrapReplacementByCall: work.unwrapReplacementByCall,
|
|
91
|
-
sourceText: work.sourceText,
|
|
92
|
-
domainSf: work.domainSfForLineNumbers,
|
|
93
|
-
unwrapEdits: work.unwrapEdits,
|
|
94
|
-
plannedGroupEdits: work.plannedGroupEdits,
|
|
95
|
-
});
|
|
96
|
-
}
|
|
97
|
-
function printGroupFilePreviewBody(args) {
|
|
98
|
-
const { filePath, reportTotal, cnInTvNoReplacement, cnInTvCalls, unwrapReplacementByCall, sourceText, domainSf, unwrapEdits, plannedGroupEdits, } = args;
|
|
99
|
-
let header = `\n── ${filePath} (${reportTotal} site(s)`;
|
|
100
|
-
if (cnInTvNoReplacement > 0) {
|
|
101
|
-
header += `; plus ${cnInTvNoReplacement} cn() inside tv left unchanged (0 args)`;
|
|
102
|
-
}
|
|
103
|
-
header += `) ──`;
|
|
104
|
-
logger.out(header);
|
|
105
|
-
for (const call of cnInTvCalls) {
|
|
106
|
-
const replacement = unwrapReplacementByCall.get(call);
|
|
107
|
-
if (replacement === undefined) {
|
|
108
|
-
logger.out(` Line ${lineOf(domainSf, call)} [tv ⊃ cn]: cn(...) has no arguments — skipped`);
|
|
109
|
-
continue;
|
|
110
|
-
}
|
|
111
|
-
const start = call.pos;
|
|
112
|
-
const end = call.end;
|
|
113
|
-
if (sourceText.slice(start, end) === replacement) {
|
|
114
|
-
continue;
|
|
115
|
-
}
|
|
116
|
-
logger.out(` Line ${lineOf(domainSf, call)} [tv ⊃ cn → string/array]:`);
|
|
117
|
-
logger.out(` ${replacement.split("\n").join("\n ")}`);
|
|
118
|
-
}
|
|
119
|
-
if (unwrapEdits.length > 0 && plannedGroupEdits.length > 0) {
|
|
120
|
-
logger.out(" ([cn] / [tv] / [JSX className] lines below reflect content after unwrap of cn inside tv.)");
|
|
121
|
-
}
|
|
122
|
-
for (const plan of plannedGroupEdits) {
|
|
123
|
-
logger.out(` Line ${lineOf(plan.lineSf, plan.reportNode)} [${plan.label}]:`);
|
|
124
|
-
logger.out(` ${plan.replacement.split("\n").join("\n ")}`);
|
|
125
|
-
logger.out(` // Buckets: ${JSON.stringify(plan.bucketSummary)}`);
|
|
126
|
-
}
|
|
127
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { collectSimplifyTargets } from "#/arrange/domain/ast/simplify-targets";
|
|
2
|
-
import { dropCnImportIfUnused } from "#/arrange/domain/imports";
|
|
3
|
-
import { parseDomainSourceFile } from "#/arrange/source-parse";
|
|
4
|
-
import { applyEditsDescending } from "#/core/source-text-edit";
|
|
5
|
-
/**
|
|
6
|
-
* Runs the simplify pass on one file — flattening class expressions and pruning an unused `cn` import.
|
|
7
|
-
*
|
|
8
|
-
* @since 0.3.16-canary.0
|
|
9
|
-
*/
|
|
10
|
-
export function processArrangeSimplifyFile(fs, args) {
|
|
11
|
-
const { filePath, write } = args;
|
|
12
|
-
const sourceText = fs.readFileSync(filePath, "utf8");
|
|
13
|
-
const domainSf = parseDomainSourceFile(filePath, sourceText);
|
|
14
|
-
const edits = collectSimplifyTargets(domainSf);
|
|
15
|
-
const meaningful = edits.filter((edit) => sourceText.slice(edit.start, edit.end) !== edit.replacement);
|
|
16
|
-
// Apply class-simplification edits first, then prune any cn import that
|
|
17
|
-
// became (or was already) unused.
|
|
18
|
-
const textAfterEdits = meaningful.length > 0 ? applyEditsDescending(sourceText, meaningful) : sourceText;
|
|
19
|
-
const textAfterImportDrop = dropCnImportIfUnused(parseDomainSourceFile(filePath, textAfterEdits));
|
|
20
|
-
const importDropped = textAfterImportDrop !== textAfterEdits;
|
|
21
|
-
const totalFound = meaningful.length + (importDropped ? 1 : 0);
|
|
22
|
-
if (totalFound === 0) {
|
|
23
|
-
return { filePath, totalFound: 0, changed: 0 };
|
|
24
|
-
}
|
|
25
|
-
if (!write) {
|
|
26
|
-
return { filePath, totalFound, changed: 0 };
|
|
27
|
-
}
|
|
28
|
-
fs.writeFileSync(filePath, textAfterImportDrop, "utf8");
|
|
29
|
-
return { filePath, totalFound, changed: totalFound };
|
|
30
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { scanArrangeTargets } from "#/arrange/scan-target";
|
|
2
|
-
import { processArrangeSimplifyFile } from "#/arrange/simplify-process-file";
|
|
3
|
-
import { ok } from "#/core/result";
|
|
4
|
-
/**
|
|
5
|
-
* Runs the simplify pass over every target file and returns the aggregated result.
|
|
6
|
-
*
|
|
7
|
-
* @since 0.3.16-canary.0
|
|
8
|
-
*/
|
|
9
|
-
export async function runArrangeSimplify(fs, args) {
|
|
10
|
-
const filePaths = scanArrangeTargets(fs, args.targetPath);
|
|
11
|
-
const modifiedFiles = [];
|
|
12
|
-
let totalFound = 0;
|
|
13
|
-
let totalChanged = 0;
|
|
14
|
-
for (const filePath of filePaths) {
|
|
15
|
-
const result = processArrangeSimplifyFile(fs, { filePath, write: args.write });
|
|
16
|
-
totalFound += result.totalFound;
|
|
17
|
-
totalChanged += result.changed;
|
|
18
|
-
if (result.changed > 0) {
|
|
19
|
-
modifiedFiles.push(result.filePath);
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
return ok({
|
|
23
|
-
filePaths,
|
|
24
|
-
modifiedFiles,
|
|
25
|
-
totalFound,
|
|
26
|
-
totalChanged,
|
|
27
|
-
hookError: null,
|
|
28
|
-
previewPlans: [],
|
|
29
|
-
});
|
|
30
|
-
}
|
package/dist/audit/cli-schema.js
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import path from "node:path";
|
|
2
|
-
import { z } from "zod";
|
|
3
|
-
/**
|
|
4
|
-
* Zod schema for {@link RtlAuditRunRequest}.
|
|
5
|
-
*
|
|
6
|
-
* @since 0.5.0-canary.6
|
|
7
|
-
*/
|
|
8
|
-
export const rtlAuditRunRequestSchema = z.object({
|
|
9
|
-
rootDir: z.string().min(1),
|
|
10
|
-
targetPath: z.string().min(1),
|
|
11
|
-
allowlist: z.array(z.string()).optional(),
|
|
12
|
-
json: z.boolean(),
|
|
13
|
-
});
|
|
14
|
-
/**
|
|
15
|
-
* Zod schema for {@link LinkAuditRunRequest}.
|
|
16
|
-
*
|
|
17
|
-
* @since 0.5.0
|
|
18
|
-
*/
|
|
19
|
-
export const linkAuditRunRequestSchema = z.object({
|
|
20
|
-
rootDir: z.string().min(1),
|
|
21
|
-
targetPath: z.string().min(1),
|
|
22
|
-
allowlist: z.array(z.string()).optional(),
|
|
23
|
-
json: z.boolean(),
|
|
24
|
-
});
|
|
25
|
-
/**
|
|
26
|
-
* Zod schema for {@link CommentAuditRunRequest}.
|
|
27
|
-
*
|
|
28
|
-
* @since 0.6.0
|
|
29
|
-
*/
|
|
30
|
-
export const commentAuditRunRequestSchema = z.object({
|
|
31
|
-
rootDir: z.string().min(1),
|
|
32
|
-
targetPath: z.string().min(1),
|
|
33
|
-
allowlist: z.array(z.string()).optional(),
|
|
34
|
-
fix: z.boolean(),
|
|
35
|
-
json: z.boolean(),
|
|
36
|
-
});
|
|
37
|
-
/**
|
|
38
|
-
* Zod schema for {@link ReactAuditRunRequest}.
|
|
39
|
-
*
|
|
40
|
-
* @since 0.8.0
|
|
41
|
-
*/
|
|
42
|
-
export const reactAuditRunRequestSchema = z.object({
|
|
43
|
-
rootDir: z.string().min(1),
|
|
44
|
-
targetPath: z.string().min(1),
|
|
45
|
-
allowlist: z.array(z.string()).optional(),
|
|
46
|
-
json: z.boolean(),
|
|
47
|
-
});
|
|
48
|
-
/**
|
|
49
|
-
* Zod schema for {@link DisplayNameAuditRunRequest}.
|
|
50
|
-
*
|
|
51
|
-
* @since 0.9.0
|
|
52
|
-
*/
|
|
53
|
-
export const displayNameAuditRunRequestSchema = z.object({
|
|
54
|
-
rootDir: z.string().min(1),
|
|
55
|
-
targetPath: z.string().min(1),
|
|
56
|
-
allowlist: z.array(z.string()).optional(),
|
|
57
|
-
json: z.boolean(),
|
|
58
|
-
});
|
|
59
|
-
/**
|
|
60
|
-
* Resolves a path that may be absolute or relative to `rootDir`.
|
|
61
|
-
*
|
|
62
|
-
* @since 0.5.0-canary.6
|
|
63
|
-
*/
|
|
64
|
-
export function resolveRepoRelativePath(rootDir, maybeRelative) {
|
|
65
|
-
return path.isAbsolute(maybeRelative) ? path.resolve(maybeRelative) : path.resolve(rootDir, maybeRelative);
|
|
66
|
-
}
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
import { parseSync } from "oxc-parser";
|
|
2
|
-
function isOxcNode(value) {
|
|
3
|
-
return typeof value === "object" && value !== null && typeof value.type === "string";
|
|
4
|
-
}
|
|
5
|
-
function isIdentifierNamed(node, name) {
|
|
6
|
-
return isOxcNode(node) && node.type === "Identifier" && node.name === name;
|
|
7
|
-
}
|
|
8
|
-
/**
|
|
9
|
-
* Scans one TypeScript source for React import-policy violations.
|
|
10
|
-
*
|
|
11
|
-
* @remarks Three violation kinds: `import * as React`, a default `React` import (type-only
|
|
12
|
-
* included), and — only when no import binds `React` — an implicit `React.*` UMD-global type
|
|
13
|
-
* reference, which tsc accepts silently through the `export as namespace React` in `@types/react`.
|
|
14
|
-
*
|
|
15
|
-
* @since 0.8.0
|
|
16
|
-
*/
|
|
17
|
-
export function auditReactImportSource(filePath, sourceText) {
|
|
18
|
-
const { program } = parseSync(filePath, sourceText);
|
|
19
|
-
const statements = program.body;
|
|
20
|
-
const violations = [];
|
|
21
|
-
let bindsReact = false;
|
|
22
|
-
for (const statement of statements) {
|
|
23
|
-
if (statement.type !== "ImportDeclaration") {
|
|
24
|
-
continue;
|
|
25
|
-
}
|
|
26
|
-
const source = statement.source;
|
|
27
|
-
if (!isOxcNode(source) || source.value !== "react") {
|
|
28
|
-
continue;
|
|
29
|
-
}
|
|
30
|
-
const specifiers = Array.isArray(statement.specifiers) ? statement.specifiers.filter(isOxcNode) : [];
|
|
31
|
-
bindsReact ||= specifiers.some((specifier) => isIdentifierNamed(specifier.local, "React"));
|
|
32
|
-
for (const specifier of specifiers) {
|
|
33
|
-
if (specifier.type === "ImportNamespaceSpecifier") {
|
|
34
|
-
violations.push({
|
|
35
|
-
line: lineOfOffset(sourceText, statement.start),
|
|
36
|
-
raw: firstLineOf(sourceText.slice(statement.start, statement.end)),
|
|
37
|
-
reason: 'namespace React import — import members by name from "react"',
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
else if (specifier.type === "ImportDefaultSpecifier") {
|
|
41
|
-
violations.push({
|
|
42
|
-
line: lineOfOffset(sourceText, statement.start),
|
|
43
|
-
raw: firstLineOf(sourceText.slice(statement.start, statement.end)),
|
|
44
|
-
reason: 'default React import — import members by name from "react"',
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
// A bound `React` means the import itself is flagged above; qualified names under it are
|
|
50
|
-
// symptoms, not extra findings.
|
|
51
|
-
if (!bindsReact) {
|
|
52
|
-
collectUmdGlobalReferences(program, sourceText, violations);
|
|
53
|
-
}
|
|
54
|
-
violations.sort((a, b) => a.line - b.line);
|
|
55
|
-
return violations;
|
|
56
|
-
}
|
|
57
|
-
function collectUmdGlobalReferences(node, sourceText, violations) {
|
|
58
|
-
if (node.type === "TSQualifiedName" && isIdentifierNamed(node.left, "React")) {
|
|
59
|
-
violations.push({
|
|
60
|
-
line: lineOfOffset(sourceText, node.start),
|
|
61
|
-
raw: sourceText.slice(node.start, node.end),
|
|
62
|
-
reason: 'implicit React.* UMD global — add import type { … } from "react"',
|
|
63
|
-
});
|
|
64
|
-
return;
|
|
65
|
-
}
|
|
66
|
-
for (const value of Object.values(node)) {
|
|
67
|
-
if (Array.isArray(value)) {
|
|
68
|
-
for (const item of value) {
|
|
69
|
-
if (isOxcNode(item)) {
|
|
70
|
-
collectUmdGlobalReferences(item, sourceText, violations);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
else if (isOxcNode(value)) {
|
|
75
|
-
collectUmdGlobalReferences(value, sourceText, violations);
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
function lineOfOffset(sourceText, offset) {
|
|
80
|
-
let line = 1;
|
|
81
|
-
for (let index = 0; index < offset; index++) {
|
|
82
|
-
if (sourceText.charCodeAt(index) === 10) {
|
|
83
|
-
line++;
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
return line;
|
|
87
|
-
}
|
|
88
|
-
function firstLineOf(text) {
|
|
89
|
-
const newlineIndex = text.indexOf("\n");
|
|
90
|
-
return newlineIndex === -1 ? text : text.slice(0, newlineIndex);
|
|
91
|
-
}
|
package/dist/audit/output.js
DELETED
|
@@ -1,213 +0,0 @@
|
|
|
1
|
-
import { CLI_EXIT_GENERAL_ERROR, CLI_EXIT_SUCCESS } from "#/core/exit-codes";
|
|
2
|
-
import { logger } from "#/core/logger";
|
|
3
|
-
/**
|
|
4
|
-
* Exit `1` when any non-allowlisted violation remains.
|
|
5
|
-
*
|
|
6
|
-
* @since 0.5.0-canary.6
|
|
7
|
-
*/
|
|
8
|
-
export function exitCodeForRtlAuditResult(result) {
|
|
9
|
-
return result.violationCount > 0 ? CLI_EXIT_GENERAL_ERROR : CLI_EXIT_SUCCESS;
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* Human-readable RTL audit report (matches the former packages/ui script shape).
|
|
13
|
-
*
|
|
14
|
-
* @since 0.5.0-canary.6
|
|
15
|
-
*/
|
|
16
|
-
export function presentRtlAuditResult(result) {
|
|
17
|
-
for (const file of result.files) {
|
|
18
|
-
logger.out(`\n${file.relativePath}`);
|
|
19
|
-
for (const { line, raw, suggestion } of file.violations) {
|
|
20
|
-
logger.out(` ${line}: ${raw} → ${suggestion}`);
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
const allowlistSuffix = result.allowlistedCount > 0 ? ` (${result.allowlistedCount} allowlisted)` : "";
|
|
24
|
-
if (result.violationCount > 0) {
|
|
25
|
-
logger.out(`\n✖ ${result.violationCount} RTL violation(s)${allowlistSuffix}`);
|
|
26
|
-
}
|
|
27
|
-
else {
|
|
28
|
-
logger.out(`✓ No physical-direction classes outside the allowlist${allowlistSuffix}`);
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* Machine-readable RTL audit summary for `--json`.
|
|
33
|
-
*
|
|
34
|
-
* @since 0.5.0-canary.6
|
|
35
|
-
*/
|
|
36
|
-
export function formatRtlAuditJsonOutput(result, rootDir) {
|
|
37
|
-
return JSON.stringify({
|
|
38
|
-
schemaVersion: 1,
|
|
39
|
-
ok: result.violationCount === 0,
|
|
40
|
-
cwd: rootDir,
|
|
41
|
-
result,
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Exit `1` when any non-allowlisted broken link remains.
|
|
46
|
-
*
|
|
47
|
-
* @since 0.5.0
|
|
48
|
-
*/
|
|
49
|
-
export function exitCodeForLinkAuditResult(result) {
|
|
50
|
-
return result.breakageCount > 0 ? CLI_EXIT_GENERAL_ERROR : CLI_EXIT_SUCCESS;
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* Human-readable link audit report.
|
|
54
|
-
*
|
|
55
|
-
* @since 0.5.0
|
|
56
|
-
*/
|
|
57
|
-
export function presentLinkAuditResult(result) {
|
|
58
|
-
for (const file of result.files) {
|
|
59
|
-
logger.out(`\n${file.relativePath}`);
|
|
60
|
-
for (const { line, raw, reason } of file.breakages) {
|
|
61
|
-
logger.out(` ${line}: ${raw} → ${reason}`);
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
const allowlistSuffix = result.allowlistedCount > 0 ? ` (${result.allowlistedCount} allowlisted)` : "";
|
|
65
|
-
if (result.breakageCount > 0) {
|
|
66
|
-
logger.out(`\n✖ ${result.breakageCount} broken link(s)${allowlistSuffix}`);
|
|
67
|
-
}
|
|
68
|
-
else {
|
|
69
|
-
logger.out(`✓ ${result.linkCount} repo-local link(s) across ${result.scannedFileCount} document(s) all resolve${allowlistSuffix}`);
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
/**
|
|
73
|
-
* Machine-readable link audit summary for `--json`.
|
|
74
|
-
*
|
|
75
|
-
* @since 0.5.0
|
|
76
|
-
*/
|
|
77
|
-
export function formatLinkAuditJsonOutput(result, rootDir) {
|
|
78
|
-
return JSON.stringify({
|
|
79
|
-
schemaVersion: 1,
|
|
80
|
-
ok: result.breakageCount === 0,
|
|
81
|
-
cwd: rootDir,
|
|
82
|
-
result,
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
/**
|
|
86
|
-
* Exit `1` when any non-allowlisted React import-policy violation remains.
|
|
87
|
-
*
|
|
88
|
-
* @since 0.8.0
|
|
89
|
-
*/
|
|
90
|
-
export function exitCodeForReactAuditResult(result) {
|
|
91
|
-
return result.violationCount > 0 ? CLI_EXIT_GENERAL_ERROR : CLI_EXIT_SUCCESS;
|
|
92
|
-
}
|
|
93
|
-
/**
|
|
94
|
-
* Human-readable React import-policy report.
|
|
95
|
-
*
|
|
96
|
-
* @since 0.8.0
|
|
97
|
-
*/
|
|
98
|
-
export function presentReactAuditResult(result) {
|
|
99
|
-
for (const file of result.files) {
|
|
100
|
-
logger.out(`\n${file.relativePath}`);
|
|
101
|
-
for (const { line, raw, reason } of file.violations) {
|
|
102
|
-
logger.out(` ${line}: ${raw} → ${reason}`);
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
const allowlistSuffix = result.allowlistedCount > 0 ? ` (${result.allowlistedCount} allowlisted)` : "";
|
|
106
|
-
if (result.violationCount > 0) {
|
|
107
|
-
logger.out(`\n✖ ${result.violationCount} React import violation(s)${allowlistSuffix}`);
|
|
108
|
-
}
|
|
109
|
-
else {
|
|
110
|
-
logger.out(`✓ No namespace/default React imports or React.* UMD globals across ${result.scannedFileCount} file(s)${allowlistSuffix}`);
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
/**
|
|
114
|
-
* Machine-readable React import-policy summary for `--json`.
|
|
115
|
-
*
|
|
116
|
-
* @since 0.8.0
|
|
117
|
-
*/
|
|
118
|
-
export function formatReactAuditJsonOutput(result, rootDir) {
|
|
119
|
-
return JSON.stringify({
|
|
120
|
-
schemaVersion: 1,
|
|
121
|
-
ok: result.violationCount === 0,
|
|
122
|
-
cwd: rootDir,
|
|
123
|
-
result,
|
|
124
|
-
});
|
|
125
|
-
}
|
|
126
|
-
/**
|
|
127
|
-
* Exit `1` when any non-allowlisted divider still breaks the convention.
|
|
128
|
-
*
|
|
129
|
-
* @since 0.6.0
|
|
130
|
-
*/
|
|
131
|
-
export function exitCodeForCommentAuditResult(result) {
|
|
132
|
-
return result.breakageCount > 0 ? CLI_EXIT_GENERAL_ERROR : CLI_EXIT_SUCCESS;
|
|
133
|
-
}
|
|
134
|
-
/**
|
|
135
|
-
* Human-readable comment-divider report.
|
|
136
|
-
*
|
|
137
|
-
* @since 0.6.0
|
|
138
|
-
*/
|
|
139
|
-
export function presentCommentAuditResult(result) {
|
|
140
|
-
for (const file of result.files) {
|
|
141
|
-
logger.out(`\n${file.relativePath}`);
|
|
142
|
-
for (const { line, raw, reason } of file.breakages) {
|
|
143
|
-
logger.out(` ${line}: ${truncate(raw)} → ${reason}`);
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
const allowlistSuffix = result.allowlistedCount > 0 ? ` (${result.allowlistedCount} allowlisted)` : "";
|
|
147
|
-
if (result.fixedCount > 0) {
|
|
148
|
-
logger.out(`\n✎ Rewrote ${result.fixedCount} divider(s)`);
|
|
149
|
-
}
|
|
150
|
-
if (result.breakageCount > 0) {
|
|
151
|
-
logger.out(`\n✖ ${result.breakageCount} comment issue(s)${allowlistSuffix} — --fix rewrites divider forms`);
|
|
152
|
-
}
|
|
153
|
-
else {
|
|
154
|
-
logger.out(`✓ ${result.dividerCount} divider(s) across ${result.scannedFileCount} file(s), no banned comment content${allowlistSuffix}`);
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
/**
|
|
158
|
-
* Machine-readable comment-divider summary for `--json`.
|
|
159
|
-
*
|
|
160
|
-
* @since 0.6.0
|
|
161
|
-
*/
|
|
162
|
-
export function formatCommentAuditJsonOutput(result, rootDir) {
|
|
163
|
-
return JSON.stringify({
|
|
164
|
-
schemaVersion: 1,
|
|
165
|
-
ok: result.breakageCount === 0,
|
|
166
|
-
cwd: rootDir,
|
|
167
|
-
result,
|
|
168
|
-
});
|
|
169
|
-
}
|
|
170
|
-
function truncate(raw) {
|
|
171
|
-
return raw.length <= 60 ? raw : `${raw.slice(0, 57)}…`;
|
|
172
|
-
}
|
|
173
|
-
/**
|
|
174
|
-
* Exit `1` when any non-allowlisted display-name violation remains.
|
|
175
|
-
*
|
|
176
|
-
* @since 0.9.0
|
|
177
|
-
*/
|
|
178
|
-
export function exitCodeForDisplayNameAuditResult(result) {
|
|
179
|
-
return result.violationCount > 0 ? CLI_EXIT_GENERAL_ERROR : CLI_EXIT_SUCCESS;
|
|
180
|
-
}
|
|
181
|
-
/**
|
|
182
|
-
* Human-readable display-name report.
|
|
183
|
-
*
|
|
184
|
-
* @since 0.9.0
|
|
185
|
-
*/
|
|
186
|
-
export function presentDisplayNameAuditResult(result) {
|
|
187
|
-
for (const file of result.files) {
|
|
188
|
-
logger.out(`\n${file.relativePath}`);
|
|
189
|
-
for (const { line, raw, reason } of file.violations) {
|
|
190
|
-
logger.out(` ${line}: ${raw} → ${reason}`);
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
const allowlistSuffix = result.allowlistedCount > 0 ? ` (${result.allowlistedCount} allowlisted)` : "";
|
|
194
|
-
if (result.violationCount > 0) {
|
|
195
|
-
logger.out(`\n✖ ${result.violationCount} display name(s) off the convention${allowlistSuffix}`);
|
|
196
|
-
}
|
|
197
|
-
else {
|
|
198
|
-
logger.out(`✓ Every token, tag and module display name follows <namespace>:<Name> across ${result.scannedFileCount} file(s)${allowlistSuffix}`);
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
/**
|
|
202
|
-
* Machine-readable display-name summary for `--json`.
|
|
203
|
-
*
|
|
204
|
-
* @since 0.9.0
|
|
205
|
-
*/
|
|
206
|
-
export function formatDisplayNameAuditJsonOutput(result, rootDir) {
|
|
207
|
-
return JSON.stringify({
|
|
208
|
-
schemaVersion: 1,
|
|
209
|
-
ok: result.violationCount === 0,
|
|
210
|
-
cwd: rootDir,
|
|
211
|
-
result,
|
|
212
|
-
});
|
|
213
|
-
}
|
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
import process from "node:process";
|
|
2
|
-
import { messageFrom } from "#/core/errors";
|
|
3
|
-
const ANSI = {
|
|
4
|
-
reset: "\x1b[0m",
|
|
5
|
-
bold: "\x1b[1m",
|
|
6
|
-
dim: "\x1b[2m",
|
|
7
|
-
green: "\x1b[32m",
|
|
8
|
-
yellow: "\x1b[33m",
|
|
9
|
-
cyan: "\x1b[36m",
|
|
10
|
-
gray: "\x1b[90m",
|
|
11
|
-
magenta: "\x1b[35m",
|
|
12
|
-
brightGreen: "\x1b[92m",
|
|
13
|
-
brightCyan: "\x1b[96m",
|
|
14
|
-
};
|
|
15
|
-
/**
|
|
16
|
-
* Console implementation: ANSI styling and layout for the mirror command.
|
|
17
|
-
*
|
|
18
|
-
* @since 0.3.16-canary.0
|
|
19
|
-
*/
|
|
20
|
-
export class MirrorSyncReporter {
|
|
21
|
-
colorsAreEnabled = true;
|
|
22
|
-
configureMirrorColors(noColor) {
|
|
23
|
-
this.colorsAreEnabled = !!process.stdout.isTTY && !noColor;
|
|
24
|
-
}
|
|
25
|
-
mirrorBanner(logger) {
|
|
26
|
-
logger.out(`\n${this.paint("📦 Mirror — package exports", ANSI.bold + ANSI.cyan)}`);
|
|
27
|
-
logger.out(`${this.paint("═".repeat(60), ANSI.dim)}\n`);
|
|
28
|
-
}
|
|
29
|
-
mirrorDryRunNotice(logger) {
|
|
30
|
-
logger.out(`${this.paint("Dry run — no files will be written.", ANSI.yellow)}\n`);
|
|
31
|
-
}
|
|
32
|
-
mirrorProcessingMode(logger, mode) {
|
|
33
|
-
if (mode.kind === "single") {
|
|
34
|
-
logger.out(`${this.paint("Processing single package...", ANSI.dim)}\n`);
|
|
35
|
-
return;
|
|
36
|
-
}
|
|
37
|
-
if (mode.source === "default-patterns") {
|
|
38
|
-
logger.out(`${this.paint("Discovering workspace packages using default patterns (packages/*)…", ANSI.dim)}\n`);
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
|
-
if (mode.source === "pnpm-workspace-yaml") {
|
|
42
|
-
logger.out(`${this.paint("Discovering workspace packages from pnpm-workspace.yaml…", ANSI.dim)}\n`);
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
logger.out(`${this.paint("pnpm-workspace.yaml declares an empty workspace package list.", ANSI.dim)}\n`);
|
|
46
|
-
}
|
|
47
|
-
mirrorNoPackages(logger) {
|
|
48
|
-
logger.out(this.paint("⚠ No packages found", ANSI.yellow));
|
|
49
|
-
}
|
|
50
|
-
logSkippedWorkspacePackage(logger, index, total, displayName, reason) {
|
|
51
|
-
const progress = this.paint(`[${index}/${total}]`, ANSI.dim);
|
|
52
|
-
logger.out(`${progress} ${this.paint("○", ANSI.gray)} ${this.paint(displayName, ANSI.dim)}`);
|
|
53
|
-
logger.out(` ${this.paint("└─", ANSI.dim)} ${this.paint(`Skipped: ${reason}`, ANSI.gray)}`);
|
|
54
|
-
logger.out("");
|
|
55
|
-
}
|
|
56
|
-
logPackageSuccess(logger, index, total, pkgStats, generatedDistAssetCounts, verbose) {
|
|
57
|
-
const progress = this.paint(`[${index}/${total}]`, ANSI.dim);
|
|
58
|
-
logger.out(`${progress} ${this.paint("✓", ANSI.brightGreen)} ${this.paint(pkgStats.name, ANSI.bold)}`);
|
|
59
|
-
if (verbose) {
|
|
60
|
-
logger.out(` ${this.paint("├─", ANSI.dim)} Path: ${pkgStats.path}`);
|
|
61
|
-
if (pkgStats.hasTransform) {
|
|
62
|
-
logger.out(` ${this.paint("├─", ANSI.dim)} ${this.paint("Custom path transformation", ANSI.cyan)}`);
|
|
63
|
-
}
|
|
64
|
-
if (pkgStats.cssConfigStatus) {
|
|
65
|
-
const status = pkgStats.cssConfigStatus === "disabled" ? "CSS disabled" : "CSS configured";
|
|
66
|
-
logger.out(` ${this.paint("├─", ANSI.dim)} ${this.paint(status, ANSI.cyan)}`);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
const breakdown = [];
|
|
70
|
-
if (generatedDistAssetCounts.jsCount > 0) {
|
|
71
|
-
breakdown.push(this.paint(`${generatedDistAssetCounts.jsCount} modules`, ANSI.green));
|
|
72
|
-
}
|
|
73
|
-
if (generatedDistAssetCounts.cssCount > 0) {
|
|
74
|
-
breakdown.push(this.paint(`${generatedDistAssetCounts.cssCount} CSS`, ANSI.magenta));
|
|
75
|
-
}
|
|
76
|
-
if (pkgStats.extraExports > 0) {
|
|
77
|
-
breakdown.push(this.paint(`${pkgStats.extraExports} custom`, ANSI.yellow));
|
|
78
|
-
}
|
|
79
|
-
const totalExportsText = this.paint(`${pkgStats.totalExports} exports`, ANSI.brightCyan);
|
|
80
|
-
if (breakdown.length === 0) {
|
|
81
|
-
logger.out(` ${this.paint("└─", ANSI.dim)} ${totalExportsText}`);
|
|
82
|
-
}
|
|
83
|
-
else {
|
|
84
|
-
logger.out(` ${this.paint("└─", ANSI.dim)} ${breakdown.join(" + ")} = ${totalExportsText}`);
|
|
85
|
-
}
|
|
86
|
-
logger.out("");
|
|
87
|
-
}
|
|
88
|
-
logPrunedStaleExport(logger, exportSpecifier) {
|
|
89
|
-
logger.out(` ${this.paint("└─", ANSI.dim)} ${this.paint(`Pruned stale export: ${exportSpecifier}`, ANSI.gray)}`);
|
|
90
|
-
}
|
|
91
|
-
logPackageError(logger, index, total, displayName, errorValue, verbose) {
|
|
92
|
-
logger.out(`${this.paint(`[${index}/${total}]`, ANSI.dim)} ${this.paint("✗", ANSI.yellow)} ${this.paint(displayName, ANSI.bold)}`);
|
|
93
|
-
logger.out(` ${this.paint("└─", ANSI.dim)} ${this.paint(`Error: ${messageFrom(errorValue)}`, ANSI.yellow)}\n`);
|
|
94
|
-
if (verbose) {
|
|
95
|
-
logger.err(errorValue instanceof Error && errorValue.stack ? errorValue.stack : messageFrom(errorValue));
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
mirrorSummarySeparator(logger) {
|
|
99
|
-
logger.out(this.paint("═".repeat(60), ANSI.dim));
|
|
100
|
-
}
|
|
101
|
-
mirrorSummary(logger, stats, elapsedSeconds) {
|
|
102
|
-
logger.out(`${this.paint("📊 Summary", ANSI.bold)} ${this.paint(`(completed in ${elapsedSeconds.toFixed(2)}s)`, ANSI.dim)}\n`);
|
|
103
|
-
logger.out(` ${this.paint("Packages:", ANSI.bold)}`);
|
|
104
|
-
logger.out(` ${this.paint("├─", ANSI.dim)} Processed: ${this.paint(String(stats.packagesProcessed), ANSI.green)}`);
|
|
105
|
-
if (stats.packagesSkipped > 0) {
|
|
106
|
-
logger.out(` ${this.paint("├─", ANSI.dim)} Skipped: ${this.paint(String(stats.packagesSkipped), ANSI.gray)}`);
|
|
107
|
-
}
|
|
108
|
-
if (stats.packagesErrored > 0) {
|
|
109
|
-
logger.out(` ${this.paint("├─", ANSI.dim)} Errors: ${this.paint(String(stats.packagesErrored), ANSI.yellow)}`);
|
|
110
|
-
}
|
|
111
|
-
logger.out(` ${this.paint("└─", ANSI.dim)} Total found: ${stats.packagesFound}\n`);
|
|
112
|
-
logger.out(` ${this.paint("Exports:", ANSI.bold)}`);
|
|
113
|
-
logger.out(` ${this.paint("├─", ANSI.dim)} JS Modules: ${this.paint(String(stats.totalJsModules), ANSI.cyan)}`);
|
|
114
|
-
logger.out(` ${this.paint("├─", ANSI.dim)} CSS Files: ${this.paint(String(stats.totalCssExports), ANSI.magenta)}`);
|
|
115
|
-
logger.out(` ${this.paint("└─", ANSI.dim)} Total: ${this.paint(String(stats.totalExports), ANSI.brightCyan)}\n`);
|
|
116
|
-
logger.out(`${this.paint("═".repeat(60), ANSI.dim)}\n`);
|
|
117
|
-
}
|
|
118
|
-
paint(text, openSequence) {
|
|
119
|
-
if (!this.colorsAreEnabled) {
|
|
120
|
-
return text;
|
|
121
|
-
}
|
|
122
|
-
return `${openSequence}${text}${ANSI.reset}`;
|
|
123
|
-
}
|
|
124
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
File without changes
|