@teambit/generator 1.0.372 → 1.0.374

Sign up to get free protection for your applications and to get access to all the features.
@@ -78,6 +78,14 @@ export interface ComponentTemplateOptions {
78
78
  * name of the component template. for example: `hook`, `react-component` or `module`.
79
79
  */
80
80
  name?: string;
81
+ /**
82
+ * display name of the template.
83
+ */
84
+ displayName?: string;
85
+ /**
86
+ * example name for the component template.
87
+ */
88
+ exampleComponentName?: string;
81
89
  /**
82
90
  * short description of the template. shown in the `bit templates` command.
83
91
  */
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["component-template.ts"],"sourcesContent":["import { ComponentID } from '@teambit/component';\n\n/**\n * BaseComponentTemplateOptions describes the foundational properties for components.\n */\nexport interface BaseComponentTemplateOptions {\n /**\n * component-name as entered by the user, e.g. `use-date`.\n * without the scope and the namespace.\n */\n name: string;\n\n /**\n * component-name as upper camel case, e.g. `use-date` becomes `UseDate`.\n * useful when generating the file content, for example for a class name.\n */\n namePascalCase: string;\n\n /**\n * component-name as lower camel case, e.g. `use-date` becomes `useDate`.\n * useful when generating the file content, for example for a function/variable name.\n */\n nameCamelCase: string;\n\n /**\n * component id.\n * the name is the name+namespace. the scope is the scope entered by --scope flag or the defaultScope\n */\n componentId: ComponentID;\n\n /**\n * aspect id of the aspect that register the template itself\n */\n aspectId: ComponentID | string;\n\n /**\n * env id of the env that register the template itself.\n * This will be usually identical to the aspectId but aspectId will always exist,\n * while envId will be undefined if the template is not registered by an env.\n */\n envId?: ComponentID;\n\n /**\n * path of the component.\n */\n path?: string;\n /**\n * scope of the component.\n */\n scope?: string;\n /**\n * namespace of the component.\n */\n namespace?: string;\n}\n\n/**\n * ComponentContext represents foundational properties for a component context.\n */\nexport type ComponentContext = BaseComponentTemplateOptions;\n\nexport interface ComponentFile {\n /**\n * relative path of the file within the component.\n */\n relativePath: string;\n\n /**\n * file content\n */\n content: string;\n\n /**\n * whether this file will be tracked as the main file\n */\n isMain?: boolean;\n}\n\nexport interface ConfigContext {\n /**\n * Aspect id of the aspect that register the template itself\n */\n aspectId: string;\n}\n\nexport type ComponentConfig = { [aspectName: string]: any };\n\nexport interface ComponentTemplateOptions {\n /**\n * name of the component template. for example: `hook`, `react-component` or `module`.\n */\n name?: string;\n\n /**\n * short description of the template. shown in the `bit templates` command.\n */\n description?: string;\n\n /**\n * hide this template so that it is not listed with `bit templates`\n */\n hidden?: boolean;\n\n /**\n * env to use for the generated component.\n */\n env?: string;\n\n /**\n * adds a metadata that the component that this template creates is of type env.\n * This will be used later to do further configuration for example:\n * - ensure to create the .bit_root for it\n */\n isEnv?: boolean;\n\n /**\n * adds a metadata that the component that this template creates is of type app.\n * This will be used later to do further configuration for example:\n * - add it to the workspace.jsonc as app\n * - ensure to create the .bit_root for it\n */\n isApp?: boolean;\n\n /**\n * list of dependencies to install when the component is created.\n */\n dependencies?: string[];\n\n /**\n * Perform installation of missing dependencies after component generation.\n * This is the same as of running `bit install --add-missing-deps` after component generation.\n */\n installMissingDependencies?: boolean;\n}\n\nexport interface ComponentTemplate extends ComponentTemplateOptions {\n name: string;\n\n /**\n * template function for generating the file of a certain component.,\n */\n generateFiles(context: ComponentContext): Promise<ComponentFile[]> | ComponentFile[];\n\n /**\n * component config. gets saved in the .bitmap file and it overrides the workspace.jsonc config.\n * for example, you can set the env that will be used for this component as follows:\n * \"teambit.envs/envs\": {\n * \"env\": \"teambit.harmony/aspect\"\n * },\n */\n config?: ComponentConfig | ((context: ConfigContext) => ComponentConfig);\n}\n"],"mappings":"","ignoreList":[]}
1
+ {"version":3,"names":[],"sources":["component-template.ts"],"sourcesContent":["import { ComponentID } from '@teambit/component';\n\n/**\n * BaseComponentTemplateOptions describes the foundational properties for components.\n */\nexport interface BaseComponentTemplateOptions {\n /**\n * component-name as entered by the user, e.g. `use-date`.\n * without the scope and the namespace.\n */\n name: string;\n\n /**\n * component-name as upper camel case, e.g. `use-date` becomes `UseDate`.\n * useful when generating the file content, for example for a class name.\n */\n namePascalCase: string;\n\n /**\n * component-name as lower camel case, e.g. `use-date` becomes `useDate`.\n * useful when generating the file content, for example for a function/variable name.\n */\n nameCamelCase: string;\n\n /**\n * component id.\n * the name is the name+namespace. the scope is the scope entered by --scope flag or the defaultScope\n */\n componentId: ComponentID;\n\n /**\n * aspect id of the aspect that register the template itself\n */\n aspectId: ComponentID | string;\n\n /**\n * env id of the env that register the template itself.\n * This will be usually identical to the aspectId but aspectId will always exist,\n * while envId will be undefined if the template is not registered by an env.\n */\n envId?: ComponentID;\n\n /**\n * path of the component.\n */\n path?: string;\n /**\n * scope of the component.\n */\n scope?: string;\n /**\n * namespace of the component.\n */\n namespace?: string;\n}\n\n/**\n * ComponentContext represents foundational properties for a component context.\n */\nexport type ComponentContext = BaseComponentTemplateOptions;\n\nexport interface ComponentFile {\n /**\n * relative path of the file within the component.\n */\n relativePath: string;\n\n /**\n * file content\n */\n content: string;\n\n /**\n * whether this file will be tracked as the main file\n */\n isMain?: boolean;\n}\n\nexport interface ConfigContext {\n /**\n * Aspect id of the aspect that register the template itself\n */\n aspectId: string;\n}\n\nexport type ComponentConfig = { [aspectName: string]: any };\n\nexport interface ComponentTemplateOptions {\n /**\n * name of the component template. for example: `hook`, `react-component` or `module`.\n */\n name?: string;\n\n /**\n * display name of the template.\n */\n displayName?: string;\n\n /**\n * example name for the component template.\n */\n exampleComponentName?: string;\n\n /**\n * short description of the template. shown in the `bit templates` command.\n */\n description?: string;\n\n /**\n * hide this template so that it is not listed with `bit templates`\n */\n hidden?: boolean;\n\n /**\n * env to use for the generated component.\n */\n env?: string;\n\n /**\n * adds a metadata that the component that this template creates is of type env.\n * This will be used later to do further configuration for example:\n * - ensure to create the .bit_root for it\n */\n isEnv?: boolean;\n\n /**\n * adds a metadata that the component that this template creates is of type app.\n * This will be used later to do further configuration for example:\n * - add it to the workspace.jsonc as app\n * - ensure to create the .bit_root for it\n */\n isApp?: boolean;\n\n /**\n * list of dependencies to install when the component is created.\n */\n dependencies?: string[];\n\n /**\n * Perform installation of missing dependencies after component generation.\n * This is the same as of running `bit install --add-missing-deps` after component generation.\n */\n installMissingDependencies?: boolean;\n}\n\nexport interface ComponentTemplate extends ComponentTemplateOptions {\n name: string;\n\n /**\n * template function for generating the file of a certain component.,\n */\n generateFiles(context: ComponentContext): Promise<ComponentFile[]> | ComponentFile[];\n\n /**\n * component config. gets saved in the .bitmap file and it overrides the workspace.jsonc config.\n * for example, you can set the env that will be used for this component as follows:\n * \"teambit.envs/envs\": {\n * \"env\": \"teambit.harmony/aspect\"\n * },\n */\n config?: ComponentConfig | ((context: ConfigContext) => ComponentConfig);\n}\n"],"mappings":"","ignoreList":[]}
@@ -1,12 +1,20 @@
1
- import { EnvService, Env, EnvContext, ServiceTransformationMap } from '@teambit/envs';
2
- import { ComponentTemplate } from './component-template';
3
- import { WorkspaceTemplate } from './workspace-template';
1
+ import { EnvService, Env, EnvContext, ServiceTransformationMap, EnvDefinition } from '@teambit/envs';
2
+ import { ComponentTemplate, ComponentTemplateOptions } from './component-template';
3
+ import { WorkspaceTemplate, WorkspaceTemplateOptions } from './workspace-template';
4
4
  type GeneratorTransformationMap = ServiceTransformationMap & {
5
- getGeneratorTemplates: () => ComponentTemplate;
6
- getGeneratorStarters: () => WorkspaceTemplate;
5
+ getGeneratorTemplates: () => ComponentTemplate[];
6
+ getGeneratorStarters: () => WorkspaceTemplate[];
7
+ };
8
+ type Descriptor = {
9
+ templates?: ComponentTemplateOptions[];
10
+ starters?: WorkspaceTemplateOptions[];
7
11
  };
