@teambit/workspace 0.0.843 → 0.0.846

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 (86) 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.d.ts +9 -60
  6. package/dist/workspace.js +37 -409
  7. package/dist/workspace.js.map +1 -1
  8. package/dist/workspace.main.runtime.js +1 -11
  9. package/dist/workspace.main.runtime.js.map +1 -1
  10. package/dist/workspace.provider.d.ts +2 -4
  11. package/dist/workspace.provider.js +3 -66
  12. package/dist/workspace.provider.js.map +1 -1
  13. package/dist/workspace.ui.runtime.d.ts +2 -1
  14. package/dist/workspace.ui.runtime.js +27 -6
  15. package/dist/workspace.ui.runtime.js.map +1 -1
  16. package/package-tar/teambit-workspace-0.0.846.tgz +0 -0
  17. package/package.json +33 -42
  18. package/{preview-1662089982043.js → preview-1662608124038.js} +2 -2
  19. package/ui/workspace/use-workspace.ts +3 -0
  20. package/workspace.ui.runtime.tsx +16 -6
  21. package/__snapshots__/pick-outdated-pkgs.spec.ts.snap +0 -171
  22. package/dist/__snapshots__/pick-outdated-pkgs.spec.js.snap +0 -171
  23. package/dist/__snapshots__/pick-outdated-pkgs.spec.ts.snap +0 -171
  24. package/dist/exceptions/dependency-type-not-supported-in-policy.d.ts +0 -4
  25. package/dist/exceptions/dependency-type-not-supported-in-policy.js +0 -27
  26. package/dist/exceptions/dependency-type-not-supported-in-policy.js.map +0 -1
  27. package/dist/exceptions/index.d.ts +0 -1
  28. package/dist/exceptions/index.js +0 -23
  29. package/dist/exceptions/index.js.map +0 -1
  30. package/dist/install.cmd.d.ts +0 -44
  31. package/dist/install.cmd.js +0 -85
  32. package/dist/install.cmd.js.map +0 -1
  33. package/dist/link/component-list-links.d.ts +0 -7
  34. package/dist/link/component-list-links.js +0 -98
  35. package/dist/link/component-list-links.js.map +0 -1
  36. package/dist/link/core-aspects-links.d.ts +0 -7
  37. package/dist/link/core-aspects-links.js +0 -95
  38. package/dist/link/core-aspects-links.js.map +0 -1
  39. package/dist/link/get-package-name-from-target.d.ts +0 -1
  40. package/dist/link/get-package-name-from-target.js +0 -16
  41. package/dist/link/get-package-name-from-target.js.map +0 -1
  42. package/dist/link/index.d.ts +0 -1
  43. package/dist/link/index.js +0 -23
  44. package/dist/link/index.js.map +0 -1
  45. package/dist/link/link-row.d.ts +0 -12
  46. package/dist/link/link-row.js +0 -38
  47. package/dist/link/link-row.js.map +0 -1
  48. package/dist/link/link-to-dir.d.ts +0 -2
  49. package/dist/link/link-to-dir.js +0 -45
  50. package/dist/link/link-to-dir.js.map +0 -1
  51. package/dist/link/link.cmd.d.ts +0 -44
  52. package/dist/link/link.cmd.js +0 -176
  53. package/dist/link/link.cmd.js.map +0 -1
  54. package/dist/link/nested-deps-in-nm-links.d.ts +0 -7
  55. package/dist/link/nested-deps-in-nm-links.js +0 -74
  56. package/dist/link/nested-deps-in-nm-links.js.map +0 -1
  57. package/dist/link/rewire-row.d.ts +0 -6
  58. package/dist/link/rewire-row.js +0 -31
  59. package/dist/link/rewire-row.js.map +0 -1
  60. package/dist/pick-outdated-pkgs.d.ts +0 -16
  61. package/dist/pick-outdated-pkgs.js +0 -308
  62. package/dist/pick-outdated-pkgs.js.map +0 -1
  63. package/dist/pick-outdated-pkgs.spec.d.ts +0 -1
  64. package/dist/pick-outdated-pkgs.spec.js +0 -121
  65. package/dist/pick-outdated-pkgs.spec.js.map +0 -1
  66. package/dist/uninstall.cmd.d.ts +0 -19
  67. package/dist/uninstall.cmd.js +0 -47
  68. package/dist/uninstall.cmd.js.map +0 -1
  69. package/dist/update.cmd.d.ts +0 -23
  70. package/dist/update.cmd.js +0 -47
  71. package/dist/update.cmd.js.map +0 -1
  72. package/exceptions/dependency-type-not-supported-in-policy.ts +0 -7
  73. package/exceptions/index.ts +0 -1
  74. package/install.cmd.tsx +0 -72
  75. package/link/component-list-links.ts +0 -50
  76. package/link/core-aspects-links.ts +0 -50
  77. package/link/get-package-name-from-target.ts +0 -5
  78. package/link/index.ts +0 -1
  79. package/link/link-row.ts +0 -20
  80. package/link/link-to-dir.ts +0 -13
  81. package/link/link.cmd.ts +0 -100
  82. package/link/nested-deps-in-nm-links.ts +0 -47
  83. package/link/rewire-row.ts +0 -17
  84. package/package-tar/teambit-workspace-0.0.843.tgz +0 -0
  85. package/uninstall.cmd.tsx +0 -23
  86. 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,6 +319,16 @@ function _scopeComponentsImporter() {
359
319
  return data;
360
320
  }
