@codefast/cli 0.3.13-canary.0 → 0.3.13-canary.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (112) hide show
  1. package/dist/bin.mjs +1 -1
  2. package/dist/commands/arrange.mjs +106 -1
  3. package/dist/commands/mirror.mjs +65 -1
  4. package/dist/commands/tag.mjs +57 -1
  5. package/dist/lib/arrange/application/analyze.mjs +91 -1
  6. package/dist/lib/arrange/application/group-file.mjs +112 -1
  7. package/dist/lib/arrange/application/run-target.mjs +64 -1
  8. package/dist/lib/arrange/domain/ast/ast-helpers.mjs +114 -1
  9. package/dist/lib/arrange/domain/ast/collectors-cn.mjs +60 -1
  10. package/dist/lib/arrange/domain/ast/collectors-jsx.mjs +19 -1
  11. package/dist/lib/arrange/domain/ast/collectors-tv.mjs +169 -1
  12. package/dist/lib/arrange/domain/ast/targets.mjs +105 -1
  13. package/dist/lib/arrange/domain/constants.mjs +168 -1
  14. package/dist/lib/arrange/domain/errors.mjs +18 -1
  15. package/dist/lib/arrange/domain/grouping.mjs +234 -1
  16. package/dist/lib/arrange/domain/imports.mjs +53 -1
  17. package/dist/lib/arrange/domain/tokenizer.mjs +215 -1
  18. package/dist/lib/arrange/index.mjs +14 -15
  19. package/dist/lib/arrange/infra/walk.mjs +32 -1
  20. package/dist/lib/arrange/presentation/formatters.mjs +51 -1
  21. package/dist/lib/arrange/presentation/report.mjs +23 -1
  22. package/dist/lib/config/domain/schema.mjs +24 -1
  23. package/dist/lib/config/index.mjs +2 -3
  24. package/dist/lib/config/infra/loader.mjs +77 -1
  25. package/dist/lib/infra/caught-unknown-message.mjs +19 -1
  26. package/dist/lib/infra/config-reporter.mjs +9 -1
  27. package/dist/lib/infra/node-io.mjs +29 -1
  28. package/dist/lib/infra/workspace/repo-root.mjs +21 -1
  29. package/dist/lib/mirror/application/engine.mjs +247 -1
  30. package/dist/lib/mirror/application/sync.mjs +161 -1
  31. package/dist/lib/mirror/domain/constants.mjs +11 -1
  32. package/dist/lib/mirror/domain/errors.mjs +14 -1
  33. package/dist/lib/mirror/index.mjs +1 -2
  34. package/dist/lib/mirror/infra/dirent-list.mjs +13 -1
  35. package/dist/lib/mirror/infra/package-filter.mjs +25 -1
  36. package/dist/lib/mirror/infra/path-normalizer.mjs +6 -1
  37. package/dist/lib/mirror/infra/update-pkg.mjs +104 -1
  38. package/dist/lib/mirror/infra/workspace-packages.mjs +158 -1
  39. package/dist/lib/mirror/presentation/reporter.mjs +111 -2
  40. package/dist/lib/tag/application/engine.mjs +286 -1
  41. package/dist/lib/tag/index.mjs +3 -4
  42. package/dist/lib/tag/infra/target-resolver.mjs +169 -1
  43. package/dist/lib/tag/presentation/colors.mjs +11 -1
  44. package/dist/lib/tag/presentation/tag-presenter.mjs +62 -1
  45. package/dist/program.mjs +33 -1
  46. package/package.json +2 -2
  47. package/dist/analyze-DvtJ3j9m.mjs +0 -92
  48. package/dist/arrange-Bbh62DrU.mjs +0 -107
  49. package/dist/arrange-BqP2DI3w.mjs +0 -8
  50. package/dist/ast-helpers-MDRYuIAk.mjs +0 -115
  51. package/dist/caught-unknown-message-CRhkDWO7.mjs +0 -20
  52. package/dist/collectors-cn-BS8TTQ8O.mjs +0 -61
  53. package/dist/collectors-jsx-D9tL2ZPM.mjs +0 -20
  54. package/dist/collectors-tv-D2PXZaRt.mjs +0 -170
  55. package/dist/colors-BjdkCfGK.mjs +0 -12
  56. package/dist/commands/mirror.test.mjs +0 -48
  57. package/dist/config-DVia_f9a.mjs +0 -3
  58. package/dist/config-reporter-SCcWDZc1.mjs +0 -10
  59. package/dist/constants-AtPhF-Ct.mjs +0 -169
  60. package/dist/constants-Bq5wdyLC.mjs +0 -8
  61. package/dist/dirent-list-BSDeRG5i.mjs +0 -14
  62. package/dist/engine-CcWEHSCq.mjs +0 -287
  63. package/dist/engine-DRTdkc5u.mjs +0 -236
  64. package/dist/errors-CFH4w6ic.mjs +0 -15
  65. package/dist/errors-CpU1ogfA.mjs +0 -19
  66. package/dist/formatters-DGE8jJ53.mjs +0 -52
  67. package/dist/group-file-ClW7XdD6.mjs +0 -113
  68. package/dist/grouping-c1grpCQT.mjs +0 -235
  69. package/dist/imports-DSVq1xhB.mjs +0 -54
  70. package/dist/lib/arrange/application/analyze.test.mjs +0 -171
  71. package/dist/lib/arrange/application/group-file.test.mjs +0 -273
  72. package/dist/lib/arrange/application/run-target.test.mjs +0 -97
  73. package/dist/lib/arrange/domain/ast/ast-helpers.test.mjs +0 -148
  74. package/dist/lib/arrange/domain/ast/collectors-cn.test.mjs +0 -58
  75. package/dist/lib/arrange/domain/ast/collectors-jsx.test.mjs +0 -20
  76. package/dist/lib/arrange/domain/ast/collectors-tv.test.mjs +0 -145
  77. package/dist/lib/arrange/domain/ast/targets.test.mjs +0 -50
  78. package/dist/lib/arrange/domain/grouping.test.mjs +0 -186
  79. package/dist/lib/arrange/domain/imports.test.mjs +0 -48
  80. package/dist/lib/arrange/domain/tokenizer.test.mjs +0 -165
  81. package/dist/lib/arrange/infra/walk.test.mjs +0 -50
  82. package/dist/lib/arrange/presentation/formatters.test.mjs +0 -73
  83. package/dist/lib/config/infra/loader.test.mjs +0 -116
  84. package/dist/lib/infra/workspace/repo-root.test.mjs +0 -45
  85. package/dist/lib/mirror/application/sync.test.mjs +0 -482
  86. package/dist/lib/mirror/infra/dirent-list.test.mjs +0 -18
  87. package/dist/lib/mirror/infra/package-filter.test.mjs +0 -32
  88. package/dist/lib/mirror/infra/workspace-packages.test.mjs +0 -167
  89. package/dist/lib/tag/application/engine.test.mjs +0 -159
  90. package/dist/lib/tag/presentation/tag-presenter.test.mjs +0 -29
  91. package/dist/loader-DpN-zl5g.mjs +0 -78
  92. package/dist/mirror-CbGiLXKT.mjs +0 -2
  93. package/dist/mirror-DqJE3ejL.mjs +0 -66
  94. package/dist/node-io-DFRbHO6m.mjs +0 -30
  95. package/dist/package-filter-C_8ryqvz.mjs +0 -26
  96. package/dist/path-normalizer-D4ceBO3l.mjs +0 -7
  97. package/dist/program-DR-H4tH3.mjs +0 -34
  98. package/dist/repo-root-HmtIEm6J.mjs +0 -22
  99. package/dist/report-DYxvw34T.mjs +0 -24
  100. package/dist/reporter-CwIe_tAM.mjs +0 -108
  101. package/dist/run-target-CJWrqNT4.mjs +0 -65
  102. package/dist/schema-Or8RAARd.mjs +0 -25
  103. package/dist/sync-e1Sp-shi.mjs +0 -157
  104. package/dist/tag-Cd9JujU5.mjs +0 -2
  105. package/dist/tag-hEKVZ_-7.mjs +0 -58
  106. package/dist/tag-presenter-Cs66UBsH.mjs +0 -63
  107. package/dist/target-resolver-CR3FXMTy.mjs +0 -170
  108. package/dist/targets-pCTslnFh.mjs +0 -106
  109. package/dist/tokenizer-CeZx73Zu.mjs +0 -216
  110. package/dist/update-pkg-CnGfjWBy.mjs +0 -37
  111. package/dist/walk-DjgQn66n.mjs +0 -33
  112. package/dist/workspace-packages-K2NYTHJq.mjs +0 -159
