@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,482 +0,0 @@
1
- import { n as createNodeCliLogger, t as createNodeCliFs } from "../../../node-io-DFRbHO6m.mjs";
2
- import { t as runMirrorSync } from "../../../sync-e1Sp-shi.mjs";
3
- import path from "node:path";
4
- import fsPromises from "node:fs/promises";
5
- import os from "node:os";
6
- //#region src/lib/mirror/application/sync.test.ts
7
- async function mkdirp(filePath) {
8
- await fsPromises.mkdir(path.dirname(filePath), { recursive: true });
9
- }
10
- async function writeText(filePath, content) {
11
- await mkdirp(filePath);
12
- await fsPromises.writeFile(filePath, content, "utf8");
13
- }
14
- async function writeJson(filePath, jsonPayload) {
15
- await mkdirp(filePath);
16
- await fsPromises.writeFile(filePath, JSON.stringify(jsonPayload, null, 2) + "\n", "utf8");
17
- }
18
- async function makeTempRoot() {
19
- return fsPromises.mkdtemp(path.join(os.tmpdir(), "mirror-sync-"));
20
- }
21
- const mirrorFs = createNodeCliFs();
22
- const mirrorLogger = createNodeCliLogger();
23
- async function runMirrorSyncWithNodeDependencies(options) {
24
- return runMirrorSync({
25
- ...options,
26
- fs: mirrorFs,
27
- logger: mirrorLogger
28
- });
29
- }
30
- describe("runMirrorSync (integration)", () => {
31
- const stdoutChunks = [];
32
- const stderrChunks = [];
33
- beforeEach(() => {
34
- stdoutChunks.length = 0;
35
- stderrChunks.length = 0;
36
- jest.spyOn(process.stdout, "write").mockImplementation((chunk) => {
37
- stdoutChunks.push(typeof chunk === "string" ? chunk : Buffer.from(chunk).toString("utf8"));
38
- return true;
39
- });
40
- jest.spyOn(process.stderr, "write").mockImplementation((chunk) => {
41
- stderrChunks.push(typeof chunk === "string" ? chunk : Buffer.from(chunk).toString("utf8"));
42
- return true;
43
- });
44
- });
45
- afterEach(() => {
46
- jest.restoreAllMocks();
47
- });
48
- function joinedStdout() {
49
- return stdoutChunks.join("");
50
- }
51
- it("writes exports for a package with index.js + index.d.ts (+ optional .cjs)", async () => {
52
- const root = await makeTempRoot();
53
- const rel = "packages/widget";
54
- const pkgDir = path.join(root, rel);
55
- await writeJson(path.join(pkgDir, "package.json"), {
56
- name: "@fixture/widget",
57
- version: "0.0.0"
58
- });
59
- await writeText(path.join(pkgDir, "dist/index.js"), "export {};\n");
60
- await writeText(path.join(pkgDir, "dist/index.d.ts"), "export {};\n");
61
- await writeText(path.join(pkgDir, "dist/index.cjs"), "module.exports = {};\n");
62
- const code = await runMirrorSyncWithNodeDependencies({
63
- rootDir: root,
64
- noColor: true,
65
- packageFilter: rel
66
- });
67
- expect(code).toBe(0);
68
- const pkg = JSON.parse(await fsPromises.readFile(path.join(pkgDir, "package.json"), "utf8"));
69
- expect(pkg.exports["./package.json"]).toBe("./package.json");
70
- expect(pkg.exports["."]).toEqual({
71
- types: "./dist/index.d.ts",
72
- import: "./dist/index.js",
73
- require: "./dist/index.cjs"
74
- });
75
- expect(joinedStdout().includes(String.fromCharCode(27))).toBe(false);
76
- });
77
- it("applies pathTransformations from injected config", async () => {
78
- const root = await makeTempRoot();
79
- const rel = "packages/ui-bridge";
80
- const pkgDir = path.join(root, rel);
81
- await writeJson(path.join(pkgDir, "package.json"), {
82
- name: "@fixture/bridge",
83
- version: "0.0.0"
84
- });
85
- await writeText(path.join(pkgDir, "dist/internal/foo.js"), "export const x = 1;\n");
86
- await writeText(path.join(pkgDir, "dist/internal/foo.d.ts"), "export declare const x: number;\n");
87
- const code = await runMirrorSyncWithNodeDependencies({
88
- rootDir: root,
89
- noColor: true,
90
- packageFilter: rel,
91
- config: { pathTransformations: { "@fixture/bridge": { removePrefix: "./internal/" } } }
92
- });
93
- expect(code).toBe(0);
94
- const pkg = JSON.parse(await fsPromises.readFile(path.join(pkgDir, "package.json"), "utf8"));
95
- expect(pkg.exports["./foo"]).toBeDefined();
96
- expect(pkg.exports["./internal/foo"]).toBeUndefined();
97
- expect(joinedStdout()).toContain("@fixture/bridge");
98
- expect(joinedStdout()).not.toContain("ui-bridge");
99
- });
100
- it("ignores pathTransformations keyed by workspace-relative path (package name only)", async () => {
101
- const root = await makeTempRoot();
102
- const rel = "packages/ui-bridge";
103
- const pkgDir = path.join(root, rel);
104
- await writeJson(path.join(pkgDir, "package.json"), {
105
- name: "@fixture/bridge",
106
- version: "0.0.0"
107
- });
108
- await writeText(path.join(pkgDir, "dist/internal/foo.js"), "export const x = 1;\n");
109
- await writeText(path.join(pkgDir, "dist/internal/foo.d.ts"), "export declare const x: number;\n");
110
- const code = await runMirrorSyncWithNodeDependencies({
111
- rootDir: root,
112
- noColor: true,
113
- packageFilter: rel,
114
- config: { pathTransformations: { [rel]: { removePrefix: "./internal/" } } }
115
- });
116
- expect(code).toBe(0);
117
- const pkg = JSON.parse(await fsPromises.readFile(path.join(pkgDir, "package.json"), "utf8"));
118
- expect(pkg.exports["./internal/foo"]).toBeDefined();
119
- expect(pkg.exports["./foo"]).toBeUndefined();
120
- });
121
- it("merges customExports for the package", async () => {
122
- const root = await makeTempRoot();
123
- const rel = "packages/custom";
124
- const pkgDir = path.join(root, rel);
125
- await writeJson(path.join(pkgDir, "package.json"), {
126
- name: "@fixture/custom",
127
- version: "0.0.0"
128
- });
129
- await writeText(path.join(pkgDir, "dist/index.js"), "export {};\n");
130
- await writeText(path.join(pkgDir, "dist/index.d.ts"), "export {};\n");
131
- const code = await runMirrorSyncWithNodeDependencies({
132
- rootDir: root,
133
- noColor: true,
134
- packageFilter: rel,
135
- config: { customExports: { "@fixture/custom": { "./extra": "./dist/extra.json" } } }
136
- });
137
- expect(code).toBe(0);
138
- const pkg = JSON.parse(await fsPromises.readFile(path.join(pkgDir, "package.json"), "utf8"));
139
- expect(pkg.exports["./extra"]).toBe("./dist/extra.json");
140
- expect(pkg.exports["."]).toBeDefined();
141
- });
142
- it("emits CSS wildcard exports for a css-only subfolder when cssExports is enabled", async () => {
143
- const root = await makeTempRoot();
144
- const rel = "packages/styles";
145
- const pkgDir = path.join(root, rel);
146
- await writeJson(path.join(pkgDir, "package.json"), {
147
- name: "@fixture/styles",
148
- version: "0.0.0"
149
- });
150
- await writeText(path.join(pkgDir, "dist/index.js"), "export {};\n");
151
- await writeText(path.join(pkgDir, "dist/index.d.ts"), "export {};\n");
152
- await writeText(path.join(pkgDir, "dist/theme/a.css"), "a {}\n");
153
- await writeText(path.join(pkgDir, "dist/theme/b.css"), "b {}\n");
154
- const code = await runMirrorSyncWithNodeDependencies({
155
- rootDir: root,
156
- noColor: true,
157
- packageFilter: rel,
158
- config: { cssExports: { "@fixture/styles": { enabled: true } } }
159
- });
160
- expect(code).toBe(0);
161
- const pkg = JSON.parse(await fsPromises.readFile(path.join(pkgDir, "package.json"), "utf8"));
162
- expect(pkg.exports["./theme/*"]).toBe("./dist/theme/*");
163
- });
164
- it("uses per-file CSS exports when forceExportFiles is set", async () => {
165
- const root = await makeTempRoot();
166
- const rel = "packages/styles-force";
167
- const pkgDir = path.join(root, rel);
168
- await writeJson(path.join(pkgDir, "package.json"), {
169
- name: "@fixture/styles2",
170
- version: "0.0.0"
171
- });
172
- await writeText(path.join(pkgDir, "dist/index.js"), "export {};\n");
173
- await writeText(path.join(pkgDir, "dist/index.d.ts"), "export {};\n");
174
- await writeText(path.join(pkgDir, "dist/blocks/x.css"), "x {}\n");
175
- await writeText(path.join(pkgDir, "dist/blocks/y.css"), "y {}\n");
176
- const code = await runMirrorSyncWithNodeDependencies({
177
- rootDir: root,
178
- noColor: true,
179
- packageFilter: rel,
180
- config: { cssExports: { "@fixture/styles2": {
181
- enabled: true,
182
- forceExportFiles: true
183
- } } }
184
- });
185
- expect(code).toBe(0);
186
- const pkg = JSON.parse(await fsPromises.readFile(path.join(pkgDir, "package.json"), "utf8"));
187
- expect(pkg.exports["./blocks/x.css"]).toBe("./dist/blocks/x.css");
188
- expect(pkg.exports["./blocks/y.css"]).toBe("./dist/blocks/y.css");
189
- expect(pkg.exports["./blocks/*"]).toBeUndefined();
190
- });
191
- it("skips CSS generation when cssExports is false for that package", async () => {
192
- const root = await makeTempRoot();
193
- const rel = "packages/no-css";
194
- const pkgDir = path.join(root, rel);
195
- await writeJson(path.join(pkgDir, "package.json"), {
196
- name: "@fixture/nocss",
197
- version: "0.0.0"
198
- });
199
- await writeText(path.join(pkgDir, "dist/index.js"), "export {};\n");
200
- await writeText(path.join(pkgDir, "dist/index.d.ts"), "export {};\n");
201
- await writeText(path.join(pkgDir, "dist/root.css"), "r {}\n");
202
- const code = await runMirrorSyncWithNodeDependencies({
203
- rootDir: root,
204
- noColor: true,
205
- packageFilter: rel,
206
- verbose: true,
207
- config: { cssExports: { "@fixture/nocss": false } }
208
- });
209
- expect(code).toBe(0);
210
- const pkg = JSON.parse(await fsPromises.readFile(path.join(pkgDir, "package.json"), "utf8"));
211
- expect(pkg.exports["./root.css"]).toBeUndefined();
212
- expect(joinedStdout()).toContain("CSS disabled");
213
- });
214
- it("skips packages listed in skipPackages", async () => {
215
- const root = await makeTempRoot();
216
- const rel = "packages/skipped-one";
217
- const pkgDir = path.join(root, rel);
218
- await writeJson(path.join(pkgDir, "package.json"), {
219
- name: "@fixture/skip",
220
- version: "0.0.0"
221
- });
222
- await writeText(path.join(pkgDir, "dist/index.js"), "export {};\n");
223
- await writeText(path.join(pkgDir, "dist/index.d.ts"), "export {};\n");
224
- const code = await runMirrorSyncWithNodeDependencies({
225
- rootDir: root,
226
- noColor: true,
227
- packageFilter: rel,
228
- config: { skipPackages: ["@fixture/skip"] }
229
- });
230
- expect(code).toBe(0);
231
- const raw = await fsPromises.readFile(path.join(pkgDir, "package.json"), "utf8");
232
- const pkg = JSON.parse(raw);
233
- expect(pkg.exports).toBeUndefined();
234
- expect(joinedStdout()).toContain("Skipped");
235
- expect(joinedStdout()).toContain("@fixture/skip");
236
- });
237
- it("applies skipPackages before dist/ existence (skipped package without dist/)", async () => {
238
- const root = await makeTempRoot();
239
- const rel = "packages/skip-no-dist";
240
- const pkgDir = path.join(root, rel);
241
- await writeJson(path.join(pkgDir, "package.json"), {
242
- name: "@fixture/skip-nodist",
243
- version: "0.0.0"
244
- });
245
- const code = await runMirrorSyncWithNodeDependencies({
246
- rootDir: root,
247
- noColor: true,
248
- packageFilter: rel,
249
- config: { skipPackages: ["@fixture/skip-nodist"] }
250
- });
251
- expect(code).toBe(0);
252
- const raw = await fsPromises.readFile(path.join(pkgDir, "package.json"), "utf8");
253
- const pkg = JSON.parse(raw);
254
- expect(pkg.exports).toBeUndefined();
255
- const out = joinedStdout();
256
- expect(out).toContain("Skipped");
257
- expect(out).toContain("configured to skip");
258
- expect(out).toContain("@fixture/skip-nodist");
259
- expect(out).not.toContain("dist/ not found");
260
- });
261
- it("skips when package.json is missing", async () => {
262
- const root = await makeTempRoot();
263
- const rel = "packages/nopkg";
264
- const pkgDir = path.join(root, rel);
265
- await writeText(path.join(pkgDir, "dist/index.js"), "export {};\n");
266
- const code = await runMirrorSyncWithNodeDependencies({
267
- rootDir: root,
268
- noColor: true,
269
- packageFilter: rel
270
- });
271
- expect(code).toBe(0);
272
- expect(joinedStdout()).toContain("package.json not found");
273
- });
274
- it("skips when dist/ is missing", async () => {
275
- const root = await makeTempRoot();
276
- const rel = "packages/nodist";
277
- const pkgDir = path.join(root, rel);
278
- await writeJson(path.join(pkgDir, "package.json"), {
279
- name: "@fixture/nodist",
280
- version: "0.0.0"
281
- });
282
- const code = await runMirrorSyncWithNodeDependencies({
283
- rootDir: root,
284
- noColor: true,
285
- packageFilter: rel
286
- });
287
- expect(code).toBe(0);
288
- expect(joinedStdout()).toContain("dist/ not found");
289
- expect(joinedStdout()).toContain("@fixture/nodist");
290
- });
291
- it("returns 0 when no workspace packages match discovery globs", async () => {
292
- const code = await runMirrorSyncWithNodeDependencies({
293
- rootDir: await makeTempRoot(),
294
- noColor: true
295
- });
296
- expect(code).toBe(0);
297
- expect(joinedStdout()).toContain("No packages found");
298
- });
299
- it("discovers packages under packages/ via default glob when pnpm-workspace.yaml is absent", async () => {
300
- const root = await makeTempRoot();
301
- for (const name of ["alpha", "beta"]) {
302
- const rel = path.join("packages", name);
303
- const pkgDir = path.join(root, rel);
304
- await writeJson(path.join(pkgDir, "package.json"), {
305
- name: `@fixture/${name}`,
306
- version: "0.0.0"
307
- });
308
- await writeText(path.join(pkgDir, "dist/index.js"), "export {};\n");
309
- await writeText(path.join(pkgDir, "dist/index.d.ts"), "export {};\n");
310
- }
311
- const code = await runMirrorSyncWithNodeDependencies({
312
- rootDir: root,
313
- noColor: true
314
- });
315
- expect(code).toBe(0);
316
- expect(joinedStdout()).toContain("default patterns");
317
- expect(joinedStdout()).toContain("@fixture/alpha");
318
- expect(joinedStdout()).toContain("@fixture/beta");
319
- });
320
- it("discovers packages from explicit pnpm-workspace.yaml globs (e.g. apps/* and packages/*)", async () => {
321
- const root = await makeTempRoot();
322
- await writeText(path.join(root, "pnpm-workspace.yaml"), `packages:
323
- - 'apps/*'
324
- - 'packages/*'
325
- `);
326
- for (const [rel, nm] of [["apps/web", "@fixture/web"], ["packages/lib", "@fixture/lib"]]) {
327
- const pkgDir = path.join(root, rel);
328
- await writeJson(path.join(pkgDir, "package.json"), {
329
- name: nm,
330
- version: "0.0.0"
331
- });
332
- await writeText(path.join(pkgDir, "dist/index.js"), "export {};\n");
333
- await writeText(path.join(pkgDir, "dist/index.d.ts"), "export {};\n");
334
- }
335
- const code = await runMirrorSyncWithNodeDependencies({
336
- rootDir: root,
337
- noColor: true
338
- });
339
- expect(code).toBe(0);
340
- expect(joinedStdout()).toContain("from pnpm-workspace.yaml");
341
- expect(joinedStdout()).toContain("@fixture/web");
342
- expect(joinedStdout()).toContain("@fixture/lib");
343
- });
344
- it("skips packages excluded with ! in pnpm-workspace.yaml", async () => {
345
- const root = await makeTempRoot();
346
- await writeText(path.join(root, "pnpm-workspace.yaml"), `packages:
347
- - 'packages/*'
348
- - '!packages/ignored'
349
- `);
350
- for (const name of ["kept", "ignored"]) {
351
- const rel = path.join("packages", name);
352
- const pkgDir = path.join(root, rel);
353
- await writeJson(path.join(pkgDir, "package.json"), {
354
- name: `@fixture/${name}`,
355
- version: "0.0.0",
356
- exports: { "./only": "./dist/only.json" }
357
- });
358
- await writeText(path.join(pkgDir, "dist/index.js"), "export {};\n");
359
- await writeText(path.join(pkgDir, "dist/index.d.ts"), "export {};\n");
360
- }
361
- const code = await runMirrorSyncWithNodeDependencies({
362
- rootDir: root,
363
- noColor: true
364
- });
365
- expect(code).toBe(0);
366
- expect(joinedStdout()).toContain("@fixture/kept");
367
- expect(joinedStdout()).not.toContain("@fixture/ignored");
368
- const ignoredRaw = await fsPromises.readFile(path.join(root, "packages", "ignored", "package.json"), "utf8");
369
- const ignoredPkg = JSON.parse(ignoredRaw);
370
- expect(ignoredPkg.exports).toEqual({ "./only": "./dist/only.json" });
371
- });
372
- it("returns exit code 1 when package.json is invalid JSON", async () => {
373
- const root = await makeTempRoot();
374
- const rel = "packages/broken";
375
- const pkgDir = path.join(root, rel);
376
- await writeText(path.join(pkgDir, "package.json"), "{ not json");
377
- await writeText(path.join(pkgDir, "dist/index.js"), "export {};\n");
378
- await writeText(path.join(pkgDir, "dist/index.d.ts"), "export {};\n");
379
- const code = await runMirrorSyncWithNodeDependencies({
380
- rootDir: root,
381
- noColor: true,
382
- packageFilter: rel,
383
- verbose: true
384
- });
385
- expect(code).toBe(1);
386
- expect(joinedStdout()).toContain("Error");
387
- expect(stderrChunks.join("")).toBeTruthy();
388
- });
389
- it("only leaves ./package.json export when dist has no valid JS modules", async () => {
390
- const root = await makeTempRoot();
391
- const rel = "packages/empty-modules";
392
- const pkgDir = path.join(root, rel);
393
- await writeJson(path.join(pkgDir, "package.json"), {
394
- name: "@fixture/empty",
395
- version: "0.0.0"
396
- });
397
- await writeText(path.join(pkgDir, "dist/readme.txt"), "noop\n");
398
- const code = await runMirrorSyncWithNodeDependencies({
399
- rootDir: root,
400
- noColor: true,
401
- packageFilter: rel
402
- });
403
- expect(code).toBe(0);
404
- const pkg = JSON.parse(await fsPromises.readFile(path.join(pkgDir, "package.json"), "utf8"));
405
- expect(Object.keys(pkg.exports)).toEqual(["./package.json"]);
406
- });
407
- it("uses folder basename in logs when package.json is invalid JSON while skipping missing dist", async () => {
408
- const root = await makeTempRoot();
409
- const rel = "packages/bad-json-nodist";
410
- const pkgDir = path.join(root, rel);
411
- await writeText(path.join(pkgDir, "package.json"), "{ not json");
412
- const code = await runMirrorSyncWithNodeDependencies({
413
- rootDir: root,
414
- noColor: true,
415
- packageFilter: rel
416
- });
417
- expect(code).toBe(0);
418
- expect(joinedStdout()).toContain("dist/ not found");
419
- expect(joinedStdout()).toContain("bad-json-nodist");
420
- });
421
- it("fails fast when pnpm-workspace.yaml exists but is invalid YAML", async () => {
422
- const root = await makeTempRoot();
423
- await writeText(path.join(root, "pnpm-workspace.yaml"), "packages:\n - [\n");
424
- const code = await runMirrorSyncWithNodeDependencies({
425
- rootDir: root,
426
- noColor: true
427
- });
428
- expect(code).toBe(1);
429
- expect(joinedStdout()).toContain("Fatal error");
430
- expect(joinedStdout()).toMatch(/pnpm-workspace\.yaml|Failed to parse/i);
431
- });
432
- it("treats packages: [] as no workspace packages", async () => {
433
- const root = await makeTempRoot();
434
- await writeText(path.join(root, "pnpm-workspace.yaml"), "packages: []\n");
435
- const code = await runMirrorSyncWithNodeDependencies({
436
- rootDir: root,
437
- noColor: true
438
- });
439
- expect(code).toBe(0);
440
- expect(joinedStdout()).toContain("empty workspace package list");
441
- expect(joinedStdout()).toContain("No packages found");
442
- });
443
- it("fails fast when pnpm-workspace.yaml packages is not an array", async () => {
444
- const root = await makeTempRoot();
445
- await writeText(path.join(root, "pnpm-workspace.yaml"), `packages: "oops"
446
- `);
447
- const code = await runMirrorSyncWithNodeDependencies({
448
- rootDir: root,
449
- noColor: true
450
- });
451
- expect(code).toBe(1);
452
- expect(joinedStdout()).toContain("Fatal error");
453
- expect(joinedStdout()).toMatch(/packages.*must be an array/i);
454
- });
455
- it("resolves packageFilter relative to rootDir when cwd differs (API)", async () => {
456
- const root = await makeTempRoot();
457
- const rel = "packages/api-cwd";
458
- const pkgDir = path.join(root, rel);
459
- await writeJson(path.join(pkgDir, "package.json"), {
460
- name: "@fixture/api-cwd",
461
- version: "0.0.0"
462
- });
463
- await writeText(path.join(pkgDir, "dist/index.js"), "export {};\n");
464
- await writeText(path.join(pkgDir, "dist/index.d.ts"), "export {};\n");
465
- const prev = process.cwd();
466
- try {
467
- process.chdir(os.tmpdir());
468
- const code = await runMirrorSyncWithNodeDependencies({
469
- rootDir: root,
470
- noColor: true,
471
- packageFilter: rel
472
- });
473
- expect(code).toBe(0);
474
- } finally {
475
- process.chdir(prev);
476
- }
477
- const pkg = JSON.parse(await fsPromises.readFile(path.join(pkgDir, "package.json"), "utf8"));
478
- expect(pkg.exports["."]).toBeDefined();
479
- });
480
- });
481
- //#endregion
482
- export {};
@@ -1,18 +0,0 @@
1
- import { t as isDirentList } from "../../../dirent-list-BSDeRG5i.mjs";
2
- //#region src/lib/mirror/infra/dirent-list.test.ts
3
- describe("isDirentList", () => {
4
- it("documents that an empty array is intentionally accepted as Dirent[]", () => {
5
- expect(isDirentList([])).toBe(true);
6
- });
7
- it("documents that string arrays are rejected as non-Dirent lists", () => {
8
- expect(isDirentList(["a", "b"])).toBe(false);
9
- });
10
- it("documents that objects exposing Dirent shape are accepted", () => {
11
- expect(isDirentList([{
12
- isFile: () => true,
13
- isDirectory: () => false
14
- }])).toBe(true);
15
- });
16
- });
17
- //#endregion
18
- export {};
@@ -1,32 +0,0 @@
1
- import { t as resolvePackageFilterUnderRoot } from "../../../package-filter-C_8ryqvz.mjs";
2
- import fs from "node:fs";
3
- import path from "node:path";
4
- import os from "node:os";
5
- //#region src/lib/mirror/infra/package-filter.test.ts
6
- describe("resolvePackageFilterUnderRoot", () => {
7
- it("normalizes a path relative to rootDir (not cwd)", () => {
8
- const root = fs.mkdtempSync(path.join(os.tmpdir(), "pkg-filter-root-"));
9
- const pkgDir = path.join(root, "packages", "widget");
10
- fs.mkdirSync(pkgDir, { recursive: true });
11
- const prev = process.cwd();
12
- try {
13
- process.chdir(os.tmpdir());
14
- expect(resolvePackageFilterUnderRoot(root, "packages/widget")).toBe("packages/widget");
15
- } finally {
16
- process.chdir(prev);
17
- }
18
- });
19
- it("accepts absolute paths under the repo root", () => {
20
- const root = fs.mkdtempSync(path.join(os.tmpdir(), "pkg-filter-abs-"));
21
- const pkgDir = path.join(root, "packages", "ui");
22
- fs.mkdirSync(pkgDir, { recursive: true });
23
- expect(resolvePackageFilterUnderRoot(root, pkgDir)).toBe("packages/ui");
24
- });
25
- it("rejects paths outside the monorepo root", () => {
26
- const root = fs.mkdtempSync(path.join(os.tmpdir(), "pkg-filter-out-"));
27
- const outside = fs.mkdtempSync(path.join(os.tmpdir(), "pkg-filter-outside-"));
28
- expect(() => resolvePackageFilterUnderRoot(root, outside)).toThrow(/subdirectory under monorepo root/);
29
- });
30
- });
31
- //#endregion
32
- export {};