isolate-package 1.29.0-0 → 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-BU1p1jhQ.mjs → isolate-3GcdAuUK.mjs} +27 -213
- 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 +1 -21
- 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 +2 -2
- 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 +303 -268
- package/src/lib/patches/copy-patches.ts +25 -7
- package/src/lib/types.ts +2 -1
- package/src/lib/utils/filter-patched-dependencies.test.ts +11 -1
- package/dist/isolate-BU1p1jhQ.mjs.map +0 -1
- package/src/lib/lockfile/helpers/generate-bun-lockfile.test.ts +0 -597
- package/src/lib/lockfile/helpers/generate-bun-lockfile.ts +0 -341
- 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,6 +18,7 @@ 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 */
|
|
@@ -34,10 +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
|
-
);
|
|
49
|
+
const { filterPatchedDependencies, readTypedJson, readTypedYamlSync } =
|
|
50
|
+
vi.mocked(await import("~/lib/utils"));
|
|
41
51
|
|
|
42
52
|
describe("copyPatches", () => {
|
|
43
53
|
beforeEach(() => {
|
|
@@ -48,46 +58,19 @@ describe("copyPatches", () => {
|
|
|
48
58
|
vi.restoreAllMocks();
|
|
49
59
|
});
|
|
50
60
|
|
|
51
|
-
|
|
52
|
-
readTypedJson.mockRejectedValue(new Error("File not found"));
|
|
53
|
-
|
|
54
|
-
const result = await copyPatches({
|
|
55
|
-
workspaceRootDir: "/workspace",
|
|
56
|
-
targetPackageManifest: { name: "test", version: "1.0.0" },
|
|
57
|
-
isolateDir: "/workspace/isolate",
|
|
58
|
-
includeDevDependencies: false,
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
expect(result).toEqual({});
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
it("should return empty object when no patchedDependencies in workspace root", async () => {
|
|
61
|
+
const mockJsonSettings = (settings: PnpmSettings | undefined) => {
|
|
65
62
|
readTypedJson.mockResolvedValue({
|
|
66
63
|
name: "root",
|
|
67
64
|
version: "1.0.0",
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
const result = await copyPatches({
|
|
71
|
-
workspaceRootDir: "/workspace",
|
|
72
|
-
targetPackageManifest: { name: "test", version: "1.0.0" },
|
|
73
|
-
isolateDir: "/workspace/isolate",
|
|
74
|
-
includeDevDependencies: false,
|
|
65
|
+
pnpm: settings,
|
|
75
66
|
});
|
|
67
|
+
};
|
|
76
68
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
readTypedJson.
|
|
82
|
-
name: "root",
|
|
83
|
-
version: "1.0.0",
|
|
84
|
-
pnpm: {
|
|
85
|
-
patchedDependencies: {
|
|
86
|
-
"lodash@4.17.21": "patches/lodash.patch",
|
|
87
|
-
},
|
|
88
|
-
},
|
|
89
|
-
} as PackageManifest);
|
|
90
|
-
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"));
|
|
91
74
|
|
|
92
75
|
const result = await copyPatches({
|
|
93
76
|
workspaceRootDir: "/workspace",
|
|
@@ -99,290 +82,342 @@ describe("copyPatches", () => {
|
|
|
99
82
|
expect(result).toEqual({});
|
|
100
83
|
});
|
|
101
84
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
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
|
+
}
|
|
107
130
|
};
|
|
108
131
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
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({
|
|
113
147
|
patchedDependencies: {
|
|
114
148
|
"lodash@4.17.21": "patches/lodash.patch",
|
|
115
149
|
},
|
|
116
|
-
}
|
|
117
|
-
} as PackageManifest);
|
|
150
|
+
});
|
|
118
151
|
|
|
119
|
-
|
|
120
|
-
"lodash@4.17.21": "patches/lodash.patch",
|
|
121
|
-
});
|
|
122
|
-
|
|
123
|
-
fs.existsSync.mockReturnValue(true);
|
|
152
|
+
filterPatchedDependencies.mockReturnValue(undefined);
|
|
124
153
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
154
|
+
const result = await copyPatches({
|
|
155
|
+
workspaceRootDir: "/workspace",
|
|
156
|
+
targetPackageManifest: { name: "test", version: "1.0.0" },
|
|
157
|
+
isolateDir: "/workspace/isolate",
|
|
158
|
+
includeDevDependencies: false,
|
|
159
|
+
});
|
|
131
160
|
|
|
132
|
-
|
|
133
|
-
"lodash@4.17.21": { path: "patches/lodash.patch", hash: "" },
|
|
161
|
+
expect(result).toEqual({});
|
|
134
162
|
});
|
|
135
|
-
/** Should preserve original folder structure */
|
|
136
|
-
expect(fs.ensureDir).toHaveBeenCalledWith("/workspace/isolate/patches");
|
|
137
|
-
expect(fs.copy).toHaveBeenCalledWith(
|
|
138
|
-
"/workspace/patches/lodash.patch",
|
|
139
|
-
"/workspace/isolate/patches/lodash.patch",
|
|
140
|
-
);
|
|
141
|
-
});
|
|
142
163
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
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
|
+
};
|
|
149
170
|
|
|
150
|
-
|
|
151
|
-
name: "root",
|
|
152
|
-
version: "1.0.0",
|
|
153
|
-
pnpm: {
|
|
171
|
+
mockManifest({
|
|
154
172
|
patchedDependencies: {
|
|
155
|
-
"
|
|
173
|
+
"lodash@4.17.21": "patches/lodash.patch",
|
|
156
174
|
},
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
175
|
+
});
|
|
176
|
+
|
|
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
|
+
);
|
|
162
199
|
});
|
|
163
200
|
|
|
164
|
-
|
|
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
|
+
};
|
|
165
207
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
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
|
+
);
|
|
180
239
|
});
|
|
181
|
-
expect(fs.copy).toHaveBeenCalledWith(
|
|
182
|
-
"/workspace/patches/vitest.patch",
|
|
183
|
-
"/workspace/isolate/patches/vitest.patch",
|
|
184
|
-
);
|
|
185
|
-
});
|
|
186
240
|
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
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
|
+
};
|
|
193
247
|
|
|
194
|
-
|
|
195
|
-
name: "root",
|
|
196
|
-
version: "1.0.0",
|
|
197
|
-
pnpm: {
|
|
248
|
+
mockManifest({
|
|
198
249
|
patchedDependencies: {
|
|
199
250
|
"lodash@4.17.21": "patches/lodash.patch",
|
|
200
251
|
},
|
|
201
|
-
}
|
|
202
|
-
} as PackageManifest);
|
|
252
|
+
});
|
|
203
253
|
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
254
|
+
filterPatchedDependencies.mockReturnValue({
|
|
255
|
+
"lodash@4.17.21": "patches/lodash.patch",
|
|
256
|
+
});
|
|
207
257
|
|
|
208
|
-
|
|
258
|
+
fs.existsSync.mockReturnValue(false);
|
|
209
259
|
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
260
|
+
const result = await copyPatches({
|
|
261
|
+
workspaceRootDir: "/workspace",
|
|
262
|
+
targetPackageManifest: targetManifest,
|
|
263
|
+
isolateDir: "/workspace/isolate",
|
|
264
|
+
includeDevDependencies: false,
|
|
265
|
+
});
|
|
216
266
|
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
267
|
+
expect(result).toEqual({});
|
|
268
|
+
expect(fs.copy).not.toHaveBeenCalled();
|
|
269
|
+
});
|
|
220
270
|
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
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
|
+
};
|
|
227
277
|
|
|
228
|
-
|
|
229
|
-
name: "root",
|
|
230
|
-
version: "1.0.0",
|
|
231
|
-
pnpm: {
|
|
278
|
+
mockManifest({
|
|
232
279
|
patchedDependencies: {
|
|
233
280
|
"@firebase/app@1.2.3": "patches/firebase-app.patch",
|
|
234
281
|
},
|
|
235
|
-
}
|
|
236
|
-
} as PackageManifest);
|
|
282
|
+
});
|
|
237
283
|
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
284
|
+
filterPatchedDependencies.mockReturnValue({
|
|
285
|
+
"@firebase/app@1.2.3": "patches/firebase-app.patch",
|
|
286
|
+
});
|
|
241
287
|
|
|
242
|
-
|
|
288
|
+
fs.existsSync.mockReturnValue(true);
|
|
243
289
|
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
290
|
+
const result = await copyPatches({
|
|
291
|
+
workspaceRootDir: "/workspace",
|
|
292
|
+
targetPackageManifest: targetManifest,
|
|
293
|
+
isolateDir: "/workspace/isolate",
|
|
294
|
+
includeDevDependencies: false,
|
|
295
|
+
});
|
|
250
296
|
|
|
251
|
-
|
|
252
|
-
|
|
297
|
+
expect(result).toEqual({
|
|
298
|
+
"@firebase/app@1.2.3": { path: "patches/firebase-app.patch", hash: "" },
|
|
299
|
+
});
|
|
253
300
|
});
|
|
254
|
-
});
|
|
255
301
|
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
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
|
+
};
|
|
262
308
|
|
|
263
|
-
|
|
264
|
-
name: "root",
|
|
265
|
-
version: "1.0.0",
|
|
266
|
-
pnpm: {
|
|
309
|
+
mockManifest({
|
|
267
310
|
patchedDependencies: {
|
|
268
311
|
"pkg-a@1.0.0": "patches/v1/fix.patch",
|
|
269
312
|
"pkg-b@1.0.0": "patches/v2/fix.patch",
|
|
270
313
|
},
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
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
|
+
);
|
|
286
344
|
});
|
|
287
345
|
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
expect(fs.copy).toHaveBeenCalledWith(
|
|
295
|
-
"/workspace/patches/v1/fix.patch",
|
|
296
|
-
"/workspace/isolate/patches/v1/fix.patch",
|
|
297
|
-
);
|
|
298
|
-
expect(fs.copy).toHaveBeenCalledWith(
|
|
299
|
-
"/workspace/patches/v2/fix.patch",
|
|
300
|
-
"/workspace/isolate/patches/v2/fix.patch",
|
|
301
|
-
);
|
|
302
|
-
});
|
|
303
|
-
|
|
304
|
-
it("should preserve deeply nested patch paths", async () => {
|
|
305
|
-
const targetManifest: PackageManifest = {
|
|
306
|
-
name: "test",
|
|
307
|
-
version: "1.0.0",
|
|
308
|
-
dependencies: { lodash: "^4.0.0" },
|
|
309
|
-
};
|
|
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
|
+
};
|
|
310
352
|
|
|
311
|
-
|
|
312
|
-
name: "root",
|
|
313
|
-
version: "1.0.0",
|
|
314
|
-
pnpm: {
|
|
353
|
+
mockManifest({
|
|
315
354
|
patchedDependencies: {
|
|
316
355
|
"lodash@4.17.21": "some/nested/path/lodash.patch",
|
|
317
356
|
},
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
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
|
+
);
|
|
323
383
|
});
|
|
324
384
|
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
/** The path should preserve the original directory structure */
|
|
335
|
-
expect(result).toEqual({
|
|
336
|
-
"lodash@4.17.21": { path: "some/nested/path/lodash.patch", hash: "" },
|
|
337
|
-
});
|
|
338
|
-
expect(fs.ensureDir).toHaveBeenCalledWith(
|
|
339
|
-
"/workspace/isolate/some/nested/path",
|
|
340
|
-
);
|
|
341
|
-
expect(fs.copy).toHaveBeenCalledWith(
|
|
342
|
-
"/workspace/some/nested/path/lodash.patch",
|
|
343
|
-
"/workspace/isolate/some/nested/path/lodash.patch",
|
|
344
|
-
);
|
|
345
|
-
});
|
|
346
|
-
|
|
347
|
-
it("should copy multiple patches correctly", async () => {
|
|
348
|
-
const targetManifest: PackageManifest = {
|
|
349
|
-
name: "test",
|
|
350
|
-
version: "1.0.0",
|
|
351
|
-
dependencies: {
|
|
352
|
-
lodash: "^4.0.0",
|
|
353
|
-
"@firebase/app": "^1.0.0",
|
|
354
|
-
},
|
|
355
|
-
};
|
|
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
|
+
};
|
|
356
394
|
|
|
357
|
-
|
|
358
|
-
name: "root",
|
|
359
|
-
version: "1.0.0",
|
|
360
|
-
pnpm: {
|
|
395
|
+
mockManifest({
|
|
361
396
|
patchedDependencies: {
|
|
362
397
|
"lodash@4.17.21": "patches/lodash.patch",
|
|
363
398
|
"@firebase/app@1.2.3": "patches/firebase-app.patch",
|
|
364
399
|
},
|
|
365
|
-
}
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
400
|
+
});
|
|
401
|
+
|
|
402
|
+
filterPatchedDependencies.mockReturnValue({
|
|
403
|
+
"lodash@4.17.21": "patches/lodash.patch",
|
|
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);
|
|
385
421
|
});
|
|
386
|
-
expect(fs.copy).toHaveBeenCalledTimes(2);
|
|
387
422
|
});
|
|
388
423
|
});
|