8
12
  export declare class GeneratorService implements EnvService<any> {
9
13
  name: string;
10
14
  transform(env: Env, context: EnvContext): GeneratorTransformationMap | undefined;
15
+ getDescriptor(env: EnvDefinition): Descriptor | undefined;
16
+ render(env: EnvDefinition): string;
17
+ private getTemplatesToRender;
18
+ private getStartersToRender;
11
19
  }
12
20
  export {};
@@ -4,6 +4,21 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.GeneratorService = void 0;
7
+ function _chalk() {
8
+ const data = _interopRequireDefault(require("chalk"));
9
+ _chalk = function () {
10
+ return data;
11
+ };
12
+ return data;
13
+ }
14
+ function _lodash() {
15
+ const data = require("lodash");
16
+ _lodash = function () {
17
+ return data;
18
+ };
19
+ return data;
20
+ }
21
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
7
22
  function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
8
23
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
9
24
  function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
@@ -27,6 +42,50 @@ class GeneratorService {
27
42
  }
28
43
  };
29
44
  }
45
+ getDescriptor(env) {
46
+ let templates;
47
+ let starters;
48
+ const result = {};
49
+ if (env.env.getGeneratorTemplates) {
50
+ const generatorTemplates = env.env.getGeneratorTemplates();
51
+ templates = (generatorTemplates || []).map(template => {
52
+ return (0, _lodash().pick)(template, ['name', 'displayName', 'exampleComponentName', 'description', 'hidden', 'env', 'installMissingDependencies', 'isEnv', 'isApp', 'dependencies']);
53
+ });
54
+ result.templates = templates;
55
+ }
56
+ if (env.env.getGeneratorTemplates) {
57
+ const generatorStarters = env.env.getGeneratorStarters();
58
+ starters = (generatorStarters || []).map(template => {
59
+ return (0, _lodash().pick)(template, ['name', 'description', 'hidden', 'appName']);
60
+ });
61
+ result.starters = starters;
62
+ }
63
+ if (!templates && !starters) return undefined;
64
+ return result;
65
+ }
66
+ render(env) {
67
+ const descriptor = this.getDescriptor(env);
68
+ const templates = this.getTemplatesToRender(descriptor?.templates || []);
69
+ const starters = this.getStartersToRender(descriptor?.starters || []);
70
+ return [templates, starters].join('\n\n');
71
+ }
72
+ getTemplatesToRender(templates) {
73
+ const templatesLabel = _chalk().default.green('Configured templates:');
74
+ if (!templates) return `${templatesLabel}\nno templates configured`;
75
+ const templatesStr = templates.map(template => {
76
+ const name = template.displayName ? `${template.displayName}(${template.name})` : template.name;
77
+ return `${name} - ${template.description}`;
78
+ }).join('\n');
79
+ return `${templatesLabel}\n${templatesStr}`;
80
+ }
81
+ getStartersToRender(starters) {
82
+ const startersLabel = _chalk().default.green('Configured starters:');
83
+ if (!starters) return `${startersLabel}\nno starters configured`;
84
+ const startersStr = starters.map(starter => {
85
+ return `${starter.name} - ${starter.description}`;
86
+ }).join('\n');
87
+ return `${startersLabel}\n${startersStr}`;
88
+ }
30
89
  }
31
90
  exports.GeneratorService = GeneratorService;
32
91
 
