@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/command.js
CHANGED
|
@@ -1,18 +1,96 @@
|
|
|
1
|
-
import process from "node:process";
|
|
2
1
|
import { Command } from "commander";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
2
|
+
import { formatArrangeGroupJsonOutput } from "#/arrange/group/cli-result";
|
|
3
|
+
import { arrangeSuggestGroupsRequestSchema } from "#/arrange/group/cli-schema";
|
|
4
|
+
import { presentArrangeGroupResult } from "#/arrange/group/output";
|
|
5
|
+
import { suggestCnGroupsFromCli } from "#/arrange/group/suggest";
|
|
6
|
+
import { formatArrangeAnalyzeJsonOutput } from "#/arrange/inspect/cli-result";
|
|
7
|
+
import { arrangeAnalyzeDirectoryRequestSchema } from "#/arrange/inspect/cli-schema";
|
|
8
|
+
import { presentAnalyzeReport } from "#/arrange/inspect/output";
|
|
9
|
+
import { runArrangeInspect } from "#/arrange/inspect/run";
|
|
10
|
+
import { prepareArrangeWorkspace } from "#/arrange/prepare";
|
|
11
|
+
import { exitCodeForArrangeResult, formatArrangeJsonOutput } from "#/arrange/regroup/cli-result";
|
|
12
|
+
import { arrangeRunRequestSchema } from "#/arrange/regroup/cli-schema";
|
|
13
|
+
import { presentArrangeResult, presentGroupFilePreviewFromWork } from "#/arrange/regroup/output";
|
|
14
|
+
import { runArrange } from "#/arrange/regroup/run";
|
|
15
|
+
import { formatArrangeSimplifyJsonOutput } from "#/arrange/simplify/cli-result";
|
|
16
|
+
import { arrangeSimplifyRunRequestSchema } from "#/arrange/simplify/cli-schema";
|
|
17
|
+
import { presentSimplifyResult } from "#/arrange/simplify/output";
|
|
18
|
+
import { runArrangeSimplify } from "#/arrange/simplify/run";
|
|
19
|
+
import { applyCommandPipeline, registerPipelineSubcommand } from "#/core/cli/command-pipeline";
|
|
20
|
+
import { consumeCliAppError } from "#/core/cli/result-handle";
|
|
21
|
+
import { CLI_EXIT_SUCCESS } from "#/core/exit-codes";
|
|
13
22
|
import { nodeFilesystem } from "#/core/filesystem/node";
|
|
14
23
|
import { logger } from "#/core/logger";
|
|
15
24
|
import { parseWithSchema } from "#/core/schema-parse";
|
|
25
|
+
const targetHelp = "Directory or file (default: nearest package directory from cwd)";
|
|
26
|
+
const prepareWorkspace = (fs, input) => prepareArrangeWorkspace(fs, { currentWorkingDirectory: input.currentWorkingDirectory, rawTarget: input.rawArg });
|
|
27
|
+
const regroupPipeline = {
|
|
28
|
+
positional: { name: "[target]", help: targetHelp },
|
|
29
|
+
schema: arrangeRunRequestSchema,
|
|
30
|
+
configureArgv: (command) => {
|
|
31
|
+
command.option("--dry-run", "Preview suggested replacements without writing files", false);
|
|
32
|
+
command.option("--with-classname, --with-class-name", "Append className as final cn() argument", false);
|
|
33
|
+
command.option("--cn-import <spec>", "Override module specifier when adding cn import");
|
|
34
|
+
},
|
|
35
|
+
prepare: prepareWorkspace,
|
|
36
|
+
buildRequest: ({ prelude, opts }) => ({
|
|
37
|
+
rootDir: prelude.rootDir,
|
|
38
|
+
targetPath: prelude.resolvedTarget,
|
|
39
|
+
write: !opts.dryRun,
|
|
40
|
+
withClassName: opts.withClassName,
|
|
41
|
+
cnImport: opts.cnImport,
|
|
42
|
+
config: prelude.config.arrange ?? {},
|
|
43
|
+
}),
|
|
44
|
+
run: (fs, request) => runArrange(fs, request),
|
|
45
|
+
presentHuman: ({ result, opts }) => {
|
|
46
|
+
// Dry-run previews are human-only; the --json summary omits the non-serializable plans.
|
|
47
|
+
if (opts.dryRun) {
|
|
48
|
+
for (const plan of result.previewPlans) {
|
|
49
|
+
presentGroupFilePreviewFromWork(plan);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
presentArrangeResult(result, !opts.dryRun);
|
|
53
|
+
},
|
|
54
|
+
formatJson: ({ result, opts }) => formatArrangeJsonOutput(result, !opts.dryRun),
|
|
55
|
+
exitCode: exitCodeForArrangeResult,
|
|
56
|
+
};
|
|
57
|
+
const inspectPipeline = {
|
|
58
|
+
name: "inspect",
|
|
59
|
+
description: "Report long strings, nested cn in tv(), and related findings (read-only)",
|
|
60
|
+
positional: { name: "[target]", help: targetHelp },
|
|
61
|
+
jsonHelp: "Print one JSON object on stdout instead of a human report",
|
|
62
|
+
schema: arrangeAnalyzeDirectoryRequestSchema,
|
|
63
|
+
prepare: prepareWorkspace,
|
|
64
|
+
buildRequest: ({ prelude }) => ({ analyzeRootPath: prelude.resolvedTarget }),
|
|
65
|
+
run: async (fs, request) => runArrangeInspect(fs, request.analyzeRootPath),
|
|
66
|
+
presentHuman: ({ result, prelude }) => {
|
|
67
|
+
presentAnalyzeReport(prelude.resolvedTarget, result);
|
|
68
|
+
},
|
|
69
|
+
formatJson: ({ result, prelude }) => formatArrangeAnalyzeJsonOutput(prelude.resolvedTarget, result),
|
|
70
|
+
exitCode: () => CLI_EXIT_SUCCESS,
|
|
71
|
+
};
|
|
72
|
+
const simplifyPipeline = {
|
|
73
|
+
name: "simplify",
|
|
74
|
+
description: "Flatten grouped arrays and static-only cn() calls back to plain strings in tv() slots",
|
|
75
|
+
positional: { name: "[target]", help: targetHelp },
|
|
76
|
+
schema: arrangeSimplifyRunRequestSchema,
|
|
77
|
+
configureArgv: (command) => {
|
|
78
|
+
command.option("--dry-run", "Show what simplify would change without writing files", false);
|
|
79
|
+
command.option("--fold-variant-classname, --fold-variant-class-name", "Fold cn() overrides into a variant function's className option (uses the TypeScript type server)", false);
|
|
80
|
+
},
|
|
81
|
+
prepare: prepareWorkspace,
|
|
82
|
+
buildRequest: ({ prelude, opts }) => ({
|
|
83
|
+
targetPath: prelude.resolvedTarget,
|
|
84
|
+
write: !opts.dryRun,
|
|
85
|
+
foldVariantClassName: opts.foldVariantClassName,
|
|
86
|
+
}),
|
|
87
|
+
run: (fs, request) => runArrangeSimplify(fs, request),
|
|
88
|
+
presentHuman: ({ result, opts }) => {
|
|
89
|
+
presentSimplifyResult(result, !opts.dryRun);
|
|
90
|
+
},
|
|
91
|
+
formatJson: ({ result, opts }) => formatArrangeSimplifyJsonOutput(result, !opts.dryRun),
|
|
92
|
+
exitCode: () => CLI_EXIT_SUCCESS,
|
|
93
|
+
};
|
|
16
94
|
/**
|
|
17
95
|
* Creates the `arrange` command and its subcommands.
|
|
18
96
|
*
|
|
@@ -23,103 +101,12 @@ export function createArrangeCommand() {
|
|
|
23
101
|
.description("Regroup Tailwind classes in cn() / tv() calls in render-pipeline order")
|
|
24
102
|
// The parent action shares option names (--json) with subcommands; positional
|
|
25
103
|
// options ensure tokens after a subcommand bind to that subcommand, not the parent.
|
|
26
|
-
.enablePositionalOptions()
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
.action(async (target, opts) => {
|
|
33
|
-
const write = !opts.dryRun;
|
|
34
|
-
const prelude = await prepareArrangeWorkspace(nodeFilesystem, {
|
|
35
|
-
currentWorkingDirectory: process.cwd(),
|
|
36
|
-
rawTarget: readOptionalPositionalArg(target),
|
|
37
|
-
});
|
|
38
|
-
if (!consumeCliAppError(prelude)) {
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
|
-
const { resolvedTarget, rootDir, config } = prelude.value;
|
|
42
|
-
const parsed = parseWithSchema(arrangeSyncRunRequestSchema, {
|
|
43
|
-
rootDir,
|
|
44
|
-
targetPath: resolvedTarget,
|
|
45
|
-
write,
|
|
46
|
-
withClassName: opts.withClassName,
|
|
47
|
-
cnImport: opts.cnImport,
|
|
48
|
-
config: config.arrange ?? {},
|
|
49
|
-
});
|
|
50
|
-
if (!consumeCliAppError(parsed)) {
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
|
-
await runCliResultAsync(runArrangeSync(nodeFilesystem, parsed.value), (value) => {
|
|
54
|
-
if (!write) {
|
|
55
|
-
for (const plan of value.previewPlans) {
|
|
56
|
-
printGroupFilePreviewFromWork(plan);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
if (opts.json) {
|
|
60
|
-
logger.out(formatArrangeSyncJsonOutput(value, write));
|
|
61
|
-
return exitCodeForArrangeSyncResult(value);
|
|
62
|
-
}
|
|
63
|
-
printSyncResult(value, write);
|
|
64
|
-
return exitCodeForArrangeSyncResult(value);
|
|
65
|
-
});
|
|
66
|
-
});
|
|
67
|
-
cmd
|
|
68
|
-
.command("inspect")
|
|
69
|
-
.description("Report long strings, nested cn in tv(), and related findings (read-only)")
|
|
70
|
-
.argument("[target]", "Directory or file (default: nearest package directory from cwd)")
|
|
71
|
-
.option("--json", "Print one JSON object on stdout instead of a human report", false)
|
|
72
|
-
.action(async (target, opts) => {
|
|
73
|
-
const prelude = await prepareArrangeWorkspace(nodeFilesystem, {
|
|
74
|
-
currentWorkingDirectory: process.cwd(),
|
|
75
|
-
rawTarget: readOptionalPositionalArg(target),
|
|
76
|
-
});
|
|
77
|
-
if (!consumeCliAppError(prelude)) {
|
|
78
|
-
return;
|
|
79
|
-
}
|
|
80
|
-
const { resolvedTarget } = prelude.value;
|
|
81
|
-
const parsed = parseWithSchema(arrangeAnalyzeDirectoryRequestSchema, {
|
|
82
|
-
analyzeRootPath: resolvedTarget,
|
|
83
|
-
});
|
|
84
|
-
if (!consumeCliAppError(parsed)) {
|
|
85
|
-
return;
|
|
86
|
-
}
|
|
87
|
-
const outcome = analyzeDirectory(nodeFilesystem, parsed.value.analyzeRootPath);
|
|
88
|
-
if (!consumeCliAppError(outcome)) {
|
|
89
|
-
return;
|
|
90
|
-
}
|
|
91
|
-
if (opts.json) {
|
|
92
|
-
logger.out(formatArrangeAnalyzeJsonOutput(resolvedTarget, outcome.value));
|
|
93
|
-
}
|
|
94
|
-
else {
|
|
95
|
-
printAnalyzeReport(resolvedTarget, outcome.value);
|
|
96
|
-
}
|
|
97
|
-
});
|
|
98
|
-
cmd
|
|
99
|
-
.command("simplify")
|
|
100
|
-
.description("Flatten grouped arrays and static-only cn() calls back to plain strings in tv() slots")
|
|
101
|
-
.argument("[target]", "Directory or file (default: nearest package directory from cwd)")
|
|
102
|
-
.option("--dry-run", "Show what simplify would change without writing files", false)
|
|
103
|
-
.option("--json", "Print one JSON object on stdout (suppresses human progress)", false)
|
|
104
|
-
.action(async (target, opts) => {
|
|
105
|
-
const write = !opts.dryRun;
|
|
106
|
-
const prelude = await prepareArrangeWorkspace(nodeFilesystem, {
|
|
107
|
-
currentWorkingDirectory: process.cwd(),
|
|
108
|
-
rawTarget: readOptionalPositionalArg(target),
|
|
109
|
-
});
|
|
110
|
-
if (!consumeCliAppError(prelude)) {
|
|
111
|
-
return;
|
|
112
|
-
}
|
|
113
|
-
const { resolvedTarget } = prelude.value;
|
|
114
|
-
await runCliResultAsync(runArrangeSimplify(nodeFilesystem, { targetPath: resolvedTarget, write }), (value) => {
|
|
115
|
-
if (opts.json) {
|
|
116
|
-
logger.out(JSON.stringify({ schemaVersion: 1, ok: true, write, result: value }));
|
|
117
|
-
return CLI_EXIT_SUCCESS;
|
|
118
|
-
}
|
|
119
|
-
printSimplifyResult(value, write);
|
|
120
|
-
return CLI_EXIT_SUCCESS;
|
|
121
|
-
});
|
|
122
|
-
});
|
|
104
|
+
.enablePositionalOptions();
|
|
105
|
+
applyCommandPipeline(cmd, nodeFilesystem, regroupPipeline);
|
|
106
|
+
registerPipelineSubcommand(cmd, nodeFilesystem, inspectPipeline);
|
|
107
|
+
registerPipelineSubcommand(cmd, nodeFilesystem, simplifyPipeline);
|
|
108
|
+
// `group` is a pure token-string transform — no workspace prelude, a variadic positional — so it
|
|
109
|
+
// does not fit the workspace pipeline and stays wired by hand.
|
|
123
110
|
cmd
|
|
124
111
|
.command("group")
|
|
125
112
|
.description("Try grouping on a pasted class string (stdout: cn(...) or tv array with --tv)")
|
|
@@ -141,31 +128,8 @@ export function createArrangeCommand() {
|
|
|
141
128
|
logger.out(formatArrangeGroupJsonOutput(output));
|
|
142
129
|
}
|
|
143
130
|
else {
|
|
144
|
-
|
|
145
|
-
logger.out(output.bucketsCommentLine);
|
|
131
|
+
presentArrangeGroupResult(output);
|
|
146
132
|
}
|
|
147
133
|
});
|
|
148
134
|
return cmd;
|
|
149
|
-
}
|
|
150
|
-
function formatArrangeAnalyzeJsonOutput(analyzeRootPath, report) {
|
|
151
|
-
return JSON.stringify({ schemaVersion: 1, analyzeRootPath, report });
|
|
152
|
-
}
|
|
153
|
-
function formatArrangeSyncJsonOutput(result, write) {
|
|
154
|
-
const { previewPlans: _plans, ...serializableResult } = result;
|
|
155
|
-
return JSON.stringify({
|
|
156
|
-
schemaVersion: 1,
|
|
157
|
-
ok: result.hookError === null,
|
|
158
|
-
write,
|
|
159
|
-
result: serializableResult,
|
|
160
|
-
});
|
|
161
|
-
}
|
|
162
|
-
function formatArrangeGroupJsonOutput(output) {
|
|
163
|
-
return JSON.stringify({
|
|
164
|
-
schemaVersion: 1,
|
|
165
|
-
primaryLine: output.primaryLine,
|
|
166
|
-
bucketsCommentLine: output.bucketsCommentLine,
|
|
167
|
-
});
|
|
168
|
-
}
|
|
169
|
-
function exitCodeForArrangeSyncResult(result) {
|
|
170
|
-
return result.hookError !== null ? CLI_EXIT_GENERAL_ERROR : CLI_EXIT_SUCCESS;
|
|
171
135
|
}
|
|
@@ -0,0 +1,394 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure-domain AST shapes for arrange analysis. No TypeScript compiler types.
|
|
3
|
+
* Positions mirror `getStart(sourceFile)` / `getEnd()` semantics from translation.
|
|
4
|
+
*
|
|
5
|
+
* @since 0.3.16-canary.0
|
|
6
|
+
*/
|
|
7
|
+
export declare enum DomainSyntaxKind {
|
|
8
|
+
Unknown = 1,
|
|
9
|
+
Identifier = 2,
|
|
10
|
+
StringLiteral = 3,
|
|
11
|
+
NoSubstitutionTemplateLiteral = 4,
|
|
12
|
+
ImportDeclaration = 5,
|
|
13
|
+
ImportClause = 6,
|
|
14
|
+
NamedImports = 7,
|
|
15
|
+
NamespaceImport = 8,
|
|
16
|
+
ImportSpecifier = 9,
|
|
17
|
+
CallExpression = 10,
|
|
18
|
+
PropertyAccessExpression = 11,
|
|
19
|
+
ObjectLiteralExpression = 12,
|
|
20
|
+
PropertyAssignment = 13,
|
|
21
|
+
ArrayLiteralExpression = 14,
|
|
22
|
+
SpreadElement = 15,
|
|
23
|
+
ParenthesizedExpression = 16,
|
|
24
|
+
AsExpression = 17,
|
|
25
|
+
SatisfiesExpression = 18,
|
|
26
|
+
NonNullExpression = 19,
|
|
27
|
+
ConditionalExpression = 20,
|
|
28
|
+
BinaryExpression = 21,
|
|
29
|
+
ExpressionStatement = 22,
|
|
30
|
+
JsxAttribute = 23,
|
|
31
|
+
JsxExpression = 24
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* The binary operators the domain AST distinguishes.
|
|
35
|
+
*
|
|
36
|
+
* @since 0.3.16-canary.0
|
|
37
|
+
*/
|
|
38
|
+
export declare enum DomainBinaryOperator {
|
|
39
|
+
Plus = 0,
|
|
40
|
+
Other = 1
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* The pure-domain counterpart of a parsed source file.
|
|
44
|
+
*
|
|
45
|
+
* @since 0.3.16-canary.0
|
|
46
|
+
*/
|
|
47
|
+
export interface DomainSourceFile {
|
|
48
|
+
readonly fileName: string;
|
|
49
|
+
readonly text: string;
|
|
50
|
+
readonly statements: ReadonlyArray<DomainAstNode>;
|
|
51
|
+
}
|
|
52
|
+
interface DomainNodeBase {
|
|
53
|
+
readonly kind: DomainSyntaxKind;
|
|
54
|
+
readonly pos: number;
|
|
55
|
+
readonly end: number;
|
|
56
|
+
readonly parent: DomainAstNode | null;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* A node kind the translator does not model, retained only for its children.
|
|
60
|
+
*
|
|
61
|
+
* @since 0.3.16-canary.0
|
|
62
|
+
*/
|
|
63
|
+
export interface DomainUnknownAstNode extends DomainNodeBase {
|
|
64
|
+
readonly kind: DomainSyntaxKind.Unknown;
|
|
65
|
+
readonly children: ReadonlyArray<DomainAstNode>;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* An identifier node.
|
|
69
|
+
*
|
|
70
|
+
* @since 0.3.16-canary.0
|
|
71
|
+
*/
|
|
72
|
+
export interface DomainIdentifier extends DomainNodeBase {
|
|
73
|
+
readonly kind: DomainSyntaxKind.Identifier;
|
|
74
|
+
readonly text: string;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* A string literal node.
|
|
78
|
+
*
|
|
79
|
+
* @since 0.3.16-canary.0
|
|
80
|
+
*/
|
|
81
|
+
export interface DomainStringLiteral extends DomainNodeBase {
|
|
82
|
+
readonly kind: DomainSyntaxKind.StringLiteral;
|
|
83
|
+
readonly text: string;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* A template literal without substitutions.
|
|
87
|
+
*
|
|
88
|
+
* @since 0.3.16-canary.0
|
|
89
|
+
*/
|
|
90
|
+
export interface DomainNoSubstitutionTemplateLiteral extends DomainNodeBase {
|
|
91
|
+
readonly kind: DomainSyntaxKind.NoSubstitutionTemplateLiteral;
|
|
92
|
+
readonly text: string;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* An `import` declaration node.
|
|
96
|
+
*
|
|
97
|
+
* @since 0.3.16-canary.0
|
|
98
|
+
*/
|
|
99
|
+
export interface DomainImportDeclaration extends DomainNodeBase {
|
|
100
|
+
readonly kind: DomainSyntaxKind.ImportDeclaration;
|
|
101
|
+
readonly importClause: DomainImportClause | undefined;
|
|
102
|
+
readonly moduleSpecifier: DomainAstNode;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* The clause of an import declaration — default name plus named or namespace bindings.
|
|
106
|
+
*
|
|
107
|
+
* @since 0.3.16-canary.0
|
|
108
|
+
*/
|
|
109
|
+
export interface DomainImportClause extends DomainNodeBase {
|
|
110
|
+
readonly kind: DomainSyntaxKind.ImportClause;
|
|
111
|
+
readonly isTypeOnly: boolean;
|
|
112
|
+
readonly name: DomainIdentifier | undefined;
|
|
113
|
+
readonly namedBindings: DomainNamedImports | DomainNamespaceImport | undefined;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* The named-bindings list of an import clause.
|
|
117
|
+
*
|
|
118
|
+
* @since 0.3.16-canary.0
|
|
119
|
+
*/
|
|
120
|
+
export interface DomainNamedImports extends DomainNodeBase {
|
|
121
|
+
readonly kind: DomainSyntaxKind.NamedImports;
|
|
122
|
+
readonly elements: ReadonlyArray<DomainImportSpecifier>;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* A namespace (`* as name`) import binding.
|
|
126
|
+
*
|
|
127
|
+
* @since 0.3.16-canary.0
|
|
128
|
+
*/
|
|
129
|
+
export interface DomainNamespaceImport extends DomainNodeBase {
|
|
130
|
+
readonly kind: DomainSyntaxKind.NamespaceImport;
|
|
131
|
+
readonly name: DomainIdentifier;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* A single named-import specifier.
|
|
135
|
+
*
|
|
136
|
+
* @since 0.3.16-canary.0
|
|
137
|
+
*/
|
|
138
|
+
export interface DomainImportSpecifier extends DomainNodeBase {
|
|
139
|
+
readonly kind: DomainSyntaxKind.ImportSpecifier;
|
|
140
|
+
readonly name: DomainIdentifier;
|
|
141
|
+
readonly propertyName: DomainIdentifier | undefined;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* A call expression node.
|
|
145
|
+
*
|
|
146
|
+
* @since 0.3.16-canary.0
|
|
147
|
+
*/
|
|
148
|
+
export interface DomainCallExpression extends DomainNodeBase {
|
|
149
|
+
readonly kind: DomainSyntaxKind.CallExpression;
|
|
150
|
+
readonly expression: DomainAstNode;
|
|
151
|
+
readonly arguments: ReadonlyArray<DomainAstNode>;
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* A property access (`object.name`) node.
|
|
155
|
+
*
|
|
156
|
+
* @since 0.3.16-canary.0
|
|
157
|
+
*/
|
|
158
|
+
export interface DomainPropertyAccessExpression extends DomainNodeBase {
|
|
159
|
+
readonly kind: DomainSyntaxKind.PropertyAccessExpression;
|
|
160
|
+
readonly expression: DomainAstNode;
|
|
161
|
+
readonly name: DomainIdentifier;
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* An object literal node.
|
|
165
|
+
*
|
|
166
|
+
* @since 0.3.16-canary.0
|
|
167
|
+
*/
|
|
168
|
+
export interface DomainObjectLiteralExpression extends DomainNodeBase {
|
|
169
|
+
readonly kind: DomainSyntaxKind.ObjectLiteralExpression;
|
|
170
|
+
readonly properties: ReadonlyArray<DomainAstNode>;
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* A `name: value` property inside an object literal.
|
|
174
|
+
*
|
|
175
|
+
* @since 0.3.16-canary.0
|
|
176
|
+
*/
|
|
177
|
+
export interface DomainPropertyAssignment extends DomainNodeBase {
|
|
178
|
+
readonly kind: DomainSyntaxKind.PropertyAssignment;
|
|
179
|
+
readonly name: DomainAstNode;
|
|
180
|
+
readonly initializer: DomainAstNode;
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* An array literal node.
|
|
184
|
+
*
|
|
185
|
+
* @since 0.3.16-canary.0
|
|
186
|
+
*/
|
|
187
|
+
export interface DomainArrayLiteralExpression extends DomainNodeBase {
|
|
188
|
+
readonly kind: DomainSyntaxKind.ArrayLiteralExpression;
|
|
189
|
+
readonly elements: ReadonlyArray<DomainAstNode>;
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* A spread (`...expression`) element node.
|
|
193
|
+
*
|
|
194
|
+
* @since 0.3.16-canary.0
|
|
195
|
+
*/
|
|
196
|
+
export interface DomainSpreadElement extends DomainNodeBase {
|
|
197
|
+
readonly kind: DomainSyntaxKind.SpreadElement;
|
|
198
|
+
readonly expression: DomainAstNode;
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* A parenthesized expression node.
|
|
202
|
+
*
|
|
203
|
+
* @since 0.3.16-canary.0
|
|
204
|
+
*/
|
|
205
|
+
export interface DomainParenthesizedExpression extends DomainNodeBase {
|
|
206
|
+
readonly kind: DomainSyntaxKind.ParenthesizedExpression;
|
|
207
|
+
readonly expression: DomainAstNode;
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* An `as` type-assertion node.
|
|
211
|
+
*
|
|
212
|
+
* @since 0.3.16-canary.0
|
|
213
|
+
*/
|
|
214
|
+
export interface DomainAsExpression extends DomainNodeBase {
|
|
215
|
+
readonly kind: DomainSyntaxKind.AsExpression;
|
|
216
|
+
readonly expression: DomainAstNode;
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* A `satisfies` expression node.
|
|
220
|
+
*
|
|
221
|
+
* @since 0.3.16-canary.0
|
|
222
|
+
*/
|
|
223
|
+
export interface DomainSatisfiesExpression extends DomainNodeBase {
|
|
224
|
+
readonly kind: DomainSyntaxKind.SatisfiesExpression;
|
|
225
|
+
readonly expression: DomainAstNode;
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* A non-null assertion (`expression!`) node.
|
|
229
|
+
*
|
|
230
|
+
* @since 0.3.16-canary.0
|
|
231
|
+
*/
|
|
232
|
+
export interface DomainNonNullExpression extends DomainNodeBase {
|
|
233
|
+
readonly kind: DomainSyntaxKind.NonNullExpression;
|
|
234
|
+
readonly expression: DomainAstNode;
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* A ternary conditional node.
|
|
238
|
+
*
|
|
239
|
+
* @since 0.3.16-canary.0
|
|
240
|
+
*/
|
|
241
|
+
export interface DomainConditionalExpression extends DomainNodeBase {
|
|
242
|
+
readonly kind: DomainSyntaxKind.ConditionalExpression;
|
|
243
|
+
readonly condition: DomainAstNode;
|
|
244
|
+
readonly whenTrue: DomainAstNode;
|
|
245
|
+
readonly whenFalse: DomainAstNode;
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* A binary expression node.
|
|
249
|
+
*
|
|
250
|
+
* @since 0.3.16-canary.0
|
|
251
|
+
*/
|
|
252
|
+
export interface DomainBinaryExpression extends DomainNodeBase {
|
|
253
|
+
readonly kind: DomainSyntaxKind.BinaryExpression;
|
|
254
|
+
readonly left: DomainAstNode;
|
|
255
|
+
readonly operator: DomainBinaryOperator;
|
|
256
|
+
readonly right: DomainAstNode;
|
|
257
|
+
}
|
|
258
|
+
/**
|
|
259
|
+
* An expression statement node.
|
|
260
|
+
*
|
|
261
|
+
* @since 0.3.16-canary.0
|
|
262
|
+
*/
|
|
263
|
+
export interface DomainExpressionStatement extends DomainNodeBase {
|
|
264
|
+
readonly kind: DomainSyntaxKind.ExpressionStatement;
|
|
265
|
+
readonly expression: DomainAstNode;
|
|
266
|
+
}
|
|
267
|
+
/**
|
|
268
|
+
* A JSX attribute node.
|
|
269
|
+
*
|
|
270
|
+
* @since 0.3.16-canary.0
|
|
271
|
+
*/
|
|
272
|
+
export interface DomainJsxAttribute extends DomainNodeBase {
|
|
273
|
+
readonly kind: DomainSyntaxKind.JsxAttribute;
|
|
274
|
+
readonly name: DomainAstNode;
|
|
275
|
+
readonly initializer: DomainAstNode | undefined;
|
|
276
|
+
}
|
|
277
|
+
/**
|
|
278
|
+
* A JSX expression container node.
|
|
279
|
+
*
|
|
280
|
+
* @since 0.3.16-canary.0
|
|
281
|
+
*/
|
|
282
|
+
export interface DomainJsxExpression extends DomainNodeBase {
|
|
283
|
+
readonly kind: DomainSyntaxKind.JsxExpression;
|
|
284
|
+
readonly expression: DomainAstNode | undefined;
|
|
285
|
+
}
|
|
286
|
+
/**
|
|
287
|
+
* The union of every node shape the domain AST models.
|
|
288
|
+
*
|
|
289
|
+
* @since 0.3.16-canary.0
|
|
290
|
+
*/
|
|
291
|
+
export type DomainAstNode = DomainUnknownAstNode | DomainIdentifier | DomainStringLiteral | DomainNoSubstitutionTemplateLiteral | DomainImportDeclaration | DomainImportClause | DomainNamedImports | DomainNamespaceImport | DomainImportSpecifier | DomainCallExpression | DomainPropertyAccessExpression | DomainObjectLiteralExpression | DomainPropertyAssignment | DomainArrayLiteralExpression | DomainSpreadElement | DomainParenthesizedExpression | DomainAsExpression | DomainSatisfiesExpression | DomainNonNullExpression | DomainConditionalExpression | DomainBinaryExpression | DomainExpressionStatement | DomainJsxAttribute | DomainJsxExpression;
|
|
292
|
+
/**
|
|
293
|
+
* A literal node that can carry a Tailwind class string.
|
|
294
|
+
*
|
|
295
|
+
* @since 0.3.16-canary.0
|
|
296
|
+
*/
|
|
297
|
+
export type DomainTailwindClassLiteral = DomainStringLiteral | DomainNoSubstitutionTemplateLiteral;
|
|
298
|
+
/**
|
|
299
|
+
* Narrows a node to `DomainIdentifier`.
|
|
300
|
+
*
|
|
301
|
+
* @since 0.3.16-canary.0
|
|
302
|
+
*/
|
|
303
|
+
export declare function isDomainIdentifier(node: DomainAstNode): node is DomainIdentifier;
|
|
304
|
+
/**
|
|
305
|
+
* Narrows a node to `DomainStringLiteral`.
|
|
306
|
+
*
|
|
307
|
+
* @since 0.3.16-canary.0
|
|
308
|
+
*/
|
|
309
|
+
export declare function isDomainStringLiteral(node: DomainAstNode): node is DomainStringLiteral;
|
|
310
|
+
/**
|
|
311
|
+
* Narrows a node to a literal that can carry Tailwind classes.
|
|
312
|
+
*
|
|
313
|
+
* @since 0.3.16-canary.0
|
|
314
|
+
*/
|
|
315
|
+
export declare function isDomainTailwindClassLiteral(node: DomainAstNode): node is DomainTailwindClassLiteral;
|
|
316
|
+
/**
|
|
317
|
+
* Narrows a node to `DomainImportDeclaration`.
|
|
318
|
+
*
|
|
319
|
+
* @since 0.3.16-canary.0
|
|
320
|
+
*/
|
|
321
|
+
export declare function isDomainImportDeclaration(node: DomainAstNode): node is DomainImportDeclaration;
|
|
322
|
+
/**
|
|
323
|
+
* Narrows a node to `DomainNamedImports`.
|
|
324
|
+
*
|
|
325
|
+
* @since 0.3.16-canary.0
|
|
326
|
+
*/
|
|
327
|
+
export declare function isDomainNamedImports(node: DomainAstNode): node is DomainNamedImports;
|
|
328
|
+
/**
|
|
329
|
+
* Narrows a node to `DomainNamespaceImport`.
|
|
330
|
+
*
|
|
331
|
+
* @since 0.3.16-canary.0
|
|
332
|
+
*/
|
|
333
|
+
export declare function isDomainNamespaceImport(node: DomainAstNode): node is DomainNamespaceImport;
|
|
334
|
+
/**
|
|
335
|
+
* Narrows a node to `DomainCallExpression`.
|
|
336
|
+
*
|
|
337
|
+
* @since 0.3.16-canary.0
|
|
338
|
+
*/
|
|
339
|
+
export declare function isDomainCallExpression(node: DomainAstNode): node is DomainCallExpression;
|
|
340
|
+
/**
|
|
341
|
+
* Narrows a node to `DomainObjectLiteralExpression`.
|
|
342
|
+
*
|
|
343
|
+
* @since 0.3.16-canary.0
|
|
344
|
+
*/
|
|
345
|
+
export declare function isDomainObjectLiteralExpression(node: DomainAstNode): node is DomainObjectLiteralExpression;
|
|
346
|
+
/**
|
|
347
|
+
* Narrows a node to `DomainPropertyAssignment`.
|
|
348
|
+
*
|
|
349
|
+
* @since 0.3.16-canary.0
|
|
350
|
+
*/
|
|
351
|
+
export declare function isDomainPropertyAssignment(node: DomainAstNode): node is DomainPropertyAssignment;
|
|
352
|
+
/**
|
|
353
|
+
* Narrows a node to `DomainArrayLiteralExpression`.
|
|
354
|
+
*
|
|
355
|
+
* @since 0.3.16-canary.0
|
|
356
|
+
*/
|
|
357
|
+
export declare function isDomainArrayLiteralExpression(node: DomainAstNode): node is DomainArrayLiteralExpression;
|
|
358
|
+
/**
|
|
359
|
+
* Narrows a node to `DomainSpreadElement`.
|
|
360
|
+
*
|
|
361
|
+
* @since 0.3.16-canary.0
|
|
362
|
+
*/
|
|
363
|
+
export declare function isDomainSpreadElement(node: DomainAstNode): node is DomainSpreadElement;
|
|
364
|
+
/**
|
|
365
|
+
* Narrows a node to `DomainPropertyAccessExpression`.
|
|
366
|
+
*
|
|
367
|
+
* @since 0.3.16-canary.0
|
|
368
|
+
*/
|
|
369
|
+
export declare function isDomainPropertyAccessExpression(node: DomainAstNode): node is DomainPropertyAccessExpression;
|
|
370
|
+
/**
|
|
371
|
+
* Narrows a node to `DomainJsxAttribute`.
|
|
372
|
+
*
|
|
373
|
+
* @since 0.3.16-canary.0
|
|
374
|
+
*/
|
|
375
|
+
export declare function isDomainJsxAttribute(node: DomainAstNode): node is DomainJsxAttribute;
|
|
376
|
+
/**
|
|
377
|
+
* Narrows a node to `DomainJsxExpression`.
|
|
378
|
+
*
|
|
379
|
+
* @since 0.3.16-canary.0
|
|
380
|
+
*/
|
|
381
|
+
export declare function isDomainJsxExpression(node: DomainAstNode): node is DomainJsxExpression;
|
|
382
|
+
/**
|
|
383
|
+
* Visits each direct child of a domain node.
|
|
384
|
+
*
|
|
385
|
+
* @since 0.3.16-canary.0
|
|
386
|
+
*/
|
|
387
|
+
export declare function forEachDomainChild(node: DomainAstNode, visit: (child: DomainAstNode) => void): void;
|
|
388
|
+
/**
|
|
389
|
+
* Resolves the one-based line number of a position in source text.
|
|
390
|
+
*
|
|
391
|
+
* @since 0.3.16-canary.0
|
|
392
|
+
*/
|
|
393
|
+
export declare function lineOfSourcePosition(sourceText: string, pos: number): number;
|
|
394
|
+
export {};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { DomainAstNode } from "#/arrange/domain/ast/ast-node";
|
|
2
|
+
import type { ForEachStringLiteralInClassExpressionOptions, TailwindClassLiteral } from "#/arrange/domain/types";
|
|
3
|
+
/**
|
|
4
|
+
* Visits every static class literal reachable inside a class expression.
|
|
5
|
+
*
|
|
6
|
+
* @since 0.3.16-canary.0
|
|
7
|
+
*/
|
|
8
|
+
export declare function forEachStringLiteralInClassExpression(expr: DomainAstNode, sink: (classLiteral: TailwindClassLiteral) => void, depth?: number, options?: ForEachStringLiteralInClassExpressionOptions): void;
|
|
9
|
+
/**
|
|
10
|
+
* Checks whether a literal sits directly inside an array literal, where splitting it apart is unsafe.
|
|
11
|
+
*
|
|
12
|
+
* @since 0.3.16-canary.0
|
|
13
|
+
*/
|
|
14
|
+
export declare function isUnsafeLiteralForCnStyleApplySplit(classLiteral: TailwindClassLiteral): boolean;
|
|
15
|
+
/**
|
|
16
|
+
* The walk options for building the `cn` apply pool — conditional branches are never descended into.
|
|
17
|
+
*
|
|
18
|
+
* @since 0.3.16-canary.0
|
|
19
|
+
*/
|
|
20
|
+
export declare const CN_APPLY_LITERAL_WALK_OPTS: ForEachStringLiteralInClassExpressionOptions;
|
|
21
|
+
/**
|
|
22
|
+
* Collects the static class literals in `cn()` arguments that are safe to regroup.
|
|
23
|
+
*
|
|
24
|
+
* @since 0.3.16-canary.0
|
|
25
|
+
*/
|
|
26
|
+
export declare function collectUnconditionalTailwindLiteralsFromCnArguments(args: ReadonlyArray<DomainAstNode>): Array<TailwindClassLiteral>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { DomainJsxAttribute } from "#/arrange/domain/ast/ast-node";
|
|
2
|
+
import type { JsxClassNameStatic } from "#/arrange/domain/types";
|
|
3
|
+
/**
|
|
4
|
+
* Extracts the static literal of a JSX `className` attribute, or `undefined` when it is not static.
|
|
5
|
+
*
|
|
6
|
+
* @since 0.3.16-canary.0
|
|
7
|
+
*/
|
|
8
|
+
export declare function jsxClassNameStaticLiteral(jsxClassNameAttribute: DomainJsxAttribute): JsxClassNameStatic | undefined;
|