@teambit/generator 0.0.593 → 0.0.594

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.
@@ -19,6 +19,7 @@ export declare class ComponentGenerator {
19
19
  generate(): Promise<GenerateResult[]>;
20
20
  private deleteGeneratedComponents;
21
21
  private generateOneComponent;
22
+ private addEnvIfProvidedByUser;
22
23
  private removeOtherEnvs;
23
24
  /**
24
25
  * writes the generated template files to the default directory set in the workspace config
@@ -173,7 +173,7 @@ class ComponentGenerator {
173
173
  componentId
174
174
  });
175
175
  const mainFile = files.find(file => file.isMain);
176
- const config = this.template.config;
176
+ const config = this.addEnvIfProvidedByUser(this.template.config);
177
177
  await this.writeComponentFiles(componentPath, files);
178
178
  const addResults = await this.workspace.track({
179
179
  rootDir: componentPath,
@@ -193,10 +193,34 @@ class ComponentGenerator {
193
193
  };
194
194
  }
195
195
 
196
+ addEnvIfProvidedByUser(config) {
197
+ var _config, _config$EnvsAspect$id;
198
+
199
+ const userEnv = this.options.env; // env entered by the user when running `bit create --env`
200
+
201
+ const templateEnv = (_config = config) === null || _config === void 0 ? void 0 : (_config$EnvsAspect$id = _config[_envs().default.id]) === null || _config$EnvsAspect$id === void 0 ? void 0 : _config$EnvsAspect$id.env;
202
+
203
+ if (!userEnv || userEnv === templateEnv) {
204
+ return config;
205
+ }
206
+
207
+ config = config || {};
208
+
209
+ if (templateEnv) {
210
+ // the component template has an env and the user wants a different env.
211
+ delete config[templateEnv];
212
+ }
213
+
214
+ config[userEnv] = {};
215
+ config[_envs().default.id] = config[_envs().default.id] || {};
216
+ config[_envs().default.id].env = userEnv;
217
+ return config;
218
+ }
219
+
196
220
  async removeOtherEnvs(component, env, config) {
197
- var _config$EnvsAspect$id;
221
+ var _config$EnvsAspect$id2;
198
222
 
199
- const envFromTemplate = config === null || config === void 0 ? void 0 : (_config$EnvsAspect$id = config[_envs().default.id]) === null || _config$EnvsAspect$id === void 0 ? void 0 : _config$EnvsAspect$id.env;
223
+ const envFromTemplate = config === null || config === void 0 ? void 0 : (_config$EnvsAspect$id2 = config[_envs().default.id]) === null || _config$EnvsAspect$id2 === void 0 ? void 0 : _config$EnvsAspect$id2.env;
200
224
 
201
225
  if (!envFromTemplate) {
202
226
  return;
@@ -1 +1 @@
1
- {"version":3,"sources":["component-generator.ts"],"names":["ComponentGenerator","constructor","workspace","componentIds","options","template","envs","generate","dirsToDeleteIfFailed","generateResults","componentId","componentPath","getComponentPath","fs","existsSync","path","join","BitError","hasName","fullName","push","generateOneComponent","err","deleteGeneratedComponents","bitMap","write","dirs","Promise","all","map","dir","absoluteDir","remove","code","name","namePascalCase","pascalCase","nameCamelCase","files","generateFiles","mainFile","find","file","isMain","config","writeComponentFiles","addResults","track","rootDir","relativePath","componentName","defaultScope","scope","component","get","env","getEnv","removeOtherEnvs","id","envId","envFromTemplate","EnvsAspect","envsNotFromConfig","getEnvsNotFromEnvsConfig","envDef","envsToRemove","filter","forEach","bitMapRecord","getBitmapEntry","templateFiles","dataToPersist","DataToPersist","vinylFiles","templateFile","templateFileVinyl","Vinyl","base","contents","Buffer","from","content","AbstractVinyl","fromVinyl","results","v","addManyFiles","addBasePath","persistAllToFS","_legacy","changeScope","defaultDirectory"],"mappings":";;;;;;;;;;;;;AAAA;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;;AAEA;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;AAA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MAAtB;AACD;AAED;AACF;AACA;;;AACmC,QAAnBC,mBAAmB,CAC/BlC,aAD+B,EAE/B2D,aAF+B,EAGC;AAChC,UAAMC,aAAa,GAAG,KAAIC,wBAAJ,GAAtB;AACA,UAAMC,UAAU,GAAGH,aAAa,CAACzC,GAAd,CAAmB6C,YAAD,IAAkB;AACrD,YAAMC,iBAAiB,GAAG,KAAIC,gBAAJ,EAAU;AAClCC,QAAAA,IAAI,EAAElE,aAD4B;AAElCI,QAAAA,IAAI,EAAEA,gBAAKC,IAAL,CAAUL,aAAV,EAAyB+D,YAAY,CAACzB,YAAtC,CAF4B;AAGlC6B,QAAAA,QAAQ,EAAEC,MAAM,CAACC,IAAP,CAAYN,YAAY,CAACO,OAAzB;AAHwB,OAAV,CAA1B;AAKA,aAAOC,yBAAcC,SAAd,CAAwBR,iBAAxB,CAAP;AACD,KAPkB,CAAnB;AAQA,UAAMS,OAAO,GAAGX,UAAU,CAAC5C,GAAX,CAAgBwD,CAAD,IAAOA,CAAC,CAACtE,IAAxB,CAAhB;AACAwD,IAAAA,aAAa,CAACe,YAAd,CAA2Bb,UAA3B;AACAF,IAAAA,aAAa,CAACgB,WAAd,CAA0B,KAAKrF,SAAL,CAAea,IAAzC;AACA,UAAMwD,aAAa,CAACiB,cAAd,EAAN;AACA,WAAOJ,OAAP;AACD;;AAEOxE,EAAAA,gBAAgB,CAACF,WAAD,EAA2B;AACjD,QAAI,KAAKN,OAAL,CAAaW,IAAjB,EAAuB,OAAO,KAAKX,OAAL,CAAaW,IAApB;AACvB,WAAO,kDAAqBL,WAAW,CAAC+E,OAAZ,CAAoBC,WAApB,CAAgChF,WAAW,CAAC0C,KAA5C,CAArB,EAAyE,KAAKlD,SAAL,CAAeyF,gBAAxF,CAAP;AACD;;AAnH6B","sourcesContent":["import Vinyl from 'vinyl';\nimport fs from 'fs-extra';\nimport pMapSeries from 'p-map-series';\nimport path from 'path';\nimport { Workspace } from '@teambit/workspace';\nimport EnvsAspect, { EnvDefinition, EnvsMain } from '@teambit/envs';\nimport { Component } from '@teambit/component';\nimport camelcase from 'camelcase';\nimport { BitError } from '@teambit/bit-error';\nimport { PathOsBasedRelative } from '@teambit/legacy/dist/utils/path';\nimport { AbstractVinyl } from '@teambit/legacy/dist/consumer/component/sources';\nimport DataToPersist from '@teambit/legacy/dist/consumer/component/sources/data-to-persist';\nimport { composeComponentPath } from '@teambit/legacy/dist/utils/bit/compose-component-path';\nimport { ComponentID } from '@teambit/component-id';\nimport { ComponentTemplate, ComponentFile, ComponentConfig } from './component-template';\nimport { CreateOptions } from './create.cmd';\n\nexport type GenerateResult = { id: ComponentID; dir: string; files: string[]; envId: string };\n\nexport class ComponentGenerator {\n constructor(\n private workspace: Workspace,\n private componentIds: ComponentID[],\n private options: CreateOptions,\n private template: ComponentTemplate,\n private envs: EnvsMain\n ) {}\n\n async generate(): Promise<GenerateResult[]> {\n const dirsToDeleteIfFailed: string[] = [];\n const generateResults = await pMapSeries(this.componentIds, async (componentId) => {\n try {\n const componentPath = this.getComponentPath(componentId);\n if (fs.existsSync(path.join(this.workspace.path, componentPath))) {\n throw new BitError(`unable to create a component at \"${componentPath}\", this path already exist`);\n }\n if (await this.workspace.hasName(componentId.fullName)) {\n throw new BitError(\n `unable to create a component \"${componentId.fullName}\", a component with the same name already exist`\n );\n }\n dirsToDeleteIfFailed.push(componentPath);\n return await this.generateOneComponent(componentId, componentPath);\n } catch (err: any) {\n await this.deleteGeneratedComponents(dirsToDeleteIfFailed);\n throw err;\n }\n });\n\n await this.workspace.bitMap.write();\n\n return generateResults;\n }\n\n private async deleteGeneratedComponents(dirs: string[]) {\n await Promise.all(\n dirs.map(async (dir) => {\n const absoluteDir = path.join(this.workspace.path, dir);\n try {\n await fs.remove(absoluteDir);\n } catch (err: any) {\n if (err.code !== 'ENOENT') {\n // if not exist, it's fine\n throw err;\n }\n }\n })\n );\n }\n\n private async generateOneComponent(componentId: ComponentID, componentPath: string): Promise<GenerateResult> {\n const name = componentId.name;\n const namePascalCase = camelcase(name, { pascalCase: true });\n const nameCamelCase = camelcase(name);\n const files = this.template.generateFiles({ name, namePascalCase, nameCamelCase, componentId });\n const mainFile = files.find((file) => file.isMain);\n const config = this.template.config;\n await this.writeComponentFiles(componentPath, files);\n const addResults = await this.workspace.track({\n rootDir: componentPath,\n mainFile: mainFile?.relativePath,\n componentName: componentId.fullName,\n defaultScope: this.options.scope,\n config,\n });\n const component = await this.workspace.get(componentId);\n const env = this.envs.getEnv(component);\n await this.removeOtherEnvs(component, env, config);\n return {\n id: componentId,\n dir: componentPath,\n files: addResults.files,\n envId: env.id,\n };\n }\n\n private async removeOtherEnvs(component: Component, env: EnvDefinition, config?: ComponentConfig) {\n const envFromTemplate = config?.[EnvsAspect.id]?.env;\n if (!envFromTemplate) {\n return;\n }\n const envsNotFromConfig = this.envs.getEnvsNotFromEnvsConfig(component).map((envDef) => envDef.id);\n const envsToRemove = envsNotFromConfig.filter((envId) => envId !== envFromTemplate);\n envsToRemove.forEach((envId) => (config[envId] = '-'));\n const bitMapRecord = this.workspace.bitMap.getBitmapEntry(component.id);\n bitMapRecord.config = config;\n }\n\n /**\n * writes the generated template files to the default directory set in the workspace config\n */\n private async writeComponentFiles(\n componentPath: string,\n templateFiles: ComponentFile[]\n ): Promise<PathOsBasedRelative[]> {\n const dataToPersist = new DataToPersist();\n const vinylFiles = templateFiles.map((templateFile) => {\n const templateFileVinyl = new Vinyl({\n base: componentPath,\n path: path.join(componentPath, templateFile.relativePath),\n contents: Buffer.from(templateFile.content),\n });\n return AbstractVinyl.fromVinyl(templateFileVinyl);\n });\n const results = vinylFiles.map((v) => v.path);\n dataToPersist.addManyFiles(vinylFiles);\n dataToPersist.addBasePath(this.workspace.path);\n await dataToPersist.persistAllToFS();\n return results;\n }\n\n private getComponentPath(componentId: ComponentID) {\n if (this.options.path) return this.options.path;\n return composeComponentPath(componentId._legacy.changeScope(componentId.scope), this.workspace.defaultDirectory);\n }\n}\n"]}
1
+ {"version":3,"sources":["component-generator.ts"],"names":["ComponentGenerator","constructor","workspace","componentIds","options","template","envs","generate","dirsToDeleteIfFailed","generateResults","componentId","componentPath","getComponentPath","fs","existsSync","path","join","BitError","hasName","fullName","push","generateOneComponent","err","deleteGeneratedComponents","bitMap","write","dirs","Promise","all","map","dir","absoluteDir","remove","code","name","namePascalCase","pascalCase","nameCamelCase","files","generateFiles","mainFile","find","file","isMain","config","addEnvIfProvidedByUser","writeComponentFiles","addResults","track","rootDir","relativePath","componentName","defaultScope","scope","component","get","env","getEnv","removeOtherEnvs","id","envId","userEnv","templateEnv","EnvsAspect","envFromTemplate","envsNotFromConfig","getEnvsNotFromEnvsConfig","envDef","envsToRemove","filter","forEach","bitMapRecord","getBitmapEntry","templateFiles","dataToPersist","DataToPersist","vinylFiles","templateFile","templateFileVinyl","Vinyl","base","contents","Buffer","from","content","AbstractVinyl","fromVinyl","results","v","addManyFiles","addBasePath","persistAllToFS","_legacy","changeScope","defaultDirectory"],"mappings":";;;;;;;;;;;;;AAAA;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;;AAEA;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;;AAOO,MAAMA,kBAAN,CAAyB;AAC9BC,EAAAA,WAAW,CACDC,SADC,EAEDC,YAFC,EAGDC,OAHC,EAIDC,QAJC,EAKDC,IALC,EAMT;AAAA,SALQJ,SAKR,GALQA,SAKR;AAAA,SAJQC,YAIR,GA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,YAAd,CAA2Bb,UAA3B;AACAF,IAAAA,aAAa,CAACgB,WAAd,CAA0B,KAAKxF,SAAL,CAAea,IAAzC;AACA,UAAM2D,aAAa,CAACiB,cAAd,EAAN;AACA,WAAOJ,OAAP;AACD;;AAEO3E,EAAAA,gBAAgB,CAACF,WAAD,EAA2B;AACjD,QAAI,KAAKN,OAAL,CAAaW,IAAjB,EAAuB,OAAO,KAAKX,OAAL,CAAaW,IAApB;AACvB,WAAO,kDAAqBL,WAAW,CAACkF,OAAZ,CAAoBC,WAApB,CAAgCnF,WAAW,CAAC2C,KAA5C,CAArB,EAAyE,KAAKnD,SAAL,CAAe4F,gBAAxF,CAAP;AACD;;AApI6B","sourcesContent":["import Vinyl from 'vinyl';\nimport fs from 'fs-extra';\nimport pMapSeries from 'p-map-series';\nimport path from 'path';\nimport { Workspace } from '@teambit/workspace';\nimport EnvsAspect, { EnvDefinition, EnvsMain } from '@teambit/envs';\nimport { Component } from '@teambit/component';\nimport camelcase from 'camelcase';\nimport { BitError } from '@teambit/bit-error';\nimport { PathOsBasedRelative } from '@teambit/legacy/dist/utils/path';\nimport { AbstractVinyl } from '@teambit/legacy/dist/consumer/component/sources';\nimport DataToPersist from '@teambit/legacy/dist/consumer/component/sources/data-to-persist';\nimport { composeComponentPath } from '@teambit/legacy/dist/utils/bit/compose-component-path';\nimport { ComponentID } from '@teambit/component-id';\nimport { ComponentTemplate, ComponentFile, ComponentConfig } from './component-template';\nimport { CreateOptions } from './create.cmd';\n\nexport type GenerateResult = { id: ComponentID; dir: string; files: string[]; envId: string };\n\nexport class ComponentGenerator {\n constructor(\n private workspace: Workspace,\n private componentIds: ComponentID[],\n private options: CreateOptions,\n private template: ComponentTemplate,\n private envs: EnvsMain\n ) {}\n\n async generate(): Promise<GenerateResult[]> {\n const dirsToDeleteIfFailed: string[] = [];\n const generateResults = await pMapSeries(this.componentIds, async (componentId) => {\n try {\n const componentPath = this.getComponentPath(componentId);\n if (fs.existsSync(path.join(this.workspace.path, componentPath))) {\n throw new BitError(`unable to create a component at \"${componentPath}\", this path already exist`);\n }\n if (await this.workspace.hasName(componentId.fullName)) {\n throw new BitError(\n `unable to create a component \"${componentId.fullName}\", a component with the same name already exist`\n );\n }\n dirsToDeleteIfFailed.push(componentPath);\n return await this.generateOneComponent(componentId, componentPath);\n } catch (err: any) {\n await this.deleteGeneratedComponents(dirsToDeleteIfFailed);\n throw err;\n }\n });\n\n await this.workspace.bitMap.write();\n\n return generateResults;\n }\n\n private async deleteGeneratedComponents(dirs: string[]) {\n await Promise.all(\n dirs.map(async (dir) => {\n const absoluteDir = path.join(this.workspace.path, dir);\n try {\n await fs.remove(absoluteDir);\n } catch (err: any) {\n if (err.code !== 'ENOENT') {\n // if not exist, it's fine\n throw err;\n }\n }\n })\n );\n }\n\n private async generateOneComponent(componentId: ComponentID, componentPath: string): Promise<GenerateResult> {\n const name = componentId.name;\n const namePascalCase = camelcase(name, { pascalCase: true });\n const nameCamelCase = camelcase(name);\n const files = this.template.generateFiles({ name, namePascalCase, nameCamelCase, componentId });\n const mainFile = files.find((file) => file.isMain);\n const config = this.addEnvIfProvidedByUser(this.template.config);\n await this.writeComponentFiles(componentPath, files);\n const addResults = await this.workspace.track({\n rootDir: componentPath,\n mainFile: mainFile?.relativePath,\n componentName: componentId.fullName,\n defaultScope: this.options.scope,\n config,\n });\n const component = await this.workspace.get(componentId);\n const env = this.envs.getEnv(component);\n await this.removeOtherEnvs(component, env, config);\n return {\n id: componentId,\n dir: componentPath,\n files: addResults.files,\n envId: env.id,\n };\n }\n\n private addEnvIfProvidedByUser(config?: ComponentConfig): ComponentConfig | undefined {\n const userEnv = this.options.env; // env entered by the user when running `bit create --env`\n const templateEnv = config?.[EnvsAspect.id]?.env;\n if (!userEnv || userEnv === templateEnv) {\n return config;\n }\n config = config || {};\n if (templateEnv) {\n // the component template has an env and the user wants a different env.\n delete config[templateEnv];\n }\n config[userEnv] = {};\n config[EnvsAspect.id] = config[EnvsAspect.id] || {};\n config[EnvsAspect.id].env = userEnv;\n return config;\n }\n\n private async removeOtherEnvs(component: Component, env: EnvDefinition, config?: ComponentConfig) {\n const envFromTemplate = config?.[EnvsAspect.id]?.env;\n if (!envFromTemplate) {\n return;\n }\n const envsNotFromConfig = this.envs.getEnvsNotFromEnvsConfig(component).map((envDef) => envDef.id);\n const envsToRemove = envsNotFromConfig.filter((envId) => envId !== envFromTemplate);\n envsToRemove.forEach((envId) => (config[envId] = '-'));\n const bitMapRecord = this.workspace.bitMap.getBitmapEntry(component.id);\n bitMapRecord.config = config;\n }\n\n /**\n * writes the generated template files to the default directory set in the workspace config\n */\n private async writeComponentFiles(\n componentPath: string,\n templateFiles: ComponentFile[]\n ): Promise<PathOsBasedRelative[]> {\n const dataToPersist = new DataToPersist();\n const vinylFiles = templateFiles.map((templateFile) => {\n const templateFileVinyl = new Vinyl({\n base: componentPath,\n path: path.join(componentPath, templateFile.relativePath),\n contents: Buffer.from(templateFile.content),\n });\n return AbstractVinyl.fromVinyl(templateFileVinyl);\n });\n const results = vinylFiles.map((v) => v.path);\n dataToPersist.addManyFiles(vinylFiles);\n dataToPersist.addBasePath(this.workspace.path);\n await dataToPersist.persistAllToFS();\n return results;\n }\n\n private getComponentPath(componentId: ComponentID) {\n if (this.options.path) return this.options.path;\n return composeComponentPath(componentId._legacy.changeScope(componentId.scope), this.workspace.defaultDirectory);\n }\n}\n"]}
@@ -5,6 +5,7 @@ export declare type CreateOptions = {
5
5
  aspect?: string;
6
6
  scope?: string;
7
7
  path?: string;
8
+ env?: string;
8
9
  };
