@codefast/cli 0.11.0 → 0.13.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 +87 -0
- package/README.md +152 -56
- package/dist/arrange/command.js +24 -25
- package/dist/arrange/domain/ast/collectors-cn.d.ts +2 -2
- package/dist/arrange/domain/ast/collectors-cn.js +2 -2
- package/dist/arrange/domain/ast/collectors-jsx.d.ts +2 -2
- package/dist/arrange/domain/ast/collectors-jsx.js +1 -1
- package/dist/arrange/domain/ast/collectors-tv.d.ts +2 -2
- package/dist/arrange/domain/ast/collectors-tv.js +5 -5
- package/dist/arrange/domain/ast/helpers.d.ts +2 -2
- package/dist/arrange/domain/ast/helpers.js +3 -4
- package/dist/arrange/domain/ast/simplify-targets.d.ts +1 -1
- package/dist/arrange/domain/ast/simplify-targets.js +5 -5
- package/dist/arrange/domain/ast/targets.d.ts +2 -2
- package/dist/arrange/domain/ast/targets.js +9 -9
- package/dist/arrange/domain/ast/translator.d.ts +1 -1
- package/dist/arrange/domain/ast/translator.js +43 -29
- package/dist/arrange/domain/constants.d.ts +1 -1
- package/dist/arrange/domain/grouping-service.d.ts +2 -2
- package/dist/arrange/domain/grouping-service.js +3 -3
- package/dist/arrange/domain/grouping.js +3 -3
- package/dist/arrange/domain/imports.d.ts +1 -1
- package/dist/arrange/domain/imports.js +2 -2
- package/dist/arrange/domain/source-text-formatters.js +1 -1
- package/dist/arrange/domain/tailwind-token.js +1 -1
- package/dist/arrange/domain/token-classifier.d.ts +1 -1
- package/dist/arrange/domain/token-classifier.js +2 -2
- package/dist/arrange/domain/types.d.ts +3 -3
- package/dist/arrange/group/cli-result.d.ts +1 -1
- package/dist/arrange/group/output.d.ts +1 -1
- package/dist/arrange/group/output.js +1 -1
- package/dist/arrange/group/suggest.d.ts +2 -2
- package/dist/arrange/group/suggest.js +2 -2
- package/dist/arrange/inspect/cli-result.d.ts +1 -1
- package/dist/arrange/inspect/domain/analyze-service.d.ts +2 -2
- package/dist/arrange/inspect/domain/analyze-service.js +7 -7
- package/dist/arrange/inspect/output.d.ts +1 -1
- package/dist/arrange/inspect/output.js +2 -2
- package/dist/arrange/inspect/run.d.ts +4 -4
- package/dist/arrange/inspect/run.js +6 -6
- package/dist/arrange/prepare.d.ts +4 -4
- package/dist/arrange/prepare.js +5 -5
- package/dist/arrange/regroup/cli-result.d.ts +1 -1
- package/dist/arrange/regroup/cli-result.js +1 -1
- package/dist/arrange/regroup/output.d.ts +2 -2
- package/dist/arrange/regroup/output.js +2 -2
- package/dist/arrange/regroup/process-file.d.ts +2 -2
- package/dist/arrange/regroup/process-file.js +3 -3
- package/dist/arrange/regroup/run.d.ts +5 -5
- package/dist/arrange/regroup/run.js +4 -4
- package/dist/arrange/resolve-target.d.ts +1 -1
- package/dist/arrange/resolve-target.js +2 -2
- package/dist/arrange/scan-target.d.ts +1 -1
- package/dist/arrange/scan-target.js +3 -3
- package/dist/arrange/simplify/cli-result.d.ts +1 -1
- package/dist/arrange/simplify/fold-targets.d.ts +3 -3
- package/dist/arrange/simplify/fold-targets.js +3 -3
- package/dist/arrange/simplify/output.d.ts +1 -1
- package/dist/arrange/simplify/output.js +1 -1
- package/dist/arrange/simplify/process-file.d.ts +4 -4
- package/dist/arrange/simplify/process-file.js +5 -5
- package/dist/arrange/simplify/run.d.ts +4 -4
- package/dist/arrange/simplify/run.js +4 -4
- package/dist/arrange/simplify/variant-classname-probe.js +1 -1
- package/dist/arrange/source-parse.d.ts +1 -1
- package/dist/arrange/source-parse.js +3 -3
- package/dist/audit/assertions/cli-result.d.ts +13 -0
- package/dist/audit/assertions/cli-result.js +22 -0
- package/dist/audit/assertions/cli-schema.d.ts +18 -0
- package/dist/audit/assertions/cli-schema.js +12 -0
- package/dist/audit/assertions/domain/double-assertion.d.ts +20 -0
- package/dist/audit/assertions/domain/double-assertion.js +122 -0
- package/dist/audit/assertions/output.d.ts +7 -0
- package/dist/audit/assertions/output.js +21 -0
- package/dist/audit/assertions/prepare.d.ts +16 -0
- package/dist/audit/assertions/prepare.js +12 -0
- package/dist/audit/assertions/run.d.ts +14 -0
- package/dist/audit/assertions/run.js +40 -0
- package/dist/audit/command.js +89 -28
- package/dist/audit/comments/cli-result.d.ts +1 -1
- package/dist/audit/comments/cli-result.js +1 -1
- package/dist/audit/comments/output.d.ts +1 -1
- package/dist/audit/comments/output.js +1 -1
- package/dist/audit/comments/prepare.d.ts +4 -4
- package/dist/audit/comments/prepare.js +1 -1
- package/dist/audit/comments/run.d.ts +4 -4
- package/dist/audit/comments/run.js +9 -9
- package/dist/audit/constants/cli-result.d.ts +13 -0
- package/dist/audit/constants/cli-result.js +22 -0
- package/dist/audit/constants/cli-schema.d.ts +18 -0
- package/dist/audit/constants/cli-schema.js +12 -0
- package/dist/audit/constants/domain/constants.d.ts +8 -0
- package/dist/audit/constants/domain/constants.js +66 -0
- package/dist/audit/constants/output.d.ts +7 -0
- package/dist/audit/constants/output.js +21 -0
- package/dist/audit/constants/prepare.d.ts +16 -0
- package/dist/audit/constants/prepare.js +37 -0
- package/dist/audit/constants/run.d.ts +14 -0
- package/dist/audit/constants/run.js +64 -0
- package/dist/audit/display-names/cli-result.d.ts +1 -1
- package/dist/audit/display-names/cli-result.js +1 -1
- package/dist/audit/display-names/domain/display-names.d.ts +1 -1
- package/dist/audit/display-names/domain/display-names.js +1 -9
- package/dist/audit/display-names/output.d.ts +1 -1
- package/dist/audit/display-names/output.js +1 -1
- package/dist/audit/display-names/prepare.d.ts +4 -4
- package/dist/audit/display-names/prepare.js +1 -1
- package/dist/audit/display-names/run.d.ts +4 -4
- package/dist/audit/display-names/run.js +5 -5
- package/dist/audit/domain/types.d.ts +128 -0
- package/dist/audit/imports/cli-result.d.ts +1 -1
- package/dist/audit/imports/cli-result.js +1 -1
- package/dist/audit/imports/domain/import-policy.d.ts +1 -1
- package/dist/audit/imports/domain/import-policy.js +4 -18
- package/dist/audit/imports/output.d.ts +1 -1
- package/dist/audit/imports/output.js +1 -1
- package/dist/audit/imports/prepare.d.ts +4 -4
- package/dist/audit/imports/prepare.js +1 -1
- package/dist/audit/imports/run.d.ts +4 -4
- package/dist/audit/imports/run.js +6 -6
- package/dist/audit/links/cli-result.d.ts +1 -1
- package/dist/audit/links/cli-result.js +1 -1
- package/dist/audit/links/domain/markdown-links.d.ts +3 -3
- package/dist/audit/links/domain/markdown-links.js +22 -8
- package/dist/audit/links/output.d.ts +1 -1
- package/dist/audit/links/output.js +1 -1
- package/dist/audit/links/prepare.d.ts +4 -4
- package/dist/audit/links/prepare.js +1 -1
- package/dist/audit/links/run.d.ts +4 -4
- package/dist/audit/links/run.js +4 -4
- package/dist/audit/prepare.d.ts +4 -4
- package/dist/audit/prepare.js +4 -4
- package/dist/audit/publish/cli-result.d.ts +13 -0
- package/dist/audit/publish/cli-result.js +25 -0
- package/dist/audit/publish/cli-schema.d.ts +18 -0
- package/dist/audit/publish/cli-schema.js +12 -0
- package/dist/audit/publish/domain/legacy-subpath.d.ts +8 -0
- package/dist/audit/publish/domain/legacy-subpath.js +22 -0
- package/dist/audit/publish/domain/stylesheet-sources.d.ts +22 -0
- package/dist/audit/publish/domain/stylesheet-sources.js +64 -0
- package/dist/audit/publish/output.d.ts +7 -0
- package/dist/audit/publish/output.js +33 -0
- package/dist/audit/publish/prepare.d.ts +16 -0
- package/dist/audit/publish/prepare.js +12 -0
- package/dist/audit/publish/run.d.ts +15 -0
- package/dist/audit/publish/run.js +91 -0
- package/dist/audit/publish/shipped-files.d.ts +21 -0
- package/dist/audit/publish/shipped-files.js +36 -0
- package/dist/audit/rtl/cli-result.d.ts +1 -1
- package/dist/audit/rtl/cli-result.js +1 -1
- package/dist/audit/rtl/domain/audit-file.d.ts +1 -1
- package/dist/audit/rtl/domain/audit-file.js +2 -2
- package/dist/audit/rtl/domain/tokenize.d.ts +1 -1
- package/dist/audit/rtl/output.d.ts +1 -1
- package/dist/audit/rtl/output.js +1 -1
- package/dist/audit/rtl/prepare.d.ts +4 -4
- package/dist/audit/rtl/prepare.js +5 -5
- package/dist/audit/rtl/run.d.ts +4 -4
- package/dist/audit/rtl/run.js +4 -4
- package/dist/bin.js +1 -1
- package/dist/cli.js +5 -5
- package/dist/core/cli/command-pipeline.d.ts +4 -5
- package/dist/core/cli/command-pipeline.js +7 -7
- package/dist/core/cli/format-error.d.ts +1 -1
- package/dist/core/cli/resolve-root.d.ts +3 -3
- package/dist/core/cli/resolve-root.js +3 -3
- package/dist/core/cli/result-handle.d.ts +2 -2
- package/dist/core/cli/result-handle.js +4 -4
- package/dist/core/config/define-config.d.ts +1 -1
- package/dist/core/config/loader.d.ts +2 -2
- package/dist/core/config/loader.js +2 -2
- package/dist/core/config/schema.d.ts +5 -0
- package/dist/core/config/schema.js +2 -0
- package/dist/core/config/warnings.js +1 -1
- package/dist/core/config.d.ts +4 -4
- package/dist/core/config.js +4 -4
- package/dist/core/filesystem/filesystem.d.ts +3 -4
- package/dist/core/filesystem/node.d.ts +1 -1
- package/dist/core/filesystem/node.js +1 -7
- package/dist/core/oxc-node.d.ts +32 -0
- package/dist/core/oxc-node.js +25 -0
- package/dist/core/schema-parse.d.ts +2 -2
- package/dist/core/schema-parse.js +2 -2
- package/dist/core/source-position.d.ts +15 -0
- package/dist/core/source-position.js +26 -0
- package/dist/core/workspace/markdown-walk.d.ts +1 -1
- package/dist/core/workspace/markdown-walk.js +1 -1
- package/dist/core/workspace/package-version.d.ts +1 -1
- package/dist/core/workspace/package-version.js +2 -2
- package/dist/core/workspace/resolver.d.ts +1 -1
- package/dist/core/workspace/resolver.js +5 -5
- package/dist/core/workspace/source-walk.d.ts +1 -1
- package/dist/core/workspace/source-walk.js +1 -1
- package/dist/core/workspace/typescript-walk.d.ts +1 -1
- package/dist/core/workspace/typescript-walk.js +1 -1
- package/dist/core/workspace/walk-files.d.ts +1 -1
- package/dist/core/workspace/walk-files.js +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +2 -2
- package/dist/mirror/cli-result.d.ts +1 -1
- package/dist/mirror/cli-result.js +1 -1
- package/dist/mirror/cli-schema.d.ts +1 -1
- package/dist/mirror/command.js +7 -7
- package/dist/mirror/dist-filesystem-node.d.ts +2 -2
- package/dist/mirror/dist-filesystem-node.js +5 -15
- package/dist/mirror/domain/exports.d.ts +2 -2
- package/dist/mirror/domain/exports.js +1 -1
- package/dist/mirror/domain/types.d.ts +2 -2
- package/dist/mirror/output.d.ts +1 -1
- package/dist/mirror/output.js +2 -2
- package/dist/mirror/package-path.d.ts +3 -3
- package/dist/mirror/package-path.js +3 -3
- package/dist/mirror/prepare.d.ts +5 -5
- package/dist/mirror/prepare.js +4 -4
- package/dist/mirror/run.d.ts +6 -6
- package/dist/mirror/run.js +7 -7
- package/dist/mirror/supplement-exports.d.ts +1 -1
- package/dist/mirror/supplement-exports.js +2 -2
- package/dist/mirror/sync-workspace-package.d.ts +3 -3
- package/dist/mirror/sync-workspace-package.js +11 -14
- package/dist/mirror/write-exports.d.ts +2 -2
- package/dist/mirror/write-exports.js +3 -3
- package/dist/pack-slim/cli-result.d.ts +1 -1
- package/dist/pack-slim/cli-result.js +1 -1
- package/dist/pack-slim/command.js +9 -9
- package/dist/pack-slim/domain/transform.d.ts +22 -1
- package/dist/pack-slim/domain/transform.js +65 -8
- package/dist/pack-slim/output.d.ts +1 -1
- package/dist/pack-slim/output.js +1 -1
- package/dist/pack-slim/prepare.d.ts +3 -3
- package/dist/pack-slim/prepare.js +2 -2
- package/dist/pack-slim/run.d.ts +5 -5
- package/dist/pack-slim/run.js +6 -6
- package/dist/pack-slim/working-tree.d.ts +2 -2
- package/dist/pack-slim/working-tree.js +2 -2
- package/dist/tag/cli-result.d.ts +1 -1
- package/dist/tag/cli-result.js +1 -1
- package/dist/tag/cli-schema.d.ts +1 -1
- package/dist/tag/command.js +7 -7
- package/dist/tag/domain/skip-filter.d.ts +1 -1
- package/dist/tag/domain/skip-filter.js +1 -1
- package/dist/tag/domain/types.d.ts +1 -1
- package/dist/tag/domain/version-summary.d.ts +5 -2
- package/dist/tag/output.d.ts +1 -1
- package/dist/tag/output.js +1 -1
- package/dist/tag/prepare.d.ts +4 -4
- package/dist/tag/prepare.js +4 -4
- package/dist/tag/run.d.ts +4 -4
- package/dist/tag/run.js +7 -7
- package/dist/tag/target/candidates.d.ts +2 -2
- package/dist/tag/target/candidates.js +2 -2
- package/dist/tag/target/resolve-path.d.ts +1 -1
- package/dist/tag/target/runner.d.ts +2 -2
- package/dist/tag/target/runner.js +3 -3
- package/dist/tag/writer/since-writer.d.ts +2 -2
- package/dist/tag/writer/since-writer.js +3 -5
- package/dist/tag/writer/version-resolver.d.ts +1 -1
- package/dist/tag/writer/version-resolver.js +1 -1
- package/package.json +7 -7
- package/dist/mirror/domain/dirent-guard.d.ts +0 -10
- package/dist/mirror/domain/dirent-guard.js +0 -15
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { isDomainArrayLiteralExpression, isDomainJsxAttribute, isDomainPropertyAssignment, isDomainTailwindClassLiteral, forEachDomainChild, } from "
|
|
2
|
-
import { isUnsafeLiteralForCnStyleApplySplit } from "
|
|
3
|
-
import { jsxClassNameStaticLiteral } from "
|
|
4
|
-
import { collectGroupableStringNodes, slotClassString } from "
|
|
5
|
-
import { APPLY_MIN_TOKENS } from "
|
|
6
|
-
import { areCnTailwindPartitionsEquivalent, suggestCnGroups, summarizeGroupBucketLabels, } from "
|
|
7
|
-
import { escapeTsStringLiteralContent, formatArray, formatArrayElementsAsSiblingLines, formatJsxCnAttributeValue, } from "
|
|
8
|
-
import { tokenizeClassString } from "
|
|
9
|
-
import { endAfterOptionalCommaFollowingInSource, indentOfLineContaining, textPrefixFromLineStartToPosition, } from "
|
|
1
|
+
import { isDomainArrayLiteralExpression, isDomainJsxAttribute, isDomainPropertyAssignment, isDomainTailwindClassLiteral, forEachDomainChild, } from "#arrange/domain/ast/ast-node";
|
|
2
|
+
import { isUnsafeLiteralForCnStyleApplySplit } from "#arrange/domain/ast/collectors-cn";
|
|
3
|
+
import { jsxClassNameStaticLiteral } from "#arrange/domain/ast/collectors-jsx";
|
|
4
|
+
import { collectGroupableStringNodes, slotClassString } from "#arrange/domain/ast/collectors-tv";
|
|
5
|
+
import { APPLY_MIN_TOKENS } from "#arrange/domain/constants";
|
|
6
|
+
import { areCnTailwindPartitionsEquivalent, suggestCnGroups, summarizeGroupBucketLabels, } from "#arrange/domain/grouping";
|
|
7
|
+
import { escapeTsStringLiteralContent, formatArray, formatArrayElementsAsSiblingLines, formatJsxCnAttributeValue, } from "#arrange/domain/source-text-formatters";
|
|
8
|
+
import { tokenizeClassString } from "#arrange/domain/tailwind-token";
|
|
9
|
+
import { endAfterOptionalCommaFollowingInSource, indentOfLineContaining, textPrefixFromLineStartToPosition, } from "#core/source-text-edit";
|
|
10
10
|
/**
|
|
11
11
|
* Resolves the source position where a group target's replacement begins.
|
|
12
12
|
*
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Anti-corruption layer: maps the oxc-parser ESTree AST to the arrange domain AST.
|
|
3
3
|
* This is the only place that parses TypeScript source for arrange AST translation.
|
|
4
4
|
*/
|
|
5
|
-
import type { DomainSourceFile } from "
|
|
5
|
+
import type { DomainSourceFile } from "#arrange/domain/ast/ast-node";
|
|
6
6
|
/**
|
|
7
7
|
* The translator mapping the `oxc-parser` ESTree AST to the arrange domain AST.
|
|
8
8
|
*
|
|
@@ -3,10 +3,27 @@
|
|
|
3
3
|
* This is the only place that parses TypeScript source for arrange AST translation.
|
|
4
4
|
*/
|
|
5
5
|
import { parseSync } from "oxc-parser";
|
|
6
|
-
import { DomainBinaryOperator, DomainSyntaxKind } from "
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
import { DomainBinaryOperator, DomainSyntaxKind } from "#arrange/domain/ast/ast-node";
|
|
7
|
+
import { isOxcNode, programStatements } from "#core/oxc-node";
|
|
8
|
+
/**
|
|
9
|
+
* Stands in for a child while its parent is built first, so the child has a parent to point at; the
|
|
10
|
+
* build replaces it before the node leaves the translator.
|
|
11
|
+
*/
|
|
12
|
+
const PENDING_NODE = Object.freeze({
|
|
13
|
+
kind: DomainSyntaxKind.Unknown,
|
|
14
|
+
pos: -1,
|
|
15
|
+
end: -1,
|
|
16
|
+
parent: null,
|
|
17
|
+
children: [],
|
|
18
|
+
});
|
|
19
|
+
/** The same stand-in for a child typed as an identifier. */
|
|
20
|
+
const PENDING_IDENTIFIER = Object.freeze({
|
|
21
|
+
kind: DomainSyntaxKind.Identifier,
|
|
22
|
+
pos: -1,
|
|
23
|
+
end: -1,
|
|
24
|
+
parent: null,
|
|
25
|
+
text: "",
|
|
26
|
+
});
|
|
10
27
|
function nodeName(node) {
|
|
11
28
|
return typeof node.name === "string" ? node.name : "";
|
|
12
29
|
}
|
|
@@ -87,15 +104,13 @@ export class TypeScriptAstTranslator {
|
|
|
87
104
|
end: node.end,
|
|
88
105
|
parent,
|
|
89
106
|
importClause: undefined,
|
|
90
|
-
moduleSpecifier:
|
|
107
|
+
moduleSpecifier: PENDING_NODE,
|
|
91
108
|
};
|
|
92
109
|
if (specifiers.length > 0) {
|
|
93
110
|
self.importClause = this.buildImportClause(node, specifiers, self);
|
|
94
111
|
}
|
|
95
112
|
const source = isOxcNode(node.source) ? node.source : undefined;
|
|
96
|
-
self.moduleSpecifier = source
|
|
97
|
-
? this.translateNode(source, self)
|
|
98
|
-
: this.translateUnknown(node, self);
|
|
113
|
+
self.moduleSpecifier = source ? this.translateNode(source, self) : this.translateUnknown(node, self);
|
|
99
114
|
return self;
|
|
100
115
|
}
|
|
101
116
|
buildImportClause(declaration, specifiers, parent) {
|
|
@@ -131,7 +146,7 @@ export class TypeScriptAstTranslator {
|
|
|
131
146
|
pos: specifier.start,
|
|
132
147
|
end: specifier.end,
|
|
133
148
|
parent,
|
|
134
|
-
name:
|
|
149
|
+
name: PENDING_IDENTIFIER,
|
|
135
150
|
};
|
|
136
151
|
self.name = this.translateIdentifier(local, self);
|
|
137
152
|
return self;
|
|
@@ -158,7 +173,7 @@ export class TypeScriptAstTranslator {
|
|
|
158
173
|
end: specifier.end,
|
|
159
174
|
parent,
|
|
160
175
|
propertyName: undefined,
|
|
161
|
-
name:
|
|
176
|
+
name: PENDING_IDENTIFIER,
|
|
162
177
|
};
|
|
163
178
|
if (imported && imported.type === "Identifier" && nodeName(imported) !== nodeName(local)) {
|
|
164
179
|
self.propertyName = this.translateIdentifier(imported, self);
|
|
@@ -220,7 +235,7 @@ export class TypeScriptAstTranslator {
|
|
|
220
235
|
pos,
|
|
221
236
|
end,
|
|
222
237
|
parent,
|
|
223
|
-
expression:
|
|
238
|
+
expression: PENDING_NODE,
|
|
224
239
|
arguments: [],
|
|
225
240
|
};
|
|
226
241
|
self.expression = this.translateNode(callee, self);
|
|
@@ -238,8 +253,8 @@ export class TypeScriptAstTranslator {
|
|
|
238
253
|
pos,
|
|
239
254
|
end,
|
|
240
255
|
parent,
|
|
241
|
-
expression:
|
|
242
|
-
name:
|
|
256
|
+
expression: PENDING_NODE,
|
|
257
|
+
name: PENDING_IDENTIFIER,
|
|
243
258
|
};
|
|
244
259
|
self.expression = this.translateNode(object, self);
|
|
245
260
|
self.name = this.translateNode(property, self);
|
|
@@ -273,8 +288,8 @@ export class TypeScriptAstTranslator {
|
|
|
273
288
|
pos,
|
|
274
289
|
end,
|
|
275
290
|
parent,
|
|
276
|
-
name:
|
|
277
|
-
initializer:
|
|
291
|
+
name: PENDING_NODE,
|
|
292
|
+
initializer: PENDING_NODE,
|
|
278
293
|
};
|
|
279
294
|
self.name = this.translateNode(key, self);
|
|
280
295
|
self.initializer = this.translateNode(value, self);
|
|
@@ -305,7 +320,7 @@ export class TypeScriptAstTranslator {
|
|
|
305
320
|
pos,
|
|
306
321
|
end,
|
|
307
322
|
parent,
|
|
308
|
-
expression:
|
|
323
|
+
expression: PENDING_NODE,
|
|
309
324
|
};
|
|
310
325
|
self.expression = this.translateNode(argument, self);
|
|
311
326
|
return self;
|
|
@@ -317,7 +332,7 @@ export class TypeScriptAstTranslator {
|
|
|
317
332
|
pos,
|
|
318
333
|
end,
|
|
319
334
|
parent,
|
|
320
|
-
expression:
|
|
335
|
+
expression: PENDING_NODE,
|
|
321
336
|
};
|
|
322
337
|
self.expression = this.translateNode(expression, self);
|
|
323
338
|
return self;
|
|
@@ -329,7 +344,7 @@ export class TypeScriptAstTranslator {
|
|
|
329
344
|
pos,
|
|
330
345
|
end,
|
|
331
346
|
parent,
|
|
332
|
-
expression:
|
|
347
|
+
expression: PENDING_NODE,
|
|
333
348
|
};
|
|
334
349
|
self.expression = this.translateNode(expression, self);
|
|
335
350
|
return self;
|
|
@@ -341,7 +356,7 @@ export class TypeScriptAstTranslator {
|
|
|
341
356
|
pos,
|
|
342
357
|
end,
|
|
343
358
|
parent,
|
|
344
|
-
expression:
|
|
359
|
+
expression: PENDING_NODE,
|
|
345
360
|
};
|
|
346
361
|
self.expression = this.translateNode(expression, self);
|
|
347
362
|
return self;
|
|
@@ -353,7 +368,7 @@ export class TypeScriptAstTranslator {
|
|
|
353
368
|
pos,
|
|
354
369
|
end,
|
|
355
370
|
parent,
|
|
356
|
-
expression:
|
|
371
|
+
expression: PENDING_NODE,
|
|
357
372
|
};
|
|
358
373
|
self.expression = this.translateNode(expression, self);
|
|
359
374
|
return self;
|
|
@@ -367,9 +382,9 @@ export class TypeScriptAstTranslator {
|
|
|
367
382
|
pos,
|
|
368
383
|
end,
|
|
369
384
|
parent,
|
|
370
|
-
condition:
|
|
371
|
-
whenTrue:
|
|
372
|
-
whenFalse:
|
|
385
|
+
condition: PENDING_NODE,
|
|
386
|
+
whenTrue: PENDING_NODE,
|
|
387
|
+
whenFalse: PENDING_NODE,
|
|
373
388
|
};
|
|
374
389
|
self.condition = this.translateNode(test, self);
|
|
375
390
|
self.whenTrue = this.translateNode(consequent, self);
|
|
@@ -384,9 +399,9 @@ export class TypeScriptAstTranslator {
|
|
|
384
399
|
pos,
|
|
385
400
|
end,
|
|
386
401
|
parent,
|
|
387
|
-
left:
|
|
402
|
+
left: PENDING_NODE,
|
|
388
403
|
operator: this.mapBinaryOperator(node.operator),
|
|
389
|
-
right:
|
|
404
|
+
right: PENDING_NODE,
|
|
390
405
|
};
|
|
391
406
|
self.left = this.translateNode(left, self);
|
|
392
407
|
self.right = this.translateNode(right, self);
|
|
@@ -399,7 +414,7 @@ export class TypeScriptAstTranslator {
|
|
|
399
414
|
pos,
|
|
400
415
|
end,
|
|
401
416
|
parent,
|
|
402
|
-
expression:
|
|
417
|
+
expression: PENDING_NODE,
|
|
403
418
|
};
|
|
404
419
|
self.expression = this.translateNode(expression, self);
|
|
405
420
|
return self;
|
|
@@ -412,7 +427,7 @@ export class TypeScriptAstTranslator {
|
|
|
412
427
|
pos,
|
|
413
428
|
end,
|
|
414
429
|
parent,
|
|
415
|
-
name:
|
|
430
|
+
name: PENDING_NODE,
|
|
416
431
|
initializer: undefined,
|
|
417
432
|
};
|
|
418
433
|
self.name = this.translateNode(name, self);
|
|
@@ -442,8 +457,7 @@ export class TypeScriptAstTranslator {
|
|
|
442
457
|
parseDomainSourceFile(filePath, sourceText) {
|
|
443
458
|
// Best-effort parse to mirror `ts.createSourceFile` leniency — recoverable syntax
|
|
444
459
|
// errors still yield a usable tree, so `parseSync` errors are intentionally ignored.
|
|
445
|
-
const
|
|
446
|
-
const statements = program.body.map((statement) => this.translateNode(statement, null));
|
|
460
|
+
const statements = programStatements(parseSync(filePath, sourceText).program).map((statement) => this.translateNode(statement, null));
|
|
447
461
|
return {
|
|
448
462
|
fileName: filePath,
|
|
449
463
|
text: sourceText,
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
* Rich domain: plan Tailwind class grouping / cn-in-tv unwrap for a single file.
|
|
3
3
|
* Pure: only DomainSourceFile, source strings, and options — no I/O.
|
|
4
4
|
*/
|
|
5
|
-
import type { DomainCallExpression, DomainSourceFile } from "
|
|
6
|
-
import type { GroupFileResult, PlannedGroupEdit } from "
|
|
5
|
+
import type { DomainCallExpression, DomainSourceFile } from "#arrange/domain/ast/ast-node";
|
|
6
|
+
import type { GroupFileResult, PlannedGroupEdit } from "#arrange/domain/types";
|
|
7
7
|
/**
|
|
8
8
|
* A planned replacement unwrapping one `cn()` call nested in `tv({ ... })`.
|
|
9
9
|
*
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
* Rich domain: plan Tailwind class grouping / cn-in-tv unwrap for a single file.
|
|
3
3
|
* Pure: only DomainSourceFile, source strings, and options — no I/O.
|
|
4
4
|
*/
|
|
5
|
-
import { listAllCnCallsInsideTvInSourceFile } from "
|
|
6
|
-
import { applyEditsDescending, buildKnownCnTvBindings, unwrapCnInsideTvCallReplacement, } from "
|
|
7
|
-
import { collectGroupTargets, planGroupEditForTarget, targetReplaceStart } from "
|
|
5
|
+
import { listAllCnCallsInsideTvInSourceFile } from "#arrange/domain/ast/collectors-tv";
|
|
6
|
+
import { applyEditsDescending, buildKnownCnTvBindings, unwrapCnInsideTvCallReplacement, } from "#arrange/domain/ast/helpers";
|
|
7
|
+
import { collectGroupTargets, planGroupEditForTarget, targetReplaceStart } from "#arrange/domain/ast/targets";
|
|
8
8
|
function toUnwrapPlans(cnInTvCalls, sourceText) {
|
|
9
9
|
return cnInTvCalls
|
|
10
10
|
.map((call) => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { BUCKET_ORDER, MAX_GROUPS_BASE, MAX_GROUPS_CAP, MAX_GROUPS_HEADROOM, MIN_GROUP_TOKENS, } from "
|
|
2
|
-
import { stripVariants, tokenizeClassString } from "
|
|
3
|
-
import { bucketsCompatible, bucketsMergeCompatible, classifyToken, compositeSecondaryOrder, selectorKey, stateKey, } from "
|
|
1
|
+
import { BUCKET_ORDER, MAX_GROUPS_BASE, MAX_GROUPS_CAP, MAX_GROUPS_HEADROOM, MIN_GROUP_TOKENS, } from "#arrange/domain/constants";
|
|
2
|
+
import { stripVariants, tokenizeClassString } from "#arrange/domain/tailwind-token";
|
|
3
|
+
import { bucketsCompatible, bucketsMergeCompatible, classifyToken, compositeSecondaryOrder, selectorKey, stateKey, } from "#arrange/domain/token-classifier";
|
|
4
4
|
/**
|
|
5
5
|
* `cn()` grouping: bucket sequence is {@link BUCKET_ORDER} only; tokens are classified with
|
|
6
6
|
* {@link classifyToken}. Comparators here (`compareClassifiedTailwindTokensForCnGrouping`, …)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { DomainSourceFile } from "
|
|
1
|
+
import type { DomainSourceFile } from "#arrange/domain/ast/ast-node";
|
|
2
2
|
/**
|
|
3
3
|
* After simplify rewrites, drop the `cn` import specifier when `cn` is no
|
|
4
4
|
* longer referenced anywhere outside the import declarations.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { forEachDomainChild, isDomainIdentifier, isDomainImportDeclaration, isDomainNamedImports, isDomainStringLiteral, } from "
|
|
2
|
-
import { endAfterOptionalCommaFollowingInSource } from "
|
|
1
|
+
import { forEachDomainChild, isDomainIdentifier, isDomainImportDeclaration, isDomainNamedImports, isDomainStringLiteral, } from "#arrange/domain/ast/ast-node";
|
|
2
|
+
import { endAfterOptionalCommaFollowingInSource } from "#core/source-text-edit";
|
|
3
3
|
function sourceFileImportsCn(sourceFile) {
|
|
4
4
|
for (const statement of sourceFile.statements) {
|
|
5
5
|
if (!isDomainImportDeclaration(statement) || !statement.importClause) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { COMPATIBLE_BUCKET_SETS, RESPONSIVE_PREFIX, STATE_PREFIXES } from "
|
|
2
|
-
import { indexOfFirstVariantColon, stripVariants } from "
|
|
1
|
+
import { COMPATIBLE_BUCKET_SETS, RESPONSIVE_PREFIX, STATE_PREFIXES } from "#arrange/domain/constants";
|
|
2
|
+
import { indexOfFirstVariantColon, stripVariants } from "#arrange/domain/tailwind-token";
|
|
3
3
|
/**
|
|
4
4
|
* Bare-token classification is **total** (always returns a {@link Bucket}). The `Result` pattern
|
|
5
5
|
* (`isOk` / `isErr`) belongs at arrange use-case / I/O boundaries, not on this hot path.
|
|
@@ -7,9 +7,9 @@
|
|
|
7
7
|
*
|
|
8
8
|
* `arbitrary` and `other` are non-pipeline tails for `[prop:value]` syntax and unknown utilities.
|
|
9
9
|
*/
|
|
10
|
-
import type { DomainAstNode, DomainCallExpression, DomainSourceFile, DomainTailwindClassLiteral } from "
|
|
11
|
-
import type { GroupFileWorkPlan } from "
|
|
12
|
-
import type { CodefastConfig } from "
|
|
10
|
+
import type { DomainAstNode, DomainCallExpression, DomainSourceFile, DomainTailwindClassLiteral } from "#arrange/domain/ast/ast-node";
|
|
11
|
+
import type { GroupFileWorkPlan } from "#arrange/domain/grouping-service";
|
|
12
|
+
import type { CodefastConfig } from "#core/config/schema";
|
|
13
13
|
/**
|
|
14
14
|
* The render-pipeline bucket a Tailwind token classifies into.
|
|
15
15
|
*
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { ArrangeSuggestGroupsOutput } from "
|
|
2
|
-
import type { ArrangeSuggestGroupsRequest } from "
|
|
1
|
+
import type { ArrangeSuggestGroupsOutput } from "#arrange/domain/types";
|
|
2
|
+
import type { ArrangeSuggestGroupsRequest } from "#arrange/group/cli-schema";
|
|
3
3
|
/**
|
|
4
4
|
* Formats the suggested grouping for an inline class string as `arrange group` output lines.
|
|
5
5
|
*
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { suggestCnGroups, summarizeGroupBucketLabels } from "
|
|
2
|
-
import { formatArray, formatCnCall } from "
|
|
1
|
+
import { suggestCnGroups, summarizeGroupBucketLabels } from "#arrange/domain/grouping";
|
|
2
|
+
import { formatArray, formatCnCall } from "#arrange/domain/source-text-formatters";
|
|
3
3
|
/**
|
|
4
4
|
* Formats the suggested grouping for an inline class string as `arrange group` output lines.
|
|
5
5
|
*
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
* Rich domain: Tailwind/cn/tv analysis rules (counts, long literals, nested cn in tv).
|
|
3
3
|
* Pure orchestration of domain collectors and invariants — no I/O.
|
|
4
4
|
*/
|
|
5
|
-
import type { DomainSourceFile } from "
|
|
6
|
-
import type { AnalyzeReport } from "
|
|
5
|
+
import type { DomainSourceFile } from "#arrange/domain/ast/ast-node";
|
|
6
|
+
import type { AnalyzeReport } from "#arrange/domain/types";
|
|
7
7
|
/**
|
|
8
8
|
* Creates a zeroed analyze report ready for accumulation.
|
|
9
9
|
*
|
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
* Rich domain: Tailwind/cn/tv analysis rules (counts, long literals, nested cn in tv).
|
|
3
3
|
* Pure orchestration of domain collectors and invariants — no I/O.
|
|
4
4
|
*/
|
|
5
|
-
import { isDomainCallExpression, isDomainJsxAttribute, isDomainObjectLiteralExpression, forEachDomainChild, } from "
|
|
6
|
-
import { forEachStringLiteralInClassExpression } from "
|
|
7
|
-
import { jsxClassNameStaticLiteral } from "
|
|
8
|
-
import { collectCnCallsInsideTv, traverseTvObject } from "
|
|
9
|
-
import { buildKnownCnTvBindings, isCnOrTvIdentifier, lineOf } from "
|
|
10
|
-
import { LONG_STRING_TOKEN_THRESHOLD } from "
|
|
11
|
-
import { tokenizeClassString } from "
|
|
5
|
+
import { isDomainCallExpression, isDomainJsxAttribute, isDomainObjectLiteralExpression, forEachDomainChild, } from "#arrange/domain/ast/ast-node";
|
|
6
|
+
import { forEachStringLiteralInClassExpression } from "#arrange/domain/ast/collectors-cn";
|
|
7
|
+
import { jsxClassNameStaticLiteral } from "#arrange/domain/ast/collectors-jsx";
|
|
8
|
+
import { collectCnCallsInsideTv, traverseTvObject } from "#arrange/domain/ast/collectors-tv";
|
|
9
|
+
import { buildKnownCnTvBindings, isCnOrTvIdentifier, lineOf } from "#arrange/domain/ast/helpers";
|
|
10
|
+
import { LONG_STRING_TOKEN_THRESHOLD } from "#arrange/domain/constants";
|
|
11
|
+
import { tokenizeClassString } from "#arrange/domain/tailwind-token";
|
|
12
12
|
const PREVIEW_MAX_LENGTH = 72;
|
|
13
13
|
function previewText(text) {
|
|
14
14
|
return text.length > PREVIEW_MAX_LENGTH ? `${text.slice(0, PREVIEW_MAX_LENGTH)}…` : text;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
|
-
import { LONG_STRING_TOKEN_THRESHOLD, MAX_REPORT_LINES } from "
|
|
3
|
-
import { logger } from "
|
|
2
|
+
import { LONG_STRING_TOKEN_THRESHOLD, MAX_REPORT_LINES } from "#arrange/domain/constants";
|
|
3
|
+
import { logger } from "#core/logger";
|
|
4
4
|
/**
|
|
5
5
|
* Presents the human-readable summary of an `arrange inspect` report.
|
|
6
6
|
*
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { AnalyzeReport } from "
|
|
2
|
-
import { AppError } from "
|
|
3
|
-
import type { Filesystem } from "
|
|
4
|
-
import type { Result } from "
|
|
1
|
+
import type { AnalyzeReport } from "#arrange/domain/types";
|
|
2
|
+
import { AppError } from "#core/errors";
|
|
3
|
+
import type { Filesystem } from "#core/filesystem/filesystem";
|
|
4
|
+
import type { Result } from "#core/result";
|
|
5
5
|
/**
|
|
6
6
|
* Scans a directory's arrange targets and returns the accumulated analyze report.
|
|
7
7
|
*
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { accumulateAnalyzeReportForSourceFile, createEmptyAnalyzeReport, } from "
|
|
2
|
-
import { scanArrangeTargets } from "
|
|
3
|
-
import { parseDomainSourceFile } from "
|
|
4
|
-
import { AppError } from "
|
|
5
|
-
import { messageFrom } from "
|
|
6
|
-
import { err, ok } from "
|
|
1
|
+
import { accumulateAnalyzeReportForSourceFile, createEmptyAnalyzeReport, } from "#arrange/inspect/domain/analyze-service";
|
|
2
|
+
import { scanArrangeTargets } from "#arrange/scan-target";
|
|
3
|
+
import { parseDomainSourceFile } from "#arrange/source-parse";
|
|
4
|
+
import { AppError } from "#core/errors";
|
|
5
|
+
import { messageFrom } from "#core/errors";
|
|
6
|
+
import { err, ok } from "#core/result";
|
|
7
7
|
/**
|
|
8
8
|
* Scans a directory's arrange targets and returns the accumulated analyze report.
|
|
9
9
|
*
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { ArrangeTargetWorkspaceAndConfig } from "
|
|
2
|
-
import { AppError } from "
|
|
3
|
-
import type { Filesystem } from "
|
|
4
|
-
import type { Result } from "
|
|
1
|
+
import type { ArrangeTargetWorkspaceAndConfig } from "#arrange/domain/types";
|
|
2
|
+
import { AppError } from "#core/errors";
|
|
3
|
+
import type { Filesystem } from "#core/filesystem/filesystem";
|
|
4
|
+
import type { Result } from "#core/result";
|
|
5
5
|
/**
|
|
6
6
|
* Resolves the arrange target, repo root, and loaded config an arrange run needs.
|
|
7
7
|
*
|
package/dist/arrange/prepare.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { resolveArrangeTargetPath } from "
|
|
2
|
-
import { resolveProjectRootResult } from "
|
|
3
|
-
import { loadCodefastConfig } from "
|
|
4
|
-
import { AppError } from "
|
|
5
|
-
import { err, ok } from "
|
|
1
|
+
import { resolveArrangeTargetPath } from "#arrange/resolve-target";
|
|
2
|
+
import { resolveProjectRootResult } from "#core/cli/resolve-root";
|
|
3
|
+
import { loadCodefastConfig } from "#core/config";
|
|
4
|
+
import { AppError } from "#core/errors";
|
|
5
|
+
import { err, ok } from "#core/result";
|
|
6
6
|
/**
|
|
7
7
|
* Resolves the arrange target, repo root, and loaded config an arrange run needs.
|
|
8
8
|
*
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { GroupFileWorkPlan } from "
|
|
2
|
-
import type { ArrangeRunResult } from "
|
|
1
|
+
import type { GroupFileWorkPlan } from "#arrange/domain/grouping-service";
|
|
2
|
+
import type { ArrangeRunResult } from "#arrange/domain/types";
|
|
3
3
|
/**
|
|
4
4
|
* Presents the totals and follow-up hints for an `arrange` run.
|
|
5
5
|
*
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { lineOf } from "
|
|
2
|
-
import { logger } from "
|
|
1
|
+
import { lineOf } from "#arrange/domain/ast/helpers";
|
|
2
|
+
import { logger } from "#core/logger";
|
|
3
3
|
/**
|
|
4
4
|
* Presents the totals and follow-up hints for an `arrange` run.
|
|
5
5
|
*
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { ArrangeGroupFileOptions, GroupFileResult } from "
|
|
2
|
-
import type { Filesystem } from "
|
|
1
|
+
import type { ArrangeGroupFileOptions, GroupFileResult } from "#arrange/domain/types";
|
|
2
|
+
import type { Filesystem } from "#core/filesystem/filesystem";
|
|
3
3
|
/**
|
|
4
4
|
* Runs the grouping pipeline on one file — preview or write — and returns its per-file result.
|
|
5
5
|
*
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { buildGroupFileUnwrapState, countPersistedGroupFileEdits, groupFileDryRunNoEdits, groupFileEditsTouchJsxCn, groupFilePreviewTotals, groupFileWorkHasNothingToReport, mergeGroupFileBodyText, tryBuildGroupFileWorkPlan, } from "
|
|
2
|
-
import { ensureCnImport } from "
|
|
3
|
-
import { parseDomainSourceFile } from "
|
|
1
|
+
import { buildGroupFileUnwrapState, countPersistedGroupFileEdits, groupFileDryRunNoEdits, groupFileEditsTouchJsxCn, groupFilePreviewTotals, groupFileWorkHasNothingToReport, mergeGroupFileBodyText, tryBuildGroupFileWorkPlan, } from "#arrange/domain/grouping-service";
|
|
2
|
+
import { ensureCnImport } from "#arrange/domain/imports";
|
|
3
|
+
import { parseDomainSourceFile } from "#arrange/source-parse";
|
|
4
4
|
/**
|
|
5
5
|
* Runs the grouping pipeline on one file — preview or write — and returns its per-file result.
|
|
6
6
|
*
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type { ArrangeRunResult } from "
|
|
2
|
-
import type { ArrangeRunRequest } from "
|
|
3
|
-
import type { AppError } from "
|
|
4
|
-
import type { Filesystem } from "
|
|
5
|
-
import type { Result } from "
|
|
1
|
+
import type { ArrangeRunResult } from "#arrange/domain/types";
|
|
2
|
+
import type { ArrangeRunRequest } from "#arrange/regroup/cli-schema";
|
|
3
|
+
import type { AppError } from "#core/errors";
|
|
4
|
+
import type { Filesystem } from "#core/filesystem/filesystem";
|
|
5
|
+
import type { Result } from "#core/result";
|
|
6
6
|
/**
|
|
7
7
|
* Runs the grouping pipeline over every target file and returns the aggregated result.
|
|
8
8
|
*
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { processArrangeGroupFile } from "
|
|
2
|
-
import { scanArrangeTargets } from "
|
|
3
|
-
import { messageFrom } from "
|
|
4
|
-
import { ok } from "
|
|
1
|
+
import { processArrangeGroupFile } from "#arrange/regroup/process-file";
|
|
2
|
+
import { scanArrangeTargets } from "#arrange/scan-target";
|
|
3
|
+
import { messageFrom } from "#core/errors";
|
|
4
|
+
import { ok } from "#core/result";
|
|
5
5
|
async function runOnAfterWriteHook(hook, modifiedFiles) {
|
|
6
6
|
if (!hook || modifiedFiles.length === 0) {
|
|
7
7
|
return null;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
|
-
import { findNearestAncestor } from "
|
|
3
|
-
import { packageJsonFileName } from "
|
|
2
|
+
import { findNearestAncestor } from "#core/workspace/ancestor-directories";
|
|
3
|
+
import { packageJsonFileName } from "#core/workspace/well-known-files";
|
|
4
4
|
/**
|
|
5
5
|
* Resolves the arrange target to a canonical path, defaulting to the nearest package directory.
|
|
6
6
|
*
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
|
-
import { messageFrom } from "
|
|
3
|
-
import { logger } from "
|
|
4
|
-
import { walkTsxFiles } from "
|
|
2
|
+
import { messageFrom } from "#core/errors";
|
|
3
|
+
import { logger } from "#core/logger";
|
|
4
|
+
import { walkTsxFiles } from "#core/workspace/typescript-walk";
|
|
5
5
|
const TEST_FILE_PATTERN = /\.(?:test|spec)\.[cm]?[jt]sx?$/;
|
|
6
6
|
/**
|
|
7
7
|
* Test/spec files are excluded from directory scans: arrange rewrites class strings,
|