361
321
 
322
+ function _exceptions2() {
323
+ const data = require("@teambit/legacy/dist/consumer/bit-map/exceptions");
324
+
325
+ _exceptions2 = function () {
326
+ return data;
327
+ };
328
+
329
+ return data;
330
+ }
331
+
362
332
  function _loader() {
363
333
  const data = _interopRequireDefault(require("@teambit/legacy/dist/cli/loader"));
364
334
 
@@ -399,26 +369,6 @@ function _componentConfigFile() {
399
369
  return data;
400
370
  }
401
371
 
402
- function _exceptions3() {
403
- const data = require("./exceptions");
404
-
405
- _exceptions3 = function () {
406
- return data;
407
- };
408
-
409
- return data;
410
- }
411
-
412
- function _pickOutdatedPkgs() {
413
- const data = require("./pick-outdated-pkgs");
414
-
415
- _pickOutdatedPkgs = function () {
416
- return data;
417
- };
418
-
419
- return data;
420
- }
421
-
422
372
  function _watcher() {
423
373
  const data = require("./watch/watcher");
424
374
 
@@ -525,7 +475,7 @@ class Workspace {
525
475
  /**
526
476
  * access to the `ComponentProvider` instance
527
477
  */
528
- componentAspect, isolator, dependencyResolver, variants, aspectLoader, logger, componentList = new (_componentsList().default)(consumer),
478
+ componentAspect, dependencyResolver, variants, aspectLoader, logger, componentList = new (_componentsList().default)(consumer),
529
479
  /**
530
480
  * private reference to the instance of Harmony.
531
481
  */
@@ -549,7 +499,6 @@ class Workspace {
549
499
  this.consumer = consumer;
550
500
  this.scope = scope;
551
501
  this.componentAspect = componentAspect;
552
- this.isolator = isolator;
553
502
  this.dependencyResolver = dependencyResolver;
554
503
  this.variants = variants;
555
504
  this.aspectLoader = aspectLoader;
@@ -1100,7 +1049,7 @@ class Workspace {
1100
1049
  // if it's not a pattern but just id, resolve it without multimatch to support specifying id without scope-name
1101
1050
  const id = await this.resolveComponentId(pattern);
1102
1051
  if (this.exists(id)) return [id];
1103
- if (throwForNoMatch) throw new (_bitError().BitError)(`unable to find "${pattern}" in the workspace`);
1052
+ if (throwForNoMatch) throw new (_exceptions2().MissingBitMapComponent)(pattern);
1104
1053
  return [];
1105
1054
  }
1106
1055
 
@@ -1832,6 +1781,22 @@ the following envs are used in this workspace: ${availableEnvs.join(', ')}`);
1832
1781
  });
1833
1782
  return this.componentConfigFileFromComponentDirAndName(relativeComponentDir, id.fullName);
1834
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
+ }
1835
1800
 
1836
1801
  async componentConfigFileFromComponentDirAndName(relativeComponentDir, name) {
1837
1802
  let componentConfigFile;
@@ -1939,9 +1904,13 @@ needed-for: ${neededFor || '<unknown>'}`);
1939
1904
 
1940
1905
  const scopeIdsGrouped = await this.scope.groupAspectIdsByEnvOfTheList(scopeIds);
1941
1906
  const scopeEnvsManifestsIds = scopeIdsGrouped.envs && scopeIdsGrouped.envs.length ? await this.scope.loadAspects(scopeIdsGrouped.envs, throwOnError, 'workspace.loadAspects loading scope aspects') : [];
1942
- 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, {
1943
1910
  packageManagerConfigRootDir: this.path
1944
- }) : [];
1911
+ }) : {
1912
+ manifests: []
1913
+ };
1945
1914
  const scopeOtherManifestsIds = (0, _lodash().compact)(scopeOtherManifests.map(m => m.id));
