@teambit/pnpm 0.0.880 → 0.0.882

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/lynx.js CHANGED
@@ -1,237 +1,172 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  require("core-js/modules/es.array.iterator.js");
6
-
7
5
  require("core-js/modules/es.promise.js");
8
-
9
6
  require("core-js/modules/es.regexp.exec.js");
10
-
11
7
  require("core-js/modules/es.string.replace.js");
12
-
13
8
  Object.defineProperty(exports, "__esModule", {
14
9
  value: true
15
10
  });
16
11
  exports.getPeerDependencyIssues = getPeerDependencyIssues;
17
12
  exports.install = install;
18
13
  exports.resolveRemoteVersion = resolveRemoteVersion;
19
-
20
14
  function _defineProperty2() {
21
15
  const data = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
22
-
23
16
  _defineProperty2 = function () {
24
17
  return data;
25
18
  };
26
-
27
19
  return data;
28
20
  }
29
-
30
21
  function _gracefulFs() {
31
22
  const data = _interopRequireDefault(require("graceful-fs"));
32
-
33
23
  _gracefulFs = function () {
34
24
  return data;
35
25
  };
36
-
37
26
  return data;
38
27
  }
39
-
40
28
  function _path() {
41
29
  const data = _interopRequireDefault(require("path"));
42
-
43
30
  _path = function () {
44
31
  return data;
45
32
  };
46
-
47
33
  return data;
48
34
  }
49
-
50
35
  function _semver() {
51
36
  const data = _interopRequireDefault(require("semver"));
52
-
53
37
  _semver = function () {
54
38
  return data;
55
39
  };
56
-
57
40
  return data;
58
41
  }
59
-
60
42
  function _parsePackageName() {
61
43
  const data = _interopRequireDefault(require("parse-package-name"));
62
-
63
44
  _parsePackageName = function () {
64
45
  return data;
65
46
  };
66
-
67
47
  return data;
68
48
  }
69
-
70
49
  function _defaultReporter() {
71
- const data = _interopRequireDefault(require("@pnpm/default-reporter"));
72
-
50
+ const data = require("@pnpm/default-reporter");
73
51
  _defaultReporter = function () {
74
52
  return data;
75
53
  };
76
-
77
54
  return data;
78
55
  }
79
-
80
56
  function _logger() {
81
57
  const data = require("@pnpm/logger");
82
-
83
58
  _logger = function () {
84
59
  return data;
85
60
  };
86
-
87
61
  return data;
88
62
  }
89
-
90
63
  function _modulesYaml() {
91
64
  const data = require("@pnpm/modules-yaml");
92
-
93
65
  _modulesYaml = function () {
94
66
  return data;
95
67
  };
96
-
97
68
  return data;
98
69
  }
99
-
100
70
  function _storeConnectionManager() {
101
71
  const data = require("@pnpm/store-connection-manager");
102
-
103
72
  _storeConnectionManager = function () {
104
73
  return data;
105
74
  };
106
-
107
75
  return data;
108
76
  }
109
-
110
77
  function _sortPackages() {
111
- const data = _interopRequireDefault(require("@pnpm/sort-packages"));
112
-
78
+ const data = require("@pnpm/sort-packages");
113
79
  _sortPackages = function () {
114
80
  return data;
115
81
  };
116
-
117
82
  return data;
118
83
  }
119
-
120
84
  function _dependencyResolver() {
121
85
  const data = require("@teambit/dependency-resolver");
122
-
123
86
  _dependencyResolver = function () {
124
87
  return data;
125
88
  };
126
-
127
89
  return data;
128
90
  }
129
-
91
+ function _bitError() {
92
+ const data = require("@teambit/bit-error");
93
+ _bitError = function () {
94
+ return data;
95
+ };
96
+ return data;
97
+ }
130
98
  function pnpm() {
131
99
  const data = _interopRequireWildcard(require("@pnpm/core"));
132
-
133
100
  pnpm = function () {
134
101
  return data;
135
102
  };
136
-
137
103
  return data;
138
104
  }
