@teambit/isolator 1.0.330 → 1.0.332

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.
@@ -9,7 +9,7 @@ import { Logger, LoggerMain } from '@teambit/logger';
9
9
  import { ComponentID, ComponentIdList } from '@teambit/component-id';
10
10
  import LegacyScope from '@teambit/legacy/dist/scope/scope';
11
11
  import { GlobalConfigMain } from '@teambit/global-config';
12
- import { PathOsBasedAbsolute } from '@teambit/legacy/dist/utils/path';
12
+ import { PathOsBasedAbsolute } from '@teambit/legacy.utils';
13
13
  import { Scope } from '@teambit/legacy/dist/scope';
14
14
  import DataToPersist from '@teambit/legacy/dist/consumer/component/sources/data-to-persist';
15
15
  import { Capsule } from './capsule';
@@ -137,9 +137,23 @@ function _artifactFiles() {
137
137
  };
138
138
  return data;
139
139
  }
140
- function _path() {
141
- const data = require("@teambit/legacy/dist/utils/path");
142
- _path = function () {
140
+ function _legacy() {
141
+ const data = require("@teambit/legacy.utils");
142
+ _legacy = function () {
143
+ return data;
144
+ };
145
+ return data;
146
+ }
147
+ function _harmonyModules() {
148
+ const data = require("@teambit/harmony.modules.concurrency");
149
+ _harmonyModules = function () {
150
+ return data;
151
+ };
152
+ return data;
153
+ }
154
+ function _pkgModules() {
155
+ const data = require("@teambit/pkg.modules.component-package-name");
156
+ _pkgModules = function () {
143
157
  return data;
144
158
  };
145
159
  return data;
@@ -158,9 +172,9 @@ function _objectHash() {
158
172
  };
159
173
  return data;
160
174
  }
161
- function _path2() {
175
+ function _path() {
162
176
  const data = _interopRequireWildcard(require("path"));
163
- _path2 = function () {
177
+ _path = function () {
164
178
  return data;
165
179
  };
166
180
  return data;
@@ -186,20 +200,6 @@ function _workspaceModules() {
186
200
  };
187
201
  return data;
188
202
  }
189
- function _componentIdToPackageName() {
190
- const data = _interopRequireDefault(require("@teambit/legacy/dist/utils/bit/component-id-to-package-name"));
191
- _componentIdToPackageName = function () {
192
- return data;
193
- };
194
- return data;
195
- }
196
- function _concurrency() {
197
- const data = require("@teambit/legacy/dist/utils/concurrency");
198
- _concurrency = function () {
199
- return data;
200
- };
201
- return data;
202
- }
203
203
  function _pMap() {
204
204
  const data = _interopRequireDefault(require("p-map"));
205
205
  _pMap = function () {
@@ -378,13 +378,13 @@ class IsolatorMain {
378
378
  withFileTypes: true
379
379
  });
380
380
  const capsuleDirents = allDirs.filter(dir => dir.isDirectory() && dir.name !== 'node_modules');
381
- return capsuleDirents.map(dir => _path2().default.join(rootDir, dir.name));
381
+ return capsuleDirents.map(dir => _path().default.join(rootDir, dir.name));
382
382
  }
383
383
  async moveCapsulesLockFileToTargetDir(capsulesDirs, sourceRootDir, targetCapsuleDir) {
384
384
  this.logger.info(`start moving lock files from ${sourceRootDir} to ${targetCapsuleDir}`);
385
385
  const promises = capsulesDirs.map(async sourceDir => {
386
- const dirname = _path2().default.basename(sourceDir);
387
- const sourceLockFile = _path2().default.join(sourceDir, 'pnpm-lock.yaml');
386
+ const dirname = _path().default.basename(sourceDir);
387
+ const sourceLockFile = _path().default.join(sourceDir, 'pnpm-lock.yaml');
388
388
  // Lock file is not exist, don't copy it to the cache
389
389
  if (!_fsExtra().default.pathExistsSync(sourceLockFile)) {
390
390
  // It was already moved during the process, do not show the log for it
@@ -393,8 +393,8 @@ class IsolatorMain {
393
393
  }
394
394
  return;
395
395
  }
396
- const targetDir = _path2().default.join(targetCapsuleDir, dirname);
397
- const targetLockFile = _path2().default.join(targetDir, 'pnpm-lock.yaml');
396
+ const targetDir = _path().default.join(targetCapsuleDir, dirname);
397
+ const targetLockFile = _path().default.join(targetDir, 'pnpm-lock.yaml');
398
398
  const targetLockFileExists = await _fsExtra().default.pathExists(targetLockFile);
399
399
  if (targetLockFileExists) {
400
400
  // Lock file is already in the cache, no need to move it
@@ -407,7 +407,7 @@ class IsolatorMain {
407
407
  this.logger.debug(`moving lock file from ${sourceLockFile} to ${targetDir}`);
408
408
  const mvFunc = this.getCapsuleTransferFn();
409
409
  try {
410
- await mvFunc(sourceLockFile, _path2().default.join(targetDir, 'pnpm-lock.yaml'));
410
+ await mvFunc(sourceLockFile, _path().default.join(targetDir, 'pnpm-lock.yaml'));
411
411
  this._movedLockFiles.add(sourceLockFile);
412
412
  } catch (err) {
413
413
  this.logger.error(`failed moving lock file from ${sourceLockFile} to ${targetDir}`, err);
@@ -418,15 +418,15 @@ class IsolatorMain {
418
418
  async moveCapsulesToTargetDir(capsulesDirs, sourceRootDir, targetCapsuleDir) {
419
419
  this.logger.info(`start moving capsules from ${sourceRootDir} to ${targetCapsuleDir}`);
420
420
  const promises = capsulesDirs.map(async sourceDir => {
421
- const dirname = _path2().default.basename(sourceDir);
421
+ const dirname = _path().default.basename(sourceDir);
422
422
  const sourceCapsuleReadyFile = this.getCapsuleReadyFilePath(sourceDir);
423
423
  if (!_fsExtra().default.pathExistsSync(sourceCapsuleReadyFile)) {
424
424
  // Capsule is not ready, don't copy it to the cache
425
425
  this.logger.console(`skipping moving capsule to cache as it is not ready ${sourceDir}`);
426
426
  return;
427
427
  }
428
- const targetDir = _path2().default.join(targetCapsuleDir, dirname);
429
- if (_fsExtra().default.pathExistsSync(_path2().default.join(targetCapsuleDir, dirname))) {
428
+ const targetDir = _path().default.join(targetCapsuleDir, dirname);
429
+ if (_fsExtra().default.pathExistsSync(_path().default.join(targetCapsuleDir, dirname))) {
430
430
  const targetCapsuleReadyFile = this.getCapsuleReadyFilePath(targetDir);
431
431
  if (_fsExtra().default.pathExistsSync(targetCapsuleReadyFile)) {
432
432
  // Capsule is already in the cache, no need to move it
@@ -514,7 +514,7 @@ class IsolatorMain {
514
514
  }));
515
515
  // validate all capsules in the real location exists and valid
516
516
  const allCapsulesExists = componentsToIsolate.every(component => {
517
- const capsuleDir = _path2().default.join(realCapsulesDir, _capsule().Capsule.getCapsuleDirName(component));
517
+ const capsuleDir = _path().default.join(realCapsulesDir, _capsule().Capsule.getCapsuleDirName(component));
518
518
  const readyFilePath = this.getCapsuleReadyFilePath(capsuleDir);
519
519
  return _fsExtra().default.existsSync(capsuleDir) && _fsExtra().default.existsSync(readyFilePath);
520
520
  });
@@ -605,13 +605,13 @@ class IsolatorMain {
605
605
  await Promise.all(capsuleList.map(async (capsule, index) => {
606
606
  const newCapsuleList = _capsuleList().default.fromArray([capsule]);
607
607
  if (opts.cacheCapsulesDir && capsulesDir !== opts.cacheCapsulesDir && opts.cacheLockFileOnly) {
608
- const cacheCapsuleDir = _path2().default.join(opts.cacheCapsulesDir, (0, _path2().basename)(capsule.path));
609
- const lockFilePath = _path2().default.join(cacheCapsuleDir, 'pnpm-lock.yaml');
608
+ const cacheCapsuleDir = _path().default.join(opts.cacheCapsulesDir, (0, _path().basename)(capsule.path));
609
+ const lockFilePath = _path().default.join(cacheCapsuleDir, 'pnpm-lock.yaml');
610
610
  const lockExists = await _fsExtra().default.pathExists(lockFilePath);
611
611
  if (lockExists) {
612
612
  try {
613
613
  // this.logger.console(`moving lock file from ${lockFilePath} to ${capsule.path}`);
614
- await (0, _fsExtra().copyFile)(lockFilePath, _path2().default.join(capsule.path, 'pnpm-lock.yaml'));
614
+ await (0, _fsExtra().copyFile)(lockFilePath, _path().default.join(capsule.path, 'pnpm-lock.yaml'));
615
615
  } catch (err) {
616
616
  // We can ignore the error, we don't want to break the flow. the file will be anyway re-generated
617
617
  // in the target capsule. it will only be a bit slower.
@@ -689,7 +689,7 @@ class IsolatorMain {
689
689
  _fsExtra().default.writeFileSync(readyFilePath, '');
690
690
  }
691
691
  getCapsuleReadyFilePath(capsulePath) {
692
- return _path2().default.join(capsulePath, CAPSULE_READY_FILE);
692
+ return _path().default.join(capsulePath, CAPSULE_READY_FILE);
693
693
  }
694
694
  async installInCapsules(capsulesDir, capsuleList, isolateInstallOptions, opts) {
695
695
  const installer = this.dependencyResolver.getInstaller({
@@ -826,7 +826,7 @@ class IsolatorMain {
826
826
  try {
827
827
  const capsules = await _fsExtra().default.readdir(rootDir);
828
828
  const withoutNodeModules = capsules.filter(c => c !== 'node_modules');
829
- const capsuleFullPaths = withoutNodeModules.map(c => _path2().default.join(rootDir, c));
829
+ const capsuleFullPaths = withoutNodeModules.map(c => _path().default.join(rootDir, c));
830
830
  return {
831
831
  capsules: capsuleFullPaths
832
832
  };
@@ -888,10 +888,10 @@ class IsolatorMain {
888
888
  this._datedHashForName.set(finalDatedDirId, hashDir);
889
889
  }
890
890
  }
891
- return _path2().default.join(capsulesRootBaseDir, datedBaseDir, dateDir, hashDir);
891
+ return _path().default.join(capsulesRootBaseDir, datedBaseDir, dateDir, hashDir);
892
892
  }
893
893
  const dir = getCapsuleDirOptsWithDefaults.useHash ? (0, _objectHash().default)(getCapsuleDirOptsWithDefaults.baseDir).substring(0, CAPSULE_DIR_LENGTH) : getCapsuleDirOptsWithDefaults.baseDir;
894
- return _path2().default.join(capsulesRootBaseDir, dir);
894
+ return _path().default.join(capsulesRootBaseDir, dir);
895
895
  }
896
896
  async deleteCapsules(rootDir) {
897
897
  const dirToDelete = rootDir || this.getRootDirOfAllCapsules();
@@ -903,7 +903,7 @@ class IsolatorMain {
903
903
  const capsules = await (0, _pMap().default)(components, component => {
904
904
  return _capsule().Capsule.createFromComponent(component, baseDir, opts);
905
905
  }, {
906
- concurrency: (0, _concurrency().concurrentComponentsLimit)()
906
+ concurrency: (0, _harmonyModules().concurrentComponentsLimit)()
907
907
  });
908
908
  return capsules;
909
909
  }
@@ -921,7 +921,7 @@ class IsolatorMain {
921
921
  }
922
922
  async getCapsulesPreviousPackageJson(capsules) {
923
923
  return Promise.all(capsules.map(async capsule => {
924
- const packageJsonPath = _path2().default.join(capsule.path, 'package.json');
924
+ const packageJsonPath = _path().default.join(capsule.path, 'package.json');
925
925
  let previousPackageJson = null;
926
926
  try {
927
927
  const previousPackageJsonRaw = await capsule.fs.promises.readFile(packageJsonPath, {
@@ -1021,7 +1021,7 @@ class IsolatorMain {
1021
1021
  return dependencies.reduce((acc, depId) => {
1022
1022
  if (Array.isArray(ignoreBitDependencies) && ignoreBitDependencies.searchWithoutVersion(depId)) return acc;
1023
1023
  const packageDependency = depId.version;
1024
- const packageName = (0, _componentIdToPackageName().default)(_objectSpread(_objectSpread({}, legacyComp), {}, {
1024
+ const packageName = (0, _pkgModules().componentIdToPackageName)(_objectSpread(_objectSpread({}, legacyComp), {}, {
1025
1025
  id: depId,
1026
1026
  isDependency: true
1027
1027
  }));
@@ -1033,7 +1033,7 @@ class IsolatorMain {
1033
1033
  const bitDevDependencies = getBitDependencies(legacyComp.devDependencies.getAllIds());
1034
1034
  const bitExtensionDependencies = getBitDependencies(legacyComp.extensions.extensionsBitIds);
1035
1035
  const packageJson = _packageJsonFile().default.createFromComponent(bitDir, legacyComp);
1036
- const main = (0, _path().pathNormalizeToLinux)(legacyComp.mainFile);
1036
+ const main = (0, _legacy().pathNormalizeToLinux)(legacyComp.mainFile);
1037
1037
  packageJson.addOrUpdateProperty('main', main);
1038
1038
  const addDependencies = packageJsonFile => {
1039
1039
  packageJsonFile.addDependencies(bitDependencies);