@atlaspack/package-manager 2.14.5-canary.22 → 2.14.5-canary.221

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 (63) hide show
  1. package/CHANGELOG.md +334 -0
  2. package/dist/JSONParseStream.js +37 -0
  3. package/dist/MockPackageInstaller.js +54 -0
  4. package/dist/NodePackageManager.js +559 -0
  5. package/dist/Npm.js +73 -0
  6. package/dist/Pnpm.js +140 -0
  7. package/dist/Yarn.js +124 -0
  8. package/dist/getCurrentPackageManager.js +17 -0
  9. package/dist/index.js +24 -0
  10. package/dist/installPackage.js +197 -0
  11. package/dist/nodejsConditions.js +39 -0
  12. package/dist/promiseFromProcess.js +16 -0
  13. package/dist/utils.js +76 -0
  14. package/dist/validateModuleSpecifier.js +11 -0
  15. package/lib/JSONParseStream.js +52 -0
  16. package/lib/MockPackageInstaller.js +79 -0
  17. package/lib/NodePackageManager.js +621 -0
  18. package/lib/Npm.js +106 -0
  19. package/lib/Pnpm.js +185 -0
  20. package/lib/Yarn.js +160 -0
  21. package/lib/getCurrentPackageManager.js +20 -0
  22. package/lib/index.js +64 -5211
  23. package/lib/installPackage.js +222 -0
  24. package/lib/nodejsConditions.js +41 -0
  25. package/lib/promiseFromProcess.js +20 -0
  26. package/lib/types/JSONParseStream.d.ts +6 -0
  27. package/lib/types/MockPackageInstaller.d.ts +14 -0
  28. package/lib/types/NodePackageManager.d.ts +37 -0
  29. package/lib/types/Npm.d.ts +4 -0
  30. package/lib/types/Pnpm.d.ts +5 -0
  31. package/lib/types/Yarn.d.ts +5 -0
  32. package/lib/types/getCurrentPackageManager.d.ts +4 -0
  33. package/lib/types/index.d.ts +10 -0
  34. package/lib/types/installPackage.d.ts +5 -0
  35. package/lib/types/nodejsConditions.d.ts +3 -0
  36. package/lib/types/promiseFromProcess.d.ts +2 -0
  37. package/lib/types/utils.d.ts +15 -0
  38. package/lib/types/validateModuleSpecifier.d.ts +1 -0
  39. package/lib/utils.js +101 -0
  40. package/lib/validateModuleSpecifier.js +14 -0
  41. package/package.json +17 -20
  42. package/src/{JSONParseStream.js → JSONParseStream.ts} +8 -7
  43. package/src/{MockPackageInstaller.js → MockPackageInstaller.ts} +4 -6
  44. package/src/{NodePackageManager.js → NodePackageManager.ts} +125 -73
  45. package/src/{Npm.js → Npm.ts} +9 -9
  46. package/src/{Pnpm.js → Pnpm.ts} +68 -50
  47. package/src/{Yarn.js → Yarn.ts} +38 -25
  48. package/src/{getCurrentPackageManager.js → getCurrentPackageManager.ts} +9 -4
  49. package/src/{index.js → index.ts} +0 -2
  50. package/src/{installPackage.js → installPackage.ts} +4 -6
  51. package/src/{nodejsConditions.js → nodejsConditions.ts} +6 -3
  52. package/src/promiseFromProcess.ts +23 -0
  53. package/src/{utils.js → utils.ts} +21 -11
  54. package/src/{validateModuleSpecifier.js → validateModuleSpecifier.ts} +0 -2
  55. package/test/{NodePackageManager.test.js → NodePackageManager.test.ts} +19 -16
  56. package/test/{getCurrentPackageManager.test.js → getCurrentPackageManager.test.ts} +0 -1
  57. package/test/{validateModuleSpecifiers.test.js → validateModuleSpecifiers.test.ts} +2 -3
  58. package/tsconfig.json +33 -0
  59. package/tsconfig.tsbuildinfo +1 -0
  60. package/index.d.ts +0 -40
  61. package/lib/index.d.ts +0 -10
  62. package/lib/index.js.map +0 -1
  63. package/src/promiseFromProcess.js +0 -19
package/CHANGELOG.md CHANGED
@@ -1,5 +1,339 @@
1
1
  # @atlaspack/package-manager
2
2
 
