@teambit/workspace 0.0.844 → 0.0.847

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 (89) hide show
  1. package/dist/index.d.ts +1 -0
  2. package/dist/index.js.map +1 -1
  3. package/dist/ui/workspace/use-workspace.js +3 -0
  4. package/dist/ui/workspace/use-workspace.js.map +1 -1
  5. package/dist/workspace-component/workspace-component-loader.js +6 -0
  6. package/dist/workspace-component/workspace-component-loader.js.map +1 -1
  7. package/dist/workspace.d.ts +9 -60
  8. package/dist/workspace.js +29 -411
  9. package/dist/workspace.js.map +1 -1
  10. package/dist/workspace.main.runtime.js +1 -11
  11. package/dist/workspace.main.runtime.js.map +1 -1
  12. package/dist/workspace.provider.d.ts +2 -4
  13. package/dist/workspace.provider.js +3 -66
  14. package/dist/workspace.provider.js.map +1 -1
  15. package/dist/workspace.ui.runtime.d.ts +2 -1
  16. package/dist/workspace.ui.runtime.js +27 -6
  17. package/dist/workspace.ui.runtime.js.map +1 -1
  18. package/package-tar/teambit-workspace-0.0.847.tgz +0 -0
  19. package/package.json +33 -42
  20. package/{preview-1662281577904.js → preview-1662694416892.js} +2 -2
  21. package/ui/workspace/use-workspace.ts +3 -0
  22. package/workspace-component/workspace-component-loader.ts +5 -0
  23. package/workspace.ui.runtime.tsx +16 -6
  24. package/__snapshots__/pick-outdated-pkgs.spec.ts.snap +0 -171
  25. package/dist/__snapshots__/pick-outdated-pkgs.spec.js.snap +0 -171
  26. package/dist/__snapshots__/pick-outdated-pkgs.spec.ts.snap +0 -171
  27. package/dist/exceptions/dependency-type-not-supported-in-policy.d.ts +0 -4
  28. package/dist/exceptions/dependency-type-not-supported-in-policy.js +0 -27
  29. package/dist/exceptions/dependency-type-not-supported-in-policy.js.map +0 -1
  30. package/dist/exceptions/index.d.ts +0 -1
  31. package/dist/exceptions/index.js +0 -23
  32. package/dist/exceptions/index.js.map +0 -1
  33. package/dist/install.cmd.d.ts +0 -44
  34. package/dist/install.cmd.js +0 -85
  35. package/dist/install.cmd.js.map +0 -1
  36. package/dist/link/component-list-links.d.ts +0 -7
  37. package/dist/link/component-list-links.js +0 -98
  38. package/dist/link/component-list-links.js.map +0 -1
  39. package/dist/link/core-aspects-links.d.ts +0 -7
  40. package/dist/link/core-aspects-links.js +0 -95
  41. package/dist/link/core-aspects-links.js.map +0 -1
  42. package/dist/link/get-package-name-from-target.d.ts +0 -1
  43. package/dist/link/get-package-name-from-target.js +0 -16
  44. package/dist/link/get-package-name-from-target.js.map +0 -1
  45. package/dist/link/index.d.ts +0 -1
  46. package/dist/link/index.js +0 -23
  47. package/dist/link/index.js.map +0 -1
  48. package/dist/link/link-row.d.ts +0 -12
  49. package/dist/link/link-row.js +0 -38
  50. package/dist/link/link-row.js.map +0 -1
  51. package/dist/link/link-to-dir.d.ts +0 -2
  52. package/dist/link/link-to-dir.js +0 -45
  53. package/dist/link/link-to-dir.js.map +0 -1
  54. package/dist/link/link.cmd.d.ts +0 -44
  55. package/dist/link/link.cmd.js +0 -176
  56. package/dist/link/link.cmd.js.map +0 -1
  57. package/dist/link/nested-deps-in-nm-links.d.ts +0 -7
  58. package/dist/link/nested-deps-in-nm-links.js +0 -74
  59. package/dist/link/nested-deps-in-nm-links.js.map +0 -1
  60. package/dist/link/rewire-row.d.ts +0 -6
  61. package/dist/link/rewire-row.js +0 -31
  62. package/dist/link/rewire-row.js.map +0 -1
  63. package/dist/pick-outdated-pkgs.d.ts +0 -16
  64. package/dist/pick-outdated-pkgs.js +0 -308
  65. package/dist/pick-outdated-pkgs.js.map +0 -1
  66. package/dist/pick-outdated-pkgs.spec.d.ts +0 -1
  67. package/dist/pick-outdated-pkgs.spec.js +0 -121
  68. package/dist/pick-outdated-pkgs.spec.js.map +0 -1
  69. package/dist/uninstall.cmd.d.ts +0 -19
  70. package/dist/uninstall.cmd.js +0 -47
  71. package/dist/uninstall.cmd.js.map +0 -1
  72. package/dist/update.cmd.d.ts +0 -23
  73. package/dist/update.cmd.js +0 -47
  74. package/dist/update.cmd.js.map +0 -1
  75. package/exceptions/dependency-type-not-supported-in-policy.ts +0 -7
  76. package/exceptions/index.ts +0 -1
  77. package/install.cmd.tsx +0 -72
  78. package/link/component-list-links.ts +0 -50
  79. package/link/core-aspects-links.ts +0 -50
  80. package/link/get-package-name-from-target.ts +0 -5
  81. package/link/index.ts +0 -1
  82. package/link/link-row.ts +0 -20
  83. package/link/link-to-dir.ts +0 -13
  84. package/link/link.cmd.ts +0 -100
  85. package/link/nested-deps-in-nm-links.ts +0 -47
  86. package/link/rewire-row.ts +0 -17
  87. package/package-tar/teambit-workspace-0.0.844.tgz +0 -0
  88. package/uninstall.cmd.tsx +0 -23
  89. package/update.cmd.tsx +0 -29
