@atlaspack/package-manager 2.14.5-canary.138 → 2.14.5-canary.139

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 (42) hide show
  1. package/lib/JSONParseStream.d.ts +6 -0
  2. package/lib/JSONParseStream.js +1 -2
  3. package/lib/MockPackageInstaller.d.ts +14 -0
  4. package/lib/NodePackageManager.d.ts +36 -0
  5. package/lib/NodePackageManager.js +44 -24
  6. package/lib/Npm.d.ts +4 -0
  7. package/lib/Npm.js +2 -1
  8. package/lib/Pnpm.d.ts +5 -0
  9. package/lib/Pnpm.js +18 -4
  10. package/lib/Yarn.d.ts +5 -0
  11. package/lib/Yarn.js +17 -3
  12. package/lib/getCurrentPackageManager.d.ts +4 -0
  13. package/lib/getCurrentPackageManager.js +3 -1
  14. package/lib/index.d.ts +8 -8
  15. package/lib/installPackage.d.ts +5 -0
  16. package/lib/installPackage.js +1 -0
  17. package/lib/nodejsConditions.d.ts +3 -0
  18. package/lib/nodejsConditions.js +6 -0
  19. package/lib/promiseFromProcess.d.ts +2 -0
  20. package/lib/promiseFromProcess.js +2 -0
  21. package/lib/utils.d.ts +15 -0
  22. package/lib/validateModuleSpecifier.d.ts +1 -0
  23. package/package.json +15 -16
  24. package/src/{JSONParseStream.js → JSONParseStream.ts} +8 -7
  25. package/src/{MockPackageInstaller.js → MockPackageInstaller.ts} +4 -6
  26. package/src/{NodePackageManager.js → NodePackageManager.ts} +72 -51
  27. package/src/{Npm.js → Npm.ts} +9 -9
  28. package/src/{Pnpm.js → Pnpm.ts} +68 -50
  29. package/src/{Yarn.js → Yarn.ts} +38 -25
  30. package/src/{getCurrentPackageManager.js → getCurrentPackageManager.ts} +9 -4
  31. package/src/{index.js → index.ts} +0 -2
  32. package/src/{installPackage.js → installPackage.ts} +5 -6
  33. package/src/{nodejsConditions.js → nodejsConditions.ts} +6 -3
  34. package/src/promiseFromProcess.ts +23 -0
  35. package/src/{utils.js → utils.ts} +21 -11
  36. package/src/{validateModuleSpecifier.js → validateModuleSpecifier.ts} +0 -2
  37. package/test/{NodePackageManager.test.js → NodePackageManager.test.ts} +13 -15
  38. package/test/{getCurrentPackageManager.test.js → getCurrentPackageManager.test.ts} +0 -1
  39. package/test/{validateModuleSpecifiers.test.js → validateModuleSpecifiers.test.ts} +2 -3
  40. package/tsconfig.json +4 -0
  41. package/index.d.ts +0 -40
  42. package/src/promiseFromProcess.js +0 -19
@@ -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
+ }
@@ -23,13 +23,12 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
23
23
  // Pair with split2 to parse stream of newline-delimited text.