1946
1915
  await this.aspectLoader.loadExtensionsByManifests([...scopeOtherManifests, ...workspaceManifests], throwOnError); // Try require components for potential plugins
1947
1916
 
@@ -2168,303 +2137,6 @@ needed-for: ${neededFor || '<unknown>'}`);
2168
2137
 
2169
2138
  return resolved;
2170
2139
  }
2171
-
2172
- async getComponentsDirectory(ids) {
2173
- const components = ids.length ? await this.getMany(ids) : await this.list();
2174
- return _component().ComponentMap.as(components, component => this.componentDir(component.id));
2175
- }
2176
- /**
2177
- * Install dependencies for all components in the workspace
2178
- *
2179
- * @returns
2180
- * @memberof Workspace
2181
- */
2182
-
2183
-
2184
- async install(packages, options) {
2185
- if (packages && packages.length) {
2186
- await this._addPackages(packages, options);
2187
- }
2188
-
2189
- if (options !== null && options !== void 0 && options.addMissingPeers) {
2190
- var _options$copyPeerToRu, _options$copyPeerToRu2;
2191
-
2192
- const compDirMap = await this.getComponentsDirectory([]);
2193
- const mergedRootPolicy = this.dependencyResolver.getWorkspacePolicy();
2194
- const depsFilterFn = await this.generateFilterFnForDepsFromLocalRemote();
2195
- const pmInstallOptions = {
2196
- dedupe: options === null || options === void 0 ? void 0 : options.dedupe,
2197
- copyPeerToRuntimeOnRoot: (_options$copyPeerToRu = options === null || options === void 0 ? void 0 : options.copyPeerToRuntimeOnRoot) !== null && _options$copyPeerToRu !== void 0 ? _options$copyPeerToRu : true,
2198
- copyPeerToRuntimeOnComponents: (_options$copyPeerToRu2 = options === null || options === void 0 ? void 0 : options.copyPeerToRuntimeOnComponents) !== null && _options$copyPeerToRu2 !== void 0 ? _options$copyPeerToRu2 : false,
2199
- dependencyFilterFn: depsFilterFn,
2200
- overrides: this.dependencyResolver.config.overrides,
2201
- packageImportMethod: this.dependencyResolver.config.packageImportMethod
2202
- };
2203
- const missingPeers = await this.dependencyResolver.getMissingPeerDependencies(this.path, mergedRootPolicy, compDirMap, pmInstallOptions);
2204
-
2205
- if (missingPeers) {
2206
- const missingPeerPackages = Object.entries(missingPeers).map(([peerName, range]) => `${peerName}@${range}`);
2207
- await this._addPackages(missingPeerPackages, options);
2208
- } else {
2209
- this.logger.console('No missing peer dependencies found.');
2210
- }
2211
- }
2212
-
2213
- if (options !== null && options !== void 0 && options.import) {
2214
- this.logger.setStatusLine('importing missing objects');
2215
- await this.importObjects();
2216
- this.logger.consoleSuccess();
2217
- }
2218
-
2219
- return this._installModules(options);
2220
- }
2221
-
2222
- async _addPackages(packages, options) {
2223
- if (!(options !== null && options !== void 0 && options.variants) && (options === null || options === void 0 ? void 0 : options.lifecycleType) === 'dev') {
2224
- throw new (_exceptions3().DependencyTypeNotSupportedInPolicy)(options === null || options === void 0 ? void 0 : options.lifecycleType);
2225
- }
2226
-
2227
- this.logger.debug(`installing the following packages: ${packages.join()}`);
2228
- const resolver = await this.dependencyResolver.getVersionResolver();
2229
- const resolvedPackagesP = packages.map(packageName => resolver.resolveRemoteVersion(packageName, {
2230
- rootDir: this.path
2231
- }));
2232
- const resolvedPackages = await Promise.all(resolvedPackagesP);
2233
- const newWorkspacePolicyEntries = [];
2234
- resolvedPackages.forEach(resolvedPackage => {
2235
- if (resolvedPackage.version) {
2236
- const versionWithPrefix = this.dependencyResolver.getVersionWithSavePrefix(resolvedPackage.version, options === null || options === void 0 ? void 0 : options.savePrefix);
2237
- newWorkspacePolicyEntries.push({
2238
- dependencyId: resolvedPackage.packageName,
2239
- value: {
2240
- version: versionWithPrefix
2241
- },
2242
- lifecycleType: (options === null || options === void 0 ? void 0 : options.lifecycleType) || 'runtime'
2243
- });
2244
- }
2245
- });
2246
-
2247
- if (!(options !== null && options !== void 0 && options.variants)) {
2248
- var _options$updateExisti;
2249
-
2250
- this.dependencyResolver.addToRootPolicy(newWorkspacePolicyEntries, {
2251
- updateExisting: (_options$updateExisti = options === null || options === void 0 ? void 0 : options.updateExisting) !== null && _options$updateExisti !== void 0 ? _options$updateExisti : false
2252
- });
2253
- } else {// TODO: implement
2254
- }
2255
-
2256
- await this.dependencyResolver.persistConfig(this.path);
2257
- }
2258
-
2259
- async _getComponentsWithDependencyPolicies() {
2260
- const allComponentIds = await this.listIds();
2261
- const componentConfigFiles = {};
2262
- const componentPoliciesById = {};
2263
- (await Promise.all(allComponentIds.map(componentId => this.componentConfigFile(componentId)))).forEach((componentConfigFile, index) => {
2264
- if (!componentConfigFile) return;
2265
- const depResolverConfig = componentConfigFile.aspects.get(_dependencyResolver().DependencyResolverAspect.id);
2266
- if (!depResolverConfig) return;
2267
- const componentId = allComponentIds[index].toString();
2268
- componentConfigFiles[componentId] = componentConfigFile;
2269
- componentPoliciesById[componentId] = depResolverConfig.config.policy;
2270
- });
2271
- return {
2272
- componentConfigFiles,
2273
- componentPoliciesById
2274
- };
2275
- }
2276
- /**
2277
- * Updates out-of-date dependencies in the workspace.
2278
- *
2279
- * @param options.all {Boolean} updates all outdated dependencies without showing a prompt.
2280
- */
2281
-
2282
-
2283
- async updateDependencies(options) {
2284
- const {
2285
- componentConfigFiles,
2286
- componentPoliciesById
2287
- } = await this._getComponentsWithDependencyPolicies();
2288
- const variantPatterns = this.variants.raw();
2289
-
2290
- const variantPoliciesByPatterns = this._variantPatternsToDepPolicesDict(variantPatterns);
2291
-
2292
- const components = await this.list();
2293
- const outdatedPkgs = await this.dependencyResolver.getOutdatedPkgsFromPolicies({
2294
- rootDir: this.path,
2295
- variantPoliciesByPatterns,
2296
- componentPoliciesById,
2297
- components
2298
- });
2299
- let outdatedPkgsToUpdate;
2300
-
2301
- if (options.all) {
2302
- outdatedPkgsToUpdate = outdatedPkgs;
2303
- } else {
2304
- this.logger.off();
2305
- outdatedPkgsToUpdate = await (0, _pickOutdatedPkgs().pickOutdatedPkgs)(outdatedPkgs);
2306
- this.logger.on();
2307
- }
2308
-
2309
- const {
2310
- updatedVariants,
2311
- updatedComponents
2312
- } = this.dependencyResolver.applyUpdates(outdatedPkgsToUpdate, {
2313
- variantPoliciesByPatterns,
2314
- componentPoliciesById
2315
- });
2316
- await this._updateVariantsPolicies(variantPatterns, updatedVariants);
2317
- const updatedComponentConfigFiles = Object.values((0, _lodash().pick)(componentConfigFiles, updatedComponents));
2318
- await this._saveManyComponentConfigFiles(updatedComponentConfigFiles);
2319
- await this._reloadConsumer();
2320
- return this._installModules({
2321
- dedupe: true
2322
- });
2323
- }
2324
-
2325
- _variantPatternsToDepPolicesDict(variantPatterns) {
2326
- const variantPoliciesByPatterns = {};
2327
-
2328
- for (const [variantPattern, extensions] of Object.entries(variantPatterns)) {
2329
- var _extensions$Dependenc;
2330
-
2331
- if ((_extensions$Dependenc = extensions[_dependencyResolver().DependencyResolverAspect.id]) !== null && _extensions$Dependenc !== void 0 && _extensions$Dependenc.policy) {
2332
- var _extensions$Dependenc2;
2333
-
2334
- variantPoliciesByPatterns[variantPattern] = (_extensions$Dependenc2 = extensions[_dependencyResolver().DependencyResolverAspect.id]) === null || _extensions$Dependenc2 === void 0 ? void 0 : _extensions$Dependenc2.policy;
2335
- }
2336
- }
2337
-
2338
- return variantPoliciesByPatterns;
2339
- }
2340
-
2341
- _updateVariantsPolicies(variantPatterns, updateVariantPolicies) {
2342
- for (const variantPattern of updateVariantPolicies) {
2343
- this.variants.setExtension(variantPattern, _dependencyResolver().DependencyResolverAspect.id, variantPatterns[variantPattern][_dependencyResolver().DependencyResolverAspect.id], {
2344
- overrideExisting: true
2345
- });
2346
- }
2347
-
2348
- return this.dependencyResolver.persistConfig(this.path);
2349
- }
2350
-
2351
- async _saveManyComponentConfigFiles(componentConfigFiles) {
2352
- await Promise.all(Array.from(componentConfigFiles).map(async componentConfigFile => {
2353
- await componentConfigFile.write({
2354
- override: true
2355
- });
2356
- }));
2357
- }
2358
-
2359
- async _installModules(options) {
2360
- var _options$copyPeerToRu3, _options$copyPeerToRu4;
2361
-
2362
- this.logger.console(`installing dependencies in workspace using ${_chalk().default.cyan(this.dependencyResolver.getPackageManagerName())}`);
2363
- this.logger.debug(`installing dependencies in workspace with options`, options);
2364
- const hasRootComponents = this.dependencyResolver.hasRootComponents(); // TODO: this make duplicate
2365
- // this.logger.consoleSuccess();
2366
- // TODO: add the links results to the output
2367
-
2368
- await this.link({
2369
- linkTeambitBit: true,
2370
- legacyLink: true,
2371
- linkCoreAspects: false,
2372
- linkDepsResolvedFromEnv: !hasRootComponents,
2373
- linkNestedDepsInNM: false
2374
- });
2375
- this.consumer.componentLoader.clearComponentsCache();
2376
- this.clearCache(); // TODO: pass get install options
2377
-
2378
- const installer = this.dependencyResolver.getInstaller({});
2379
- const compDirMap = await this.getComponentsDirectory([]);
2380
- const mergedRootPolicy = this.dependencyResolver.getWorkspacePolicy();
2381
- const depsFilterFn = await this.generateFilterFnForDepsFromLocalRemote();
2382
- const pmInstallOptions = {
2383
- dedupe: !hasRootComponents && (options === null || options === void 0 ? void 0 : options.dedupe),
2384
- copyPeerToRuntimeOnRoot: (_options$copyPeerToRu3 = options === null || options === void 0 ? void 0 : options.copyPeerToRuntimeOnRoot) !== null && _options$copyPeerToRu3 !== void 0 ? _options$copyPeerToRu3 : true,
2385
- copyPeerToRuntimeOnComponents: (_options$copyPeerToRu4 = options === null || options === void 0 ? void 0 : options.copyPeerToRuntimeOnComponents) !== null && _options$copyPeerToRu4 !== void 0 ? _options$copyPeerToRu4 : false,
2386
- dependencyFilterFn: depsFilterFn,
2387
- overrides: this.dependencyResolver.config.overrides,
2388
- packageImportMethod: this.dependencyResolver.config.packageImportMethod,
2389
- rootComponents: hasRootComponents
2390
- };
2391
- await installer.install(this.path, mergedRootPolicy, compDirMap, {
2392
- installTeambitBit: false
2393
- }, pmInstallOptions);
2394
- await this.link({
2395
- linkTeambitBit: false,
2396
- legacyLink: true,
2397
- linkCoreAspects: this.dependencyResolver.linkCoreAspects(),
2398
- linkDepsResolvedFromEnv: !hasRootComponents,
2399
- linkNestedDepsInNM: !this.isLegacy && !hasRootComponents
2400
- });
2401
- await this.consumer.componentFsCache.deleteAllDependenciesDataCache();
2402
- return compDirMap;
2403
- }
2404
-
2405
- async link(options = {}) {
2406
- if (options.fetchObject) {
2407
- await this.importObjects();
2408
- }
2409
-
2410
- options.consumer = this.consumer;
2411
- const compDirMap = await this.getComponentsDirectory([]);
2412
- const mergedRootPolicy = this.dependencyResolver.getWorkspacePolicy();
2413
- const linker = this.dependencyResolver.getLinker({
2414
- rootDir: this.path,
2415
- linkingOptions: options
2416
- });
2417
- const res = await linker.link(this.path, mergedRootPolicy, compDirMap, options);
2418
- return res;
2419
- }
2420
- /**
2421
- * @param componentPath can be relative or absolute. supports Linux and Windows
2422
- */
2423
-
2424
-
2425
- async getComponentIdByPath(componentPath) {
2426
- const relativePath = _path2().default.isAbsolute(componentPath) ? _path2().default.relative(this.path, componentPath) : componentPath;
2427
- const linuxPath = (0, _path().pathNormalizeToLinux)(relativePath);
2428
- const bitId = this.consumer.bitMap.getComponentIdByPath(linuxPath);
2429
-
2430
- if (bitId) {
2431
- return this.resolveComponentId(bitId);
2432
- }
2433
-
2434
- return undefined;
2435
- }
2436
- /**
2437
- * Generate a filter to pass to the installer
2438
- * This will filter deps which are come from remotes which defined in scope.json
2439
- * those components comes from local remotes, usually doesn't have a package in a registry
2440
- * so no reason to try to install them (it will fail)
2441
- */
2442
-
2443
-
2444
- async generateFilterFnForDepsFromLocalRemote() {
2445
- // TODO: once scope create a new API for this, replace it with the new one
2446
- const remotes = await this.scope._legacyRemotes();
2447
- const reg = await this.dependencyResolver.getRegistries();
2448
- const packageScopes = Object.keys(reg.scopes);
2449
- return dependencyList => {
2450
- const filtered = dependencyList.filter(dep => {
2451
- if (!(dep instanceof _dependencyResolver().ComponentDependency)) {
2452
- return true;
2453
- }
2454
-
2455
- if (remotes.isHub(dep.componentId.scope)) {
2456
- return true;
2457
- }
2458
-
2459
- if (packageScopes.some(scope => dep.packageName.startsWith(`@${scope}/`))) {
2460
- return true;
2461
- }
2462
-
2463
- return false;
2464
- });
2465
- return filtered;
2466
- };
2467
- }
2468
2140
  /**
2469
2141
  * whether a scope is hosted by Bit cloud.
2470
2142
  * otherwise, it is self-hosted
@@ -2485,7 +2157,7 @@ needed-for: ${neededFor || '<unknown>'}`);
2485
2157
  try {
2486
2158
  return await this.importAndGetMany(componentIds);
2487
2159
  } catch (err) {
2488
- if (err instanceof _exceptions2().ComponentNotFound) {
2160
+ if (err instanceof _exceptions().ComponentNotFound) {
2489
2161
  var _config$workspaceConf3;
2490
2162
 
2491
2163
  const config = this.harmony.get('teambit.harmony/config');
@@ -2497,36 +2169,6 @@ your workspace.jsonc has this component-id set. you might want to remove/change
2497
2169
  }
2498
2170
  }
2499
2171
 
2500
- throw err;
2501
- }
2502
- } // TODO: replace with a proper import API on the workspace
2503
-
2504
-
2505
- async importObjects() {
2506
- const importOptions = {
2507
- ids: [],
2508
- verbose: false,
2509
- merge: false,
2510
- objectsOnly: true,
2511
- override: false,
2512
- writeDists: false,
2513
- writeConfig: false,
2514
- installNpmPackages: false,
2515
- importDependenciesDirectly: false,
2516
- importDependents: false
2517
- };
2518
- const importer = new (_importer().Importer)(this, this.dependencyResolver);
2519
-
2520
- try {
2521
- const res = await importer.import(importOptions, []);
2522
- return res;
2523
- } catch (err) {
2524
- // TODO: this is a hack since the legacy throw an error, we should provide a way to not throw this error from the legacy
2525
- if (err instanceof _exceptions().NothingToImport) {
2526
- // Do not write nothing to import warning
2527
- return undefined;
2528
- }
2529
-
2530
2172
  throw err;
2531
2173
  }
2532
2174
  }
@@ -2751,20 +2393,6 @@ your workspace.jsonc has this component-id set. you might want to remove/change
2751
2393
  });
2752
2394
  return Promise.all(resolveMergedExtensionsP);
2753
2395
  }
2754
- /**
2755
- * Uninstall the specified packages from dependencies.
2756
- *
2757
- * @param {string[]} the list of packages that should be removed from dependencies.
2758
- */
2759
-
2760
-
2761
- async uninstallDependencies(packages) {
2762
- this.dependencyResolver.removeFromRootPolicy(packages);
2763
- await this.dependencyResolver.persistConfig(this.path);
2764
- return this._installModules({
2765
- dedupe: true
2766
- });
2767
- }
2768
2396
  /**
2769
2397
  * configure an environment to the given components in the .bitmap file, this configuration overrides other, such as
2770
2398
  * overrides in workspace.jsonc.