@codefast/cli 0.7.0 → 0.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +152 -37
- package/dist/arrange/analyze.js +3 -2
- package/dist/arrange/cli-schema.js +7 -2
- package/dist/arrange/command.js +3 -2
- package/dist/arrange/domain/analyze-service.js +3 -2
- package/dist/arrange/domain/ast/ast-node.js +35 -2
- package/dist/arrange/domain/ast/collectors-cn.js +9 -2
- package/dist/arrange/domain/ast/collectors-jsx.js +3 -2
- package/dist/arrange/domain/ast/collectors-tv.js +11 -2
- package/dist/arrange/domain/ast/helpers.js +5 -2
- package/dist/arrange/domain/ast/simplify-targets.js +1 -2
- package/dist/arrange/domain/ast/targets.js +7 -2
- package/dist/arrange/domain/constants.js +1 -2
- package/dist/arrange/domain/grouping-service.js +15 -2
- package/dist/arrange/domain/grouping.js +3 -2
- package/dist/arrange/domain/imports.js +3 -2
- package/dist/arrange/domain/source-text-formatters.js +9 -2
- package/dist/arrange/domain/tailwind-token.js +3 -2
- package/dist/arrange/domain/token-classifier.js +5 -2
- package/dist/arrange/domain/types.js +1 -2
- package/dist/arrange/output.js +9 -2
- package/dist/arrange/process-file.js +3 -2
- package/dist/arrange/resolve-target.js +3 -2
- package/dist/arrange/scan-target.js +3 -2
- package/dist/arrange/simplify-process-file.js +3 -2
- package/dist/arrange/simplify-sync.js +3 -2
- package/dist/arrange/source-parse.js +3 -2
- package/dist/arrange/suggest.js +3 -2
- package/dist/arrange/sync.js +3 -2
- package/dist/arrange/typescript-ast-translator.js +3 -2
- package/dist/arrange/workspace.js +3 -2
- package/dist/audit/cli-schema.js +14 -4
- package/dist/audit/command.js +45 -6
- package/dist/audit/domain/audit-file.js +4 -5
- package/dist/audit/domain/comment-content.js +1 -2
- package/dist/audit/domain/comment-dividers.js +1 -2
- package/dist/audit/domain/link-references.js +1 -2
- package/dist/audit/domain/mappings.js +10 -9
- package/dist/audit/domain/markdown-links.js +1 -2
- package/dist/audit/domain/react-imports.js +91 -0
- package/dist/audit/domain/since-versions.js +85 -0
- package/dist/audit/domain/tokenize.js +7 -6
- package/dist/audit/domain/tsdoc-syntax.js +1 -2
- package/dist/audit/domain/types.js +1 -2
- package/dist/audit/output.js +45 -5
- package/dist/audit/prepare.js +33 -3
- package/dist/audit/run-comments.js +26 -2
- package/dist/audit/run-links.js +1 -2
- package/dist/audit/run-react.js +55 -0
- package/dist/audit/run.js +2 -3
- package/dist/bin.js +1 -2
- package/dist/cli.js +5 -2
- package/dist/core/cli/format-error.js +3 -2
- package/dist/core/cli/global-options.js +1 -2
- package/dist/core/cli/positional.js +1 -2
- package/dist/core/cli/result-handle.js +5 -20
- package/dist/core/config/loader.js +3 -2
- package/dist/core/config/schema.js +27 -9
- package/dist/core/config/warnings.js +3 -2
- package/dist/core/config.js +3 -2
- package/dist/core/errors.js +3 -2
- package/dist/core/exit-codes.js +5 -2
- package/dist/core/filesystem/node.js +3 -2
- package/dist/core/filesystem/port.js +1 -2
- package/dist/core/glob.js +1 -2
- package/dist/core/logger.js +3 -2
- package/dist/core/result.js +5 -2
- package/dist/core/schema-parse.js +3 -2
- package/dist/core/source-text-edit.js +9 -2
- package/dist/core/verbose-diagnostics.js +3 -2
- package/dist/core/workspace/markdown-walk.js +1 -2
- package/dist/core/workspace/package-version.js +24 -0
- package/dist/core/workspace/resolver.js +3 -2
- package/dist/core/workspace/skip-directories.js +3 -2
- package/dist/core/workspace/source-walk.js +1 -2
- package/dist/core/workspace/typescript-walk.js +3 -2
- package/dist/mirror/cli-result.js +5 -2
- package/dist/mirror/cli-schema.js +3 -2
- package/dist/mirror/command.js +3 -2
- package/dist/mirror/dist-filesystem-impl.js +3 -2
- package/dist/mirror/domain/constants.js +11 -2
- package/dist/mirror/domain/dirent-guard.js +1 -2
- package/dist/mirror/domain/dist-filesystem.js +1 -2
- package/dist/mirror/domain/errors.js +5 -2
- package/dist/mirror/domain/exports.js +5 -2
- package/dist/mirror/domain/package-display-name.js +1 -2
- package/dist/mirror/domain/path-normalizer.js +3 -2
- package/dist/mirror/domain/types.js +1 -2
- package/dist/mirror/output.js +3 -2
- package/dist/mirror/package-path.js +5 -2
- package/dist/mirror/prepare.js +3 -2
- package/dist/mirror/supplement-exports.js +3 -2
- package/dist/mirror/sync-reporter.js +1 -2
- package/dist/mirror/sync-types.js +1 -2
- package/dist/mirror/sync-workspace-package.js +3 -2
- package/dist/mirror/sync.js +3 -2
- package/dist/mirror/write-exports.js +1 -2
- package/dist/pack-slim/cli-result.js +23 -0
- package/dist/pack-slim/cli-schema.js +11 -0
- package/dist/pack-slim/command.js +79 -0
- package/dist/pack-slim/domain/transform.js +95 -0
- package/dist/pack-slim/domain/types.js +2 -0
- package/dist/pack-slim/output.js +53 -0
- package/dist/pack-slim/sync.js +151 -0
- package/dist/pack-slim/working-tree.js +45 -0
- package/dist/tag/cli-result.js +3 -2
- package/dist/tag/cli-schema.js +3 -2
- package/dist/tag/command.js +3 -2
- package/dist/tag/domain/types.js +1 -2
- package/dist/tag/output.js +5 -2
- package/dist/tag/prepare.js +3 -2
- package/dist/tag/resolve-target-path.js +3 -2
- package/dist/tag/since-writer.js +3 -2
- package/dist/tag/sync.js +3 -2
- package/dist/tag/target-candidates.js +3 -2
- package/dist/tag/target-runner.js +3 -2
- package/dist/tag/version-resolver.js +8 -23
- package/package.json +9 -16
- package/dist/arrange/analyze.js.map +0 -1
- package/dist/arrange/cli-schema.js.map +0 -1
- package/dist/arrange/command.js.map +0 -1
- package/dist/arrange/domain/analyze-service.js.map +0 -1
- package/dist/arrange/domain/ast/ast-node.js.map +0 -1
- package/dist/arrange/domain/ast/collectors-cn.js.map +0 -1
- package/dist/arrange/domain/ast/collectors-jsx.js.map +0 -1
- package/dist/arrange/domain/ast/collectors-tv.js.map +0 -1
- package/dist/arrange/domain/ast/helpers.js.map +0 -1
- package/dist/arrange/domain/ast/simplify-targets.js.map +0 -1
- package/dist/arrange/domain/ast/targets.js.map +0 -1
- package/dist/arrange/domain/constants.js.map +0 -1
- package/dist/arrange/domain/grouping-service.js.map +0 -1
- package/dist/arrange/domain/grouping.js.map +0 -1
- package/dist/arrange/domain/imports.js.map +0 -1
- package/dist/arrange/domain/source-text-formatters.js.map +0 -1
- package/dist/arrange/domain/tailwind-token.js.map +0 -1
- package/dist/arrange/domain/token-classifier.js.map +0 -1
- package/dist/arrange/domain/types.js.map +0 -1
- package/dist/arrange/output.js.map +0 -1
- package/dist/arrange/process-file.js.map +0 -1
- package/dist/arrange/resolve-target.js.map +0 -1
- package/dist/arrange/scan-target.js.map +0 -1
- package/dist/arrange/simplify-process-file.js.map +0 -1
- package/dist/arrange/simplify-sync.js.map +0 -1
- package/dist/arrange/source-parse.js.map +0 -1
- package/dist/arrange/suggest.js.map +0 -1
- package/dist/arrange/sync.js.map +0 -1
- package/dist/arrange/typescript-ast-translator.js.map +0 -1
- package/dist/arrange/workspace.js.map +0 -1
- package/dist/audit/cli-schema.js.map +0 -1
- package/dist/audit/command.js.map +0 -1
- package/dist/audit/domain/audit-file.js.map +0 -1
- package/dist/audit/domain/comment-content.js.map +0 -1
- package/dist/audit/domain/comment-dividers.js.map +0 -1
- package/dist/audit/domain/link-references.js.map +0 -1
- package/dist/audit/domain/mappings.js.map +0 -1
- package/dist/audit/domain/markdown-links.js.map +0 -1
- package/dist/audit/domain/tokenize.js.map +0 -1
- package/dist/audit/domain/tsdoc-syntax.js.map +0 -1
- package/dist/audit/domain/types.js.map +0 -1
- package/dist/audit/output.js.map +0 -1
- package/dist/audit/prepare.js.map +0 -1
- package/dist/audit/run-comments.js.map +0 -1
- package/dist/audit/run-links.js.map +0 -1
- package/dist/audit/run.js.map +0 -1
- package/dist/bin.js.map +0 -1
- package/dist/cli.js.map +0 -1
- package/dist/core/cli/format-error.js.map +0 -1
- package/dist/core/cli/global-options.js.map +0 -1
- package/dist/core/cli/positional.js.map +0 -1
- package/dist/core/cli/result-handle.js.map +0 -1
- package/dist/core/config/loader.js.map +0 -1
- package/dist/core/config/schema.js.map +0 -1
- package/dist/core/config/warnings.js.map +0 -1
- package/dist/core/config.js.map +0 -1
- package/dist/core/errors.js.map +0 -1
- package/dist/core/exit-codes.js.map +0 -1
- package/dist/core/filesystem/node.js.map +0 -1
- package/dist/core/filesystem/port.js.map +0 -1
- package/dist/core/glob.js.map +0 -1
- package/dist/core/logger.js.map +0 -1
- package/dist/core/result.js.map +0 -1
- package/dist/core/schema-parse.js.map +0 -1
- package/dist/core/source-text-edit.js.map +0 -1
- package/dist/core/verbose-diagnostics.js.map +0 -1
- package/dist/core/workspace/markdown-walk.js.map +0 -1
- package/dist/core/workspace/resolver.js.map +0 -1
- package/dist/core/workspace/skip-directories.js.map +0 -1
- package/dist/core/workspace/source-walk.js.map +0 -1
- package/dist/core/workspace/typescript-walk.js.map +0 -1
- package/dist/mirror/cli-result.js.map +0 -1
- package/dist/mirror/cli-schema.js.map +0 -1
- package/dist/mirror/command.js.map +0 -1
- package/dist/mirror/dist-filesystem-impl.js.map +0 -1
- package/dist/mirror/domain/constants.js.map +0 -1
- package/dist/mirror/domain/dirent-guard.js.map +0 -1
- package/dist/mirror/domain/dist-filesystem.js.map +0 -1
- package/dist/mirror/domain/errors.js.map +0 -1
- package/dist/mirror/domain/exports.js.map +0 -1
- package/dist/mirror/domain/package-display-name.js.map +0 -1
- package/dist/mirror/domain/path-normalizer.js.map +0 -1
- package/dist/mirror/domain/types.js.map +0 -1
- package/dist/mirror/output.js.map +0 -1
- package/dist/mirror/package-path.js.map +0 -1
- package/dist/mirror/prepare.js.map +0 -1
- package/dist/mirror/supplement-exports.js.map +0 -1
- package/dist/mirror/sync-reporter.js.map +0 -1
- package/dist/mirror/sync-types.js.map +0 -1
- package/dist/mirror/sync-workspace-package.js.map +0 -1
- package/dist/mirror/sync.js.map +0 -1
- package/dist/mirror/write-exports.js.map +0 -1
- package/dist/tag/cli-result.js.map +0 -1
- package/dist/tag/cli-schema.js.map +0 -1
- package/dist/tag/command.js.map +0 -1
- package/dist/tag/domain/types.js.map +0 -1
- package/dist/tag/output.js.map +0 -1
- package/dist/tag/prepare.js.map +0 -1
- package/dist/tag/resolve-target-path.js.map +0 -1
- package/dist/tag/since-writer.js.map +0 -1
- package/dist/tag/sync.js.map +0 -1
- package/dist/tag/target-candidates.js.map +0 -1
- package/dist/tag/target-runner.js.map +0 -1
- package/dist/tag/version-resolver.js.map +0 -1
|
@@ -95,6 +95,8 @@ export function isCnOrTvIdentifier(expr, name, knownBindings = EMPTY_CN_TV_BINDI
|
|
|
95
95
|
return false;
|
|
96
96
|
}
|
|
97
97
|
/**
|
|
98
|
+
* Resolves a property assignment's name text, or `undefined` for computed names.
|
|
99
|
+
*
|
|
98
100
|
* @since 0.3.16-canary.0
|
|
99
101
|
*/
|
|
100
102
|
export function propertyAssignmentNameText(prop) {
|
|
@@ -107,6 +109,8 @@ export function propertyAssignmentNameText(prop) {
|
|
|
107
109
|
return undefined;
|
|
108
110
|
}
|
|
109
111
|
/**
|
|
112
|
+
* Resolves the one-based line number a node starts on.
|
|
113
|
+
*
|
|
110
114
|
* @since 0.3.16-canary.0
|
|
111
115
|
*/
|
|
112
116
|
export function lineOf(sourceFile, node) {
|
|
@@ -147,5 +151,4 @@ export function unwrapCnInsideTvCallReplacement(call, sourceText) {
|
|
|
147
151
|
}
|
|
148
152
|
lines.push(`${baseIndent}]`);
|
|
149
153
|
return lines.join("\n");
|
|
150
|
-
}
|
|
151
|
-
//# sourceMappingURL=helpers.js.map
|
|
154
|
+
}
|
|
@@ -8,6 +8,8 @@ import { escapeTsStringLiteralContent, formatArray, formatArrayElementsAsSibling
|
|
|
8
8
|
import { tokenizeClassString } from "#/arrange/domain/tailwind-token";
|
|
9
9
|
import { endAfterOptionalCommaFollowingInSource, indentOfLineContaining, textPrefixFromLineStartToPosition, } from "#/core/source-text-edit";
|
|
10
10
|
/**
|
|
11
|
+
* Resolves the source position where a group target's replacement begins.
|
|
12
|
+
*
|
|
11
13
|
* @since 0.3.16-canary.0
|
|
12
14
|
*/
|
|
13
15
|
export function targetReplaceStart(target) {
|
|
@@ -38,6 +40,8 @@ function collectLongJsxClassNameTargets(sourceFile) {
|
|
|
38
40
|
return results;
|
|
39
41
|
}
|
|
40
42
|
/**
|
|
43
|
+
* Collects a file's group targets — `cn()` / `tv()` slots, plus long JSX `className` literals in `.tsx`.
|
|
44
|
+
*
|
|
41
45
|
* @since 0.3.16-canary.0
|
|
42
46
|
*/
|
|
43
47
|
export function collectGroupTargets(sourceFile, filePath) {
|
|
@@ -91,6 +95,8 @@ function formatCnCallReplacement(stringNode, sourceText, withClassName) {
|
|
|
91
95
|
return `cn(\n${argLines.join("\n")}\n${baseIndent})`;
|
|
92
96
|
}
|
|
93
97
|
/**
|
|
98
|
+
* Plans the grouped replacement for one target, or `undefined` when regrouping would change nothing.
|
|
99
|
+
*
|
|
94
100
|
* @since 0.3.16-canary.0
|
|
95
101
|
*/
|
|
96
102
|
export function planGroupEditForTarget(target, textAfterUnwrap, withClassName) {
|
|
@@ -178,5 +184,4 @@ export function planGroupEditForTarget(target, textAfterUnwrap, withClassName) {
|
|
|
178
184
|
reportNode: target.item.primaryClassLiteral,
|
|
179
185
|
label: target.item.isTvContext ? "tv" : "cn",
|
|
180
186
|
};
|
|
181
|
-
}
|
|
182
|
-
//# sourceMappingURL=targets.js.map
|
|
187
|
+
}
|
|
@@ -17,6 +17,8 @@ function toUnwrapPlans(cnInTvCalls, sourceText) {
|
|
|
17
17
|
.filter((plan) => plan !== undefined);
|
|
18
18
|
}
|
|
19
19
|
/**
|
|
20
|
+
* Builds the unwrap phase's state — cn-in-tv calls, their replacements, and the text after unwrapping.
|
|
21
|
+
*
|
|
20
22
|
* @since 0.3.16-canary.0
|
|
21
23
|
*/
|
|
22
24
|
export function buildGroupFileUnwrapState(domainSfInitial, sourceText) {
|
|
@@ -80,12 +82,16 @@ export function tryBuildGroupFileWorkPlan(input) {
|
|
|
80
82
|
};
|
|
81
83
|
}
|
|
82
84
|
/**
|
|
85
|
+
* Creates the empty per-file result for a dry run with nothing to edit.
|
|
86
|
+
*
|
|
83
87
|
* @since 0.3.16-canary.0
|
|
84
88
|
*/
|
|
85
89
|
export function groupFileDryRunNoEdits(filePath) {
|
|
86
90
|
return { filePath, totalFound: 0, changed: 0 };
|
|
87
91
|
}
|
|
88
92
|
/**
|
|
93
|
+
* Derives the preview-mode per-file result from a work plan's report total.
|
|
94
|
+
*
|
|
89
95
|
* @since 0.3.16-canary.0
|
|
90
96
|
*/
|
|
91
97
|
export function groupFilePreviewTotals(work) {
|
|
@@ -96,6 +102,8 @@ export function groupFilePreviewTotals(work) {
|
|
|
96
102
|
};
|
|
97
103
|
}
|
|
98
104
|
/**
|
|
105
|
+
* Applies a work plan's grouping edits to the unwrapped text and returns the merged file body.
|
|
106
|
+
*
|
|
99
107
|
* @since 0.3.16-canary.0
|
|
100
108
|
*/
|
|
101
109
|
export function mergeGroupFileBodyText(work) {
|
|
@@ -108,21 +116,26 @@ export function mergeGroupFileBodyText(work) {
|
|
|
108
116
|
return groupEdits.length > 0 ? applyEditsDescending(work.textAfterUnwrap, groupEdits) : work.textAfterUnwrap;
|
|
109
117
|
}
|
|
110
118
|
/**
|
|
119
|
+
* Checks whether any planned edit rewrites a JSX `className` into a `cn()` call.
|
|
120
|
+
*
|
|
111
121
|
* @since 0.3.16-canary.0
|
|
112
122
|
*/
|
|
113
123
|
export function groupFileEditsTouchJsxCn(work) {
|
|
114
124
|
return work.plannedGroupEdits.some((plannedEdit) => plannedEdit.jsxCn);
|
|
115
125
|
}
|
|
116
126
|
/**
|
|
127
|
+
* Counts the edits a work plan writes in apply mode — unwraps plus grouping replacements.
|
|
128
|
+
*
|
|
117
129
|
* @since 0.3.16-canary.0
|
|
118
130
|
*/
|
|
119
131
|
export function countPersistedGroupFileEdits(work) {
|
|
120
132
|
return work.unwrapEdits.length + work.plannedGroupEdits.length;
|
|
121
133
|
}
|
|
122
134
|
/**
|
|
135
|
+
* Checks whether a work plan has no edit sites and no skipped cn-in-tv calls to report.
|
|
136
|
+
*
|
|
123
137
|
* @since 0.3.16-canary.0
|
|
124
138
|
*/
|
|
125
139
|
export function groupFileWorkHasNothingToReport(work) {
|
|
126
140
|
return work.editSitesCount === 0 && work.cnInTvNoReplacement === 0;
|
|
127
|
-
}
|
|
128
|
-
//# sourceMappingURL=grouping-service.js.map
|
|
141
|
+
}
|
|
@@ -334,6 +334,8 @@ function chunkIsOnlyEaseTimingMotion(groupStr) {
|
|
|
334
334
|
return classTokens.every((classToken) => classifyToken(classToken) === "motion" && stripVariants(classToken).startsWith("ease-"));
|
|
335
335
|
}
|
|
336
336
|
/**
|
|
337
|
+
* Partitions a class string into render-pipeline-ordered groups, one per suggested `cn()` argument.
|
|
338
|
+
*
|
|
337
339
|
* @since 0.3.16-canary.0
|
|
338
340
|
*/
|
|
339
341
|
export function suggestCnGroups(classString) {
|
|
@@ -431,5 +433,4 @@ export function summarizeGroupBucketLabels(groups) {
|
|
|
431
433
|
}
|
|
432
434
|
return onlyBucket;
|
|
433
435
|
});
|
|
434
|
-
}
|
|
435
|
-
//# sourceMappingURL=grouping.js.map
|
|
436
|
+
}
|
|
@@ -113,6 +113,8 @@ export function dropCnImportIfUnused(sourceFile) {
|
|
|
113
113
|
return sourceText;
|
|
114
114
|
}
|
|
115
115
|
/**
|
|
116
|
+
* Returns the source text with a `cn` import present, adding one when the file lacks it.
|
|
117
|
+
*
|
|
116
118
|
* @since 0.3.16-canary.0
|
|
117
119
|
*/
|
|
118
120
|
export function ensureCnImport(sourceFile, cnImportOverride) {
|
|
@@ -156,5 +158,4 @@ export function ensureCnImport(sourceFile, cnImportOverride) {
|
|
|
156
158
|
insertAt = 0;
|
|
157
159
|
}
|
|
158
160
|
return `${sourceText.slice(0, insertAt)}${importLine}\n${sourceText.slice(insertAt)}`;
|
|
159
|
-
}
|
|
160
|
-
//# sourceMappingURL=imports.js.map
|
|
161
|
+
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { indentOfLineContaining } from "#/core/source-text-edit";
|
|
2
2
|
/**
|
|
3
|
+
* Escapes backslashes and double quotes for embedding in a double-quoted TypeScript string literal.
|
|
4
|
+
*
|
|
3
5
|
* @since 0.3.16-canary.0
|
|
4
6
|
*/
|
|
5
7
|
export function escapeTsStringLiteralContent(group) {
|
|
@@ -31,6 +33,8 @@ function formatCnArguments(groups, options) {
|
|
|
31
33
|
return lines.join("\n");
|
|
32
34
|
}
|
|
33
35
|
/**
|
|
36
|
+
* Formats grouped class strings as a multiline `cn(...)` call.
|
|
37
|
+
*
|
|
34
38
|
* @since 0.3.16-canary.0
|
|
35
39
|
*/
|
|
36
40
|
export function formatCnCall(groups, options) {
|
|
@@ -51,6 +55,8 @@ export function formatCnCall(groups, options) {
|
|
|
51
55
|
return lines.join("\n");
|
|
52
56
|
}
|
|
53
57
|
/**
|
|
58
|
+
* Formats grouped class strings as a multiline array literal.
|
|
59
|
+
*
|
|
54
60
|
* @since 0.3.16-canary.0
|
|
55
61
|
*/
|
|
56
62
|
export function formatArray(groups) {
|
|
@@ -86,6 +92,8 @@ export function formatArrayElementsAsSiblingLines(groups, continuationPrefix) {
|
|
|
86
92
|
return segments.join("");
|
|
87
93
|
}
|
|
88
94
|
/**
|
|
95
|
+
* Formats grouped class strings as a JSX attribute value wrapping a multiline `cn(...)` call.
|
|
96
|
+
*
|
|
89
97
|
* @since 0.3.16-canary.0
|
|
90
98
|
*/
|
|
91
99
|
export function formatJsxCnAttributeValue(groups, source, valueNodeStart) {
|
|
@@ -96,5 +104,4 @@ export function formatJsxCnAttributeValue(groups, source, valueNodeStart) {
|
|
|
96
104
|
commaAfterLastGroup: groups.length > 1,
|
|
97
105
|
});
|
|
98
106
|
return `{cn(\n${cnArgumentsBlock}\n${baseIndent})}`;
|
|
99
|
-
}
|
|
100
|
-
//# sourceMappingURL=source-text-formatters.js.map
|
|
107
|
+
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { MAX_STRIP_VARIANT_PASSES } from "#/arrange/domain/constants";
|
|
2
2
|
/**
|
|
3
|
+
* Splits a class string into its whitespace-separated tokens.
|
|
4
|
+
*
|
|
3
5
|
* @since 0.3.16-canary.0
|
|
4
6
|
*/
|
|
5
7
|
export function tokenizeClassString(classString) {
|
|
@@ -48,5 +50,4 @@ export function stripVariants(token) {
|
|
|
48
50
|
withoutVariants = withoutVariants.slice(colonIdx + 1);
|
|
49
51
|
}
|
|
50
52
|
return withoutVariants;
|
|
51
|
-
}
|
|
52
|
-
//# sourceMappingURL=tailwind-token.js.map
|
|
53
|
+
}
|
|
@@ -302,6 +302,8 @@ function isArbitraryParentSelectorStateToken(token) {
|
|
|
302
302
|
return selector.includes("&");
|
|
303
303
|
}
|
|
304
304
|
/**
|
|
305
|
+
* Classifies a Tailwind token into its render-pipeline bucket.
|
|
306
|
+
*
|
|
305
307
|
* @since 0.3.16-canary.0
|
|
306
308
|
*/
|
|
307
309
|
export function classifyToken(token) {
|
|
@@ -417,6 +419,8 @@ function normalizeSelectorVariantLayer(layer) {
|
|
|
417
419
|
return layer;
|
|
418
420
|
}
|
|
419
421
|
/**
|
|
422
|
+
* Checks whether two buckets may share one group in a suggested partition.
|
|
423
|
+
*
|
|
420
424
|
* @since 0.3.16-canary.0
|
|
421
425
|
*/
|
|
422
426
|
export function bucketsCompatible(a, b) {
|
|
@@ -444,5 +448,4 @@ export function bucketsMergeCompatible(a, b) {
|
|
|
444
448
|
return false;
|
|
445
449
|
}
|
|
446
450
|
return bucketsCompatible(a, b);
|
|
447
|
-
}
|
|
448
|
-
//# sourceMappingURL=token-classifier.js.map
|
|
451
|
+
}
|
package/dist/arrange/output.js
CHANGED
|
@@ -3,6 +3,8 @@ import { lineOf } from "#/arrange/domain/ast/helpers";
|
|
|
3
3
|
import { LONG_STRING_TOKEN_THRESHOLD, MAX_REPORT_LINES } from "#/arrange/domain/constants";
|
|
4
4
|
import { logger } from "#/core/logger";
|
|
5
5
|
/**
|
|
6
|
+
* Prints the human-readable summary of an `arrange analyze` report.
|
|
7
|
+
*
|
|
6
8
|
* @since 0.3.16-canary.0
|
|
7
9
|
*/
|
|
8
10
|
export function printAnalyzeReport(resolvedTargetPath, report) {
|
|
@@ -40,6 +42,8 @@ export function printAnalyzeReport(resolvedTargetPath, report) {
|
|
|
40
42
|
}
|
|
41
43
|
}
|
|
42
44
|
/**
|
|
45
|
+
* Prints the totals and follow-up hints for an `arrange` run.
|
|
46
|
+
*
|
|
43
47
|
* @since 0.3.16-canary.0
|
|
44
48
|
*/
|
|
45
49
|
export function printSyncResult(result, write) {
|
|
@@ -59,6 +63,8 @@ export function printSyncResult(result, write) {
|
|
|
59
63
|
}
|
|
60
64
|
}
|
|
61
65
|
/**
|
|
66
|
+
* Prints the totals for an `arrange simplify` run.
|
|
67
|
+
*
|
|
62
68
|
* @since 0.3.16-canary.0
|
|
63
69
|
*/
|
|
64
70
|
export function printSimplifyResult(result, write) {
|
|
@@ -71,6 +77,8 @@ export function printSimplifyResult(result, write) {
|
|
|
71
77
|
}
|
|
72
78
|
}
|
|
73
79
|
/**
|
|
80
|
+
* Prints the per-file preview of a work plan's unwrap and grouping edits.
|
|
81
|
+
*
|
|
74
82
|
* @since 0.3.16-canary.0
|
|
75
83
|
*/
|
|
76
84
|
export function printGroupFilePreviewFromWork(work) {
|
|
@@ -116,5 +124,4 @@ function printGroupFilePreviewBody(args) {
|
|
|
116
124
|
logger.out(` ${plan.replacement.split("\n").join("\n ")}`);
|
|
117
125
|
logger.out(` // Buckets: ${JSON.stringify(plan.bucketSummary)}`);
|
|
118
126
|
}
|
|
119
|
-
}
|
|
120
|
-
//# sourceMappingURL=output.js.map
|
|
127
|
+
}
|
|
@@ -2,6 +2,8 @@ import { buildGroupFileUnwrapState, countPersistedGroupFileEdits, groupFileDryRu
|
|
|
2
2
|
import { ensureCnImport } from "#/arrange/domain/imports";
|
|
3
3
|
import { parseDomainSourceFile } from "#/arrange/source-parse";
|
|
4
4
|
/**
|
|
5
|
+
* Runs the grouping pipeline on one file — preview or write — and returns its per-file result.
|
|
6
|
+
*
|
|
5
7
|
* @since 0.3.16-canary.0
|
|
6
8
|
*/
|
|
7
9
|
export function processArrangeGroupFile(fs, args) {
|
|
@@ -40,5 +42,4 @@ export function processArrangeGroupFile(fs, args) {
|
|
|
40
42
|
totalFound: persistedEditCount + work.cnInTvNoReplacement,
|
|
41
43
|
changed: persistedEditCount,
|
|
42
44
|
};
|
|
43
|
-
}
|
|
44
|
-
//# sourceMappingURL=process-file.js.map
|
|
45
|
+
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
2
|
const packageJsonFileName = "package.json";
|
|
3
3
|
/**
|
|
4
|
+
* Resolves the arrange target to a canonical path, defaulting to the nearest package directory.
|
|
5
|
+
*
|
|
4
6
|
* @since 0.3.16-canary.0
|
|
5
7
|
*/
|
|
6
8
|
export function resolveArrangeTargetPath(fs, args) {
|
|
@@ -29,5 +31,4 @@ function findNearestPackageDirectory(fs, currentWorkingDirectory) {
|
|
|
29
31
|
}
|
|
30
32
|
currentDir = parentDirectory;
|
|
31
33
|
}
|
|
32
|
-
}
|
|
33
|
-
//# sourceMappingURL=resolve-target.js.map
|
|
34
|
+
}
|
|
@@ -12,6 +12,8 @@ function isTestFile(filePath) {
|
|
|
12
12
|
return TEST_FILE_PATTERN.test(path.basename(filePath));
|
|
13
13
|
}
|
|
14
14
|
/**
|
|
15
|
+
* Lists the files an arrange run visits — a directory's non-test `.ts`/`.tsx` files, or the single target.
|
|
16
|
+
*
|
|
15
17
|
* @since 0.3.16-canary.0
|
|
16
18
|
*/
|
|
17
19
|
export function scanArrangeTargets(fs, targetPath) {
|
|
@@ -26,5 +28,4 @@ export function scanArrangeTargets(fs, targetPath) {
|
|
|
26
28
|
}
|
|
27
29
|
}
|
|
28
30
|
return [resolvedTargetPath];
|
|
29
|
-
}
|
|
30
|
-
//# sourceMappingURL=scan-target.js.map
|
|
31
|
+
}
|
|
@@ -3,6 +3,8 @@ import { dropCnImportIfUnused } from "#/arrange/domain/imports";
|
|
|
3
3
|
import { parseDomainSourceFile } from "#/arrange/source-parse";
|
|
4
4
|
import { applyEditsDescending } from "#/core/source-text-edit";
|
|
5
5
|
/**
|
|
6
|
+
* Runs the simplify pass on one file — flattening class expressions and pruning an unused `cn` import.
|
|
7
|
+
*
|
|
6
8
|
* @since 0.3.16-canary.0
|
|
7
9
|
*/
|
|
8
10
|
export function processArrangeSimplifyFile(fs, args) {
|
|
@@ -25,5 +27,4 @@ export function processArrangeSimplifyFile(fs, args) {
|
|
|
25
27
|
}
|
|
26
28
|
fs.writeFileSync(filePath, textAfterImportDrop, "utf8");
|
|
27
29
|
return { filePath, totalFound, changed: totalFound };
|
|
28
|
-
}
|
|
29
|
-
//# sourceMappingURL=simplify-process-file.js.map
|
|
30
|
+
}
|
|
@@ -2,6 +2,8 @@ import { scanArrangeTargets } from "#/arrange/scan-target";
|
|
|
2
2
|
import { processArrangeSimplifyFile } from "#/arrange/simplify-process-file";
|
|
3
3
|
import { ok } from "#/core/result";
|
|
4
4
|
/**
|
|
5
|
+
* Runs the simplify pass over every target file and returns the aggregated result.
|
|
6
|
+
*
|
|
5
7
|
* @since 0.3.16-canary.0
|
|
6
8
|
*/
|
|
7
9
|
export async function runArrangeSimplify(fs, args) {
|
|
@@ -25,5 +27,4 @@ export async function runArrangeSimplify(fs, args) {
|
|
|
25
27
|
hookError: null,
|
|
26
28
|
previewPlans: [],
|
|
27
29
|
});
|
|
28
|
-
}
|
|
29
|
-
//# sourceMappingURL=simplify-sync.js.map
|
|
30
|
+
}
|
|
@@ -3,6 +3,8 @@ import { messageFrom } from "#/core/errors";
|
|
|
3
3
|
import { logger } from "#/core/logger";
|
|
4
4
|
const translator = new TypeScriptAstTranslator();
|
|
5
5
|
/**
|
|
6
|
+
* Parses source text into a domain source file via the shared `oxc-parser` translator.
|
|
7
|
+
*
|
|
6
8
|
* @since 0.3.16-canary.0
|
|
7
9
|
*/
|
|
8
10
|
export function parseDomainSourceFile(filePath, sourceText) {
|
|
@@ -13,5 +15,4 @@ export function parseDomainSourceFile(filePath, sourceText) {
|
|
|
13
15
|
logger.err(`[domain-source-parser] ${messageFrom(caughtError)}`);
|
|
14
16
|
throw caughtError;
|
|
15
17
|
}
|
|
16
|
-
}
|
|
17
|
-
//# sourceMappingURL=source-parse.js.map
|
|
18
|
+
}
|
package/dist/arrange/suggest.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { suggestCnGroups, summarizeGroupBucketLabels } from "#/arrange/domain/grouping";
|
|
2
2
|
import { formatArray, formatCnCall } from "#/arrange/domain/source-text-formatters";
|
|
3
3
|
/**
|
|
4
|
+
* Formats the suggested grouping for an inline class string as `arrange group` output lines.
|
|
5
|
+
*
|
|
4
6
|
* @since 0.3.16-canary.0
|
|
5
7
|
*/
|
|
6
8
|
export function suggestCnGroupsFromCli(request) {
|
|
@@ -10,5 +12,4 @@ export function suggestCnGroupsFromCli(request) {
|
|
|
10
12
|
: formatCnCall(groups, { trailingClassName: request.trailingClassName });
|
|
11
13
|
const bucketsCommentLine = `// Buckets: ${JSON.stringify(summarizeGroupBucketLabels(groups))}`;
|
|
12
14
|
return { primaryLine, bucketsCommentLine };
|
|
13
|
-
}
|
|
14
|
-
//# sourceMappingURL=suggest.js.map
|
|
15
|
+
}
|
package/dist/arrange/sync.js
CHANGED
|
@@ -15,6 +15,8 @@ async function runOnAfterWriteHook(hook, modifiedFiles) {
|
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
17
|
/**
|
|
18
|
+
* Runs the grouping pipeline over every target file and returns the aggregated result.
|
|
19
|
+
*
|
|
18
20
|
* @since 0.3.16-canary.0
|
|
19
21
|
*/
|
|
20
22
|
export async function runArrangeSync(fs, request) {
|
|
@@ -44,5 +46,4 @@ export async function runArrangeSync(fs, request) {
|
|
|
44
46
|
? await runOnAfterWriteHook(arrangeConfig?.onAfterWrite, modifiedFiles)
|
|
45
47
|
: null;
|
|
46
48
|
return ok({ filePaths, modifiedFiles, totalFound, totalChanged, hookError, previewPlans });
|
|
47
|
-
}
|
|
48
|
-
//# sourceMappingURL=sync.js.map
|
|
49
|
+
}
|
|
@@ -11,6 +11,8 @@ function nodeName(node) {
|
|
|
11
11
|
return typeof node.name === "string" ? node.name : "";
|
|
12
12
|
}
|
|
13
13
|
/**
|
|
14
|
+
* The translator mapping the `oxc-parser` ESTree AST to the arrange domain AST.
|
|
15
|
+
*
|
|
14
16
|
* @since 0.3.16-canary.0
|
|
15
17
|
*/
|
|
16
18
|
export class TypeScriptAstTranslator {
|
|
@@ -451,5 +453,4 @@ export class TypeScriptAstTranslator {
|
|
|
451
453
|
statements,
|
|
452
454
|
};
|
|
453
455
|
}
|
|
454
|
-
}
|
|
455
|
-
//# sourceMappingURL=typescript-ast-translator.js.map
|
|
456
|
+
}
|
|
@@ -5,6 +5,8 @@ import { messageFrom } from "#/core/errors";
|
|
|
5
5
|
import { err, ok } from "#/core/result";
|
|
6
6
|
import { findRepoRoot } from "#/core/workspace/resolver";
|
|
7
7
|
/**
|
|
8
|
+
* Resolves the arrange target, repo root, and loaded config an arrange run needs.
|
|
9
|
+
*
|
|
8
10
|
* @since 0.3.16-canary.0
|
|
9
11
|
*/
|
|
10
12
|
export async function prepareArrangeWorkspace(fs, args) {
|
|
@@ -27,5 +29,4 @@ export async function prepareArrangeWorkspace(fs, args) {
|
|
|
27
29
|
return loadedOutcome;
|
|
28
30
|
}
|
|
29
31
|
return ok({ resolvedTarget, rootDir, config: loadedOutcome.value.config });
|
|
30
|
-
}
|
|
31
|
-
//# sourceMappingURL=workspace.js.map
|
|
32
|
+
}
|
package/dist/audit/cli-schema.js
CHANGED
|
@@ -3,7 +3,7 @@ import { z } from "zod";
|
|
|
3
3
|
/**
|
|
4
4
|
* Zod schema for {@link RtlAuditRunRequest}.
|
|
5
5
|
*
|
|
6
|
-
* @since
|
|
6
|
+
* @since 0.5.0-canary.6
|
|
7
7
|
*/
|
|
8
8
|
export const rtlAuditRunRequestSchema = z.object({
|
|
9
9
|
rootDir: z.string().min(1),
|
|
@@ -34,12 +34,22 @@ export const commentAuditRunRequestSchema = z.object({
|
|
|
34
34
|
fix: z.boolean(),
|
|
35
35
|
json: z.boolean(),
|
|
36
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
|
+
});
|
|
37
48
|
/**
|
|
38
49
|
* Resolves a path that may be absolute or relative to `rootDir`.
|
|
39
50
|
*
|
|
40
|
-
* @since
|
|
51
|
+
* @since 0.5.0-canary.6
|
|
41
52
|
*/
|
|
42
53
|
export function resolveRepoRelativePath(rootDir, maybeRelative) {
|
|
43
54
|
return path.isAbsolute(maybeRelative) ? path.resolve(maybeRelative) : path.resolve(rootDir, maybeRelative);
|
|
44
|
-
}
|
|
45
|
-
//# sourceMappingURL=cli-schema.js.map
|
|
55
|
+
}
|
package/dist/audit/command.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import process from "node:process";
|
|
2
2
|
import { Command } from "commander";
|
|
3
|
-
import { commentAuditRunRequestSchema, linkAuditRunRequestSchema, rtlAuditRunRequestSchema } from "#/audit/cli-schema";
|
|
4
|
-
import { exitCodeForCommentAuditResult, exitCodeForLinkAuditResult, exitCodeForRtlAuditResult, formatCommentAuditJsonOutput, formatLinkAuditJsonOutput, formatRtlAuditJsonOutput, presentCommentAuditResult, presentLinkAuditResult, presentRtlAuditResult, } from "#/audit/output";
|
|
5
|
-
import { prepareCommentAudit, prepareLinkAudit, prepareRtlAudit } from "#/audit/prepare";
|
|
3
|
+
import { commentAuditRunRequestSchema, linkAuditRunRequestSchema, reactAuditRunRequestSchema, rtlAuditRunRequestSchema, } from "#/audit/cli-schema";
|
|
4
|
+
import { exitCodeForCommentAuditResult, exitCodeForLinkAuditResult, exitCodeForReactAuditResult, exitCodeForRtlAuditResult, formatCommentAuditJsonOutput, formatLinkAuditJsonOutput, formatReactAuditJsonOutput, formatRtlAuditJsonOutput, presentCommentAuditResult, presentLinkAuditResult, presentReactAuditResult, presentRtlAuditResult, } from "#/audit/output";
|
|
5
|
+
import { prepareCommentAudit, prepareLinkAudit, prepareReactAudit, prepareRtlAudit } from "#/audit/prepare";
|
|
6
6
|
import { runRtlAudit } from "#/audit/run";
|
|
7
7
|
import { runCommentAudit } from "#/audit/run-comments";
|
|
8
8
|
import { runLinkAudit } from "#/audit/run-links";
|
|
9
|
+
import { runReactAudit } from "#/audit/run-react";
|
|
9
10
|
import { readOptionalPositionalArg } from "#/core/cli/positional";
|
|
10
11
|
import { consumeCliAppError } from "#/core/cli/result-handle";
|
|
11
12
|
import { nodeFilesystem } from "#/core/filesystem/node";
|
|
@@ -15,7 +16,7 @@ import { parseWithSchema } from "#/core/schema-parse";
|
|
|
15
16
|
* Top-level `audit` command — the source scans. Every one of them reports by default; only
|
|
16
17
|
* `comments --fix` writes, and only where the rewrite discards nothing a person wrote.
|
|
17
18
|
*
|
|
18
|
-
* @since
|
|
19
|
+
* @since 0.5.0-canary.6
|
|
19
20
|
*/
|
|
20
21
|
export function createAuditCommand() {
|
|
21
22
|
const cmd = new Command("audit").description("Source audits").enablePositionalOptions();
|
|
@@ -97,6 +98,45 @@ export function createAuditCommand() {
|
|
|
97
98
|
}
|
|
98
99
|
process.exitCode = exitCodeForLinkAuditResult(outcome.value);
|
|
99
100
|
});
|
|
101
|
+
cmd
|
|
102
|
+
.command("react")
|
|
103
|
+
.description("Report React namespace/default imports and implicit React.* UMD-global type references")
|
|
104
|
+
.argument("[target]", "Directory or file to scan (default: the repo root)")
|
|
105
|
+
.option("--json", "Print one JSON summary on stdout", false)
|
|
106
|
+
.action(async (target, opts) => {
|
|
107
|
+
const prelude = await prepareReactAudit(nodeFilesystem, {
|
|
108
|
+
currentWorkingDirectory: process.cwd(),
|
|
109
|
+
rawTarget: readOptionalPositionalArg(target),
|
|
110
|
+
});
|
|
111
|
+
if (!consumeCliAppError(prelude)) {
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
const { rootDir, targetPath, allowlist } = prelude.value;
|
|
115
|
+
const parsed = parseWithSchema(reactAuditRunRequestSchema, {
|
|
116
|
+
rootDir,
|
|
117
|
+
targetPath,
|
|
118
|
+
allowlist,
|
|
119
|
+
json: !!opts.json,
|
|
120
|
+
});
|
|
121
|
+
if (!consumeCliAppError(parsed)) {
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
const outcome = runReactAudit(nodeFilesystem, {
|
|
125
|
+
rootDir: parsed.value.rootDir,
|
|
126
|
+
targetPath: parsed.value.targetPath,
|
|
127
|
+
allowlist: parsed.value.allowlist ?? [],
|
|
128
|
+
});
|
|
129
|
+
if (!consumeCliAppError(outcome)) {
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
if (parsed.value.json) {
|
|
133
|
+
logger.out(formatReactAuditJsonOutput(outcome.value, rootDir));
|
|
134
|
+
}
|
|
135
|
+
else {
|
|
136
|
+
presentReactAuditResult(outcome.value);
|
|
137
|
+
}
|
|
138
|
+
process.exitCode = exitCodeForReactAuditResult(outcome.value);
|
|
139
|
+
});
|
|
100
140
|
cmd
|
|
101
141
|
.command("comments")
|
|
102
142
|
.description("Report section dividers that are not in the repo's one allowed form")
|
|
@@ -140,5 +180,4 @@ export function createAuditCommand() {
|
|
|
140
180
|
process.exitCode = exitCodeForCommentAuditResult(outcome.value);
|
|
141
181
|
});
|
|
142
182
|
return cmd;
|
|
143
|
-
}
|
|
144
|
-
//# sourceMappingURL=command.js.map
|
|
183
|
+
}
|
|
@@ -5,9 +5,9 @@ import { collectTokens } from "#/audit/domain/tokenize";
|
|
|
5
5
|
* token whose variants include `rtl` and whose value matches. Variant order
|
|
6
6
|
* differs between authors, so this stays deliberately loose.
|
|
7
7
|
*
|
|
8
|
-
* @since
|
|
8
|
+
* @since 0.5.0-canary.6
|
|
9
9
|
*/
|
|
10
|
-
|
|
10
|
+
function hasRtlCompanion(fileTokens, expectedValue) {
|
|
11
11
|
return fileTokens.some(({ variant, value }) => {
|
|
12
12
|
if (!variant) {
|
|
13
13
|
return false;
|
|
@@ -22,7 +22,7 @@ export function hasRtlCompanion(fileTokens, expectedValue) {
|
|
|
22
22
|
/**
|
|
23
23
|
* Detects physical-direction Tailwind classes that should be logical or rtl:-paired.
|
|
24
24
|
*
|
|
25
|
-
* @since
|
|
25
|
+
* @since 0.5.0-canary.6
|
|
26
26
|
*/
|
|
27
27
|
export function auditFileContent(content) {
|
|
28
28
|
const tokens = collectTokens(content);
|
|
@@ -97,5 +97,4 @@ export function auditFileContent(content) {
|
|
|
97
97
|
}
|
|
98
98
|
}
|
|
99
99
|
return violations;
|
|
100
|
-
}
|
|
101
|
-
//# sourceMappingURL=audit-file.js.map
|
|
100
|
+
}
|