139
-
140
105
  function _client() {
141
- const data = _interopRequireDefault(require("@pnpm/client"));
142
-
106
+ const data = require("@pnpm/client");
143
107
  _client = function () {
144
108
  return data;
145
109
  };
146
-
147
110
  return data;
148
111
  }
149
-
150
112
  function _pickRegistryForPackage() {
151
- const data = _interopRequireDefault(require("@pnpm/pick-registry-for-package"));
152
-
113
+ const data = require("@pnpm/pick-registry-for-package");
153
114
  _pickRegistryForPackage = function () {
154
115
  return data;
155
116
  };
156
-
157
117
  return data;
158
118
  }
159
-
160
119
  function _nerfDart() {
161
120
  const data = _interopRequireDefault(require("nerf-dart"));
162
-
163
121
  _nerfDart = function () {
164
122
  return data;
165
123
  };
166
-
167
124
  return data;
168
125
  }
169
-
170
126
  function _util() {
171
127
  const data = require("util");
172
-
173
128
  _util = function () {
174
129
  return data;
175
130
  };
176
-
177
131
  return data;
178
132
  }
179
-
180
133
  function _pkgsGraph() {
181
- const data = _interopRequireDefault(require("pkgs-graph"));
182
-
134
+ const data = require("pkgs-graph");
183
135
  _pkgsGraph = function () {
184
136
  return data;
185
137
  };
186
-
187
138
  return data;
188
139
  }
189
-
190
140
  function _userHome() {
191
141
  const data = _interopRequireDefault(require("user-home"));
192
-
193
142
  _userHome = function () {
194
143
  return data;
195
144
  };
196
-
197
145
  return data;
198
146
  }
199
-
200
147
  function _pnpmErrorToBitError() {
201
148
  const data = require("./pnpm-error-to-bit-error");
202
-
203
149
  _pnpmErrorToBitError = function () {
204
150
  return data;
205
151
  };
206
-
207
152
  return data;
208
153
  }
209
-
210
154
  function _readConfig() {
211
155
  const data = require("./read-config");
212
-
213
156
  _readConfig = function () {
214
157
  return data;
215
158
  };
216
-
217
159
  return data;
218
160
  }
219
-
220
161
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
221
-
222
162
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
223
-
224
163
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
225
-
226
164
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2().default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
227
-
228
165
  const link = (0, _util().promisify)(_gracefulFs().default.link);
229
166
  const installsRunning = {};
230
167
  const STORE_CACHE = {};
231
-
232
168
  async function createStoreController(options) {
233
169
  var _options$proxyConfig, _options$proxyConfig2, _options$networkConfi, _options$networkConfi2, _options$networkConfi3, _options$networkConfi4, _options$proxyConfig3;
234
-
235
170
  const authConfig = getAuthConfig(options.registries);
236
171
  const opts = {
237
172
  dir: options.rootDir,
@@ -251,21 +186,17 @@ async function createStoreController(options) {
251
186
  networkConcurrency: options.networkConfig.networkConcurrency,
252
187
  packageImportMethod: options.packageImportMethod,
253
188
  pnpmHomeDir: _path().default.join(_userHome().default, '.pnpm') // This is not actually used in our case
254
-
255
- }; // We should avoid the recreation of store.
189
+ };
190
+ // We should avoid the recreation of store.
256
191
  // The store holds cache that makes subsequent resolutions faster.
257
-
258
192
  const cacheKey = JSON.stringify(opts);
259
-
260
193
  if (!STORE_CACHE[cacheKey]) {
261
194
  // Although it would be enough to call createNewStoreController(),
262
195
  // that doesn't resolve the store directory location.
263
196
  STORE_CACHE[cacheKey] = await (0, _storeConnectionManager().createOrConnectStoreController)(opts);
264
197
  }
265
-
266
198
  return STORE_CACHE[cacheKey];
267
199
  }
268
-
269
200
  async function generateResolverAndFetcher(cacheDir, registries, proxyConfig = {}, networkConfig = {}) {
270
201
  const pnpmConfig = await (0, _readConfig().readConfig)();
271
202
  const authConfig = getAuthConfig(registries);
@@ -288,16 +219,16 @@ async function generateResolverAndFetcher(cacheDir, registries, proxyConfig = {}
288
219
  retries: networkConfig.fetchRetries
289
220
  }
290
221
  };