3
+ ## 2.14.34
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [[`25cbee6`](https://github.com/atlassian-labs/atlaspack/commit/25cbee625fb47ac20423fe34ff37bc818a807245)]:
8
+ - @atlaspack/workers@2.14.34
9
+ - @atlaspack/fs@2.15.29
10
+ - @atlaspack/types@2.15.24
11
+ - @atlaspack/utils@3.0.2
12
+ - @atlaspack/node-resolver-core@3.7.5
13
+ - @atlaspack/logger@2.14.26
14
+
15
+ ## 2.14.33
16
+
17
+ ### Patch Changes
18
+
19
+ - Updated dependencies [[`236e546`](https://github.com/atlassian-labs/atlaspack/commit/236e5465863dca6044a7191e05260a5b924c342e)]:
20
+ - @atlaspack/utils@3.0.1
21
+ - @atlaspack/workers@2.14.33
22
+ - @atlaspack/node-resolver-core@3.7.4
23
+ - @atlaspack/fs@2.15.28
24
+ - @atlaspack/types@2.15.23
25
+ - @atlaspack/logger@2.14.25
26
+
27
+ ## 2.14.32
28
+
29
+ ### Patch Changes
30
+
31
+ - Updated dependencies [[`1180103`](https://github.com/atlassian-labs/atlaspack/commit/118010351ed444f8178988afb3f77807154dd933)]:
32
+ - @atlaspack/utils@3.0.0
33
+ - @atlaspack/fs@2.15.27
34
+ - @atlaspack/node-resolver-core@3.7.3
35
+ - @atlaspack/logger@2.14.24
36
+ - @atlaspack/workers@2.14.32
37
+ - @atlaspack/types@2.15.22
38
+
39
+ ## 2.14.31
40
+
41
+ ### Patch Changes
42
+
43
+ - [#785](https://github.com/atlassian-labs/atlaspack/pull/785) [`0e7dd5e`](https://github.com/atlassian-labs/atlaspack/commit/0e7dd5ec6fbe05aa9e0bb5775a9d0975f206a922) Thanks [@matt-koko](https://github.com/matt-koko)! - We need to re-publish every package in Atlaspack with the corrected types field.
44
+
45
+ - Updated dependencies [[`0e7dd5e`](https://github.com/atlassian-labs/atlaspack/commit/0e7dd5ec6fbe05aa9e0bb5775a9d0975f206a922)]:
46
+ - @atlaspack/build-cache@2.13.6
47
+ - @atlaspack/diagnostic@2.14.4
48
+ - @atlaspack/fs@2.15.26
49
+ - @atlaspack/logger@2.14.23
50
+ - @atlaspack/types@2.15.21
51
+ - @atlaspack/utils@2.19.3
52
+ - @atlaspack/workers@2.14.31
53
+ - @atlaspack/node-resolver-core@3.7.2
54
+
55
+ ## 2.14.30
56
+
57
+ ### Patch Changes
58
+
59
+ - Updated dependencies []:
60
+ - @atlaspack/fs@2.15.25
61
+ - @atlaspack/utils@2.19.2
62
+ - @atlaspack/node-resolver-core@3.7.1
63
+ - @atlaspack/logger@2.14.22
64
+ - @atlaspack/types@2.15.20
65
+ - @atlaspack/workers@2.14.30
66
+
67
+ ## 2.14.29
68
+
69
+ ### Patch Changes
70
+
71
+ - [#764](https://github.com/atlassian-labs/atlaspack/pull/764) [`58ddd5d`](https://github.com/atlassian-labs/atlaspack/commit/58ddd5d79adde2ac5dc4c60ca575e4705a91e592) Thanks [@mattcompiles](https://github.com/mattcompiles)! - Fix using Atlaspack linked with source files
72
+
73
+ - Updated dependencies [[`53dd47b`](https://github.com/atlassian-labs/atlaspack/commit/53dd47bd6d23cd47f87297347f03a609ab38a03d)]:
74
+ - @atlaspack/node-resolver-core@3.7.0
75
+ - @atlaspack/fs@2.15.24
76
+ - @atlaspack/utils@2.19.1
77
+ - @atlaspack/logger@2.14.21
78
+ - @atlaspack/types@2.15.19
79
+ - @atlaspack/workers@2.14.29
80
+
81
+ ## 2.14.28
82
+
83
+ ### Patch Changes
84
+
85
+ - Updated dependencies [[`f0349a6`](https://github.com/atlassian-labs/atlaspack/commit/f0349a6b9b04755088f121095ca6301a2ada3767)]:
86
+ - @atlaspack/utils@2.19.0
87
+ - @atlaspack/fs@2.15.23
88
+ - @atlaspack/node-resolver-core@3.6.4
89
+ - @atlaspack/workers@2.14.28
90
+ - @atlaspack/logger@2.14.20
91
+ - @atlaspack/types@2.15.18
92
+
93
+ ## 2.14.27
94
+
95
+ ### Patch Changes
96
+
97
+ - Updated dependencies []:
98
+ - @atlaspack/fs@2.15.22
99
+ - @atlaspack/utils@2.18.4
100
+ - @atlaspack/node-resolver-core@3.6.3
101
+ - @atlaspack/logger@2.14.19
102
+ - @atlaspack/types@2.15.17
103
+ - @atlaspack/workers@2.14.27
104
+
105
+ ## 2.14.26
106
+
107
+ ### Patch Changes
108
+
109
+ - [#742](https://github.com/atlassian-labs/atlaspack/pull/742) [`ee040bb`](https://github.com/atlassian-labs/atlaspack/commit/ee040bb6428f29b57d892ddd8107e29077d08ffd) Thanks [@yamadapc](https://github.com/yamadapc)! - Internal changes and bug fixes to environmentDeduplication flag
110
+
111
+ - Updated dependencies [[`ee040bb`](https://github.com/atlassian-labs/atlaspack/commit/ee040bb6428f29b57d892ddd8107e29077d08ffd), [`889c65c`](https://github.com/atlassian-labs/atlaspack/commit/889c65cd25b811045e26a117e7404f694dde77a2)]:
112
+ - @atlaspack/node-resolver-core@3.6.2
113
+ - @atlaspack/build-cache@2.13.5
114
+ - @atlaspack/diagnostic@2.14.3
115
+ - @atlaspack/workers@2.14.26
116
+ - @atlaspack/logger@2.14.18
117
+ - @atlaspack/types@2.15.16
118
+ - @atlaspack/utils@2.18.3
119
+ - @atlaspack/fs@2.15.21
120
+
121
+ ## 2.14.25
122
+
123
+ ### Patch Changes
124
+
125
+ - Updated dependencies []:
126
+ - @atlaspack/fs@2.15.20
127
+ - @atlaspack/utils@2.18.2
128
+ - @atlaspack/node-resolver-core@3.6.1
129
+ - @atlaspack/logger@2.14.17
130
+ - @atlaspack/types@2.15.15
131
+ - @atlaspack/workers@2.14.25
132
+
133
+ ## 2.14.24
134
+
135
+ ### Patch Changes
136
+
137
+ - Updated dependencies [[`7f5841c`](https://github.com/atlassian-labs/atlaspack/commit/7f5841c39df049f9546cccbeea2a7337e0337b45)]:
138
+ - @atlaspack/node-resolver-core@3.6.0
139
+ - @atlaspack/fs@2.15.19
140
+ - @atlaspack/logger@2.14.16
141
+ - @atlaspack/utils@2.18.1
142
+ - @atlaspack/types@2.15.14
143
+ - @atlaspack/workers@2.14.24
144
+
145
+ ## 2.14.23
146
+
147
+ ### Patch Changes
148
+
149
+ - Updated dependencies [[`23d561e`](https://github.com/atlassian-labs/atlaspack/commit/23d561e51e68b0c38fd1ff4e4fb173e5e7b01cf2)]:
150
+ - @atlaspack/utils@2.18.0
151
+ - @atlaspack/fs@2.15.18
152
+ - @atlaspack/node-resolver-core@3.5.23
153
+ - @atlaspack/workers@2.14.23
154
+ - @atlaspack/logger@2.14.15
155
+ - @atlaspack/types@2.15.13
156
+
157
+ ## 2.14.22
158
+
159
+ ### Patch Changes
160
+
161
+ - [#720](https://github.com/atlassian-labs/atlaspack/pull/720) [`d2fd849`](https://github.com/atlassian-labs/atlaspack/commit/d2fd849770fe6305e9c694bd97b1bd905abd9d94) Thanks [@alshdavid](https://github.com/alshdavid)! - Migrate to TypeScript
162
+
163
+ - Updated dependencies [[`d2fd849`](https://github.com/atlassian-labs/atlaspack/commit/d2fd849770fe6305e9c694bd97b1bd905abd9d94)]:
164
+ - @atlaspack/node-resolver-core@3.5.22
165
+ - @atlaspack/build-cache@2.13.4
166
+ - @atlaspack/diagnostic@2.14.2
167
+ - @atlaspack/workers@2.14.22
168
+ - @atlaspack/logger@2.14.14
169
+ - @atlaspack/types@2.15.12
170
+ - @atlaspack/utils@2.17.4
171
+ - @atlaspack/fs@2.15.17
172
+
173
+ ## 2.14.21
174
+
175
+ ### Patch Changes
176
+
177
+ - Updated dependencies []:
178
+ - @atlaspack/fs@2.15.16
179
+ - @atlaspack/types@2.15.11
180
+ - @atlaspack/workers@2.14.21
181
+ - @atlaspack/utils@2.17.3
182
+ - @atlaspack/node-resolver-core@3.5.21
183
+
184
+ ## 2.14.20
185
+
186
+ ### Patch Changes
187
+
188
+ - Updated dependencies []:
189
+ - @atlaspack/fs@2.15.15
190
+ - @atlaspack/utils@2.17.2
191
+ - @atlaspack/node-resolver-core@3.5.20
192
+ - @atlaspack/types@2.15.10
193
+ - @atlaspack/workers@2.14.20
194
+
195
+ ## 2.14.19
196
+
197
+ ### Patch Changes
198
+
199
+ - Updated dependencies []:
200
+ - @atlaspack/fs@2.15.14
201
+ - @atlaspack/utils@2.17.1
202
+ - @atlaspack/node-resolver-core@3.5.19
203
+ - @atlaspack/types@2.15.9
204
+ - @atlaspack/workers@2.14.19
205
+
206
+ ## 2.14.18
207
+
208
+ ### Patch Changes
209
+
210
+ - [#645](https://github.com/atlassian-labs/atlaspack/pull/645) [`de23e0c`](https://github.com/atlassian-labs/atlaspack/commit/de23e0ce49d5504fe3947ac26640a3d951087da3) Thanks [@alshdavid](https://github.com/alshdavid)! - Updated build system and added some extra test-specific code
211
+
212
+ - [#682](https://github.com/atlassian-labs/atlaspack/pull/682) [`a5ed1b4`](https://github.com/atlassian-labs/atlaspack/commit/a5ed1b414498560f393ff491af4da25b6e8dde56) Thanks [@alshdavid](https://github.com/alshdavid)! - Updating build system
213
+
214
+ - Updated dependencies [[`dbb4072`](https://github.com/atlassian-labs/atlaspack/commit/dbb40721ebeb45990a14ba04e6b44e7f836fb32d), [`de23e0c`](https://github.com/atlassian-labs/atlaspack/commit/de23e0ce49d5504fe3947ac26640a3d951087da3), [`18a57cf`](https://github.com/atlassian-labs/atlaspack/commit/18a57cf8a4789b2de5ad8e2676f317a26cc91417), [`a5ed1b4`](https://github.com/atlassian-labs/atlaspack/commit/a5ed1b414498560f393ff491af4da25b6e8dde56)]:
215
+ - @atlaspack/utils@2.17.0
216
+ - @atlaspack/fs@2.15.13
217
+ - @atlaspack/node-resolver-core@3.5.18
218
+ - @atlaspack/workers@2.14.18
219
+ - @atlaspack/logger@2.14.13
220
+ - @atlaspack/types@2.15.8
221
+
222
+ ## 2.14.17
223
+
224
+ ### Patch Changes
225
+
226
+ - Updated dependencies []:
227
+ - @atlaspack/fs@2.15.12
228
+ - @atlaspack/logger@2.14.12
229
+ - @atlaspack/utils@2.16.1
230
+ - @atlaspack/node-resolver-core@3.5.17
231
+ - @atlaspack/workers@2.14.17
232
+ - @atlaspack/types@2.15.7
233
+
234
+ ## 2.14.16
235
+
236
+ ### Patch Changes
237
+
238
+ - Updated dependencies [[`30ee2cf`](https://github.com/atlassian-labs/atlaspack/commit/30ee2cfcd34cf2646ded0eda13fdb80a2a5de529)]:
239
+ - @atlaspack/utils@2.16.0
240
+ - @atlaspack/fs@2.15.11
241
+ - @atlaspack/node-resolver-core@3.5.16
242
+ - @atlaspack/workers@2.14.16
243
+ - @atlaspack/types@2.15.6
244
+
245
+ ## 2.14.15
246
+
247
+ ### Patch Changes
248
+
249
+ - Updated dependencies []:
250
+ - @atlaspack/fs@2.15.10
251
+ - @atlaspack/utils@2.15.3
252
+ - @atlaspack/node-resolver-core@3.5.15
253
+ - @atlaspack/types@2.15.5
254
+ - @atlaspack/workers@2.14.15
255
+
256
+ ## 2.14.14
257
+
258
+ ### Patch Changes
259
+
260
+ - Updated dependencies []:
261
+ - @atlaspack/fs@2.15.9
262
+ - @atlaspack/utils@2.15.2
263
+ - @atlaspack/node-resolver-core@3.5.14
264
+ - @atlaspack/types@2.15.4
265
+ - @atlaspack/workers@2.14.14
266
+
267
+ ## 2.14.13
268
+
269
+ ### Patch Changes
270
+
271
+ - Updated dependencies [[`ef3d622`](https://github.com/atlassian-labs/atlaspack/commit/ef3d6228f4e006702198a19c61e051d194d325cb)]:
272
+ - @atlaspack/workers@2.14.13
273
+ - @atlaspack/logger@2.14.11
274
+ - @atlaspack/fs@2.15.8
275
+ - @atlaspack/types@2.15.3
276
+ - @atlaspack/utils@2.15.1
277
+ - @atlaspack/node-resolver-core@3.5.13
278
+
279
+ ## 2.14.12
280
+
281
+ ### Patch Changes
282
+
283
+ - Updated dependencies [[`e39c6cf`](https://github.com/atlassian-labs/atlaspack/commit/e39c6cf05f7e95ce5420dbcea66f401b1cbd397c)]:
284
+ - @atlaspack/utils@2.15.0
285
+ - @atlaspack/fs@2.15.7
286
+ - @atlaspack/node-resolver-core@3.5.12
287
+ - @atlaspack/workers@2.14.12
288
+ - @atlaspack/types@2.15.2
289
+
290
+ ## 2.14.11
291
+
292
+ ### Patch Changes
293
+
294
+ - Updated dependencies []:
295
+ - @atlaspack/fs@2.15.6
296
+ - @atlaspack/utils@2.14.11
297
+ - @atlaspack/node-resolver-core@3.5.11
298
+ - @atlaspack/types@2.15.1
299
+ - @atlaspack/workers@2.14.11
300
+
301
+ ## 2.14.10
302
+
303
+ ### Patch Changes
304
+
305
+ - Updated dependencies [[`0999fb7`](https://github.com/atlassian-labs/atlaspack/commit/0999fb78da519a6c7582d212883e515fcf6c1252), [`51aba5f`](https://github.com/atlassian-labs/atlaspack/commit/51aba5fc0e49235ee06bbc3c376f48c3e7da5c4b), [`1e32d4e`](https://github.com/atlassian-labs/atlaspack/commit/1e32d4eae6b3af3968e8a0ef97d35b4347fd4196)]:
306
+ - @atlaspack/fs@2.15.5
307
+ - @atlaspack/types@2.15.0
308
+ - @atlaspack/node-resolver-core@3.5.10
309
+ - @atlaspack/workers@2.14.10
310
+ - @atlaspack/logger@2.14.10
311
+ - @atlaspack/utils@2.14.10
312
+
313
+ ## 2.14.9
314
+
315
+ ### Patch Changes
316
+
317
+ - Updated dependencies [[`e4d966c`](https://github.com/atlassian-labs/atlaspack/commit/e4d966c3c9c4292c5013372ae65b10d19d4bacc6)]:
318
+ - @atlaspack/fs@2.15.4
319
+ - @atlaspack/logger@2.14.9
320
+ - @atlaspack/utils@2.14.9
321
+ - @atlaspack/node-resolver-core@3.5.9
322
+ - @atlaspack/workers@2.14.9
323
+ - @atlaspack/types@2.14.9
324
+
325
+ ## 2.14.8
326
+
327
+ ### Patch Changes
328
+
329
+ - Updated dependencies [[`3a3e8e7`](https://github.com/atlassian-labs/atlaspack/commit/3a3e8e7be9e2dffd7304436d792f0f595d59665a), [`1ab0a27`](https://github.com/atlassian-labs/atlaspack/commit/1ab0a275aeca40350415e2b03e7440d1dddc6228), [`b8a4ae8`](https://github.com/atlassian-labs/atlaspack/commit/b8a4ae8f83dc0a83d8b145c5f729936ce52080a3)]:
330
+ - @atlaspack/fs@2.15.3
331
+ - @atlaspack/utils@2.14.8
332
+ - @atlaspack/node-resolver-core@3.5.8
333
+ - @atlaspack/logger@2.14.8
334
+ - @atlaspack/types@2.14.8
335
+ - @atlaspack/workers@2.14.8
336
+
3
337
  ## 2.14.7
4
338
 
5
339
  ### Patch Changes
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const logger_1 = __importDefault(require("@atlaspack/logger"));
7
+ const stream_1 = require("stream");
8
+ // Transforms chunks of json strings to parsed objects.
9
+ // Pair with split2 to parse stream of newline-delimited text.
10
+ class JSONParseStream extends stream_1.Transform {
11
+ constructor(options) {
12
+ // @ts-expect-error TS2698
13
+ super({ ...options, objectMode: true });
14
+ }
15
+ _transform(chunk, encoding, callback) {
16
+ try {
17
+ let parsed;
18
+ try {
19
+ parsed = JSON.parse(chunk.toString());
20
+ }
21
+ catch (e) {
22
+ // Be permissive and ignoreJSON parse errors in case there was
23
+ // a non-JSON line in the package manager's stdout.
24
+ logger_1.default.verbose({
25
+ message: 'Ignored invalid JSON message: ' + chunk.toString(),
26
+ origin: '@atlaspack/package-manager',
27
+ });
28
+ return;
29
+ }
30
+ callback(null, parsed);
31
+ }
32
+ catch (err) {
33
+ callback(err);
34
+ }
35
+ }
36
+ }
37
+ exports.default = JSONParseStream;
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.MockPackageInstaller = void 0;
7
+ const path_1 = __importDefault(require("path"));
8
+ const build_cache_1 = require("@atlaspack/build-cache");
9
+ const fs_1 = require("@atlaspack/fs");
10
+ const package_json_1 = __importDefault(require("../package.json"));
11
+ const utils_1 = require("./utils");
12
+ // This PackageInstaller implementation simply copies files from one filesystem to another.
13
+ // Mostly useful for testing purposes.
14
+ class MockPackageInstaller {
15
+ constructor() {
16
+ this.packages = new Map();
17
+ }
18
+ register(packageName, fs, packagePath) {
19
+ this.packages.set(packageName, { fs, packagePath });
20
+ }
21
+ async install({ modules, fs, cwd, packagePath, saveDev = true, }) {
22
+ if (packagePath == null) {
23
+ packagePath = path_1.default.join(cwd, 'package.json');
24
+ await fs.writeFile(packagePath, '{}');
25
+ }
26
+ let pkg = JSON.parse(await fs.readFile(packagePath, 'utf8'));
27
+ let key = saveDev ? 'devDependencies' : 'dependencies';
28
+ if (!pkg[key]) {
29
+ pkg[key] = {};
30
+ }
31
+ for (let module of modules) {
32
+ pkg[key][module.name] =
33
+ '^' + (await this.installPackage(module, fs, packagePath));
34
+ }
35
+ await fs.writeFile(packagePath, JSON.stringify(pkg));
36
+ }
37
+ async installPackage(moduleRequest, fs, packagePath) {
38
+ let pkg = this.packages.get(moduleRequest.name);
39
+ if (!pkg) {
40
+ throw new Error('Unknown package ' + moduleRequest.name);
41
+ }
42
+ let dest = path_1.default.join(path_1.default.dirname(packagePath), 'node_modules', moduleRequest.name);
43
+ await (0, fs_1.ncp)(pkg.fs, pkg.packagePath, fs, dest);
44
+ let packageJSON = JSON.parse(await fs.readFile(path_1.default.join(dest, 'package.json'), 'utf8'));
45
+ if (packageJSON.dependencies != null) {
46
+ for (let dep of (0, utils_1.moduleRequestsFromDependencyMap)(packageJSON.dependencies)) {
47
+ await this.installPackage(dep, fs, packagePath);
48
+ }
49
+ }
50
+ return packageJSON.version;
51
+ }
52
+ }
53
+ exports.MockPackageInstaller = MockPackageInstaller;
54
+ (0, build_cache_1.registerSerializableClass)(`${package_json_1.default.version}:MockPackageInstaller`, MockPackageInstaller);