@teambit/workspace 0.0.598 → 0.0.605

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
@@ -16,10 +16,18 @@ export declare class BitMap {
16
16
  * later, upon `bit tag`, the data is saved in the scope.
17
17
  * returns a boolean indicating whether a change has been made.
18
18
  */
19
- addComponentConfig(aspectId: string, id: ComponentID, config?: Record<string, any>): Promise<boolean>;
19
+ addComponentConfig(id: ComponentID, aspectId: string, config?: Record<string, any>): boolean;
20
+ removeComponentConfig(id: ComponentID, aspectId: string): boolean;
20
21
  /**
21
22
  * write .bitmap object to the filesystem
22
23
  */
23
24
  write(): Promise<void>;
25
+ /**
26
+ * get the data saved in the .bitmap file for this component-id.
27
+ */
24
28
  getBitmapEntry(id: ComponentID, { ignoreVersion, ignoreScopeAndVersion }?: GetBitMapComponentOptions): ComponentMap;
29
+ /**
30
+ * components that were not tagged yet are safe to rename them from the .bitmap file.
31
+ */
32
+ renameNewComponent(sourceId: ComponentID, targetId: ComponentID): void;
25
33
  }
package/dist/bit-map.js CHANGED
@@ -33,7 +33,7 @@ class BitMap {
33
33
  */
34
34
 
35
35
 
36
- async addComponentConfig(aspectId, id, config) {
36
+ addComponentConfig(id, aspectId, config = {}) {
37
37
  if (!aspectId || typeof aspectId !== 'string') throw new Error(`expect aspectId to be string, got ${aspectId}`);
38
38
  const bitMapEntry = this.getBitmapEntry(id, {
39
39
  ignoreScopeAndVersion: true
@@ -51,7 +51,22 @@ class BitMap {
51
51
  }
52
52
 
53
53
  this.legacyBitMap.markAsChanged();
54
- await this.write();
54
+ return true; // changes have been made
55
+ }
56
+
57
+ removeComponentConfig(id, aspectId) {
58
+ if (!aspectId || typeof aspectId !== 'string') throw new Error(`expect aspectId to be string, got ${aspectId}`);
59
+ const bitMapEntry = this.getBitmapEntry(id, {
60
+ ignoreScopeAndVersion: true
61
+ });
62
+ const currentConfig = (bitMapEntry.config || (bitMapEntry.config = {}))[aspectId];
63
+
64
+ if (!currentConfig) {
65
+ return false; // no changes
66
+ }
67
+
68
+ delete bitMapEntry.config[aspectId];
69
+ this.legacyBitMap.markAsChanged();
55
70
  return true; // changes have been made
56
71
  }
57
72
  /**
@@ -62,6 +77,10 @@ class BitMap {
62
77
  async write() {
63
78
  await this.consumer.writeBitMap();
64
79
  }
80
+ /**
81
+ * get the data saved in the .bitmap file for this component-id.
82
+ */
83
+
65
84
 
66
85
  getBitmapEntry(id, {
67
86
  ignoreVersion,
@@ -72,6 +91,22 @@ class BitMap {
72
91
  ignoreScopeAndVersion
73
92
  });
74
93
  }
94
+ /**
95
+ * components that were not tagged yet are safe to rename them from the .bitmap file.
96
+ */
97
+
98
+
99
+ renameNewComponent(sourceId, targetId) {
100
+ const bitMapEntry = this.getBitmapEntry(sourceId);
101
+
102
+ if (bitMapEntry.id.hasVersion()) {
103
+ throw new Error(`unable to rename tagged or exported component: ${bitMapEntry.id.toString()}`);
104
+ }
105
+
106
+ this.legacyBitMap.removeComponent(bitMapEntry.id);
107
+ bitMapEntry.id = targetId._legacy;
108
+ this.legacyBitMap.setComponent(bitMapEntry.id, bitMapEntry);
109
+ }
75
110
 
76
111
  }
77
112
 
@@ -1 +1 @@
1
- {"version":3,"sources":["bit-map.ts"],"names":["BitMap","constructor","legacyBitMap","consumer","addComponentConfig","aspectId","id","config","Error","bitMapEntry","getBitmapEntry","ignoreScopeAndVersion","currentConfig","markAsChanged","write","writeBitMap","ignoreVersion","getComponent","_legacy"],"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;;;AAC0B,QAAlBC,kBAAkB,CAACC,QAAD,EAAmBC,EAAnB,EAAoCC,MAApC,EAAoF;AAC1G,QAAI,CAACF,QAAD,IAAa,OAAOA,QAAP,KAAoB,QAArC,EAA+C,MAAM,IAAIG,KAAJ,CAAW,qCAAoCH,QAAS,EAAxD,CAAN;AAC/C,UAAMI,WAAW,GAAG,KAAKC,cAAL,CAAoBJ,EAApB,EAAwB;AAAEK,MAAAA,qBAAqB,EAAE;AAAzB,KAAxB,CAApB;AACA,UAAMC,aAAa,GAAG,CAACH,WAAW,CAACF,MAAb,KAACE,WAAW,CAACF,MAAb,GAAwB,EAAxB,GAA4BF,QAA5B,CAAtB;;AACA,QAAI,uBAAQO,aAAR,EAAuBL,MAAvB,CAAJ,EAAoC;AAClC,aAAO,KAAP,CADkC,CACpB;AACf;;AACD,QAAI,CAACA,MAAL,EAAa;AACX,aAAOE,WAAW,CAACF,MAAZ,CAAmBF,QAAnB,CAAP;AACD,KAFD,MAEO;AACLI,MAAAA,WAAW,CAACF,MAAZ,CAAmBF,QAAnB,IAA+BE,MAA/B;AACD;;AACD,SAAKL,YAAL,CAAkBW,aAAlB;AACA,UAAM,KAAKC,KAAL,EAAN;AACA,WAAO,IAAP,CAd0G,CAc7F;AACd;AAED;AACF;AACA;;;AACa,QAALA,KAAK,GAAG;AACZ,UAAM,KAAKX,QAAL,CAAcY,WAAd,EAAN;AACD;;AAEDL,EAAAA,cAAc,CACZJ,EADY,EAEZ;AAAEU,IAAAA,aAAF;AAAiBL,IAAAA;AAAjB,MAAsE,EAF1D,EAGE;AACd,WAAO,KAAKT,YAAL,CAAkBe,YAAlB,CAA+BX,EAAE,CAACY,OAAlC,EAA2C;AAAEF,MAAAA,aAAF;AAAiBL,MAAAA;AAAjB,KAA3C,CAAP;AACD;;AArCiB","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 async addComponentConfig(aspectId: string, id: ComponentID, config?: Record<string, any>): Promise<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 await this.write();\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 getBitmapEntry(\n id: ComponentID,\n { ignoreVersion, ignoreScopeAndVersion }: GetBitMapComponentOptions = {}\n ): ComponentMap {\n return this.legacyBitMap.getComponent(id._legacy, { ignoreVersion, ignoreScopeAndVersion });\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","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,QA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AAb,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,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { ComponentTreeNode, ComponentTreeNodeProps } from '@teambit/component-tree';
2
3
  export declare class ComponentTreeWidget implements ComponentTreeNode {
3
4
  widget: ({ component }: ComponentTreeNodeProps) => JSX.Element | null;
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { Command, CommandOptions } from '@teambit/cli';
2
3
  import { EjectConfResult, Workspace } from './workspace';
3
4
  declare type EjectConfArgs = [string];
@@ -0,0 +1,11 @@
1
+ import { Command } from '@teambit/cli';
2
+ import { Workspace } from '../workspace';
3
+ export declare class EnvsSetCmd implements Command {
4
+ private workspace;
5
+ name: string;
6
+ description: string;
7
+ options: never[];
8
+ group: string;
9
+ constructor(workspace: Workspace);
10
+ report([pattern, env]: [string, string]): Promise<string>;
11
+ }
@@ -0,0 +1,55 @@
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.EnvsSetCmd = 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 EnvsSetCmd {
35
+ constructor(workspace) {
36
+ this.workspace = workspace;
37
+ (0, _defineProperty2().default)(this, "name", 'set <pattern> <env>');
38
+ (0, _defineProperty2().default)(this, "description", 'set an environment to component(s)');
39
+ (0, _defineProperty2().default)(this, "options", []);
40
+ (0, _defineProperty2().default)(this, "group", 'development');
41
+ }
42
+
43
+ async report([pattern, env]) {
44
+ const envId = await this.workspace.resolveComponentId(env);
45
+ const components = await this.workspace.byPattern(pattern);
46
+ await this.workspace.setEnvToComponents(envId, components);
47
+ return `added ${_chalk().default.bold(envId.toString())} env to the following component(s):
48
+ ${components.map(comp => comp.id.toString()).join('\n')}`;
49
+ }
50
+
51
+ }
52
+
53
+ exports.EnvsSetCmd = EnvsSetCmd;
54
+
55
+ //# sourceMappingURL=envs-set.cmd.js.map
@@ -0,0 +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"]}
@@ -0,0 +1,11 @@
1
+ import { Command } from '@teambit/cli';
2
+ import { Workspace } from '../workspace';
3
+ export declare class EnvsUnsetCmd implements Command {
4
+ private workspace;
5
+ name: string;
6
+ description: string;
7
+ options: never[];
8
+ group: string;
9
+ constructor(workspace: Workspace);
10
+ report([pattern]: [string]): Promise<string>;
11
+ }
@@ -0,0 +1,46 @@
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.EnvsUnsetCmd = 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
+ class EnvsUnsetCmd {
25
+ constructor(workspace) {
26
+ this.workspace = workspace;
27
+ (0, _defineProperty2().default)(this, "name", 'unset <pattern>');
28
+ (0, _defineProperty2().default)(this, "description", 'unset an environment from component(s)');
29
+ (0, _defineProperty2().default)(this, "options", []);
30
+ (0, _defineProperty2().default)(this, "group", 'development');
31
+ }
32
+
33
+ async report([pattern]) {
34
+ const components = await this.workspace.byPattern(pattern);
35
+ const {
36
+ changed
37
+ } = await this.workspace.unsetEnvFromComponents(components);
38
+ return `successfully removed env from the following component(s):
39
+ ${changed.map(id => id.toString()).join('\n')}`;
40
+ }
41
+
42
+ }
43
+
44
+ exports.EnvsUnsetCmd = EnvsUnsetCmd;
45
+
46
+ //# sourceMappingURL=envs-unset.cmd.js.map
@@ -0,0 +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,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { Command } from '@teambit/cli';
2
3
  import { Workspace } from './workspace';
3
4
  export declare class ListCmd implements Command {
@@ -1 +1,2 @@
1
+ /// <reference types="react" />
1
2
  export declare function WorkspaceOverview(): JSX.Element;
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import 'reset-css';
2
3
  import { RouteSlot } from '@teambit/ui-foundation.ui.react-router.slot-router';
3
4
  import WorkspaceUI from '../../workspace.ui.runtime';
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import type { DrawerType } from '@teambit/ui-foundation.ui.tree.drawer';
2
3
  import { ComponentTreeSlot } from '@teambit/component-tree';
3
4
  export declare class WorkspaceComponentsDrawer implements DrawerType {
@@ -292,12 +292,13 @@ class WorkspaceComponentLoader {
292
292
 
293
293
  addMultipleEnvsIssueIfNeeded(component) {
294
294
  const envs = this.envs.getAllEnvsConfiguredOnComponent(component);
295
+ const envIds = (0, _lodash().uniq)(envs.map(env => env.id));
295
296
 
296
- if (envs.length < 2) {
297
+ if (envIds.length < 2) {
297
298
  return;
298
299
  }
299
300
 
300
- component.state.issues.getOrCreate(_componentIssues().IssuesClasses.MultipleEnvs).data = envs.map(e => e.id);
301
+ component.state.issues.getOrCreate(_componentIssues().IssuesClasses.MultipleEnvs).data = envIds;
301
302
  }
302
303
 
303
304
  clearCache() {
@@ -1 +1 @@
1
- {"version":3,"sources":["workspace-component-loader.ts"],"names":["WorkspaceComponentLoader","constructor","workspace","logger","dependencyResolver","envs","componentsCache","maxSize","componentsCacheForCapsule","getMany","ids","forCapsule","idsWithoutEmpty","errors","longProcessLogger","createLongProcessLogger","length","componentsP","id","logProgress","toString","get","catch","err","isComponentNotExistsError","push","undefined","components","forEach","consumer","isLegacy","console","warn","filteredComponents","end","getInvalid","loadComponent","_legacy","ConsumerComponent","isComponentInvalidByErrorType","componentId","legacyComponent","useCache","storeInCache","bitIdWithVersion","bitmapIdsFromCurrentLane","version","changeVersion","fromCache","getFromCache","consumerComponent","getConsumerComponent","updatedId","ComponentID","fromLegacy","scope","component","loadOne","addMultipleEnvsIssueIfNeeded","saveInCache","getIfExist","getAllEnvsConfiguredOnComponent","state","issues","getOrCreate","IssuesClasses","MultipleEnvs","data","map","e","clearCache","deleteAll","clearComponentCache","idStr","delete","componentFromScope","MissingBitMapComponent","extensionDataList","componentExtensions","extensionsFromConsumerComponent","extensions","ExtensionDataList","mergeConfigs","filterRemovedExtensions","State","Config","mainFile","createAspectList","ComponentFS","fromVinyls","files","dependencies","workspaceComponent","WorkspaceComponent","head","tags","executeLoadSlot","newComponentFromState","set","isEqual","loadComponentForCapsule","debug","name","message","ComponentNotFound","ComponentNotFoundInPath","entries","onComponentLoadSlot","toArray","promises","extension","onLoad","upsertExtensionData","envsData","getEnvSystemDescriptor","policy","mergeVariantPolicies","config","extractDepsFromLegacy","depResolverData","serialize","EnvsAspect","DependencyResolverAspect","Promise","all","updatedAspectList","aspects","TagMap","existingExtension","findExtension","Object","assign","getDataEntry","ExtensionDataEntry"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAA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, ComponentFS, ComponentID, Config, InvalidComponent, State, TagMap } from '@teambit/component';\nimport { BitId } from '@teambit/legacy-bit-id';\nimport { ExtensionDataList } from '@teambit/legacy/dist/consumer/config/extension-data';\nimport mapSeries from 'p-map-series';\nimport { compact } from 'lodash';\nimport ConsumerComponent from '@teambit/legacy/dist/consumer/component';\nimport { MissingBitMapComponent } from '@teambit/legacy/dist/consumer/bit-map/exceptions';\nimport { getLatestVersionNumber } from '@teambit/legacy/dist/utils';\nimport { IssuesClasses } from '@teambit/component-issues';\nimport { ComponentNotFound } from '@teambit/legacy/dist/scope/exceptions';\nimport { DependencyResolverAspect, DependencyResolverMain } from '@teambit/dependency-resolver';\nimport { Logger } from '@teambit/logger';\nimport { EnvsAspect, EnvsMain } from '@teambit/envs';\nimport { ExtensionDataEntry } from '@teambit/legacy/dist/consumer/config';\nimport { getMaxSizeForComponents, InMemoryCache } from '@teambit/legacy/dist/cache/in-memory-cache';\nimport { createInMemoryCache } from '@teambit/legacy/dist/cache/cache-factory';\nimport ComponentNotFoundInPath from '@teambit/legacy/dist/consumer/component/exceptions/component-not-found-in-path';\nimport { Workspace } from '../workspace';\nimport { WorkspaceComponent } from './workspace-component';\n\nexport class WorkspaceComponentLoader {\n private componentsCache: InMemoryCache<Component>; // cache loaded components\n private componentsCacheForCapsule: InMemoryCache<Component>; // cache loaded components for capsule, must not use the cache for the workspace\n constructor(\n private workspace: Workspace,\n private logger: Logger,\n private dependencyResolver: DependencyResolverMain,\n private envs: EnvsMain\n ) {\n this.componentsCache = createInMemoryCache({ maxSize: getMaxSizeForComponents() });\n this.componentsCacheForCapsule = createInMemoryCache({ maxSize: getMaxSizeForComponents() });\n }\n\n async getMany(ids: Array<ComponentID>, forCapsule = false): Promise<Component[]> {\n const idsWithoutEmpty = compact(ids);\n const errors: { id: ComponentID; err: Error }[] = [];\n const longProcessLogger = this.logger.createLongProcessLogger('loading components', ids.length);\n const componentsP = mapSeries(idsWithoutEmpty, async (id: ComponentID) => {\n longProcessLogger.logProgress(id.toString());\n return this.get(id, forCapsule).catch((err) => {\n if (this.isComponentNotExistsError(err)) {\n errors.push({\n id,\n err,\n });\n return undefined;\n }\n throw err;\n });\n });\n const components = await componentsP;\n errors.forEach((err) => {\n if (!this.workspace.consumer.isLegacy) {\n this.logger.console(`failed loading component ${err.id.toString()}, see full error in debug.log file`);\n }\n this.logger.warn(`failed loading component ${err.id.toString()}`, err.err);\n });\n // remove errored components\n const filteredComponents: Component[] = compact(components);\n longProcessLogger.end();\n return filteredComponents;\n }\n\n async getInvalid(ids: Array<ComponentID>): Promise<InvalidComponent[]> {\n const idsWithoutEmpty = compact(ids);\n const errors: InvalidComponent[] = [];\n const longProcessLogger = this.logger.createLongProcessLogger('loading components', ids.length);\n await mapSeries(idsWithoutEmpty, async (id: ComponentID) => {\n longProcessLogger.logProgress(id.toString());\n try {\n await this.workspace.consumer.loadComponent(id._legacy);\n } catch (err: any) {\n if (ConsumerComponent.isComponentInvalidByErrorType(err)) {\n errors.push({\n id,\n err,\n });\n return;\n }\n throw err;\n }\n });\n return errors;\n }\n\n async get(\n componentId: ComponentID,\n forCapsule = false,\n legacyComponent?: ConsumerComponent,\n useCache = true,\n storeInCache = true\n ): Promise<Component> {\n const bitIdWithVersion: BitId = getLatestVersionNumber(\n this.workspace.consumer.bitmapIdsFromCurrentLane,\n componentId._legacy\n );\n const id = bitIdWithVersion.version ? componentId.changeVersion(bitIdWithVersion.version) : componentId;\n const fromCache = this.getFromCache(id, forCapsule);\n if (fromCache && useCache) {\n return fromCache;\n }\n const consumerComponent = legacyComponent || (await this.getConsumerComponent(id, forCapsule));\n // in case of out-of-sync, the id may changed during the load process\n const updatedId = consumerComponent ? ComponentID.fromLegacy(consumerComponent.id, id.scope) : id;\n const component = await this.loadOne(updatedId, consumerComponent);\n if (storeInCache) {\n this.addMultipleEnvsIssueIfNeeded(component); // it's in storeInCache block, otherwise, it wasn't fully loaded\n this.saveInCache(component, forCapsule);\n }\n return component;\n }\n\n async getIfExist(componentId: ComponentID) {\n try {\n return await this.get(componentId);\n } catch (err: any) {\n if (this.isComponentNotExistsError(err)) {\n return undefined;\n }\n throw err;\n }\n }\n\n private addMultipleEnvsIssueIfNeeded(component: Component) {\n const envs = this.envs.getAllEnvsConfiguredOnComponent(component);\n if (envs.length < 2) {\n return;\n }\n component.state.issues.getOrCreate(IssuesClasses.MultipleEnvs).data = envs.map((e) => e.id);\n }\n\n clearCache() {\n this.componentsCache.deleteAll();\n this.componentsCacheForCapsule.deleteAll();\n }\n clearComponentCache(id: ComponentID) {\n const idStr = id.toString();\n this.componentsCache.delete(idStr);\n this.componentsCacheForCapsule.delete(idStr);\n }\n\n private async loadOne(id: ComponentID, consumerComponent?: ConsumerComponent) {\n const componentFromScope = await this.workspace.scope.get(id);\n if (!consumerComponent) {\n if (!componentFromScope) throw new MissingBitMapComponent(id.toString());\n return componentFromScope;\n }\n\n let extensionDataList = await this.workspace.componentExtensions(id, componentFromScope);\n const extensionsFromConsumerComponent = consumerComponent.extensions || new ExtensionDataList();\n // Merge extensions added by the legacy code in memory (for example data of dependency resolver)\n extensionDataList = ExtensionDataList.mergeConfigs([\n extensionsFromConsumerComponent,\n extensionDataList,\n ]).filterRemovedExtensions();\n\n // temporarily mutate consumer component extensions until we remove all direct access from legacy to extensions data\n // TODO: remove this once we remove all direct access from legacy code to extensions data\n consumerComponent.extensions = extensionDataList;\n\n const state = new State(\n new Config(consumerComponent.mainFile, extensionDataList),\n await this.workspace.createAspectList(extensionDataList),\n ComponentFS.fromVinyls(consumerComponent.files),\n consumerComponent.dependencies,\n consumerComponent\n );\n if (componentFromScope) {\n // Removed by @gilad. do not mutate the component from the scope\n // componentFromScope.state = state;\n // const workspaceComponent = WorkspaceComponent.fromComponent(componentFromScope, this.workspace);\n const workspaceComponent = new WorkspaceComponent(\n componentFromScope.id,\n componentFromScope.head,\n state,\n componentFromScope.tags,\n this.workspace\n );\n return this.executeLoadSlot(workspaceComponent);\n }\n return this.executeLoadSlot(this.newComponentFromState(id, state));\n }\n\n private saveInCache(component: Component, forCapsule: boolean): void {\n if (forCapsule) {\n this.componentsCacheForCapsule.set(component.id.toString(), component);\n } else {\n this.componentsCache.set(component.id.toString(), component);\n }\n }\n\n /**\n * make sure that not only the id-str match, but also the legacy-id.\n * this is needed because the ComponentID.toString() is the same whether or not the legacy-id has\n * scope-name, as it includes the defaultScope if the scope is empty.\n * as a result, when out-of-sync is happening and the id is changed to include scope-name in the\n * legacy-id, the component is the cache has the old id.\n */\n private getFromCache(id: ComponentID, forCapsule: boolean): Component | undefined {\n const fromCache = forCapsule\n ? this.componentsCacheForCapsule.get(id.toString())\n : this.componentsCache.get(id.toString());\n if (fromCache && fromCache.id._legacy.isEqual(id._legacy)) {\n return fromCache;\n }\n return undefined;\n }\n\n private async getConsumerComponent(id: ComponentID, forCapsule = false): Promise<ConsumerComponent | undefined> {\n try {\n return forCapsule\n ? // eslint-disable-next-line @typescript-eslint/return-await\n await this.workspace.consumer.loadComponentForCapsule(id._legacy)\n : // eslint-disable-next-line @typescript-eslint/return-await\n await this.workspace.consumer.loadComponent(id._legacy);\n } catch (err: any) {\n // don't return undefined for any error. otherwise, if the component is invalid (e.g. main\n // file is missing) it returns the model component later unexpectedly, or if it's new, it\n // shows MissingBitMapComponent error incorrectly.\n if (this.isComponentNotExistsError(err)) {\n this.logger.debug(\n `failed loading component \"${id.toString()}\" from the workspace due to \"${err.name}\" error\\n${err.message}`\n );\n return undefined;\n }\n throw err;\n }\n }\n\n private isComponentNotExistsError(err: Error): boolean {\n return (\n err instanceof ComponentNotFound ||\n err instanceof MissingBitMapComponent ||\n err instanceof ComponentNotFoundInPath\n );\n }\n\n private async executeLoadSlot(component: Component) {\n const entries = this.workspace.onComponentLoadSlot.toArray();\n const promises = entries.map(async ([extension, onLoad]) => {\n const data = await onLoad(component);\n return this.upsertExtensionData(component, extension, data);\n });\n\n // Special load events which runs from the workspace but should run from the correct aspect\n // TODO: remove this once those extensions dependent on workspace\n const envsData = await this.workspace.getEnvSystemDescriptor(component);\n\n // Move to deps resolver main runtime once we switch ws<> deps resolver direction\n const policy = await this.dependencyResolver.mergeVariantPolicies(component.config.extensions);\n const dependencies = await this.dependencyResolver.extractDepsFromLegacy(component, policy);\n\n const depResolverData = {\n dependencies,\n policy: policy.serialize(),\n };\n\n promises.push(this.upsertExtensionData(component, EnvsAspect.id, envsData));\n promises.push(this.upsertExtensionData(component, DependencyResolverAspect.id, depResolverData));\n\n await Promise.all(promises);\n\n // Update the aspect list to have changes happened during the on load slot (new data added above)\n const updatedAspectList = await this.workspace.createAspectList(component.state.config.extensions);\n component.state.aspects = updatedAspectList;\n return component;\n }\n\n private newComponentFromState(id: ComponentID, state: State): Component {\n return new WorkspaceComponent(id, null, state, new TagMap(), this.workspace);\n }\n\n private async upsertExtensionData(component: Component, extension: string, data: any) {\n const existingExtension = component.state.config.extensions.findExtension(extension);\n if (existingExtension) {\n // Only merge top level of extension data\n Object.assign(existingExtension.data, data);\n return;\n }\n component.state.config.extensions.push(await this.getDataEntry(extension, data));\n }\n\n private async getDataEntry(extension: string, data: { [key: string]: any }): Promise<ExtensionDataEntry> {\n // TODO: @gilad we need to refactor the extension data entry api.\n return new ExtensionDataEntry(undefined, undefined, extension, undefined, data);\n }\n}\n"]}
1
+ {"version":3,"sources":["workspace-component-loader.ts"],"names":["WorkspaceComponentLoader","constructor","workspace","logger","dependencyResolver","envs","componentsCache","maxSize","componentsCacheForCapsule","getMany","ids","forCapsule","idsWithoutEmpty","errors","longProcessLogger","createLongProcessLogger","length","componentsP","id","logProgress","toString","get","catch","err","isComponentNotExistsError","push","undefined","components","forEach","consumer","isLegacy","console","warn","filteredComponents","end","getInvalid","loadComponent","_legacy","ConsumerComponent","isComponentInvalidByErrorType","componentId","legacyComponent","useCache","storeInCache","bitIdWithVersion","bitmapIdsFromCurrentLane","version","changeVersion","fromCache","getFromCache","consumerComponent","getConsumerComponent","updatedId","ComponentID","fromLegacy","scope","component","loadOne","addMultipleEnvsIssueIfNeeded","saveInCache","getIfExist","getAllEnvsConfiguredOnComponent","envIds","map","env","state","issues","getOrCreate","IssuesClasses","MultipleEnvs","data","clearCache","deleteAll","clearComponentCache","idStr","delete","componentFromScope","MissingBitMapComponent","extensionDataList","componentExtensions","extensionsFromConsumerComponent","extensions","ExtensionDataList","mergeConfigs","filterRemovedExtensions","State","Config","mainFile","createAspectList","ComponentFS","fromVinyls","files","dependencies","workspaceComponent","WorkspaceComponent","head","tags","executeLoadSlot","newComponentFromState","set","isEqual","loadComponentForCapsule","debug","name","message","ComponentNotFound","ComponentNotFoundInPath","entries","onComponentLoadSlot","toArray","promises","extension","onLoad","upsertExtensionData","envsData","getEnvSystemDescriptor","policy","mergeVariantPolicies","config","extractDepsFromLegacy","depResolverData","serialize","EnvsAspect","DependencyResolverAspect","Promise","all","updatedAspectList","aspects","TagMap","existingExtension","findExtension","Object","assign","getDataEntry","ExtensionDataEntry"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;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AAhC;AACAzB,IAAAA,SAAS,CAACS,KAAV,CAAgB8D,OAAhB,GAA0BD,iBAA1B;AACA,WAAOtE,SAAP;AACD;;AAEO0C,EAAAA,qBAAqB,CAAChF,EAAD,EAAkB+C,KAAlB,EAA2C;AACtE,WAAO,KAAI6B,wCAAJ,EAAuB5E,EAAvB,EAA2B,IAA3B,EAAiC+C,KAAjC,EAAwC,KAAI+D,mBAAJ,GAAxC,EAAsD,KAAK9H,SAA3D,CAAP;AACD;;AAEgC,QAAnB+G,mBAAmB,CAACzD,SAAD,EAAuBuD,SAAvB,EAA0CzC,IAA1C,EAAqD;AACpF,UAAM2D,iBAAiB,GAAGzE,SAAS,CAACS,KAAV,CAAgBqD,MAAhB,CAAuBrC,UAAvB,CAAkCiD,aAAlC,CAAgDnB,SAAhD,CAA1B;;AACA,QAAIkB,iBAAJ,EAAuB;AACrB;AACAE,MAAAA,MAAM,CAACC,MAAP,CAAcH,iBAAiB,CAAC3D,IAAhC,EAAsCA,IAAtC;AACA;AACD;;AACDd,IAAAA,SAAS,CAACS,KAAV,CAAgBqD,MAAhB,CAAuBrC,UAAvB,CAAkCxD,IAAlC,CAAuC,MAAM,KAAK4G,YAAL,CAAkBtB,SAAlB,EAA6BzC,IAA7B,CAA7C;AACD;;AAEyB,QAAZ+D,YAAY,CAACtB,SAAD,EAAoBzC,IAApB,EAA+E;AACvG;AACA,WAAO,KAAIgE,4BAAJ,EAAuB5G,SAAvB,EAAkCA,SAAlC,EAA6CqF,SAA7C,EAAwDrF,SAAxD,EAAmE4C,IAAnE,CAAP;AACD;;AA1QmC","sourcesContent":["import { Component, ComponentFS, ComponentID, Config, InvalidComponent, State, TagMap } from '@teambit/component';\nimport { BitId } from '@teambit/legacy-bit-id';\nimport { ExtensionDataList } from '@teambit/legacy/dist/consumer/config/extension-data';\nimport mapSeries from 'p-map-series';\nimport { compact, uniq } from 'lodash';\nimport ConsumerComponent from '@teambit/legacy/dist/consumer/component';\nimport { MissingBitMapComponent } from '@teambit/legacy/dist/consumer/bit-map/exceptions';\nimport { getLatestVersionNumber } from '@teambit/legacy/dist/utils';\nimport { IssuesClasses } from '@teambit/component-issues';\nimport { ComponentNotFound } from '@teambit/legacy/dist/scope/exceptions';\nimport { DependencyResolverAspect, DependencyResolverMain } from '@teambit/dependency-resolver';\nimport { Logger } from '@teambit/logger';\nimport { EnvsAspect, EnvsMain } from '@teambit/envs';\nimport { ExtensionDataEntry } from '@teambit/legacy/dist/consumer/config';\nimport { getMaxSizeForComponents, InMemoryCache } from '@teambit/legacy/dist/cache/in-memory-cache';\nimport { createInMemoryCache } from '@teambit/legacy/dist/cache/cache-factory';\nimport ComponentNotFoundInPath from '@teambit/legacy/dist/consumer/component/exceptions/component-not-found-in-path';\nimport { Workspace } from '../workspace';\nimport { WorkspaceComponent } from './workspace-component';\n\nexport class WorkspaceComponentLoader {\n private componentsCache: InMemoryCache<Component>; // cache loaded components\n private componentsCacheForCapsule: InMemoryCache<Component>; // cache loaded components for capsule, must not use the cache for the workspace\n constructor(\n private workspace: Workspace,\n private logger: Logger,\n private dependencyResolver: DependencyResolverMain,\n private envs: EnvsMain\n ) {\n this.componentsCache = createInMemoryCache({ maxSize: getMaxSizeForComponents() });\n this.componentsCacheForCapsule = createInMemoryCache({ maxSize: getMaxSizeForComponents() });\n }\n\n async getMany(ids: Array<ComponentID>, forCapsule = false): Promise<Component[]> {\n const idsWithoutEmpty = compact(ids);\n const errors: { id: ComponentID; err: Error }[] = [];\n const longProcessLogger = this.logger.createLongProcessLogger('loading components', ids.length);\n const componentsP = mapSeries(idsWithoutEmpty, async (id: ComponentID) => {\n longProcessLogger.logProgress(id.toString());\n return this.get(id, forCapsule).catch((err) => {\n if (this.isComponentNotExistsError(err)) {\n errors.push({\n id,\n err,\n });\n return undefined;\n }\n throw err;\n });\n });\n const components = await componentsP;\n errors.forEach((err) => {\n if (!this.workspace.consumer.isLegacy) {\n this.logger.console(`failed loading component ${err.id.toString()}, see full error in debug.log file`);\n }\n this.logger.warn(`failed loading component ${err.id.toString()}`, err.err);\n });\n // remove errored components\n const filteredComponents: Component[] = compact(components);\n longProcessLogger.end();\n return filteredComponents;\n }\n\n async getInvalid(ids: Array<ComponentID>): Promise<InvalidComponent[]> {\n const idsWithoutEmpty = compact(ids);\n const errors: InvalidComponent[] = [];\n const longProcessLogger = this.logger.createLongProcessLogger('loading components', ids.length);\n await mapSeries(idsWithoutEmpty, async (id: ComponentID) => {\n longProcessLogger.logProgress(id.toString());\n try {\n await this.workspace.consumer.loadComponent(id._legacy);\n } catch (err: any) {\n if (ConsumerComponent.isComponentInvalidByErrorType(err)) {\n errors.push({\n id,\n err,\n });\n return;\n }\n throw err;\n }\n });\n return errors;\n }\n\n async get(\n componentId: ComponentID,\n forCapsule = false,\n legacyComponent?: ConsumerComponent,\n useCache = true,\n storeInCache = true\n ): Promise<Component> {\n const bitIdWithVersion: BitId = getLatestVersionNumber(\n this.workspace.consumer.bitmapIdsFromCurrentLane,\n componentId._legacy\n );\n const id = bitIdWithVersion.version ? componentId.changeVersion(bitIdWithVersion.version) : componentId;\n const fromCache = this.getFromCache(id, forCapsule);\n if (fromCache && useCache) {\n return fromCache;\n }\n const consumerComponent = legacyComponent || (await this.getConsumerComponent(id, forCapsule));\n // in case of out-of-sync, the id may changed during the load process\n const updatedId = consumerComponent ? ComponentID.fromLegacy(consumerComponent.id, id.scope) : id;\n const component = await this.loadOne(updatedId, consumerComponent);\n if (storeInCache) {\n this.addMultipleEnvsIssueIfNeeded(component); // it's in storeInCache block, otherwise, it wasn't fully loaded\n this.saveInCache(component, forCapsule);\n }\n return component;\n }\n\n async getIfExist(componentId: ComponentID) {\n try {\n return await this.get(componentId);\n } catch (err: any) {\n if (this.isComponentNotExistsError(err)) {\n return undefined;\n }\n throw err;\n }\n }\n\n private addMultipleEnvsIssueIfNeeded(component: Component) {\n const envs = this.envs.getAllEnvsConfiguredOnComponent(component);\n const envIds = uniq(envs.map((env) => env.id));\n if (envIds.length < 2) {\n return;\n }\n component.state.issues.getOrCreate(IssuesClasses.MultipleEnvs).data = envIds;\n }\n\n clearCache() {\n this.componentsCache.deleteAll();\n this.componentsCacheForCapsule.deleteAll();\n }\n clearComponentCache(id: ComponentID) {\n const idStr = id.toString();\n this.componentsCache.delete(idStr);\n this.componentsCacheForCapsule.delete(idStr);\n }\n\n private async loadOne(id: ComponentID, consumerComponent?: ConsumerComponent) {\n const componentFromScope = await this.workspace.scope.get(id);\n if (!consumerComponent) {\n if (!componentFromScope) throw new MissingBitMapComponent(id.toString());\n return componentFromScope;\n }\n\n let extensionDataList = await this.workspace.componentExtensions(id, componentFromScope);\n const extensionsFromConsumerComponent = consumerComponent.extensions || new ExtensionDataList();\n // Merge extensions added by the legacy code in memory (for example data of dependency resolver)\n extensionDataList = ExtensionDataList.mergeConfigs([\n extensionsFromConsumerComponent,\n extensionDataList,\n ]).filterRemovedExtensions();\n\n // temporarily mutate consumer component extensions until we remove all direct access from legacy to extensions data\n // TODO: remove this once we remove all direct access from legacy code to extensions data\n consumerComponent.extensions = extensionDataList;\n\n const state = new State(\n new Config(consumerComponent.mainFile, extensionDataList),\n await this.workspace.createAspectList(extensionDataList),\n ComponentFS.fromVinyls(consumerComponent.files),\n consumerComponent.dependencies,\n consumerComponent\n );\n if (componentFromScope) {\n // Removed by @gilad. do not mutate the component from the scope\n // componentFromScope.state = state;\n // const workspaceComponent = WorkspaceComponent.fromComponent(componentFromScope, this.workspace);\n const workspaceComponent = new WorkspaceComponent(\n componentFromScope.id,\n componentFromScope.head,\n state,\n componentFromScope.tags,\n this.workspace\n );\n return this.executeLoadSlot(workspaceComponent);\n }\n return this.executeLoadSlot(this.newComponentFromState(id, state));\n }\n\n private saveInCache(component: Component, forCapsule: boolean): void {\n if (forCapsule) {\n this.componentsCacheForCapsule.set(component.id.toString(), component);\n } else {\n this.componentsCache.set(component.id.toString(), component);\n }\n }\n\n /**\n * make sure that not only the id-str match, but also the legacy-id.\n * this is needed because the ComponentID.toString() is the same whether or not the legacy-id has\n * scope-name, as it includes the defaultScope if the scope is empty.\n * as a result, when out-of-sync is happening and the id is changed to include scope-name in the\n * legacy-id, the component is the cache has the old id.\n */\n private getFromCache(id: ComponentID, forCapsule: boolean): Component | undefined {\n const fromCache = forCapsule\n ? this.componentsCacheForCapsule.get(id.toString())\n : this.componentsCache.get(id.toString());\n if (fromCache && fromCache.id._legacy.isEqual(id._legacy)) {\n return fromCache;\n }\n return undefined;\n }\n\n private async getConsumerComponent(id: ComponentID, forCapsule = false): Promise<ConsumerComponent | undefined> {\n try {\n return forCapsule\n ? // eslint-disable-next-line @typescript-eslint/return-await\n await this.workspace.consumer.loadComponentForCapsule(id._legacy)\n : // eslint-disable-next-line @typescript-eslint/return-await\n await this.workspace.consumer.loadComponent(id._legacy);\n } catch (err: any) {\n // don't return undefined for any error. otherwise, if the component is invalid (e.g. main\n // file is missing) it returns the model component later unexpectedly, or if it's new, it\n // shows MissingBitMapComponent error incorrectly.\n if (this.isComponentNotExistsError(err)) {\n this.logger.debug(\n `failed loading component \"${id.toString()}\" from the workspace due to \"${err.name}\" error\\n${err.message}`\n );\n return undefined;\n }\n throw err;\n }\n }\n\n private isComponentNotExistsError(err: Error): boolean {\n return (\n err instanceof ComponentNotFound ||\n err instanceof MissingBitMapComponent ||\n err instanceof ComponentNotFoundInPath\n );\n }\n\n private async executeLoadSlot(component: Component) {\n const entries = this.workspace.onComponentLoadSlot.toArray();\n const promises = entries.map(async ([extension, onLoad]) => {\n const data = await onLoad(component);\n return this.upsertExtensionData(component, extension, data);\n });\n\n // Special load events which runs from the workspace but should run from the correct aspect\n // TODO: remove this once those extensions dependent on workspace\n const envsData = await this.workspace.getEnvSystemDescriptor(component);\n\n // Move to deps resolver main runtime once we switch ws<> deps resolver direction\n const policy = await this.dependencyResolver.mergeVariantPolicies(component.config.extensions);\n const dependencies = await this.dependencyResolver.extractDepsFromLegacy(component, policy);\n\n const depResolverData = {\n dependencies,\n policy: policy.serialize(),\n };\n\n promises.push(this.upsertExtensionData(component, EnvsAspect.id, envsData));\n promises.push(this.upsertExtensionData(component, DependencyResolverAspect.id, depResolverData));\n\n await Promise.all(promises);\n\n // Update the aspect list to have changes happened during the on load slot (new data added above)\n const updatedAspectList = await this.workspace.createAspectList(component.state.config.extensions);\n component.state.aspects = updatedAspectList;\n return component;\n }\n\n private newComponentFromState(id: ComponentID, state: State): Component {\n return new WorkspaceComponent(id, null, state, new TagMap(), this.workspace);\n }\n\n private async upsertExtensionData(component: Component, extension: string, data: any) {\n const existingExtension = component.state.config.extensions.findExtension(extension);\n if (existingExtension) {\n // Only merge top level of extension data\n Object.assign(existingExtension.data, data);\n return;\n }\n component.state.config.extensions.push(await this.getDataEntry(extension, data));\n }\n\n private async getDataEntry(extension: string, data: { [key: string]: any }): Promise<ExtensionDataEntry> {\n // TODO: @gilad we need to refactor the extension data entry api.\n return new ExtensionDataEntry(undefined, undefined, extension, undefined, data);\n }\n}\n"]}
@@ -286,6 +286,10 @@ export declare class Workspace implements ComponentFactory {
286
286
  * don't throw an error if the component was not found, simply return undefined.
287
287
  */
288
288
  getIfExist(componentId: ComponentID): Promise<Component | undefined>;
289
+ /**
290
+ * whether a component exists in the workspace
291
+ */
292
+ exists(componentId: ComponentID): boolean;
289
293
  /**
290
294
  * This will make sure to fetch the objects prior to load them
291
295
  * do not use it if you are not sure you need it.
@@ -346,16 +350,13 @@ export declare class Workspace implements ComponentFactory {
346
350
  private componentDefaultScopeFromComponentDirAndNameWithoutConfigFile;
347
351
  /**
348
352
  * Calculate the component config based on:
353
+ * the config property in the .bitmap file
349
354
  * the component.json file in the component folder
350
355
  * matching pattern in the variants config
351
356
  * defaults extensions from workspace config
352
- *
353
- * @param {ComponentID} componentId
354
- * @param {Component} [componentFromScope]
355
- * @returns {Promise<ExtensionDataList>}
356
- * @memberof Workspace
357
357
  */
358
358
  componentExtensions(componentId: ComponentID, componentFromScope?: Component): Promise<ExtensionDataList>;
359
+ private filterEnvsFromExtensionsIfNeeded;
359
360
  triggerOnPreWatch(componentIds: ComponentID[], watchOpts: WatchOptions): Promise<void>;
360
361
  /**
361
362
  * This will mutate the entries with extensionId prop to have resolved legacy id
@@ -475,5 +476,17 @@ export declare class Workspace implements ComponentFactory {
475
476
  * @param {string[]} the list of packages that should be removed from dependencies.
476
477
  */
477
478
  uninstallDependencies(packages: string[]): Promise<ComponentMap<string>>;
479
+ /**
480
+ * configure an environment to the given components in the .bitmap file, this configuration overrides other, such as
481
+ * overrides in workspace.jsonc.
482
+ */
483
+ setEnvToComponents(envId: ComponentID, components: Component[]): Promise<void>;
484
+ /**
485
+ * remove env configuration from the .bitmap file, so then other configuration, such as "variants" will take place
486
+ */
487
+ unsetEnvFromComponents(components: Component[]): Promise<{
488
+ changed: ComponentID[];
489
+ unchanged: ComponentID[];
490
+ }>;
478
491
  }
479
492
  export default Workspace;