291
- const result = (0, _client().default)(opts);
222
+ const result = (0, _client().createClient)(opts);
292
223
  return result;
293
224
  }
294
-
295
225
  async function getPeerDependencyIssues(manifestsByPaths, opts) {
296
226
  const projects = [];
297
227
  const workspacePackages = {};
298
-
299
228
  for (const [rootDir, manifest] of Object.entries(manifestsByPaths)) {
300
229
  projects.push({
230
+ buildIndex: 0,
231
+ // this is not used while searching for peer issues anyway
301
232
  manifest,
302
233
  rootDir
303
234
  });
@@ -307,7 +238,6 @@ async function getPeerDependencyIssues(manifestsByPaths, opts) {
307
238
  manifest
308
239
  };
309
240
  }
310
-
311
241
  const registriesMap = getRegistriesMap(opts.registries);
312
242
  const storeController = await createStoreController(_objectSpread(_objectSpread({}, opts), {}, {
313
243
  rootDir: opts.rootDir
@@ -320,8 +250,8 @@ async function getPeerDependencyIssues(manifestsByPaths, opts) {
320
250
  registries: registriesMap
321
251
  });
322
252
  }
323
-
324
- async function install(rootDir, manifestsByPaths, storeDir, cacheDir, registries, proxyConfig = {}, networkConfig = {}, options, // eslint-disable-next-line @typescript-eslint/no-unused-vars
253
+ async function install(rootDir, manifestsByPaths, storeDir, cacheDir, registries, proxyConfig = {}, networkConfig = {}, options,
254
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
325
255
  logger) {
326
256
  if (!manifestsByPaths[rootDir].dependenciesMeta) {
327
257
  manifestsByPaths = _objectSpread(_objectSpread({}, manifestsByPaths), {}, {
@@ -330,24 +260,22 @@ logger) {
330
260
  })
331
261
  });
332
262
  }
333
-
334
- let readPackage;
263
+ const readPackage = [];
335
264
  let hoistingLimits = new Map();
336
-
337
265
  if (options !== null && options !== void 0 && options.rootComponents) {
338
266
  const {
339
267
  rootComponentWrappers,
340
268
  rootComponents
341
269
  } = createRootComponentWrapperManifests(rootDir, manifestsByPaths);
342
270
  manifestsByPaths = _objectSpread(_objectSpread({}, rootComponentWrappers), manifestsByPaths);
343
- readPackage = readPackageHook;
271
+ readPackage.push(readPackageHook);
344
272
  hoistingLimits = new Map();
345
273
  hoistingLimits.set('.@', new Set(rootComponents));
346
274
  } else if (options !== null && options !== void 0 && options.rootComponentsForCapsules) {
347
- readPackage = readPackageHookForCapsules;
275
+ readPackage.push(readPackageHookForCapsules);
348
276
  }
349
-
350
277
  const {
278
+ allProjects,
351
279
  packagesToBuild,
352
280
  workspacePackages
353
281
  } = groupPkgs(manifestsByPaths);
@@ -362,8 +290,8 @@ logger) {
362
290
  networkConfig,
363
291
  packageImportMethod: options === null || options === void 0 ? void 0 : options.packageImportMethod
364
292
  });
365
-
366
293
  const opts = _objectSpread(_objectSpread({
294
+ allProjects,
367
295
  storeDir: storeController.dir,
368
296
  dir: rootDir,
369
297
  storeController: storeController.ctrl,
@@ -384,8 +312,7 @@ logger) {
384
312
  ignoreMissing: ['*']
385
313
  }, options === null || options === void 0 ? void 0 : options.peerDependencyRules)
386
314
  });