@@ -1 +1 @@
1
- {"version":3,"names":["GeneratorService","constructor","_defineProperty","transform","env","context","generators","undefined","getGeneratorTemplates","generatorList","compute","getGeneratorStarters","starters","starterList","exports"],"sources":["generator.service.tsx"],"sourcesContent":["import { EnvService, Env, EnvContext, ServiceTransformationMap } from '@teambit/envs';\nimport { ComponentTemplate } from './component-template';\nimport { WorkspaceTemplate } from './workspace-template';\n\ntype GeneratorTransformationMap = ServiceTransformationMap & {\n getGeneratorTemplates: () => ComponentTemplate;\n getGeneratorStarters: () => WorkspaceTemplate;\n};\nexport class GeneratorService implements EnvService<any> {\n name = 'generator';\n\n transform(env: Env, context: EnvContext): GeneratorTransformationMap | undefined {\n // Old env\n if (!env?.generators) return undefined;\n return {\n getGeneratorTemplates: () => {\n if (!env.generators) return undefined;\n const generatorList = env.generators()(context);\n return generatorList.compute();\n },\n getGeneratorStarters: () => {\n if (!env.starters) return undefined;\n const starterList = env.starters()(context);\n return starterList.compute();\n },\n };\n }\n}\n"],"mappings":";;;;;;;;;AAQO,MAAMA,gBAAgB,CAA4B;EAAAC,YAAA;IAAAC,eAAA,eAChD,WAAW;EAAA;EAElBC,SAASA,CAACC,GAAQ,EAAEC,OAAmB,EAA0C;IAC/E;IACA,IAAI,CAACD,GAAG,EAAEE,UAAU,EAAE,OAAOC,SAAS;IACtC,OAAO;MACLC,qBAAqB,EAAEA,CAAA,KAAM;QAC3B,IAAI,CAACJ,GAAG,CAACE,UAAU,EAAE,OAAOC,SAAS;QACrC,MAAME,aAAa,GAAGL,GAAG,CAACE,UAAU,CAAC,CAAC,CAACD,OAAO,CAAC;QAC/C,OAAOI,aAAa,CAACC,OAAO,CAAC,CAAC;MAChC,CAAC;MACDC,oBAAoB,EAAEA,CAAA,KAAM;QAC1B,IAAI,CAACP,GAAG,CAACQ,QAAQ,EAAE,OAAOL,SAAS;QACnC,MAAMM,WAAW,GAAGT,GAAG,CAACQ,QAAQ,CAAC,CAAC,CAACP,OAAO,CAAC;QAC3C,OAAOQ,WAAW,CAACH,OAAO,CAAC,CAAC;MAC9B;IACF,CAAC;EACH;AACF;AAACI,OAAA,CAAAd,gBAAA,GAAAA,gBAAA","ignoreList":[]}
1
+ {"version":3,"names":["_chalk","data","_interopRequireDefault","require","_lodash","e","__esModule","default","_defineProperty","r","t","_toPropertyKey","Object","defineProperty","value","enumerable","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","GeneratorService","constructor","transform","env","context","generators","undefined","getGeneratorTemplates","generatorList","compute","getGeneratorStarters","starters","starterList","getDescriptor","templates","result","generatorTemplates","map","template","pick","generatorStarters","render","descriptor","getTemplatesToRender","getStartersToRender","join","templatesLabel","chalk","green","templatesStr","name","displayName","description","startersLabel","startersStr","starter","exports"],"sources":["generator.service.tsx"],"sourcesContent":["import chalk from 'chalk';\nimport { EnvService, Env, EnvContext, ServiceTransformationMap, EnvDefinition } from '@teambit/envs';\nimport { pick } from 'lodash';\nimport { ComponentTemplate, ComponentTemplateOptions } from './component-template';\nimport { WorkspaceTemplate, WorkspaceTemplateOptions } from './workspace-template';\n\ntype GeneratorTransformationMap = ServiceTransformationMap & {\n getGeneratorTemplates: () => ComponentTemplate[];\n getGeneratorStarters: () => WorkspaceTemplate[];\n};\n\ntype Descriptor = {\n templates?: ComponentTemplateOptions[];\n starters?: WorkspaceTemplateOptions[];\n};\nexport class GeneratorService implements EnvService<any> {\n name = 'generator';\n\n transform(env: Env, context: EnvContext): GeneratorTransformationMap | undefined {\n // Old env\n if (!env?.generators) return undefined;\n return {\n getGeneratorTemplates: () => {\n if (!env.generators) return undefined;\n const generatorList = env.generators()(context);\n return generatorList.compute();\n },\n getGeneratorStarters: () => {\n if (!env.starters) return undefined;\n const starterList = env.starters()(context);\n return starterList.compute();\n },\n };\n }\n\n getDescriptor(env: EnvDefinition): Descriptor | undefined {\n let templates;\n let starters;\n const result: Descriptor = {};\n\n if (env.env.getGeneratorTemplates) {\n const generatorTemplates: ComponentTemplate[] = env.env.getGeneratorTemplates();\n\n templates = (generatorTemplates || []).map((template) => {\n return pick(template, [\n 'name',\n 'displayName',\n 'exampleComponentName',\n 'description',\n 'hidden',\n 'env',\n 'installMissingDependencies',\n 'isEnv',\n 'isApp',\n 'dependencies',\n ]);\n });\n result.templates = templates;\n }\n\n if (env.env.getGeneratorTemplates) {\n const generatorStarters: WorkspaceTemplate[] = env.env.getGeneratorStarters();\n\n starters = (generatorStarters || []).map((template) => {\n return pick(template, ['name', 'description', 'hidden', 'appName']);\n });\n result.starters = starters;\n }\n\n if (!templates && !starters) return undefined;\n\n return result;\n }\n\n render(env: EnvDefinition) {\n const descriptor = this.getDescriptor(env);\n const templates = this.getTemplatesToRender(descriptor?.templates || []);\n const starters = this.getStartersToRender(descriptor?.starters || []);\n return [templates, starters].join('\\n\\n');\n }\n\n private getTemplatesToRender(templates: Descriptor['templates']) {\n const templatesLabel = chalk.green('Configured templates:');\n if (!templates) return `${templatesLabel}\\nno templates configured`;\n const templatesStr = templates\n .map((template) => {\n const name = template.displayName ? `${template.displayName}(${template.name})` : template.name;\n return `${name} - ${template.description}`;\n })\n .join('\\n');\n return `${templatesLabel}\\n${templatesStr}`;\n }\n\n private getStartersToRender(starters: Descriptor['starters']) {\n const startersLabel = chalk.green('Configured starters:');\n if (!starters) return `${startersLabel}\\nno starters configured`;\n const startersStr = starters\n .map((starter) => {\n return `${starter.name} - ${starter.description}`;\n })\n .join('\\n');\n return `${startersLabel}\\n${startersStr}`;\n }\n}\n"],"mappings":";;;;;;AAAA,SAAAA,OAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAH,MAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAG,QAAA;EAAA,MAAAH,IAAA,GAAAE,OAAA;EAAAC,OAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAA8B,SAAAC,uBAAAG,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,SAAAG,gBAAAH,CAAA,EAAAI,CAAA,EAAAC,CAAA,YAAAD,CAAA,GAAAE,cAAA,CAAAF,CAAA,MAAAJ,CAAA,GAAAO,MAAA,CAAAC,cAAA,CAAAR,CAAA,EAAAI,CAAA,IAAAK,KAAA,EAAAJ,CAAA,EAAAK,UAAA,MAAAC,YAAA,MAAAC,QAAA,UAAAZ,CAAA,CAAAI,CAAA,IAAAC,CAAA,EAAAL,CAAA;AAAA,SAAAM,eAAAD,CAAA,QAAAQ,CAAA,GAAAC,YAAA,CAAAT,CAAA,uCAAAQ,CAAA,GAAAA,CAAA,GAAAA,CAAA;AAAA,SAAAC,aAAAT,CAAA,EAAAD,CAAA,2BAAAC,CAAA,KAAAA,CAAA,SAAAA,CAAA,MAAAL,CAAA,GAAAK,CAAA,CAAAU,MAAA,CAAAC,WAAA,kBAAAhB,CAAA,QAAAa,CAAA,GAAAb,CAAA,CAAAiB,IAAA,CAAAZ,CAAA,EAAAD,CAAA,uCAAAS,CAAA,SAAAA,CAAA,YAAAK,SAAA,yEAAAd,CAAA,GAAAe,MAAA,GAAAC,MAAA,EAAAf,CAAA;AAavB,MAAMgB,gBAAgB,C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AAC,CACDP,IAAI,CAAC,IAAI,CAAC;IACb,OAAO,GAAGC,cAAc,KAAKG,YAAY,EAAE;EAC7C;EAEQL,mBAAmBA,CAACb,QAAgC,EAAE;IAC5D,MAAMsB,aAAa,GAAGN,gBAAK,CAACC,KAAK,CAAC,sBAAsB,CAAC;IACzD,IAAI,CAACjB,QAAQ,EAAE,OAAO,GAAGsB,aAAa,0BAA0B;IAChE,MAAMC,WAAW,GAAGvB,QAAQ,CACzBM,GAAG,CAAEkB,OAAO,IAAK;MAChB,OAAO,GAAGA,OAAO,CAACL,IAAI,MAAMK,OAAO,CAACH,WAAW,EAAE;IACnD,CAAC,CAAC,CACDP,IAAI,CAAC,IAAI,CAAC;IACb,OAAO,GAAGQ,aAAa,KAAKC,WAAW,EAAE;EAC3C;AACF;AAACE,OAAA,CAAApC,gBAAA,GAAAA,gBAAA","ignoreList":[]}
@@ -1,5 +1,5 @@
1
- import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad/teambit.generator_generator@1.0.372/dist/generator.composition.js';
2
- import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad/teambit.generator_generator@1.0.372/dist/generator.docs.mdx';
1
+ import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad/teambit.generator_generator@1.0.374/dist/generator.composition.js';
2
+ import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad/teambit.generator_generator@1.0.374/dist/generator.docs.mdx';
3
3
 
4
4
  export const compositions = [compositions_0];
5
5
  export const overview = [overview_0];
@@ -173,7 +173,10 @@ class WorkspaceGenerator {
173
173
  import: false,
174
174
  copyPeerToRuntimeOnRoot: true,
175
175
  copyPeerToRuntimeOnComponents: false,
176
- updateExisting: false
176
+ updateExisting: false,
177
+ // skip pruning here to prevent cases which it caused an error about
178
+ // tsconfig not found because the env location was changed
179
+ skipPrune: true
177
180
  });
178
181
 
179
182
  // compile the components again now that we have the dependencies installed
