isolate-package 1.29.0-1 → 1.29.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.
@@ -1,5 +1,5 @@
1
1
  import { describe, it, expect, beforeEach, afterEach, vi } from "vitest";
2
- import type { PackageManifest } from "~/lib/types";
2
+ import type { PackageManifest, PnpmSettings } from "~/lib/types";
3
3
  import { copyPatches } from "./copy-patches";
4
4
 
5
5
  /** Mock fs-extra */
@@ -18,11 +18,12 @@ vi.mock("~/lib/utils", () => ({
18
18
  getRootRelativeLogPath: vi.fn((p: string) => p),
19
19
  isRushWorkspace: vi.fn(() => false),
20
20
  readTypedJson: vi.fn(),
21
+ readTypedYamlSync: vi.fn(),
21
22
  }));
22
23
 
23
24
  /** Mock the package manager */
24
25
  vi.mock("~/lib/package-manager", () => ({
25
- usePackageManager: vi.fn(() => ({ name: "pnpm", majorVersion: 9 })),
26
+ usePackageManager: vi.fn(() => ({ majorVersion: 9 })),
26
27
  }));
27
28
 
28
29
  /** Mock the pnpm lockfile readers */
@@ -34,11 +35,19 @@ vi.mock("pnpm_lockfile_file_v9", () => ({
34
35
  readWantedLockfile: vi.fn(() => Promise.resolve(null)),
35
36
  }));
36
37
 
38
+ /** Mock the logger */
39
+ vi.mock("~/lib/logger", () => ({
40
+ useLogger: () => ({
41
+ debug: vi.fn(),
42
+ info: vi.fn(),
43
+ warn: vi.fn(),
44
+ error: vi.fn(),
45
+ }),
46
+ }));
47
+
37
48
  const fs = vi.mocked((await import("fs-extra")).default);
38
- const { filterPatchedDependencies, readTypedJson } = vi.mocked(
39
- await import("~/lib/utils"),
40
- );
41
- const { usePackageManager } = vi.mocked(await import("~/lib/package-manager"));
49
+ const { filterPatchedDependencies, readTypedJson, readTypedYamlSync } =
50
+ vi.mocked(await import("~/lib/utils"));
42
51
 