387
-
388
- const stopReporting = (0, _defaultReporter().default)({
315
+ const stopReporting = (0, _defaultReporter().initDefaultReporter)({
389
316
  context: {
390
317
  argv: []
391
318
  },
@@ -395,7 +322,6 @@ logger) {
395
322
  },
396
323
  streamParser: _logger().streamParser
397
324
  });
398
-
399
325
  try {
400
326
  await installsRunning[rootDir];
401
327
  installsRunning[rootDir] = (0, pnpm().mutateModules)(packagesToBuild, opts);
@@ -406,10 +332,8 @@ logger) {
406
332
  } finally {
407
333
  stopReporting();
408
334
  }
409
-
410
335
  if (options.rootComponents) {
411
- const modulesState = await (0, _modulesYaml().read)(_path().default.join(rootDir, 'node_modules'));
412
-
336
+ const modulesState = await (0, _modulesYaml().readModulesManifest)(_path().default.join(rootDir, 'node_modules'));
413
337
  if (modulesState !== null && modulesState !== void 0 && modulesState.injectedDeps) {
414
338
  await linkManifestsToInjectedDeps({
415
339
  injectedDeps: modulesState.injectedDeps,
@@ -419,6 +343,7 @@ logger) {
419
343
  }
420
344
  }
421
345
  }
346
+
422
347
  /**
423
348
  * This function creates manifests for root component wrappers.
424
349
  * Root component wrappers are used to isolated workspace components with their workspace dependencies
@@ -426,19 +351,13 @@ logger) {
426
351
  * A root component wrapper has the wrapped component in the dependencies and any of its peer dependencies.
427
352
  * This way pnpm will install the wrapped component in isolation from other components and their dependencies.
428
353
  */
429
-
430
-
431
354
  function createRootComponentWrapperManifests(rootDir, manifestsByPaths) {
432
355
  const rootComponentWrappers = {};
433
356
  const rootComponents = [];
434
-
435
357
  for (const manifest of Object.values(manifestsByPaths)) {
436
358
  const name = manifest.name.toString(); // eslint-disable-line
437
-
438
359
  const compDir = _path().default.join(rootDir, 'node_modules', name);
439
-
440
360
  const id = _path().default.relative(rootDir, compDir).replace(/\\/g, '/');
441
-
442
361
  rootComponents.push(encodeURIComponent(id));
443
362
  rootComponentWrappers[compDir] = {
444
363
  name: `${name}__root`,
@@ -452,12 +371,12 @@ function createRootComponentWrapperManifests(rootDir, manifestsByPaths) {
452
371
  }
453
372
  };
454
373
  }
455
-
456
374
  return {
457
375
  rootComponentWrappers,
458
376
  rootComponents
459
377
  };
460
378
  }
379
+
461
380
  /**
462
381
  * This hook is used when installation is executed inside a capsule.
463
382
  * The components in the capsules should get their peer dependencies installed,
@@ -465,8 +384,6 @@ function createRootComponentWrapperManifests(rootDir, manifestsByPaths) {
465
384
  * Also, any local dependencies are extended with the "injected" option,
466
385
  * this tells pnpm to hard link the packages instead of symlinking them.
467
386
  */
468
-
469
-
470
387
  function readPackageHookForCapsules(pkg, workspaceDir) {
471
388
  // workspaceDir is set only for workspace packages
472
389
  if (workspaceDir) {
@@ -474,45 +391,36 @@ function readPackageHookForCapsules(pkg, workspaceDir) {
474
391
  dependencies: _objectSpread(_objectSpread(_objectSpread({}, pkg.dependencies), pkg.peerDependencies), pkg['defaultPeerDependencies'])
475
392
  }));
476
393
  }
477
-
478
394
  return readDependencyPackageHook(pkg);
479
395
  }
396
+
480
397
  /**
481
398
  * This hook is used when installation happens in a Bit workspace.
482
399
  * We need a different hook for this case because unlike in a capsule, in a workspace,
483
400
  * the package manager only links workspace components to subdependencies.
484
401
  * For direct dependencies, Bit's linking is used.
485
402
  */
486
-
487
-
488
403
  function readPackageHook(pkg, workspaceDir) {
489
404
  var _pkg$name;
490
-
491
405
  if (!pkg.dependencies || (_pkg$name = pkg.name) !== null && _pkg$name !== void 0 && _pkg$name.endsWith(`__root`)) {
492
406
  return pkg;
493
- } // workspaceDir is set only for workspace packages
494
-
495
-
407
+ }
408
+ // workspaceDir is set only for workspace packages
496
409
  if (workspaceDir) {
497
410
  return readWorkspacePackageHook(pkg);
498
411
  }