@@ -1 +1 @@
1
- {"version":3,"names":["_fsExtra","data","_interopRequireDefault","require","_bit","_execa","_pMapSeries","_ui","_logger","_workspace","_forking","_importer","_compiler","_gitModules","_path","_lodash","_git","_install","_hostInitializer","_workspaceConfigFiles","_generator","e","__esModule","default","_defineProperty","r","t","_toPropertyKey","Object","defineProperty","value","enumerable","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","WorkspaceGenerator","constructor","workspaceName","workspacePath","options","template","aspectComponent","generate","fs","ensureDir","process","chdir","initGit","HostInitializerMain","init","skipGit","writeWorkspaceFiles","reloadBitInWorkspaceDir","workspace","inInstallContext","setupGitBitmapMergeDriver","forkComponentsFromRemote","installBeforeCreateComponentsIfNeeded","createComponentsFromRemote","importComponentsFromRemote","clearCache","install","undefined","dedupe","import","copyPeerToRuntimeOnRoot","copyPeerToRuntimeOnComponents","updateExisting","compileComponents","wsConfigFiles","writeConfigFiles","err","logger","error","remove","gitExecutablePath","getGitExecutablePath","params","execa","exitCodeName","GitNotFound","git","setGitMergeDriver","global","buildUI","uiMain","harmony","get","UIAspect","id","createRuntime","getWorkspaceContext","name","defaultScope","empty","workspaceContext","templateFiles","generateFiles","Promise","all","map","templateFile","outputFile","join","relativePath","content","loadBit","WorkspaceAspect","InstallAspect","loggerMain","LoggerAspect","createLogger","GeneratorAspect","importer","ImporterAspect","forking","ForkingAspect","GitAspect","WorkspaceConfigFilesAspect","generator","create","configuredEnvs","getConfiguredEnvs","length","componentsToCreate","aspectsForComponentsToCreate","compact","componentToCreate","aspect","needInstall","some","includes","console","pMapSeries","generateComponentTemplate","componentName","templateName","env","path","scope","componentsToFork","importComponents","fork","componentsToForkRestructured","targetName","config","targetScope","sourceId","targetId","forkMultipleFromRemote","refactor","componentsToImport","componentToImport","ids","installNpmPackages","writeToPath","bitMap","write","compiler","CompilerAspect","compileOnWorkspace","exports"],"sources":["workspace-generator.ts"],"sourcesContent":["import fs from 'fs-extra';\nimport { loadBit } from '@teambit/bit';\nimport { Harmony } from '@teambit/harmony';\nimport { Component } from '@teambit/component';\nimport execa from 'execa';\nimport pMapSeries from 'p-map-series';\nimport { UIAspect, UiMain } from '@teambit/ui';\nimport { Logger, LoggerAspect, LoggerMain } from '@teambit/logger';\nimport { WorkspaceAspect, Workspace } from '@teambit/workspace';\nimport { ForkingAspect, ForkingMain } from '@teambit/forking';\nimport { ImporterAspect, ImporterMain } from '@teambit/importer';\nimport { CompilerAspect, CompilerMain } from '@teambit/compiler';\nimport { getGitExecutablePath, GitNotFound } from '@teambit/git.modules.git-executable';\nimport { join } from 'path';\nimport { compact, some } from 'lodash';\nimport { ComponentID } from '@teambit/component-id';\nimport { GitAspect, GitMain } from '@teambit/git';\nimport { InstallAspect, InstallMain } from '@teambit/install';\nimport { HostInitializerMain } from '@teambit/host-initializer';\nimport { WorkspaceConfigFilesAspect, WorkspaceConfigFilesMain } from '@teambit/workspace-config-files';\n// import { ComponentGenerator } from './component-generator';\nimport { WorkspaceTemplate, WorkspaceContext } from './workspace-template';\nimport { NewOptions } from './new.cmd';\nimport { GeneratorAspect } from './generator.aspect';\nimport { GeneratorMain } from './generator.main.runtime';\n\nexport type GenerateResult = { id: ComponentID; dir: string; files: string[]; envId: string };\n\nexport class WorkspaceGenerator {\n private harmony: Harmony;\n private workspace: Workspace;\n private install: InstallMain;\n private importer: ImporterMain;\n private logger?: Logger;\n private forking: ForkingMain;\n private git: GitMain;\n private wsConfigFiles: WorkspaceConfigFilesMain;\n private generator: GeneratorMain;\n\n constructor(\n private workspaceName: string,\n private workspacePath: string,\n private options: NewOptions & { currentDir?: boolean },\n private template: WorkspaceTemplate,\n private aspectComponent?: Component\n ) {}\n\n async generate(): Promise<string> {\n await fs.ensureDir(this.workspacePath);\n try {\n process.chdir(this.workspacePath);\n await this.initGit();\n await HostInitializerMain.init(\n this.workspacePath,\n this.options.skipGit,\n false,\n false,\n false,\n false,\n false,\n false,\n false,\n {}\n );\n await this.writeWorkspaceFiles();\n await this.reloadBitInWorkspaceDir();\n // Setting the workspace to be in install context to prevent errors during the workspace generation\n // the workspace will be in install context until the end of the generation install process\n this.workspace.inInstallContext = true;\n await this.setupGitBitmapMergeDriver();\n await this.forkComponentsFromRemote();\n await this.installBeforeCreateComponentsIfNeeded();\n await this.createComponentsFromRemote();\n await this.importComponentsFromRemote();\n await this.workspace.clearCache();\n await this.install.install(undefined, {\n dedupe: true,\n import: false,\n copyPeerToRuntimeOnRoot: true,\n copyPeerToRuntimeOnComponents: false,\n updateExisting: false,\n });\n\n // compile the components again now that we have the dependencies installed\n await this.compileComponents(true);\n await this.wsConfigFiles.writeConfigFiles({});\n } catch (err: any) {\n this.logger?.error(`failed generating a new workspace, will delete the dir ${this.workspacePath}`, err);\n await fs.remove(this.workspacePath);\n throw err;\n }\n\n return this.workspacePath;\n }\n\n private async initGit() {\n if (this.options.skipGit) return;\n const gitExecutablePath = getGitExecutablePath();\n const params = ['init'];\n try {\n await execa(gitExecutablePath, params);\n } catch (err: any) {\n if (err.exitCodeName === 'ENOENT') {\n throw new GitNotFound(gitExecutablePath, err);\n }\n throw err;\n }\n }\n\n private async setupGitBitmapMergeDriver() {\n if (this.options.skipGit) return;\n await this.git.setGitMergeDriver({ global: false });\n }\n\n private async buildUI() {\n const uiMain = this.harmony.get<UiMain>(UIAspect.id);\n await uiMain.createRuntime({});\n }\n\n private getWorkspaceContext(): WorkspaceContext {\n return {\n name: this.workspaceName,\n defaultScope: this.options.defaultScope,\n empty: this.options.empty,\n aspectComponent: this.aspectComponent,\n template: this.template,\n skipGit: this.options.skipGit,\n };\n }\n\n /**\n * writes the generated template files to the default directory set in the workspace config\n */\n private async writeWorkspaceFiles(): Promise<void> {\n const workspaceContext = this.getWorkspaceContext();\n const templateFiles = await this.template.generateFiles(workspaceContext);\n await Promise.all(\n templateFiles.map(async (templateFile) => {\n await fs.outputFile(join(this.workspacePath, templateFile.relativePath), templateFile.content);\n })\n );\n }\n\n private async reloadBitInWorkspaceDir() {\n this.harmony = await loadBit(this.workspacePath);\n this.workspace = this.harmony.get<Workspace>(WorkspaceAspect.id);\n this.install = this.harmony.get<InstallMain>(InstallAspect.id);\n const loggerMain = this.harmony.get<LoggerMain>(LoggerAspect.id);\n this.logger = loggerMain.createLogger(GeneratorAspect.id);\n this.importer = this.harmony.get<ImporterMain>(ImporterAspect.id);\n this.forking = this.harmony.get<ForkingMain>(ForkingAspect.id);\n this.git = this.harmony.get<GitMain>(GitAspect.id);\n this.wsConfigFiles = this.harmony.get<WorkspaceConfigFilesMain>(WorkspaceConfigFilesAspect.id);\n this.generator = this.harmony.get<GeneratorMain>(GeneratorAspect.id);\n }\n\n private async installBeforeCreateComponentsIfNeeded() {\n if (this.options.empty || !this.template.create) return;\n const configuredEnvs = this.generator.getConfiguredEnvs();\n if (!configuredEnvs.length) return;\n const workspaceContext = this.getWorkspaceContext();\n const componentsToCreate = this.template.create(workspaceContext);\n const aspectsForComponentsToCreate = compact(\n componentsToCreate.map((componentToCreate) => componentToCreate.aspect)\n );\n const needInstall = some(aspectsForComponentsToCreate, (aspect) => {\n return configuredEnvs.includes(aspect);\n });\n if (needInstall) {\n this.logger?.console(\n `installing dependencies in workspace using to load components templates from the following envs: ${configuredEnvs.join(\n ', '\n )}`\n );\n await this.install.install(undefined, {\n dedupe: true,\n import: false,\n copyPeerToRuntimeOnRoot: true,\n copyPeerToRuntimeOnComponents: false,\n updateExisting: false,\n });\n }\n }\n\n private async createComponentsFromRemote() {\n if (this.options.empty || !this.template.create) return;\n const workspaceContext = this.getWorkspaceContext();\n const componentsToCreate = this.template.create(workspaceContext);\n await pMapSeries(componentsToCreate, async (componentToCreate) => {\n return this.generator.generateComponentTemplate(\n [componentToCreate.componentName],\n componentToCreate.templateName,\n {\n aspect: componentToCreate.aspect,\n env: componentToCreate.env,\n path: componentToCreate.path,\n scope: componentToCreate.scope,\n }\n );\n });\n }\n\n private async forkComponentsFromRemote() {\n if (this.options.empty) return;\n const workspaceContext = this.getWorkspaceContext();\n const componentsToFork =\n this.template?.importComponents?.(workspaceContext) || this.template?.fork?.(workspaceContext) || [];\n if (!componentsToFork.length) return;\n const componentsToForkRestructured = componentsToFork.map(({ id, targetName, path, env, config, targetScope }) => ({\n sourceId: id,\n targetId: targetName,\n targetScope,\n path,\n env,\n config,\n }));\n await this.forking.forkMultipleFromRemote(componentsToForkRestructured, {\n scope: this.workspace.defaultScope,\n refactor: true,\n install: false,\n });\n }\n\n private async importComponentsFromRemote() {\n if (this.options.empty) return;\n const workspaceContext = this.getWorkspaceContext();\n const componentsToImport = this.template?.import?.(workspaceContext) || [];\n\n if (!componentsToImport.length) return;\n\n await pMapSeries(componentsToImport, async (componentToImport) => {\n await this.importer.import(\n {\n ids: [componentToImport.id],\n installNpmPackages: false,\n writeConfigFiles: false,\n writeToPath: componentToImport.path,\n },\n []\n );\n });\n\n await this.workspace.bitMap.write('new');\n }\n\n private async compileComponents(clearCache = true) {\n if (clearCache) {\n await this.workspace.clearCache();\n }\n const compiler = this.harmony.get<CompilerMain>(CompilerAspect.id);\n await compiler.compileOnWorkspace();\n }\n}\n"],"mappings":";;;;;;AAAA,SAAAA,SAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAH,QAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,KAAA;EAAA,MAAAH,IAAA,GAAAE,OAAA;EAAAC,IAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAGA,SAAAI,OAAA;EAAA,MAAAJ,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAE,MAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAK,YAAA;EAAA,MAAAL,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAG,WAAA,YAAAA,CAAA;IAAA,OAAAL,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAM,IAAA;EAAA,M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AU,EAACkB,kBAAkB,EAAE,MAAOC,iBAAiB,IAAK;MAChE,MAAM,IAAI,CAACvC,QAAQ,CAACjD,MAAM,CACxB;QACEyF,GAAG,EAAE,CAACD,iBAAiB,CAAC/D,EAAE,CAAC;QAC3BiE,kBAAkB,EAAE,KAAK;QACzBpF,gBAAgB,EAAE,KAAK;QACvBqF,WAAW,EAAEH,iBAAiB,CAACd;MACjC,CAAC,EACD,EACF,CAAC;IACH,CAAC,CAAC;IAEF,MAAM,IAAI,CAACrF,SAAS,CAACuG,MAAM,CAACC,KAAK,CAAC,KAAK,CAAC;EAC1C;EAEA,MAAczF,iBAAiBA,CAACR,UAAU,GAAG,IAAI,EAAE;IACjD,IAAIA,UAAU,EAAE;MACd,MAAM,IAAI,CAACP,SAAS,CAACO,UAAU,CAAC,CAAC;IACnC;IACA,MAAMkG,QAAQ,GAAG,IAAI,CAACxE,OAAO,CAACC,GAAG,CAAewE,0BAAc,CAACtE,EAAE,CAAC;IAClE,MAAMqE,QAAQ,CAACE,kBAAkB,CAAC,CAAC;EACrC;AACF;AAACC,OAAA,CAAA9H,kBAAA,GAAAA,kBAAA","ignoreList":[]}
1
+ {"version":3,"names":["_fsExtra","data","_interopRequireDefault","require","_bit","_execa","_pMapSeries","_ui","_logger","_workspace","_forking","_importer","_compiler","_gitModules","_path","_lodash","_git","_install","_hostInitializer","_workspaceConfigFiles","_generator","e","__esModule","default","_defineProperty","r","t","_toPropertyKey","Object","defineProperty","value","enumerable","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","WorkspaceGenerator","constructor","workspaceName","workspacePath","options","template","aspectComponent","generate","fs","ensureDir","process","chdir","initGit","HostInitializerMain","init","skipGit","writeWorkspaceFiles","reloadBitInWorkspaceDir","workspace","inInstallContext","setupGitBitmapMergeDriver","forkComponentsFromRemote","installBeforeCreateComponentsIfNeeded","createComponentsFromRemote","importComponentsFromRemote","clearCache","install","undefined","dedupe","import","copyPeerToRuntimeOnRoot","copyPeerToRuntimeOnComponents","updateExisting","skipPrune","compileComponents","wsConfigFiles","writeConfigFiles","err","logger","error","remove","gitExecutablePath","getGitExecutablePath","params","execa","exitCodeName","GitNotFound","git","setGitMergeDriver","global","buildUI","uiMain","harmony","get","UIAspect","id","createRuntime","getWorkspaceContext","name","defaultScope","empty","workspaceContext","templateFiles","generateFiles","Promise","all","map","templateFile","outputFile","join","relativePath","content","loadBit","WorkspaceAspect","InstallAspect","loggerMain","LoggerAspect","createLogger","GeneratorAspect","importer","ImporterAspect","forking","ForkingAspect","GitAspect","WorkspaceConfigFilesAspect","generator","create","configuredEnvs","getConfiguredEnvs","length","componentsToCreate","aspectsForComponentsToCreate","compact","componentToCreate","aspect","needInstall","some","includes","console","pMapSeries","generateComponentTemplate","componentName","templateName","env","path","scope","componentsToFork","importComponents","fork","componentsToForkRestructured","targetName","config","targetScope","sourceId","targetId","forkMultipleFromRemote","refactor","componentsToImport","componentToImport","ids","installNpmPackages","writeToPath","bitMap","write","compiler","CompilerAspect","compileOnWorkspace","exports"],"sources":["workspace-generator.ts"],"sourcesContent":["import fs from 'fs-extra';\nimport { loadBit } from '@teambit/bit';\nimport { Harmony } from '@teambit/harmony';\nimport { Component } from '@teambit/component';\nimport execa from 'execa';\nimport pMapSeries from 'p-map-series';\nimport { UIAspect, UiMain } from '@teambit/ui';\nimport { Logger, LoggerAspect, LoggerMain } from '@teambit/logger';\nimport { WorkspaceAspect, Workspace } from '@teambit/workspace';\nimport { ForkingAspect, ForkingMain } from '@teambit/forking';\nimport { ImporterAspect, ImporterMain } from '@teambit/importer';\nimport { CompilerAspect, CompilerMain } from '@teambit/compiler';\nimport { getGitExecutablePath, GitNotFound } from '@teambit/git.modules.git-executable';\nimport { join } from 'path';\nimport { compact, some } from 'lodash';\nimport { ComponentID } from '@teambit/component-id';\nimport { GitAspect, GitMain } from '@teambit/git';\nimport { InstallAspect, InstallMain } from '@teambit/install';\nimport { HostInitializerMain } from '@teambit/host-initializer';\nimport { WorkspaceConfigFilesAspect, WorkspaceConfigFilesMain } from '@teambit/workspace-config-files';\n// import { ComponentGenerator } from './component-generator';\nimport { WorkspaceTemplate, WorkspaceContext } from './workspace-template';\nimport { NewOptions } from './new.cmd';\nimport { GeneratorAspect } from './generator.aspect';\nimport { GeneratorMain } from './generator.main.runtime';\n\nexport type GenerateResult = { id: ComponentID; dir: string; files: string[]; envId: string };\n\nexport class WorkspaceGenerator {\n private harmony: Harmony;\n private workspace: Workspace;\n private install: InstallMain;\n private importer: ImporterMain;\n private logger?: Logger;\n private forking: ForkingMain;\n private git: GitMain;\n private wsConfigFiles: WorkspaceConfigFilesMain;\n private generator: GeneratorMain;\n\n constructor(\n private workspaceName: string,\n private workspacePath: string,\n private options: NewOptions & { currentDir?: boolean },\n private template: WorkspaceTemplate,\n private aspectComponent?: Component\n ) {}\n\n async generate(): Promise<string> {\n await fs.ensureDir(this.workspacePath);\n try {\n process.chdir(this.workspacePath);\n await this.initGit();\n await HostInitializerMain.init(\n this.workspacePath,\n this.options.skipGit,\n false,\n false,\n false,\n false,\n false,\n false,\n false,\n {}\n );\n await this.writeWorkspaceFiles();\n await this.reloadBitInWorkspaceDir();\n // Setting the workspace to be in install context to prevent errors during the workspace generation\n // the workspace will be in install context until the end of the generation install process\n this.workspace.inInstallContext = true;\n await this.setupGitBitmapMergeDriver();\n await this.forkComponentsFromRemote();\n await this.installBeforeCreateComponentsIfNeeded();\n await this.createComponentsFromRemote();\n await this.importComponentsFromRemote();\n await this.workspace.clearCache();\n await this.install.install(undefined, {\n dedupe: true,\n import: false,\n copyPeerToRuntimeOnRoot: true,\n copyPeerToRuntimeOnComponents: false,\n updateExisting: false,\n // skip pruning here to prevent cases which it caused an error about\n // tsconfig not found because the env location was changed\n skipPrune: true,\n });\n\n // compile the components again now that we have the dependencies installed\n await this.compileComponents(true);\n await this.wsConfigFiles.writeConfigFiles({});\n } catch (err: any) {\n this.logger?.error(`failed generating a new workspace, will delete the dir ${this.workspacePath}`, err);\n await fs.remove(this.workspacePath);\n throw err;\n }\n\n return this.workspacePath;\n }\n\n private async initGit() {\n if (this.options.skipGit) return;\n const gitExecutablePath = getGitExecutablePath();\n const params = ['init'];\n try {\n await execa(gitExecutablePath, params);\n } catch (err: any) {\n if (err.exitCodeName === 'ENOENT') {\n throw new GitNotFound(gitExecutablePath, err);\n }\n throw err;\n }\n }\n\n private async setupGitBitmapMergeDriver() {\n if (this.options.skipGit) return;\n await this.git.setGitMergeDriver({ global: false });\n }\n\n private async buildUI() {\n const uiMain = this.harmony.get<UiMain>(UIAspect.id);\n await uiMain.createRuntime({});\n }\n\n private getWorkspaceContext(): WorkspaceContext {\n return {\n name: this.workspaceName,\n defaultScope: this.options.defaultScope,\n empty: this.options.empty,\n aspectComponent: this.aspectComponent,\n template: this.template,\n skipGit: this.options.skipGit,\n };\n }\n\n /**\n * writes the generated template files to the default directory set in the workspace config\n */\n private async writeWorkspaceFiles(): Promise<void> {\n const workspaceContext = this.getWorkspaceContext();\n const templateFiles = await this.template.generateFiles(workspaceContext);\n await Promise.all(\n templateFiles.map(async (templateFile) => {\n await fs.outputFile(join(this.workspacePath, templateFile.relativePath), templateFile.content);\n })\n );\n }\n\n private async reloadBitInWorkspaceDir() {\n this.harmony = await loadBit(this.workspacePath);\n this.workspace = this.harmony.get<Workspace>(WorkspaceAspect.id);\n this.install = this.harmony.get<InstallMain>(InstallAspect.id);\n const loggerMain = this.harmony.get<LoggerMain>(LoggerAspect.id);\n this.logger = loggerMain.createLogger(GeneratorAspect.id);\n this.importer = this.harmony.get<ImporterMain>(ImporterAspect.id);\n this.forking = this.harmony.get<ForkingMain>(ForkingAspect.id);\n this.git = this.harmony.get<GitMain>(GitAspect.id);\n this.wsConfigFiles = this.harmony.get<WorkspaceConfigFilesMain>(WorkspaceConfigFilesAspect.id);\n this.generator = this.harmony.get<GeneratorMain>(GeneratorAspect.id);\n }\n\n private async installBeforeCreateComponentsIfNeeded() {\n if (this.options.empty || !this.template.create) return;\n const configuredEnvs = this.generator.getConfiguredEnvs();\n if (!configuredEnvs.length) return;\n const workspaceContext = this.getWorkspaceContext();\n const componentsToCreate = this.template.create(workspaceContext);\n const aspectsForComponentsToCreate = compact(\n componentsToCreate.map((componentToCreate) => componentToCreate.aspect)\n );\n const needInstall = some(aspectsForComponentsToCreate, (aspect) => {\n return configuredEnvs.includes(aspect);\n });\n if (needInstall) {\n this.logger?.console(\n `installing dependencies in workspace using to load components templates from the following envs: ${configuredEnvs.join(\n ', '\n )}`\n );\n await this.install.install(undefined, {\n dedupe: true,\n import: false,\n copyPeerToRuntimeOnRoot: true,\n copyPeerToRuntimeOnComponents: false,\n updateExisting: false,\n });\n }\n }\n\n private async createComponentsFromRemote() {\n if (this.options.empty || !this.template.create) return;\n const workspaceContext = this.getWorkspaceContext();\n const componentsToCreate = this.template.create(workspaceContext);\n await pMapSeries(componentsToCreate, async (componentToCreate) => {\n return this.generator.generateComponentTemplate(\n [componentToCreate.componentName],\n componentToCreate.templateName,\n {\n aspect: componentToCreate.aspect,\n env: componentToCreate.env,\n path: componentToCreate.path,\n scope: componentToCreate.scope,\n }\n );\n });\n }\n\n private async forkComponentsFromRemote() {\n if (this.options.empty) return;\n const workspaceContext = this.getWorkspaceContext();\n const componentsToFork =\n this.template?.importComponents?.(workspaceContext) || this.template?.fork?.(workspaceContext) || [];\n if (!componentsToFork.length) return;\n const componentsToForkRestructured = componentsToFork.map(({ id, targetName, path, env, config, targetScope }) => ({\n sourceId: id,\n targetId: targetName,\n targetScope,\n path,\n env,\n config,\n }));\n await this.forking.forkMultipleFromRemote(componentsToForkRestructured, {\n scope: this.workspace.defaultScope,\n refactor: true,\n install: false,\n });\n }\n\n private async importComponentsFromRemote() {\n if (this.options.empty) return;\n const workspaceContext = this.getWorkspaceContext();\n const componentsToImport = this.template?.import?.(workspaceContext) || [];\n\n if (!componentsToImport.length) return;\n\n await pMapSeries(componentsToImport, async (componentToImport) => {\n await this.importer.import(\n {\n ids: [componentToImport.id],\n installNpmPackages: false,\n writeConfigFiles: false,\n writeToPath: componentToImport.path,\n },\n []\n );\n });\n\n await this.workspace.bitMap.write('new');\n }\n\n private async compileComponents(clearCache = true) {\n if (clearCache) {\n await this.workspace.clearCache();\n }\n const compiler = this.harmony.get<CompilerMain>(CompilerAspect.id);\n await compiler.compileOnWorkspace();\n }\n}\n"],"mappings":";;;;;;AAAA,SAAAA,SAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAH,QAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,KAAA;EAAA,MAAAH,IAAA,GAAAE,OAAA;EAAAC,IAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAGA,SAAAI,OAAA;EAAA,MAAAJ,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAE,MAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAK,YAAA;EAAA,MAAAL,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAG,WAAA,YAAAA,CAAA;IAAA,OAAAL,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAM,IAAA;EAAA,MAAAN,IAAA,GAAAE,OAAA;EAAAI,GAAA,YAAAA,CAAA;IAAA,OAAAN,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAO,QAAA;EAAA,MAAAP,IAAA,GAAAE,OAAA;EAAAK,OAAA,YAAAA,CAAA;IAAA,OAAAP,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAQ,WAAA;EAAA,MAAAR,IAAA,GAAAE,OAAA;EAAAM,UAAA,YAAAA,CAAA;IAAA,OAAAR,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAS,SAAA;EAAA,MAAAT,IAAA,GAAAE,OAAA;EAAAO,QAAA,YAAAA,CAAA;IAAA,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AAG,IAAI,EAAE;IACjD,IAAIA,UAAU,EAAE;MACd,MAAM,IAAI,CAACP,SAAS,CAACO,UAAU,CAAC,CAAC;IACnC;IACA,MAAMmG,QAAQ,GAAG,IAAI,CAACxE,OAAO,CAACC,GAAG,CAAewE,0BAAc,CAACtE,EAAE,CAAC;IAClE,MAAMqE,QAAQ,CAACE,kBAAkB,CAAC,CAAC;EACrC;AACF;AAACC,OAAA,CAAA/H,kBAAA,GAAAA,kBAAA","ignoreList":[]}
@@ -113,7 +113,7 @@ export interface ImportComponentInfo {
113
113
  */
114
114
  path?: string;
115
115
  }