9
10
  export declare class CreateCmd implements Command {
10
11
  private generator;
@@ -40,7 +40,7 @@ class CreateCmd {
40
40
  (0, _defineProperty2().default)(this, "alias", '');
41
41
  (0, _defineProperty2().default)(this, "loader", true);
42
42
  (0, _defineProperty2().default)(this, "group", 'development');
43
- (0, _defineProperty2().default)(this, "options", [['n', 'namespace <string>', `sets the component's namespace and nested dirs inside the scope`], ['s', 'scope <string>', `sets the component's scope-name. if not entered, the default-scope will be used`], ['a', 'aspect <string>', 'aspect-id of the template. helpful when multiple aspects use the same template name'], ['p', 'path <string>', 'relative path in the workspace. by default the path is `<scope>/<namespace>/<name>`']]);
43
+ (0, _defineProperty2().default)(this, "options", [['n', 'namespace <string>', `sets the component's namespace and nested dirs inside the scope`], ['s', 'scope <string>', `sets the component's scope-name. if not entered, the default-scope will be used`], ['a', 'aspect <string>', 'aspect-id of the template. helpful when multiple aspects use the same template name'], ['p', 'path <string>', 'relative path in the workspace. by default the path is `<scope>/<namespace>/<name>`'], ['e', 'env <string>', "set the component's environment. (overrides the env from variants and the template)"]]);
44
44
  }
45
45
 
46
46
  async report([templateName, componentNames], options) {
@@ -52,7 +52,7 @@ class CreateCmd {
52
52
  env: ${result.envId}
53
53
  `;
54
54
  }).join('\n');
55
- const footer = `env configuration is according to workspace variants or the template config learn more at https://harmony-docs.bit.dev/building-with-bit/environments/#configure-environment-for-components`;
55
+ const footer = `env configuration is according to workspace variants, template config or --env flag. learn more at https://harmony-docs.bit.dev/building-with-bit/environments/#configure-environment-for-components`;
56
56
  return `${_chalk().default.green(title)}\n\n${componentsData}\n\n${footer}`;
57
57
  }
58
58
 
@@ -1 +1 @@
1
- {"version":3,"sources":["create.cmd.ts"],"names":["CreateCmd","constructor","generator","report","templateName","componentNames","options","results","generateComponentTemplate","title","length","componentsData","map","result","chalk","bold","id","toString","dir","envId","join","footer","green"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAUO,MAAMA,SAAN,CAAmC;AAcxCC,EAAAA,WAAW,CAASC,SAAT,EAAmC;AAAA,SAA1BA,SAA0B,GAA1BA,SAA0B;AAAA,kDAbvC,2CAauC;AAAA,yDAZhC,wCAYgC;AAAA,8DAX3B,EAW2B;AAAA,mDAVtC,EAUsC;AAAA,oDATrC,IASqC;AAAA,mDARtC,aAQsC;AAAA,qDAPpC,CACR,CAAC,GAAD,EAAM,oBAAN,EAA6B,iEAA7B,CADQ,EAER,CAAC,GAAD,EAAM,gBAAN,EAAyB,iFAAzB,CAFQ,EAGR,CAAC,GAAD,EAAM,iBAAN,EAAyB,qFAAzB,CAHQ,EAIR,CAAC,GAAD,EAAM,eAAN,EAAuB,qFAAvB,CAJQ,CAOoC;AAAE;;AAEpC,QAANC,MAAM,CAAC,CAACC,YAAD,EAAeC,cAAf,CAAD,EAAqDC,OAArD,EAA6E;AACvF,UAAMC,OAAO,GAAG,MAAM,KAAKL,SAAL,CAAeM,yBAAf,CAAyCH,cAAzC,EAAyDD,YAAzD,EAAuEE,OAAvE,CAAtB;AACA,UAAMG,KAAK,GAAI,GAAEF,OAAO,CAACG,MAAO,4BAAhC;AAEA,UAAMC,cAAc,GAAGJ,OAAO,CAC3BK,GADoB,CACfC,MAAD,IAAY;AACf,aAAQ,GAAEC,iBAAMC,IAAN,CAAWF,MAAM,CAACG,EAAP,CAAUC,QAAV,EAAX,CAAiC;AACnD,gBAAgBJ,MAAM,CAACK,GAAI;AAC3B,gBAAgBL,MAAM,CAACM,KAAM;AAC7B,CAHQ;AAID,KANoB,EAOpBC,IAPoB,CAOf,IAPe,CAAvB;AAQA,UAAMC,MAAM,GAAI,6LAAhB;AAEA,WAAQ,GAAEP,iBAAMQ,KAAN,CAAYb,KAAZ,CAAmB,OAAME,cAAe,OAAMU,MAAO,EAA/D;AACD;;AA/BuC","sourcesContent":["import { Command, CommandOptions } from '@teambit/cli';\nimport chalk from 'chalk';\nimport { GeneratorMain } from './generator.main.runtime';\n\nexport type CreateOptions = {\n namespace?: string;\n aspect?: string;\n scope?: string;\n path?: string;\n};\n\nexport class CreateCmd implements Command {\n name = 'create <templateName> <componentNames...>';\n description = 'create a new component from a template';\n shortDescription = '';\n alias = '';\n loader = true;\n group = 'development';\n options = [\n ['n', 'namespace <string>', `sets the component's namespace and nested dirs inside the scope`],\n ['s', 'scope <string>', `sets the component's scope-name. if not entered, the default-scope will be used`],\n ['a', 'aspect <string>', 'aspect-id of the template. helpful when multiple aspects use the same template name'],\n ['p', 'path <string>', 'relative path in the workspace. by default the path is `<scope>/<namespace>/<name>`'],\n ] as CommandOptions;\n\n constructor(private generator: GeneratorMain) {}\n\n async report([templateName, componentNames]: [string, string[]], options: CreateOptions) {\n const results = await this.generator.generateComponentTemplate(componentNames, templateName, options);\n const title = `${results.length} component(s) were created`;\n\n const componentsData = results\n .map((result) => {\n return `${chalk.bold(result.id.toString())}\n location: ${result.dir}\n env: ${result.envId}\n`;\n })\n .join('\\n');\n const footer = `env configuration is according to workspace variants or the template config learn more at https://harmony-docs.bit.dev/building-with-bit/environments/#configure-environment-for-components`;\n\n return `${chalk.green(title)}\\n\\n${componentsData}\\n\\n${footer}`;\n }\n}\n"]}
1
+ {"version":3,"sources":["create.cmd.ts"],"names":["CreateCmd","constructor","generator","report","templateName","componentNames","options","results","generateComponentTemplate","title","length","componentsData","map","result","chalk","bold","id","toString","dir","envId","join","footer","green"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAWO,MAAMA,SAAN,CAAmC;AAexCC,EAAAA,WAAW,CAASC,SAAT,EAAmC;AAAA,SAA1BA,SAA0B,GAA1BA,SAA0B;AAAA,kDAdvC,2CAcuC;AAAA,yDAbhC,wCAagC;AAAA,8DAZ3B,EAY2B;AAAA,mDAXtC,EAWsC;AAAA,oDAVrC,IAUqC;AAAA,mDATtC,aASsC;AAAA,qDARpC,CACR,CAAC,GAAD,EAAM,oBAAN,EAA6B,iEAA7B,CADQ,EAER,CAAC,GAAD,EAAM,gBAAN,EAAyB,iFAAzB,CAFQ,EAGR,CAAC,GAAD,EAAM,iBAAN,EAAyB,qFAAzB,CAHQ,EAIR,CAAC,GAAD,EAAM,eAAN,EAAuB,qFAAvB,CAJQ,EAKR,CAAC,GAAD,EAAM,cAAN,EAAsB,qFAAtB,CALQ,CAQoC;AAAE;;AAEpC,QAANC,MAAM,CAAC,CAACC,YAAD,EAAeC,cAAf,CAAD,EAAqDC,OAArD,EAA6E;AACvF,UAAMC,OAAO,GAAG,MAAM,KAAKL,SAAL,CAAeM,yBAAf,CAAyCH,cAAzC,EAAyDD,YAAzD,EAAuEE,OAAvE,CAAtB;AACA,UAAMG,KAAK,GAAI,GAAEF,OAAO,CAACG,MAAO,4BAAhC;AAEA,UAAMC,cAAc,GAAGJ,OAAO,CAC3BK,GADoB,CACfC,MAAD,IAAY;AACf,aAAQ,GAAEC,iBAAMC,IAAN,CAAWF,MAAM,CAACG,EAAP,CAAUC,QAAV,EAAX,CAAiC;AACnD,gBAAgBJ,MAAM,CAACK,GAAI;AAC3B,gBAAgBL,MAAM,CAACM,KAAM;AAC7B,CAHQ;AAID,KANoB,EAOpBC,IAPoB,CAOf,IAPe,CAAvB;AAQA,UAAMC,MAAM,GAAI,sMAAhB;AAEA,WAAQ,GAAEP,iBAAMQ,KAAN,CAAYb,KAAZ,CAAmB,OAAME,cAAe,OAAMU,MAAO,EAA/D;AACD;;AAhCuC","sourcesContent":["import { Command, CommandOptions } from '@teambit/cli';\nimport chalk from 'chalk';\nimport { GeneratorMain } from './generator.main.runtime';\n\nexport type CreateOptions = {\n namespace?: string;\n aspect?: string;\n scope?: string;\n path?: string;\n env?: string;\n};\n\nexport class CreateCmd implements Command {\n name = 'create <templateName> <componentNames...>';\n description = 'create a new component from a template';\n shortDescription = '';\n alias = '';\n loader = true;\n group = 'development';\n options = [\n ['n', 'namespace <string>', `sets the component's namespace and nested dirs inside the scope`],\n ['s', 'scope <string>', `sets the component's scope-name. if not entered, the default-scope will be used`],\n ['a', 'aspect <string>', 'aspect-id of the template. helpful when multiple aspects use the same template name'],\n ['p', 'path <string>', 'relative path in the workspace. by default the path is `<scope>/<namespace>/<name>`'],\n ['e', 'env <string>', \"set the component's environment. (overrides the env from variants and the template)\"],\n ] as CommandOptions;\n\n constructor(private generator: GeneratorMain) {}\n\n async report([templateName, componentNames]: [string, string[]], options: CreateOptions) {\n const results = await this.generator.generateComponentTemplate(componentNames, templateName, options);\n const title = `${results.length} component(s) were created`;\n\n const componentsData = results\n .map((result) => {\n return `${chalk.bold(result.id.toString())}\n location: ${result.dir}\n env: ${result.envId}\n`;\n })\n .join('\\n');\n const footer = `env configuration is according to workspace variants, template config or --env flag. learn more at https://harmony-docs.bit.dev/building-with-bit/environments/#configure-environment-for-components`;\n\n return `${chalk.green(title)}\\n\\n${componentsData}\\n\\n${footer}`;\n }\n}\n"]}
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@teambit/generator",
3
- "version": "0.0.593",
3
+ "version": "0.0.594",
4
4
  "homepage": "https://bit.dev/teambit/generator/generator",
5
5
  "main": "dist/index.js",
6
6
  "componentId": {
7
7
  "scope": "teambit.generator",
8
8
  "name": "generator",
9
- "version": "0.0.593"
9
+ "version": "0.0.594"
10
10
  },
11
11
  "dependencies": {
12
12
  "camelcase": "6.2.0",
@@ -21,21 +21,21 @@
21
21
  "isbinaryfile": "4.0.6",
22
22
  "@babel/runtime": "7.12.18",
23
23
  "core-js": "^3.0.0",
24
- "@teambit/bit-error": "0.0.393",
25
- "@teambit/component-id": "0.0.397",
26
- "@teambit/component": "0.0.593",
27
- "@teambit/envs": "0.0.593",
28
- "@teambit/workspace": "0.0.593",
29
- "@teambit/cli": "0.0.407",
30
- "@teambit/graphql": "0.0.593",
31
- "@teambit/aspect-loader": "0.0.593",
32
- "@teambit/bit": "0.0.595",
33
- "@teambit/legacy-bit-id": "0.0.396",
34
- "@teambit/compiler": "0.0.593",
35
- "@teambit/dependency-resolver": "0.0.593",
36
- "@teambit/logger": "0.0.495",
37
- "@teambit/pkg": "0.0.593",
38
- "@teambit/ui": "0.0.593"
24
+ "@teambit/bit-error": "0.0.394",
25
+ "@teambit/component-id": "0.0.398",
26
+ "@teambit/component": "0.0.594",
27
+ "@teambit/envs": "0.0.594",
28
+ "@teambit/workspace": "0.0.594",
29
+ "@teambit/cli": "0.0.408",
30
+ "@teambit/graphql": "0.0.594",
31
+ "@teambit/aspect-loader": "0.0.594",
32
+ "@teambit/bit": "0.0.596",
33
+ "@teambit/legacy-bit-id": "0.0.397",
34
+ "@teambit/compiler": "0.0.594",
35
+ "@teambit/dependency-resolver": "0.0.594",
36
+ "@teambit/logger": "0.0.496",
37
+ "@teambit/pkg": "0.0.594",
38
+ "@teambit/ui": "0.0.594"
39
39
  },
40
40
  "devDependencies": {
41
41
  "@types/fs-extra": "9.0.7",
@@ -46,10 +46,10 @@
46
46
  "@types/react-dom": "^17.0.5",
47
47
  "@types/react": "^17.0.8",
48
48
  "@types/node": "12.20.4",
49
- "@teambit/generator.aspect-docs.generator": "0.0.133"
49
+ "@teambit/generator.aspect-docs.generator": "0.0.134"
50
50
  },
51
51
  "peerDependencies": {
52
- "@teambit/legacy": "1.0.193",
52
+ "@teambit/legacy": "1.0.195",
53
53
  "react-dom": "^16.8.0 || ^17.0.0",
54
54
  "react": "^16.8.0 || ^17.0.0"
55
55
  },
@@ -77,7 +77,7 @@
77
77
  "react": "-"
78
78
  },
79
79
  "peerDependencies": {
80
- "@teambit/legacy": "1.0.193",
80
+ "@teambit/legacy": "1.0.195",
81
81
  "react-dom": "^16.8.0 || ^17.0.0",
82
82
  "react": "^16.8.0 || ^17.0.0"
83
83
  }