@teambit/workspace 0.0.646 → 0.0.650

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.
@@ -1,12 +1,13 @@
1
- import { ComponentID, AspectList } from '@teambit/component';
1
+ import { ComponentID, AspectList, AspectEntry, ResolveComponentIdFunc } from '@teambit/component';
2
2
  import { COMPONENT_CONFIG_FILE_NAME } from '@teambit/legacy/dist/constants';
3
- import { ExtensionDataList } from '@teambit/legacy/dist/consumer/config/extension-data';
3
+ import { ExtensionDataList, configEntryToDataEntry } from '@teambit/legacy/dist/consumer/config/extension-data';
4
4
  import { PathOsBasedAbsolute } from '@teambit/legacy/dist/utils/path';
5
5
  import detectIndent from 'detect-indent';
6
6
  import detectNewline from 'detect-newline';
7
7
  import fs from 'fs-extra';
8
8
  import path from 'path';
9
9
  import stringifyPackage from 'stringify-package';
10
+ import { REMOVE_EXTENSION_SPECIAL_SIGN } from '@teambit/legacy/dist/consumer/config';
10
11
 
11
12
  import { AlreadyExistsError } from './exceptions';
12
13
 
@@ -34,12 +35,12 @@ export class ComponentConfigFile {
34
35
  constructor(
35
36
  public componentId: ComponentID,
36
37
  public aspects: AspectList,
38
+ private componentDir: PathOsBasedAbsolute,
37
39
  public propagate: boolean = false,
38
40
  private options: ComponentConfigFileOptions = { indent: DEFAULT_INDENT, newLine: DEFAULT_NEWLINE },
39
41
  public defaultScope?: string
40
42
  ) {}
41
43
 
42
- // TODO: remove consumer from here
43
44
  static async load(
44
45
  componentDir: PathOsBasedAbsolute,
45
46
  aspectListFactory: (extensionDataList: ExtensionDataList) => Promise<AspectList>,
@@ -57,16 +58,23 @@ export class ComponentConfigFile {
57
58
  const componentId = ComponentID.fromObject(parsed.componentId, parsed.defaultScope || outsideDefaultScope);
58
59
  const aspects = await aspectListFactory(ExtensionDataList.fromConfigObject(parsed.extensions));
59
60
 
60
- return new ComponentConfigFile(componentId, aspects, !!parsed.propagate, { indent, newLine }, parsed.defaultScope);
61
+ return new ComponentConfigFile(
62
+ componentId,
63
+ aspects,
64
+ componentDir,
65
+ Boolean(parsed.propagate),
66
+ { indent, newLine },
67
+ parsed.defaultScope
68
+ );
61
69
  }
62
70
 
63
71
  static composePath(componentRootFolder: string) {
64
72
  return path.join(componentRootFolder, COMPONENT_CONFIG_FILE_NAME);
65
73
  }
66
74
 
67
- async write(componentDir: string, options: WriteConfigFileOptions = {}): Promise<void> {
75
+ async write(options: WriteConfigFileOptions = {}): Promise<void> {
68
76
  const json = this.toJson();
69
- const filePath = ComponentConfigFile.composePath(componentDir);
77
+ const filePath = ComponentConfigFile.composePath(this.componentDir);
70
78
  const isExist = await fs.pathExists(filePath);
71
79
  if (isExist && !options.override) {
72
80
  throw new AlreadyExistsError(filePath);
@@ -74,6 +82,32 @@ export class ComponentConfigFile {
74
82
  return fs.writeJsonSync(filePath, json, { spaces: this.options.indent, EOL: this.options.newLine });
75
83
  }
76
84
 
85
+ async addAspect(aspectId: string, config: any, resolveComponentId: ResolveComponentIdFunc) {
86
+ const existing = this.aspects.get(aspectId);
87
+ if (existing) {
88
+ existing.config = config;
89
+ } else {
90
+ const aspectEntry = await this.aspectEntryFromConfigObject(aspectId, config, resolveComponentId);
91
+ this.aspects.entries.push(aspectEntry);
92
+ }
93
+ }
94
+
95
+ async removeAspect(aspectId: string, markWithMinusIfNotExist: boolean, resolveComponentId: ResolveComponentIdFunc) {
96
+ const existing = this.aspects.get(aspectId);
97
+ if (existing) {
98
+ const aspectList = this.aspects.withoutEntries([aspectId]);
99
+ this.aspects = aspectList;
100
+ } else if (markWithMinusIfNotExist) {
101
+ await this.addAspect(aspectId, REMOVE_EXTENSION_SPECIAL_SIGN, resolveComponentId);
102
+ }
103
+ }
104
+
105
+ private async aspectEntryFromConfigObject(id: string, config: any, resolveComponentId: ResolveComponentIdFunc) {
106
+ const aspectId = await resolveComponentId(id);
107
+ const legacyEntry = configEntryToDataEntry(id, config);
108
+ return new AspectEntry(aspectId, legacyEntry);
109
+ }
110
+
77
111
  toJson(): ComponentConfigFileJson {
78
112
  return {
79
113
  componentId: this.componentId.toObject(),
@@ -1,4 +1,4 @@
1
- import { ComponentID, AspectList } from '@teambit/component';
1
+ import { ComponentID, AspectList, ResolveComponentIdFunc } from '@teambit/component';
2
2
  import { ExtensionDataList } from '@teambit/legacy/dist/consumer/config/extension-data';
3
3
  import { PathOsBasedAbsolute } from '@teambit/legacy/dist/utils/path';
4
4
  interface ComponentConfigFileOptions {
@@ -17,13 +17,17 @@ interface ComponentConfigFileJson {
17
17
  export declare class ComponentConfigFile {
18
18
  componentId: ComponentID;
19
19
  aspects: AspectList;
20
+ private componentDir;
20
21
  propagate: boolean;
21
22
  private options;
22
23
  defaultScope?: string | undefined;
23
- constructor(componentId: ComponentID, aspects: AspectList, propagate?: boolean, options?: ComponentConfigFileOptions, defaultScope?: string | undefined);
24
+ constructor(componentId: ComponentID, aspects: AspectList, componentDir: PathOsBasedAbsolute, propagate?: boolean, options?: ComponentConfigFileOptions, defaultScope?: string | undefined);
24
25
  static load(componentDir: PathOsBasedAbsolute, aspectListFactory: (extensionDataList: ExtensionDataList) => Promise<AspectList>, outsideDefaultScope?: string): Promise<ComponentConfigFile | undefined>;
25
26
  static composePath(componentRootFolder: string): string;
26
- write(componentDir: string, options?: WriteConfigFileOptions): Promise<void>;
27
+ write(options?: WriteConfigFileOptions): Promise<void>;
28
+ addAspect(aspectId: string, config: any, resolveComponentId: ResolveComponentIdFunc): Promise<void>;
29
+ removeAspect(aspectId: string, markWithMinusIfNotExist: boolean, resolveComponentId: ResolveComponentIdFunc): Promise<void>;
30
+ private aspectEntryFromConfigObject;
27
31
  toJson(): ComponentConfigFileJson;
28
32
  toString(): string;
29
33
  }
@@ -2,6 +2,8 @@
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
4
 
5
+ require("core-js/modules/es.array.iterator.js");
6
+
5
7
  require("core-js/modules/es.promise.js");
6
8
 
7
9
  Object.defineProperty(exports, "__esModule", {
@@ -89,6 +91,16 @@ function _stringifyPackage() {
89
91
  return data;
90
92
  }
91
93
 
94
+ function _config() {
95
+ const data = require("@teambit/legacy/dist/consumer/config");
96
+
97
+ _config = function () {
98
+ return data;
99
+ };
100
+
101
+ return data;
102
+ }
103
+
92
104
  function _exceptions() {
93
105
  const data = require("./exceptions");
94
106
 
@@ -103,17 +115,17 @@ const DEFAULT_INDENT = 2;
103
115
  const DEFAULT_NEWLINE = '\n';
104
116
 
105
117
  class ComponentConfigFile {
106
- constructor(componentId, aspects, propagate = false, options = {
118
+ constructor(componentId, aspects, componentDir, propagate = false, options = {
107
119
  indent: DEFAULT_INDENT,
108
120
  newLine: DEFAULT_NEWLINE
109
121
  }, defaultScope) {
110
122
  this.componentId = componentId;
111
123
  this.aspects = aspects;
124
+ this.componentDir = componentDir;
112
125
  this.propagate = propagate;
113
126
  this.options = options;
114
127
  this.defaultScope = defaultScope;
115
- } // TODO: remove consumer from here
116
-
128
+ }
117
129
 
118
130
  static async load(componentDir, aspectListFactory, outsideDefaultScope) {
119
131
  const filePath = ComponentConfigFile.composePath(componentDir);
@@ -131,7 +143,7 @@ class ComponentConfigFile {
131
143
  const componentId = _component().ComponentID.fromObject(parsed.componentId, parsed.defaultScope || outsideDefaultScope);
132
144
 
133
145
  const aspects = await aspectListFactory(_extensionData().ExtensionDataList.fromConfigObject(parsed.extensions));
134
- return new ComponentConfigFile(componentId, aspects, !!parsed.propagate, {
146
+ return new ComponentConfigFile(componentId, aspects, componentDir, Boolean(parsed.propagate), {
135
147
  indent,
136
148
  newLine
137
149
  }, parsed.defaultScope);
@@ -141,9 +153,9 @@ class ComponentConfigFile {
141
153
  return _path().default.join(componentRootFolder, _constants().COMPONENT_CONFIG_FILE_NAME);
142
154
  }
143
155
 
144
- async write(componentDir, options = {}) {
156
+ async write(options = {}) {
145
157
  const json = this.toJson();
146
- const filePath = ComponentConfigFile.composePath(componentDir);
158
+ const filePath = ComponentConfigFile.composePath(this.componentDir);
147
159
  const isExist = await _fsExtra().default.pathExists(filePath);
148
160
 
149
161
  if (isExist && !options.override) {
@@ -156,6 +168,34 @@ class ComponentConfigFile {
156
168
  });
157
169
  }
158
170
 
171
+ async addAspect(aspectId, config, resolveComponentId) {
172
+ const existing = this.aspects.get(aspectId);
173
+
174
+ if (existing) {
175
+ existing.config = config;
176
+ } else {
177
+ const aspectEntry = await this.aspectEntryFromConfigObject(aspectId, config, resolveComponentId);
178
+ this.aspects.entries.push(aspectEntry);
179
+ }
180
+ }
181
+
182
+ async removeAspect(aspectId, markWithMinusIfNotExist, resolveComponentId) {
183
+ const existing = this.aspects.get(aspectId);
184
+
185
+ if (existing) {
186
+ const aspectList = this.aspects.withoutEntries([aspectId]);
187
+ this.aspects = aspectList;
188
+ } else if (markWithMinusIfNotExist) {
189
+ await this.addAspect(aspectId, _config().REMOVE_EXTENSION_SPECIAL_SIGN, resolveComponentId);
190
+ }
191
+ }
192
+
193
+ async aspectEntryFromConfigObject(id, config, resolveComponentId) {
194
+ const aspectId = await resolveComponentId(id);
195
+ const legacyEntry = (0, _extensionData().configEntryToDataEntry)(id, config);
196
+ return new (_component().AspectEntry)(aspectId, legacyEntry);
197
+ }
198
+
159
199
  toJson() {
160
200
  return {
161
201
  componentId: this.componentId.toObject(),
@@ -1 +1 @@
1
- {"version":3,"sources":["component-config-file.ts"],"names":["DEFAULT_INDENT","DEFAULT_NEWLINE","ComponentConfigFile","constructor","componentId","aspects","propagate","options","indent","newLine","defaultScope","load","componentDir","aspectListFactory","outsideDefaultScope","filePath","composePath","isExist","fs","pathExists","undefined","content","readFile","parsed","parseComponentJsonContent","amount","ComponentID","fromObject","ExtensionDataList","fromConfigObject","extensions","componentRootFolder","path","join","COMPONENT_CONFIG_FILE_NAME","write","json","toJson","override","AlreadyExistsError","writeJsonSync","spaces","EOL","toObject","toConfigObject","toString","str","dir","JSON","parse","err","Error","message"],"mappings":";;;;;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AA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WAAO;AACLjC,MAAAA,WAAW,EAAE,KAAKA,WAAL,CAAiBuC,QAAjB,EADR;AAELrC,MAAAA,SAAS,EAAE,KAAKA,SAFX;AAGLI,MAAAA,YAAY,EAAE,KAAKA,YAHd;AAILoB,MAAAA,UAAU,EAAE,KAAKzB,OAAL,CAAauC,cAAb;AAJP,KAAP;AAMD;;AAEDC,EAAAA,QAAQ,GAAW;AACjB,UAAMT,IAAI,GAAG,KAAKC,MAAL,EAAb;AACA,WAAO,iCAAiBD,IAAjB,EAAuB,KAAK7B,OAAL,CAAaC,MAApC,EAA4C,KAAKD,OAAL,CAAaE,OAAzD,CAAP;AACD;;AAxD8B;;;;AA2DjC,SAASe,yBAAT,CAAmCsB,GAAnC,EAAgDC,GAAhD,EAA6D;AAC3D,MAAI;AACF,WAAOC,IAAI,CAACC,KAAL,CAAWH,GAAX,CAAP;AACD,GAFD,CAEE,OAAOI,GAAP,EAAiB;AACjB,UAAM,IAAIC,KAAJ,CAAW,yCAAwCJ,GAAI,qBAAoBG,GAAG,CAACE,OAAQ,EAAvF,CAAN;AACD;AACF","sourcesContent":["import { ComponentID, AspectList } from '@teambit/component';\nimport { COMPONENT_CONFIG_FILE_NAME } from '@teambit/legacy/dist/constants';\nimport { ExtensionDataList } from '@teambit/legacy/dist/consumer/config/extension-data';\nimport { PathOsBasedAbsolute } from '@teambit/legacy/dist/utils/path';\nimport detectIndent from 'detect-indent';\nimport detectNewline from 'detect-newline';\nimport fs from 'fs-extra';\nimport path from 'path';\nimport stringifyPackage from 'stringify-package';\n\nimport { AlreadyExistsError } from './exceptions';\n\ninterface ComponentConfigFileOptions {\n indent: number;\n newLine: '\\r\\n' | '\\n' | undefined;\n}\n\ninterface WriteConfigFileOptions {\n override?: boolean;\n}\n\ninterface ComponentConfigFileJson {\n componentId: any;\n // TODO: think if we want to change it to aspects\n extensions: any;\n propagate: boolean;\n defaultScope?: string;\n}\n\nconst DEFAULT_INDENT = 2;\nconst DEFAULT_NEWLINE = '\\n';\n\nexport class ComponentConfigFile {\n constructor(\n public componentId: ComponentID,\n public aspects: AspectList,\n public propagate: boolean = false,\n private options: ComponentConfigFileOptions = { indent: DEFAULT_INDENT, newLine: DEFAULT_NEWLINE },\n public defaultScope?: string\n ) {}\n\n // TODO: remove consumer from here\n static async load(\n componentDir: PathOsBasedAbsolute,\n aspectListFactory: (extensionDataList: ExtensionDataList) => Promise<AspectList>,\n outsideDefaultScope?: string\n ): Promise<ComponentConfigFile | undefined> {\n const filePath = ComponentConfigFile.composePath(componentDir);\n const isExist = await fs.pathExists(filePath);\n if (!isExist) {\n return undefined;\n }\n const content = await fs.readFile(filePath, 'utf-8');\n const parsed: ComponentConfigFileJson = parseComponentJsonContent(content, componentDir);\n const indent = detectIndent(content).amount;\n const newLine = detectNewline(content);\n const componentId = ComponentID.fromObject(parsed.componentId, parsed.defaultScope || outsideDefaultScope);\n const aspects = await aspectListFactory(ExtensionDataList.fromConfigObject(parsed.extensions));\n\n return new ComponentConfigFile(componentId, aspects, !!parsed.propagate, { indent, newLine }, parsed.defaultScope);\n }\n\n static composePath(componentRootFolder: string) {\n return path.join(componentRootFolder, COMPONENT_CONFIG_FILE_NAME);\n }\n\n async write(componentDir: string, options: WriteConfigFileOptions = {}): Promise<void> {\n const json = this.toJson();\n const filePath = ComponentConfigFile.composePath(componentDir);\n const isExist = await fs.pathExists(filePath);\n if (isExist && !options.override) {\n throw new AlreadyExistsError(filePath);\n }\n return fs.writeJsonSync(filePath, json, { spaces: this.options.indent, EOL: this.options.newLine });\n }\n\n toJson(): ComponentConfigFileJson {\n return {\n componentId: this.componentId.toObject(),\n propagate: this.propagate,\n defaultScope: this.defaultScope,\n extensions: this.aspects.toConfigObject(),\n };\n }\n\n toString(): string {\n const json = this.toJson();\n return stringifyPackage(json, this.options.indent, this.options.newLine);\n }\n}\n\nfunction parseComponentJsonContent(str: string, dir: string) {\n try {\n return JSON.parse(str);\n } catch (err: any) {\n throw new Error(`failed parsing component.json file at ${dir}. original error: ${err.message}`);\n }\n}\n"]}
1
+ {"version":3,"sources":["component-config-file.ts"],"names":["DEFAULT_INDENT","DEFAULT_NEWLINE","ComponentConfigFile","constructor","componentId","aspects","componentDir","propagate","options","indent","newLine","defaultScope","load","aspectListFactory","outsideDefaultScope","filePath","composePath","isExist","fs","pathExists","undefined","content","readFile","parsed","parseComponentJsonContent","amount","ComponentID","fromObject","ExtensionDataList","fromConfigObject","extensions","Boolean","componentRootFolder","path","join","COMPONENT_CONFIG_FILE_NAME","write","json","toJson","override","AlreadyExistsError","writeJsonSync","spaces","EOL","addAspect","aspectId","config","resolveComponentId","existing","get","aspectEntry","aspectEntryFromConfigObject","entries","push","removeAspect","markWithMinusIfNotExist","aspectList","withoutEntries","REMOVE_EXTENSION_SPECIAL_SIGN","id","legacyEntry","AspectEntry","toObject","toConfigObject","toString","str","dir","JSON","parse","err","Error","message"],"mappings":";;;;;;;;;;;;;AAAA;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;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAmBA,MAAMA,cAAc,GAAG,CAAvB;AACA,MAAMC,eAAe,GAAG,IAAxB;;AAEO,MAAMC,mBAAN,CAA0B;AAC/BC,EAAAA,WAAW,CACFC,WADE,EAEFC,OAFE,EAGDC,YAHC,EAIFC,SAAkB,GAAG,KAJnB,EAKDC,OAAmC,GAAG;AAAEC,IAAAA,MAAM,EA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AACD;AACF","sourcesContent":["import { ComponentID, AspectList, AspectEntry, ResolveComponentIdFunc } from '@teambit/component';\nimport { COMPONENT_CONFIG_FILE_NAME } from '@teambit/legacy/dist/constants';\nimport { ExtensionDataList, configEntryToDataEntry } from '@teambit/legacy/dist/consumer/config/extension-data';\nimport { PathOsBasedAbsolute } from '@teambit/legacy/dist/utils/path';\nimport detectIndent from 'detect-indent';\nimport detectNewline from 'detect-newline';\nimport fs from 'fs-extra';\nimport path from 'path';\nimport stringifyPackage from 'stringify-package';\nimport { REMOVE_EXTENSION_SPECIAL_SIGN } from '@teambit/legacy/dist/consumer/config';\n\nimport { AlreadyExistsError } from './exceptions';\n\ninterface ComponentConfigFileOptions {\n indent: number;\n newLine: '\\r\\n' | '\\n' | undefined;\n}\n\ninterface WriteConfigFileOptions {\n override?: boolean;\n}\n\ninterface ComponentConfigFileJson {\n componentId: any;\n // TODO: think if we want to change it to aspects\n extensions: any;\n propagate: boolean;\n defaultScope?: string;\n}\n\nconst DEFAULT_INDENT = 2;\nconst DEFAULT_NEWLINE = '\\n';\n\nexport class ComponentConfigFile {\n constructor(\n public componentId: ComponentID,\n public aspects: AspectList,\n private componentDir: PathOsBasedAbsolute,\n public propagate: boolean = false,\n private options: ComponentConfigFileOptions = { indent: DEFAULT_INDENT, newLine: DEFAULT_NEWLINE },\n public defaultScope?: string\n ) {}\n\n static async load(\n componentDir: PathOsBasedAbsolute,\n aspectListFactory: (extensionDataList: ExtensionDataList) => Promise<AspectList>,\n outsideDefaultScope?: string\n ): Promise<ComponentConfigFile | undefined> {\n const filePath = ComponentConfigFile.composePath(componentDir);\n const isExist = await fs.pathExists(filePath);\n if (!isExist) {\n return undefined;\n }\n const content = await fs.readFile(filePath, 'utf-8');\n const parsed: ComponentConfigFileJson = parseComponentJsonContent(content, componentDir);\n const indent = detectIndent(content).amount;\n const newLine = detectNewline(content);\n const componentId = ComponentID.fromObject(parsed.componentId, parsed.defaultScope || outsideDefaultScope);\n const aspects = await aspectListFactory(ExtensionDataList.fromConfigObject(parsed.extensions));\n\n return new ComponentConfigFile(\n componentId,\n aspects,\n componentDir,\n Boolean(parsed.propagate),\n { indent, newLine },\n parsed.defaultScope\n );\n }\n\n static composePath(componentRootFolder: string) {\n return path.join(componentRootFolder, COMPONENT_CONFIG_FILE_NAME);\n }\n\n async write(options: WriteConfigFileOptions = {}): Promise<void> {\n const json = this.toJson();\n const filePath = ComponentConfigFile.composePath(this.componentDir);\n const isExist = await fs.pathExists(filePath);\n if (isExist && !options.override) {\n throw new AlreadyExistsError(filePath);\n }\n return fs.writeJsonSync(filePath, json, { spaces: this.options.indent, EOL: this.options.newLine });\n }\n\n async addAspect(aspectId: string, config: any, resolveComponentId: ResolveComponentIdFunc) {\n const existing = this.aspects.get(aspectId);\n if (existing) {\n existing.config = config;\n } else {\n const aspectEntry = await this.aspectEntryFromConfigObject(aspectId, config, resolveComponentId);\n this.aspects.entries.push(aspectEntry);\n }\n }\n\n async removeAspect(aspectId: string, markWithMinusIfNotExist: boolean, resolveComponentId: ResolveComponentIdFunc) {\n const existing = this.aspects.get(aspectId);\n if (existing) {\n const aspectList = this.aspects.withoutEntries([aspectId]);\n this.aspects = aspectList;\n } else if (markWithMinusIfNotExist) {\n await this.addAspect(aspectId, REMOVE_EXTENSION_SPECIAL_SIGN, resolveComponentId);\n }\n }\n\n private async aspectEntryFromConfigObject(id: string, config: any, resolveComponentId: ResolveComponentIdFunc) {\n const aspectId = await resolveComponentId(id);\n const legacyEntry = configEntryToDataEntry(id, config);\n return new AspectEntry(aspectId, legacyEntry);\n }\n\n toJson(): ComponentConfigFileJson {\n return {\n componentId: this.componentId.toObject(),\n propagate: this.propagate,\n defaultScope: this.defaultScope,\n extensions: this.aspects.toConfigObject(),\n };\n }\n\n toString(): string {\n const json = this.toJson();\n return stringifyPackage(json, this.options.indent, this.options.newLine);\n }\n}\n\nfunction parseComponentJsonContent(str: string, dir: string) {\n try {\n return JSON.parse(str);\n } catch (err: any) {\n throw new Error(`failed parsing component.json file at ${dir}. original error: ${err.message}`);\n }\n}\n"]}
@@ -0,0 +1,11 @@
1
+ import { Command } from '@teambit/cli';
2
+ import { Workspace } from '../workspace';
3
+ export declare class EnvsReplaceCmd implements Command {
4
+ private workspace;
5
+ name: string;
6
+ description: string;
7
+ options: never[];
8
+ group: string;
9
+ constructor(workspace: Workspace);
10
+ report([oldEnv, env]: [string, string]): Promise<string>;
11
+ }
@@ -0,0 +1,56 @@
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.EnvsReplaceCmd = 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 EnvsReplaceCmd {
35
+ constructor(workspace) {
36
+ this.workspace = workspace;
37
+ (0, _defineProperty2().default)(this, "name", 'replace <old-env> <new-env>');
38
+ (0, _defineProperty2().default)(this, "description", 'replace an existing env with another env for all components using the old env');
39
+ (0, _defineProperty2().default)(this, "options", []);
40
+ (0, _defineProperty2().default)(this, "group", 'development');
41
+ }
42
+
43
+ async report([oldEnv, env]) {
44
+ const envId = await this.workspace.resolveComponentId(env);
45
+ const components = await this.workspace.getComponentsUsingEnv(oldEnv, true);
46
+ const componentIds = components.map(comp => comp.id);
47
+ await this.workspace.setEnvToComponents(envId, componentIds);
48
+ return `added ${_chalk().default.bold(envId.toString())} env to the following component(s):
49
+ ${componentIds.map(compId => compId.toString()).join('\n')}`;
50
+ }
51
+
52
+ }
53
+
54
+ exports.EnvsReplaceCmd = EnvsReplaceCmd;
55
+
56
+ //# sourceMappingURL=envs-replace.cmd.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["envs-replace.cmd.ts"],"names":["EnvsReplaceCmd","constructor","workspace","report","oldEnv","env","envId","resolveComponentId","components","getComponentsUsingEnv","componentIds","map","comp","id","setEnvToComponents","chalk","bold","toString","compId","join"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAGO,MAAMA,cAAN,CAAwC;AAM7CC,EAAAA,WAAW,CAASC,SAAT,EAA+B;AAAA,SAAtBA,SAAsB,GAAtBA,SAAsB;AAAA,kDALnC,6BAKmC;AAAA,yDAJ5B,+EAI4B;AAAA,qDAHhC,EAGgC;AAAA,mDAFlC,aAEkC;AAAE;;AAEhC,QAANC,MAAM,CAAC,CAACC,MAAD,EAASC,GAAT,CAAD,EAAkC;AAC5C,UAAMC,KAAK,GAAG,MAAM,KAAKJ,SAAL,CAAeK,kBAAf,CAAkCF,GAAlC,CAApB;AACA,UAAMG,UAAU,GAAG,MAAM,KAAKN,SAAL,CAAeO,qBAAf,CAAqCL,MAArC,EAA6C,IAA7C,CAAzB;AACA,UAAMM,YAAY,GAAGF,UAAU,CAACG,GAAX,CAAgBC,IAAD,IAAUA,IAAI,CAACC,EAA9B,CAArB;AACA,UAAM,KAAKX,SAAL,CAAeY,kBAAf,CAAkCR,KAAlC,EAAyCI,YAAzC,CAAN;AACA,WAAQ,SAAQK,iBAAMC,IAAN,CAAWV,KAAK,CAACW,QAAN,EAAX,CAA6B;AACjD,EAAEP,YAAY,CAACC,GAAb,CAAkBO,MAAD,IAAYA,MAAM,CAACD,QAAP,EAA7B,EAAgDE,IAAhD,CAAqD,IAArD,CAA2D,EADzD;AAED;;AAf4C","sourcesContent":["import { Command } from '@teambit/cli';\nimport chalk from 'chalk';\nimport { Workspace } from '../workspace';\n\nexport class EnvsReplaceCmd implements Command {\n name = 'replace <old-env> <new-env>';\n description = 'replace an existing env with another env for all components using the old env';\n options = [];\n group = 'development';\n\n constructor(private workspace: Workspace) {}\n\n async report([oldEnv, env]: [string, string]) {\n const envId = await this.workspace.resolveComponentId(env);\n const components = await this.workspace.getComponentsUsingEnv(oldEnv, true);\n const componentIds = components.map((comp) => comp.id);\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"]}
@@ -54,7 +54,6 @@ class EnvsSetCmd {
54
54
  async report([pattern, env]) {
55
55
  const envId = await this.workspace.resolveComponentId(env);
56
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
57
  await this.workspace.setEnvToComponents(envId, componentIds);
59
58
  return `added ${_chalk().default.bold(envId.toString())} env to the following component(s):
60
59
  ${componentIds.map(compId => compId.toString()).join('\n')}`;
@@ -1 +1 @@
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"]}
1
+ {"version":3,"sources":["envs-set.cmd.ts"],"names":["EnvsSetCmd","constructor","workspace","report","pattern","env","envId","resolveComponentId","componentIds","idsByPattern","setEnvToComponents","chalk","bold","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,UAAM,KAAKF,SAAL,CAAeQ,kBAAf,CAAkCJ,KAAlC,EAAyCE,YAAzC,CAAN;AACA,WAAQ,SAAQG,iBAAMC,IAAN,CAAWN,KAAK,CAACO,QAAN,EAAX,CAA6B;AACjD,EAAEL,YAAY,CAACM,GAAb,CAAkBC,MAAD,IAAYA,MAAM,CAACF,QAAP,EAA7B,EAAgDG,IAAhD,CAAqD,IAArD,CAA2D,EADzD;AAED;;AAfwC","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 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"]}
@@ -43,7 +43,7 @@ class PatternCommand {
43
43
  }
44
44
 
45
45
  async report([pattern]) {
46
- const ids = await this.workspace.idsByPattern(pattern);
46
+ const ids = await this.json([pattern]);
47
47
 
48
48
  const title = _chalk().default.green(`found ${_chalk().default.bold(ids.length.toString())} components matching the pattern`);
49
49
 
@@ -51,7 +51,7 @@ class PatternCommand {
51
51
  }
52
52
 
53
53
  async json([pattern]) {
54
- return this.workspace.idsByPattern(pattern);
54
+ return this.workspace.idsByPattern(pattern, false);
55
55
  }
56
56
 
57
57
  }
@@ -1 +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"]}
1
+ {"version":3,"sources":["pattern.cmd.ts"],"names":["PatternCommand","constructor","workspace","report","pattern","ids","json","title","chalk","green","bold","length","toString","join","idsByPattern"],"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,KAAKC,IAAL,CAAU,CAACF,OAAD,CAAV,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,QAAJP,IAAI,CAAC,CAACF,OAAD,CAAD,EAAsB;AAC9B,WAAO,KAAKF,SAAL,CAAeY,YAAf,CAA4BV,OAA5B,EAAqC,KAArC,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.json([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, false);\n }\n}\n"]}
package/dist/tag-cmd.d.ts CHANGED
@@ -10,7 +10,7 @@ export declare class Tag implements Command {
10
10
  options: CommandOptions;
11
11
  migration: boolean;
12
12
  remoteOp: boolean;
13
- report([id]: [string[]], { message, ver, all, snapped, patch, minor, major, preRelease, force, verbose, ignoreUnresolvedDependencies, ignoreIssues, ignoreNewestVersion, skipTests, skipAutoTag, scope, build, soft, persist, disableDeployPipeline, disableTagPipeline, forceDeploy, incrementBy, }: {
13
+ report([id]: [string[]], { message, ver, all, editor, snapped, patch, minor, major, preRelease, force, verbose, ignoreUnresolvedDependencies, ignoreIssues, ignoreNewestVersion, skipTests, skipAutoTag, scope, build, soft, persist, disableDeployPipeline, disableTagPipeline, forceDeploy, incrementBy, }: {
14
14
  all?: boolean | string;
15
15
  snapped?: boolean | string;
16
16
  ver?: string;
package/dist/tag-cmd.js CHANGED
@@ -112,7 +112,7 @@ https://${_constants().BASE_DOCS_DOMAIN}/docs/tag-component-version
112
112
  ${(0, _constants().WILDCARD_HELP)('tag')}`);
113
113
  (0, _defineProperty2().default)(this, "alias", 't');
114
114
  (0, _defineProperty2().default)(this, "loader", true);
115
- (0, _defineProperty2().default)(this, "options", [['m', 'message <message>', 'log message describing the user changes'], ['a', 'all [version]', 'tag all new and modified components'], ['s', 'scope [version]', 'tag all components of the current scope'], ['', 'snapped [version]', 'tag components that their head is a snap (not a tag)'], ['', 'ver <version>', 'tag specified components with the given version'], ['p', 'patch', 'increment the patch version number'], ['', 'minor', 'increment the minor version number'], ['', 'major', 'increment the major version number'], ['', 'pre-release [identifier]', 'EXPERIMENTAL. increment a pre-release version (e.g. 1.0.0-dev.1)'], ['f', 'force', 'force-tag even if tests are failing and even when component has not changed'], ['v', 'verbose', 'show specs output on failure'], ['', 'ignore-unresolved-dependencies', 'DEPRECATED. use --ignore-issues instead'], ['i', 'ignore-issues', 'ignore component issues (shown in "bit status" as "issues found")'], ['I', 'ignore-newest-version', 'ignore existing of newer versions (default = false)'], ['', 'skip-tests', 'skip running component tests during tag process'], ['', 'skip-auto-tag', 'skip auto tagging dependents'], ['b', 'build', 'EXPERIMENTAL. not needed for now. run the pipeline build and complete the tag'], ['', 'soft', 'do not persist. only keep note of the changes to be made'], ['', 'persist', 'persist the changes generated by --soft tag'], ['', 'disable-deploy-pipeline', 'DEPRECATED. use --disable-tag-pipeline instead'], ['', 'disable-tag-pipeline', 'skip the tag pipeline to avoid publishing the components'], ['', 'force-deploy', 'run the tag pipeline although the build failed'], ['', 'increment-by <number>', '(default to 1) increment semver flag (patch/minor/major) by. e.g. incrementing patch by 2: 0.0.1 -> 0.0.3.']]);
115
+ (0, _defineProperty2().default)(this, "options", [['m', 'message <message>', 'log message describing the user changes'], ['a', 'all [version]', 'tag all new and modified components'], ['s', 'scope [version]', 'tag all components of the current scope'], ['', 'editor [editor]', 'EXPERIMENTAL. open an editor to edit the tag messages per component, optionally specify the editor-name, default to vim'], ['', 'snapped [version]', 'tag components that their head is a snap (not a tag)'], ['', 'ver <version>', 'tag specified components with the given version'], ['p', 'patch', 'increment the patch version number'], ['', 'minor', 'increment the minor version number'], ['', 'major', 'increment the major version number'], ['', 'pre-release [identifier]', 'EXPERIMENTAL. increment a pre-release version (e.g. 1.0.0-dev.1)'], ['f', 'force', 'force-tag even if tests are failing and even when component has not changed'], ['v', 'verbose', 'show specs output on failure'], ['', 'ignore-unresolved-dependencies', 'DEPRECATED. use --ignore-issues instead'], ['i', 'ignore-issues', 'ignore component issues (shown in "bit status" as "issues found")'], ['I', 'ignore-newest-version', 'ignore existing of newer versions (default = false)'], ['', 'skip-tests', 'skip running component tests during tag process'], ['', 'skip-auto-tag', 'skip auto tagging dependents'], ['b', 'build', 'EXPERIMENTAL. not needed for now. run the pipeline build and complete the tag'], ['', 'soft', 'do not persist. only keep note of the changes to be made'], ['', 'persist', 'persist the changes generated by --soft tag'], ['', 'disable-deploy-pipeline', 'DEPRECATED. use --disable-tag-pipeline instead'], ['', 'disable-tag-pipeline', 'skip the tag pipeline to avoid publishing the components'], ['', 'force-deploy', 'run the tag pipeline although the build failed'], ['', 'increment-by <number>', '(default to 1) increment semver flag (patch/minor/major) by. e.g. incrementing patch by 2: 0.0.1 -> 0.0.3.']]);
116
116
  (0, _defineProperty2().default)(this, "migration", true);
117
117
  (0, _defineProperty2().default)(this, "remoteOp", true);
118
118
  }
@@ -123,6 +123,7 @@ ${(0, _constants().WILDCARD_HELP)('tag')}`);
123
123
  message = '',
124
124
  ver,
125
125
  all = false,
126
+ editor = '',
126
127
  snapped = false,
127
128
  patch,
128
129
  minor,
@@ -185,6 +186,14 @@ ${(0, _constants().WILDCARD_HELP)('tag')}`);
185
186
  throw new (_generalError().default)('you can use either --all or --persist, but not both');
186
187
  }
187
188
 
189
+ if (editor && persist) {
190
+ throw new (_generalError().default)('you can use either --editor or --persist, but not both');
191
+ }
192
+
193
+ if (editor && message) {
194
+ throw new (_generalError().default)('you can use either --editor or --message, but not both');
195
+ }
196
+
188
197
  const releaseFlags = [patch, minor, major, preRelease].filter(x => x);
189
198
 
190
199
  if (releaseFlags.length > 1) {
@@ -199,6 +208,7 @@ ${(0, _constants().WILDCARD_HELP)('tag')}`);
199
208
  ids: id,
200
209
  all: Boolean(all),
201
210
  snapped: Boolean(snapped),
211
+ editor,
202
212
  message,
203
213
  exactVersion: getVersion(),
204
214
  releaseType,
@@ -1 +1 @@
1
- {"version":3,"sources":["tag-cmd.ts"],"names":["Tag","BASE_DOCS_DOMAIN","report","id","message","ver","all","snapped","patch","minor","major","preRelease","force","verbose","ignoreUnresolvedDependencies","ignoreIssues","ignoreNewestVersion","skipTests","skipAutoTag","scope","build","soft","persist","disableDeployPipeline","disableTagPipeline","forceDeploy","incrementBy","BUILD_ON_CI","Boolean","getVersion","length","GeneralError","secondArg","semver","valid","disableTagAndSnapPipelines","releaseFlags","filter","x","releaseType","DEFAULT_BIT_RELEASE_TYPE","includeImported","params","ids","exactVersion","results","chalk","yellow","NOTHING_TO_TAG_MSG","taggedComponents","autoTaggedResults","warnings","newComponents","changedComponents","component","searchWithoutVersion","addedComponents","autoTaggedCount","warningsOutput","join","tagExplanationPersist","tagExplanationSoft","tagExplanation","isSoftTag","outputComponents","comps","map","componentOutput","toString","autoTag","result","triggeredBy","searchWithoutScopeAndVersion","autoTagComp","a","AUTO_TAGGED_MSG","publishOutput","publishedPackages","successTitle","green","successCompsStr","successOutput","softTagPrefix","outputIfExists","label","explanation","components","underline","newDesc","changedDesc","softTagClarification","bold"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;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;;AAMA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;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6C,IAAN,CACE,iHADF,CADyB,GAIzB,EAJJ;AAKA,WACEjC,cAAc,GACdZ,iBAAMiC,KAAN,CACG,GAAE9B,gBAAgB,CAACnB,MAAjB,GAA0B2B,eAAgB,iBAAgBZ,OAAO,CAACkB,SAAR,GAAoB,OAApB,GAA8B,EAAG,QADhG,CADA,GAIAD,cAJA,GAKAqB,cAAc,CAAC,gBAAD,EAAmBK,OAAnB,EAA4BhC,eAA5B,CALd,GAMA2B,cAAc,CAAC,oBAAD,EAAuBM,WAAvB,EAAoCpC,iBAApC,CANd,GAOAuB,aAAa,EAPb,GAQAc,oBATF;AAWD;;AAtOiC","sourcesContent":["import chalk from 'chalk';\nimport semver, { ReleaseType } from 'semver';\nimport { Command, CommandOptions } from '@teambit/cli';\nimport { tagAction } from '@teambit/legacy/dist/api/consumer';\nimport {\n TagResults,\n NOTHING_TO_TAG_MSG,\n AUTO_TAGGED_MSG,\n BasicTagParams,\n} from '@teambit/legacy/dist/api/consumer/lib/tag';\nimport { isString } from '@teambit/legacy/dist/utils';\nimport { DEFAULT_BIT_RELEASE_TYPE, BASE_DOCS_DOMAIN, WILDCARD_HELP } from '@teambit/legacy/dist/constants';\nimport GeneralError from '@teambit/legacy/dist/error/general-error';\nimport { isFeatureEnabled, BUILD_ON_CI } from '@teambit/legacy/dist/api/consumer/lib/feature-toggle';\n\nexport class Tag implements Command {\n name = 'tag [id...]';\n group = 'development';\n shortDescription = 'record component changes and lock versions';\n description = `record component changes and lock versions.\nif component ids are entered, you can specify a version per id using \"@\" sign, e.g. bit tag foo@1.0.0 bar@minor baz@major\nhttps://${BASE_DOCS_DOMAIN}/docs/tag-component-version\n${WILDCARD_HELP('tag')}`;\n alias = 't';\n loader = true;\n options = [\n ['m', 'message <message>', 'log message describing the user changes'],\n ['a', 'all [version]', 'tag all new and modified components'],\n ['s', 'scope [version]', 'tag all components of the current scope'],\n ['', 'snapped [version]', 'tag components that their head is a snap (not a tag)'],\n ['', 'ver <version>', 'tag specified components with the given version'],\n ['p', 'patch', 'increment the patch version number'],\n ['', 'minor', 'increment the minor version number'],\n ['', 'major', 'increment the major version number'],\n ['', 'pre-release [identifier]', 'EXPERIMENTAL. increment a pre-release version (e.g. 1.0.0-dev.1)'],\n ['f', 'force', 'force-tag even if tests are failing and even when component has not changed'],\n ['v', 'verbose', 'show specs output on failure'],\n ['', 'ignore-unresolved-dependencies', 'DEPRECATED. use --ignore-issues instead'],\n ['i', 'ignore-issues', 'ignore component issues (shown in \"bit status\" as \"issues found\")'],\n ['I', 'ignore-newest-version', 'ignore existing of newer versions (default = false)'],\n ['', 'skip-tests', 'skip running component tests during tag process'],\n ['', 'skip-auto-tag', 'skip auto tagging dependents'],\n ['b', 'build', 'EXPERIMENTAL. not needed for now. run the pipeline build and complete the tag'],\n ['', 'soft', 'do not persist. only keep note of the changes to be made'],\n ['', 'persist', 'persist the changes generated by --soft tag'],\n ['', 'disable-deploy-pipeline', 'DEPRECATED. use --disable-tag-pipeline instead'],\n ['', 'disable-tag-pipeline', 'skip the tag pipeline to avoid publishing the components'],\n ['', 'force-deploy', 'run the tag pipeline although the build failed'],\n [\n '',\n 'increment-by <number>',\n '(default to 1) increment semver flag (patch/minor/major) by. e.g. incrementing patch by 2: 0.0.1 -> 0.0.3.',\n ],\n ] as CommandOptions;\n migration = true;\n remoteOp = true; // In case a compiler / tester is not installed\n\n // eslint-disable-next-line complexity\n async report(\n [id = []]: [string[]],\n {\n message = '',\n ver,\n all = false,\n snapped = false,\n patch,\n minor,\n major,\n preRelease,\n force = false,\n verbose = false,\n ignoreUnresolvedDependencies,\n ignoreIssues = false,\n ignoreNewestVersion = false,\n skipTests = false,\n skipAutoTag = false,\n scope,\n build,\n soft = false,\n persist = false,\n disableDeployPipeline = false,\n disableTagPipeline = false,\n forceDeploy = false,\n incrementBy = 1,\n }: {\n all?: boolean | string;\n snapped?: boolean | string;\n ver?: string;\n patch?: boolean;\n minor?: boolean;\n major?: boolean;\n ignoreUnresolvedDependencies?: boolean;\n ignoreIssues?: boolean;\n scope?: string | boolean;\n incrementBy?: number;\n disableDeployPipeline?: boolean;\n disableTagPipeline?: boolean;\n } & Partial<BasicTagParams>\n ): Promise<string> {\n build = isFeatureEnabled(BUILD_ON_CI) ? Boolean(build) : true;\n if (soft) build = false;\n function getVersion(): string | undefined {\n if (scope && isString(scope)) return scope;\n if (all && isString(all)) return all;\n if (snapped && isString(snapped)) return snapped;\n return ver;\n }\n\n if (!id.length && !all && !snapped && !scope && !persist) {\n throw new GeneralError('missing [id]. to tag all components, please use --all flag');\n }\n if (id.length && all) {\n throw new GeneralError(\n 'you can use either a specific component [id] to tag a particular component or --all flag to tag them all'\n );\n }\n if (typeof ignoreUnresolvedDependencies === 'boolean') {\n ignoreIssues = ignoreUnresolvedDependencies;\n }\n if (id.length === 2) {\n const secondArg = id[1];\n // previously, the synopsis of this command was `bit tag [id] [version]`, show a descriptive\n // error when users still use it.\n if (semver.valid(secondArg)) {\n throw new GeneralError(\n `seems like you entered a version as the second arg, this is not supported anymore, please use \"@\" sign or --ver flag instead`\n );\n }\n }\n const disableTagAndSnapPipelines = disableTagPipeline || disableDeployPipeline;\n if (disableTagAndSnapPipelines && forceDeploy) {\n throw new GeneralError('you can use either force-deploy or disable-tag-pipeline, but not both');\n }\n if (all && persist) {\n throw new GeneralError('you can use either --all or --persist, but not both');\n }\n\n const releaseFlags = [patch, minor, major, preRelease].filter((x) => x);\n if (releaseFlags.length > 1) {\n throw new GeneralError('you can use only one of the following - patch, minor, major, pre-release');\n }\n\n let releaseType: ReleaseType = DEFAULT_BIT_RELEASE_TYPE;\n const includeImported = Boolean(scope && all);\n\n if (major) releaseType = 'major';\n else if (minor) releaseType = 'minor';\n else if (patch) releaseType = 'patch';\n else if (preRelease) releaseType = 'prerelease';\n\n const params = {\n ids: id,\n all: Boolean(all),\n snapped: Boolean(snapped),\n message,\n exactVersion: getVersion(),\n releaseType,\n preRelease: typeof preRelease === 'string' ? preRelease : '',\n force,\n verbose,\n ignoreIssues,\n ignoreNewestVersion,\n skipTests,\n skipAutoTag,\n build,\n soft,\n persist,\n scope,\n includeImported,\n disableTagAndSnapPipelines,\n forceDeploy,\n incrementBy,\n };\n\n const results = await tagAction(params);\n if (!results) return chalk.yellow(NOTHING_TO_TAG_MSG);\n const { taggedComponents, autoTaggedResults, warnings, newComponents }: TagResults = results;\n const changedComponents = taggedComponents.filter((component) => !newComponents.searchWithoutVersion(component.id));\n const addedComponents = taggedComponents.filter((component) => newComponents.searchWithoutVersion(component.id));\n const autoTaggedCount = autoTaggedResults ? autoTaggedResults.length : 0;\n\n const warningsOutput = warnings && warnings.length ? `${chalk.yellow(warnings.join('\\n'))}\\n\\n` : '';\n const tagExplanationPersist = `\\n(use \"bit export [collection]\" to push these components to a remote\")\n(use \"bit untag\" to unstage versions)\\n`;\n const tagExplanationSoft = `\\n(use \"bit tag --persist\" to persist the changes\")\n(use \"bit untag --soft\" to remove the soft-tags)\\n`;\n\n const tagExplanation = results.isSoftTag ? tagExplanationSoft : tagExplanationPersist;\n\n const outputComponents = (comps) => {\n return comps\n .map((component) => {\n let componentOutput = ` > ${component.id.toString()}`;\n const autoTag = autoTaggedResults.filter((result) =>\n result.triggeredBy.searchWithoutScopeAndVersion(component.id)\n );\n if (autoTag.length) {\n const autoTagComp = autoTag.map((a) => a.component.id.toString());\n componentOutput += `\\n ${AUTO_TAGGED_MSG}:\n ${autoTagComp.join('\\n ')}`;\n }\n return componentOutput;\n })\n .join('\\n');\n };\n\n const publishOutput = () => {\n const { publishedPackages } = results;\n if (!publishedPackages || !publishedPackages.length) return '';\n const successTitle = `\\n\\n${chalk.green(\n `published the following ${publishedPackages.length} component(s) successfully\\n`\n )}`;\n const successCompsStr = publishedPackages.join('\\n');\n const successOutput = successCompsStr ? successTitle + successCompsStr : '';\n return successOutput;\n };\n\n const softTagPrefix = results.isSoftTag ? 'soft-tagged ' : '';\n const outputIfExists = (label, explanation, components) => {\n if (!components.length) return '';\n return `\\n${chalk.underline(softTagPrefix + label)}\\n(${explanation})\\n${outputComponents(components)}\\n`;\n };\n\n const newDesc = results.isSoftTag\n ? 'set to be tagged first version for components'\n : 'first version for components';\n const changedDesc = results.isSoftTag\n ? 'components that set to get a version bump'\n : 'components that got a version bump';\n const softTagClarification = results.isSoftTag\n ? chalk.bold(\n 'keep in mind that this is a soft-tag (changes recorded to be tagged), to persist the changes use --persist flag'\n )\n : '';\n return (\n warningsOutput +\n chalk.green(\n `${taggedComponents.length + autoTaggedCount} component(s) ${results.isSoftTag ? 'soft-' : ''}tagged`\n ) +\n tagExplanation +\n outputIfExists('new components', newDesc, addedComponents) +\n outputIfExists('changed components', changedDesc, changedComponents) +\n publishOutput() +\n softTagClarification\n );\n }\n}\n"]}
1
+ {"version":3,"sources":["tag-cmd.ts"],"names":["Tag","BASE_DOCS_DOMAIN","report","id","message","ver","all","editor","snapped","patch","minor","major","preRelease","force","verbose","ignoreUnresolvedDependencies","ignoreIssues","ignoreNewestVersion","skipTests","skipAutoTag","scope","build","soft","persist","disableDeployPipeline","disableTagPipeline","forceDeploy","incrementBy","BUILD_ON_CI","Boolean","getVersion","length","GeneralError","secondArg","semver","valid","disableTagAndSnapPipelines","releaseFlags","filter","x","releaseType","DEFAULT_BIT_RELEASE_TYPE","includeImported","params","ids","exactVersion","results","chalk","yellow","NOTHING_TO_TAG_MSG","taggedComponents","autoTaggedResults","warnings","newComponents","changedComponents","component","searchWithoutVersion","addedComponents","autoTaggedCount","warningsOutput","join","tagExplanationPersist","tagExplanationSoft","tagExplanation","isSoftTag","outputComponents","comps","map","componentOutput","toString","autoTag","result","triggeredBy","searchWithoutScopeAndVersion","autoTagComp","a","AUTO_TAGGED_MSG","publishOutput","publishedPackages","successTitle","green","successCompsStr","successOutput","softTagPrefix","outputIfExists","label","explanation","components","underline","newDesc","changedDesc","softTagClarification","bold"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA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kB,SAAR,GAAoB,cAApB,GAAqC,EAA3D;;AACA,UAAMoB,cAAc,GAAG,CAACC,KAAD,EAAQC,WAAR,EAAqBC,UAArB,KAAoC;AACzD,UAAI,CAACA,UAAU,CAACxD,MAAhB,EAAwB,OAAO,EAAP;AACxB,aAAQ,KAAIgB,iBAAMyC,SAAN,CAAgBL,aAAa,GAAGE,KAAhC,CAAuC,MAAKC,WAAY,MAAKrB,gBAAgB,CAACsB,UAAD,CAAa,IAAtG;AACD,KAHD;;AAKA,UAAME,OAAO,GAAG3C,OAAO,CAACkB,SAAR,GACZ,+CADY,GAEZ,8BAFJ;AAGA,UAAM0B,WAAW,GAAG5C,OAAO,CAACkB,SAAR,GAChB,2CADgB,GAEhB,oCAFJ;AAGA,UAAM2B,oBAAoB,GAAG7C,OAAO,CAACkB,SAAR,GACzBjB,iBAAM6C,IAAN,CACE,iHADF,CADyB,GAIzB,EAJJ;AAKA,WACEjC,cAAc,GACdZ,iBAAMiC,KAAN,CACG,GAAE9B,gBAAgB,CAACnB,MAAjB,GAA0B2B,eAAgB,iBAAgBZ,OAAO,CAACkB,SAAR,GAAoB,OAApB,GAA8B,EAAG,QADhG,CADA,GAIAD,cAJA,GAKAqB,cAAc,CAAC,gBAAD,EAAmBK,OAAnB,EAA4BhC,eAA5B,CALd,GAMA2B,cAAc,CAAC,oBAAD,EAAuBM,WAAvB,EAAoCpC,iBAApC,CANd,GAOAuB,aAAa,EAPb,GAQAc,oBATF;AAWD;;AAnPiC","sourcesContent":["import chalk from 'chalk';\nimport semver, { ReleaseType } from 'semver';\nimport { Command, CommandOptions } from '@teambit/cli';\nimport { tagAction } from '@teambit/legacy/dist/api/consumer';\nimport {\n TagResults,\n NOTHING_TO_TAG_MSG,\n AUTO_TAGGED_MSG,\n BasicTagParams,\n} from '@teambit/legacy/dist/api/consumer/lib/tag';\nimport { isString } from '@teambit/legacy/dist/utils';\nimport { DEFAULT_BIT_RELEASE_TYPE, BASE_DOCS_DOMAIN, WILDCARD_HELP } from '@teambit/legacy/dist/constants';\nimport GeneralError from '@teambit/legacy/dist/error/general-error';\nimport { isFeatureEnabled, BUILD_ON_CI } from '@teambit/legacy/dist/api/consumer/lib/feature-toggle';\n\nexport class Tag implements Command {\n name = 'tag [id...]';\n group = 'development';\n shortDescription = 'record component changes and lock versions';\n description = `record component changes and lock versions.\nif component ids are entered, you can specify a version per id using \"@\" sign, e.g. bit tag foo@1.0.0 bar@minor baz@major\nhttps://${BASE_DOCS_DOMAIN}/docs/tag-component-version\n${WILDCARD_HELP('tag')}`;\n alias = 't';\n loader = true;\n options = [\n ['m', 'message <message>', 'log message describing the user changes'],\n ['a', 'all [version]', 'tag all new and modified components'],\n ['s', 'scope [version]', 'tag all components of the current scope'],\n [\n '',\n 'editor [editor]',\n 'EXPERIMENTAL. open an editor to edit the tag messages per component, optionally specify the editor-name, default to vim',\n ],\n ['', 'snapped [version]', 'tag components that their head is a snap (not a tag)'],\n ['', 'ver <version>', 'tag specified components with the given version'],\n ['p', 'patch', 'increment the patch version number'],\n ['', 'minor', 'increment the minor version number'],\n ['', 'major', 'increment the major version number'],\n ['', 'pre-release [identifier]', 'EXPERIMENTAL. increment a pre-release version (e.g. 1.0.0-dev.1)'],\n ['f', 'force', 'force-tag even if tests are failing and even when component has not changed'],\n ['v', 'verbose', 'show specs output on failure'],\n ['', 'ignore-unresolved-dependencies', 'DEPRECATED. use --ignore-issues instead'],\n ['i', 'ignore-issues', 'ignore component issues (shown in \"bit status\" as \"issues found\")'],\n ['I', 'ignore-newest-version', 'ignore existing of newer versions (default = false)'],\n ['', 'skip-tests', 'skip running component tests during tag process'],\n ['', 'skip-auto-tag', 'skip auto tagging dependents'],\n ['b', 'build', 'EXPERIMENTAL. not needed for now. run the pipeline build and complete the tag'],\n ['', 'soft', 'do not persist. only keep note of the changes to be made'],\n ['', 'persist', 'persist the changes generated by --soft tag'],\n ['', 'disable-deploy-pipeline', 'DEPRECATED. use --disable-tag-pipeline instead'],\n ['', 'disable-tag-pipeline', 'skip the tag pipeline to avoid publishing the components'],\n ['', 'force-deploy', 'run the tag pipeline although the build failed'],\n [\n '',\n 'increment-by <number>',\n '(default to 1) increment semver flag (patch/minor/major) by. e.g. incrementing patch by 2: 0.0.1 -> 0.0.3.',\n ],\n ] as CommandOptions;\n migration = true;\n remoteOp = true; // In case a compiler / tester is not installed\n\n // eslint-disable-next-line complexity\n async report(\n [id = []]: [string[]],\n {\n message = '',\n ver,\n all = false,\n editor = '',\n snapped = false,\n patch,\n minor,\n major,\n preRelease,\n force = false,\n verbose = false,\n ignoreUnresolvedDependencies,\n ignoreIssues = false,\n ignoreNewestVersion = false,\n skipTests = false,\n skipAutoTag = false,\n scope,\n build,\n soft = false,\n persist = false,\n disableDeployPipeline = false,\n disableTagPipeline = false,\n forceDeploy = false,\n incrementBy = 1,\n }: {\n all?: boolean | string;\n snapped?: boolean | string;\n ver?: string;\n patch?: boolean;\n minor?: boolean;\n major?: boolean;\n ignoreUnresolvedDependencies?: boolean;\n ignoreIssues?: boolean;\n scope?: string | boolean;\n incrementBy?: number;\n disableDeployPipeline?: boolean;\n disableTagPipeline?: boolean;\n } & Partial<BasicTagParams>\n ): Promise<string> {\n build = isFeatureEnabled(BUILD_ON_CI) ? Boolean(build) : true;\n if (soft) build = false;\n function getVersion(): string | undefined {\n if (scope && isString(scope)) return scope;\n if (all && isString(all)) return all;\n if (snapped && isString(snapped)) return snapped;\n return ver;\n }\n\n if (!id.length && !all && !snapped && !scope && !persist) {\n throw new GeneralError('missing [id]. to tag all components, please use --all flag');\n }\n if (id.length && all) {\n throw new GeneralError(\n 'you can use either a specific component [id] to tag a particular component or --all flag to tag them all'\n );\n }\n if (typeof ignoreUnresolvedDependencies === 'boolean') {\n ignoreIssues = ignoreUnresolvedDependencies;\n }\n if (id.length === 2) {\n const secondArg = id[1];\n // previously, the synopsis of this command was `bit tag [id] [version]`, show a descriptive\n // error when users still use it.\n if (semver.valid(secondArg)) {\n throw new GeneralError(\n `seems like you entered a version as the second arg, this is not supported anymore, please use \"@\" sign or --ver flag instead`\n );\n }\n }\n const disableTagAndSnapPipelines = disableTagPipeline || disableDeployPipeline;\n if (disableTagAndSnapPipelines && forceDeploy) {\n throw new GeneralError('you can use either force-deploy or disable-tag-pipeline, but not both');\n }\n if (all && persist) {\n throw new GeneralError('you can use either --all or --persist, but not both');\n }\n if (editor && persist) {\n throw new GeneralError('you can use either --editor or --persist, but not both');\n }\n if (editor && message) {\n throw new GeneralError('you can use either --editor or --message, but not both');\n }\n\n const releaseFlags = [patch, minor, major, preRelease].filter((x) => x);\n if (releaseFlags.length > 1) {\n throw new GeneralError('you can use only one of the following - patch, minor, major, pre-release');\n }\n\n let releaseType: ReleaseType = DEFAULT_BIT_RELEASE_TYPE;\n const includeImported = Boolean(scope && all);\n\n if (major) releaseType = 'major';\n else if (minor) releaseType = 'minor';\n else if (patch) releaseType = 'patch';\n else if (preRelease) releaseType = 'prerelease';\n\n const params = {\n ids: id,\n all: Boolean(all),\n snapped: Boolean(snapped),\n editor,\n message,\n exactVersion: getVersion(),\n releaseType,\n preRelease: typeof preRelease === 'string' ? preRelease : '',\n force,\n verbose,\n ignoreIssues,\n ignoreNewestVersion,\n skipTests,\n skipAutoTag,\n build,\n soft,\n persist,\n scope,\n includeImported,\n disableTagAndSnapPipelines,\n forceDeploy,\n incrementBy,\n };\n\n const results = await tagAction(params);\n if (!results) return chalk.yellow(NOTHING_TO_TAG_MSG);\n const { taggedComponents, autoTaggedResults, warnings, newComponents }: TagResults = results;\n const changedComponents = taggedComponents.filter((component) => !newComponents.searchWithoutVersion(component.id));\n const addedComponents = taggedComponents.filter((component) => newComponents.searchWithoutVersion(component.id));\n const autoTaggedCount = autoTaggedResults ? autoTaggedResults.length : 0;\n\n const warningsOutput = warnings && warnings.length ? `${chalk.yellow(warnings.join('\\n'))}\\n\\n` : '';\n const tagExplanationPersist = `\\n(use \"bit export [collection]\" to push these components to a remote\")\n(use \"bit untag\" to unstage versions)\\n`;\n const tagExplanationSoft = `\\n(use \"bit tag --persist\" to persist the changes\")\n(use \"bit untag --soft\" to remove the soft-tags)\\n`;\n\n const tagExplanation = results.isSoftTag ? tagExplanationSoft : tagExplanationPersist;\n\n const outputComponents = (comps) => {\n return comps\n .map((component) => {\n let componentOutput = ` > ${component.id.toString()}`;\n const autoTag = autoTaggedResults.filter((result) =>\n result.triggeredBy.searchWithoutScopeAndVersion(component.id)\n );\n if (autoTag.length) {\n const autoTagComp = autoTag.map((a) => a.component.id.toString());\n componentOutput += `\\n ${AUTO_TAGGED_MSG}:\n ${autoTagComp.join('\\n ')}`;\n }\n return componentOutput;\n })\n .join('\\n');\n };\n\n const publishOutput = () => {\n const { publishedPackages } = results;\n if (!publishedPackages || !publishedPackages.length) return '';\n const successTitle = `\\n\\n${chalk.green(\n `published the following ${publishedPackages.length} component(s) successfully\\n`\n )}`;\n const successCompsStr = publishedPackages.join('\\n');\n const successOutput = successCompsStr ? successTitle + successCompsStr : '';\n return successOutput;\n };\n\n const softTagPrefix = results.isSoftTag ? 'soft-tagged ' : '';\n const outputIfExists = (label, explanation, components) => {\n if (!components.length) return '';\n return `\\n${chalk.underline(softTagPrefix + label)}\\n(${explanation})\\n${outputComponents(components)}\\n`;\n };\n\n const newDesc = results.isSoftTag\n ? 'set to be tagged first version for components'\n : 'first version for components';\n const changedDesc = results.isSoftTag\n ? 'components that set to get a version bump'\n : 'components that got a version bump';\n const softTagClarification = results.isSoftTag\n ? chalk.bold(\n 'keep in mind that this is a soft-tag (changes recorded to be tagged), to persist the changes use --persist flag'\n )\n : '';\n return (\n warningsOutput +\n chalk.green(\n `${taggedComponents.length + autoTaggedCount} component(s) ${results.isSoftTag ? 'soft-' : ''}tagged`\n ) +\n tagExplanation +\n outputIfExists('new components', newDesc, addedComponents) +\n outputIfExists('changed components', changedDesc, changedComponents) +\n publishOutput() +\n softTagClarification\n );\n }\n}\n"]}
@@ -250,6 +250,7 @@ export declare class Workspace implements ComponentFactory {
250
250
  */
251
251
  load(ids: Array<BitId | string>): Promise<ResolvedComponent[]>;
252
252
  createAspectList(extensionDataList: ExtensionDataList): Promise<AspectList>;
253
+ private extensionDataEntryToAspectEntry;
253
254
  /**
254
255
  * get a component from workspace
255
256
  * @param id component ID
@@ -274,6 +275,9 @@ export declare class Workspace implements ComponentFactory {
274
275
  } | null>;
275
276
  getDefaultExtensions(): ExtensionDataList;
276
277
  ejectConfig(id: ComponentID, options: EjectConfOptions): Promise<EjectConfResult>;
278
+ /**
279
+ * see component-aspect, createAspectListFromLegacy() method for a context why this is needed.
280
+ */
277
281
  private resolveScopeAspectListIds;
278
282
  /**
279
283
  * load components into the workspace through a variants pattern.
@@ -285,7 +289,7 @@ export declare class Workspace implements ComponentFactory {
285
289
  * get component-ids matching the given pattern. a pattern can have multiple patterns separated by a comma.
286
290
  * it supports negate (!) character to exclude ids.
287
291
  */
288
- idsByPattern(pattern: string): Promise<ComponentID[]>;
292
+ idsByPattern(pattern: string, throwForNoMatch?: boolean): Promise<ComponentID[]>;
289
293
  /**
290
294
  * useful for workspace commands, such as `bit build`, `bit compile`.
291
295
  * by default, it should be running on new and modified components.
@@ -293,6 +297,7 @@ export declare class Workspace implements ComponentFactory {
293
297
  * some commands such as build/test needs to run also on the dependents.
294
298
  */
295
299
  getComponentsByUserInput(all?: boolean, pattern?: string, includeDependents?: boolean): Promise<Component[]>;
300
+ getComponentsUsingEnv(env: string, throwIfNotFound?: boolean): Promise<Component[]>;
296
301
  getMany(ids: Array<ComponentID>, forCapsule?: boolean): Promise<Component[]>;
297
302
  getManyByLegacy(components: ConsumerComponent[]): Promise<Component[]>;
298
303
  /**
@@ -379,6 +384,9 @@ export declare class Workspace implements ComponentFactory {
379
384
  }>;
380
385
  private filterEnvsFromExtensionsIfNeeded;
381
386
  triggerOnPreWatch(componentIds: ComponentID[], watchOpts: WatchOptions): Promise<void>;
387
+ addSpecificComponentConfig(id: ComponentID, aspectId: string, config?: Record<string, any>): Promise<void>;
388
+ removeSpecificComponentConfig(id: ComponentID, aspectId: string, markWithMinusIfNotExist: boolean): Promise<void>;
389
+ getSpecificComponentConfig(id: ComponentID, aspectId: string): Promise<any>;
382
390
  /**
383
391
  * This will mutate the entries with extensionId prop to have resolved legacy id
384
392
  * This should be worked on the extension data list not the new aspect list
@@ -397,7 +405,7 @@ export declare class Workspace implements ComponentFactory {
397
405
  * load aspects from the workspace and if not exists in the workspace, load from the scope.
398
406
  * keep in mind that the graph may have circles.
399
407
  */
400
- loadAspects(ids?: string[], throwOnError?: boolean): Promise<string[]>;
408
+ loadAspects(ids?: string[], throwOnError?: boolean, neededFor?: ComponentID): Promise<string[]>;
401
409
  /**
402
410
  * Note - this gets called from Harmony only.
403
411
  * returns one graph that includes all dependencies types. each edge has a label of the dependency
@@ -411,7 +419,7 @@ export declare class Workspace implements ComponentFactory {
411
419
  * Load all unloaded extensions from a list
412
420
  * @param extensions list of extensions with config to load
413
421
  */
414
- loadExtensions(extensions: ExtensionDataList, throwOnError?: boolean): Promise<void>;
422
+ loadExtensions(extensions: ExtensionDataList, originatedFrom?: ComponentID, throwOnError?: boolean): Promise<void>;
415
423
  /**
416
424
  * Provides a cache folder, unique per key.
417
425
  * Return value may be undefined, if workspace folder is unconventional (bare-scope, no node_modules, etc)