package/dist/workspace.js CHANGED
@@ -29,16 +29,6 @@ function _defineProperty2() {
29
29
  return data;
30
30
  }
31
31
 
32
- function _chalk() {
33
- const data = _interopRequireDefault(require("chalk"));
34
-
35
- _chalk = function () {
36
- return data;
37
- };
38
-
39
- return data;
40
- }
41
-
42
32
  function _memoizee() {
43
33
  const data = _interopRequireDefault(require("memoizee"));
44
34
 
@@ -99,16 +89,6 @@ function _component() {
99
89
  return data;
100
90
  }
101
91
 
102
- function _importer() {
103
- const data = require("@teambit/importer");
104
-
105
- _importer = function () {
106
- return data;
107
- };
108
-
109
- return data;
110
- }
111
-
112
92
  function _bitError() {
113
93
  const data = require("@teambit/bit-error");
114
94
 
@@ -129,16 +109,6 @@ function _config() {
129
109
  return data;
130
110
  }
131
111
 
132
- function _dependencyResolver() {
133
- const data = require("@teambit/dependency-resolver");
134
-
135
- _dependencyResolver = function () {
136
- return data;
137
- };
138
-
139
- return data;
140
- }
141
-
142
112
  function _envs() {
143
113
  const data = require("@teambit/envs");
144
114
 
@@ -179,16 +149,6 @@ function _consumer() {
179
149
  return data;
180
150
  }
181
151
 
182
- function _exceptions() {
183
- const data = require("@teambit/legacy/dist/consumer/exceptions");
184
-
185
- _exceptions = function () {
186
- return data;
187
- };
188
-
189
- return data;
190
- }
191
-
192
152
  function _bitId() {
193
153
  const data = require("@teambit/legacy/dist/bit-id");
194
154
 
@@ -249,10 +209,10 @@ function _cacheFactory() {
249
209
  return data;
250
210
  }
251
211
 
252
- function _exceptions2() {
212
+ function _exceptions() {
253
213
  const data = require("@teambit/legacy/dist/scope/exceptions");
254
214
 
255
- _exceptions2 = function () {
215
+ _exceptions = function () {
256
216
  return data;
257
217
  };
258
218
 
@@ -359,10 +319,10 @@ function _scopeComponentsImporter() {
359
319
  return data;
360
320
  }
361
321
 
362
- function _exceptions3() {
322
+ function _exceptions2() {
363
323
  const data = require("@teambit/legacy/dist/consumer/bit-map/exceptions");
364
324
 
365
- _exceptions3 = function () {
325
+ _exceptions2 = function () {
366
326
  return data;
367
327
  };
368
328
 
@@ -409,26 +369,6 @@ function _componentConfigFile() {
409
369
  return data;
410
370
  }
411
371
 
412
- function _exceptions4() {
413
- const data = require("./exceptions");
414
-
415
- _exceptions4 = function () {
416
- return data;
417
- };
418
-
419
- return data;
420
- }
421
-
422
- function _pickOutdatedPkgs() {
423
- const data = require("./pick-outdated-pkgs");
424
-
425
- _pickOutdatedPkgs = function () {
426
- return data;
427
- };
428
-
429
- return data;
430
- }
431
-
432
372
  function _watcher() {
433
373
  const data = require("./watch/watcher");
434
374
 
@@ -535,7 +475,7 @@ class Workspace {
535
475
  /**
536
476
  * access to the `ComponentProvider` instance
537
477
  */
538
- componentAspect, isolator, dependencyResolver, variants, aspectLoader, logger, componentList = new (_componentsList().default)(consumer),
478
+ componentAspect, dependencyResolver, variants, aspectLoader, logger, componentList = new (_componentsList().default)(consumer),
539
479
  /**
540
480
  * private reference to the instance of Harmony.
541
481
  */
@@ -559,7 +499,6 @@ class Workspace {
559
499
  this.consumer = consumer;
560
500
  this.scope = scope;
561
501
  this.componentAspect = componentAspect;
562
- this.isolator = isolator;
563
502
  this.dependencyResolver = dependencyResolver;
564
503
  this.variants = variants;
565
504
  this.aspectLoader = aspectLoader;
@@ -1110,7 +1049,7 @@ class Workspace {
1110
1049
  // if it's not a pattern but just id, resolve it without multimatch to support specifying id without scope-name
1111
1050
  const id = await this.resolveComponentId(pattern);
1112
1051
  if (this.exists(id)) return [id];
1113
- if (throwForNoMatch) throw new (_exceptions3().MissingBitMapComponent)(pattern);
1052
+ if (throwForNoMatch) throw new (_exceptions2().MissingBitMapComponent)(pattern);
1114
1053
  return [];
1115
1054
  }
1116
1055
 
@@ -1842,6 +1781,22 @@ the following envs are used in this workspace: ${availableEnvs.join(', ')}`);
1842
1781
  });
1843
1782
  return this.componentConfigFileFromComponentDirAndName(relativeComponentDir, id.fullName);
1844
1783
  }
1784
+ /**
1785
+ * @param componentPath can be relative or absolute. supports Linux and Windows
1786
+ */
1787
+
1788
+
1789
+ async getComponentIdByPath(componentPath) {
1790
+ const relativePath = _path2().default.isAbsolute(componentPath) ? _path2().default.relative(this.path, componentPath) : componentPath;
1791
+ const linuxPath = (0, _path().pathNormalizeToLinux)(relativePath);
1792
+ const bitId = this.consumer.bitMap.getComponentIdByPath(linuxPath);
1793
+
1794
+ if (bitId) {
1795
+ return this.resolveComponentId(bitId);
1796
+ }
1797
+
1798
+ return undefined;
1799
+ }
1845
1800
 
1846
1801
  async componentConfigFileFromComponentDirAndName(relativeComponentDir, name) {
1847
1802
  let componentConfigFile;
@@ -1949,9 +1904,13 @@ needed-for: ${neededFor || '<unknown>'}`);
1949
1904
 
1950
1905
  const scopeIdsGrouped = await this.scope.groupAspectIdsByEnvOfTheList(scopeIds);
1951
1906
  const scopeEnvsManifestsIds = scopeIdsGrouped.envs && scopeIdsGrouped.envs.length ? await this.scope.loadAspects(scopeIdsGrouped.envs, throwOnError, 'workspace.loadAspects loading scope aspects') : [];
1952
- const scopeOtherManifests = scopeIdsGrouped.other && scopeIdsGrouped.other.length ? await this.scope.getManifestsGraphRecursively(scopeIdsGrouped.other, (0, _lodash().compact)(workspaceManifestsIds), throwOnError, {
1907
+ const {
1908
+ manifests: scopeOtherManifests
1909
+ } = scopeIdsGrouped.other && scopeIdsGrouped.other.length ? await this.scope.getManifestsGraphRecursively(scopeIdsGrouped.other, (0, _lodash().compact)(workspaceManifestsIds), throwOnError, {
1953
1910
  packageManagerConfigRootDir: this.path
1954
- }) : [];
1911
+ }) : {
1912
+ manifests: []
1913
+ };
1955
1914
  const scopeOtherManifestsIds = (0, _lodash().compact)(scopeOtherManifests.map(m => m.id));
1956
1915
  await this.aspectLoader.loadExtensionsByManifests([...scopeOtherManifests, ...workspaceManifests], throwOnError); // Try require components for potential plugins
1957
1916
 
@@ -2178,303 +2137,6 @@ needed-for: ${neededFor || '<unknown>'}`);
2178
2137
 
2179
2138
  return resolved;
2180
2139
  }
2181
-
2182
- async getComponentsDirectory(ids) {
2183
- const components = ids.length ? await this.getMany(ids) : await this.list();
2184
- return _component().ComponentMap.as(components, component => this.componentDir(component.id));
2185
- }
2186
- /**
2187
- * Install dependencies for all components in the workspace
2188
- *
2189
- * @returns
2190
- * @memberof Workspace
2191
- */
2192
-
2193
-
2194
- async install(packages, options) {
2195
- if (packages && packages.length) {
2196
- await this._addPackages(packages, options);
2197
- }
2198
-
2199
- if (options !== null && options !== void 0 && options.addMissingPeers) {
2200
- var _options$copyPeerToRu, _options$copyPeerToRu2;
2201
-
2202
- const compDirMap = await this.getComponentsDirectory([]);
2203
- const mergedRootPolicy = this.dependencyResolver.getWorkspacePolicy();
2204
- const depsFilterFn = await this.generateFilterFnForDepsFromLocalRemote();
2205
- const pmInstallOptions = {
2206
- dedupe: options === null || options === void 0 ? void 0 : options.dedupe,
2207
- copyPeerToRuntimeOnRoot: (_options$copyPeerToRu = options === null || options === void 0 ? void 0 : options.copyPeerToRuntimeOnRoot) !== null && _options$copyPeerToRu !== void 0 ? _options$copyPeerToRu : true,
2208
- copyPeerToRuntimeOnComponents: (_options$copyPeerToRu2 = options === null || options === void 0 ? void 0 : options.copyPeerToRuntimeOnComponents) !== null && _options$copyPeerToRu2 !== void 0 ? _options$copyPeerToRu2 : false,
2209
- dependencyFilterFn: depsFilterFn,
2210
- overrides: this.dependencyResolver.config.overrides,
2211
- packageImportMethod: this.dependencyResolver.config.packageImportMethod
2212
- };
2213
- const missingPeers = await this.dependencyResolver.getMissingPeerDependencies(this.path, mergedRootPolicy, compDirMap, pmInstallOptions);
2214
-
2215
- if (missingPeers) {
2216
- const missingPeerPackages = Object.entries(missingPeers).map(([peerName, range]) => `${peerName}@${range}`);
2217
- await this._addPackages(missingPeerPackages, options);
2218
- } else {
2219
- this.logger.console('No missing peer dependencies found.');
2220
- }
2221
- }
2222
-
2223
- if (options !== null && options !== void 0 && options.import) {
2224
- this.logger.setStatusLine('importing missing objects');
2225
- await this.importObjects();
2226
- this.logger.consoleSuccess();
2227
- }
2228
-
2229
- return this._installModules(options);
2230
- }
2231
-
2232
- async _addPackages(packages, options) {
2233
- if (!(options !== null && options !== void 0 && options.variants) && (options === null || options === void 0 ? void 0 : options.lifecycleType) === 'dev') {
2234
- throw new (_exceptions4().DependencyTypeNotSupportedInPolicy)(options === null || options === void 0 ? void 0 : options.lifecycleType);
2235
- }
2236
-
2237
- this.logger.debug(`installing the following packages: ${packages.join()}`);
2238
- const resolver = await this.dependencyResolver.getVersionResolver();
2239
- const resolvedPackagesP = packages.map(packageName => resolver.resolveRemoteVersion(packageName, {
2240
- rootDir: this.path
2241
- }));
2242
- const resolvedPackages = await Promise.all(resolvedPackagesP);
2243
- const newWorkspacePolicyEntries = [];
2244
- resolvedPackages.forEach(resolvedPackage => {
2245
- if (resolvedPackage.version) {
2246
- const versionWithPrefix = this.dependencyResolver.getVersionWithSavePrefix(resolvedPackage.version, options === null || options === void 0 ? void 0 : options.savePrefix);
2247
- newWorkspacePolicyEntries.push({
2248
- dependencyId: resolvedPackage.packageName,
2249
- value: {
2250
- version: versionWithPrefix
2251
- },
2252
- lifecycleType: (options === null || options === void 0 ? void 0 : options.lifecycleType) || 'runtime'
2253
- });
2254
- }
2255
- });
2256
-
2257
- if (!(options !== null && options !== void 0 && options.variants)) {
2258
- var _options$updateExisti;
2259
-
2260
- this.dependencyResolver.addToRootPolicy(newWorkspacePolicyEntries, {
2261
- updateExisting: (_options$updateExisti = options === null || options === void 0 ? void 0 : options.updateExisting) !== null && _options$updateExisti !== void 0 ? _options$updateExisti : false
2262
- });
2263
- } else {// TODO: implement
2264
- }
2265
-
2266
- await this.dependencyResolver.persistConfig(this.path);
2267
- }
2268
-
2269
- async _getComponentsWithDependencyPolicies() {
2270
- const allComponentIds = await this.listIds();
2271
- const componentConfigFiles = {};
2272
- const componentPoliciesById = {};
2273
- (await Promise.all(allComponentIds.map(componentId => this.componentConfigFile(componentId)))).forEach((componentConfigFile, index) => {
2274
- if (!componentConfigFile) return;
2275
- const depResolverConfig = componentConfigFile.aspects.get(_dependencyResolver().DependencyResolverAspect.id);
2276
- if (!depResolverConfig) return;
2277
- const componentId = allComponentIds[index].toString();
2278
- componentConfigFiles[componentId] = componentConfigFile;
2279
- componentPoliciesById[componentId] = depResolverConfig.config.policy;
2280
- });
2281
- return {
2282
- componentConfigFiles,
2283
- componentPoliciesById
2284
- };
2285
- }
2286
- /**
2287
- * Updates out-of-date dependencies in the workspace.
2288
- *
2289
- * @param options.all {Boolean} updates all outdated dependencies without showing a prompt.
2290
- */
2291
-
2292
-
2293
- async updateDependencies(options) {
2294
- const {
2295
- componentConfigFiles,
2296
- componentPoliciesById
2297
- } = await this._getComponentsWithDependencyPolicies();
2298
- const variantPatterns = this.variants.raw();
2299
-
2300
- const variantPoliciesByPatterns = this._variantPatternsToDepPolicesDict(variantPatterns);
2301
-
2302
- const components = await this.list();
2303
- const outdatedPkgs = await this.dependencyResolver.getOutdatedPkgsFromPolicies({
2304
- rootDir: this.path,
2305
- variantPoliciesByPatterns,
2306
- componentPoliciesById,
2307
- components
2308
- });
2309
- let outdatedPkgsToUpdate;
2310
-
2311
- if (options.all) {
2312
- outdatedPkgsToUpdate = outdatedPkgs;
2313
- } else {
2314
- this.logger.off();
2315
- outdatedPkgsToUpdate = await (0, _pickOutdatedPkgs().pickOutdatedPkgs)(outdatedPkgs);
2316
- this.logger.on();
2317
- }
2318
-
2319
- const {
2320
- updatedVariants,
2321
- updatedComponents
2322
- } = this.dependencyResolver.applyUpdates(outdatedPkgsToUpdate, {
2323
- variantPoliciesByPatterns,
2324
- componentPoliciesById
2325
- });
2326
- await this._updateVariantsPolicies(variantPatterns, updatedVariants);
2327
- const updatedComponentConfigFiles = Object.values((0, _lodash().pick)(componentConfigFiles, updatedComponents));
2328
- await this._saveManyComponentConfigFiles(updatedComponentConfigFiles);
2329
- await this._reloadConsumer();
2330
- return this._installModules({
2331
- dedupe: true
2332
- });
2333
- }
2334
-
2335
- _variantPatternsToDepPolicesDict(variantPatterns) {
2336
- const variantPoliciesByPatterns = {};
2337
-
2338
- for (const [variantPattern, extensions] of Object.entries(variantPatterns)) {
2339
- var _extensions$Dependenc;
2340
-
2341
- if ((_extensions$Dependenc = extensions[_dependencyResolver().DependencyResolverAspect.id]) !== null && _extensions$Dependenc !== void 0 && _extensions$Dependenc.policy) {
2342
- var _extensions$Dependenc2;
2343
-
2344
- variantPoliciesByPatterns[variantPattern] = (_extensions$Dependenc2 = extensions[_dependencyResolver().DependencyResolverAspect.id]) === null || _extensions$Dependenc2 === void 0 ? void 0 : _extensions$Dependenc2.policy;
2345
- }
2346
- }
2347
-
2348
- return variantPoliciesByPatterns;
2349
- }
2350
-
2351
- _updateVariantsPolicies(variantPatterns, updateVariantPolicies) {
2352
- for (const variantPattern of updateVariantPolicies) {
2353
- this.variants.setExtension(variantPattern, _dependencyResolver().DependencyResolverAspect.id, variantPatterns[variantPattern][_dependencyResolver().DependencyResolverAspect.id], {
2354
- overrideExisting: true
2355
- });
2356
- }
2357
-
2358
- return this.dependencyResolver.persistConfig(this.path);
2359
- }
2360
-
2361
- async _saveManyComponentConfigFiles(componentConfigFiles) {
2362
- await Promise.all(Array.from(componentConfigFiles).map(async componentConfigFile => {
2363
- await componentConfigFile.write({
2364
- override: true
2365
- });
2366
- }));
2367
- }
2368
-
2369
- async _installModules(options) {
2370
- var _options$copyPeerToRu3, _options$copyPeerToRu4;
2371
-
2372
- this.logger.console(`installing dependencies in workspace using ${_chalk().default.cyan(this.dependencyResolver.getPackageManagerName())}`);
2373
- this.logger.debug(`installing dependencies in workspace with options`, options);
2374
- const hasRootComponents = this.dependencyResolver.hasRootComponents(); // TODO: this make duplicate
2375
- // this.logger.consoleSuccess();
2376
- // TODO: add the links results to the output
2377
-
2378
- await this.link({
2379
- linkTeambitBit: true,
2380
- legacyLink: true,
2381
- linkCoreAspects: false,
2382
- linkDepsResolvedFromEnv: !hasRootComponents,
2383
- linkNestedDepsInNM: false
2384
- });
2385
- this.consumer.componentLoader.clearComponentsCache();
2386
- this.clearCache(); // TODO: pass get install options
2387
-
2388
- const installer = this.dependencyResolver.getInstaller({});
2389
- const compDirMap = await this.getComponentsDirectory([]);
2390
- const mergedRootPolicy = this.dependencyResolver.getWorkspacePolicy();
2391
- const depsFilterFn = await this.generateFilterFnForDepsFromLocalRemote();
2392
- const pmInstallOptions = {
2393
- dedupe: !hasRootComponents && (options === null || options === void 0 ? void 0 : options.dedupe),
2394
- copyPeerToRuntimeOnRoot: (_options$copyPeerToRu3 = options === null || options === void 0 ? void 0 : options.copyPeerToRuntimeOnRoot) !== null && _options$copyPeerToRu3 !== void 0 ? _options$copyPeerToRu3 : true,
2395
- copyPeerToRuntimeOnComponents: (_options$copyPeerToRu4 = options === null || options === void 0 ? void 0 : options.copyPeerToRuntimeOnComponents) !== null && _options$copyPeerToRu4 !== void 0 ? _options$copyPeerToRu4 : false,
2396
- dependencyFilterFn: depsFilterFn,
2397
- overrides: this.dependencyResolver.config.overrides,
2398
- packageImportMethod: this.dependencyResolver.config.packageImportMethod,
2399
- rootComponents: hasRootComponents
2400
- };
2401
- await installer.install(this.path, mergedRootPolicy, compDirMap, {
2402
- installTeambitBit: false
2403
- }, pmInstallOptions);
2404
- await this.link({
2405
- linkTeambitBit: false,
2406
- legacyLink: true,
2407
- linkCoreAspects: this.dependencyResolver.linkCoreAspects(),
2408
- linkDepsResolvedFromEnv: !hasRootComponents,
2409
- linkNestedDepsInNM: !this.isLegacy && !hasRootComponents
2410
- });
2411
- await this.consumer.componentFsCache.deleteAllDependenciesDataCache();
2412
- return compDirMap;
2413
- }
2414
-
2415
- async link(options = {}) {
2416
- if (options.fetchObject) {
2417
- await this.importObjects();
2418
- }
2419
-
2420
- options.consumer = this.consumer;
2421
- const compDirMap = await this.getComponentsDirectory([]);
2422
- const mergedRootPolicy = this.dependencyResolver.getWorkspacePolicy();
2423
- const linker = this.dependencyResolver.getLinker({
2424
- rootDir: this.path,
2425
- linkingOptions: options
2426
- });
2427
- const res = await linker.link(this.path, mergedRootPolicy, compDirMap, options);
2428
- return res;
2429
- }
2430
- /**
2431
- * @param componentPath can be relative or absolute. supports Linux and Windows
2432
- */
2433
-
2434
-
2435
- async getComponentIdByPath(componentPath) {
2436
- const relativePath = _path2().default.isAbsolute(componentPath) ? _path2().default.relative(this.path, componentPath) : componentPath;
2437
- const linuxPath = (0, _path().pathNormalizeToLinux)(relativePath);
2438
- const bitId = this.consumer.bitMap.getComponentIdByPath(linuxPath);
2439
-
2440
- if (bitId) {
2441
- return this.resolveComponentId(bitId);
2442
- }
2443
-
2444
- return undefined;
2445
- }
2446
- /**
2447
- * Generate a filter to pass to the installer
2448
- * This will filter deps which are come from remotes which defined in scope.json
2449
- * those components comes from local remotes, usually doesn't have a package in a registry
2450
- * so no reason to try to install them (it will fail)
2451
- */
2452
-
2453
-
2454
- async generateFilterFnForDepsFromLocalRemote() {
2455
- // TODO: once scope create a new API for this, replace it with the new one
2456
- const remotes = await this.scope._legacyRemotes();
2457
- const reg = await this.dependencyResolver.getRegistries();
2458
- const packageScopes = Object.keys(reg.scopes);
2459
- return dependencyList => {
2460
- const filtered = dependencyList.filter(dep => {
2461
- if (!(dep instanceof _dependencyResolver().ComponentDependency)) {
2462
- return true;
2463
- }
2464
-
2465
- if (remotes.isHub(dep.componentId.scope)) {
2466
- return true;
2467
- }
2468
-
2469
- if (packageScopes.some(scope => dep.packageName.startsWith(`@${scope}/`))) {
2470
- return true;
2471
- }
2472
-
2473
- return false;
2474
- });
2475
- return filtered;
2476
- };
2477
- }
2478
2140
  /**
2479
2141
  * whether a scope is hosted by Bit cloud.
2480
2142
  * otherwise, it is self-hosted
@@ -2495,7 +2157,7 @@ needed-for: ${neededFor || '<unknown>'}`);
2495
2157
  try {
2496
2158
  return await this.importAndGetMany(componentIds);
2497
2159
  } catch (err) {
2498
- if (err instanceof _exceptions2().ComponentNotFound) {
2160
+ if (err instanceof _exceptions().ComponentNotFound) {
2499
2161
  var _config$workspaceConf3;
2500
2162
 
2501
2163
  const config = this.harmony.get('teambit.harmony/config');
@@ -2507,36 +2169,6 @@ your workspace.jsonc has this component-id set. you might want to remove/change
2507
2169
  }
2508
2170
  }
2509
2171
 
2510
- throw err;
2511
- }
2512
- } // TODO: replace with a proper import API on the workspace
2513
-
2514
-
2515
- async importObjects() {
2516
- const importOptions = {
2517
- ids: [],
2518
- verbose: false,
2519
- merge: false,
2520
- objectsOnly: true,
2521
- override: false,
2522
- writeDists: false,
2523
- writeConfig: false,
2524
- installNpmPackages: false,
2525
- importDependenciesDirectly: false,
2526
- importDependents: false
2527
- };
2528
- const importer = new (_importer().Importer)(this, this.dependencyResolver);
2529
-
2530
- try {
2531
- const res = await importer.import(importOptions, []);
2532
- return res;
2533
- } catch (err) {
2534
- // TODO: this is a hack since the legacy throw an error, we should provide a way to not throw this error from the legacy
2535
- if (err instanceof _exceptions().NothingToImport) {
2536
- // Do not write nothing to import warning
2537
- return undefined;
2538
- }
2539
-
2540
2172
  throw err;
2541
2173
  }
2542
2174
  }
@@ -2761,20 +2393,6 @@ your workspace.jsonc has this component-id set. you might want to remove/change
2761
2393
  });
2762
2394
  return Promise.all(resolveMergedExtensionsP);
2763
2395
  }
2764
- /**
2765
- * Uninstall the specified packages from dependencies.
2766
- *
2767
- * @param {string[]} the list of packages that should be removed from dependencies.
2768
- */
2769
-
2770
-
2771
- async uninstallDependencies(packages) {
2772
- this.dependencyResolver.removeFromRootPolicy(packages);
2773
- await this.dependencyResolver.persistConfig(this.path);
2774
- return this._installModules({
2775
- dedupe: true
2776
- });
2777
- }
2778
2396
  /**
2779
2397
  * configure an environment to the given components in the .bitmap file, this configuration overrides other, such as
2780
2398
  * overrides in workspace.jsonc.