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.
- package/dist/index.mjs +1 -1
- package/dist/{isolate-CqPWp-1k.mjs → isolate-3GcdAuUK.mjs} +31 -217
- package/dist/isolate-3GcdAuUK.mjs.map +1 -0
- package/dist/isolate-bin.mjs +1 -1
- package/package.json +1 -1
- package/src/get-internal-package-names.test.ts +10 -0
- package/src/isolate.ts +3 -25
- package/src/lib/lockfile/helpers/index.ts +0 -1
- package/src/lib/lockfile/process-lockfile.ts +6 -6
- package/src/lib/manifest/adapt-target-package-manifest.ts +4 -5
- package/src/lib/manifest/helpers/adapt-internal-package-manifests.test.ts +132 -0
- package/src/lib/manifest/helpers/adapt-internal-package-manifests.ts +5 -6
- package/src/lib/manifest/validate-manifest.test.ts +19 -10
- package/src/lib/manifest/validate-manifest.ts +13 -1
- package/src/lib/patches/copy-patches.test.ts +301 -311
- package/src/lib/patches/copy-patches.ts +28 -19
- package/src/lib/types.ts +2 -3
- package/src/lib/utils/filter-patched-dependencies.test.ts +11 -1
- package/dist/isolate-CqPWp-1k.mjs.map +0 -1
- package/src/lib/lockfile/helpers/generate-bun-lockfile.test.ts +0 -619
- package/src/lib/lockfile/helpers/generate-bun-lockfile.ts +0 -340
- package/src/lib/lockfile/helpers/generate-pnpm-lockfile.test.ts +0 -387
- package/src/lib/lockfile/helpers/pnpm-map-importer.test.ts +0 -183
- package/src/lib/lockfile/process-lockfile.test.ts +0 -238
- package/src/testing/setup.ts +0 -13
|
@@ -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(() => ({
|
|
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 } =
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
readTypedJson.
|
|
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
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
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
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
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
|
-
|
|
121
|
-
"lodash@4.17.21": "patches/lodash.patch",
|
|
122
|
-
});
|
|
123
|
-
|
|
124
|
-
fs.existsSync.mockReturnValue(true);
|
|
152
|
+
filterPatchedDependencies.mockReturnValue(undefined);
|
|
125
153
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
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
|
-
|
|
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
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
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
|
-
|
|
152
|
-
name: "root",
|
|
153
|
-
version: "1.0.0",
|
|
154
|
-
pnpm: {
|
|
171
|
+
mockManifest({
|
|
155
172
|
patchedDependencies: {
|
|
156
|
-
"
|
|
173
|
+
"lodash@4.17.21": "patches/lodash.patch",
|
|
157
174
|
},
|
|
158
|
-
}
|
|
159
|
-
} as PackageManifest);
|
|
175
|
+
});
|
|
160
176
|
|
|
161
|
-
|
|
162
|
-
|
|
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
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
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
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
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
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
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
|
-
|
|
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
|
-
|
|
206
|
-
|
|
207
|
-
|
|
254
|
+
filterPatchedDependencies.mockReturnValue({
|
|
255
|
+
"lodash@4.17.21": "patches/lodash.patch",
|
|
256
|
+
});
|
|
208
257
|
|
|
209
|
-
|
|
258
|
+
fs.existsSync.mockReturnValue(false);
|
|
210
259
|
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
260
|
+
const result = await copyPatches({
|
|
261
|
+
workspaceRootDir: "/workspace",
|
|
262
|
+
targetPackageManifest: targetManifest,
|
|
263
|
+
isolateDir: "/workspace/isolate",
|
|
264
|
+
includeDevDependencies: false,
|
|
265
|
+
});
|
|
217
266
|
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
267
|
+
expect(result).toEqual({});
|
|
268
|
+
expect(fs.copy).not.toHaveBeenCalled();
|
|
269
|
+
});
|
|
221
270
|
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
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
|
-
|
|
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
|
-
|
|
240
|
-
|
|
241
|
-
|
|
284
|
+
filterPatchedDependencies.mockReturnValue({
|
|
285
|
+
"@firebase/app@1.2.3": "patches/firebase-app.patch",
|
|
286
|
+
});
|
|
242
287
|
|
|
243
|
-
|
|
288
|
+
fs.existsSync.mockReturnValue(true);
|
|
244
289
|
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
290
|
+
const result = await copyPatches({
|
|
291
|
+
workspaceRootDir: "/workspace",
|
|
292
|
+
targetPackageManifest: targetManifest,
|
|
293
|
+
isolateDir: "/workspace/isolate",
|
|
294
|
+
includeDevDependencies: false,
|
|
295
|
+
});
|
|
251
296
|
|
|
252
|
-
|
|
253
|
-
|
|
297
|
+
expect(result).toEqual({
|
|
298
|
+
"@firebase/app@1.2.3": { path: "patches/firebase-app.patch", hash: "" },
|
|
299
|
+
});
|
|
254
300
|
});
|
|
255
|
-
});
|
|
256
301
|
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
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
|
-
|
|
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
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
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
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
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
|
-
|
|
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
|
-
|
|
405
|
-
name: "root",
|
|
406
|
-
version: "1.0.0",
|
|
407
|
-
patchedDependencies: {
|
|
402
|
+
filterPatchedDependencies.mockReturnValue({
|
|
408
403
|
"lodash@4.17.21": "patches/lodash.patch",
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
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
|
});
|