499
-
500
412
  return readDependencyPackageHook(pkg);
501
413
  }
414
+
502
415
  /**
503
416
  * This hook adds the "injected" option to any workspace dependency.
504
417
  * The injected option tell pnpm to hard link the packages instead of symlinking them.
505
418
  */
506
-
507
-
508
419
  function readDependencyPackageHook(pkg) {
509
420
  var _pkg$dependenciesMeta;
510
-
511
421
  const dependenciesMeta = (_pkg$dependenciesMeta = pkg.dependenciesMeta) !== null && _pkg$dependenciesMeta !== void 0 ? _pkg$dependenciesMeta : {};
512
-
513
422
  for (const [name, version] of Object.entries((_pkg$dependencies = pkg.dependencies) !== null && _pkg$dependencies !== void 0 ? _pkg$dependencies : {})) {
514
423
  var _pkg$dependencies;
515
-
516
424
  if (version.startsWith('workspace:')) {
517
425
  // This instructs pnpm to hard link the component from the workspace, not symlink it.
518
426
  dependenciesMeta[name] = {
@@ -520,11 +428,11 @@ function readDependencyPackageHook(pkg) {
520
428
  };
521
429
  }
522
430
  }
523
-
524
431
  return _objectSpread(_objectSpread({}, pkg), {}, {
525
432
  dependenciesMeta
526
433
  });
527
434
  }
435
+
528
436
  /**
529
437
  * This hook is used when installation happens in a Bit workspace.
530
438
  * It is applied on workspace projects, and it removes any references to other workspace projects.
@@ -532,29 +440,23 @@ function readDependencyPackageHook(pkg) {
532
440
  * pnpm should not override the links created by Bit.
533
441
  * Otherwise, the IDE would reference workspace projects from inside `node_modules/.pnpm`.
534
442
  */
535
-
536
-
537
443
  function readWorkspacePackageHook(pkg) {
538
444
  const newDeps = {};
539
-
540
445
  for (const [name, version] of Object.entries((_pkg$dependencies2 = pkg.dependencies) !== null && _pkg$dependencies2 !== void 0 ? _pkg$dependencies2 : {})) {
541
446
  var _pkg$dependencies2;
542
-
543
447
  if (!version.startsWith('workspace:')) {
544
448
  newDeps[name] = version;
545
449
  }
546
450
  }
547
-
548
451
  return _objectSpread(_objectSpread({}, pkg), {}, {
549
452
  dependencies: newDeps
550
453
  });
551
454
  }
455
+
552
456
  /*
553
457
  * The package.json files of the components are generated into node_modules/<component pkg name>/package.json
554
458
  * This function copies the generated package.json file into all the locations of the component.
555
459
  */
556
-
557
-
558
460
  async function linkManifestsToInjectedDeps({
559
461
  rootDir,
560
462
  manifestsByPaths,
@@ -562,18 +464,14 @@ async function linkManifestsToInjectedDeps({
562
464
  }) {
563
465
  await Promise.all(Object.entries(injectedDeps).map(async ([compDir, targetDirs]) => {
564
466
  var _manifestsByPaths$pat;
565
-
566
467
  const pkgName = (_manifestsByPaths$pat = manifestsByPaths[_path().default.join(rootDir, compDir)]) === null || _manifestsByPaths$pat === void 0 ? void 0 : _manifestsByPaths$pat.name;
567
468
  if (!pkgName) return;
568
-
569
469
  const pkgJsonPath = _path().default.join(rootDir, 'node_modules', pkgName, 'package.json');
570
-
571
470
  if (_gracefulFs().default.existsSync(pkgJsonPath)) {
572
471
  await Promise.all(targetDirs.map(targetDir => link(pkgJsonPath, _path().default.join(targetDir, 'package.json'))));
573
472
  }
574
473
  }));
575
474
  }
576
-
577
475
  function groupPkgs(manifestsByPaths) {
578
476
  const pkgs = Object.entries(manifestsByPaths).map(([dir, manifest]) => ({
579
477
  dir,
@@ -581,8 +479,10 @@ function groupPkgs(manifestsByPaths) {
581
479
  }));
582
480
  const {
583
481
  graph
584
- } = (0, _pkgsGraph().default)(pkgs);
585
- const chunks = (0, _sortPackages().default)(graph); // This will create local link by pnpm to a component exists in the ws.
482
+ } = (0, _pkgsGraph().createPkgGraph)(pkgs);
483
+ const chunks = (0, _sortPackages().sortPackages)(graph);
484
+
485
+ // This will create local link by pnpm to a component exists in the ws.
586
486
  // it will later deleted by the link process
587
487
  // we keep it here to better support case like this:
588
488
  // compA@1.0.0 uses compB@1.0.0
@@ -593,21 +493,22 @@ function groupPkgs(manifestsByPaths) {
593
493
  // with this we will have a link to the local B by pnpm so it will install B@1.0.0 inside A
594
494
  // then when overriding the link, A will still works
595
495
  // This is the rational behind not deleting this completely, but need further check that it really works
596
-
597
496
  const packagesToBuild = []; // @pnpm/core will use this to install the packages
598
-
497
+ const allProjects = [];
599
498
  const workspacePackages = {}; // @pnpm/core will use this to link packages to each other
600
499
 
601
500
  chunks.forEach((dirs, buildIndex) => {
602
501
  for (const rootDir of dirs) {
603
502
  const manifest = manifestsByPaths[rootDir];
604
- packagesToBuild.push({
503
+ allProjects.push({
605
504
  buildIndex,
606
505
  manifest,
506
+ rootDir
507
+ });
508
+ packagesToBuild.push({
607
509
  rootDir,
608
510
  mutation: 'install'
609
511
  });
610
-
611
512
  if (manifest.name) {
612
513
  workspacePackages[manifest.name] = workspacePackages[manifest.name] || {};
613
514
  workspacePackages[manifest.name][manifest.version] = {
@@ -619,23 +520,24 @@ function groupPkgs(manifestsByPaths) {
619
520
  });
620
521
  return {
621
522
  packagesToBuild,
523
+ allProjects,
622
524
  workspacePackages
623
525
  };
624
526
  }
625
-
626
527
  async function resolveRemoteVersion(packageName, rootDir, cacheDir, registries, proxyConfig = {}, networkConfig = {}) {
627
528
  const {
628
529
  resolve
629
530
  } = await generateResolverAndFetcher(cacheDir, registries, proxyConfig, networkConfig);
630
531
  const resolveOpts = {
532
+ lockfileDir: rootDir,
533
+ preferredVersions: {},
631
534
  projectDir: rootDir,
632
535
  registry: ''
633
536
  };
634
-
635
537
  try {
636
538
  const parsedPackage = (0, _parsePackageName().default)(packageName);
637
539
  const registriesMap = getRegistriesMap(registries);
638
- const registry = (0, _pickRegistryForPackage().default)(registriesMap, parsedPackage.name);
540
+ const registry = (0, _pickRegistryForPackage().pickRegistryForPackage)(registriesMap, parsedPackage.name);
639
541
  const wantedDep = {
640
542
  alias: parsedPackage.name,
641
543
  pref: parsedPackage.version
@@ -643,6 +545,9 @@ async function resolveRemoteVersion(packageName, rootDir, cacheDir, registries,
643
545
  const isValidRange = parsedPackage.version ? !!_semver().default.validRange(parsedPackage.version) : false;
644
546
  resolveOpts.registry = registry;
645
547
  const val = await resolve(wantedDep, resolveOpts);
548
+ if (!val.manifest) {
549
+ throw new (_bitError().BitError)('The resolved package has no manifest');
550
+ }
646
551
  const version = isValidRange ? parsedPackage.version : val.manifest.version;
647
552
  return {
648
553
  packageName: val.manifest.name,
@@ -652,17 +557,21 @@ async function resolveRemoteVersion(packageName, rootDir, cacheDir, registries,
652
557
  };
653
558
  } catch (e) {
654
559
  var _e$message;
655
-
656
560
  if (!((_e$message = e.message) !== null && _e$message !== void 0 && _e$message.includes('is not a valid string'))) {
657
561
  throw (0, _pnpmErrorToBitError().pnpmErrorToBitError)(e);
658
- } // The provided package is probably a git url or path to a folder
659
-
660
-
562
+ }
563
+ // The provided package is probably a git url or path to a folder
661
564
  const wantedDep = {
662
565
  alias: undefined,
663
566
  pref: packageName
664
567
  };
665
568
  const val = await resolve(wantedDep, resolveOpts);
569
+ if (!val.manifest) {
570
+ throw new (_bitError().BitError)('The resolved package has no manifest');
571
+ }
572
+ if (!val.normalizedPref) {
573
+ throw new (_bitError().BitError)('The resolved package has no version');
574
+ }
666
575
  return {
667
576
  packageName: val.manifest.name,
668
577
  version: val.normalizedPref,
@@ -671,7 +580,6 @@ async function resolveRemoteVersion(packageName, rootDir, cacheDir, registries,
671
580
  };
672
581
  }
673
582
  }
674
-
675
583
  function getRegistriesMap(registries) {
676
584
  const registriesMap = {
677
585
  default: registries.defaultRegistry.uri || _dependencyResolver().NPM_REGISTRY
@@ -681,15 +589,12 @@ function getRegistriesMap(registries) {
681
589
  });
682
590
  return registriesMap;
683
591
  }
684
-
685
592
  function getAuthConfig(registries) {
686
593
  const res = {};
687
594
  res.registry = registries.defaultRegistry.uri;
688
-
689
595
  if (registries.defaultRegistry.alwaysAuth) {
690
596
  res['always-auth'] = true;
691
597
  }
692
-
693
598
  const defaultAuthTokens = getAuthTokenForRegistry(registries.defaultRegistry, true);
694
599
  defaultAuthTokens.forEach(({
695
600
  keyName,
@@ -705,7 +610,6 @@ function getAuthConfig(registries) {
705
610
  }) => {
706
611
  res[keyName] = val;
707
612
  });
708
-
709
613
  if (registry.alwaysAuth) {
710
614
  const nerfed = (0, _nerfDart().default)(registry.uri);
711
615
  const alwaysAuthKeyName = `${nerfed}:always-auth`;
@@ -714,27 +618,22 @@ function getAuthConfig(registries) {
714
618
  });
715
619
  return res;
716
620
  }
717
-
718
621
  function getAuthTokenForRegistry(registry, isDefault = false) {
719
622
  const nerfed = (0, _nerfDart().default)(registry.uri);
720
-
721
623
  if (registry.originalAuthType === 'authToken') {
722
624
  return [{
723
625
  keyName: `${nerfed}:_authToken`,
724
626
  val: registry.originalAuthValue || ''
725
627
  }];
726
628
  }
727
-
728
629
  if (registry.originalAuthType === 'auth') {
729
630
  return [{
730
631
  keyName: isDefault ? '_auth' : `${nerfed}:_auth`,
731
632
  val: registry.originalAuthValue || ''
732
633
  }];
733
634
  }
734
-
735
635
  if (registry.originalAuthType === 'user-pass') {
736
636
  var _registry$originalAut, _registry$originalAut2;
737
-
738
637
  return [{
739
638
  keyName: `${nerfed}:username`,
740
639
  val: ((_registry$originalAut = registry.originalAuthValue) === null || _registry$originalAut === void 0 ? void 0 : _registry$originalAut.split(':')[0]) || ''
@@ -743,7 +642,6 @@ function getAuthTokenForRegistry(registry, isDefault = false) {
743
642
  val: ((_registry$originalAut2 = registry.originalAuthValue) === null || _registry$originalAut2 === void 0 ? void 0 : _registry$originalAut2.split(':')[1]) || ''
744
643
  }];
745
644
  }
746
-
747
645
  return [];
748
646
  }
749
647