116
- export interface WorkspaceTemplate {
116
+ export interface WorkspaceTemplateOptions {
117
117
  /**
118
118
  * name of the workspace starter. for example: `react-workspace`.
119
119
  */
@@ -131,6 +131,8 @@ export interface WorkspaceTemplate {
131
131
  * hide this starter so that it is not listed with `bit starter`
132
132
  */
133
133
  hidden?: boolean;
134
+ }
135
+ export interface WorkspaceTemplate extends WorkspaceTemplateOptions {
134
136
  /**
135
137
  * starter function for generating the template files,
136
138
  */
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["workspace-template.ts"],"sourcesContent":["import type { Component } from '@teambit/component';\nimport { ComponentConfig } from './component-template';\n\n/**\n * BaseWorkspaceOptions describes the foundational properties for workspaces.\n */\nexport interface BaseWorkspaceOptions {\n /**\n * The name of the workspace as provided by the user (e.g., `react-app`).\n * This is also used as the directory name for the workspace.\n */\n name: string;\n\n /**\n * The default scope provided by the user.\n * This is set in the workspace.jsonc and is utilized for components within the workspace.\n */\n defaultScope?: string;\n\n /**\n * Indicates whether the user has opted to avoid creating components (typically with a `--empty` flag).\n */\n empty?: boolean;\n\n /**\n * Represents the aspect in the context where a remote aspect is imported (often via the `--aspect` flag).\n * This is useful for obtaining the aspect-id and other related information.\n */\n aspectComponent?: Component;\n\n /**\n * Represents the selected template to initialize or create the workspace.\n */\n template: WorkspaceTemplate;\n\n /**\n * Flag to check if Git repository generation should be skipped.\n */\n skipGit?: boolean;\n\n /**\n * Local path to the workspace template.\n * Useful during the development of a workspace-template.\n */\n loadFrom?: string;\n}\n\n/**\n * WorkspaceContext represents foundational properties for a workspace context.\n */\nexport type WorkspaceContext = BaseWorkspaceOptions;\n\nexport interface WorkspaceFile {\n /**\n * relative path of the file within the workspace.\n */\n relativePath: string;\n\n /**\n * file content\n */\n content: string;\n}\n\nexport interface CreateComponentInfo {\n /**\n * the template for generating the component\n */\n templateName: string;\n /**\n * component name to generate\n */\n componentName: string;\n /**\n * sets the component's scope-name. if not entered, the default-scope will be used\n */\n scope?: string;\n /**\n * relative path in the workspace. by default the path is `<scope>/<namespace>/<name>`\n */\n path?: string;\n /**\n * set the component's environment. (overrides the env from variants and the template)\n */\n env?: string;\n /**\n * aspect-id of the template.\n */\n aspect?: string;\n}\n\nexport interface ForkComponentInfo extends ImportComponentInfo {\n /**\n * a new component name. if not specified, use the original id (without the scope)\n */\n targetName?: string;\n\n /**\n * a new scope for the component. if not specified, use the original scope\n */\n targetScope?: string;\n\n /**\n * env to use for the component.\n */\n env?: string;\n\n /**\n * component config. gets saved in the .bitmap file and overrides the workspace.jsonc config.\n * for example, you can set the env that will be used for this component as follows:\n * \"teambit.envs/envs\": {\n * \"env\": \"teambit.harmony/aspect\"\n * },\n */\n config?: ComponentConfig;\n}\n\n/**\n * @deprecated use ForkComponentInfo instead.\n */\nexport type ComponentToImport = ForkComponentInfo;\n\nexport interface ImportComponentInfo {\n /**\n * full component id\n */\n id: string;\n\n /**\n * path where to write the component\n */\n path?: string;\n}\n\nexport interface WorkspaceTemplate {\n /**\n * name of the workspace starter. for example: `react-workspace`.\n */\n name: string;\n\n /**\n * name of an app created in the workspace. for example: `my-app`.\n * This will be used to instruct the user to run `bit run <appName>` in the new workspace.\n */\n appName?: string;\n\n /**\n * short description of the starter. shown in the `bit starter` command when outside of bit-workspace.\n */\n description?: string;\n\n /**\n * hide this starter so that it is not listed with `bit starter`\n */\n hidden?: boolean;\n\n /**\n * starter function for generating the template files,\n */\n generateFiles(context: WorkspaceContext): Promise<WorkspaceFile[]>;\n\n /**\n * @deprecated use `fork()` or `import()` instead\n * this is working similarly to `fork()`\n */\n importComponents?: (context: WorkspaceContext) => ForkComponentInfo[];\n\n /**\n * import components into the new workspace, don't change their source code.\n */\n import?: (context: WorkspaceContext) => ImportComponentInfo[];\n\n /**\n * populate existing components into the new workspace and add them as new components.\n * change their source code and update the dependency names according to the new component names.\n */\n fork?: (context: WorkspaceContext) => ForkComponentInfo[];\n\n /**\n * populate new components into the new workspace and add them as new components.\n */\n create?: (context: WorkspaceContext) => CreateComponentInfo[];\n}\n"],"mappings":"","ignoreList":[]}
1
+ {"version":3,"names":[],"sources":["workspace-template.ts"],"sourcesContent":["import type { Component } from '@teambit/component';\nimport { ComponentConfig } from './component-template';\n\n/**\n * BaseWorkspaceOptions describes the foundational properties for workspaces.\n */\nexport interface BaseWorkspaceOptions {\n /**\n * The name of the workspace as provided by the user (e.g., `react-app`).\n * This is also used as the directory name for the workspace.\n */\n name: string;\n\n /**\n * The default scope provided by the user.\n * This is set in the workspace.jsonc and is utilized for components within the workspace.\n */\n defaultScope?: string;\n\n /**\n * Indicates whether the user has opted to avoid creating components (typically with a `--empty` flag).\n */\n empty?: boolean;\n\n /**\n * Represents the aspect in the context where a remote aspect is imported (often via the `--aspect` flag).\n * This is useful for obtaining the aspect-id and other related information.\n */\n aspectComponent?: Component;\n\n /**\n * Represents the selected template to initialize or create the workspace.\n */\n template: WorkspaceTemplate;\n\n /**\n * Flag to check if Git repository generation should be skipped.\n */\n skipGit?: boolean;\n\n /**\n * Local path to the workspace template.\n * Useful during the development of a workspace-template.\n */\n loadFrom?: string;\n}\n\n/**\n * WorkspaceContext represents foundational properties for a workspace context.\n */\nexport type WorkspaceContext = BaseWorkspaceOptions;\n\nexport interface WorkspaceFile {\n /**\n * relative path of the file within the workspace.\n */\n relativePath: string;\n\n /**\n * file content\n */\n content: string;\n}\n\nexport interface CreateComponentInfo {\n /**\n * the template for generating the component\n */\n templateName: string;\n /**\n * component name to generate\n */\n componentName: string;\n /**\n * sets the component's scope-name. if not entered, the default-scope will be used\n */\n scope?: string;\n /**\n * relative path in the workspace. by default the path is `<scope>/<namespace>/<name>`\n */\n path?: string;\n /**\n * set the component's environment. (overrides the env from variants and the template)\n */\n env?: string;\n /**\n * aspect-id of the template.\n */\n aspect?: string;\n}\n\nexport interface ForkComponentInfo extends ImportComponentInfo {\n /**\n * a new component name. if not specified, use the original id (without the scope)\n */\n targetName?: string;\n\n /**\n * a new scope for the component. if not specified, use the original scope\n */\n targetScope?: string;\n\n /**\n * env to use for the component.\n */\n env?: string;\n\n /**\n * component config. gets saved in the .bitmap file and overrides the workspace.jsonc config.\n * for example, you can set the env that will be used for this component as follows:\n * \"teambit.envs/envs\": {\n * \"env\": \"teambit.harmony/aspect\"\n * },\n */\n config?: ComponentConfig;\n}\n\n/**\n * @deprecated use ForkComponentInfo instead.\n */\nexport type ComponentToImport = ForkComponentInfo;\n\nexport interface ImportComponentInfo {\n /**\n * full component id\n */\n id: string;\n\n /**\n * path where to write the component\n */\n path?: string;\n}\n\nexport interface WorkspaceTemplateOptions {\n /**\n * name of the workspace starter. for example: `react-workspace`.\n */\n name: string;\n\n /**\n * name of an app created in the workspace. for example: `my-app`.\n * This will be used to instruct the user to run `bit run <appName>` in the new workspace.\n */\n appName?: string;\n\n /**\n * short description of the starter. shown in the `bit starter` command when outside of bit-workspace.\n */\n description?: string;\n\n /**\n * hide this starter so that it is not listed with `bit starter`\n */\n hidden?: boolean;\n}\n\nexport interface WorkspaceTemplate extends WorkspaceTemplateOptions {\n /**\n * starter function for generating the template files,\n */\n generateFiles(context: WorkspaceContext): Promise<WorkspaceFile[]>;\n\n /**\n * @deprecated use `fork()` or `import()` instead\n * this is working similarly to `fork()`\n */\n importComponents?: (context: WorkspaceContext) => ForkComponentInfo[];\n\n /**\n * import components into the new workspace, don't change their source code.\n */\n import?: (context: WorkspaceContext) => ImportComponentInfo[];\n\n /**\n * populate existing components into the new workspace and add them as new components.\n * change their source code and update the dependency names according to the new component names.\n */\n fork?: (context: WorkspaceContext) => ForkComponentInfo[];\n\n /**\n * populate new components into the new workspace and add them as new components.\n */\n create?: (context: WorkspaceContext) => CreateComponentInfo[];\n}\n"],"mappings":"","ignoreList":[]}
@@ -1,10 +1,17 @@
1
- import { EnvService, Env, EnvContext, ServiceTransformationMap } from '@teambit/envs';
2
- import { ComponentTemplate } from './component-template';
3
- import { WorkspaceTemplate } from './workspace-template';
1
+ import chalk from 'chalk';
2
+ import { EnvService, Env, EnvContext, ServiceTransformationMap, EnvDefinition } from '@teambit/envs';
3
+ import { pick } from 'lodash';
4
+ import { ComponentTemplate, ComponentTemplateOptions } from './component-template';
5
+ import { WorkspaceTemplate, WorkspaceTemplateOptions } from './workspace-template';
4
6
 
5
7
  type GeneratorTransformationMap = ServiceTransformationMap & {
6
- getGeneratorTemplates: () => ComponentTemplate;
7
- getGeneratorStarters: () => WorkspaceTemplate;
8
+ getGeneratorTemplates: () => ComponentTemplate[];
9
+ getGeneratorStarters: () => WorkspaceTemplate[];
10
+ };
11
+
12
+ type Descriptor = {
13
+ templates?: ComponentTemplateOptions[];
14
+ starters?: WorkspaceTemplateOptions[];
8
15
  };
9
16
  export class GeneratorService implements EnvService<any> {
10
17
  name = 'generator';
@@ -25,4 +32,73 @@ export class GeneratorService implements EnvService<any> {
25
32
  },
26
33
  };
27
34
  }
35
+
36
+ getDescriptor(env: EnvDefinition): Descriptor | undefined {
37
+ let templates;
38
+ let starters;
39
+ const result: Descriptor = {};
40
+
41
+ if (env.env.getGeneratorTemplates) {
42
+ const generatorTemplates: ComponentTemplate[] = env.env.getGeneratorTemplates();
43
+
44
+ templates = (generatorTemplates || []).map((template) => {
45
+ return pick(template, [
46
+ 'name',
47
+ 'displayName',
48
+ 'exampleComponentName',
49
+ 'description',
50
+ 'hidden',
51
+ 'env',
52
+ 'installMissingDependencies',
53
+ 'isEnv',
54
+ 'isApp',
55
+ 'dependencies',
56
+ ]);
57
+ });
58
+ result.templates = templates;
59
+ }
60
+
61
+ if (env.env.getGeneratorTemplates) {
62
+ const generatorStarters: WorkspaceTemplate[] = env.env.getGeneratorStarters();
63
+
64
+ starters = (generatorStarters || []).map((template) => {
65
+ return pick(template, ['name', 'description', 'hidden', 'appName']);
66
+ });
67
+ result.starters = starters;
68
+ }
69
+
70
+ if (!templates && !starters) return undefined;
71
+
72
+ return result;
73
+ }
74
+
75
+ render(env: EnvDefinition) {
76
+ const descriptor = this.getDescriptor(env);
77
+ const templates = this.getTemplatesToRender(descriptor?.templates || []);
78
+ const starters = this.getStartersToRender(descriptor?.starters || []);
79
+ return [templates, starters].join('\n\n');
80
+ }
81
+
82
+ private getTemplatesToRender(templates: Descriptor['templates']) {
83
+ const templatesLabel = chalk.green('Configured templates:');
84
+ if (!templates) return `${templatesLabel}\nno templates configured`;
85
+ const templatesStr = templates
86
+ .map((template) => {
87
+ const name = template.displayName ? `${template.displayName}(${template.name})` : template.name;
88
+ return `${name} - ${template.description}`;
89
+ })
90
+ .join('\n');
91
+ return `${templatesLabel}\n${templatesStr}`;
92
+ }
93
+
94
+ private getStartersToRender(starters: Descriptor['starters']) {
95
+ const startersLabel = chalk.green('Configured starters:');
96
+ if (!starters) return `${startersLabel}\nno starters configured`;
97
+ const startersStr = starters
98
+ .map((starter) => {
99
+ return `${starter.name} - ${starter.description}`;
100
+ })
101
+ .join('\n');
102
+ return `${startersLabel}\n${startersStr}`;
103
+ }
28
104
  }
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@teambit/generator",
3
- "version": "1.0.372",
3
+ "version": "1.0.374",
4
4
  "homepage": "https://bit.cloud/teambit/generator/generator",
