@atlaspack/package-manager 2.14.5-canary.14 → 2.14.5-canary.140

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 (48) hide show
  1. package/CHANGELOG.md +188 -0
  2. package/lib/JSONParseStream.d.ts +6 -0
  3. package/lib/JSONParseStream.js +52 -0
  4. package/lib/MockPackageInstaller.d.ts +14 -0
  5. package/lib/MockPackageInstaller.js +79 -0
  6. package/lib/NodePackageManager.d.ts +36 -0
  7. package/lib/NodePackageManager.js +602 -0
  8. package/lib/Npm.d.ts +4 -0
  9. package/lib/Npm.js +106 -0
  10. package/lib/Pnpm.d.ts +5 -0
  11. package/lib/Pnpm.js +185 -0
  12. package/lib/Yarn.d.ts +5 -0
  13. package/lib/Yarn.js +160 -0
  14. package/lib/getCurrentPackageManager.d.ts +4 -0
  15. package/lib/getCurrentPackageManager.js +20 -0
  16. package/lib/index.d.ts +8 -8
  17. package/lib/index.js +64 -5211
  18. package/lib/installPackage.d.ts +5 -0
  19. package/lib/installPackage.js +223 -0
  20. package/lib/nodejsConditions.d.ts +3 -0
  21. package/lib/nodejsConditions.js +41 -0
  22. package/lib/promiseFromProcess.d.ts +2 -0
  23. package/lib/promiseFromProcess.js +20 -0
  24. package/lib/utils.d.ts +15 -0
  25. package/lib/utils.js +101 -0
  26. package/lib/validateModuleSpecifier.d.ts +1 -0
  27. package/lib/validateModuleSpecifier.js +14 -0
  28. package/package.json +16 -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} +88 -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} +5 -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.js.map +0 -1
  48. package/src/promiseFromProcess.js +0 -19
package/CHANGELOG.md CHANGED
@@ -1,5 +1,193 @@
1
1
  # @atlaspack/package-manager
2
2
 
