@atlaspack/package-manager 2.14.5-canary.16 → 2.14.5-canary.161

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 (49) hide show
  1. package/CHANGELOG.md +228 -0
  2. package/lib/JSONParseStream.js +52 -0
  3. package/lib/MockPackageInstaller.js +79 -0
  4. package/lib/NodePackageManager.js +597 -0
  5. package/lib/Npm.js +106 -0
  6. package/lib/Pnpm.js +185 -0
  7. package/lib/Yarn.js +160 -0
  8. package/lib/getCurrentPackageManager.js +20 -0
  9. package/lib/index.js +64 -5211
  10. package/lib/installPackage.js +222 -0
  11. package/lib/nodejsConditions.js +41 -0
  12. package/lib/promiseFromProcess.js +20 -0
  13. package/lib/types/JSONParseStream.d.ts +6 -0
  14. package/lib/types/MockPackageInstaller.d.ts +14 -0
  15. package/lib/types/NodePackageManager.d.ts +36 -0
  16. package/lib/types/Npm.d.ts +4 -0
  17. package/lib/types/Pnpm.d.ts +5 -0
  18. package/lib/types/Yarn.d.ts +5 -0
  19. package/lib/types/getCurrentPackageManager.d.ts +4 -0
  20. package/lib/types/index.d.ts +10 -0
  21. package/lib/types/installPackage.d.ts +5 -0
  22. package/lib/types/nodejsConditions.d.ts +3 -0
  23. package/lib/types/promiseFromProcess.d.ts +2 -0
  24. package/lib/types/utils.d.ts +15 -0
  25. package/lib/types/validateModuleSpecifier.d.ts +1 -0
  26. package/lib/utils.js +101 -0
  27. package/lib/validateModuleSpecifier.js +14 -0
  28. package/package.json +17 -19
  29. package/src/{JSONParseStream.js → JSONParseStream.ts} +8 -7
  30. package/src/{MockPackageInstaller.js → MockPackageInstaller.ts} +4 -6
  31. package/src/{NodePackageManager.js → NodePackageManager.ts} +83 -57
  32. package/src/{Npm.js → Npm.ts} +9 -9
  33. package/src/{Pnpm.js → Pnpm.ts} +68 -50
  34. package/src/{Yarn.js → Yarn.ts} +38 -25
  35. package/src/{getCurrentPackageManager.js → getCurrentPackageManager.ts} +9 -4
  36. package/src/{index.js → index.ts} +0 -2
  37. package/src/{installPackage.js → installPackage.ts} +4 -6
  38. package/src/{nodejsConditions.js → nodejsConditions.ts} +6 -3
  39. package/src/promiseFromProcess.ts +23 -0
  40. package/src/{utils.js → utils.ts} +21 -11
  41. package/src/{validateModuleSpecifier.js → validateModuleSpecifier.ts} +0 -2
  42. package/test/{NodePackageManager.test.js → NodePackageManager.test.ts} +19 -16
  43. package/test/{getCurrentPackageManager.test.js → getCurrentPackageManager.test.ts} +0 -1
  44. package/test/{validateModuleSpecifiers.test.js → validateModuleSpecifiers.test.ts} +2 -3
  45. package/tsconfig.json +4 -0
  46. package/index.d.ts +0 -40
  47. package/lib/index.d.ts +0 -10
  48. package/lib/index.js.map +0 -1
  49. package/src/promiseFromProcess.js +0 -19
package/CHANGELOG.md CHANGED
@@ -1,5 +1,233 @@
1
1
  # @atlaspack/package-manager
2
2
 