43
52
  describe("copyPatches", () => {
44
53
  beforeEach(() => {
@@ -49,46 +58,19 @@ describe("copyPatches", () => {
49
58
  vi.restoreAllMocks();
50
59
  });
51
60
 
52
- it("should return empty object when workspace root package.json cannot be read", async () => {
53
- readTypedJson.mockRejectedValue(new Error("File not found"));
54
-
55
- const result = await copyPatches({
56
- workspaceRootDir: "/workspace",
57
- targetPackageManifest: { name: "test", version: "1.0.0" },
58
- isolateDir: "/workspace/isolate",
59
- includeDevDependencies: false,
60
- });
61
-
62
- expect(result).toEqual({});
63
- });
64
-
65
- it("should return empty object when no patchedDependencies in workspace root", async () => {
61
+ const mockJsonSettings = (settings: PnpmSettings | undefined) => {
66
62
  readTypedJson.mockResolvedValue({
67
63
  name: "root",
68
64
  version: "1.0.0",
69
- } as PackageManifest);
70
-
71
- const result = await copyPatches({
72
- workspaceRootDir: "/workspace",
73
- targetPackageManifest: { name: "test", version: "1.0.0" },
74
- isolateDir: "/workspace/isolate",
75
- includeDevDependencies: false,
65
+ pnpm: settings,
76
66
  });
67
+ };
77
68
 
78
- expect(result).toEqual({});
79
- });
80
-
81
- it("should return empty object when all patches are filtered out", async () => {
82
- readTypedJson.mockResolvedValue({
83
- name: "root",
84
- version: "1.0.0",
85
- pnpm: {
86
- patchedDependencies: {
87
- "lodash@4.17.21": "patches/lodash.patch",
88
- },
89
- },
90
- } as PackageManifest);
91
- filterPatchedDependencies.mockReturnValue(undefined);
69
+ it("should return empty object when workspace root package.json cannot be read", async () => {
70
+ readTypedYamlSync.mockImplementation(() => {
71
+ throw new Error("File not found");
72
+ });
73
+ readTypedJson.mockRejectedValue(new Error("File not found"));
92
74
 
93
75
  const result = await copyPatches({
94
76
  workspaceRootDir: "/workspace",
@@ -100,334 +82,342 @@ describe("copyPatches", () => {
100
82
  expect(result).toEqual({});
101
83
  });
102
84
 
103
- it("should copy patches for production dependencies", async () => {
104
- const targetManifest: PackageManifest = {
105
- name: "test",
106
- version: "1.0.0",
107
- dependencies: { lodash: "^4.0.0" },
85
+ // Repeat these tests for each combination of config formats
86
+ describe.for([
87
+ "yamlOnly",
88
+ "yamlAndJson",
89
+ "jsonYamlEmpty",
90
+ "jsonYamlError",
91
+ ] as const)("valid config tests: %s", (mode) => {
92
+ // Helper to set up mocks for the correct manifest file for this test scenario
93
+ const mockManifest = (settings: PnpmSettings | undefined) => {
94
+ switch (mode) {
95
+ case "yamlOnly": {
96
+ readTypedYamlSync.mockReturnValue(settings ?? {});
97
+ readTypedJson.mockResolvedValue({ name: "test", version: "1.0.0" });
98
+ break;
99
+ }
100
+ case "yamlAndJson": {
101
+ readTypedYamlSync.mockReturnValue(settings ?? {});
102
+ readTypedJson.mockResolvedValue({
103
+ name: "test",
104
+ version: "1.0.0",
105
+ pnpm: settings,
106
+ });
107
+ break;
108
+ }
109
+ case "jsonYamlEmpty": {
110
+ readTypedYamlSync.mockReturnValue({});
111
+ readTypedJson.mockResolvedValue({
112
+ name: "test",
113
+ version: "1.0.0",
114
+ pnpm: settings,
115
+ });
116
+ break;
117
+ }
118
+ case "jsonYamlError": {
119
+ readTypedYamlSync.mockImplementation(() => {
120
+ throw new Error("File not found");
121
+ });
122
+ readTypedJson.mockResolvedValue({
123
+ name: "test",
124
+ version: "1.0.0",
125
+ pnpm: settings,
126
+ });
127
+ break;
128
+ }
129
+ }
108
130
  };
109
131
 
110
- readTypedJson.mockResolvedValue({
111
- name: "root",
112
- version: "1.0.0",
113
- pnpm: {
132
+ it("should return empty object when no patchedDependencies in workspace root", async () => {
133
+ mockManifest(undefined);
134
+
135
+ const result = await copyPatches({
136
+ workspaceRootDir: "/workspace",
137
+ targetPackageManifest: { name: "test", version: "1.0.0" },
138
+ isolateDir: "/workspace/isolate",
139
+ includeDevDependencies: false,
140
+ });
141
+
142
+ expect(result).toEqual({});
143
+ });
144
+
145
+ it("should return empty object when all patches are filtered out", async () => {
146
+ mockManifest({
114
147
  patchedDependencies: {
115
148
  "lodash@4.17.21": "patches/lodash.patch",
116
149
  },
117
- },
118
- } as PackageManifest);
150
+ });
119
151
 
120
- filterPatchedDependencies.mockReturnValue({
121
- "lodash@4.17.21": "patches/lodash.patch",
122
- });
123
-
124
- fs.existsSync.mockReturnValue(true);
152
+ filterPatchedDependencies.mockReturnValue(undefined);
125
153
 
126
- const result = await copyPatches({
127
- workspaceRootDir: "/workspace",
128
- targetPackageManifest: targetManifest,
129
- isolateDir: "/workspace/isolate",
130
- includeDevDependencies: false,
131
- });
154
+ const result = await copyPatches({
155
+ workspaceRootDir: "/workspace",
156
+ targetPackageManifest: { name: "test", version: "1.0.0" },
157
+ isolateDir: "/workspace/isolate",
158
+ includeDevDependencies: false,
159
+ });
132
160
 
133
- expect(result).toEqual({
134
- "lodash@4.17.21": { path: "patches/lodash.patch", hash: "" },
161
+ expect(result).toEqual({});
135
162
  });
136
- /** Should preserve original folder structure */
137
- expect(fs.ensureDir).toHaveBeenCalledWith("/workspace/isolate/patches");
138
- expect(fs.copy).toHaveBeenCalledWith(
139
- "/workspace/patches/lodash.patch",
140
- "/workspace/isolate/patches/lodash.patch",
141
- );
142
- });
143
163
 
144
- it("should include dev dependency patches when includeDevDependencies is true", async () => {
145
- const targetManifest: PackageManifest = {
146
- name: "test",
147
- version: "1.0.0",
148
- devDependencies: { vitest: "^1.0.0" },
149
- };
164
+ it("should copy patches for production dependencies", async () => {
165
+ const targetManifest: PackageManifest = {
166
+ name: "test",
167
+ version: "1.0.0",
168
+ dependencies: { lodash: "^4.0.0" },
169
+ };
150
170
 
151
- readTypedJson.mockResolvedValue({
152
- name: "root",
153
- version: "1.0.0",
154
- pnpm: {
171
+ mockManifest({
155
172
  patchedDependencies: {
156
- "vitest@1.0.0": "patches/vitest.patch",
173
+ "lodash@4.17.21": "patches/lodash.patch",
157
174
  },
158
- },
159
- } as PackageManifest);
175
+ });
160
176
 
161
- filterPatchedDependencies.mockReturnValue({
162
- "vitest@1.0.0": "patches/vitest.patch",
177
+ filterPatchedDependencies.mockReturnValue({
178
+ "lodash@4.17.21": "patches/lodash.patch",
179
+ });
180
+
181
+ fs.existsSync.mockReturnValue(true);
182
+
183
+ const result = await copyPatches({
184
+ workspaceRootDir: "/workspace",
185
+ targetPackageManifest: targetManifest,
186
+ isolateDir: "/workspace/isolate",
187
+ includeDevDependencies: false,
188
+ });
189
+
190
+ expect(result).toEqual({
191
+ "lodash@4.17.21": { path: "patches/lodash.patch", hash: "" },
192
+ });
193
+ /** Should preserve original folder structure */
194
+ expect(fs.ensureDir).toHaveBeenCalledWith("/workspace/isolate/patches");
195
+ expect(fs.copy).toHaveBeenCalledWith(
196
+ "/workspace/patches/lodash.patch",
197
+ "/workspace/isolate/patches/lodash.patch",
198
+ );
163
199
  });
164
200
 
165
- fs.existsSync.mockReturnValue(true);
166
-
167
- const result = await copyPatches({
168
- workspaceRootDir: "/workspace",
169
- targetPackageManifest: targetManifest,
170
- isolateDir: "/workspace/isolate",
171
- includeDevDependencies: true,
172
- });
201
+ it("should include dev dependency patches when includeDevDependencies is true", async () => {
202
+ const targetManifest: PackageManifest = {
203
+ name: "test",
204
+ version: "1.0.0",
205
+ devDependencies: { vitest: "^1.0.0" },
206
+ };
173
207
 
174
- expect(result).toEqual({
175
- "vitest@1.0.0": { path: "patches/vitest.patch", hash: "" },
176
- });
177
- expect(filterPatchedDependencies).toHaveBeenCalledWith({
178
- patchedDependencies: { "vitest@1.0.0": "patches/vitest.patch" },
179
- targetPackageManifest: targetManifest,
180
- includeDevDependencies: true,
208
+ mockManifest({
209
+ patchedDependencies: {
210
+ "vitest@1.0.0": "patches/vitest.patch",
211
+ },
212
+ });
213
+
214
+ filterPatchedDependencies.mockReturnValue({
215
+ "vitest@1.0.0": "patches/vitest.patch",
216
+ });
217
+
218
+ fs.existsSync.mockReturnValue(true);
219
+
220
+ const result = await copyPatches({
221
+ workspaceRootDir: "/workspace",
222
+ targetPackageManifest: targetManifest,
223
+ isolateDir: "/workspace/isolate",
224
+ includeDevDependencies: true,
225
+ });
226
+
227
+ expect(result).toEqual({
228
+ "vitest@1.0.0": { path: "patches/vitest.patch", hash: "" },
229
+ });
230
+ expect(filterPatchedDependencies).toHaveBeenCalledWith({
231
+ patchedDependencies: { "vitest@1.0.0": "patches/vitest.patch" },
232
+ targetPackageManifest: targetManifest,
233
+ includeDevDependencies: true,
234
+ });
235
+ expect(fs.copy).toHaveBeenCalledWith(
236
+ "/workspace/patches/vitest.patch",
237
+ "/workspace/isolate/patches/vitest.patch",
238
+ );
181
239
  });
182
- expect(fs.copy).toHaveBeenCalledWith(
183
- "/workspace/patches/vitest.patch",
184
- "/workspace/isolate/patches/vitest.patch",
185
- );
186
- });
187
240
 
188
- it("should skip missing patch files and log a warning", async () => {
189
- const targetManifest: PackageManifest = {
190
- name: "test",
191
- version: "1.0.0",
192
- dependencies: { lodash: "^4.0.0" },
193
- };
241
+ it("should skip missing patch files and log a warning", async () => {
242
+ const targetManifest: PackageManifest = {
243
+ name: "test",
244
+ version: "1.0.0",
245
+ dependencies: { lodash: "^4.0.0" },
246
+ };
194
247
 
195
- readTypedJson.mockResolvedValue({
196
- name: "root",
197
- version: "1.0.0",
198
- pnpm: {
248
+ mockManifest({
199
249
  patchedDependencies: {
200
250
  "lodash@4.17.21": "patches/lodash.patch",
201
251
  },
202
- },
203
- } as PackageManifest);
252
+ });
204
253
 
205
- filterPatchedDependencies.mockReturnValue({
206
- "lodash@4.17.21": "patches/lodash.patch",
207
- });
254
+ filterPatchedDependencies.mockReturnValue({
255
+ "lodash@4.17.21": "patches/lodash.patch",
256
+ });
208
257
 
209
- fs.existsSync.mockReturnValue(false);
258
+ fs.existsSync.mockReturnValue(false);
210
259
 
211
- const result = await copyPatches({
212
- workspaceRootDir: "/workspace",
213
- targetPackageManifest: targetManifest,
214
- isolateDir: "/workspace/isolate",
215
- includeDevDependencies: false,
216
- });
260
+ const result = await copyPatches({
261
+ workspaceRootDir: "/workspace",
262
+ targetPackageManifest: targetManifest,
263
+ isolateDir: "/workspace/isolate",
264
+ includeDevDependencies: false,
265
+ });
217
266
 
218
- expect(result).toEqual({});
219
- expect(fs.copy).not.toHaveBeenCalled();
220
- });
267
+ expect(result).toEqual({});
268
+ expect(fs.copy).not.toHaveBeenCalled();
269
+ });
221
270
 
222
- it("should handle scoped package names correctly", async () => {
223
- const targetManifest: PackageManifest = {
224
- name: "test",
225
- version: "1.0.0",
226
- dependencies: { "@firebase/app": "^1.0.0" },
227
- };
271
+ it("should handle scoped package names correctly", async () => {
272
+ const targetManifest: PackageManifest = {
273
+ name: "test",
274
+ version: "1.0.0",
275
+ dependencies: { "@firebase/app": "^1.0.0" },
276
+ };
228
277
 
229
- readTypedJson.mockResolvedValue({
230
- name: "root",
231
- version: "1.0.0",
232
- pnpm: {
278
+ mockManifest({
233
279
  patchedDependencies: {
234
280
  "@firebase/app@1.2.3": "patches/firebase-app.patch",
235
281
  },
236
- },
237
- } as PackageManifest);
282
+ });
238
283
 
239
- filterPatchedDependencies.mockReturnValue({
240
- "@firebase/app@1.2.3": "patches/firebase-app.patch",
241
- });
284
+ filterPatchedDependencies.mockReturnValue({
285
+ "@firebase/app@1.2.3": "patches/firebase-app.patch",
286
+ });
242
287
 
243
- fs.existsSync.mockReturnValue(true);
288
+ fs.existsSync.mockReturnValue(true);
244
289
 
245
- const result = await copyPatches({
246
- workspaceRootDir: "/workspace",
247
- targetPackageManifest: targetManifest,
248
- isolateDir: "/workspace/isolate",
249
- includeDevDependencies: false,
250
- });
290
+ const result = await copyPatches({
291
+ workspaceRootDir: "/workspace",
292
+ targetPackageManifest: targetManifest,
293
+ isolateDir: "/workspace/isolate",
294
+ includeDevDependencies: false,
295
+ });
251
296
 
252
- expect(result).toEqual({
253
- "@firebase/app@1.2.3": { path: "patches/firebase-app.patch", hash: "" },
297
+ expect(result).toEqual({
298
+ "@firebase/app@1.2.3": { path: "patches/firebase-app.patch", hash: "" },
299
+ });
254
300
  });
255
- });
256
301
 
257
- it("should preserve nested folder structure when copying patches", async () => {
258
- const targetManifest: PackageManifest = {
259
- name: "test",
260
- version: "1.0.0",
261
- dependencies: { "pkg-a": "^1.0.0", "pkg-b": "^1.0.0" },
262
- };
302
+ it("should preserve nested folder structure when copying patches", async () => {
303
+ const targetManifest: PackageManifest = {
304
+ name: "test",
305
+ version: "1.0.0",
306
+ dependencies: { "pkg-a": "^1.0.0", "pkg-b": "^1.0.0" },
307
+ };
263
308
 
264
- readTypedJson.mockResolvedValue({
265
- name: "root",
266
- version: "1.0.0",
267
- pnpm: {
309
+ mockManifest({
268
310
  patchedDependencies: {
269
311
  "pkg-a@1.0.0": "patches/v1/fix.patch",
270
312
  "pkg-b@1.0.0": "patches/v2/fix.patch",
271
313
  },
272
- },
273
- } as PackageManifest);
274
-
275
- filterPatchedDependencies.mockReturnValue({
276
- "pkg-a@1.0.0": "patches/v1/fix.patch",
277
- "pkg-b@1.0.0": "patches/v2/fix.patch",
314
+ });
315
+
316
+ filterPatchedDependencies.mockReturnValue({
317
+ "pkg-a@1.0.0": "patches/v1/fix.patch",
318
+ "pkg-b@1.0.0": "patches/v2/fix.patch",
319
+ });
320
+
321
+ fs.existsSync.mockReturnValue(true);
322
+
323
+ const result = await copyPatches({
324
+ workspaceRootDir: "/workspace",
325
+ targetPackageManifest: targetManifest,
326
+ isolateDir: "/workspace/isolate",
327
+ includeDevDependencies: false,
328
+ });
329
+
330
+ /** Should preserve original paths without renaming */
331
+ expect(result).toEqual({
332
+ "pkg-a@1.0.0": { path: "patches/v1/fix.patch", hash: "" },
333
+ "pkg-b@1.0.0": { path: "patches/v2/fix.patch", hash: "" },
334
+ });
335
+ expect(fs.copy).toHaveBeenCalledTimes(2);
336
+ expect(fs.copy).toHaveBeenCalledWith(
337
+ "/workspace/patches/v1/fix.patch",
338
+ "/workspace/isolate/patches/v1/fix.patch",
339
+ );
340
+ expect(fs.copy).toHaveBeenCalledWith(
341
+ "/workspace/patches/v2/fix.patch",
342
+ "/workspace/isolate/patches/v2/fix.patch",
343
+ );
278
344
  });
279
345
 
280
- fs.existsSync.mockReturnValue(true);
346
+ it("should preserve deeply nested patch paths", async () => {
347
+ const targetManifest: PackageManifest = {
348
+ name: "test",
349
+ version: "1.0.0",
350
+ dependencies: { lodash: "^4.0.0" },
351
+ };
281
352
 
282
- const result = await copyPatches({
283
- workspaceRootDir: "/workspace",
284
- targetPackageManifest: targetManifest,
285
- isolateDir: "/workspace/isolate",
286
- includeDevDependencies: false,
287
- });
288
-
289
- /** Should preserve original paths without renaming */
290
- expect(result).toEqual({
291
- "pkg-a@1.0.0": { path: "patches/v1/fix.patch", hash: "" },
292
- "pkg-b@1.0.0": { path: "patches/v2/fix.patch", hash: "" },
293
- });
294
- expect(fs.copy).toHaveBeenCalledTimes(2);
295
- expect(fs.copy).toHaveBeenCalledWith(
296
- "/workspace/patches/v1/fix.patch",
297
- "/workspace/isolate/patches/v1/fix.patch",
298
- );
299
- expect(fs.copy).toHaveBeenCalledWith(
300
- "/workspace/patches/v2/fix.patch",
301
- "/workspace/isolate/patches/v2/fix.patch",
302
- );
303
- });
304
-
305
- it("should preserve deeply nested patch paths", async () => {
306
- const targetManifest: PackageManifest = {
307
- name: "test",
308
- version: "1.0.0",
309
- dependencies: { lodash: "^4.0.0" },
310
- };
311
-
312
- readTypedJson.mockResolvedValue({
313
- name: "root",
314
- version: "1.0.0",
315
- pnpm: {
353
+ mockManifest({
316
354
  patchedDependencies: {
317
355
  "lodash@4.17.21": "some/nested/path/lodash.patch",
318
356
  },
319
- },
320
- } as PackageManifest);
321
-
322
- filterPatchedDependencies.mockReturnValue({
323
- "lodash@4.17.21": "some/nested/path/lodash.patch",
357
+ });
358
+
359
+ filterPatchedDependencies.mockReturnValue({
360
+ "lodash@4.17.21": "some/nested/path/lodash.patch",
361
+ });
362
+
363
+ fs.existsSync.mockReturnValue(true);
364
+
365
+ const result = await copyPatches({
366
+ workspaceRootDir: "/workspace",
367
+ targetPackageManifest: targetManifest,
368
+ isolateDir: "/workspace/isolate",
369
+ includeDevDependencies: false,
370
+ });
371
+
372
+ /** The path should preserve the original directory structure */
373
+ expect(result).toEqual({
374
+ "lodash@4.17.21": { path: "some/nested/path/lodash.patch", hash: "" },
375
+ });
376
+ expect(fs.ensureDir).toHaveBeenCalledWith(
377
+ "/workspace/isolate/some/nested/path",
378
+ );
379
+ expect(fs.copy).toHaveBeenCalledWith(
380
+ "/workspace/some/nested/path/lodash.patch",
381
+ "/workspace/isolate/some/nested/path/lodash.patch",
382
+ );
324
383
  });
325
384
 
326
- fs.existsSync.mockReturnValue(true);
327
-
328
- const result = await copyPatches({
329
- workspaceRootDir: "/workspace",
330
- targetPackageManifest: targetManifest,
331
- isolateDir: "/workspace/isolate",
332
- includeDevDependencies: false,
333
- });
334
-
335
- /** The path should preserve the original directory structure */
336
- expect(result).toEqual({
337
- "lodash@4.17.21": { path: "some/nested/path/lodash.patch", hash: "" },
338
- });
339
- expect(fs.ensureDir).toHaveBeenCalledWith(
340
- "/workspace/isolate/some/nested/path",
341
- );
342
- expect(fs.copy).toHaveBeenCalledWith(
343
- "/workspace/some/nested/path/lodash.patch",
344
- "/workspace/isolate/some/nested/path/lodash.patch",
345
- );
346
- });
347
-
348
- it("should copy multiple patches correctly", async () => {
349
- const targetManifest: PackageManifest = {
350
- name: "test",
351
- version: "1.0.0",
352
- dependencies: {
353
- lodash: "^4.0.0",
354
- "@firebase/app": "^1.0.0",
355
- },
356
- };
385
+ it("should copy multiple patches correctly", async () => {
386
+ const targetManifest: PackageManifest = {
387
+ name: "test",
388
+ version: "1.0.0",
389
+ dependencies: {
390
+ lodash: "^4.0.0",
391
+ "@firebase/app": "^1.0.0",
392
+ },
393
+ };
357
394
 
358
- readTypedJson.mockResolvedValue({
359
- name: "root",
360
- version: "1.0.0",
361
- pnpm: {
395
+ mockManifest({
362
396
  patchedDependencies: {
363
397
  "lodash@4.17.21": "patches/lodash.patch",
364
398
  "@firebase/app@1.2.3": "patches/firebase-app.patch",
365
399
  },
366
- },
367
- } as PackageManifest);
368
-
369
- filterPatchedDependencies.mockReturnValue({
370
- "lodash@4.17.21": "patches/lodash.patch",
371
- "@firebase/app@1.2.3": "patches/firebase-app.patch",
372
- });
373
-
374
- fs.existsSync.mockReturnValue(true);
375
-
376
- const result = await copyPatches({
377
- workspaceRootDir: "/workspace",
378
- targetPackageManifest: targetManifest,
379
- isolateDir: "/workspace/isolate",
380
- includeDevDependencies: false,
381
- });
382
-
383
- expect(result).toEqual({
384
- "lodash@4.17.21": { path: "patches/lodash.patch", hash: "" },
385
- "@firebase/app@1.2.3": { path: "patches/firebase-app.patch", hash: "" },
386
- });
387
- expect(fs.copy).toHaveBeenCalledTimes(2);
388
- });
389
-
390
- it("should read top-level patchedDependencies for Bun projects", async () => {
391
- usePackageManager.mockReturnValue({
392
- name: "bun",
393
- majorVersion: 1,
394
- version: "1.2.0",
395
- packageManagerString: "bun@1.2.0",
396
- });
397
-
398
- const targetManifest: PackageManifest = {
399
- name: "test",
400
- version: "1.0.0",
401
- dependencies: { lodash: "^4.0.0" },
402
- };
400
+ });
403
401
 
404
- readTypedJson.mockResolvedValue({
405
- name: "root",
406
- version: "1.0.0",
407
- patchedDependencies: {
402
+ filterPatchedDependencies.mockReturnValue({
408
403
  "lodash@4.17.21": "patches/lodash.patch",
409
- },
410
- } as PackageManifest);
411
-
412
- filterPatchedDependencies.mockReturnValue({
413
- "lodash@4.17.21": "patches/lodash.patch",
414
- });
415
-
416
- fs.existsSync.mockReturnValue(true);
417
-
418
- const result = await copyPatches({
419
- workspaceRootDir: "/workspace",
420
- targetPackageManifest: targetManifest,
421
- isolateDir: "/workspace/isolate",
422
- includeDevDependencies: false,
423
- });
424
-
425
- expect(result).toEqual({
426
- "lodash@4.17.21": { path: "patches/lodash.patch", hash: "" },
404
+ "@firebase/app@1.2.3": "patches/firebase-app.patch",
405
+ });
406
+
407
+ fs.existsSync.mockReturnValue(true);
408
+
409
+ const result = await copyPatches({
410
+ workspaceRootDir: "/workspace",
411
+ targetPackageManifest: targetManifest,
412
+ isolateDir: "/workspace/isolate",
413
+ includeDevDependencies: false,
414
+ });
415
+
416
+ expect(result).toEqual({
417
+ "lodash@4.17.21": { path: "patches/lodash.patch", hash: "" },
418
+ "@firebase/app@1.2.3": { path: "patches/firebase-app.patch", hash: "" },
419
+ });
420
+ expect(fs.copy).toHaveBeenCalledTimes(2);
427
421
  });
428
- expect(fs.copy).toHaveBeenCalledWith(
429
- "/workspace/patches/lodash.patch",
430
- "/workspace/isolate/patches/lodash.patch",
431
- );
432
422
  });
433
423
  });