3
+ ## 2.14.21
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies []:
8
+ - @atlaspack/fs@2.15.16
9
+ - @atlaspack/types@2.15.11
10
+ - @atlaspack/workers@2.14.21
11
+ - @atlaspack/utils@2.17.3
12
+ - @atlaspack/node-resolver-core@3.5.21
13
+
14
+ ## 2.14.20
15
+
16
+ ### Patch Changes
17
+
18
+ - Updated dependencies []:
19
+ - @atlaspack/fs@2.15.15
20
+ - @atlaspack/utils@2.17.2
21
+ - @atlaspack/node-resolver-core@3.5.20
22
+ - @atlaspack/types@2.15.10
23
+ - @atlaspack/workers@2.14.20
24
+
25
+ ## 2.14.19
26
+
27
+ ### Patch Changes
28
+
29
+ - Updated dependencies []:
30
+ - @atlaspack/fs@2.15.14
31
+ - @atlaspack/utils@2.17.1
32
+ - @atlaspack/node-resolver-core@3.5.19
33
+ - @atlaspack/types@2.15.9
34
+ - @atlaspack/workers@2.14.19
35
+
36
+ ## 2.14.18
37
+
38
+ ### Patch Changes
39
+
40
+ - [#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
41
+
42
+ - [#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
43
+
44
+ - 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)]:
45
+ - @atlaspack/utils@2.17.0
46
+ - @atlaspack/fs@2.15.13
47
+ - @atlaspack/node-resolver-core@3.5.18
48
+ - @atlaspack/workers@2.14.18
49
+ - @atlaspack/logger@2.14.13
50
+ - @atlaspack/types@2.15.8
51
+
52
+ ## 2.14.17
53
+
54
+ ### Patch Changes
55
+
56
+ - Updated dependencies []:
57
+ - @atlaspack/fs@2.15.12
58
+ - @atlaspack/logger@2.14.12
59
+ - @atlaspack/utils@2.16.1
60
+ - @atlaspack/node-resolver-core@3.5.17
61
+ - @atlaspack/workers@2.14.17
62
+ - @atlaspack/types@2.15.7
63
+
64
+ ## 2.14.16
65
+
66
+ ### Patch Changes
67
+
68
+ - Updated dependencies [[`30ee2cf`](https://github.com/atlassian-labs/atlaspack/commit/30ee2cfcd34cf2646ded0eda13fdb80a2a5de529)]:
69
+ - @atlaspack/utils@2.16.0
70
+ - @atlaspack/fs@2.15.11
71
+ - @atlaspack/node-resolver-core@3.5.16
72
+ - @atlaspack/workers@2.14.16
73
+ - @atlaspack/types@2.15.6
74
+
75
+ ## 2.14.15
76
+
77
+ ### Patch Changes
78
+
79
+ - Updated dependencies []:
80
+ - @atlaspack/fs@2.15.10
81
+ - @atlaspack/utils@2.15.3
82
+ - @atlaspack/node-resolver-core@3.5.15
83
+ - @atlaspack/types@2.15.5
84
+ - @atlaspack/workers@2.14.15
85
+
86
+ ## 2.14.14
87
+
88
+ ### Patch Changes
89
+
90
+ - Updated dependencies []:
91
+ - @atlaspack/fs@2.15.9
92
+ - @atlaspack/utils@2.15.2
93
+ - @atlaspack/node-resolver-core@3.5.14
94
+ - @atlaspack/types@2.15.4
95
+ - @atlaspack/workers@2.14.14
96
+
97
+ ## 2.14.13
98
+
99
+ ### Patch Changes
100
+
101
+ - Updated dependencies [[`ef3d622`](https://github.com/atlassian-labs/atlaspack/commit/ef3d6228f4e006702198a19c61e051d194d325cb)]:
102
+ - @atlaspack/workers@2.14.13
103
+ - @atlaspack/logger@2.14.11
104
+ - @atlaspack/fs@2.15.8
105
+ - @atlaspack/types@2.15.3
106
+ - @atlaspack/utils@2.15.1
107
+ - @atlaspack/node-resolver-core@3.5.13
108
+
109
+ ## 2.14.12
110
+
111
+ ### Patch Changes
112
+
113
+ - Updated dependencies [[`e39c6cf`](https://github.com/atlassian-labs/atlaspack/commit/e39c6cf05f7e95ce5420dbcea66f401b1cbd397c)]:
114
+ - @atlaspack/utils@2.15.0
115
+ - @atlaspack/fs@2.15.7
116
+ - @atlaspack/node-resolver-core@3.5.12
117
+ - @atlaspack/workers@2.14.12
118
+ - @atlaspack/types@2.15.2
119
+
120
+ ## 2.14.11
121
+
122
+ ### Patch Changes
123
+
124
+ - Updated dependencies []:
125
+ - @atlaspack/fs@2.15.6
126
+ - @atlaspack/utils@2.14.11
127
+ - @atlaspack/node-resolver-core@3.5.11
128
+ - @atlaspack/types@2.15.1
129
+ - @atlaspack/workers@2.14.11
130
+
131
+ ## 2.14.10
132
+
133
+ ### Patch Changes
134
+
135
+ - 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)]:
136
+ - @atlaspack/fs@2.15.5
137
+ - @atlaspack/types@2.15.0
138
+ - @atlaspack/node-resolver-core@3.5.10
139
+ - @atlaspack/workers@2.14.10
140
+ - @atlaspack/logger@2.14.10
141
+ - @atlaspack/utils@2.14.10
142
+
143
+ ## 2.14.9
144
+
145
+ ### Patch Changes
146
+
147
+ - Updated dependencies [[`e4d966c`](https://github.com/atlassian-labs/atlaspack/commit/e4d966c3c9c4292c5013372ae65b10d19d4bacc6)]:
148
+ - @atlaspack/fs@2.15.4
149
+ - @atlaspack/logger@2.14.9
150
+ - @atlaspack/utils@2.14.9
151
+ - @atlaspack/node-resolver-core@3.5.9
152
+ - @atlaspack/workers@2.14.9
153
+ - @atlaspack/types@2.14.9
154
+
155
+ ## 2.14.8
156
+
157
+ ### Patch Changes
158
+
159
+ - 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)]:
160
+ - @atlaspack/fs@2.15.3
161
+ - @atlaspack/utils@2.14.8
162
+ - @atlaspack/node-resolver-core@3.5.8
163
+ - @atlaspack/logger@2.14.8
164
+ - @atlaspack/types@2.14.8
165
+ - @atlaspack/workers@2.14.8
166
+
167
+ ## 2.14.7
168
+
169
+ ### Patch Changes
170
+
171
+ - Updated dependencies [[`556d6ab`](https://github.com/atlassian-labs/atlaspack/commit/556d6ab8ede759fa7f37fcd3f4da336ef1c55e8f)]:
172
+ - @atlaspack/logger@2.14.7
173
+ - @atlaspack/fs@2.15.2
174
+ - @atlaspack/utils@2.14.7
175
+ - @atlaspack/node-resolver-core@3.5.7
176
+ - @atlaspack/workers@2.14.7
177
+ - @atlaspack/types@2.14.7
178
+
179
+ ## 2.14.6
180
+
181
+ ### Patch Changes
182
+
183
+ - Updated dependencies []:
184
+ - @atlaspack/fs@2.15.1
185
+ - @atlaspack/utils@2.14.6
186
+ - @atlaspack/node-resolver-core@3.5.6
187
+ - @atlaspack/logger@2.14.6
188
+ - @atlaspack/types@2.14.6
189
+ - @atlaspack/workers@2.14.6
190
+
3
191
  ## 2.14.5
4
192
 
5
193
  ### Patch Changes
@@ -0,0 +1,6 @@
1
+ import type { JSONObject } from '@atlaspack/types';
2
+ import { Transform } from 'stream';
3
+ export default class JSONParseStream extends Transform {
4
+ constructor(options: unknown);
5
+ _transform(chunk: Buffer | string, encoding: string, callback: (err?: Error | null | undefined, parsed?: JSONObject | null | undefined) => unknown): void;
6
+ }
@@ -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,14 @@
1
+ import type { ModuleRequest, PackageInstaller, InstallerOptions } from '@atlaspack/types';
2
+ import type { FileSystem } from '@atlaspack/fs';
3
+ import type { FilePath } from '@atlaspack/types';
4
+ type Package = {
5
+ fs: FileSystem;
6
+ packagePath: FilePath;
7
+ };
8
+ export declare class MockPackageInstaller implements PackageInstaller {
9
+ packages: Map<string, Package>;
10
+ register(packageName: string, fs: FileSystem, packagePath: FilePath): void;
11
+ install({ modules, fs, cwd, packagePath, saveDev, }: InstallerOptions): Promise<void>;
12
+ installPackage(moduleRequest: ModuleRequest, fs: FileSystem, packagePath: FilePath): Promise<any>;
13
+ }
14
+ export {};
@@ -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);
@@ -0,0 +1,36 @@
1
+ import type { FilePath, DependencySpecifier, SemverRange } from '@atlaspack/types';
2
+ import type { FileSystem } from '@atlaspack/fs';
3
+ import type { ModuleRequest, PackageManager, PackageInstaller, InstallOptions, Invalidations, PackageManagerResolveResult } from '@atlaspack/types';
4
+ export declare class NodePackageManager implements PackageManager {
5
+ fs: FileSystem;
6
+ projectRoot: FilePath;
7
+ installer: PackageInstaller | null | undefined;
8
+ resolver: ResolverBase;
9
+ currentExtensions: Array<string>;
10
+ constructor(fs: FileSystem, projectRoot: FilePath, installer?: PackageInstaller | null);
11
+ _createResolver(): ResolverBase;
12
+ static deserialize(opts: any): NodePackageManager;
13
+ serialize(): {
14
+ $$raw: boolean;
15
+ fs: FileSystem;
16
+ projectRoot: FilePath;
17
+ installer: PackageInstaller | null | undefined;
18
+ };
19
+ require(name: DependencySpecifier, from: FilePath, opts?: {
20
+ range?: SemverRange | null | undefined;
21
+ shouldAutoInstall?: boolean;
22
+ saveDev?: boolean;
23
+ } | null): Promise<any>;
24
+ requireSync(name: DependencySpecifier, from: FilePath): any;
25
+ load(filePath: FilePath, from: FilePath): any;
26
+ resolve(id: DependencySpecifier, from: FilePath, options?: {
27
+ range?: SemverRange | null | undefined;
28
+ shouldAutoInstall?: boolean;
29
+ saveDev?: boolean;
30
+ } | null): Promise<PackageManagerResolveResult>;
31
+ resolveSync(name: DependencySpecifier, from: FilePath): PackageManagerResolveResult;
32
+ install(modules: Array<ModuleRequest>, from: FilePath, opts?: InstallOptions): Promise<void>;
33
+ getInvalidations(name: DependencySpecifier, from: FilePath): Invalidations;
34
+ invalidate(name: DependencySpecifier, from: FilePath): void;
35
+ resolveInternal(name: string, from: string): PackageManagerResolveResult;
36
+ }