@codefast/cli 0.3.12 → 0.3.13-canary.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/README.md +206 -51
- package/dist/analyze-DvtJ3j9m.mjs +92 -0
- package/dist/arrange-Bbh62DrU.mjs +107 -0
- package/dist/arrange-BqP2DI3w.mjs +8 -0
- package/dist/ast-helpers-MDRYuIAk.mjs +115 -0
- package/dist/{bin.js → bin.mjs} +4 -1
- package/dist/caught-unknown-message-CRhkDWO7.mjs +20 -0
- package/dist/collectors-cn-BS8TTQ8O.mjs +61 -0
- package/dist/collectors-jsx-D9tL2ZPM.mjs +20 -0
- package/dist/collectors-tv-D2PXZaRt.mjs +170 -0
- package/dist/colors-BjdkCfGK.mjs +12 -0
- package/dist/commands/arrange.mjs +2 -0
- package/dist/commands/mirror.mjs +2 -0
- package/dist/commands/mirror.test.mjs +48 -0
- package/dist/commands/tag.mjs +2 -0
- package/dist/config-DVia_f9a.mjs +3 -0
- package/dist/config-reporter-SCcWDZc1.mjs +10 -0
- package/dist/constants-AtPhF-Ct.mjs +169 -0
- package/dist/constants-Bq5wdyLC.mjs +8 -0
- package/dist/dirent-list-BSDeRG5i.mjs +14 -0
- package/dist/engine-CcWEHSCq.mjs +287 -0
- package/dist/engine-DRTdkc5u.mjs +236 -0
- package/dist/errors-CFH4w6ic.mjs +15 -0
- package/dist/errors-CpU1ogfA.mjs +19 -0
- package/dist/formatters-DGE8jJ53.mjs +52 -0
- package/dist/group-file-ClW7XdD6.mjs +113 -0
- package/dist/grouping-c1grpCQT.mjs +235 -0
- package/dist/imports-DSVq1xhB.mjs +54 -0
- package/dist/lib/arrange/application/analyze.mjs +2 -0
- package/dist/lib/arrange/application/analyze.test.mjs +171 -0
- package/dist/lib/arrange/application/group-file.mjs +2 -0
- package/dist/lib/arrange/application/group-file.test.mjs +273 -0
- package/dist/lib/arrange/application/run-target.mjs +2 -0
- package/dist/lib/arrange/application/run-target.test.mjs +97 -0
- package/dist/lib/arrange/domain/ast/ast-helpers.mjs +2 -0
- package/dist/lib/arrange/domain/ast/ast-helpers.test.mjs +148 -0
- package/dist/lib/arrange/domain/ast/collectors-cn.mjs +2 -0
- package/dist/lib/arrange/domain/ast/collectors-cn.test.mjs +58 -0
- package/dist/lib/arrange/domain/ast/collectors-jsx.mjs +2 -0
- package/dist/lib/arrange/domain/ast/collectors-jsx.test.mjs +20 -0
- package/dist/lib/arrange/domain/ast/collectors-tv.mjs +2 -0
- package/dist/lib/arrange/domain/ast/collectors-tv.test.mjs +145 -0
- package/dist/lib/arrange/domain/ast/targets.mjs +2 -0
- package/dist/lib/arrange/domain/ast/targets.test.mjs +50 -0
- package/dist/lib/arrange/domain/constants.mjs +2 -0
- package/dist/lib/arrange/domain/errors.mjs +2 -0
- package/dist/lib/arrange/domain/grouping.mjs +2 -0
- package/dist/lib/arrange/domain/grouping.test.mjs +186 -0
- package/dist/lib/arrange/domain/imports.mjs +2 -0
- package/dist/lib/arrange/domain/imports.test.mjs +48 -0
- package/dist/lib/arrange/domain/tokenizer.mjs +2 -0
- package/dist/lib/arrange/domain/tokenizer.test.mjs +165 -0
- package/dist/lib/arrange/index.mjs +16 -0
- package/dist/lib/arrange/infra/walk.mjs +2 -0
- package/dist/lib/arrange/infra/walk.test.mjs +50 -0
- package/dist/lib/arrange/presentation/formatters.mjs +2 -0
- package/dist/lib/arrange/presentation/formatters.test.mjs +73 -0
- package/dist/lib/arrange/presentation/report.mjs +2 -0
- package/dist/lib/config/domain/schema.mjs +2 -0
- package/dist/lib/config/index.mjs +4 -0
- package/dist/lib/config/infra/loader.mjs +2 -0
- package/dist/lib/config/infra/loader.test.mjs +116 -0
- package/dist/lib/infra/caught-unknown-message.mjs +2 -0
- package/dist/lib/infra/config-reporter.mjs +2 -0
- package/dist/lib/infra/node-io.mjs +2 -0
- package/dist/lib/infra/workspace/repo-root.mjs +2 -0
- package/dist/lib/infra/workspace/repo-root.test.mjs +45 -0
- package/dist/lib/mirror/application/engine.mjs +2 -0
- package/dist/lib/mirror/application/sync.mjs +2 -0
- package/dist/lib/mirror/application/sync.test.mjs +482 -0
- package/dist/lib/mirror/domain/constants.mjs +2 -0
- package/dist/lib/mirror/domain/errors.mjs +2 -0
- package/dist/lib/mirror/domain/types.mjs +1 -0
- package/dist/lib/mirror/index.mjs +3 -0
- package/dist/lib/mirror/infra/dirent-list.mjs +2 -0
- package/dist/lib/mirror/infra/dirent-list.test.mjs +18 -0
- package/dist/lib/mirror/infra/package-filter.mjs +2 -0
- package/dist/lib/mirror/infra/package-filter.test.mjs +32 -0
- package/dist/lib/mirror/infra/path-normalizer.mjs +2 -0
- package/dist/lib/mirror/infra/update-pkg.mjs +2 -0
- package/dist/lib/mirror/infra/workspace-packages.mjs +2 -0
- package/dist/lib/mirror/infra/workspace-packages.test.mjs +167 -0
- package/dist/lib/mirror/presentation/reporter.mjs +2 -0
- package/dist/lib/tag/application/engine.mjs +2 -0
- package/dist/lib/tag/application/engine.test.mjs +159 -0
- package/dist/lib/tag/domain/types.mjs +1 -0
- package/dist/lib/tag/index.mjs +5 -0
- package/dist/lib/tag/infra/target-resolver.mjs +2 -0
- package/dist/lib/tag/presentation/colors.mjs +2 -0
- package/dist/lib/tag/presentation/tag-presenter.mjs +2 -0
- package/dist/lib/tag/presentation/tag-presenter.test.mjs +29 -0
- package/dist/loader-DpN-zl5g.mjs +78 -0
- package/dist/mirror-CbGiLXKT.mjs +2 -0
- package/dist/mirror-DqJE3ejL.mjs +66 -0
- package/dist/node-io-DFRbHO6m.mjs +30 -0
- package/dist/package-filter-C_8ryqvz.mjs +26 -0
- package/dist/path-normalizer-D4ceBO3l.mjs +7 -0
- package/dist/program-DR-H4tH3.mjs +34 -0
- package/dist/program.mjs +2 -0
- package/dist/repo-root-HmtIEm6J.mjs +22 -0
- package/dist/report-DYxvw34T.mjs +24 -0
- package/dist/reporter-CwIe_tAM.mjs +108 -0
- package/dist/run-target-CJWrqNT4.mjs +65 -0
- package/dist/schema-Or8RAARd.mjs +25 -0
- package/dist/sync-e1Sp-shi.mjs +157 -0
- package/dist/tag-Cd9JujU5.mjs +2 -0
- package/dist/tag-hEKVZ_-7.mjs +58 -0
- package/dist/tag-presenter-Cs66UBsH.mjs +63 -0
- package/dist/target-resolver-CR3FXMTy.mjs +170 -0
- package/dist/targets-pCTslnFh.mjs +106 -0
- package/dist/tokenizer-CeZx73Zu.mjs +216 -0
- package/dist/update-pkg-CnGfjWBy.mjs +37 -0
- package/dist/walk-DjgQn66n.mjs +33 -0
- package/dist/workspace-packages-K2NYTHJq.mjs +159 -0
- package/package.json +11 -11
- package/dist/bin.d.ts +0 -3
- package/dist/bin.d.ts.map +0 -1
- package/dist/commands/arrange.d.ts +0 -3
- package/dist/commands/arrange.d.ts.map +0 -1
- package/dist/commands/arrange.js +0 -114
- package/dist/commands/mirror.d.ts +0 -4
- package/dist/commands/mirror.d.ts.map +0 -1
- package/dist/commands/mirror.js +0 -63
- package/dist/lib/arrange/analyze.d.ts +0 -4
- package/dist/lib/arrange/analyze.d.ts.map +0 -1
- package/dist/lib/arrange/analyze.js +0 -105
- package/dist/lib/arrange/ast/collectors-cn.d.ts +0 -10
- package/dist/lib/arrange/ast/collectors-cn.d.ts.map +0 -1
- package/dist/lib/arrange/ast/collectors-cn.js +0 -84
- package/dist/lib/arrange/ast/collectors-jsx.d.ts +0 -4
- package/dist/lib/arrange/ast/collectors-jsx.d.ts.map +0 -1
- package/dist/lib/arrange/ast/collectors-jsx.js +0 -18
- package/dist/lib/arrange/ast/collectors-tv.d.ts +0 -13
- package/dist/lib/arrange/ast/collectors-tv.d.ts.map +0 -1
- package/dist/lib/arrange/ast/collectors-tv.js +0 -273
- package/dist/lib/arrange/ast/targets.d.ts +0 -8
- package/dist/lib/arrange/ast/targets.d.ts.map +0 -1
- package/dist/lib/arrange/ast/targets.js +0 -143
- package/dist/lib/arrange/ast/utils.d.ts +0 -36
- package/dist/lib/arrange/ast/utils.d.ts.map +0 -1
- package/dist/lib/arrange/ast/utils.js +0 -138
- package/dist/lib/arrange/constants.d.ts +0 -68
- package/dist/lib/arrange/constants.d.ts.map +0 -1
- package/dist/lib/arrange/constants.js +0 -179
- package/dist/lib/arrange/errors.d.ts +0 -14
- package/dist/lib/arrange/errors.d.ts.map +0 -1
- package/dist/lib/arrange/errors.js +0 -16
- package/dist/lib/arrange/formatters.d.ts +0 -16
- package/dist/lib/arrange/formatters.d.ts.map +0 -1
- package/dist/lib/arrange/formatters.js +0 -57
- package/dist/lib/arrange/group-file.d.ts +0 -4
- package/dist/lib/arrange/group-file.d.ts.map +0 -1
- package/dist/lib/arrange/group-file.js +0 -115
- package/dist/lib/arrange/grouping.d.ts +0 -41
- package/dist/lib/arrange/grouping.d.ts.map +0 -1
- package/dist/lib/arrange/grouping.js +0 -280
- package/dist/lib/arrange/imports.d.ts +0 -6
- package/dist/lib/arrange/imports.d.ts.map +0 -1
- package/dist/lib/arrange/imports.js +0 -74
- package/dist/lib/arrange/report.d.ts +0 -4
- package/dist/lib/arrange/report.d.ts.map +0 -1
- package/dist/lib/arrange/report.js +0 -37
- package/dist/lib/arrange/run-target.d.ts +0 -4
- package/dist/lib/arrange/run-target.d.ts.map +0 -1
- package/dist/lib/arrange/run-target.js +0 -28
- package/dist/lib/arrange/tokenizer.d.ts +0 -37
- package/dist/lib/arrange/tokenizer.d.ts.map +0 -1
- package/dist/lib/arrange/tokenizer.js +0 -390
- package/dist/lib/arrange/types.d.ts +0 -104
- package/dist/lib/arrange/types.d.ts.map +0 -1
- package/dist/lib/arrange/types.js +0 -7
- package/dist/lib/arrange/walk.d.ts +0 -4
- package/dist/lib/arrange/walk.d.ts.map +0 -1
- package/dist/lib/arrange/walk.js +0 -34
- package/dist/lib/arrange.d.ts +0 -41
- package/dist/lib/arrange.d.ts.map +0 -1
- package/dist/lib/arrange.js +0 -38
- package/dist/lib/infra/fs-contract.d.ts +0 -28
- package/dist/lib/infra/fs-contract.d.ts.map +0 -1
- package/dist/lib/infra/node-io.d.ts +0 -4
- package/dist/lib/infra/node-io.d.ts.map +0 -1
- package/dist/lib/infra/node-io.js +0 -27
- package/dist/lib/mirror/config.d.ts +0 -7
- package/dist/lib/mirror/config.d.ts.map +0 -1
- package/dist/lib/mirror/config.js +0 -146
- package/dist/lib/mirror/constants.d.ts +0 -10
- package/dist/lib/mirror/constants.d.ts.map +0 -1
- package/dist/lib/mirror/constants.js +0 -13
- package/dist/lib/mirror/engine.d.ts +0 -12
- package/dist/lib/mirror/engine.d.ts.map +0 -1
- package/dist/lib/mirror/engine.js +0 -248
- package/dist/lib/mirror/errors.d.ts +0 -10
- package/dist/lib/mirror/errors.d.ts.map +0 -1
- package/dist/lib/mirror/errors.js +0 -12
- package/dist/lib/mirror/package-filter.d.ts +0 -8
- package/dist/lib/mirror/package-filter.d.ts.map +0 -1
- package/dist/lib/mirror/package-filter.js +0 -33
- package/dist/lib/mirror/reporter.d.ts +0 -24
- package/dist/lib/mirror/reporter.d.ts.map +0 -1
- package/dist/lib/mirror/reporter.js +0 -126
- package/dist/lib/mirror/sync.d.ts +0 -4
- package/dist/lib/mirror/sync.d.ts.map +0 -1
- package/dist/lib/mirror/sync.js +0 -135
- package/dist/lib/mirror/types.d.ts +0 -81
- package/dist/lib/mirror/types.d.ts.map +0 -1
- package/dist/lib/mirror/update-pkg.d.ts +0 -13
- package/dist/lib/mirror/update-pkg.d.ts.map +0 -1
- package/dist/lib/mirror/update-pkg.js +0 -39
- package/dist/lib/mirror/workspace-packages.d.ts +0 -26
- package/dist/lib/mirror/workspace-packages.d.ts.map +0 -1
- package/dist/lib/mirror/workspace-packages.js +0 -160
- package/dist/lib/mirror.d.ts +0 -7
- package/dist/lib/mirror.d.ts.map +0 -1
- package/dist/lib/mirror.js +0 -5
- package/dist/lib/repo-root.d.ts +0 -7
- package/dist/lib/repo-root.d.ts.map +0 -1
- package/dist/lib/repo-root.js +0 -23
- package/dist/lib/shared/utils.d.ts +0 -9
- package/dist/lib/shared/utils.d.ts.map +0 -1
- package/dist/lib/shared/utils.js +0 -12
- package/dist/program.d.ts +0 -4
- package/dist/program.d.ts.map +0 -1
- package/dist/program.js +0 -38
- /package/dist/lib/{infra/fs-contract.js → arrange/domain/types.mjs} +0 -0
- /package/dist/lib/{mirror/types.js → infra/fs-contract.mjs} +0 -0
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import "./constants-AtPhF-Ct.mjs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
//#region src/lib/arrange/presentation/report.ts
|
|
4
|
+
function printAnalyzeReport(analyzeRootDirectoryPath, analyzeReport, logger) {
|
|
5
|
+
const { out } = logger;
|
|
6
|
+
out(`Path: ${path.resolve(analyzeRootDirectoryPath)}`);
|
|
7
|
+
out(`.ts/.tsx files: ${analyzeReport.files}`);
|
|
8
|
+
out(`cn(...) call sites: ${analyzeReport.cnCallExpressions}`);
|
|
9
|
+
out(`tv(...) call sites: ${analyzeReport.tvCallExpressions}`);
|
|
10
|
+
out(`\nLong cn(...) string literals (≥18 tokens — consider splitting arguments): ${analyzeReport.longCnStringLiterals.length}`);
|
|
11
|
+
for (const findingEntry of analyzeReport.longCnStringLiterals.slice(0, 40)) out(` ${findingEntry.file}:${findingEntry.line} (${findingEntry.tokenCount} tokens) ${findingEntry.preview}`);
|
|
12
|
+
if (analyzeReport.longCnStringLiterals.length > 40) out(` … and ${analyzeReport.longCnStringLiterals.length - 40} more`);
|
|
13
|
+
out(`\nLong tv({...}) string literals in base/variants/… (≥18 tokens): ${analyzeReport.longTvStringLiterals.length}`);
|
|
14
|
+
for (const findingEntry of analyzeReport.longTvStringLiterals.slice(0, 40)) out(` ${findingEntry.file}:${findingEntry.line} (${findingEntry.tokenCount} tokens) ${findingEntry.preview}`);
|
|
15
|
+
if (analyzeReport.longTvStringLiterals.length > 40) out(` … and ${analyzeReport.longTvStringLiterals.length - 40} more`);
|
|
16
|
+
out(`\nJSX className="..." or className={'...'} (static strings, ≥18 tokens): ${analyzeReport.longJsxClassNameLiterals.length}`);
|
|
17
|
+
for (const findingEntry of analyzeReport.longJsxClassNameLiterals.slice(0, 40)) out(` ${findingEntry.file}:${findingEntry.line} (${findingEntry.tokenCount} tokens) ${findingEntry.preview}`);
|
|
18
|
+
if (analyzeReport.longJsxClassNameLiterals.length > 40) out(` … and ${analyzeReport.longJsxClassNameLiterals.length - 40} more`);
|
|
19
|
+
out(`\ncn(...) nested inside tv({...}) (prefer a string or array — preview/apply can rewrite): ${analyzeReport.cnInsideTvCalls.length}`);
|
|
20
|
+
for (const findingEntry of analyzeReport.cnInsideTvCalls.slice(0, 40)) out(` ${findingEntry.file}:${findingEntry.line} (${findingEntry.argCount} args) ${findingEntry.preview}`);
|
|
21
|
+
if (analyzeReport.cnInsideTvCalls.length > 40) out(` … and ${analyzeReport.cnInsideTvCalls.length - 40} more`);
|
|
22
|
+
}
|
|
23
|
+
//#endregion
|
|
24
|
+
export { printAnalyzeReport as t };
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { t as messageFromCaughtUnknown } from "./caught-unknown-message-CRhkDWO7.mjs";
|
|
2
|
+
import { t as printConfigSchemaWarnings } from "./config-reporter-SCcWDZc1.mjs";
|
|
3
|
+
import process from "node:process";
|
|
4
|
+
//#region src/lib/mirror/presentation/reporter.ts
|
|
5
|
+
const Colors = {
|
|
6
|
+
RESET: "\x1B[0m",
|
|
7
|
+
BOLD: "\x1B[1m",
|
|
8
|
+
DIM: "\x1B[2m",
|
|
9
|
+
GREEN: "\x1B[32m",
|
|
10
|
+
YELLOW: "\x1B[33m",
|
|
11
|
+
CYAN: "\x1B[36m",
|
|
12
|
+
GRAY: "\x1B[90m",
|
|
13
|
+
MAGENTA: "\x1B[35m",
|
|
14
|
+
BRIGHT_GREEN: "\x1B[92m",
|
|
15
|
+
BRIGHT_YELLOW: "\x1B[93m",
|
|
16
|
+
BRIGHT_CYAN: "\x1B[96m",
|
|
17
|
+
disable() {
|
|
18
|
+
for (const key of Object.keys(this)) if (typeof this[key] === "string") this[key] = "";
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
function configureMirrorColors(noColor) {
|
|
22
|
+
if (!process.stdout.isTTY || noColor) Colors.disable();
|
|
23
|
+
}
|
|
24
|
+
function printMirrorConfigWarnings(logger, warnings) {
|
|
25
|
+
printConfigSchemaWarnings(logger, warnings);
|
|
26
|
+
}
|
|
27
|
+
function mirrorGlobWarning(logger, message) {
|
|
28
|
+
const { out } = logger;
|
|
29
|
+
out(`${Colors.YELLOW}⚠ ${message}${Colors.RESET}`);
|
|
30
|
+
}
|
|
31
|
+
function logSkippedWorkspacePackage(logger, index, total, displayName, reason) {
|
|
32
|
+
const { out } = logger;
|
|
33
|
+
out(`${`${Colors.DIM}[${index}/${total}]${Colors.RESET}`} ${Colors.GRAY}○${Colors.RESET} ${Colors.DIM}${displayName}${Colors.RESET}`);
|
|
34
|
+
out(` ${Colors.DIM}└─${Colors.RESET} ${Colors.GRAY}Skipped: ${reason}${Colors.RESET}`);
|
|
35
|
+
out("");
|
|
36
|
+
}
|
|
37
|
+
function mirrorBanner(logger) {
|
|
38
|
+
const { out } = logger;
|
|
39
|
+
out(`\n${Colors.BOLD}${Colors.CYAN}📦 Mirror — package exports${Colors.RESET}`);
|
|
40
|
+
out(`${Colors.DIM}${"═".repeat(60)}${Colors.RESET}\n`);
|
|
41
|
+
}
|
|
42
|
+
function mirrorProcessingMode(logger, mode) {
|
|
43
|
+
const { out } = logger;
|
|
44
|
+
if (mode.kind === "single") {
|
|
45
|
+
out(`${Colors.DIM}Processing single package...${Colors.RESET}\n`);
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
switch (mode.source) {
|
|
49
|
+
case "default-patterns":
|
|
50
|
+
out(`${Colors.DIM}Discovering workspace packages using default patterns (packages/*)…${Colors.RESET}\n`);
|
|
51
|
+
break;
|
|
52
|
+
case "pnpm-workspace-yaml":
|
|
53
|
+
out(`${Colors.DIM}Discovering workspace packages from pnpm-workspace.yaml…${Colors.RESET}\n`);
|
|
54
|
+
break;
|
|
55
|
+
case "declared-empty":
|
|
56
|
+
out(`${Colors.DIM}pnpm-workspace.yaml declares an empty workspace package list.${Colors.RESET}\n`);
|
|
57
|
+
break;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
function mirrorNoPackages(logger) {
|
|
61
|
+
logger.out(`${Colors.YELLOW}⚠ No packages found${Colors.RESET}`);
|
|
62
|
+
}
|
|
63
|
+
function logPackageSuccess(logger, index, total, pkgStats, generatedDistAssetCounts, verbose) {
|
|
64
|
+
const { out } = logger;
|
|
65
|
+
out(`${`${Colors.DIM}[${index}/${total}]${Colors.RESET}`} ${Colors.BRIGHT_GREEN}✓${Colors.RESET} ${Colors.BOLD}${pkgStats.name}${Colors.RESET}`);
|
|
66
|
+
if (verbose) {
|
|
67
|
+
out(` ${Colors.DIM}├─${Colors.RESET} Path: ${pkgStats.path}`);
|
|
68
|
+
if (pkgStats.hasTransform) out(` ${Colors.DIM}├─${Colors.RESET} ${Colors.CYAN}Custom path transformation${Colors.RESET}`);
|
|
69
|
+
if (pkgStats.cssConfigStatus) out(` ${Colors.DIM}├─${Colors.RESET} ${Colors.CYAN}${pkgStats.cssConfigStatus === "disabled" ? "CSS disabled" : "CSS configured"}${Colors.RESET}`);
|
|
70
|
+
}
|
|
71
|
+
const breakdown = [];
|
|
72
|
+
if (generatedDistAssetCounts.jsCount > 0) breakdown.push(`${Colors.GREEN}${generatedDistAssetCounts.jsCount} modules${Colors.RESET}`);
|
|
73
|
+
if (generatedDistAssetCounts.cssCount > 0) breakdown.push(`${Colors.MAGENTA}${generatedDistAssetCounts.cssCount} CSS${Colors.RESET}`);
|
|
74
|
+
if (pkgStats.customExports > 0) breakdown.push(`${Colors.YELLOW}${pkgStats.customExports} custom${Colors.RESET}`);
|
|
75
|
+
if (breakdown.length > 0) out(` ${Colors.DIM}└─${Colors.RESET} ${breakdown.join(" + ")} = ${Colors.BRIGHT_CYAN}${pkgStats.totalExports} exports${Colors.RESET}`);
|
|
76
|
+
else out(` ${Colors.DIM}└─${Colors.RESET} ${Colors.BRIGHT_CYAN}${pkgStats.totalExports} exports${Colors.RESET}`);
|
|
77
|
+
out("");
|
|
78
|
+
}
|
|
79
|
+
function logPackageError(logger, index, total, displayName, errValue, verbose) {
|
|
80
|
+
const { out, err: errLine } = logger;
|
|
81
|
+
out(`${Colors.DIM}[${index}/${total}]${Colors.RESET} ${Colors.YELLOW}✗${Colors.RESET} ${Colors.BOLD}${displayName}${Colors.RESET}`);
|
|
82
|
+
out(` ${Colors.DIM}└─${Colors.RESET} ${Colors.YELLOW}Error: ${messageFromCaughtUnknown(errValue)}${Colors.RESET}\n`);
|
|
83
|
+
if (verbose) errLine(errValue instanceof Error && errValue.stack ? errValue.stack : messageFromCaughtUnknown(errValue));
|
|
84
|
+
}
|
|
85
|
+
function mirrorSummarySeparator(logger) {
|
|
86
|
+
logger.out(`${Colors.DIM}${"═".repeat(60)}${Colors.RESET}`);
|
|
87
|
+
}
|
|
88
|
+
function mirrorSummary(logger, stats, elapsedSeconds) {
|
|
89
|
+
const { out } = logger;
|
|
90
|
+
out(`${Colors.BOLD}📊 Summary${Colors.RESET} ${Colors.DIM}(completed in ${elapsedSeconds.toFixed(2)}s)${Colors.RESET}\n`);
|
|
91
|
+
out(` ${Colors.BOLD}Packages:${Colors.RESET}`);
|
|
92
|
+
out(` ${Colors.DIM}├─${Colors.RESET} Processed: ${Colors.GREEN}${stats.packagesProcessed}${Colors.RESET}`);
|
|
93
|
+
if (stats.packagesSkipped > 0) out(` ${Colors.DIM}├─${Colors.RESET} Skipped: ${Colors.GRAY}${stats.packagesSkipped}${Colors.RESET}`);
|
|
94
|
+
if (stats.packagesErrored > 0) out(` ${Colors.DIM}├─${Colors.RESET} Errors: ${Colors.YELLOW}${stats.packagesErrored}${Colors.RESET}`);
|
|
95
|
+
out(` ${Colors.DIM}└─${Colors.RESET} Total found: ${stats.packagesFound}\n`);
|
|
96
|
+
out(` ${Colors.BOLD}Exports:${Colors.RESET}`);
|
|
97
|
+
out(` ${Colors.DIM}├─${Colors.RESET} JS Modules: ${Colors.CYAN}${stats.totalJsModules}${Colors.RESET}`);
|
|
98
|
+
out(` ${Colors.DIM}├─${Colors.RESET} CSS Files: ${Colors.MAGENTA}${stats.totalCssExports}${Colors.RESET}`);
|
|
99
|
+
out(` ${Colors.DIM}└─${Colors.RESET} Total: ${Colors.BRIGHT_CYAN}${stats.totalExports}${Colors.RESET}\n`);
|
|
100
|
+
out(`${Colors.DIM}${"═".repeat(60)}${Colors.RESET}\n`);
|
|
101
|
+
}
|
|
102
|
+
function mirrorFatalError(logger, caughtError) {
|
|
103
|
+
const { out, err: errLine } = logger;
|
|
104
|
+
out(`${Colors.YELLOW}Fatal error: ${messageFromCaughtUnknown(caughtError)}${Colors.RESET}`);
|
|
105
|
+
errLine(caughtError instanceof Error && caughtError.stack ? caughtError.stack : messageFromCaughtUnknown(caughtError));
|
|
106
|
+
}
|
|
107
|
+
//#endregion
|
|
108
|
+
export { mirrorBanner as a, mirrorNoPackages as c, mirrorSummarySeparator as d, printMirrorConfigWarnings as f, logSkippedWorkspacePackage as i, mirrorProcessingMode as l, logPackageError as n, mirrorFatalError as o, logPackageSuccess as r, mirrorGlobWarning as s, configureMirrorColors as t, mirrorSummary as u };
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { t as messageFromCaughtUnknown } from "./caught-unknown-message-CRhkDWO7.mjs";
|
|
2
|
+
import { n as walkTsxFiles } from "./walk-DjgQn66n.mjs";
|
|
3
|
+
import { t as groupFile } from "./group-file-ClW7XdD6.mjs";
|
|
4
|
+
import { n as ArrangeErrorCode, t as ArrangeError } from "./errors-CpU1ogfA.mjs";
|
|
5
|
+
import path from "node:path";
|
|
6
|
+
//#region src/lib/arrange/application/run-target.ts
|
|
7
|
+
function runOnTarget(target, options, fs, logger) {
|
|
8
|
+
const { out } = logger;
|
|
9
|
+
if (!fs.existsSync(target)) throw new ArrangeError(ArrangeErrorCode.TARGET_NOT_FOUND, `Not found: ${target}`);
|
|
10
|
+
const filePaths = fs.statSync(target).isDirectory() ? walkTsxFiles(target, fs) : [target];
|
|
11
|
+
const modifiedFiles = [];
|
|
12
|
+
let totalFound = 0;
|
|
13
|
+
let totalChanged = 0;
|
|
14
|
+
for (const filePath of filePaths) {
|
|
15
|
+
const result = groupFile(filePath, options, fs, logger);
|
|
16
|
+
totalFound += result.totalFound;
|
|
17
|
+
totalChanged += result.changed;
|
|
18
|
+
if (result.changed > 0) modifiedFiles.push(result.filePath);
|
|
19
|
+
}
|
|
20
|
+
out(`\nTotal: ${filePaths.length} file(s), ${totalFound} site(s) (cn/tv/JSX className) to review.`);
|
|
21
|
+
if (options.write) out(`Applied: ${totalChanged} site(s) updated.`);
|
|
22
|
+
else out(`(Run "apply" to write changes, or "pnpm cli:arrange-apply" / "pnpm exec codefast arrange apply")`);
|
|
23
|
+
if (options.write ? totalChanged > 0 : totalFound > 0) out("Note: class order may change across concern groups — smoke-test the UI if you rely on cascade order.");
|
|
24
|
+
return {
|
|
25
|
+
filePaths,
|
|
26
|
+
modifiedFiles,
|
|
27
|
+
totalFound,
|
|
28
|
+
totalChanged
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
async function runArrangeOnAfterWriteHook(logger, hook, modifiedFiles) {
|
|
32
|
+
if (!hook || modifiedFiles.length === 0) return;
|
|
33
|
+
try {
|
|
34
|
+
await hook({ files: modifiedFiles });
|
|
35
|
+
} catch (caughtHookError) {
|
|
36
|
+
logger.err(`[arrange] onAfterWrite hook failed: ${messageFromCaughtUnknown(caughtHookError)}`);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* CLI entry: run arrange preview/apply using config injected by the command layer.
|
|
41
|
+
* @returns Process exit code (`0`, or `1` when the target path is missing).
|
|
42
|
+
*/
|
|
43
|
+
async function runArrangeSync(opts) {
|
|
44
|
+
opts.rootDir;
|
|
45
|
+
const { fs, logger } = opts;
|
|
46
|
+
const resolvedTarget = path.resolve(opts.targetPath);
|
|
47
|
+
let result;
|
|
48
|
+
try {
|
|
49
|
+
result = runOnTarget(resolvedTarget, {
|
|
50
|
+
write: opts.write,
|
|
51
|
+
withClassName: !!opts.withClassName,
|
|
52
|
+
cnImport: opts.cnImport
|
|
53
|
+
}, fs, logger);
|
|
54
|
+
} catch (caughtError) {
|
|
55
|
+
if (caughtError instanceof ArrangeError && caughtError.code === ArrangeErrorCode.TARGET_NOT_FOUND) {
|
|
56
|
+
logger.err(caughtError.message);
|
|
57
|
+
return 1;
|
|
58
|
+
}
|
|
59
|
+
throw caughtError;
|
|
60
|
+
}
|
|
61
|
+
if (opts.write && result.modifiedFiles.length > 0) await runArrangeOnAfterWriteHook(logger, opts.config?.onAfterWrite, result.modifiedFiles);
|
|
62
|
+
return 0;
|
|
63
|
+
}
|
|
64
|
+
//#endregion
|
|
65
|
+
export { runOnTarget as n, runArrangeSync as t };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
//#region src/lib/config/domain/schema.ts
|
|
3
|
+
const hookSchema = z.custom((value) => typeof value === "function", { message: "Expected a function" });
|
|
4
|
+
const mirrorConfigSchema = z.object({
|
|
5
|
+
skipPackages: z.array(z.string()).optional(),
|
|
6
|
+
pathTransformations: z.record(z.string(), z.object({ removePrefix: z.string().optional() }).strict()).optional(),
|
|
7
|
+
customExports: z.record(z.string(), z.record(z.string(), z.string())).optional(),
|
|
8
|
+
cssExports: z.record(z.string(), z.union([z.boolean(), z.object({
|
|
9
|
+
enabled: z.boolean().optional(),
|
|
10
|
+
customExports: z.record(z.string(), z.string()).optional(),
|
|
11
|
+
forceExportFiles: z.boolean().optional()
|
|
12
|
+
}).strict()])).optional()
|
|
13
|
+
}).strict();
|
|
14
|
+
const codefastTagConfigSchema = z.object({
|
|
15
|
+
skipPackages: z.array(z.string()).optional(),
|
|
16
|
+
onAfterWrite: hookSchema.optional()
|
|
17
|
+
}).strict();
|
|
18
|
+
const codefastArrangeConfigSchema = z.object({ onAfterWrite: hookSchema.optional() }).strict();
|
|
19
|
+
const codefastConfigSchema = z.object({
|
|
20
|
+
mirror: mirrorConfigSchema.optional(),
|
|
21
|
+
tag: codefastTagConfigSchema.optional(),
|
|
22
|
+
arrange: codefastArrangeConfigSchema.optional()
|
|
23
|
+
}).strict();
|
|
24
|
+
//#endregion
|
|
25
|
+
export { mirrorConfigSchema as a, hookSchema as i, codefastConfigSchema as n, codefastTagConfigSchema as r, codefastArrangeConfigSchema as t };
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import { t as messageFromCaughtUnknown } from "./caught-unknown-message-CRhkDWO7.mjs";
|
|
2
|
+
import { r as PACKAGE_JSON, t as DIST_DIR } from "./constants-Bq5wdyLC.mjs";
|
|
3
|
+
import { n as generateExports, t as createPathTransform } from "./engine-DRTdkc5u.mjs";
|
|
4
|
+
import { t as resolvePackageFilterUnderRoot } from "./package-filter-C_8ryqvz.mjs";
|
|
5
|
+
import { a as mirrorBanner, c as mirrorNoPackages, d as mirrorSummarySeparator, i as logSkippedWorkspacePackage, l as mirrorProcessingMode, n as logPackageError, o as mirrorFatalError, r as logPackageSuccess, t as configureMirrorColors, u as mirrorSummary } from "./reporter-CwIe_tAM.mjs";
|
|
6
|
+
import { n as resolvePackageDisplayName, r as writePackageJsonExportsAtomic } from "./update-pkg-CnGfjWBy.mjs";
|
|
7
|
+
import { t as findWorkspacePackageRelPaths } from "./workspace-packages-K2NYTHJq.mjs";
|
|
8
|
+
import path from "node:path";
|
|
9
|
+
//#region src/lib/mirror/application/sync.ts
|
|
10
|
+
function resolvePackageScopedConfig(configMap, pkgMeta) {
|
|
11
|
+
if (!configMap) return void 0;
|
|
12
|
+
return configMap[pkgMeta.packageName];
|
|
13
|
+
}
|
|
14
|
+
function isPackageSkipped(skipPackagesArray, pkgMeta) {
|
|
15
|
+
if (!skipPackagesArray) return false;
|
|
16
|
+
return skipPackagesArray.includes(pkgMeta.packageName);
|
|
17
|
+
}
|
|
18
|
+
async function syncExportsForWorkspacePackage(fs, logger, rootDir, packagePathStr, index, total, config, verbose, stats) {
|
|
19
|
+
const packageDir = path.resolve(rootDir, packagePathStr);
|
|
20
|
+
const distDir = path.join(packageDir, DIST_DIR);
|
|
21
|
+
const packageJsonPath = path.join(packageDir, PACKAGE_JSON);
|
|
22
|
+
const folderBasename = path.basename(packageDir);
|
|
23
|
+
const pkgStats = {
|
|
24
|
+
name: folderBasename,
|
|
25
|
+
path: packageDir,
|
|
26
|
+
jsModules: 0,
|
|
27
|
+
cssExports: 0,
|
|
28
|
+
customExports: 0,
|
|
29
|
+
totalExports: 0,
|
|
30
|
+
hasTransform: false,
|
|
31
|
+
cssConfigStatus: "",
|
|
32
|
+
skipped: false,
|
|
33
|
+
skipReason: "",
|
|
34
|
+
error: null
|
|
35
|
+
};
|
|
36
|
+
if (!fs.existsSync(packageJsonPath)) {
|
|
37
|
+
pkgStats.skipped = true;
|
|
38
|
+
pkgStats.skipReason = "package.json not found";
|
|
39
|
+
stats.packagesSkipped++;
|
|
40
|
+
logSkippedWorkspacePackage(logger, index, total, folderBasename, pkgStats.skipReason);
|
|
41
|
+
return pkgStats;
|
|
42
|
+
}
|
|
43
|
+
let packageJsonParseError;
|
|
44
|
+
try {
|
|
45
|
+
const pkgContent = await fs.readFile(packageJsonPath, "utf8");
|
|
46
|
+
const raw = JSON.parse(pkgContent);
|
|
47
|
+
if (raw === null || typeof raw !== "object" || Array.isArray(raw)) throw new SyntaxError("package.json root must be a JSON object");
|
|
48
|
+
pkgStats.name = resolvePackageDisplayName(raw, folderBasename);
|
|
49
|
+
} catch (caughtError) {
|
|
50
|
+
pkgStats.name = folderBasename;
|
|
51
|
+
packageJsonParseError = caughtError;
|
|
52
|
+
}
|
|
53
|
+
const pkgMeta = { packageName: pkgStats.name };
|
|
54
|
+
if (isPackageSkipped(config.skipPackages, pkgMeta)) {
|
|
55
|
+
pkgStats.skipped = true;
|
|
56
|
+
pkgStats.skipReason = "configured to skip";
|
|
57
|
+
stats.packagesSkipped++;
|
|
58
|
+
logSkippedWorkspacePackage(logger, index, total, pkgStats.name, pkgStats.skipReason);
|
|
59
|
+
return pkgStats;
|
|
60
|
+
}
|
|
61
|
+
if (packageJsonParseError !== void 0) {
|
|
62
|
+
if (!fs.existsSync(distDir)) {
|
|
63
|
+
pkgStats.skipped = true;
|
|
64
|
+
pkgStats.skipReason = "dist/ not found";
|
|
65
|
+
stats.packagesSkipped++;
|
|
66
|
+
logSkippedWorkspacePackage(logger, index, total, pkgStats.name, pkgStats.skipReason);
|
|
67
|
+
return pkgStats;
|
|
68
|
+
}
|
|
69
|
+
pkgStats.error = messageFromCaughtUnknown(packageJsonParseError);
|
|
70
|
+
stats.packagesErrored++;
|
|
71
|
+
logPackageError(logger, index, total, pkgStats.name, packageJsonParseError, verbose);
|
|
72
|
+
return pkgStats;
|
|
73
|
+
}
|
|
74
|
+
if (!fs.existsSync(distDir)) {
|
|
75
|
+
pkgStats.skipped = true;
|
|
76
|
+
pkgStats.skipReason = "dist/ not found";
|
|
77
|
+
stats.packagesSkipped++;
|
|
78
|
+
logSkippedWorkspacePackage(logger, index, total, pkgStats.name, pkgStats.skipReason);
|
|
79
|
+
return pkgStats;
|
|
80
|
+
}
|
|
81
|
+
try {
|
|
82
|
+
const pathTransform = createPathTransform(config, pkgMeta);
|
|
83
|
+
pkgStats.hasTransform = !!pathTransform;
|
|
84
|
+
const cssConfig = resolvePackageScopedConfig(config.cssExports, pkgMeta);
|
|
85
|
+
if (cssConfig === false) pkgStats.cssConfigStatus = "disabled";
|
|
86
|
+
else if (cssConfig !== void 0) pkgStats.cssConfigStatus = "configured";
|
|
87
|
+
const customExports = resolvePackageScopedConfig(config.customExports, pkgMeta) || {};
|
|
88
|
+
const generatedExports = await generateExports(fs, distDir, pathTransform, cssConfig, customExports);
|
|
89
|
+
await writePackageJsonExportsAtomic(fs, packageJsonPath, generatedExports.exports);
|
|
90
|
+
pkgStats.jsModules = generatedExports.jsCount;
|
|
91
|
+
pkgStats.cssExports = generatedExports.cssCount;
|
|
92
|
+
pkgStats.customExports = Object.keys(customExports).length;
|
|
93
|
+
pkgStats.totalExports = Object.keys(generatedExports.exports).length;
|
|
94
|
+
stats.packagesProcessed++;
|
|
95
|
+
stats.totalExports += pkgStats.totalExports;
|
|
96
|
+
stats.totalJsModules += pkgStats.jsModules;
|
|
97
|
+
stats.totalCssExports += pkgStats.cssExports;
|
|
98
|
+
logPackageSuccess(logger, index, total, pkgStats, generatedExports, verbose);
|
|
99
|
+
} catch (caughtError) {
|
|
100
|
+
pkgStats.error = messageFromCaughtUnknown(caughtError);
|
|
101
|
+
stats.packagesErrored++;
|
|
102
|
+
logPackageError(logger, index, total, pkgStats.name, caughtError, verbose);
|
|
103
|
+
}
|
|
104
|
+
return pkgStats;
|
|
105
|
+
}
|
|
106
|
+
/** @returns Process exit code (0 or 1). */
|
|
107
|
+
async function runMirrorSync(opts) {
|
|
108
|
+
const { fs, logger } = opts;
|
|
109
|
+
const config = opts.config ?? {};
|
|
110
|
+
configureMirrorColors(!!opts.noColor);
|
|
111
|
+
mirrorBanner(logger);
|
|
112
|
+
const startTime = performance.now();
|
|
113
|
+
const verbose = !!opts.verbose;
|
|
114
|
+
try {
|
|
115
|
+
const stats = {
|
|
116
|
+
packagesFound: 0,
|
|
117
|
+
packagesProcessed: 0,
|
|
118
|
+
packagesSkipped: 0,
|
|
119
|
+
packagesErrored: 0,
|
|
120
|
+
totalExports: 0,
|
|
121
|
+
totalJsModules: 0,
|
|
122
|
+
totalCssExports: 0,
|
|
123
|
+
packageDetails: []
|
|
124
|
+
};
|
|
125
|
+
let targetPackages = [];
|
|
126
|
+
if (opts.packageFilter) {
|
|
127
|
+
targetPackages = [resolvePackageFilterUnderRoot(opts.rootDir, opts.packageFilter)];
|
|
128
|
+
mirrorProcessingMode(logger, { kind: "single" });
|
|
129
|
+
} else {
|
|
130
|
+
const { relPaths, multiSource } = await findWorkspacePackageRelPaths(opts.rootDir, fs, logger);
|
|
131
|
+
targetPackages = relPaths;
|
|
132
|
+
mirrorProcessingMode(logger, {
|
|
133
|
+
kind: "multi",
|
|
134
|
+
source: multiSource
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
stats.packagesFound = targetPackages.length;
|
|
138
|
+
if (targetPackages.length === 0) {
|
|
139
|
+
mirrorNoPackages(logger);
|
|
140
|
+
return 0;
|
|
141
|
+
}
|
|
142
|
+
let nextPackageOrdinal = 1;
|
|
143
|
+
for (const pkgPath of targetPackages) {
|
|
144
|
+
const pkgStats = await syncExportsForWorkspacePackage(fs, logger, opts.rootDir, pkgPath, nextPackageOrdinal++, targetPackages.length, config, verbose, stats);
|
|
145
|
+
stats.packageDetails.push(pkgStats);
|
|
146
|
+
}
|
|
147
|
+
const elapsed = (performance.now() - startTime) / 1e3;
|
|
148
|
+
mirrorSummarySeparator(logger);
|
|
149
|
+
mirrorSummary(logger, stats, elapsed);
|
|
150
|
+
return stats.packagesErrored > 0 ? 1 : 0;
|
|
151
|
+
} catch (caughtError) {
|
|
152
|
+
mirrorFatalError(logger, caughtError);
|
|
153
|
+
return 1;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
//#endregion
|
|
157
|
+
export { runMirrorSync as t };
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { t as messageFromCaughtUnknown } from "./caught-unknown-message-CRhkDWO7.mjs";
|
|
2
|
+
import { t as loadConfig } from "./loader-DpN-zl5g.mjs";
|
|
3
|
+
import "./config-DVia_f9a.mjs";
|
|
4
|
+
import { t as printConfigSchemaWarnings } from "./config-reporter-SCcWDZc1.mjs";
|
|
5
|
+
import { n as createNodeCliLogger, t as createNodeCliFs } from "./node-io-DFRbHO6m.mjs";
|
|
6
|
+
import { t as findRepoRoot } from "./repo-root-HmtIEm6J.mjs";
|
|
7
|
+
import { r as runTagSync } from "./engine-CcWEHSCq.mjs";
|
|
8
|
+
import { a as formatWarningsAndErrors, i as formatTargetTable, r as formatSummary, t as createTagProgressListener } from "./tag-presenter-Cs66UBsH.mjs";
|
|
9
|
+
import "./tag-Cd9JujU5.mjs";
|
|
10
|
+
import process from "node:process";
|
|
11
|
+
import path from "node:path";
|
|
12
|
+
//#region src/commands/tag.ts
|
|
13
|
+
function resolveTagRootDir(fs, logger) {
|
|
14
|
+
try {
|
|
15
|
+
return findRepoRoot(fs);
|
|
16
|
+
} catch (caughtRepoRootError) {
|
|
17
|
+
logger.out(`[tag] workspace root auto-detection failed (${messageFromCaughtUnknown(caughtRepoRootError)}), using cwd=${process.cwd()}`);
|
|
18
|
+
return process.cwd();
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
function registerTagCommand(program) {
|
|
22
|
+
program.command("tag").alias("annotate").description("Add @since <version> JSDoc tags to exported declarations").argument("[target]", "Directory or file to annotate (default: auto-discover workspace packages)").option("--dry-run", "Show summary without writing files", false).action(async (target, options) => {
|
|
23
|
+
const fs = createNodeCliFs();
|
|
24
|
+
const logger = createNodeCliLogger();
|
|
25
|
+
const rootDir = resolveTagRootDir(fs, logger);
|
|
26
|
+
let tagConfig = {};
|
|
27
|
+
try {
|
|
28
|
+
const { config, warnings } = await loadConfig(fs, rootDir);
|
|
29
|
+
printConfigSchemaWarnings(logger, warnings);
|
|
30
|
+
tagConfig = config.tag ?? {};
|
|
31
|
+
} catch (caughtConfigError) {
|
|
32
|
+
logger.err(messageFromCaughtUnknown(caughtConfigError));
|
|
33
|
+
process.exitCode = 1;
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
const tagResult = await runTagSync({
|
|
37
|
+
rootDir,
|
|
38
|
+
config: tagConfig,
|
|
39
|
+
skipPackages: tagConfig.skipPackages,
|
|
40
|
+
targetPath: target ? path.resolve(target) : void 0,
|
|
41
|
+
write: !options.dryRun,
|
|
42
|
+
fs,
|
|
43
|
+
listener: createTagProgressListener((line) => logger.out(line))
|
|
44
|
+
});
|
|
45
|
+
logger.out(formatTargetTable(tagResult.selectedTargets, rootDir));
|
|
46
|
+
if (tagResult.selectedTargets.length === 0) {
|
|
47
|
+
logger.err("No packages found in workspace. Check your pnpm-workspace.yaml or provide an explicit target path.");
|
|
48
|
+
process.exitCode = 1;
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
const warningsAndErrorsSection = formatWarningsAndErrors(tagResult);
|
|
52
|
+
if (warningsAndErrorsSection) logger.err(warningsAndErrorsSection);
|
|
53
|
+
logger.out(formatSummary(tagResult));
|
|
54
|
+
process.exitCode = tagResult.targetResults.some((targetResult) => targetResult.runError !== null) || tagResult.hookError ? 1 : 0;
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
//#endregion
|
|
58
|
+
export { registerTagCommand as t };
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { n as withTagColor, t as TAG_COLORS } from "./colors-BjdkCfGK.mjs";
|
|
2
|
+
//#region src/lib/tag/presentation/tag-presenter.ts
|
|
3
|
+
function targetDisplayName(target) {
|
|
4
|
+
return target.packageName ?? target.rootRelativeTargetPath;
|
|
5
|
+
}
|
|
6
|
+
function warningsAndErrorsFromResult(result) {
|
|
7
|
+
const entries = [];
|
|
8
|
+
for (const targetResult of result.targetResults) if (targetResult.runError) entries.push(targetResult.runError);
|
|
9
|
+
if (result.hookError) entries.push(result.hookError);
|
|
10
|
+
return entries;
|
|
11
|
+
}
|
|
12
|
+
function formatProgress(event) {
|
|
13
|
+
if (event.type === "target-started") return `[tag] Processing ${targetDisplayName(event.target)}...`;
|
|
14
|
+
const changedFiles = event.result.result?.filesChanged ?? 0;
|
|
15
|
+
return `[tag] Done ${targetDisplayName(event.target)} (${changedFiles} changes)`;
|
|
16
|
+
}
|
|
17
|
+
function formatTargetTable(targets, rootDir) {
|
|
18
|
+
const packageColumnWidth = Math.max(7, ...targets.map((target) => (target.packageName ?? "-").length));
|
|
19
|
+
const pathColumnWidth = Math.max(4, ...targets.map((target) => target.rootRelativeTargetPath.length));
|
|
20
|
+
const lines = [];
|
|
21
|
+
lines.push(`[tag] Root: ${rootDir}`);
|
|
22
|
+
lines.push(`[tag] Resolved targets: ${targets.length}`);
|
|
23
|
+
lines.push("[tag] Targets:");
|
|
24
|
+
lines.push(` ${"package".padEnd(packageColumnWidth)} ${"path".padEnd(pathColumnWidth)} source`);
|
|
25
|
+
lines.push(` ${"-".repeat(packageColumnWidth)} ${"-".repeat(pathColumnWidth)} ${"-".repeat(6)}`);
|
|
26
|
+
for (const target of targets) lines.push(` ${(target.packageName ?? "-").padEnd(packageColumnWidth)} ${target.rootRelativeTargetPath.padEnd(pathColumnWidth)} ${target.source}`);
|
|
27
|
+
return lines.join("\n");
|
|
28
|
+
}
|
|
29
|
+
function formatWarningsAndErrors(result) {
|
|
30
|
+
const entries = warningsAndErrorsFromResult(result);
|
|
31
|
+
if (entries.length === 0) return null;
|
|
32
|
+
const lines = [withTagColor("⚠️ Warnings & Errors", TAG_COLORS.YELLOW)];
|
|
33
|
+
for (const entry of entries) lines.push(withTagColor(`- ${entry}`, TAG_COLORS.RED));
|
|
34
|
+
return lines.join("\n");
|
|
35
|
+
}
|
|
36
|
+
function formatSummary(result) {
|
|
37
|
+
const isDryRun = result.mode === "dry-run";
|
|
38
|
+
const summaryPrefix = isDryRun ? "[tag:dry-run]" : "[tag]";
|
|
39
|
+
const versionSuffix = result.versionSummary === "mixed" && result.distinctVersions.length > 0 ? ` [${result.distinctVersions.join(", ")}]` : "";
|
|
40
|
+
const summaryColor = result.targetResults.some((targetResult) => targetResult.runError !== null) || result.hookError !== null ? TAG_COLORS.RED : isDryRun ? TAG_COLORS.YELLOW : TAG_COLORS.GREEN;
|
|
41
|
+
const lines = [withTagColor(`${summaryPrefix} version=${result.versionSummary}${versionSuffix} files=${result.filesChanged}/${result.filesScanned} declarations=${result.taggedDeclarations}`, summaryColor)];
|
|
42
|
+
if (result.skippedPackages.length > 0) lines.push(`[tag] Skipped: ${result.skippedPackages.length} package(s)`);
|
|
43
|
+
return lines.join("\n");
|
|
44
|
+
}
|
|
45
|
+
function createTagProgressListener(onProgressLine) {
|
|
46
|
+
return {
|
|
47
|
+
onTargetStarted: (target) => {
|
|
48
|
+
onProgressLine(formatProgress({
|
|
49
|
+
type: "target-started",
|
|
50
|
+
target
|
|
51
|
+
}));
|
|
52
|
+
},
|
|
53
|
+
onTargetCompleted: (target, result) => {
|
|
54
|
+
onProgressLine(formatProgress({
|
|
55
|
+
type: "target-completed",
|
|
56
|
+
target,
|
|
57
|
+
result
|
|
58
|
+
}));
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
//#endregion
|
|
63
|
+
export { formatWarningsAndErrors as a, formatTargetTable as i, formatProgress as n, formatSummary as r, createTagProgressListener as t };
|