@@ -1,167 +0,0 @@
1
- import { t as createNodeCliFs } from "../../../node-io-DFRbHO6m.mjs";
2
- import { i as workspacePatternToPackageJsonGlob, n as parsePnpmWorkspaceDocument, r as splitWorkspacePackageEntries, t as findWorkspacePackageRelPaths } from "../../../workspace-packages-K2NYTHJq.mjs";
3
- import fs from "node:fs";
4
- import path from "node:path";
5
- import os from "node:os";
6
- //#region src/lib/mirror/infra/workspace-packages.test.ts
7
- function createTestLogger() {
8
- const lines = [];
9
- return {
10
- lines,
11
- out: (line) => {
12
- lines.push(line);
13
- },
14
- err: (line) => {
15
- lines.push(`[err] ${line}`);
16
- }
17
- };
18
- }
19
- describe("splitWorkspacePackageEntries", () => {
20
- it("splits include and exclude entries", () => {
21
- expect(splitWorkspacePackageEntries([
22
- "packages/*",
23
- "!packages/playground",
24
- "apps/*"
25
- ])).toEqual({
26
- include: ["packages/*", "apps/*"],
27
- exclude: ["packages/playground"]
28
- });
29
- });
30
- it("ignores non-strings", () => {
31
- expect(splitWorkspacePackageEntries([
32
- "a",
33
- 1,
34
- null,
35
- "b"
36
- ])).toEqual({
37
- include: ["a", "b"],
38
- exclude: []
39
- });
40
- });
41
- });
42
- describe("parsePnpmWorkspaceDocument", () => {
43
- it("throws on non-object root", () => {
44
- expect(() => parsePnpmWorkspaceDocument([])).toThrow(/root must be a mapping/);
45
- expect(() => parsePnpmWorkspaceDocument("x")).toThrow(/root must be a mapping/);
46
- });
47
- it("throws when packages is not an array", () => {
48
- expect(() => parsePnpmWorkspaceDocument({ packages: "nope" })).toThrow(/must be an array/);
49
- });
50
- it("marks missing packages key", () => {
51
- expect(parsePnpmWorkspaceDocument({ catalog: {} })).toEqual({
52
- include: [],
53
- exclude: [],
54
- hasPackagesKey: false,
55
- isEmptyPackagesArray: false
56
- });
57
- });
58
- it("marks explicit empty array", () => {
59
- expect(parsePnpmWorkspaceDocument({ packages: [] })).toEqual({
60
- include: [],
61
- exclude: [],
62
- hasPackagesKey: true,
63
- isEmptyPackagesArray: true
64
- });
65
- });
66
- });
67
- describe("workspacePatternToPackageJsonGlob", () => {
68
- it("appends /package.json with POSIX slashes", () => {
69
- expect(workspacePatternToPackageJsonGlob("packages/*")).toBe("packages/*/package.json");
70
- expect(workspacePatternToPackageJsonGlob("packages/**")).toBe("packages/**/package.json");
71
- expect(workspacePatternToPackageJsonGlob("apps/*")).toBe("apps/*/package.json");
72
- });
73
- });
74
- describe("findWorkspacePackageRelPaths", () => {
75
- const cliFs = createNodeCliFs();
76
- it("falls back to packages/* when pnpm-workspace.yaml is missing", async () => {
77
- const root = fs.mkdtempSync(path.join(os.tmpdir(), "ws-missing-"));
78
- const logger = createTestLogger();
79
- try {
80
- fs.mkdirSync(path.join(root, "packages", "a"), { recursive: true });
81
- fs.writeFileSync(path.join(root, "packages", "a", "package.json"), "{}", "utf8");
82
- const { relPaths, multiSource } = await findWorkspacePackageRelPaths(root, cliFs, logger);
83
- expect(relPaths).toEqual(["packages/a"]);
84
- expect(multiSource).toBe("default-patterns");
85
- } finally {
86
- fs.rmSync(root, {
87
- recursive: true,
88
- force: true
89
- });
90
- }
91
- });
92
- it("reads globs from pnpm-workspace.yaml", async () => {
93
- const root = fs.mkdtempSync(path.join(os.tmpdir(), "ws-yaml-"));
94
- const logger = createTestLogger();
95
- try {
96
- fs.writeFileSync(path.join(root, "pnpm-workspace.yaml"), `packages:
97
- - 'tooling/*'
98
- - 'packages/*'
99
- `, "utf8");
100
- fs.mkdirSync(path.join(root, "tooling", "eslint"), { recursive: true });
101
- fs.writeFileSync(path.join(root, "tooling", "eslint", "package.json"), "{}", "utf8");
102
- fs.mkdirSync(path.join(root, "packages", "ui"), { recursive: true });
103
- fs.writeFileSync(path.join(root, "packages", "ui", "package.json"), "{}", "utf8");
104
- const { relPaths, multiSource } = await findWorkspacePackageRelPaths(root, cliFs, logger);
105
- expect(relPaths).toEqual(["packages/ui", "tooling/eslint"]);
106
- expect(multiSource).toBe("pnpm-workspace-yaml");
107
- } finally {
108
- fs.rmSync(root, {
109
- recursive: true,
110
- force: true
111
- });
112
- }
113
- });
114
- it("applies negated workspace patterns", async () => {
115
- const root = fs.mkdtempSync(path.join(os.tmpdir(), "ws-neg-"));
116
- const logger = createTestLogger();
117
- try {
118
- fs.writeFileSync(path.join(root, "pnpm-workspace.yaml"), `packages:
119
- - 'packages/*'
120
- - '!packages/skip'
121
- `, "utf8");
122
- for (const name of ["keep", "skip"]) {
123
- fs.mkdirSync(path.join(root, "packages", name), { recursive: true });
124
- fs.writeFileSync(path.join(root, "packages", name, "package.json"), "{}", "utf8");
125
- }
126
- const { relPaths, multiSource } = await findWorkspacePackageRelPaths(root, cliFs, logger);
127
- expect(relPaths).toEqual(["packages/keep"]);
128
- expect(multiSource).toBe("pnpm-workspace-yaml");
129
- } finally {
130
- fs.rmSync(root, {
131
- recursive: true,
132
- force: true
133
- });
134
- }
135
- });
136
- it("returns empty paths when packages is an explicit empty array", async () => {
137
- const root = fs.mkdtempSync(path.join(os.tmpdir(), "ws-empty-arr-"));
138
- const logger = createTestLogger();
139
- try {
140
- fs.writeFileSync(path.join(root, "pnpm-workspace.yaml"), `packages: []
141
- `, "utf8");
142
- const { relPaths, multiSource } = await findWorkspacePackageRelPaths(root, cliFs, logger);
143
- expect(relPaths).toEqual([]);
144
- expect(multiSource).toBe("declared-empty");
145
- } finally {
146
- fs.rmSync(root, {
147
- recursive: true,
148
- force: true
149
- });
150
- }
151
- });
152
- it("rejects invalid YAML document when file exists", async () => {
153
- const root = fs.mkdtempSync(path.join(os.tmpdir(), "ws-bad-yaml-"));
154
- const logger = createTestLogger();
155
- try {
156
- fs.writeFileSync(path.join(root, "pnpm-workspace.yaml"), "{ not yaml", "utf8");
157
- await expect(findWorkspacePackageRelPaths(root, cliFs, logger)).rejects.toThrow(/Failed to parse pnpm-workspace.yaml/);
158
- } finally {
159
- fs.rmSync(root, {
160
- recursive: true,
161
- force: true
162
- });
163
- }
164
- });
165
- });
166
- //#endregion
167
- export {};
@@ -1,159 +0,0 @@
1
- import { t as createNodeCliFs } from "../../../node-io-DFRbHO6m.mjs";
2
- import { n as runTagOnTarget, r as runTagSync, t as resolveNearestPackageVersion } from "../../../engine-CcWEHSCq.mjs";
3
- import "../../../tag-Cd9JujU5.mjs";
4
- import fs from "node:fs";
5
- import path from "node:path";
6
- import os from "node:os";
7
- //#region src/lib/tag/application/engine.test.ts
8
- const tagFs = createNodeCliFs();
9
- function withTempPackage(fileName, source, fn) {
10
- const rootDir = fs.mkdtempSync(path.join(os.tmpdir(), "tag-engine-"));
11
- const srcDir = path.join(rootDir, "src");
12
- const sourceFile = path.join(srcDir, fileName);
13
- try {
14
- fs.mkdirSync(srcDir, { recursive: true });
15
- fs.writeFileSync(path.join(rootDir, "package.json"), "{\"name\":\"demo\",\"version\":\"1.2.3\"}", "utf8");
16
- fs.writeFileSync(sourceFile, source, "utf8");
17
- fn({
18
- rootDir,
19
- sourceFile
20
- });
21
- } finally {
22
- fs.rmSync(rootDir, {
23
- recursive: true,
24
- force: true
25
- });
26
- }
27
- }
28
- describe("resolveNearestPackageVersion", () => {
29
- it("loads version from nearest package.json", () => {
30
- withTempPackage("index.ts", "export const foo = 1;\n", ({ sourceFile }) => {
31
- expect(resolveNearestPackageVersion(sourceFile, tagFs)).toBe("1.2.3");
32
- });
33
- });
34
- });
35
- describe("runTagOnTarget", () => {
36
- it("adds @since for exported declarations and preserves existing @since tags", () => {
37
- withTempPackage("index.ts", `/** Existing docs */
38
- export function a() {
39
- return 1;
40
- }
41
-
42
- /** @since 0.0.1 */
43
- export const b = 2;
44
-
45
- const c = 3;
46
- export { c };
47
- `, ({ sourceFile, rootDir }) => {
48
- const result = runTagOnTarget(path.join(rootDir, "src"), { write: true }, tagFs);
49
- const after = fs.readFileSync(sourceFile, "utf8");
50
- expect(result.version).toBe("1.2.3");
51
- expect(result.filesChanged).toBe(1);
52
- expect(result.taggedDeclarations).toBe(2);
53
- expect(after).toContain("* @since 1.2.3");
54
- expect(after).toContain("/** @since 0.0.1 */");
55
- expect(after).toContain("/**\n * @since 1.2.3\n */\nconst c = 3;");
56
- });
57
- });
58
- it("normalizes single-line JSDoc to multiline before appending @since", () => {
59
- withTempPackage("types.ts", `/** String or no-substitution template literal used as a Tailwind class blob. */
60
- export type TailwindClassBlob = string;
61
- `, ({ sourceFile, rootDir }) => {
62
- runTagOnTarget(path.join(rootDir, "src"), { write: true }, tagFs);
63
- const after = fs.readFileSync(sourceFile, "utf8");
64
- expect(after).toContain(`/**
65
- * String or no-substitution template literal used as a Tailwind class blob.
66
- *
67
- * @since 1.2.3
68
- */`);
69
- });
70
- });
71
- it("supports dry-run mode without changing files", () => {
72
- const before = "export interface User { id: string }\n";
73
- withTempPackage("types.ts", before, ({ sourceFile, rootDir }) => {
74
- const result = runTagOnTarget(path.join(rootDir, "src"), { write: false }, tagFs);
75
- const after = fs.readFileSync(sourceFile, "utf8");
76
- expect(result.filesChanged).toBe(1);
77
- expect(result.taggedDeclarations).toBe(1);
78
- expect(after).toBe(before);
79
- });
80
- });
81
- });
82
- describe("runTagSync", () => {
83
- it("auto-discovers workspace package src directories when no target is provided", async () => {
84
- const rootDir = fs.mkdtempSync(path.join(os.tmpdir(), "tag-workspace-"));
85
- const packageOneDir = path.join(rootDir, "packages", "one");
86
- const packageTwoDir = path.join(rootDir, "packages", "two");
87
- const packageOneSrcDir = path.join(packageOneDir, "src");
88
- const packageTwoSrcDir = path.join(packageTwoDir, "src");
89
- try {
90
- fs.mkdirSync(packageOneSrcDir, { recursive: true });
91
- fs.mkdirSync(packageTwoSrcDir, { recursive: true });
92
- fs.writeFileSync(path.join(rootDir, "pnpm-workspace.yaml"), "packages:\n - 'packages/*'\n", "utf8");
93
- fs.writeFileSync(path.join(packageOneDir, "package.json"), "{\"name\":\"one\",\"version\":\"1.0.0\"}", "utf8");
94
- fs.writeFileSync(path.join(packageTwoDir, "package.json"), "{\"name\":\"two\",\"version\":\"2.0.0\"}", "utf8");
95
- fs.writeFileSync(path.join(packageOneSrcDir, "index.ts"), "export const one = 1;\n", "utf8");
96
- fs.writeFileSync(path.join(packageTwoSrcDir, "index.ts"), "export const two = 2;\n", "utf8");
97
- const startedTargets = [];
98
- const completedTargets = [];
99
- const runResult = await runTagSync({
100
- rootDir,
101
- write: true,
102
- fs: tagFs,
103
- listener: {
104
- onTargetStarted: (target) => startedTargets.push(target.rootRelativeTargetPath),
105
- onTargetCompleted: (target) => completedTargets.push(target.rootRelativeTargetPath)
106
- }
107
- });
108
- expect(runResult.selectedTargets.length).toBe(2);
109
- expect(runResult.targetResults.every((entry) => entry.runError === null)).toBe(true);
110
- expect(fs.readFileSync(path.join(packageOneSrcDir, "index.ts"), "utf8")).toContain("* @since 1.0.0");
111
- expect(fs.readFileSync(path.join(packageTwoSrcDir, "index.ts"), "utf8")).toContain("* @since 2.0.0");
112
- expect(runResult.versionSummary).toBe("mixed");
113
- expect(runResult.distinctVersions).toEqual(["1.0.0", "2.0.0"]);
114
- expect(runResult.skippedPackages).toEqual([]);
115
- expect(runResult.filesChanged).toBe(2);
116
- expect(startedTargets.sort((left, right) => left.localeCompare(right))).toEqual(["packages/one/src", "packages/two/src"]);
117
- expect(completedTargets.sort((left, right) => left.localeCompare(right))).toEqual(["packages/one/src", "packages/two/src"]);
118
- } finally {
119
- fs.rmSync(rootDir, {
120
- recursive: true,
121
- force: true
122
- });
123
- }
124
- });
125
- it("skips workspace packages listed in skipPackages", async () => {
126
- const rootDir = fs.mkdtempSync(path.join(os.tmpdir(), "tag-workspace-skip-"));
127
- const packageOneDir = path.join(rootDir, "packages", "one");
128
- const packageTwoDir = path.join(rootDir, "packages", "two");
129
- const packageOneSrcDir = path.join(packageOneDir, "src");
130
- const packageTwoSrcDir = path.join(packageTwoDir, "src");
131
- try {
132
- fs.mkdirSync(packageOneSrcDir, { recursive: true });
133
- fs.mkdirSync(packageTwoSrcDir, { recursive: true });
134
- fs.writeFileSync(path.join(rootDir, "pnpm-workspace.yaml"), "packages:\n - 'packages/*'\n", "utf8");
135
- fs.writeFileSync(path.join(packageOneDir, "package.json"), "{\"name\":\"@scope/one\",\"version\":\"1.0.0\"}", "utf8");
136
- fs.writeFileSync(path.join(packageTwoDir, "package.json"), "{\"name\":\"@scope/two\",\"version\":\"2.0.0\"}", "utf8");
137
- fs.writeFileSync(path.join(packageOneSrcDir, "index.ts"), "export const one = 1;\n", "utf8");
138
- fs.writeFileSync(path.join(packageTwoSrcDir, "index.ts"), "export const two = 2;\n", "utf8");
139
- const runResult = await runTagSync({
140
- rootDir,
141
- write: true,
142
- fs: tagFs,
143
- skipPackages: ["@scope/two"]
144
- });
145
- expect(runResult.skippedPackages).toEqual(["@scope/two"]);
146
- expect(runResult.selectedTargets).toHaveLength(1);
147
- expect(runResult.selectedTargets[0]?.packageName).toBe("@scope/one");
148
- expect(fs.readFileSync(path.join(packageOneSrcDir, "index.ts"), "utf8")).toContain("* @since 1.0.0");
149
- expect(fs.readFileSync(path.join(packageTwoSrcDir, "index.ts"), "utf8")).not.toContain("* @since 2.0.0");
150
- } finally {
151
- fs.rmSync(rootDir, {
152
- recursive: true,
153
- force: true
154
- });
155
- }
156
- });
157
- });
158
- //#endregion
159
- export {};
@@ -1,29 +0,0 @@
1
- import { i as formatTargetTable } from "../../../tag-presenter-Cs66UBsH.mjs";
2
- //#region src/lib/tag/presentation/tag-presenter.test.ts
3
- describe("formatTargetTable", () => {
4
- it("aligns columns using longest package and path values", () => {
5
- const lines = formatTargetTable([{
6
- packageName: "@codefast/core",
7
- packageDir: "/repo/packages/core",
8
- rootRelativeTargetPath: "packages/core/src",
9
- targetPath: "/repo/packages/core/src",
10
- source: "workspace-package-selected-src"
11
- }, {
12
- packageName: "@codefast/benchmark-tailwind-variants",
13
- packageDir: "/repo/benchmarks/tailwind-variants",
14
- rootRelativeTargetPath: "benchmarks/tailwind-variants/src",
15
- targetPath: "/repo/benchmarks/tailwind-variants/src",
16
- source: "workspace-package-selected-src"
17
- }], "/repo").split("\n");
18
- const headerLine = lines[3];
19
- const firstDataLine = lines[5];
20
- const secondDataLine = lines[6];
21
- const pathHeaderIndex = headerLine.indexOf("path");
22
- const firstPathIndex = firstDataLine.indexOf("packages/core/src");
23
- const secondPathIndex = secondDataLine.indexOf("benchmarks/tailwind-variants/src");
24
- expect(firstPathIndex).toBe(pathHeaderIndex);
25
- expect(secondPathIndex).toBe(pathHeaderIndex);
26
- });
27
- });
28
- //#endregion
29
- export {};
@@ -1,78 +0,0 @@
1
- import { n as codefastConfigSchema } from "./schema-Or8RAARd.mjs";
2
- import process from "node:process";
3
- import path from "node:path";
4
- import jiti from "jiti";
5
- import { ZodError } from "zod";
6
- //#region src/lib/config/infra/loader.ts
7
- const CONFIG_JS_PRIORITY = [
8
- "codefast.config.mjs",
9
- "codefast.config.js",
10
- "codefast.config.cjs"
11
- ];
12
- const CONFIG_JSON = "codefast.config.json";
13
- const cachedLoads = /* @__PURE__ */ new Map();
14
- function formatZodError(error, filePath) {
15
- const formatted = error.issues.map((issue) => {
16
- return ` - ${issue.path.length > 0 ? issue.path.join(".") : "<root>"}: ${issue.message}`;
17
- }).join("\n");
18
- return `Invalid config schema in ${path.basename(filePath)}:\n${formatted}`;
19
- }
20
- function parseLoadedConfig(raw, filePath) {
21
- try {
22
- return codefastConfigSchema.parse(raw);
23
- } catch (caughtError) {
24
- if (caughtError instanceof ZodError) throw new Error(formatZodError(caughtError, filePath));
25
- throw caughtError;
26
- }
27
- }
28
- function listConfigCandidates(startDir, fs) {
29
- const candidates = [];
30
- let current = path.resolve(startDir);
31
- while (true) {
32
- for (const name of CONFIG_JS_PRIORITY) {
33
- const candidate = path.join(current, name);
34
- if (fs.existsSync(candidate)) candidates.push(candidate);
35
- }
36
- const jsonCandidate = path.join(current, CONFIG_JSON);
37
- if (fs.existsSync(jsonCandidate)) candidates.push(jsonCandidate);
38
- const parent = path.dirname(current);
39
- if (parent === current) break;
40
- current = parent;
41
- }
42
- return candidates;
43
- }
44
- async function readConfigFromPath(filePath, fs) {
45
- if (path.extname(filePath) === ".json") {
46
- const content = await fs.readFile(filePath, "utf8");
47
- return parseLoadedConfig(JSON.parse(content), filePath);
48
- }
49
- const moduleConfig = jiti(process.cwd(), {
50
- interopDefault: true,
51
- moduleCache: false
52
- })(filePath);
53
- return parseLoadedConfig(typeof moduleConfig === "object" && moduleConfig !== null && "default" in moduleConfig ? moduleConfig.default : moduleConfig, filePath);
54
- }
55
- async function loadOnce(fs, startDir) {
56
- const warnings = [];
57
- const configPaths = listConfigCandidates(startDir, fs);
58
- if (configPaths.length === 0) return {
59
- config: {},
60
- warnings
61
- };
62
- const configPath = configPaths[0];
63
- return {
64
- config: await readConfigFromPath(configPath, fs),
65
- warnings,
66
- configPath
67
- };
68
- }
69
- async function loadConfig(fs, startDir = process.cwd()) {
70
- const cacheKey = path.resolve(startDir);
71
- if (!cachedLoads.has(cacheKey)) cachedLoads.set(cacheKey, loadOnce(fs, cacheKey));
72
- return cachedLoads.get(cacheKey);
73
- }
74
- function resetConfigLoaderCacheForTests() {
75
- cachedLoads.clear();
76
- }
77
- //#endregion
78
- export { resetConfigLoaderCacheForTests as n, loadConfig as t };
@@ -1,2 +0,0 @@
1
- import "./sync-e1Sp-shi.mjs";
2
- export {};
@@ -1,66 +0,0 @@
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 { t as runMirrorSync } from "./sync-e1Sp-shi.mjs";
8
- import "./mirror-CbGiLXKT.mjs";
9
- import process from "node:process";
10
- import { realpathSync } from "node:fs";
11
- import path from "node:path";
12
- //#region src/commands/mirror.ts
13
- function tryRealpath(entryPath) {
14
- try {
15
- return realpathSync.native(entryPath);
16
- } catch {
17
- return path.resolve(entryPath);
18
- }
19
- }
20
- function normalizePath(relPath) {
21
- return relPath.split(path.sep).join("/").replace(/\\/g, "/");
22
- }
23
- function packageArgToRelative(rootDir, arg) {
24
- if (!arg) return void 0;
25
- const rootReal = tryRealpath(path.resolve(rootDir));
26
- const cwdReal = tryRealpath(process.cwd());
27
- const targetReal = tryRealpath(path.isAbsolute(arg) ? path.resolve(arg) : path.resolve(cwdReal, arg));
28
- const normalized = normalizePath(path.relative(rootReal, targetReal));
29
- if (normalized.startsWith("..") || path.isAbsolute(normalized) || normalized === "" || normalized === ".") throw new Error(`Package path must be a subdirectory under monorepo root: ${rootDir}`);
30
- return normalized;
31
- }
32
- function registerMirrorCommand(program) {
33
- program.command("mirror").description("Keep package manifests aligned with what you ship").command("sync").description("Write package.json exports from dist/ for workspace packages").argument("[package]", "Optional package path relative to repo root (e.g. packages/ui)").option("-v, --verbose", "Print extra diagnostics", false).action(async function(pkg, options) {
34
- const globals = this.optsWithGlobals();
35
- const fs = createNodeCliFs();
36
- const logger = createNodeCliLogger();
37
- const rootDir = findRepoRoot(fs);
38
- let packageFilter;
39
- try {
40
- packageFilter = packageArgToRelative(rootDir, pkg);
41
- } catch (caughtPathError) {
42
- this.error(messageFromCaughtUnknown(caughtPathError));
43
- return;
44
- }
45
- let mirrorConfig = {};
46
- try {
47
- const { config, warnings } = await loadConfig(fs, rootDir);
48
- printConfigSchemaWarnings(logger, warnings);
49
- mirrorConfig = config.mirror ?? {};
50
- } catch (caughtConfigError) {
51
- this.error(messageFromCaughtUnknown(caughtConfigError));
52
- return;
53
- }
54
- process.exitCode = await runMirrorSync({
55
- rootDir,
56
- config: mirrorConfig,
57
- verbose: options.verbose,
58
- noColor: globals.color === false,
59
- packageFilter,
60
- fs,
61
- logger
62
- });
63
- });
64
- }
65
- //#endregion
66
- export { registerMirrorCommand as n, packageArgToRelative as t };
@@ -1,30 +0,0 @@
1
- import process from "node:process";
2
- import fs from "node:fs";
3
- import fsPromises from "node:fs/promises";
4
- //#region src/lib/infra/node-io.ts
5
- function createNodeCliFs() {
6
- return {
7
- existsSync: fs.existsSync,
8
- statSync: fs.statSync,
9
- readFileSync: fs.readFileSync,
10
- writeFileSync: fs.writeFileSync,
11
- readdirSync: fs.readdirSync,
12
- readFile: (p, enc) => fsPromises.readFile(p, enc),
13
- writeFile: (p, data, enc) => fsPromises.writeFile(p, data, enc),
14
- readdir: (p, opts) => fsPromises.readdir(p, opts),
15
- rename: (oldPath, newPath) => fsPromises.rename(oldPath, newPath),
16
- unlink: (p) => fsPromises.unlink(p)
17
- };
18
- }
19
- function createNodeCliLogger() {
20
- return {
21
- out: (line) => {
22
- process.stdout.write(`${line}\n`);
23
- },
24
- err: (line) => {
25
- process.stderr.write(`${line}\n`);
26
- }
27
- };
28
- }
29
- //#endregion
30
- export { createNodeCliLogger as n, createNodeCliFs as t };
@@ -1,26 +0,0 @@
1
- import { t as normalizePath } from "./path-normalizer-D4ceBO3l.mjs";
2
- import { realpathSync } from "node:fs";
3
- import path from "node:path";
4
- //#region src/lib/mirror/infra/package-filter.ts
5
- function tryRealpath(entryPath) {
6
- try {
7
- return realpathSync.native(entryPath);
8
- } catch {
9
- return path.resolve(entryPath);
10
- }
11
- }
12
- /**
13
- * Resolve `packageFilter` to a POSIX-ish path relative to `rootDir`, without using
14
- * `process.cwd()`. Use for programmatic `runMirrorSync` calls.
15
- *
16
- * @throws If the resolved path is not a strict subdirectory of `rootDir`.
17
- */
18
- function resolvePackageFilterUnderRoot(rootDir, packageFilter) {
19
- const rootReal = tryRealpath(path.resolve(rootDir));
20
- const resolved = path.isAbsolute(packageFilter) ? tryRealpath(path.resolve(packageFilter)) : tryRealpath(path.join(rootReal, packageFilter));
21
- const normalized = normalizePath(path.relative(rootReal, resolved));
22
- if (normalized.startsWith("..") || path.isAbsolute(normalized) || normalized === "" || normalized === ".") throw new Error(`Package path must be a subdirectory under monorepo root: ${rootDir}`);
23
- return normalized;
24
- }
25
- //#endregion
26
- export { resolvePackageFilterUnderRoot as t };
@@ -1,7 +0,0 @@
1
- import path from "node:path";
2
- //#region src/lib/mirror/infra/path-normalizer.ts
3
- function normalizePath(pathString) {
4
- return pathString.split(path.sep).join("/").replace(/\\/g, "/");
5
- }
6
- //#endregion
7
- export { normalizePath as t };
@@ -1,34 +0,0 @@
1
- import { t as registerArrangeCommand } from "./arrange-Bbh62DrU.mjs";
2
- import { n as registerMirrorCommand } from "./mirror-DqJE3ejL.mjs";
3
- import { t as registerTagCommand } from "./tag-hEKVZ_-7.mjs";
4
- import process from "node:process";
5
- import { readFileSync } from "node:fs";
6
- import path from "node:path";
7
- import { fileURLToPath } from "node:url";
8
- import { Command } from "commander";
9
- //#region src/program.ts
10
- function readVersion() {
11
- try {
12
- const dir = path.dirname(fileURLToPath(import.meta.url));
13
- const raw = readFileSync(path.join(dir, "..", "package.json"), "utf-8");
14
- const pkgVersion = JSON.parse(raw).version;
15
- return typeof pkgVersion === "string" && pkgVersion.length > 0 ? pkgVersion : "unknown";
16
- } catch {
17
- return "unknown";
18
- }
19
- }
20
- function createProgram() {
21
- const program = new Command();
22
- program.name("codefast").description("Codefast monorepo developer CLI").version(readVersion()).option("--no-color", "Disable ANSI color output").configureHelp({ sortSubcommands: true }).showHelpAfterError("(use --help for usage)");
23
- registerMirrorCommand(program);
24
- registerArrangeCommand(program);
25
- registerTagCommand(program);
26
- return program;
27
- }
28
- async function runCli(argv) {
29
- await createProgram().parseAsync(argv, { from: "node" });
30
- const code = process.exitCode ?? 0;
31
- return typeof code === "number" ? code : Number(code) || 0;
32
- }
33
- //#endregion
34
- export { runCli as n, createProgram as t };
@@ -1,22 +0,0 @@
1
- import path from "node:path";
2
- import { fileURLToPath } from "node:url";
3
- //#region src/lib/infra/workspace/repo-root.ts
4
- /**
5
- * Resolve the monorepo root (directory containing `pnpm-workspace.yaml`).
6
- * Tries the compiled package location first, then `process.cwd()`.
7
- */
8
- function findRepoRoot(fs) {
9
- const candidates = [path.dirname(fileURLToPath(import.meta.url)), process.cwd()];
10
- for (const start of candidates) {
11
- let dir = path.resolve(start);
12
- for (;;) {
13
- if (fs.existsSync(path.join(dir, "pnpm-workspace.yaml"))) return dir;
14
- const parent = path.dirname(dir);
15
- if (parent === dir) break;
16
- dir = parent;
17
- }
18
- }
19
- throw new Error(`Could not locate monorepo root (missing pnpm-workspace.yaml). Searched from: ${candidates.join(", ")}`);
20
- }
21
- //#endregion
22
- export { findRepoRoot as t };
@@ -1,24 +0,0 @@
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 };