@teambit/workspace 1.0.346 → 1.0.348

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/workspace.js CHANGED
@@ -439,6 +439,14 @@ class Workspace {
439
439
  return this.consumer.getPath();
440
440
  }
441
441
 
442
+ /**
443
+ * Get the location of the bit roots folder
444
+ */
445
+ get rootComponentsPath() {
446
+ const baseDir = this.config.rootComponentsDirectory != null ? _path().default.join(this.path, this.config.rootComponentsDirectory) : this.modulesPath;
447
+ return _path().default.join(baseDir, _constants().BIT_ROOTS_DIR);
448
+ }
449
+
442
450
  /** get the `node_modules` folder of this workspace */
443
451
  get modulesPath() {
444
452
  return _path().default.join(this.path, 'node_modules');
@@ -547,6 +555,7 @@ class Workspace {
547
555
 
548
556
  /**
549
557
  * get ids of all workspace components.
558
+ * deleted components are filtered out. (use this.listIdsIncludeRemoved() if you need them)
550
559
  */
551
560
  listIds() {
552
561
  return this.consumer.bitmapIdsFromCurrentLane;
@@ -651,7 +660,7 @@ class Workspace {
651
660
  */
652
661
  async listPotentialTagIds() {
653
662
  const deletedIds = await this.locallyDeletedIds();
654
- const allIdsWithoutDeleted = await this.listIds();
663
+ const allIdsWithoutDeleted = this.listIds();
655
664
  return [...deletedIds, ...allIdsWithoutDeleted];
656
665
  }
657
666
  async getNewAndModifiedIds() {
@@ -1677,8 +1686,11 @@ the following envs are used in this workspace: ${availableEnvs.join(', ')}`);
1677
1686
  await this.clearCache();
1678
1687
  }
1679
1688
  async getComponentPackagePath(component) {
1680
- const inInWs = await this.hasId(component.id);
1681
- const relativePath = this.dependencyResolver.getRuntimeModulePath(component, inInWs);
1689
+ const relativePath = this.dependencyResolver.getRuntimeModulePath(component, {
1690
+ workspacePath: this.path,
1691
+ rootComponentsPath: this.rootComponentsPath,
1692
+ isInWorkspace: this.hasId(component.id)
1693
+ });
1682
1694
  return _path().default.join(this.path, relativePath);
1683
1695
  }
1684
1696
 
@@ -2092,6 +2104,25 @@ the following envs are used in this workspace: ${availableEnvs.join(', ')}`);
2092
2104
  async getComponentStatusById(id) {
2093
2105
  return this.componentStatusLoader.getComponentStatusById(id);
2094
2106
  }
2107
+ async setLocalOnly(ids) {
2108
+ const staged = (0, _lodash().compact)(await (0, _pMapSeries().default)(ids, async id => {
2109
+ const componentStatus = await this.getComponentStatusById(id);
2110
+ if (componentStatus.staged) return id;
2111
+ }));
2112
+ if (staged.length) {
2113
+ throw new (_bitError().BitError)(`unable to set the following component(s) as local-only because they have local snaps/tags: ${staged.join(', ')}`);
2114
+ }
2115
+ this.bitMap.setLocalOnly(ids);
2116
+ await this.bitMap.write('setLocalOnly');
2117
+ }
2118
+ async unsetLocalOnly(ids) {
2119
+ const successfullyUnset = this.bitMap.unsetLocalOnly(ids);
2120
+ await this.bitMap.write('unsetLocalOnly');
2121
+ return successfullyUnset;
2122
+ }
2123
+ listLocalOnly() {
2124
+ return _componentId().ComponentIdList.fromArray(this.bitMap.listLocalOnly());
2125
+ }
2095
2126
  }
2096
2127
 
2097
2128
  /**