5
5
  "main": "dist/index.js",
6
6
  "componentId": {
7
7
  "scope": "teambit.generator",
8
8
  "name": "generator",
9
- "version": "1.0.372"
9
+ "version": "1.0.374"
10
10
  },
11
11
  "dependencies": {
12
12
  "camelcase": "6.2.0",
@@ -22,29 +22,29 @@
22
22
  "@teambit/harmony": "0.4.6",
23
23
  "@teambit/git.modules.git-ignore": "1.0.2",
24
24
  "@teambit/component.sources": "0.0.18",
25
- "@teambit/envs": "1.0.371",
26
- "@teambit/logger": "0.0.1041",
27
- "@teambit/new-component-helper": "1.0.371",
25
+ "@teambit/envs": "1.0.373",
26
+ "@teambit/logger": "0.0.1043",
27
+ "@teambit/new-component-helper": "1.0.373",
28
28
  "@teambit/pkg.modules.component-package-name": "0.0.3",
29
29
  "@teambit/toolbox.path.path": "0.0.2",
30
- "@teambit/tracker": "1.0.371",
31
- "@teambit/workspace-config-files": "1.0.371",
30
+ "@teambit/tracker": "1.0.373",
31
+ "@teambit/workspace-config-files": "1.0.373",
32
32
  "@teambit/workspace.modules.node-modules-linker": "0.0.193",
33
- "@teambit/workspace": "1.0.371",
34
- "@teambit/component": "1.0.371",
35
- "@teambit/cli": "0.0.948",
36
- "@teambit/graphql": "1.0.371",
37
- "@teambit/aspect-loader": "1.0.371",
38
- "@teambit/bit": "1.8.22",
39
- "@teambit/git": "1.0.371",
40
- "@teambit/compiler": "1.0.371",
41
- "@teambit/forking": "1.0.371",
33
+ "@teambit/workspace": "1.0.373",
34
+ "@teambit/component": "1.0.373",
35
+ "@teambit/cli": "0.0.950",
36
+ "@teambit/graphql": "1.0.373",
37
+ "@teambit/aspect-loader": "1.0.373",
38
+ "@teambit/bit": "1.8.24",
39
+ "@teambit/git": "1.0.373",
40
+ "@teambit/compiler": "1.0.373",
41
+ "@teambit/forking": "1.0.373",
42
42
  "@teambit/git.modules.git-executable": "0.0.1",
43
- "@teambit/host-initializer": "0.0.84",
44
- "@teambit/importer": "1.0.371",
45
- "@teambit/install": "1.0.371",
46
- "@teambit/ui": "1.0.371",
47
- "@teambit/config": "0.0.1122"
43
+ "@teambit/host-initializer": "0.0.86",
44
+ "@teambit/importer": "1.0.373",
45
+ "@teambit/install": "1.0.373",
46
+ "@teambit/ui": "1.0.373",
47
+ "@teambit/config": "0.0.1124"
48
48
  },
49
49
  "devDependencies": {
50
50
  "@types/fs-extra": "9.0.7",