@teambit/workspace 0.0.637 → 0.0.641

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/bit-map.d.ts CHANGED
@@ -17,7 +17,7 @@ export declare class BitMap {
17
17
  * returns a boolean indicating whether a change has been made.
18
18
  */
19
19
  addComponentConfig(id: ComponentID, aspectId: string, config?: Record<string, any>): boolean;
20
- removeComponentConfig(id: ComponentID, aspectId: string): boolean;
20
+ removeComponentConfig(id: ComponentID, aspectId: string, markWithMinusIfNotExist: boolean): boolean;
21
21
  /**
22
22
  * write .bitmap object to the filesystem
23
23
  */
package/dist/bit-map.js CHANGED
@@ -17,6 +17,16 @@ function _lodash() {
17
17
  return data;
18
18
  }
19
19
 
20
+ function _config() {
21
+ const data = require("@teambit/legacy/dist/consumer/config");
22
+
23
+ _config = function () {
24
+ return data;
25
+ };
26
+
27
+ return data;
28
+ }
29
+
20
30
  /**
21
31
  * consider extracting to a new component.
22
32
  * (pro: making Workspace aspect smaller. con: it's an implementation details of the workspace)
@@ -54,18 +64,23 @@ class BitMap {
54
64
  return true; // changes have been made
55
65
  }
56
66
 
57
- removeComponentConfig(id, aspectId) {
67
+ removeComponentConfig(id, aspectId, markWithMinusIfNotExist) {
58
68
  if (!aspectId || typeof aspectId !== 'string') throw new Error(`expect aspectId to be string, got ${aspectId}`);
59
69
  const bitMapEntry = this.getBitmapEntry(id, {
60
70
  ignoreScopeAndVersion: true
61
71
  });
62
72
  const currentConfig = (bitMapEntry.config || (bitMapEntry.config = {}))[aspectId];
63
73
 
64
- if (!currentConfig) {
65
- return false; // no changes
74
+ if (currentConfig) {
75
+ delete bitMapEntry.config[aspectId];
76
+ } else {
77
+ if (!markWithMinusIfNotExist) {
78
+ return false; // no changes
79
+ }
80
+
81
+ bitMapEntry.config[aspectId] = _config().REMOVE_EXTENSION_SPECIAL_SIGN;
66
82
  }
67
83
 
68
- delete bitMapEntry.config[aspectId];
69
84
  this.legacyBitMap.markAsChanged();
70
85
  return true; // changes have been made
71
86
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["bit-map.ts"],"names":["BitMap","constructor","legacyBitMap","consumer","addComponentConfig","id","aspectId","config","Error","bitMapEntry","getBitmapEntry","ignoreScopeAndVersion","currentConfig","markAsChanged","removeComponentConfig","write","writeBitMap","ignoreVersion","getComponent","_legacy","renameNewComponent","sourceId","targetId","hasVersion","toString","removeComponent","setComponent"],"mappings":";;;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAMA;AACA;AACA;AACA;AACO,MAAMA,MAAN,CAAa;AAClBC,EAAAA,WAAW,CAASC,YAAT,EAA6CC,QAA7C,EAAiE;AAAA,SAAxDD,YAAwD,GAAxDA,YAAwD;AAAA,SAApBC,QAAoB,GAApBA,QAAoB;AAAE;AAE9E;AACF;AACA;AACA;AACA;;;AACEC,EAAAA,kBAAkB,CAACC,EAAD,EAAkBC,QAAlB,EAAoCC,MAA2B,GAAG,EAAlE,EAA+E;AAC/F,QAAI,CAACD,QAAD,IAAa,OAAOA,QAAP,KAAoB,QAArC,EAA+C,MAAM,IAAIE,KAAJ,CAAW,qCAAoCF,QAAS,EAAxD,CAAN;AAC/C,UAAMG,WAAW,GAAG,KAAKC,cAAL,CAAoBL,EAApB,EAAwB;AAAEM,MAAAA,qBAAqB,EAAE;AAAzB,KAAxB,CAApB;AACA,UAAMC,aAAa,GAAG,CAACH,WAAW,CAACF,MAAb,KAACE,WAAW,CAACF,MAAb,GAAwB,EAAxB,GAA4BD,QAA5B,CAAtB;;AACA,QAAI,uBAAQM,aAAR,EAAuBL,MAAvB,CAAJ,EAAoC;AAClC,aAAO,KAAP,CADkC,CACpB;AACf;;AACD,QAAI,CAACA,MAAL,EAAa;AACX,aAAOE,WAAW,CAACF,MAAZ,CAAmBD,QAAnB,CAAP;AACD,KAFD,MAEO;AACLG,MAAAA,WAAW,CAACF,MAAZ,CAAmBD,QAAnB,IAA+BC,MAA/B;AACD;;AACD,SAAKL,YAAL,CAAkBW,aAAlB;AAEA,WAAO,IAAP,CAd+F,CAclF;AACd;;AAEDC,EAAAA,qBAAqB,CAACT,EAAD,EAAkBC,QAAlB,EAA6C;AAChE,QAAI,CAACA,QAAD,IAAa,OAAOA,QAAP,KAAoB,QAArC,EAA+C,MAAM,IAAIE,KAAJ,CAAW,qCAAoCF,QAAS,EAAxD,CAAN;AAC/C,UAAMG,WAAW,GAAG,KAAKC,cAAL,CAAoBL,EAApB,EAAwB;AAAEM,MAAAA,qBAAqB,EAAE;AAAzB,KAAxB,CAApB;AACA,UAAMC,aAAa,GAAG,CAACH,WAAW,CAACF,MAAb,KAACE,WAAW,CAACF,MAAb,GAAwB,EAAxB,GAA4BD,QAA5B,CAAtB;;AACA,QAAI,CAACM,aAAL,EAAoB;AAClB,aAAO,KAAP,CADkB,CACJ;AACf;;AACD,WAAOH,WAAW,CAACF,MAAZ,CAAmBD,QAAnB,CAAP;AACA,SAAKJ,YAAL,CAAkBW,aAAlB;AAEA,WAAO,IAAP,CAVgE,CAUnD;AACd;AAED;AACF;AACA;;;AACa,QAALE,KAAK,GAAG;AACZ,UAAM,KAAKZ,QAAL,CAAca,WAAd,EAAN;AACD;AAED;AACF;AACA;;;AACEN,EAAAA,cAAc,CACZL,EADY,EAEZ;AAAEY,IAAAA,aAAF;AAAiBN,IAAAA;AAAjB,MAAsE,EAF1D,EAGE;AACd,WAAO,KAAKT,YAAL,CAAkBgB,YAAlB,CAA+Bb,EAAE,CAACc,OAAlC,EAA2C;AAAEF,MAAAA,aAAF;AAAiBN,MAAAA;AAAjB,KAA3C,CAAP;AACD;AAED;AACF;AACA;;;AACES,EAAAA,kBAAkB,CAACC,QAAD,EAAwBC,QAAxB,EAA+C;AAC/D,UAAMb,WAAW,GAAG,KAAKC,cAAL,CAAoBW,QAApB,CAApB;;AACA,QAAIZ,WAAW,CAACJ,EAAZ,CAAekB,UAAf,EAAJ,EAAiC;AAC/B,YAAM,IAAIf,KAAJ,CAAW,kDAAiDC,WAAW,CAACJ,EAAZ,CAAemB,QAAf,EAA0B,EAAtF,CAAN;AACD;;AACD,SAAKtB,YAAL,CAAkBuB,eAAlB,CAAkChB,WAAW,CAACJ,EAA9C;AACAI,IAAAA,WAAW,CAACJ,EAAZ,GAAiBiB,QAAQ,CAACH,OAA1B;AACA,SAAKjB,YAAL,CAAkBwB,YAAlB,CAA+BjB,WAAW,CAACJ,EAA3C,EAA+CI,WAA/C;AACD;;AAlEiB","sourcesContent":["import { isEqual } from 'lodash';\nimport { ComponentID } from '@teambit/component-id';\nimport LegacyBitMap from '@teambit/legacy/dist/consumer/bit-map';\nimport { Consumer } from '@teambit/legacy/dist/consumer';\nimport { GetBitMapComponentOptions } from '@teambit/legacy/dist/consumer/bit-map/bit-map';\nimport ComponentMap from '@teambit/legacy/dist/consumer/bit-map/component-map';\n/**\n * consider extracting to a new component.\n * (pro: making Workspace aspect smaller. con: it's an implementation details of the workspace)\n */\nexport class BitMap {\n constructor(private legacyBitMap: LegacyBitMap, private consumer: Consumer) {}\n\n /**\n * adds component config to the .bitmap file.\n * later, upon `bit tag`, the data is saved in the scope.\n * returns a boolean indicating whether a change has been made.\n */\n addComponentConfig(id: ComponentID, aspectId: string, config: Record<string, any> = {}): boolean {\n if (!aspectId || typeof aspectId !== 'string') throw new Error(`expect aspectId to be string, got ${aspectId}`);\n const bitMapEntry = this.getBitmapEntry(id, { ignoreScopeAndVersion: true });\n const currentConfig = (bitMapEntry.config ||= {})[aspectId];\n if (isEqual(currentConfig, config)) {\n return false; // no changes\n }\n if (!config) {\n delete bitMapEntry.config[aspectId];\n } else {\n bitMapEntry.config[aspectId] = config;\n }\n this.legacyBitMap.markAsChanged();\n\n return true; // changes have been made\n }\n\n removeComponentConfig(id: ComponentID, aspectId: string): boolean {\n if (!aspectId || typeof aspectId !== 'string') throw new Error(`expect aspectId to be string, got ${aspectId}`);\n const bitMapEntry = this.getBitmapEntry(id, { ignoreScopeAndVersion: true });\n const currentConfig = (bitMapEntry.config ||= {})[aspectId];\n if (!currentConfig) {\n return false; // no changes\n }\n delete bitMapEntry.config[aspectId];\n this.legacyBitMap.markAsChanged();\n\n return true; // changes have been made\n }\n\n /**\n * write .bitmap object to the filesystem\n */\n async write() {\n await this.consumer.writeBitMap();\n }\n\n /**\n * get the data saved in the .bitmap file for this component-id.\n */\n getBitmapEntry(\n id: ComponentID,\n { ignoreVersion, ignoreScopeAndVersion }: GetBitMapComponentOptions = {}\n ): ComponentMap {\n return this.legacyBitMap.getComponent(id._legacy, { ignoreVersion, ignoreScopeAndVersion });\n }\n\n /**\n * components that were not tagged yet are safe to rename them from the .bitmap file.\n */\n renameNewComponent(sourceId: ComponentID, targetId: ComponentID) {\n const bitMapEntry = this.getBitmapEntry(sourceId);\n if (bitMapEntry.id.hasVersion()) {\n throw new Error(`unable to rename tagged or exported component: ${bitMapEntry.id.toString()}`);\n }\n this.legacyBitMap.removeComponent(bitMapEntry.id);\n bitMapEntry.id = targetId._legacy;\n this.legacyBitMap.setComponent(bitMapEntry.id, bitMapEntry);\n }\n}\n"]}
1
+ {"version":3,"sources":["bit-map.ts"],"names":["BitMap","constructor","legacyBitMap","consumer","addComponentConfig","id","aspectId","config","Error","bitMapEntry","getBitmapEntry","ignoreScopeAndVersion","currentConfig","markAsChanged","removeComponentConfig","markWithMinusIfNotExist","REMOVE_EXTENSION_SPECIAL_SIGN","write","writeBitMap","ignoreVersion","getComponent","_legacy","renameNewComponent","sourceId","targetId","hasVersion","toString","removeComponent","setComponent"],"mappings":"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","sourcesContent":["import { isEqual } from 'lodash';\nimport { ComponentID } from '@teambit/component-id';\nimport LegacyBitMap from '@teambit/legacy/dist/consumer/bit-map';\nimport { Consumer } from '@teambit/legacy/dist/consumer';\nimport { GetBitMapComponentOptions } from '@teambit/legacy/dist/consumer/bit-map/bit-map';\nimport ComponentMap from '@teambit/legacy/dist/consumer/bit-map/component-map';\nimport { REMOVE_EXTENSION_SPECIAL_SIGN } from '@teambit/legacy/dist/consumer/config';\n/**\n * consider extracting to a new component.\n * (pro: making Workspace aspect smaller. con: it's an implementation details of the workspace)\n */\nexport class BitMap {\n constructor(private legacyBitMap: LegacyBitMap, private consumer: Consumer) {}\n\n /**\n * adds component config to the .bitmap file.\n * later, upon `bit tag`, the data is saved in the scope.\n * returns a boolean indicating whether a change has been made.\n */\n addComponentConfig(id: ComponentID, aspectId: string, config: Record<string, any> = {}): boolean {\n if (!aspectId || typeof aspectId !== 'string') throw new Error(`expect aspectId to be string, got ${aspectId}`);\n const bitMapEntry = this.getBitmapEntry(id, { ignoreScopeAndVersion: true });\n const currentConfig = (bitMapEntry.config ||= {})[aspectId];\n if (isEqual(currentConfig, config)) {\n return false; // no changes\n }\n if (!config) {\n delete bitMapEntry.config[aspectId];\n } else {\n bitMapEntry.config[aspectId] = config;\n }\n this.legacyBitMap.markAsChanged();\n\n return true; // changes have been made\n }\n\n removeComponentConfig(id: ComponentID, aspectId: string, markWithMinusIfNotExist: boolean): boolean {\n if (!aspectId || typeof aspectId !== 'string') throw new Error(`expect aspectId to be string, got ${aspectId}`);\n const bitMapEntry = this.getBitmapEntry(id, { ignoreScopeAndVersion: true });\n const currentConfig = (bitMapEntry.config ||= {})[aspectId];\n if (currentConfig) {\n delete bitMapEntry.config[aspectId];\n } else {\n if (!markWithMinusIfNotExist) {\n return false; // no changes\n }\n bitMapEntry.config[aspectId] = REMOVE_EXTENSION_SPECIAL_SIGN;\n }\n\n this.legacyBitMap.markAsChanged();\n\n return true; // changes have been made\n }\n\n /**\n * write .bitmap object to the filesystem\n */\n async write() {\n await this.consumer.writeBitMap();\n }\n\n /**\n * get the data saved in the .bitmap file for this component-id.\n */\n getBitmapEntry(\n id: ComponentID,\n { ignoreVersion, ignoreScopeAndVersion }: GetBitMapComponentOptions = {}\n ): ComponentMap {\n return this.legacyBitMap.getComponent(id._legacy, { ignoreVersion, ignoreScopeAndVersion });\n }\n\n /**\n * components that were not tagged yet are safe to rename them from the .bitmap file.\n */\n renameNewComponent(sourceId: ComponentID, targetId: ComponentID) {\n const bitMapEntry = this.getBitmapEntry(sourceId);\n if (bitMapEntry.id.hasVersion()) {\n throw new Error(`unable to rename tagged or exported component: ${bitMapEntry.id.toString()}`);\n }\n this.legacyBitMap.removeComponent(bitMapEntry.id);\n bitMapEntry.id = targetId._legacy;\n this.legacyBitMap.setComponent(bitMapEntry.id, bitMapEntry);\n }\n}\n"]}
@@ -6,6 +6,7 @@ export declare class EnvsSetCmd implements Command {
6
6
  description: string;
7
7
  options: never[];
8
8
  group: string;
9
+ extendedDescription: string;
9
10
  constructor(workspace: Workspace);
10
11
  report([pattern, env]: [string, string]): Promise<string>;
11
12
  }
@@ -31,21 +31,33 @@ function _chalk() {
31
31
  return data;
32
32
  }
33
33
 
34
+ function _constants() {
35
+ const data = require("@teambit/legacy/dist/constants");
36
+
37
+ _constants = function () {
38
+ return data;
39
+ };
40
+
41
+ return data;
42
+ }
43
+
34
44
  class EnvsSetCmd {
35
45
  constructor(workspace) {
36
46
  this.workspace = workspace;
37
47
  (0, _defineProperty2().default)(this, "name", 'set <pattern> <env>');
38
- (0, _defineProperty2().default)(this, "description", 'set an environment to component(s)');
48
+ (0, _defineProperty2().default)(this, "description", 'set an environment for component(s)');
39
49
  (0, _defineProperty2().default)(this, "options", []);
40
50
  (0, _defineProperty2().default)(this, "group", 'development');
51
+ (0, _defineProperty2().default)(this, "extendedDescription", `${(0, _constants().PATTERN_HELP)('env set')}`);
41
52
  }
42
53
 
43
54
  async report([pattern, env]) {
44
55
  const envId = await this.workspace.resolveComponentId(env);
45
- const components = await this.workspace.byPattern(pattern);
46
- await this.workspace.setEnvToComponents(envId, components);
56
+ const componentIds = await this.workspace.idsByPattern(pattern);
57
+ if (!componentIds.length) return _chalk().default.yellow(`unable to find any matching for ${_chalk().default.bold(pattern)} pattern`);
58
+ await this.workspace.setEnvToComponents(envId, componentIds);
47
59
  return `added ${_chalk().default.bold(envId.toString())} env to the following component(s):
48
- ${components.map(comp => comp.id.toString()).join('\n')}`;
60
+ ${componentIds.map(compId => compId.toString()).join('\n')}`;
49
61
  }
50
62
 
51
63
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["envs-set.cmd.ts"],"names":["EnvsSetCmd","constructor","workspace","report","pattern","env","envId","resolveComponentId","components","byPattern","setEnvToComponents","chalk","bold","toString","map","comp","id","join"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAGO,MAAMA,UAAN,CAAoC;AAMzCC,EAAAA,WAAW,CAASC,SAAT,EAA+B;AAAA,SAAtBA,SAAsB,GAAtBA,SAAsB;AAAA,kDALnC,qBAKmC;AAAA,yDAJ5B,oCAI4B;AAAA,qDAHhC,EAGgC;AAAA,mDAFlC,aAEkC;AAAE;;AAEhC,QAANC,MAAM,CAAC,CAACC,OAAD,EAAUC,GAAV,CAAD,EAAmC;AAC7C,UAAMC,KAAK,GAAG,MAAM,KAAKJ,SAAL,CAAeK,kBAAf,CAAkCF,GAAlC,CAApB;AACA,UAAMG,UAAU,GAAG,MAAM,KAAKN,SAAL,CAAeO,SAAf,CAAyBL,OAAzB,CAAzB;AACA,UAAM,KAAKF,SAAL,CAAeQ,kBAAf,CAAkCJ,KAAlC,EAAyCE,UAAzC,CAAN;AACA,WAAQ,SAAQG,iBAAMC,IAAN,CAAWN,KAAK,CAACO,QAAN,EAAX,CAA6B;AACjD,EAAEL,UAAU,CAACM,GAAX,CAAgBC,IAAD,IAAUA,IAAI,CAACC,EAAL,CAAQH,QAAR,EAAzB,EAA6CI,IAA7C,CAAkD,IAAlD,CAAwD,EADtD;AAED;;AAdwC","sourcesContent":["import { Command } from '@teambit/cli';\nimport chalk from 'chalk';\nimport { Workspace } from '../workspace';\n\nexport class EnvsSetCmd implements Command {\n name = 'set <pattern> <env>';\n description = 'set an environment to component(s)';\n options = [];\n group = 'development';\n\n constructor(private workspace: Workspace) {}\n\n async report([pattern, env]: [string, string]) {\n const envId = await this.workspace.resolveComponentId(env);\n const components = await this.workspace.byPattern(pattern);\n await this.workspace.setEnvToComponents(envId, components);\n return `added ${chalk.bold(envId.toString())} env to the following component(s):\n${components.map((comp) => comp.id.toString()).join('\\n')}`;\n }\n}\n"]}
1
+ {"version":3,"sources":["envs-set.cmd.ts"],"names":["EnvsSetCmd","constructor","workspace","report","pattern","env","envId","resolveComponentId","componentIds","idsByPattern","length","chalk","yellow","bold","setEnvToComponents","toString","map","compId","join"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAGO,MAAMA,UAAN,CAAoC;AAOzCC,EAAAA,WAAW,CAASC,SAAT,EAA+B;AAAA,SAAtBA,SAAsB,GAAtBA,SAAsB;AAAA,kDANnC,qBAMmC;AAAA,yDAL5B,qCAK4B;AAAA,qDAJhC,EAIgC;AAAA,mDAHlC,aAGkC;AAAA,iEAFnB,GAAE,+BAAa,SAAb,CAAwB,EAEP;AAAE;;AAEhC,QAANC,MAAM,CAAC,CAACC,OAAD,EAAUC,GAAV,CAAD,EAAmC;AAC7C,UAAMC,KAAK,GAAG,MAAM,KAAKJ,SAAL,CAAeK,kBAAf,CAAkCF,GAAlC,CAApB;AACA,UAAMG,YAAY,GAAG,MAAM,KAAKN,SAAL,CAAeO,YAAf,CAA4BL,OAA5B,CAA3B;AACA,QAAI,CAACI,YAAY,CAACE,MAAlB,EAA0B,OAAOC,iBAAMC,MAAN,CAAc,mCAAkCD,iBAAME,IAAN,CAAWT,OAAX,CAAoB,UAApE,CAAP;AAC1B,UAAM,KAAKF,SAAL,CAAeY,kBAAf,CAAkCR,KAAlC,EAAyCE,YAAzC,CAAN;AACA,WAAQ,SAAQG,iBAAME,IAAN,CAAWP,KAAK,CAACS,QAAN,EAAX,CAA6B;AACjD,EAAEP,YAAY,CAACQ,GAAb,CAAkBC,MAAD,IAAYA,MAAM,CAACF,QAAP,EAA7B,EAAgDG,IAAhD,CAAqD,IAArD,CAA2D,EADzD;AAED;;AAhBwC","sourcesContent":["import { Command } from '@teambit/cli';\nimport chalk from 'chalk';\nimport { PATTERN_HELP } from '@teambit/legacy/dist/constants';\nimport { Workspace } from '../workspace';\n\nexport class EnvsSetCmd implements Command {\n name = 'set <pattern> <env>';\n description = 'set an environment for component(s)';\n options = [];\n group = 'development';\n extendedDescription = `${PATTERN_HELP('env set')}`;\n\n constructor(private workspace: Workspace) {}\n\n async report([pattern, env]: [string, string]) {\n const envId = await this.workspace.resolveComponentId(env);\n const componentIds = await this.workspace.idsByPattern(pattern);\n if (!componentIds.length) return chalk.yellow(`unable to find any matching for ${chalk.bold(pattern)} pattern`);\n await this.workspace.setEnvToComponents(envId, componentIds);\n return `added ${chalk.bold(envId.toString())} env to the following component(s):\n${componentIds.map((compId) => compId.toString()).join('\\n')}`;\n }\n}\n"]}
@@ -6,6 +6,7 @@ export declare class EnvsUnsetCmd implements Command {
6
6
  description: string;
7
7
  options: never[];
8
8
  group: string;
9
+ extendedDescription: string;
9
10
  constructor(workspace: Workspace);
10
11
  report([pattern]: [string]): Promise<string>;
11
12
  }
@@ -21,20 +21,31 @@ function _defineProperty2() {
21
21
  return data;
22
22
  }
23
23
 
24
+ function _constants() {
25
+ const data = require("@teambit/legacy/dist/constants");
26
+
27
+ _constants = function () {
28
+ return data;
29
+ };
30
+
31
+ return data;
32
+ }
33
+
24
34
  class EnvsUnsetCmd {
25
35
  constructor(workspace) {
26
36
  this.workspace = workspace;
27
- (0, _defineProperty2().default)(this, "name", 'unset <pattern>');
37
+ (0, _defineProperty2().default)(this, "name", 'unset <component>');
28
38
  (0, _defineProperty2().default)(this, "description", 'unset an environment from component(s)');
29
39
  (0, _defineProperty2().default)(this, "options", []);
30
40
  (0, _defineProperty2().default)(this, "group", 'development');
41
+ (0, _defineProperty2().default)(this, "extendedDescription", `${(0, _constants().PATTERN_HELP)('env unset')}`);
31
42
  }
32
43
 
33
44
  async report([pattern]) {
34
- const components = await this.workspace.byPattern(pattern);
45
+ const componentIds = await this.workspace.idsByPattern(pattern);
35
46
  const {
36
47
  changed
37
- } = await this.workspace.unsetEnvFromComponents(components);
48
+ } = await this.workspace.unsetEnvFromComponents(componentIds);
38
49
  return `successfully removed env from the following component(s):
39
50
  ${changed.map(id => id.toString()).join('\n')}`;
40
51
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["envs-unset.cmd.ts"],"names":["EnvsUnsetCmd","constructor","workspace","report","pattern","components","byPattern","changed","unsetEnvFromComponents","map","id","toString","join"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAGO,MAAMA,YAAN,CAAsC;AAM3CC,EAAAA,WAAW,CAASC,SAAT,EAA+B;AAAA,SAAtBA,SAAsB,GAAtBA,SAAsB;AAAA,kDALnC,iBAKmC;AAAA,yDAJ5B,wCAI4B;AAAA,qDAHhC,EAGgC;AAAA,mDAFlC,aAEkC;AAAE;;AAEhC,QAANC,MAAM,CAAC,CAACC,OAAD,CAAD,EAAsB;AAChC,UAAMC,UAAU,GAAG,MAAM,KAAKH,SAAL,CAAeI,SAAf,CAAyBF,OAAzB,CAAzB;AACA,UAAM;AAAEG,MAAAA;AAAF,QAAc,MAAM,KAAKL,SAAL,CAAeM,sBAAf,CAAsCH,UAAtC,CAA1B;AACA,WAAQ;AACZ,EAAEE,OAAO,CAACE,GAAR,CAAaC,EAAD,IAAQA,EAAE,CAACC,QAAH,EAApB,EAAmCC,IAAnC,CAAwC,IAAxC,CAA8C,EAD5C;AAED;;AAb0C","sourcesContent":["import { Command } from '@teambit/cli';\nimport { Workspace } from '../workspace';\n\nexport class EnvsUnsetCmd implements Command {\n name = 'unset <pattern>';\n description = 'unset an environment from component(s)';\n options = [];\n group = 'development';\n\n constructor(private workspace: Workspace) {}\n\n async report([pattern]: [string]) {\n const components = await this.workspace.byPattern(pattern);\n const { changed } = await this.workspace.unsetEnvFromComponents(components);\n return `successfully removed env from the following component(s):\n${changed.map((id) => id.toString()).join('\\n')}`;\n }\n}\n"]}
1
+ {"version":3,"sources":["envs-unset.cmd.ts"],"names":["EnvsUnsetCmd","constructor","workspace","report","pattern","componentIds","idsByPattern","changed","unsetEnvFromComponents","map","id","toString","join"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAGO,MAAMA,YAAN,CAAsC;AAO3CC,EAAAA,WAAW,CAASC,SAAT,EAA+B;AAAA,SAAtBA,SAAsB,GAAtBA,SAAsB;AAAA,kDANnC,mBAMmC;AAAA,yDAL5B,wCAK4B;AAAA,qDAJhC,EAIgC;AAAA,mDAHlC,aAGkC;AAAA,iEAFnB,GAAE,+BAAa,WAAb,CAA0B,EAET;AAAE;;AAEhC,QAANC,MAAM,CAAC,CAACC,OAAD,CAAD,EAAsB;AAChC,UAAMC,YAAY,GAAG,MAAM,KAAKH,SAAL,CAAeI,YAAf,CAA4BF,OAA5B,CAA3B;AACA,UAAM;AAAEG,MAAAA;AAAF,QAAc,MAAM,KAAKL,SAAL,CAAeM,sBAAf,CAAsCH,YAAtC,CAA1B;AACA,WAAQ;AACZ,EAAEE,OAAO,CAACE,GAAR,CAAaC,EAAD,IAAQA,EAAE,CAACC,QAAH,EAApB,EAAmCC,IAAnC,CAAwC,IAAxC,CAA8C,EAD5C;AAED;;AAd0C","sourcesContent":["import { Command } from '@teambit/cli';\nimport { PATTERN_HELP } from '@teambit/legacy/dist/constants';\nimport { Workspace } from '../workspace';\n\nexport class EnvsUnsetCmd implements Command {\n name = 'unset <component>';\n description = 'unset an environment from component(s)';\n options = [];\n group = 'development';\n extendedDescription = `${PATTERN_HELP('env unset')}`;\n\n constructor(private workspace: Workspace) {}\n\n async report([pattern]: [string]) {\n const componentIds = await this.workspace.idsByPattern(pattern);\n const { changed } = await this.workspace.unsetEnvFromComponents(componentIds);\n return `successfully removed env from the following component(s):\n${changed.map((id) => id.toString()).join('\\n')}`;\n }\n}\n"]}
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { WorkspaceAspect } from './workspace.aspect';
2
- export type { default as Workspace } from './workspace';
2
+ export type { default as Workspace, ExtensionsOrigin } from './workspace';
3
3
  export type { ResolvedComponent } from '@teambit/harmony.modules.resolved-component';
4
4
  export type { AlreadyExistsError as ComponentConfigFileAlreadyExistsError } from './component-config-file';
5
5
  export type { WorkspaceMain } from './workspace.main.runtime';
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["index.ts"],"names":["WorkspaceAspect"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAQA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAGA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;eAIeA,4B","sourcesContent":["import { WorkspaceAspect } from './workspace.aspect';\n// eslint-disable-next-line import/prefer-default-export\nexport type { default as Workspace } from './workspace';\n// TODO: change to module path once track the utils folder\nexport type { ResolvedComponent } from '@teambit/harmony.modules.resolved-component';\nexport type { AlreadyExistsError as ComponentConfigFileAlreadyExistsError } from './component-config-file';\nexport type { WorkspaceMain } from './workspace.main.runtime';\nexport type { WatchOptions } from './watch/watcher';\nexport { CheckTypes } from './watch/check-types';\nexport * from './events';\nexport type { WorkspaceUI } from './workspace.ui.runtime';\nexport type { SerializableResults, OnComponentEventResult } from './on-component-events';\nexport { ComponentStatus } from './workspace-component';\nexport { WorkspaceModelComponent } from './ui/workspace/workspace-model';\nexport { WorkspaceContext } from './ui/workspace/workspace-context';\nexport type { WorkspaceComponent } from './workspace-component';\n\nexport { WorkspaceAspect };\nexport default WorkspaceAspect;\n"]}
1
+ {"version":3,"sources":["index.ts"],"names":["WorkspaceAspect"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAQA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAGA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;eAIeA,4B","sourcesContent":["import { WorkspaceAspect } from './workspace.aspect';\n// eslint-disable-next-line import/prefer-default-export\nexport type { default as Workspace, ExtensionsOrigin } from './workspace';\n// TODO: change to module path once track the utils folder\nexport type { ResolvedComponent } from '@teambit/harmony.modules.resolved-component';\nexport type { AlreadyExistsError as ComponentConfigFileAlreadyExistsError } from './component-config-file';\nexport type { WorkspaceMain } from './workspace.main.runtime';\nexport type { WatchOptions } from './watch/watcher';\nexport { CheckTypes } from './watch/check-types';\nexport * from './events';\nexport type { WorkspaceUI } from './workspace.ui.runtime';\nexport type { SerializableResults, OnComponentEventResult } from './on-component-events';\nexport { ComponentStatus } from './workspace-component';\nexport { WorkspaceModelComponent } from './ui/workspace/workspace-model';\nexport { WorkspaceContext } from './ui/workspace/workspace-context';\nexport type { WorkspaceComponent } from './workspace-component';\n\nexport { WorkspaceAspect };\nexport default WorkspaceAspect;\n"]}
@@ -0,0 +1,14 @@
1
+ import { Command, CommandOptions } from '@teambit/cli';
2
+ import { Workspace } from './workspace';
3
+ export declare class PatternCommand implements Command {
4
+ private workspace;
5
+ name: string;
6
+ alias: string;
7
+ description: string;
8
+ group: string;
9
+ private: boolean;
10
+ options: CommandOptions;
11
+ constructor(workspace: Workspace);
12
+ report([pattern]: [string]): Promise<string>;
13
+ json([pattern]: [string]): Promise<import("@teambit/component-id").ComponentID[]>;
14
+ }
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ require("core-js/modules/es.array.iterator.js");
6
+
7
+ require("core-js/modules/es.promise.js");
8
+
9
+ Object.defineProperty(exports, "__esModule", {
10
+ value: true
11
+ });
12
+ exports.PatternCommand = void 0;
13
+
14
+ function _defineProperty2() {
15
+ const data = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
16
+
17
+ _defineProperty2 = function () {
18
+ return data;
19
+ };
20
+
21
+ return data;
22
+ }
23
+
24
+ function _chalk() {
25
+ const data = _interopRequireDefault(require("chalk"));
26
+
27
+ _chalk = function () {
28
+ return data;
29
+ };
30
+
31
+ return data;
32
+ }
33
+
34
+ class PatternCommand {
35
+ constructor(workspace) {
36
+ this.workspace = workspace;
37
+ (0, _defineProperty2().default)(this, "name", 'pattern <pattern>');
38
+ (0, _defineProperty2().default)(this, "alias", '');
39
+ (0, _defineProperty2().default)(this, "description", 'list the component ids matching the given pattern');
40
+ (0, _defineProperty2().default)(this, "group", 'development');
41
+ (0, _defineProperty2().default)(this, "private", false);
42
+ (0, _defineProperty2().default)(this, "options", [['j', 'json', 'return the output as JSON']]);
43
+ }
44
+
45
+ async report([pattern]) {
46
+ const ids = await this.workspace.idsByPattern(pattern);
47
+
48
+ const title = _chalk().default.green(`found ${_chalk().default.bold(ids.length.toString())} components matching the pattern`);
49
+
50
+ return `${title}\n${ids.join('\n')}`;
51
+ }
52
+
53
+ async json([pattern]) {
54
+ return this.workspace.idsByPattern(pattern);
55
+ }
56
+
57
+ }
58
+
59
+ exports.PatternCommand = PatternCommand;
60
+
61
+ //# sourceMappingURL=pattern.cmd.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["pattern.cmd.ts"],"names":["PatternCommand","constructor","workspace","report","pattern","ids","idsByPattern","title","chalk","green","bold","length","toString","join","json"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAGO,MAAMA,cAAN,CAAwC;AAQ7CC,EAAAA,WAAW,CAASC,SAAT,EAA+B;AAAA,SAAtBA,SAAsB,GAAtBA,SAAsB;AAAA,kDAPnC,mBAOmC;AAAA,mDANlC,EAMkC;AAAA,yDAL5B,mDAK4B;AAAA,mDAJlC,aAIkC;AAAA,qDAHhC,KAGgC;AAAA,qDAFhC,CAAC,CAAC,GAAD,EAAM,MAAN,EAAc,2BAAd,CAAD,CAEgC;AAAE;;AAEhC,QAANC,MAAM,CAAC,CAACC,OAAD,CAAD,EAAsB;AAChC,UAAMC,GAAG,GAAG,MAAM,KAAKH,SAAL,CAAeI,YAAf,CAA4BF,OAA5B,CAAlB;;AACA,UAAMG,KAAK,GAAGC,iBAAMC,KAAN,CAAa,SAAQD,iBAAME,IAAN,CAAWL,GAAG,CAACM,MAAJ,CAAWC,QAAX,EAAX,CAAkC,kCAAvD,CAAd;;AACA,WAAQ,GAAEL,KAAM,KAAIF,GAAG,CAACQ,IAAJ,CAAS,IAAT,CAAe,EAAnC;AACD;;AAES,QAAJC,IAAI,CAAC,CAACV,OAAD,CAAD,EAAsB;AAC9B,WAAO,KAAKF,SAAL,CAAeI,YAAf,CAA4BF,OAA5B,CAAP;AACD;;AAlB4C","sourcesContent":["import { Command, CommandOptions } from '@teambit/cli';\nimport chalk from 'chalk';\nimport { Workspace } from './workspace';\n\nexport class PatternCommand implements Command {\n name = 'pattern <pattern>';\n alias = '';\n description = 'list the component ids matching the given pattern';\n group = 'development';\n private = false;\n options = [['j', 'json', 'return the output as JSON']] as CommandOptions;\n\n constructor(private workspace: Workspace) {}\n\n async report([pattern]: [string]) {\n const ids = await this.workspace.idsByPattern(pattern);\n const title = chalk.green(`found ${chalk.bold(ids.length.toString())} components matching the pattern`);\n return `${title}\\n${ids.join('\\n')}`;\n }\n\n async json([pattern]: [string]) {\n return this.workspace.idsByPattern(pattern);\n }\n}\n"]}
@@ -38,6 +38,7 @@ import { BitMap } from './bit-map';
38
38
  export declare type EjectConfResult = {
39
39
  configPath: string;
40
40
  };
41
+ export declare const AspectSpecificField = "__specific";
41
42
  export declare const ComponentAdded = "componentAdded";
42
43
  export declare const ComponentChanged = "componentChanged";
43
44
  export declare const ComponentRemoved = "componentRemoved";
@@ -67,7 +68,7 @@ export declare type TrackData = {
67
68
  [aspectName: string]: any;
68
69
  };
69
70
  };
70
- export declare type ExtensionsOrigin = 'BitmapFile' | 'Model' | 'WorkspaceVariants' | 'ComponentJsonFile' | 'WorkspaceDefault' | 'FinalAfterMerge';
71
+ export declare type ExtensionsOrigin = 'BitmapFile' | 'ModelSpecific' | 'ModelNonSpecific' | 'WorkspaceVariants' | 'ComponentJsonFile' | 'WorkspaceDefault' | 'FinalAfterMerge';
71
72
  export declare type TrackResult = {
72
73
  componentName: string;
73
74
  files: string[];
@@ -280,6 +281,11 @@ export declare class Workspace implements ComponentFactory {
280
281
  * @param scope scope name.
281
282
  */
282
283
  byPattern(pattern: string, scope?: string): Promise<Component[]>;
284
+ /**
285
+ * get component-ids matching the given pattern. a pattern can have multiple patterns separated by a comma.
286
+ * it supports negate (!) character to exclude ids.
287
+ */
288
+ idsByPattern(pattern: string): Promise<ComponentID[]>;
283
289
  /**
284
290
  * useful for workspace commands, such as `bit build`, `bit compile`.
285
291
  * by default, it should be running on new and modified components.
@@ -495,11 +501,11 @@ export declare class Workspace implements ComponentFactory {
495
501
  * configure an environment to the given components in the .bitmap file, this configuration overrides other, such as
496
502
  * overrides in workspace.jsonc.
497
503
  */
498
- setEnvToComponents(envId: ComponentID, components: Component[]): Promise<void>;
504
+ setEnvToComponents(envId: ComponentID, componentIds: ComponentID[]): Promise<void>;
499
505
  /**
500
506
  * remove env configuration from the .bitmap file, so then other configuration, such as "variants" will take place
501
507
  */
502
- unsetEnvFromComponents(components: Component[]): Promise<{
508
+ unsetEnvFromComponents(ids: ComponentID[]): Promise<{
503
509
  changed: ComponentID[];
504
510
  unchanged: ComponentID[];
505
511
  }>;
package/dist/workspace.js CHANGED
@@ -14,10 +14,12 @@ require("core-js/modules/es.promise.js");
14
14
 
15
15
  require("core-js/modules/es.regexp.exec.js");
16
16
 
17
+ require("core-js/modules/es.string.trim.js");
18
+
17
19
  Object.defineProperty(exports, "__esModule", {
18
20
  value: true
19
21
  });
20
- exports.default = exports.Workspace = exports.ComponentRemoved = exports.ComponentChanged = exports.ComponentAdded = void 0;
22
+ exports.default = exports.Workspace = exports.ComponentRemoved = exports.ComponentChanged = exports.ComponentAdded = exports.AspectSpecificField = void 0;
21
23
 
22
24
  function _defineProperty2() {
23
25
  const data = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
@@ -59,6 +61,16 @@ function _pMapSeries() {
59
61
  return data;
60
62
  }
61
63
 
64
+ function _multimatch() {
65
+ const data = _interopRequireDefault(require("multimatch"));
66
+
67
+ _multimatch = function () {
68
+ return data;
69
+ };
70
+
71
+ return data;
72
+ }
73
+
62
74
  function _aspectLoader() {
63
75
  const data = require("@teambit/aspect-loader");
64
76
 
@@ -119,6 +131,16 @@ function _bitError() {
119
131
  return data;
120
132
  }
121
133
 
134
+ function _config() {
135
+ const data = require("@teambit/legacy/dist/consumer/config");
136
+
137
+ _config = function () {
138
+ return data;
139
+ };
140
+
141
+ return data;
142
+ }
143
+
122
144
  function _dependencyResolver() {
123
145
  const data = require("@teambit/dependency-resolver");
124
146
 
@@ -490,6 +512,8 @@ function _bitMap() {
490
512
  }
491
513
 
492
514
  /* eslint-disable max-lines */
515
+ const AspectSpecificField = '__specific';
516
+ exports.AspectSpecificField = AspectSpecificField;
493
517
  const ComponentAdded = 'componentAdded';
494
518
  exports.ComponentAdded = ComponentAdded;
495
519
  const ComponentChanged = 'componentChanged';
@@ -1081,6 +1105,20 @@ class Workspace {
1081
1105
  const components = await this.getMany(targetIds);
1082
1106
  return components;
1083
1107
  }
1108
+ /**
1109
+ * get component-ids matching the given pattern. a pattern can have multiple patterns separated by a comma.
1110
+ * it supports negate (!) character to exclude ids.
1111
+ */
1112
+
1113
+
1114
+ async idsByPattern(pattern) {
1115
+ const ids = await this.listIds();
1116
+ const patterns = pattern.split(',').map(p => p.trim()); // check also as legacyId.toString, as it doesn't have the defaultScope
1117
+
1118
+ const idsToCheck = id => [id.toStringWithoutVersion(), id._legacy.toStringWithoutVersion()];
1119
+
1120
+ return ids.filter(id => (0, _multimatch().default)(idsToCheck(id), patterns).length);
1121
+ }
1084
1122
  /**
1085
1123
  * useful for workspace commands, such as `bit build`, `bit compile`.
1086
1124
  * by default, it should be running on new and modified components.
@@ -1355,6 +1393,9 @@ class Workspace {
1355
1393
  let wsDefaultExtensions;
1356
1394
  const mergeFromScope = true;
1357
1395
  const scopeExtensions = (componentFromScope === null || componentFromScope === void 0 ? void 0 : (_componentFromScope$c = componentFromScope.config) === null || _componentFromScope$c === void 0 ? void 0 : _componentFromScope$c.extensions) || new (_extensionData().ExtensionDataList)();
1396
+ const [specific, nonSpecific] = (0, _lodash().partition)(scopeExtensions, entry => entry.config[AspectSpecificField] === true);
1397
+ const scopeExtensionsNonSpecific = new (_extensionData().ExtensionDataList)(...nonSpecific);
1398
+ const scopeExtensionsSpecific = new (_extensionData().ExtensionDataList)(...specific);
1358
1399
  const bitMapEntry = this.consumer.bitMap.getComponentIfExist(componentId._legacy);
1359
1400
  const bitMapExtensions = bitMapEntry === null || bitMapEntry === void 0 ? void 0 : bitMapEntry.config;
1360
1401
  const componentConfigFile = await this.componentConfigFile(componentId);
@@ -1388,12 +1429,14 @@ class Workspace {
1388
1429
 
1389
1430
  const extensionsToMerge = [];
1390
1431
  let envWasFoundPreviously = false;
1432
+ const removedExtensionIds = [];
1391
1433
 
1392
1434
  const addAndLoadExtensions = async (extensions, origin, extraData) => {
1393
1435
  if (!extensions.length) {
1394
1436
  return;
1395
1437
  }
1396
1438
 
1439
+ removedExtensionIds.push(...extensions.filter(extData => extData.isRemoved).map(extData => extData.stringId));
1397
1440
  const extsWithoutRemoved = extensions.filterRemovedExtensions();
1398
1441
  const selfInMergedExtensions = extsWithoutRemoved.findExtension(componentId._legacy.toStringWithoutScopeAndVersion(), true, true);
1399
1442
  const extsWithoutSelf = selfInMergedExtensions !== null && selfInMergedExtensions !== void 0 && selfInMergedExtensions.extensionId ? extsWithoutRemoved.remove(selfInMergedExtensions.extensionId) : extsWithoutRemoved;
@@ -1410,16 +1453,23 @@ class Workspace {
1410
1453
  });
1411
1454
  };
1412
1455
 
1456
+ const setDataListAsSpecific = extensions => {
1457
+ extensions.forEach(dataEntry => dataEntry.config[AspectSpecificField] = true);
1458
+ };
1459
+
1413
1460
  if (bitMapExtensions) {
1414
- const extensionsDataEntries = Object.keys(bitMapExtensions).map(aspectId => new (_extensionData().ExtensionDataEntry)(aspectId, undefined, aspectId, bitMapExtensions[aspectId]));
1415
- const extensionDataList = new (_extensionData().ExtensionDataList)(...extensionsDataEntries);
1461
+ const extensionDataList = _extensionData().ExtensionDataList.fromConfigObject(bitMapExtensions);
1462
+
1463
+ setDataListAsSpecific(extensionDataList);
1416
1464
  await addAndLoadExtensions(extensionDataList, 'BitmapFile');
1417
1465
  }
1418
1466
 
1419
1467
  if (configFileExtensions) {
1468
+ setDataListAsSpecific(configFileExtensions);
1420
1469
  await addAndLoadExtensions(configFileExtensions, 'ComponentJsonFile');
1421
1470
  }
1422
1471
 
1472
+ await addAndLoadExtensions(scopeExtensionsSpecific, 'ModelSpecific');
1423
1473
  let continuePropagating = (_componentConfigFile$ = componentConfigFile === null || componentConfigFile === void 0 ? void 0 : componentConfigFile.propagate) !== null && _componentConfigFile$ !== void 0 ? _componentConfigFile$ : true;
1424
1474
 
1425
1475
  if (variantsExtensions && continuePropagating) {
@@ -1448,14 +1498,21 @@ class Workspace {
1448
1498
 
1449
1499
 
1450
1500
  if (mergeFromScope && continuePropagating) {
1451
- await addAndLoadExtensions(scopeExtensions, 'Model');
1501
+ await addAndLoadExtensions(scopeExtensionsNonSpecific, 'ModelNonSpecific');
1452
1502
  } // It's important to do this resolution before the merge, otherwise we have issues with extensions
1453
1503
  // coming from scope with local scope name, as opposed to the same extension comes from the workspace with default scope name
1454
1504
 
1455
1505
 
1456
1506
  await Promise.all(extensionsToMerge.map(list => this.resolveExtensionListIds(list.extensions)));
1507
+
1508
+ const afterMerge = _extensionData().ExtensionDataList.mergeConfigs(extensionsToMerge.map(ext => ext.extensions));
1509
+
1510
+ const withoutRemoved = afterMerge.filter(extData => !removedExtensionIds.includes(extData.stringId));
1511
+
1512
+ const extensions = _extensionData().ExtensionDataList.fromArray(withoutRemoved);
1513
+
1457
1514
  return {
1458
- extensions: _extensionData().ExtensionDataList.mergeConfigs(extensionsToMerge.map(ext => ext.extensions)),
1515
+ extensions,
1459
1516
  beforeMerge: extensionsToMerge
1460
1517
  };
1461
1518
  }
@@ -1858,8 +1915,13 @@ class Workspace {
1858
1915
  overrides: this.dependencyResolver.config.overrides
1859
1916
  };
1860
1917
  const missingPeers = await this.dependencyResolver.getMissingPeerDependencies(this.path, mergedRootPolicy, compDirMap, pmInstallOptions);
1861
- const missingPeerPackages = Object.entries(missingPeers).map(([peerName, range]) => `${peerName}@${range}`);
1862
- await this._addPackages(missingPeerPackages, options);
1918
+
1919
+ if (missingPeers) {
1920
+ const missingPeerPackages = Object.entries(missingPeers).map(([peerName, range]) => `${peerName}@${range}`);
1921
+ await this._addPackages(missingPeerPackages, options);
1922
+ } else {
1923
+ this.logger.console('No missing peer dependencies found.');
1924
+ }
1863
1925
  }
1864
1926
 
1865
1927
  if (options !== null && options !== void 0 && options.import) {
@@ -2388,12 +2450,14 @@ your workspace.jsonc has this component-id set. you might want to remove/change
2388
2450
  */
2389
2451
 
2390
2452
 
2391
- async setEnvToComponents(envId, components) {
2453
+ async setEnvToComponents(envId, componentIds) {
2392
2454
  const envIdStr = envId.toString();
2393
- components.forEach(component => {
2394
- this.bitMap.addComponentConfig(component.id, envIdStr);
2395
- this.bitMap.addComponentConfig(component.id, _envs().EnvsAspect.id, {
2396
- env: envIdStr
2455
+ const existsOnWorkspace = await this.hasId(envId);
2456
+ const envIdStrNoVersion = envId.toStringWithoutVersion();
2457
+ componentIds.forEach(componentId => {
2458
+ this.bitMap.addComponentConfig(componentId, existsOnWorkspace ? envIdStrNoVersion : envIdStr);
2459
+ this.bitMap.addComponentConfig(componentId, _envs().EnvsAspect.id, {
2460
+ env: envIdStrNoVersion
2397
2461
  });
2398
2462
  });
2399
2463
  await this.bitMap.write();
@@ -2403,23 +2467,24 @@ your workspace.jsonc has this component-id set. you might want to remove/change
2403
2467
  */
2404
2468
 
2405
2469
 
2406
- async unsetEnvFromComponents(components) {
2470
+ async unsetEnvFromComponents(ids) {
2407
2471
  const changed = [];
2408
2472
  const unchanged = [];
2409
- components.forEach(comp => {
2410
- var _bitMapEntry$config, _bitMapEntry$config$E;
2473
+ ids.forEach(id => {
2474
+ var _bitMapEntry$config;
2411
2475
 
2412
- const bitMapEntry = this.bitMap.getBitmapEntry(comp.id);
2413
- const currentEnv = (_bitMapEntry$config = bitMapEntry.config) === null || _bitMapEntry$config === void 0 ? void 0 : (_bitMapEntry$config$E = _bitMapEntry$config[_envs().EnvsAspect.id]) === null || _bitMapEntry$config$E === void 0 ? void 0 : _bitMapEntry$config$E.env;
2476
+ const bitMapEntry = this.bitMap.getBitmapEntry(id);
2477
+ const envsAspect = (_bitMapEntry$config = bitMapEntry.config) === null || _bitMapEntry$config === void 0 ? void 0 : _bitMapEntry$config[_envs().EnvsAspect.id];
2478
+ const currentEnv = envsAspect && envsAspect !== _config().REMOVE_EXTENSION_SPECIAL_SIGN ? envsAspect.env : null;
2414
2479
 
2415
2480
  if (!currentEnv) {
2416
- unchanged.push(comp.id);
2481
+ unchanged.push(id);
2417
2482
  return;
2418
2483
  }
2419
2484
 
2420
- this.bitMap.removeComponentConfig(comp.id, currentEnv);
2421
- this.bitMap.removeComponentConfig(comp.id, _envs().EnvsAspect.id);
2422
- changed.push(comp.id);
2485
+ this.bitMap.removeComponentConfig(id, currentEnv, false);
2486
+ this.bitMap.removeComponentConfig(id, _envs().EnvsAspect.id, false);
2487
+ changed.push(id);
2423
2488
  });
2424
2489
  await this.bitMap.write();
2425
2490
  return {