24
24
  class JSONParseStream extends _stream().Transform {
25
25
  constructor(options) {
26
+ // @ts-expect-error TS2698
26
27
  super({
27
28
  ...options,
28
29
  objectMode: true
29
30
  });
30
31
  }
31
-
32
- // $FlowFixMe We are in object mode, so we emit objects, not strings
33
32
  _transform(chunk, encoding, callback) {
34
33
  try {
35
34
  let parsed;
@@ -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,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
+ }
@@ -123,14 +123,18 @@ const invalidationsCache = new Map();
123
123
  // See https://github.com/nodejs/node/blob/master/lib/internal/modules/cjs/loader.js
124
124
  // for reference to Node internals.
125
125
  class NodePackageManager {
126
+ // @ts-expect-error TS2749
127
+
126
128
  constructor(fs, projectRoot, installer) {
127
129
  this.fs = fs;
128
130
  this.projectRoot = projectRoot;
129
131
  this.installer = installer;
130
132
 
131
- // $FlowFixMe - no type for _extensions
133
+ // @ts-expect-error TS2339
132
134
  this.currentExtensions = Object.keys(_module().default._extensions).map(e => e.substring(1));
133
135
  }
136
+
137
+ // @ts-expect-error TS2749
134
138
  _createResolver() {
135
139
  return new (_nodeResolverCore().ResolverBase)(this.projectRoot, {
136
140
  fs: this.fs instanceof _fs().NodeFS && process.versions.pnp == null ? undefined : {
@@ -143,7 +147,7 @@ class NodePackageManager {
143
147
  entries: ENTRIES,
144
148
  packageExports: true,
145
149
  moduleDirResolver: process.versions.pnp != null ? (module, from) => {
146
- // $FlowFixMe[prop-missing]
150
+ // @ts-expect-error TS2339
147
151
  let pnp = _module().default.findPnpApi(_path().default.dirname(from));
148
152
  return pnp.resolveToUnqualified(
149
153
  // append slash to force loading builtins from npm
@@ -181,10 +185,9 @@ class NodePackageManager {
181
185
 
182
186
  // On Windows, Node requires absolute paths to be file URLs.
183
187
  if (process.platform === 'win32' && _path().default.isAbsolute(resolved)) {
188
+ // @ts-expect-error TS2322
184
189
  resolved = (0, _url().pathToFileURL)(resolved);
185
190
  }
186
-
187
- // $FlowFixMe
188
191
  return import(resolved);
189
192
  }
190
193
  return this.load(resolved, from);
@@ -198,20 +201,19 @@ class NodePackageManager {
198
201
  load(filePath, from) {
199
202
  if (!_path().default.isAbsolute(filePath)) {
200
203
  // Node builtin module
201
- // $FlowFixMe
202
204
  return require(filePath);
203
205
  }
204
206
 
205
- // $FlowFixMe[prop-missing]
207
+ // @ts-expect-error TS2339
206
208
  const cachedModule = _module().default._cache[filePath];
207
209
  if (cachedModule !== undefined) {
208
210
  return cachedModule.exports;
209
211
  }
210
212
 
211
- // $FlowFixMe
213
+ // @ts-expect-error TS2339
212
214
  let m = new (_module().default)(filePath, _module().default._cache[from] || module.parent);
213
215
 
214
- // $FlowFixMe _extensions not in type
216
+ // @ts-expect-error TS2339
215
217
  const extensions = Object.keys(_module().default._extensions);
216
218
  // This handles supported extensions changing due to, for example, esbuild/register being used
217
219
  // We assume that the extension list will change in size - as these tools usually add support for
@@ -221,7 +223,7 @@ class NodePackageManager {
221
223
  this.resolver = this._createResolver();
222
224
  }
223
225
 
224
- // $FlowFixMe[prop-missing]
226
+ // @ts-expect-error TS2339
225
227
  _module().default._cache[filePath] = m;
226
228
 
227
229
  // Patch require within this module so it goes through our require
@@ -234,21 +236,23 @@ class NodePackageManager {
234
236
  readFileSync,
235
237
  statSync
236
238
  } = _fs2().default;
237
- // $FlowFixMe
239
+ // @ts-expect-error TS2322
238
240
  _fs2().default.readFileSync = (filename, encoding) => {
239
241
  return this.fs.readFileSync(filename, encoding);
240
242
  };
241
243
 
242
- // $FlowFixMe
244
+ // @ts-expect-error TS2540
243
245
  _fs2().default.statSync = filename => {
244
246
  return this.fs.statSync(filename);
245
247
  };
246
248
  if (!filePath.includes(NODE_MODULES)) {
247
249
  let extname = _path().default.extname(filePath);
248
250
  if ((extname === '.ts' || extname === '.tsx' || extname === '.mts' || extname === '.cts') &&
249
- // $FlowFixMe
251
+ // @ts-expect-error TS2339
250
252
  !_module().default._extensions[extname]) {
253
+ // @ts-expect-error TS2339
251
254
  let compile = m._compile;
255
+ // @ts-expect-error TS2339
252
256
  m._compile = (code, filename) => {
253
257
  let out = (0, _core().transformSync)(code, {
254
258
  filename,
@@ -259,25 +263,25 @@ class NodePackageManager {
259
263
  compile.call(m, out.code, filename);
260
264
  };
261
265
 
262
- // $FlowFixMe
266
+ // @ts-expect-error TS2339
263
267
  _module().default._extensions[extname] = (m, filename) => {
264
- // $FlowFixMe
268
+ // @ts-expect-error TS2339
265
269
  delete _module().default._extensions[extname];
266
- // $FlowFixMe
270
+ // @ts-expect-error TS2339
267
271
  _module().default._extensions['.js'](m, filename);
268
272
  };
269
273
  }
270
274
  }
271
275
  try {
276
+ // @ts-expect-error TS2339
272
277
  m.load(filePath);
273
278
  } catch (err) {
274
- // $FlowFixMe[prop-missing]
279
+ // @ts-expect-error TS2339
275
280
  delete _module().default._cache[filePath];
276
281
  throw err;
277
282
  } finally {
278
- // $FlowFixMe
279
283
  _fs2().default.readFileSync = readFileSync;
280
- // $FlowFixMe
284
+ // @ts-expect-error TS2540
281
285
  _fs2().default.statSync = statSync;
282
286
  }
283
287
  return m.exports;
@@ -300,7 +304,7 @@ class NodePackageManager {
300
304
  hints: ['Autoinstall is disabled, please install this package manually and restart Parcel.']
301
305
  }
302
306
  });
303
- // $FlowFixMe - needed for loadParcelPlugin
307
+ // @ts-expect-error TS2339
304
308
  err.code = 'MODULE_NOT_FOUND';
305
309
  throw err;
306
310
  } else {
@@ -323,6 +327,7 @@ class NodePackageManager {
323
327
  }
324
328
  throw new (_diagnostic().default)({
325
329
  diagnostic: conflicts.fields.map(field => ({
330
+ // @ts-expect-error TS2345
326
331
  message: (0, _diagnostic().md)`Could not find module "${name}", but it was listed in package.json. Run your package manager first.`,
327
332
  origin: '@atlaspack/package-manager',
328
333
  codeFrames: [{
@@ -356,6 +361,7 @@ class NodePackageManager {
356
361
  } else if (conflicts != null) {
357
362
  throw new (_diagnostic().default)({
358
363
  diagnostic: {
364
+ // @ts-expect-error TS2345
359
365
  message: (0, _diagnostic().md)`Could not find module "${name}" satisfying ${range}.`,
360
366
  origin: '@atlaspack/package-manager',
361
367
  codeFrames: [{
@@ -372,8 +378,10 @@ class NodePackageManager {
372
378
  });
373
379
  }
374
380
  let version = pkg === null || pkg === void 0 ? void 0 : pkg.version;
381
+ // @ts-expect-error TS2345
375
382
  let message = (0, _diagnostic().md)`Could not resolve package "${name}" that satisfies ${range}.`;
376
383
  if (version != null) {
384
+ // @ts-expect-error TS2345
377
385
  message += (0, _diagnostic().md)` Found ${version}.`;
378
386
  }
379
387
  throw new (_diagnostic().default)({
@@ -452,6 +460,8 @@ class NodePackageManager {
452
460
  if (!resolved || !_path().default.isAbsolute(resolved.resolved)) {
453
461
  return;
454
462
  }
463
+
464
+ // @ts-expect-error TS2345
455
465
  res.invalidateOnFileCreate.push(...resolved.invalidateOnFileCreate);
456
466
  res.invalidateOnFileChange.add(resolved.resolved);
457
467
  for (let file of resolved.invalidateOnFileChange) {
@@ -470,17 +480,25 @@ class NodePackageManager {
470
480
  // cannot be intercepted. Instead, ask the resolver to parse the file and recursively analyze the deps.
471
481
  if (resolved.type === 2) {
472
482
  let invalidations = this.resolver.getInvalidations(resolved.resolved);
483
+ // @ts-expect-error TS7006
473
484
  invalidations.invalidateOnFileChange.forEach(i => res.invalidateOnFileChange.add(i));
474
- invalidations.invalidateOnFileCreate.forEach(i => res.invalidateOnFileCreate.push(i));
485
+ // @ts-expect-error TS7006
486
+ invalidations.invalidateOnFileCreate.forEach(i =>
487
+ // @ts-expect-error TS2345
488
+ res.invalidateOnFileCreate.push(i));
475
489
  res.invalidateOnStartup ||= invalidations.invalidateOnStartup;
476
490
  if (res.invalidateOnStartup) {
477
491
  _logger().default.warn({
492
+ // @ts-expect-error TS2345
478
493
  message: (0, _diagnostic().md)`${_path().default.relative(this.projectRoot, resolved.resolved)} contains non-statically analyzable dependencies in its module graph. This causes Parcel to invalidate the cache on startup.`,
479
494
  origin: '@atlaspack/package-manager'
480
495
  });
481
496
  }
482
497
  }
498
+
499
+ // @ts-expect-error TS2345
483
500
  invalidationsCache.set(resolved.resolved, res);
501
+ // @ts-expect-error TS2322
484
502
  return res;
485
503
  }
486
504
  return {
@@ -513,10 +531,10 @@ class NodePackageManager {
513
531
  }
514
532
  invalidationsCache.delete(resolved.resolved);
515
533
 
516
- // $FlowFixMe
534
+ // @ts-expect-error TS2339
517
535
  let module = _module().default._cache[resolved.resolved];
518
536
  if (module) {
519
- // $FlowFixMe
537
+ // @ts-expect-error TS2339
520
538
  delete _module().default._cache[resolved.resolved];
521
539
  }
522
540
  let moduleChildren = children.get(resolved.resolved);
@@ -545,16 +563,17 @@ class NodePackageManager {
545
563
  // Invalidate whenever the .pnp.js file changes.
546
564
  // TODO: only when we actually resolve a node_modules package?
547
565
  if (process.versions.pnp != null && res.invalidateOnFileChange) {
548
- // $FlowFixMe[prop-missing]
566
+ // @ts-expect-error TS2339
549
567
  let pnp = _module().default.findPnpApi(_path().default.dirname(from));
550
568
  res.invalidateOnFileChange.push(pnp.resolveToUnqualified('pnpapi', null));
551
569
  }
552
570
  if (res.error) {
553
571
  let e = new Error(`Could not resolve module "${name}" from "${from}"`);
554
- // $FlowFixMe
572
+ // @ts-expect-error TS2339
555
573
  e.code = 'MODULE_NOT_FOUND';
556
574
  throw e;
557
575
  }
576
+ // @ts-expect-error TS7034
558
577
  let getPkg;
559
578
  switch (res.resolution.type) {
560
579
  case 'Path':
@@ -570,6 +589,7 @@ class NodePackageManager {
570
589
  invalidateOnFileCreate: res.invalidateOnFileCreate,
571
590
  type: res.moduleType,
572
591
  get pkg() {
592
+ // @ts-expect-error TS7005
573
593
  return getPkg();
574
594
  }
575
595
  };
package/lib/Npm.d.ts ADDED
@@ -0,0 +1,4 @@
1
+ import type { PackageInstaller, InstallerOptions } from '@atlaspack/types';
2
+ export declare class Npm implements PackageInstaller {
3
+ install({ modules, cwd, fs, packagePath, saveDev, }: InstallerOptions): Promise<void>;
4
+ }
package/lib/Npm.js CHANGED
@@ -36,7 +36,8 @@ var _promiseFromProcess = _interopRequireDefault(require("./promiseFromProcess")
36
36
  var _utils = require("./utils");
37
37
  var _package = _interopRequireDefault(require("../package.json"));
38
38
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
39
- // $FlowFixMe
39
+ // @ts-expect-error TS7016
40
+
40
41
  const NPM_CMD = 'npm';
41
42
  class Npm {
42
43
  async install({
package/lib/Pnpm.d.ts ADDED
@@ -0,0 +1,5 @@
1
+ import type { PackageInstaller, InstallerOptions } from '@atlaspack/types';
2
+ export declare class Pnpm implements PackageInstaller {
3
+ static exists(): Promise<boolean>;
4
+ install({ modules, cwd, saveDev, }: InstallerOptions): Promise<void>;
5
+ }
package/lib/Pnpm.js CHANGED
@@ -58,7 +58,12 @@ var _promiseFromProcess = _interopRequireDefault(require("./promiseFromProcess")
58
58
  var _utils = require("./utils");
59
59
  var _package = _interopRequireDefault(require("../package.json"));
60
60
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
61
- // $FlowFixMe
61
+ // @ts-expect-error TS7016
62
+
63
+ // @ts-expect-error TS7016
64
+
65
+ // @ts-expect-error TS7016
66
+
62
67
  const PNPM_CMD = 'pnpm';
63
68
  let hasPnpm;
64
69
  let pnpmVersion;
@@ -81,6 +86,7 @@ class Pnpm {
81
86
  }) {
82
87
  if (pnpmVersion == null) {
83
88
  let version = await (0, _utils.exec)('pnpm --version');
89
+ // @ts-expect-error TS2345
84
90
  pnpmVersion = parseInt(version.stdout, 10);
85
91
  }
86
92
  let args = ['add', '--reporter', 'ndjson'];
@@ -109,7 +115,11 @@ class Pnpm {
109
115
  cwd,
110
116
  env
111
117
  });
112
- installProcess.stdout.pipe((0, _split().default)()).pipe(new _JSONParseStream.default()).on('error', e => {
118
+ installProcess.stdout.pipe((0, _split().default)())
119
+ // @ts-expect-error TS2554
120
+ .pipe(new _JSONParseStream.default())
121
+ // @ts-expect-error TS7006
122
+ .on('error', e => {
113
123
  _logger().default.warn({
114
124
  origin: '@atlaspack/package-manager',
115
125
  message: e.chunk,
@@ -133,9 +143,13 @@ class Pnpm {
133
143
  }
134
144
  });
135
145
  let stderr = [];
136
- installProcess.stderr.on('data', str => {
146
+ installProcess.stderr
147
+ // @ts-expect-error TS7006
148
+ .on('data', str => {
137
149
  stderr.push(str.toString());
138
- }).on('error', e => {
150
+ })
151
+ // @ts-expect-error TS7006
152
+ .on('error', e => {
139
153
  _logger().default.warn({
140
154
  origin: '@atlaspack/package-manager',
141
155
  message: e.message
package/lib/Yarn.d.ts ADDED
@@ -0,0 +1,5 @@
1
+ import type { PackageInstaller, InstallerOptions } from '@atlaspack/types';
2
+ export declare class Yarn implements PackageInstaller {
3
+ static exists(): Promise<boolean>;
4
+ install({ modules, cwd, saveDev, }: InstallerOptions): Promise<void>;
5
+ }
package/lib/Yarn.js CHANGED
@@ -44,7 +44,12 @@ var _promiseFromProcess = _interopRequireDefault(require("./promiseFromProcess")
44
44
  var _utils = require("./utils");
45
45
  var _package = _interopRequireDefault(require("../package.json"));
46
46
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
47
- // $FlowFixMe
47
+ // @ts-expect-error TS7016
48
+
49
+ // @ts-expect-error TS7016
50
+
51
+ // @ts-expect-error TS7016
52
+
48
53
  const YARN_CMD = 'yarn';
49
54
  let hasYarn;
50
55
  let yarnVersion;
@@ -67,6 +72,7 @@ class Yarn {
67
72
  }) {
68
73
  if (yarnVersion == null) {
69
74
  let version = await (0, _utils.exec)('yarn --version');
75
+ // @ts-expect-error TS2345
70
76
  yarnVersion = parseInt(version.stdout, 10);
71
77
  }
72
78
  let args = ['add', '--json'].concat(modules.map(_utils.npmSpecifierFromModuleRequest));
@@ -92,7 +98,11 @@ class Yarn {
92
98
  });
93
99
  installProcess.stdout
94
100
  // Invoking yarn with --json provides streaming, newline-delimited JSON output.
95
- .pipe((0, _split().default)()).pipe(new _JSONParseStream.default()).on('error', e => {
101
+ .pipe((0, _split().default)())
102
+ // @ts-expect-error TS2554
103
+ .pipe(new _JSONParseStream.default())
104
+ // @ts-expect-error TS7006
105
+ .on('error', e => {
96
106
  _logger().default.error(e, '@atlaspack/package-manager');
97
107
  }).on('data', message => {
98
108
  switch (message.type) {
@@ -111,7 +121,11 @@ class Yarn {
111
121
  }
112
122
  });
113
123
 
114
- installProcess.stderr.pipe((0, _split().default)()).pipe(new _JSONParseStream.default()).on('error', e => {
124
+ installProcess.stderr.pipe((0, _split().default)())
125
+ // @ts-expect-error TS2554
126
+ .pipe(new _JSONParseStream.default())
127
+ // @ts-expect-error TS7006
128
+ .on('error', e => {
115
129
  _logger().default.error(e, '@atlaspack/package-manager');
116
130
  }).on('data', message => {
117
131
  switch (message.type) {
@@ -0,0 +1,4 @@
1
+ export default function getCurrentPackageManager(userAgent?: string | null): {
2
+ name: string;
3
+ version: string;
4
+ } | null | undefined;
@@ -4,7 +4,9 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = getCurrentPackageManager;
7
- function getCurrentPackageManager(userAgent = process.env.npm_config_user_agent) {
7
+ function getCurrentPackageManager(
8
+ // @ts-expect-error TS2322
9
+ userAgent = process.env.npm_config_user_agent) {
8
10
  if (!userAgent) {
9
11
  return undefined;
10
12
  }
package/lib/index.d.ts CHANGED
@@ -1,10 +1,10 @@
1
- import type { PackageManagerResolveResult } from "@atlaspack/types";
2
- export type { PackageManager, Invalidations, PackageInstaller, ModuleRequest } from "@atlaspack/types";
3
- export * from "./Npm";
4
- export * from "./Pnpm";
5
- export * from "./Yarn";
6
- export * from "./MockPackageInstaller";
7
- export * from "./NodePackageManager";
8
- export { _addToInstallQueue } from "./installPackage";
1
+ import type { PackageManagerResolveResult } from '@atlaspack/types';
2
+ export type { PackageManager, Invalidations, PackageInstaller, ModuleRequest, } from '@atlaspack/types';
3
+ export * from './Npm';
4
+ export * from './Pnpm';
5
+ export * from './Yarn';
6
+ export * from './MockPackageInstaller';
7
+ export * from './NodePackageManager';
8
+ export { _addToInstallQueue } from './installPackage';
9
9
  export type { PackageManagerResolveResult };
10
10
  export type { PackageManagerResolveResult as ResolveResult };
@@ -0,0 +1,5 @@
1
+ import type { FilePath } from '@atlaspack/types';
2
+ import type { ModuleRequest, PackageManager, InstallOptions } from '@atlaspack/types';
3
+ import type { FileSystem } from '@atlaspack/fs';
4
+ export declare function _addToInstallQueue(fs: FileSystem, packageManager: PackageManager, modules: Array<ModuleRequest>, filePath: FilePath, projectRoot: FilePath, options?: InstallOptions): Promise<unknown>;
5
+ export declare function installPackage(fs: FileSystem, packageManager: PackageManager, modules: Array<ModuleRequest>, filePath: FilePath, projectRoot: FilePath, options?: InstallOptions): Promise<unknown>;
@@ -116,6 +116,7 @@ async function installPeerDependencies(fs, packageManager, module, from, project
116
116
  if (!_semver().default.satisfies(pkg.version, range)) {
117
117
  throw new (_diagnostic().default)({
118
118
  diagnostic: {
119
+ // @ts-expect-error TS2345
119
120
  message: (0, _diagnostic().md)`Could not install the peer dependency "${name}" for "${module.name}", installed version ${pkg.version} is incompatible with ${range}`,
120
121
  origin: '@atlaspack/package-manager',
121
122
  codeFrames: [{
@@ -0,0 +1,3 @@
1
+ export declare const defaultNodejsConditions: Array<string>;
2
+ /** @description Gets the export conditions from NODE_OPTIONS and node arguments */
3
+ export declare function getConditionsFromEnv(): Array<string>;
@@ -15,6 +15,7 @@ function _process() {
15
15
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
16
16
  // https://nodejs.org/api/packages.html#conditional-exports
17
17
  // TODO We don't support { "type": "module" }
18
+ // @ts-expect-error TS4104
18
19
  const defaultNodejsConditions = exports.defaultNodejsConditions = Object.freeze(['node-addons', 'node',
19
20
  // 'import',
20
21
  'require', 'module-sync', 'default']);
@@ -26,10 +27,15 @@ function getConditionsFromEnv() {
26
27
  const conditions = [];
27
28
  for (const arg of [..._process().default.execArgv, ...(_process().default.env.NODE_OPTIONS || '').split(' ')]) {
28
29
  if (arg.startsWith('--conditions=')) {
30
+ // @ts-expect-error TS2345
29
31
  conditions.push(arg.substring(13));
30
32
  }
31
33
  }
34
+
35
+ // @ts-expect-error TS4104
32
36
  envConditions = Object.freeze([...conditions, ...defaultNodejsConditions]);
33
37
  }
38
+
39
+ // @ts-expect-error TS2322
34
40
  return envConditions;
35
41
  }
@@ -0,0 +1,2 @@
1
+ import type { ChildProcess } from 'child_process';
2
+ export default function promiseFromProcess(childProcess: ChildProcess): Promise<void>;
@@ -12,6 +12,8 @@ function promiseFromProcess(childProcess) {
12
12
  reject(new Error('Child process failed'));
13
13
  return;
14
14
  }
15
+
16
+ // @ts-expect-error TS2794
15
17
  resolve();
16
18
  });
17
19
  });
package/lib/utils.d.ts ADDED
@@ -0,0 +1,15 @@
1
+ import type { FilePath, ModuleRequest } from '@atlaspack/types';
2
+ import type { FileSystem } from '@atlaspack/fs';
3
+ export declare const exec: (command: string, options?: child_process.execOpts) => Promise<{
4
+ stdout: string | Buffer;
5
+ stderr: string | Buffer;
6
+ }>;
7
+ export declare function npmSpecifierFromModuleRequest(moduleRequest: ModuleRequest): string;
8
+ export declare function moduleRequestsFromDependencyMap(dependencyMap: {
9
+ [key: string]: string;
10
+ }): Array<ModuleRequest>;
11
+ export declare function getConflictingLocalDependencies(fs: FileSystem, name: string, local: FilePath, projectRoot: FilePath): Promise<{
12
+ json: string;
13
+ filePath: FilePath;
14
+ fields: Array<string>;
15
+ } | null | undefined>;
@@ -0,0 +1 @@
1
+ export default function validateModuleSpecifier(moduleName: string): string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaspack/package-manager",
3
- "version": "2.14.5-canary.138+eda07caaf",
3
+ "version": "2.14.5-canary.139+d2fd84977",
4
4
  "description": "Blazing fast, zero configuration web application bundler",
5
5
  "license": "(MIT OR Apache-2.0)",
6
6
  "publishConfig": {
@@ -10,15 +10,14 @@
10
10
  "type": "git",
11
11
  "url": "https://github.com/atlassian-labs/atlaspack.git"
12
12
  },
13
- "main": "lib/index.js",
14
- "source": "src/index.js",
15
- "types": "index.d.ts",
13
+ "main": "./lib/index.js",
14
+ "source": "./src/index.ts",
15
+ "types": "./lib/index.d.ts",
16
16
  "engines": {
17
17
  "node": ">= 16.0.0"
18
18
  },
19
19
  "scripts": {
20
- "build-ts": "mkdir -p lib && flow-to-ts src/index.js > lib/index.d.ts",
21
- "check-ts": "tsc --noEmit index.d.ts",
20
+ "check-ts": "tsc --emitDeclarationOnly --rootDir src",
22
21
  "test": "mocha test"
23
22
  },
24
23
  "targets": {
@@ -39,14 +38,14 @@
39
38
  }
40
39
  },
41
40
  "dependencies": {
42
- "@atlaspack/build-cache": "2.13.3-canary.206+eda07caaf",
43
- "@atlaspack/diagnostic": "2.14.1-canary.206+eda07caaf",
44
- "@atlaspack/fs": "2.14.5-canary.138+eda07caaf",
45
- "@atlaspack/logger": "2.14.5-canary.138+eda07caaf",
46
- "@atlaspack/node-resolver-core": "3.5.5-canary.138+eda07caaf",
47
- "@atlaspack/types": "2.14.5-canary.138+eda07caaf",
48
- "@atlaspack/utils": "2.14.5-canary.138+eda07caaf",
49
- "@atlaspack/workers": "2.14.5-canary.138+eda07caaf",
41
+ "@atlaspack/build-cache": "2.13.3-canary.207+d2fd84977",
42
+ "@atlaspack/diagnostic": "2.14.1-canary.207+d2fd84977",
43
+ "@atlaspack/fs": "2.14.5-canary.139+d2fd84977",
44
+ "@atlaspack/logger": "2.14.5-canary.139+d2fd84977",
45
+ "@atlaspack/node-resolver-core": "3.5.5-canary.139+d2fd84977",
46
+ "@atlaspack/types": "2.14.5-canary.139+d2fd84977",
47
+ "@atlaspack/utils": "2.14.5-canary.139+d2fd84977",
48
+ "@atlaspack/workers": "2.14.5-canary.139+d2fd84977",
50
49
  "@swc/core": "^1.10.0",
51
50
  "command-exists": "^1.2.6",
52
51
  "cross-spawn": "^6.0.4",
@@ -61,5 +60,5 @@
61
60
  "./src/Yarn.js": false
62
61
  },
63
62
  "type": "commonjs",
64
- "gitHead": "eda07caafd2ebb814bbdbfd0ec12fa63124e213f"
65
- }
63
+ "gitHead": "d2fd849770fe6305e9c694bd97b1bd905abd9d94"
64
+ }