3
+ ## 2.14.25
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies []:
8
+ - @atlaspack/fs@2.15.20
9
+ - @atlaspack/utils@2.18.2
10
+ - @atlaspack/node-resolver-core@3.6.1
11
+ - @atlaspack/logger@2.14.17
12
+ - @atlaspack/types@2.15.15
13
+ - @atlaspack/workers@2.14.25
14
+
15
+ ## 2.14.24
16
+
17
+ ### Patch Changes
18
+
19
+ - Updated dependencies [[`7f5841c`](https://github.com/atlassian-labs/atlaspack/commit/7f5841c39df049f9546cccbeea2a7337e0337b45)]:
20
+ - @atlaspack/node-resolver-core@3.6.0
21
+ - @atlaspack/fs@2.15.19
22
+ - @atlaspack/logger@2.14.16
23
+ - @atlaspack/utils@2.18.1
24
+ - @atlaspack/types@2.15.14
25
+ - @atlaspack/workers@2.14.24
26
+
27
+ ## 2.14.23
28
+
29
+ ### Patch Changes
30
+
31
+ - Updated dependencies [[`23d561e`](https://github.com/atlassian-labs/atlaspack/commit/23d561e51e68b0c38fd1ff4e4fb173e5e7b01cf2)]:
32
+ - @atlaspack/utils@2.18.0
33
+ - @atlaspack/fs@2.15.18
34
+ - @atlaspack/node-resolver-core@3.5.23
35
+ - @atlaspack/workers@2.14.23
36
+ - @atlaspack/logger@2.14.15
37
+ - @atlaspack/types@2.15.13
38
+
39
+ ## 2.14.22
40
+
41
+ ### Patch Changes
42
+
43
+ - [#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
44
+
45
+ - Updated dependencies [[`d2fd849`](https://github.com/atlassian-labs/atlaspack/commit/d2fd849770fe6305e9c694bd97b1bd905abd9d94)]:
46
+ - @atlaspack/node-resolver-core@3.5.22
47
+ - @atlaspack/build-cache@2.13.4
48
+ - @atlaspack/diagnostic@2.14.2
49
+ - @atlaspack/workers@2.14.22
50
+ - @atlaspack/logger@2.14.14
51
+ - @atlaspack/types@2.15.12
52
+ - @atlaspack/utils@2.17.4
53
+ - @atlaspack/fs@2.15.17
54
+
55
+ ## 2.14.21
56
+
57
+ ### Patch Changes
58
+
59
+ - Updated dependencies []:
60
+ - @atlaspack/fs@2.15.16
61
+ - @atlaspack/types@2.15.11
62
+ - @atlaspack/workers@2.14.21
63
+ - @atlaspack/utils@2.17.3
64
+ - @atlaspack/node-resolver-core@3.5.21
65
+
66
+ ## 2.14.20
67
+
68
+ ### Patch Changes
69
+
70
+ - Updated dependencies []:
71
+ - @atlaspack/fs@2.15.15
72
+ - @atlaspack/utils@2.17.2
73
+ - @atlaspack/node-resolver-core@3.5.20
74
+ - @atlaspack/types@2.15.10
75
+ - @atlaspack/workers@2.14.20
76
+
77
+ ## 2.14.19
78
+
79
+ ### Patch Changes
80
+
81
+ - Updated dependencies []:
82
+ - @atlaspack/fs@2.15.14
83
+ - @atlaspack/utils@2.17.1
84
+ - @atlaspack/node-resolver-core@3.5.19
85
+ - @atlaspack/types@2.15.9
86
+ - @atlaspack/workers@2.14.19
87
+
88
+ ## 2.14.18
89
+
90
+ ### Patch Changes
91
+
92
+ - [#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
93
+
94
+ - [#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
95
+
96
+ - 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)]:
97
+ - @atlaspack/utils@2.17.0
98
+ - @atlaspack/fs@2.15.13
99
+ - @atlaspack/node-resolver-core@3.5.18
100
+ - @atlaspack/workers@2.14.18
101
+ - @atlaspack/logger@2.14.13
102
+ - @atlaspack/types@2.15.8
103
+
104
+ ## 2.14.17
105
+
106
+ ### Patch Changes
107
+
108
+ - Updated dependencies []:
109
+ - @atlaspack/fs@2.15.12
110
+ - @atlaspack/logger@2.14.12
111
+ - @atlaspack/utils@2.16.1
112
+ - @atlaspack/node-resolver-core@3.5.17
113
+ - @atlaspack/workers@2.14.17
114
+ - @atlaspack/types@2.15.7
115
+
116
+ ## 2.14.16
117
+
118
+ ### Patch Changes
119
+
120
+ - Updated dependencies [[`30ee2cf`](https://github.com/atlassian-labs/atlaspack/commit/30ee2cfcd34cf2646ded0eda13fdb80a2a5de529)]:
121
+ - @atlaspack/utils@2.16.0
122
+ - @atlaspack/fs@2.15.11
123
+ - @atlaspack/node-resolver-core@3.5.16
124
+ - @atlaspack/workers@2.14.16
125
+ - @atlaspack/types@2.15.6
126
+
127
+ ## 2.14.15
128
+
129
+ ### Patch Changes
130
+
131
+ - Updated dependencies []:
132
+ - @atlaspack/fs@2.15.10
133
+ - @atlaspack/utils@2.15.3
134
+ - @atlaspack/node-resolver-core@3.5.15
135
+ - @atlaspack/types@2.15.5
136
+ - @atlaspack/workers@2.14.15
137
+
138
+ ## 2.14.14
139
+
140
+ ### Patch Changes
141
+
142
+ - Updated dependencies []:
143
+ - @atlaspack/fs@2.15.9
144
+ - @atlaspack/utils@2.15.2
145
+ - @atlaspack/node-resolver-core@3.5.14
146
+ - @atlaspack/types@2.15.4
147
+ - @atlaspack/workers@2.14.14
148
+
149
+ ## 2.14.13
150
+
151
+ ### Patch Changes
152
+
153
+ - Updated dependencies [[`ef3d622`](https://github.com/atlassian-labs/atlaspack/commit/ef3d6228f4e006702198a19c61e051d194d325cb)]:
154
+ - @atlaspack/workers@2.14.13
155
+ - @atlaspack/logger@2.14.11
156
+ - @atlaspack/fs@2.15.8
157
+ - @atlaspack/types@2.15.3
158
+ - @atlaspack/utils@2.15.1
159
+ - @atlaspack/node-resolver-core@3.5.13
160
+
161
+ ## 2.14.12
162
+
163
+ ### Patch Changes
164
+
165
+ - Updated dependencies [[`e39c6cf`](https://github.com/atlassian-labs/atlaspack/commit/e39c6cf05f7e95ce5420dbcea66f401b1cbd397c)]:
166
+ - @atlaspack/utils@2.15.0
167
+ - @atlaspack/fs@2.15.7
168
+ - @atlaspack/node-resolver-core@3.5.12
169
+ - @atlaspack/workers@2.14.12
170
+ - @atlaspack/types@2.15.2
171
+
172
+ ## 2.14.11
173
+
174
+ ### Patch Changes
175
+
176
+ - Updated dependencies []:
177
+ - @atlaspack/fs@2.15.6
178
+ - @atlaspack/utils@2.14.11
179
+ - @atlaspack/node-resolver-core@3.5.11
180
+ - @atlaspack/types@2.15.1
181
+ - @atlaspack/workers@2.14.11
182
+
183
+ ## 2.14.10
184
+
185
+ ### Patch Changes
186
+
187
+ - 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)]:
188
+ - @atlaspack/fs@2.15.5
189
+ - @atlaspack/types@2.15.0
190
+ - @atlaspack/node-resolver-core@3.5.10
191
+ - @atlaspack/workers@2.14.10
192
+ - @atlaspack/logger@2.14.10
193
+ - @atlaspack/utils@2.14.10
194
+
195
+ ## 2.14.9
196
+
197
+ ### Patch Changes
198
+
199
+ - Updated dependencies [[`e4d966c`](https://github.com/atlassian-labs/atlaspack/commit/e4d966c3c9c4292c5013372ae65b10d19d4bacc6)]:
200
+ - @atlaspack/fs@2.15.4
201
+ - @atlaspack/logger@2.14.9
202
+ - @atlaspack/utils@2.14.9
203
+ - @atlaspack/node-resolver-core@3.5.9
204
+ - @atlaspack/workers@2.14.9
205
+ - @atlaspack/types@2.14.9
206
+
207
+ ## 2.14.8
208
+
209
+ ### Patch Changes
210
+
211
+ - 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)]:
212
+ - @atlaspack/fs@2.15.3
213
+ - @atlaspack/utils@2.14.8
214
+ - @atlaspack/node-resolver-core@3.5.8
215
+ - @atlaspack/logger@2.14.8
216
+ - @atlaspack/types@2.14.8
217
+ - @atlaspack/workers@2.14.8
218
+
219
+ ## 2.14.7
220
+
221
+ ### Patch Changes
222
+
223
+ - Updated dependencies [[`556d6ab`](https://github.com/atlassian-labs/atlaspack/commit/556d6ab8ede759fa7f37fcd3f4da336ef1c55e8f)]:
224
+ - @atlaspack/logger@2.14.7
225
+ - @atlaspack/fs@2.15.2
226
+ - @atlaspack/utils@2.14.7
227
+ - @atlaspack/node-resolver-core@3.5.7
228
+ - @atlaspack/workers@2.14.7
229
+ - @atlaspack/types@2.14.7
230
+
3
231
  ## 2.14.6
4
232
 
5
233
  ### Patch Changes
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ function _logger() {
8
+ const data = _interopRequireDefault(require("@atlaspack/logger"));
9
+ _logger = function () {
10
+ return data;
11
+ };
12
+ return data;
13
+ }
14
+ function _stream() {
15
+ const data = require("stream");
16
+ _stream = function () {
17
+ return data;
18
+ };
19
+ return data;
20
+ }
21
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
22
+ // Transforms chunks of json strings to parsed objects.
23
+ // Pair with split2 to parse stream of newline-delimited text.
24
+ class JSONParseStream extends _stream().Transform {
25
+ constructor(options) {
26
+ // @ts-expect-error TS2698
27
+ super({
28
+ ...options,
29
+ objectMode: true
30
+ });
31
+ }
32
+ _transform(chunk, encoding, callback) {
33
+ try {
34
+ let parsed;
35
+ try {
36
+ parsed = JSON.parse(chunk.toString());
37
+ } catch (e) {
38
+ // Be permissive and ignoreJSON parse errors in case there was
39
+ // a non-JSON line in the package manager's stdout.
40
+ _logger().default.verbose({
41
+ message: 'Ignored invalid JSON message: ' + chunk.toString(),
42
+ origin: '@atlaspack/package-manager'
43
+ });
44
+ return;
45
+ }
46
+ callback(null, parsed);
47
+ } catch (err) {
48
+ callback(err);
49
+ }
50
+ }
51
+ }
52
+ exports.default = JSONParseStream;
@@ -0,0 +1,79 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.MockPackageInstaller = void 0;
7
+ function _path() {
8
+ const data = _interopRequireDefault(require("path"));
9
+ _path = function () {
10
+ return data;
11
+ };
12
+ return data;
13
+ }
14
+ function _buildCache() {
15
+ const data = require("@atlaspack/build-cache");
16
+ _buildCache = function () {
17
+ return data;
18
+ };
19
+ return data;
20
+ }
21
+ function _fs() {
22
+ const data = require("@atlaspack/fs");
23
+ _fs = function () {
24
+ return data;
25
+ };
26
+ return data;
27
+ }
28
+ var _package = _interopRequireDefault(require("../package.json"));
29
+ var _utils = require("./utils");
30
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
31
+ // This PackageInstaller implementation simply copies files from one filesystem to another.
32
+ // Mostly useful for testing purposes.
33
+ class MockPackageInstaller {
34
+ packages = new Map();
35
+ register(packageName, fs, packagePath) {
36
+ this.packages.set(packageName, {
37
+ fs,
38
+ packagePath
39
+ });
40
+ }
41
+ async install({
42
+ modules,
43
+ fs,
44
+ cwd,
45
+ packagePath,
46
+ saveDev = true
47
+ }) {
48
+ if (packagePath == null) {
49
+ packagePath = _path().default.join(cwd, 'package.json');
50
+ await fs.writeFile(packagePath, '{}');
51
+ }
52
+ let pkg = JSON.parse(await fs.readFile(packagePath, 'utf8'));
53
+ let key = saveDev ? 'devDependencies' : 'dependencies';
54
+ if (!pkg[key]) {
55
+ pkg[key] = {};
56
+ }
57
+ for (let module of modules) {
58
+ pkg[key][module.name] = '^' + (await this.installPackage(module, fs, packagePath));
59
+ }
60
+ await fs.writeFile(packagePath, JSON.stringify(pkg));
61
+ }
62
+ async installPackage(moduleRequest, fs, packagePath) {
63
+ let pkg = this.packages.get(moduleRequest.name);
64
+ if (!pkg) {
65
+ throw new Error('Unknown package ' + moduleRequest.name);
66
+ }
67
+ let dest = _path().default.join(_path().default.dirname(packagePath), 'node_modules', moduleRequest.name);
68
+ await (0, _fs().ncp)(pkg.fs, pkg.packagePath, fs, dest);
69
+ let packageJSON = JSON.parse(await fs.readFile(_path().default.join(dest, 'package.json'), 'utf8'));
70
+ if (packageJSON.dependencies != null) {
71
+ for (let dep of (0, _utils.moduleRequestsFromDependencyMap)(packageJSON.dependencies)) {
72
+ await this.installPackage(dep, fs, packagePath);
73
+ }
74
+ }
75
+ return packageJSON.version;
76
+ }
77
+ }
78
+ exports.MockPackageInstaller = MockPackageInstaller;
79
+ (0, _buildCache().registerSerializableClass)(`${_package.default.version}:MockPackageInstaller`, MockPackageInstaller);