@teambit/generator 0.0.1144 → 0.0.1146

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.
Files changed (148) hide show
  1. package/dist/component-template.d.ts +39 -22
  2. package/dist/component-template.js.map +1 -1
  3. package/dist/create.cmd.d.ts +10 -9
  4. package/dist/create.cmd.js +15 -12
  5. package/dist/create.cmd.js.map +1 -1
  6. package/dist/generator.graphql.d.ts +4 -0
  7. package/dist/generator.graphql.js +12 -1
  8. package/dist/generator.graphql.js.map +1 -1
  9. package/dist/generator.main.runtime.d.ts +5 -5
  10. package/dist/generator.main.runtime.js +16 -29
  11. package/dist/generator.main.runtime.js.map +1 -1
  12. package/dist/new.cmd.d.ts +6 -7
  13. package/dist/new.cmd.js +4 -0
  14. package/dist/new.cmd.js.map +1 -1
  15. package/dist/{preview-1693279117198.js → preview-1693538278577.js} +2 -2
  16. package/dist/templates/basic/basic.starter.d.ts +3 -0
  17. package/dist/templates/basic/basic.starter.js +39 -0
  18. package/dist/templates/basic/basic.starter.js.map +1 -0
  19. package/dist/templates/basic/index.d.ts +1 -0
  20. package/dist/templates/basic/index.js +20 -0
  21. package/dist/templates/basic/index.js.map +1 -0
  22. package/dist/templates/basic/template/files/git-ignore.d.ts +1 -0
  23. package/dist/templates/basic/template/files/git-ignore.js +118 -0
  24. package/dist/templates/basic/template/files/git-ignore.js.map +1 -0
  25. package/dist/templates/basic/template/files/workspace-config.d.ts +2 -0
  26. package/dist/templates/{workspace-generator/index.js → basic/template/files/workspace-config.js} +35 -11
  27. package/dist/templates/basic/template/files/workspace-config.js.map +1 -0
  28. package/dist/templates/component-generator/files/component-template-files/component.d.ts +1 -0
  29. package/dist/templates/component-generator/files/component-template-files/component.js +35 -0
  30. package/dist/templates/component-generator/files/component-template-files/component.js.map +1 -0
  31. package/dist/templates/component-generator/files/component-template-files/composition.d.ts +1 -0
  32. package/dist/templates/component-generator/files/component-template-files/composition.js +29 -0
  33. package/dist/templates/component-generator/files/component-template-files/composition.js.map +1 -0
  34. package/dist/templates/component-generator/files/component-template-files/index-file.d.ts +1 -0
  35. package/dist/templates/component-generator/files/component-template-files/index-file.js +24 -0
  36. package/dist/templates/component-generator/files/component-template-files/index-file.js.map +1 -0
  37. package/dist/templates/component-generator/files/component-template-files/test.d.ts +1 -0
  38. package/dist/templates/component-generator/files/component-template-files/test.js +31 -0
  39. package/dist/templates/component-generator/files/component-template-files/test.js.map +1 -0
  40. package/dist/templates/component-generator/files/component-template.d.ts +2 -0
  41. package/dist/templates/component-generator/files/component-template.js +67 -0
  42. package/dist/templates/component-generator/files/component-template.js.map +1 -0
  43. package/dist/templates/component-generator/files/index.d.ts +1 -1
  44. package/dist/templates/component-generator/files/index.js +1 -5
  45. package/dist/templates/component-generator/files/index.js.map +1 -1
  46. package/dist/templates/component-generator/index.d.ts +1 -1
  47. package/dist/templates/component-generator/index.js +36 -16
  48. package/dist/templates/component-generator/index.js.map +1 -1
  49. package/dist/templates/{component-generator → component-generator-standalone}/files/aspect-file.d.ts +1 -1
  50. package/dist/templates/component-generator-standalone/files/aspect-file.js.map +1 -0
  51. package/dist/templates/component-generator-standalone/files/index.d.ts +2 -0
  52. package/dist/templates/component-generator-standalone/files/index.js +19 -0
  53. package/dist/templates/component-generator-standalone/files/index.js.map +1 -0
  54. package/dist/templates/{component-generator → component-generator-standalone}/files/main-runtime.d.ts +1 -1
  55. package/dist/templates/component-generator-standalone/files/main-runtime.js.map +1 -0
  56. package/dist/templates/component-generator-standalone/index.d.ts +2 -0
  57. package/dist/templates/component-generator-standalone/index.js +64 -0
  58. package/dist/templates/component-generator-standalone/index.js.map +1 -0
  59. package/dist/templates/index.d.ts +4 -0
  60. package/dist/templates/index.js +59 -0
  61. package/dist/templates/index.js.map +1 -0
  62. package/dist/templates/starter/files/doc-file.d.ts +2 -0
  63. package/dist/templates/starter/files/doc-file.js +33 -0
  64. package/dist/templates/starter/files/doc-file.js.map +1 -0
  65. package/dist/templates/starter/files/generate-files.d.ts +1 -0
  66. package/dist/templates/starter/files/generate-files.js +35 -0
  67. package/dist/templates/starter/files/generate-files.js.map +1 -0
  68. package/dist/templates/starter/files/index.d.ts +1 -1
  69. package/dist/templates/starter/files/index.js +1 -1
  70. package/dist/templates/starter/files/index.js.map +1 -1
  71. package/dist/templates/starter/files/starter.d.ts +2 -1
  72. package/dist/templates/starter/files/starter.js +39 -29
  73. package/dist/templates/starter/files/starter.js.map +1 -1
  74. package/dist/templates/starter/files/workspace-config-tpl.js +7 -1
  75. package/dist/templates/starter/files/workspace-config-tpl.js.map +1 -1
  76. package/dist/templates/starter/index.d.ts +1 -1
  77. package/dist/templates/starter/index.js +16 -16
  78. package/dist/templates/starter/index.js.map +1 -1
  79. package/dist/templates/starter-standalone/files/doc-file.d.ts +2 -0
  80. package/dist/templates/starter-standalone/files/doc-file.js +33 -0
  81. package/dist/templates/starter-standalone/files/doc-file.js.map +1 -0
  82. package/dist/templates/starter-standalone/files/git-ignore-tpl.d.ts +1 -0
  83. package/dist/templates/starter-standalone/files/git-ignore-tpl.js +121 -0
  84. package/dist/templates/starter-standalone/files/git-ignore-tpl.js.map +1 -0
  85. package/dist/templates/starter-standalone/files/index.d.ts +2 -0
  86. package/dist/templates/starter-standalone/files/index.js +15 -0
  87. package/dist/templates/starter-standalone/files/index.js.map +1 -0
  88. package/dist/templates/starter-standalone/files/starter.d.ts +2 -0
  89. package/dist/templates/starter-standalone/files/starter.js +44 -0
  90. package/dist/templates/starter-standalone/files/starter.js.map +1 -0
  91. package/dist/templates/starter-standalone/files/workspace-config-tpl.d.ts +1 -0
  92. package/dist/templates/starter-standalone/files/workspace-config-tpl.js +30 -0
  93. package/dist/templates/starter-standalone/files/workspace-config-tpl.js.map +1 -0
  94. package/dist/templates/starter-standalone/index.d.ts +2 -0
  95. package/dist/templates/starter-standalone/index.js +73 -0
  96. package/dist/templates/starter-standalone/index.js.map +1 -0
  97. package/dist/workspace-generator.js +17 -1
  98. package/dist/workspace-generator.js.map +1 -1
  99. package/dist/workspace-template.d.ts +37 -29
  100. package/dist/workspace-template.js.map +1 -1
  101. package/package.json +22 -22
  102. package/templates/basic/basic.starter.ts +22 -0
  103. package/templates/basic/index.ts +1 -0
  104. package/templates/basic/template/files/git-ignore.ts +110 -0
  105. package/templates/basic/template/files/workspace-config.ts +33 -0
  106. package/templates/component-generator/files/component-template-files/component.ts +26 -0
  107. package/templates/component-generator/files/component-template-files/composition.ts +20 -0
  108. package/templates/component-generator/files/component-template-files/index-file.ts +15 -0
  109. package/templates/component-generator/files/component-template-files/test.ts +22 -0
  110. package/templates/component-generator/files/component-template.ts +58 -0
  111. package/templates/component-generator/files/index.ts +2 -6
  112. package/templates/component-generator/index.ts +22 -12
  113. package/templates/{component-generator → component-generator-standalone}/files/aspect-file.ts +1 -1
  114. package/templates/component-generator-standalone/files/index.ts +10 -0
  115. package/templates/{component-generator → component-generator-standalone}/files/main-runtime.ts +1 -1
  116. package/templates/component-generator-standalone/index.ts +39 -0
  117. package/templates/index.ts +4 -0
  118. package/templates/starter/files/doc-file.ts +24 -0
  119. package/templates/starter/files/generate-files.ts +27 -0
  120. package/templates/starter/files/index.ts +2 -2
  121. package/templates/starter/files/starter.ts +37 -28
  122. package/templates/starter/files/workspace-config-tpl.ts +7 -1
  123. package/templates/starter/index.ts +13 -11
  124. package/templates/starter-standalone/files/doc-file.ts +24 -0
  125. package/templates/starter-standalone/files/git-ignore-tpl.ts +113 -0
  126. package/templates/starter-standalone/files/index.ts +6 -0
  127. package/templates/starter-standalone/files/starter.ts +35 -0
  128. package/templates/starter-standalone/files/workspace-config-tpl.ts +22 -0
  129. package/templates/starter-standalone/index.ts +44 -0
  130. package/dist/templates/component-generator/files/aspect-file.js.map +0 -1
  131. package/dist/templates/component-generator/files/main-runtime.js.map +0 -1
  132. package/dist/templates/starter/files/docs-file.d.ts +0 -1
  133. package/dist/templates/starter/files/docs-file.js +0 -45
  134. package/dist/templates/starter/files/docs-file.js.map +0 -1
  135. package/dist/templates/starter/files/readme-tpl.d.ts +0 -1
  136. package/dist/templates/starter/files/readme-tpl.js +0 -47
  137. package/dist/templates/starter/files/readme-tpl.js.map +0 -1
  138. package/dist/templates/workspace-generator/index.d.ts +0 -2
  139. package/dist/templates/workspace-generator/index.js.map +0 -1
  140. package/templates/starter/files/docs-file.ts +0 -37
  141. package/templates/starter/files/readme-tpl.ts +0 -39
  142. package/templates/workspace-generator/index.ts +0 -10
  143. /package/dist/templates/{component-generator → component-generator-standalone}/files/aspect-file.js +0 -0
  144. /package/dist/templates/{component-generator → component-generator-standalone}/files/docs-file.d.ts +0 -0
  145. /package/dist/templates/{component-generator → component-generator-standalone}/files/docs-file.js +0 -0
  146. /package/dist/templates/{component-generator → component-generator-standalone}/files/docs-file.js.map +0 -0
  147. /package/dist/templates/{component-generator → component-generator-standalone}/files/main-runtime.js +0 -0
  148. /package/templates/{component-generator → component-generator-standalone}/files/docs-file.ts +0 -0
@@ -1,19 +1,8 @@
1
- import { ComponentID } from '@teambit/component-id';
2
- export interface ComponentFile {
3
- /**
4
- * relative path of the file within the component.
5
- */
6
- relativePath: string;
7
- /**
8
- * file content
9
- */
10
- content: string;
11
- /**
12
- * whether this file will be tracked as the main file
13
- */
14
- isMain?: boolean;
15
- }
16
- export interface ComponentContext {
1
+ import { ComponentID } from '@teambit/component';
2
+ /**
3
+ * BaseComponentTemplateOptions describes the foundational properties for components.
4
+ */
5
+ export interface BaseComponentTemplateOptions {
17
6
  /**
18
7
  * component-name as entered by the user, e.g. `use-date`.
19
8
  * without the scope and the namespace.
@@ -37,15 +26,43 @@ export interface ComponentContext {
37
26
  /**
38
27
  * aspect id of the aspect that register the template itself
39
28
  */
40
- aspectId: ComponentID;
29
+ aspectId: ComponentID | string;
41
30
  /**
42
- * env id of the env that register the template itself
43
- * This will be usually identical to the aspectId
44
- * but aspectId will always exist, while envId will be undefined if the template is not registered by an env
45
- * so in case you want to use the envId, you should check if it exists first
46
- * You can use this in case you want to only do something if the template was registered by an env
31
+ * env id of the env that register the template itself.
32
+ * This will be usually identical to the aspectId but aspectId will always exist,
33
+ * while envId will be undefined if the template is not registered by an env.
47
34
  */
48
35
  envId?: ComponentID;
36
+ /**
37
+ * path of the component.
38
+ */
39
+ path?: string;
40
+ /**
41
+ * scope of the component.
42
+ */
43
+ scope?: string;
44
+ /**
45
+ * namespace of the component.
46
+ */
47
+ namespace?: string;
48
+ }
49
+ /**
50
+ * ComponentContext represents foundational properties for a component context.
51
+ */
52
+ export declare type ComponentContext = BaseComponentTemplateOptions;
53
+ export interface ComponentFile {
54
+ /**
55
+ * relative path of the file within the component.
56
+ */
57
+ relativePath: string;
58
+ /**
59
+ * file content
60
+ */
61
+ content: string;
62
+ /**
63
+ * whether this file will be tracked as the main file
64
+ */
65
+ isMain?: boolean;
49
66
  }
50
67
  export interface ConfigContext {
51
68
  /**
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["component-template.ts"],"sourcesContent":["import { ComponentID } from '@teambit/component-id';\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 ComponentContext {\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;\n\n /**\n * env id of the env that register the template itself\n * This will be usually identical to the aspectId\n * but aspectId will always exist, while envId will be undefined if the template is not registered by an env\n * so in case you want to use the envId, you should check if it exists first\n * You can use this in case you want to only do something if the template was registered by an env\n */\n envId?: ComponentID;\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 ComponentTemplate {\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 component.\n */\n env?: 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":""}
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 ComponentTemplate {\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 component.\n */\n env?: 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":""}
@@ -1,15 +1,16 @@
1
1
  import { Command, CommandOptions } from '@teambit/cli';
2
+ import { ComponentID } from '@teambit/component';
2
3
  import { GeneratorMain } from './generator.main.runtime';
3
- export declare type CreateOptions = {
4
- namespace?: string;
5
- aspect?: string;
6
- scope?: string;
7
- path?: string;
8
- env?: string;
4
+ import type { BaseComponentTemplateOptions } from './component-template';
5
+ /**
6
+ * CreateOptions combines foundational properties with additional options for creating a component.
7
+ */
8
+ export declare type CreateOptions = BaseComponentTemplateOptions & {
9
+ env: string;
10
+ aspect: string;
9
11
  };
10
12
  export declare class CreateCmd implements Command {
11
13
  private generator;
12
- private docsDomain;
13
14
  name: string;
14
15
  description: string;
15
16
  alias: string;
@@ -25,8 +26,8 @@ export declare class CreateCmd implements Command {
25
26
  }[];
26
27
  group: string;
27
28
  options: CommandOptions;
28
- constructor(generator: GeneratorMain, docsDomain: string);
29
+ constructor(generator: GeneratorMain);
29
30
  report([templateName, componentNames]: [string, string[]], options: CreateOptions & {
30
- template?: string;
31
+ template?: string | ComponentID;
31
32
  }): Promise<string>;
32
33
  }
@@ -21,10 +21,13 @@ function _chalk() {
21
21
  };
22
22
  return data;
23
23
  }
24
+ /**
25
+ * CreateOptions combines foundational properties with additional options for creating a component.
26
+ */
27
+
24
28
  class CreateCmd {
25
- constructor(generator, docsDomain) {
29
+ constructor(generator) {
26
30
  this.generator = generator;
27
- this.docsDomain = docsDomain;
28
31
  (0, _defineProperty2().default)(this, "name", 'create <template-name> <component-names...>');
29
32
  (0, _defineProperty2().default)(this, "description", 'create a new component (source files and config) using a template.');
30
33
  (0, _defineProperty2().default)(this, "alias", '');
@@ -38,24 +41,24 @@ class CreateCmd {
38
41
  description: 'a list of component names to generate'
39
42
  }]);
40
43
  (0, _defineProperty2().default)(this, "examples", [{
41
- cmd: 'bit create react ui/button',
44
+ cmd: 'bit create react ui/button --aspect teambit.react/react-env',
42
45
  description: "creates a component named 'ui/button' using the 'react' template"
43
46
  }, {
44
- cmd: 'bit create react ui/button pages/register',
45
- description: "creates two components, 'ui/button' and 'pages/register', using the 'react' template"
47
+ cmd: 'bit create node utils/is-string utils/is-number --aspect teambit.node/node',
48
+ description: "creates two components, 'utils/is-string' and 'utils/is-number' using the 'node' template from the 'node' aspect(env)"
46
49
  }, {
47
- cmd: 'bit create react ui/button --scope my-org.my-scope',
48
- description: "creates a component named 'ui/button' and sets it scope to 'my-org.my-scope'. \nby default, the scope is the `defaultScope` value, configured in your `workspace.jsonc`."
50
+ cmd: 'bit create mdx docs/create-components --aspect teambit.mdx/mdx-env --scope my-org.my-scope',
51
+ description: "creates an mdx component named 'docs/create-components' and sets it scope to 'my-org.my-scope'. \nby default, the scope is the `defaultScope` value, configured in your `workspace.jsonc`."
49
52
  }, {
50
- cmd: 'bit create react ui/button --env teambit.community/envs/community-react@1.95.13',
51
- description: "creates a component named 'ui/button' and sets it to use the 'community-react' env. \n(the template's default env is 'teambit.react/react')."
53
+ cmd: 'bit create react ui/button --aspect teambit.react/react-env --env teambit.community/envs/community-react@3.0.3',
54
+ description: "creates a component named 'ui/button' from the teambit.react/react-env env and sets it to use the 'community-react' env. \n(the template's default env is 'teambit.react/react-env')."
52
55
  }]);
53
56
  (0, _defineProperty2().default)(this, "group", 'development');
54
57
  (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'], ['t', 'template <string>', 'env-id of the template. alias for --aspect.'], ['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)"]]);
55
58
  }
56
59
  async report([templateName, componentNames], options) {
57
- var _options$aspect;
58
- options.aspect = (_options$aspect = options.aspect) !== null && _options$aspect !== void 0 ? _options$aspect : options.template;
60
+ var _options$aspectId;
61
+ options.aspectId = (_options$aspectId = options.aspectId) !== null && _options$aspectId !== void 0 ? _options$aspectId : options.template;
59
62
  const results = await this.generator.generateComponentTemplate(componentNames, templateName, options);
60
63
  const title = `${results.length} component(s) were created`;
61
64
  const componentsData = results.map(result => {
@@ -65,7 +68,7 @@ class CreateCmd {
65
68
  package: ${result.packageName}
66
69
  `;
67
70
  }).join('\n');
68
- const footer = `env configuration is according to workspace variants, template config or --env flag. learn more at https://${this.docsDomain}/envs/using-envs`;
71
+ const footer = `env configuration is according to workspace variants, template config or --env flag.`;
69
72
  return `${_chalk().default.green(title)}\n\n${componentsData}\n\n${footer}`;
70
73
  }
71
74
  }
@@ -1 +1 @@
1
- {"version":3,"names":["_chalk","data","_interopRequireDefault","require","CreateCmd","constructor","generator","docsDomain","_defineProperty2","default","name","description","cmd","report","templateName","componentNames","options","_options$aspect","aspect","template","results","generateComponentTemplate","title","length","componentsData","map","result","chalk","bold","id","toString","dir","envId","envSetBy","packageName","join","footer","green","exports"],"sources":["create.cmd.ts"],"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 <template-name> <component-names...>';\n description = 'create a new component (source files and config) using a template.';\n alias = '';\n loader = true;\n helpUrl = 'reference/starters/create-starter';\n arguments = [\n {\n name: 'template-name',\n description:\n \"the template for generating the component \\n(run 'bit templates' for a list of available templates)\",\n },\n {\n name: 'component-names...',\n description: 'a list of component names to generate',\n },\n ];\n examples = [\n {\n cmd: 'bit create react ui/button',\n description: \"creates a component named 'ui/button' using the 'react' template\",\n },\n {\n cmd: 'bit create react ui/button pages/register',\n description: \"creates two components, 'ui/button' and 'pages/register', using the 'react' template\",\n },\n {\n cmd: 'bit create react ui/button --scope my-org.my-scope',\n description:\n \"creates a component named 'ui/button' and sets it scope to 'my-org.my-scope'. \\nby default, the scope is the `defaultScope` value, configured in your `workspace.jsonc`.\",\n },\n {\n cmd: 'bit create react ui/button --env teambit.community/envs/community-react@1.95.13',\n description:\n \"creates a component named 'ui/button' and sets it to use the 'community-react' env. \\n(the template's default env is 'teambit.react/react').\",\n },\n ];\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 ['t', 'template <string>', 'env-id of the template. alias for --aspect.'],\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, private docsDomain: string) {}\n\n async report(\n [templateName, componentNames]: [string, string[]],\n options: CreateOptions & {\n template?: string;\n }\n ) {\n options.aspect = options.aspect ?? options.template;\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} (set by ${result.envSetBy})\n package: ${result.packageName}\n`;\n })\n .join('\\n');\n const footer = `env configuration is according to workspace variants, template config or --env flag. learn more at https://${this.docsDomain}/envs/using-envs`;\n\n return `${chalk.green(title)}\\n\\n${componentsData}\\n\\n${footer}`;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;AACA,SAAAA,OAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAH,MAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAWO,MAAMG,SAAS,CAAoB;EA+CxCC,WAAWA,CAASC,SAAwB,EAAUC,UAAkB,EAAE;IAAA,KAAtDD,SAAwB,GAAxBA,SAAwB;IAAA,KAAUC,UAAkB,GAAlBA,UAAkB;IAAA,IAAAC,gBAAA,GAAAC,OAAA,gBA9CjE,6CAA6C;IAAA,IAAAD,gBAAA,GAAAC,OAAA,uBACtC,oEAAoE;IAAA,IAAAD,gBAAA,GAAAC,OAAA,iBAC1E,EAAE;IAAA,IAAAD,gBAAA,GAAAC,OAAA,kBACD,IAAI;IAAA,IAAAD,gBAAA,GAAAC,OAAA,mBACH,mCAAmC;IAAA,IAAAD,gBAAA,GAAAC,OAAA,qBACjC,CACV;MACEC,IAAI,EAAE,eAAe;MACrBC,WAAW,EACT;IACJ,CAAC,EACD;MACED,IAAI,EAAE,oBAAoB;MAC1BC,WAAW,EAAE;IACf,CAAC,CACF;IAAA,IAAAH,gBAAA,GAAAC,OAAA,oBACU,CACT;MACEG,GAAG,EAAE,4B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MAAM,CAACM,KAAM,YAAWN,MAAM,CAACO,QAAS;AACxD,gBAAgBP,MAAM,CAACQ,WAAY;AACnC,CAAC;IACK,CAAC,CAAC,CACDC,IAAI,CAAC,IAAI,CAAC;IACb,MAAMC,MAAM,GAAI,8GAA6G,IAAI,CAAC7B,UAAW,kBAAiB;IAE9J,OAAQ,GAAEoB,gBAAK,CAACU,KAAK,CAACf,KAAK,CAAE,OAAME,cAAe,OAAMY,MAAO,EAAC;EAClE;AACF;AAACE,OAAA,CAAAlC,SAAA,GAAAA,SAAA"}
1
+ {"version":3,"names":["_chalk","data","_interopRequireDefault","require","CreateCmd","constructor","generator","_defineProperty2","default","name","description","cmd","report","templateName","componentNames","options","_options$aspectId","aspectId","template","results","generateComponentTemplate","title","length","componentsData","map","result","chalk","bold","id","toString","dir","envId","envSetBy","packageName","join","footer","green","exports"],"sources":["create.cmd.ts"],"sourcesContent":["import { Command, CommandOptions } from '@teambit/cli';\nimport { ComponentID } from '@teambit/component';\nimport chalk from 'chalk';\nimport { GeneratorMain } from './generator.main.runtime';\nimport type { BaseComponentTemplateOptions } from './component-template';\n\n/**\n * CreateOptions combines foundational properties with additional options for creating a component.\n */\nexport type CreateOptions = BaseComponentTemplateOptions & {\n env: string;\n aspect: string;\n};\n\nexport class CreateCmd implements Command {\n name = 'create <template-name> <component-names...>';\n description = 'create a new component (source files and config) using a template.';\n alias = '';\n loader = true;\n helpUrl = 'reference/starters/create-starter';\n arguments = [\n {\n name: 'template-name',\n description:\n \"the template for generating the component \\n(run 'bit templates' for a list of available templates)\",\n },\n {\n name: 'component-names...',\n description: 'a list of component names to generate',\n },\n ];\n examples = [\n {\n cmd: 'bit create react ui/button --aspect teambit.react/react-env',\n description: \"creates a component named 'ui/button' using the 'react' template\",\n },\n {\n cmd: 'bit create node utils/is-string utils/is-number --aspect teambit.node/node',\n description:\n \"creates two components, 'utils/is-string' and 'utils/is-number' using the 'node' template from the 'node' aspect(env)\",\n },\n {\n cmd: 'bit create mdx docs/create-components --aspect teambit.mdx/mdx-env --scope my-org.my-scope',\n description:\n \"creates an mdx component named 'docs/create-components' and sets it scope to 'my-org.my-scope'. \\nby default, the scope is the `defaultScope` value, configured in your `workspace.jsonc`.\",\n },\n {\n cmd: 'bit create react ui/button --aspect teambit.react/react-env --env teambit.community/envs/community-react@3.0.3',\n description:\n \"creates a component named 'ui/button' from the teambit.react/react-env env and sets it to use the 'community-react' env. \\n(the template's default env is 'teambit.react/react-env').\",\n },\n ];\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 ['t', 'template <string>', 'env-id of the template. alias for --aspect.'],\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(\n [templateName, componentNames]: [string, string[]],\n options: CreateOptions & {\n template?: string | ComponentID;\n }\n ) {\n options.aspectId = options.aspectId ?? options.template;\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} (set by ${result.envSetBy})\n package: ${result.packageName}\n`;\n })\n .join('\\n');\n const footer = `env configuration is according to workspace variants, template config or --env flag.`;\n\n return `${chalk.green(title)}\\n\\n${componentsData}\\n\\n${footer}`;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAEA,SAAAA,OAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAH,MAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAIA;AACA;AACA;;AAMO,MAAMG,SAAS,CAAoB;E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cAAc,CAAqB,EAClDC,OAEC,EACD;IAAA,IAAAC,iBAAA;IACAD,OAAO,CAACE,QAAQ,IAAAD,iBAAA,GAAGD,OAAO,CAACE,QAAQ,cAAAD,iBAAA,cAAAA,iBAAA,GAAID,OAAO,CAACG,QAAQ;IACvD,MAAMC,OAAO,GAAG,MAAM,IAAI,CAACb,SAAS,CAACc,yBAAyB,CAACN,cAAc,EAAED,YAAY,EAAEE,OAAO,CAAC;IACrG,MAAMM,KAAK,GAAI,GAAEF,OAAO,CAACG,MAAO,4BAA2B;IAE3D,MAAMC,cAAc,GAAGJ,OAAO,CAC3BK,GAAG,CAAEC,MAAM,IAAK;MACf,OAAQ,GAAEC,gBAAK,CAACC,IAAI,CAACF,MAAM,CAACG,EAAE,CAACC,QAAQ,CAAC,CAAC,CAAE;AACnD,gBAAgBJ,MAAM,CAACK,GAAI;AAC3B,gBAAgBL,MAAM,CAACM,KAAM,YAAWN,MAAM,CAACO,QAAS;AACxD,gBAAgBP,MAAM,CAACQ,WAAY;AACnC,CAAC;IACK,CAAC,CAAC,CACDC,IAAI,CAAC,IAAI,CAAC;IACb,MAAMC,MAAM,GAAI,sFAAqF;IAErG,OAAQ,GAAET,gBAAK,CAACU,KAAK,CAACf,KAAK,CAAE,OAAME,cAAe,OAAMY,MAAO,EAAC;EAClE;AACF;AAACE,OAAA,CAAAjC,SAAA,GAAAA,SAAA"}
@@ -1,3 +1,7 @@
1
1
  import { Schema } from '@teambit/graphql';
2
2
  import { GeneratorMain } from './generator.main.runtime';
3
+ import { CreateOptions } from './create.cmd';
4
+ export declare type CreateQueryOptions = CreateOptions & {
5
+ templateName: string;
6
+ };
3
7
  export declare function generatorSchema(generator: GeneratorMain): Schema;
@@ -6,6 +6,13 @@ Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
8
  exports.generatorSchema = generatorSchema;
9
+ function _defineProperty2() {
10
+ const data = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
+ _defineProperty2 = function () {
12
+ return data;
13
+ };
14
+ return data;
15
+ }
9
16
  function _objectWithoutProperties2() {
10
17
  const data = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
11
18
  _objectWithoutProperties2 = function () {
@@ -20,6 +27,8 @@ function _graphqlTag() {
20
27
  };
21
28
  return data;
22
29
  }
30
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
31
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2().default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
23
32
  function generatorSchema(generator) {
24
33
  return {
25
34
  typeDefs: (0, _graphqlTag().default)`
@@ -61,7 +70,9 @@ function generatorSchema(generator) {
61
70
  templateName
62
71
  } = _ref,
63
72
  options = (0, _objectWithoutProperties2().default)(_ref, ["name", "templateName"]);
64
- const res = await generator.generateComponentTemplate([name], templateName, options);
73
+ const res = await generator.generateComponentTemplate([name], templateName, _objectSpread({
74
+ name
75
+ }, options));
65
76
  return res.map(component => ({
66
77
  id: component.id.toString(),
67
78
  dir: component.dir,
@@ -1 +1 @@
1
- {"version":3,"names":["_graphqlTag","data","_interopRequireDefault","require","generatorSchema","generator","typeDefs","gql","resolvers","Mutation","createComponent","req","_ref","name","templateName","options","_objectWithoutProperties2","default","res","generateComponentTemplate","map","component","id","toString","dir","files","Generator","templates","listTemplates","Query"],"sources":["generator.graphql.ts"],"sourcesContent":["import { Schema } from '@teambit/graphql';\nimport gql from 'graphql-tag';\nimport { GeneratorMain } from './generator.main.runtime';\n\nexport function generatorSchema(generator: GeneratorMain): Schema {\n return {\n typeDefs: gql`\n type GenerateResult {\n id: String\n dir: String\n files: [String]\n }\n\n type Mutation {\n # create Component by template\n createComponent(\n name: String!\n templateName: String!\n scope: String\n namespace: String\n aspect: String\n ): [GenerateResult]\n }\n\n type TemplateDescriptor {\n aspectId: String!\n name: String!\n }\n\n type Generator {\n templates: [TemplateDescriptor]\n }\n\n type Query {\n generator: Generator\n }\n `,\n resolvers: {\n Mutation: {\n createComponent: async (\n req: any,\n {\n name,\n templateName,\n ...options\n }: { name: string; templateName: string; scope?: string; namespace?: string; aspect?: string }\n ) => {\n const res = await generator.generateComponentTemplate([name], templateName, options);\n return res.map((component) => ({\n id: component.id.toString(),\n dir: component.dir,\n files: component.files,\n }));\n },\n },\n Generator: {\n templates: async () => {\n return generator.listTemplates();\n },\n },\n Query: {\n generator: () => generator,\n },\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;AACA,SAAAA,YAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAH,WAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAGO,SAASG,eAAeA,CAACC,SAAwB,EAAU;EAChE,OAAO;IACLC,QAAQ,EAAE,IAAAC,qBAAG,CAAC;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;IACDC,SAAS,EAAE;MACTC,QAAQ,EAAE;QACRC,eAAe,EAAE,MAAAA,CACfC,GAAQ,EAAAC,IAAA,KAML;UAAA,IALH;cACEC,IAAI;cACJC;YAE2F,CAAC,GAAAF,IAAA;YADzFG,OAAO,OAAAC,yBAAA,GAAAC,OAAA,EAAAL,IAAA;UAGZ,MAAMM,GAAG,GAAG,MAAMb,SAAS,CAACc,yBAAyB,CAAC,CAACN,IAAI,CAAC,EAAEC,YAAY,EAAEC,OAAO,CAAC;UACpF,OAAOG,GAAG,CAACE,GAAG,CAAEC,SAAS,KAAM;YAC7BC,EAAE,EAAED,SAAS,CAACC,EAAE,CAACC,QAAQ,CAAC,CAAC;YAC3BC,GAAG,EAAEH,SAAS,CAACG,GAAG;YAClBC,KAAK,EAAEJ,SAAS,CAACI;UACnB,CAAC,CAAC,CAAC;QACL;MACF,CAAC;MACDC,SAAS,EAAE;QACTC,SAAS,EAAE,MAAAA,CAAA,KAAY;UACrB,OAAOtB,SAAS,CAACuB,aAAa,CAAC,CAAC;QAClC;MACF,CAAC;MACDC,KAAK,EAAE;QACLxB,SAAS,EAAEA,CAAA,KAAMA;MACnB;IACF;EACF,CAAC;AACH"}
1
+ {"version":3,"names":["_graphqlTag","data","_interopRequireDefault","require","ownKeys","object","enumerableOnly","keys","Object","getOwnPropertySymbols","symbols","filter","sym","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","target","i","arguments","length","source","forEach","key","_defineProperty2","default","getOwnPropertyDescriptors","defineProperties","defineProperty","generatorSchema","generator","typeDefs","gql","resolvers","Mutation","createComponent","req","_ref","name","templateName","options","_objectWithoutProperties2","res","generateComponentTemplate","map","component","id","toString","dir","files","Generator","templates","listTemplates","Query"],"sources":["generator.graphql.ts"],"sourcesContent":["import { Schema } from '@teambit/graphql';\nimport gql from 'graphql-tag';\nimport { GeneratorMain } from './generator.main.runtime';\nimport { CreateOptions } from './create.cmd';\n\nexport type CreateQueryOptions = CreateOptions & { templateName: string };\n\nexport function generatorSchema(generator: GeneratorMain): Schema {\n return {\n typeDefs: gql`\n type GenerateResult {\n id: String\n dir: String\n files: [String]\n }\n\n type Mutation {\n # create Component by template\n createComponent(\n name: String!\n templateName: String!\n scope: String\n namespace: String\n aspect: String\n ): [GenerateResult]\n }\n\n type TemplateDescriptor {\n aspectId: String!\n name: String!\n }\n\n type Generator {\n templates: [TemplateDescriptor]\n }\n\n type Query {\n generator: Generator\n }\n `,\n resolvers: {\n Mutation: {\n createComponent: async (req: any, { name, templateName, ...options }: CreateQueryOptions) => {\n const res = await generator.generateComponentTemplate([name], templateName, { name, ...options });\n return res.map((component) => ({\n id: component.id.toString(),\n dir: component.dir,\n files: component.files,\n }));\n },\n },\n Generator: {\n templates: async () => {\n return generator.listTemplates();\n },\n },\n Query: {\n generator: () => generator,\n },\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AACA,SAAAA,YAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAH,WAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAA8B,SAAAG,QAAAC,MAAA,EAAAC,cAAA,QAAAC,IAAA,GAAAC,MAAA,CAAAD,IAAA,CAAAF,MAAA,OAAAG,MAAA,CAAAC,qBAAA,QAAAC,OAAA,GAAAF,MAAA,CAAAC,qBAAA,CAAAJ,MAAA,GAAAC,cAAA,KAAAI,OAAA,GAAAA,OAAA,CAAAC,MAAA,WAAAC,GAAA,WAAAJ,MAAA,CAAAK,wBAAA,CAAAR,MAAA,EAAAO,GAAA,EAAAE,UAAA,OAAAP,IAAA,CAAAQ,IAAA,CAAAC,KAAA,CAAAT,IAAA,EAAAG,OAAA,YAAAH,IAAA;AAAA,SAAAU,cAAAC,MAAA,aAAAC,CAAA,MAAAA,CAAA,GAAAC,SAAA,CAAAC,MAAA,EAAAF,CAAA,UAAAG,MAAA,WAAAF,SAAA,CAAAD,CAAA,IAAAC,SAAA,CAAAD,CAAA,QAAAA,CAAA,OAAAf,OAAA,CAAAI,MAAA,CAAAc,MAAA,OAAAC,OAAA,WAAAC,GAAA,QAAAC,gBAAA,GAAAC,OAAA,EAAAR,MAAA,EAAAM,GAAA,EAAAF,MAAA,CAAAE,GAAA,SAAAhB,MAAA,CAAAmB,yBAAA,GAAAnB,MAAA,CAAAoB,gBAAA,CAA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AAA,KAAMA;MACnB;IACF;EACF,CAAC;AACH"}
@@ -2,7 +2,6 @@ import { GraphqlMain } from '@teambit/graphql';
2
2
  import { CLIMain } from '@teambit/cli';
3
3
  import { Workspace } from '@teambit/workspace';
4
4
  import { EnvDefinition, EnvsMain } from '@teambit/envs';
5
- import type { CommunityMain } from '@teambit/community';
6
5
  import { WorkspaceConfigFilesMain } from '@teambit/workspace-config-files';
7
6
  import type { ComponentMain, Component } from '@teambit/component';
8
7
  import { SlotRegistry } from '@teambit/harmony';
@@ -76,7 +75,7 @@ export declare class GeneratorMain {
76
75
  */
77
76
  registerComponentTemplate(templates: ComponentTemplate[]): this;
78
77
  /**
79
- * register a new component template.
78
+ * register a new workspace starter.
80
79
  */
81
80
  registerWorkspaceTemplate(templates: WorkspaceTemplate[]): this;
82
81
  registerOnComponentCreate(fn: OnComponentCreateFn): this;
@@ -129,7 +128,9 @@ export declare class GeneratorMain {
129
128
  }>;
130
129
  searchRegisteredWorkspaceTemplate(name?: string, aspectId?: string, remoteEnvsAspect?: EnvsMain): Promise<WorkspaceTemplate | undefined>;
131
130
  generateComponentTemplate(componentNames: string[], templateName: string, options: CreateOptions): Promise<GenerateResult[]>;
132
- generateWorkspaceTemplate(workspaceName: string, templateName: string, options: NewOptions): Promise<GenerateWorkspaceTemplateResult>;
131
+ generateWorkspaceTemplate(workspaceName: string, templateName: string, options: NewOptions & {
132
+ aspect?: string;
133
+ }): Promise<GenerateWorkspaceTemplateResult>;
133
134
  private getAllComponentTemplatesDescriptorsFlattened;
134
135
  private getAllComponentTemplatesFlattened;
135
136
  private getAllWorkspaceTemplatesDescriptorFlattened;
@@ -148,14 +149,13 @@ export declare class GeneratorMain {
148
149
  static slots: (((registerFn: () => string) => SlotRegistry<ComponentTemplate[]>) | ((registerFn: () => string) => SlotRegistry<WorkspaceTemplate[]>) | ((registerFn: () => string) => SlotRegistry<OnComponentCreateFn>))[];
149
150
  static dependencies: import("@teambit/bit").Aspect[];
150
151
  static runtime: import("@teambit/bit").RuntimeDefinition;
151
- static provider([workspace, cli, graphql, envs, aspectLoader, newComponentHelper, community, componentAspect, tracker, loggerMain, git, wsConfigFiles,]: [
152
+ static provider([workspace, cli, graphql, envs, aspectLoader, newComponentHelper, componentAspect, tracker, loggerMain, git, wsConfigFiles,]: [
152
153
  Workspace,
153
154
  CLIMain,
154
155
  GraphqlMain,
155
156
  EnvsMain,
156
157
  AspectLoaderMain,
157
158
  NewComponentHelperMain,
158
- CommunityMain,
159
159
  ComponentMain,
160
160
  TrackerMain,
161
161
  LoggerMain,
@@ -46,13 +46,6 @@ function _envs() {
46
46
  };
47
47
  return data;
48
48
  }
49
- function _community() {
50
- const data = require("@teambit/community");
51
- _community = function () {
52
- return data;
53
- };
54
- return data;
55
- }
56
49
  function _config() {
57
50
  const data = _interopRequireDefault(require("@teambit/legacy/dist/consumer/config"));
58
51
  _config = function () {
@@ -186,30 +179,23 @@ function _new() {
186
179
  };
187
180
  return data;
188
181
  }
189
- function _componentGenerator2() {
190
- const data = require("./templates/component-generator");
191
- _componentGenerator2 = function () {
182
+ function _templates2() {
183
+ const data = require("./templates");
184
+ _templates2 = function () {
192
185
  return data;
193
186
  };
194
187
  return data;
195
188
  }
196
- function _workspaceGenerator2() {
197
- const data = require("./templates/workspace-generator");
198
- _workspaceGenerator2 = function () {
189
+ function _basic() {
190
+ const data = require("./templates/basic");
191
+ _basic = function () {
199
192
  return data;
200
193
  };
201
194
  return data;
202
195
  }
203
196
  function _starter() {
204
- const data = require("./templates/starter");
205
- _starter = function () {
206
- return data;
207
- };
208
- return data;
209
- }
210
- function _starter2() {
211
197
  const data = require("./starter.plugin");
212
- _starter2 = function () {
198
+ _starter = function () {
213
199
  return data;
214
200
  };
215
201
  return data;
@@ -268,7 +254,7 @@ class GeneratorMain {
268
254
  }
269
255
 
270
256
  /**
271
- * register a new component template.
257
+ * register a new workspace starter.
272
258
  */
273
259
  registerWorkspaceTemplate(templates) {
274
260
  this.workspaceTemplateSlot.register(templates);
@@ -445,10 +431,10 @@ class GeneratorMain {
445
431
  await this.loadAspects();
446
432
  const {
447
433
  namespace,
448
- aspect: aspectId
434
+ aspect
449
435
  } = options;
450
436
  const componentConfigLoadingRegistry = _config().default.componentConfigLoadingRegistry;
451
- const templateWithId = await this.getComponentTemplate(templateName, aspectId);
437
+ const templateWithId = await this.getComponentTemplate(templateName, aspect);
452
438
  _config().default.componentConfigLoadingRegistry = componentConfigLoadingRegistry;
453
439
  if (!templateWithId) throw new (_bitError().BitError)(`template "${templateName}" was not found`);
454
440
  const componentIds = componentNames.map(componentName => this.newComponentHelper.getNewComponentId(componentName, namespace, options.scope));
@@ -594,21 +580,22 @@ class GeneratorMain {
594
580
  await this.workspace.loadAspects(this.config.aspects);
595
581
  this.aspectLoaded = true;
596
582
  }
597
- static async provider([workspace, cli, graphql, envs, aspectLoader, newComponentHelper, community, componentAspect, tracker, loggerMain, git, wsConfigFiles], config, [componentTemplateSlot, workspaceTemplateSlot, onComponentCreateSlot]) {
583
+ static async provider([workspace, cli, graphql, envs, aspectLoader, newComponentHelper, componentAspect, tracker, loggerMain, git, wsConfigFiles], config, [componentTemplateSlot, workspaceTemplateSlot, onComponentCreateSlot]) {
598
584
  const logger = loggerMain.createLogger(_generator().GeneratorAspect.id);
599
585
  const generator = new GeneratorMain(componentTemplateSlot, workspaceTemplateSlot, onComponentCreateSlot, config, workspace, envs, aspectLoader, newComponentHelper, componentAspect, tracker, logger, git, wsConfigFiles);
600
- const commands = [new (_create().CreateCmd)(generator, community.getDocsDomain()), new (_templates().TemplatesCmd)(generator), new (_new().NewCmd)(generator)];
586
+ const commands = [new (_create().CreateCmd)(generator), new (_templates().TemplatesCmd)(generator), new (_new().NewCmd)(generator)];
601
587
  cli.register(...commands);
602
588
  graphql.register((0, _generator2().generatorSchema)(generator));
603
- aspectLoader.registerPlugins([new (_starter2().StarterPlugin)(generator)]);
589
+ aspectLoader.registerPlugins([new (_starter().StarterPlugin)(generator)]);
604
590
  envs.registerService(new (_generator3().GeneratorService)());
605
- if (generator) generator.registerComponentTemplate([_componentGenerator2().componentGeneratorTemplate, _starter().starterTemplate, _workspaceGenerator2().workspaceGeneratorTemplate]);
591
+ if (generator) generator.registerComponentTemplate([_templates2().componentGeneratorTemplate, _templates2().componentGeneratorTemplateStandalone, _templates2().starterTemplate, _templates2().starterTemplateStandalone]);
592
+ generator.registerWorkspaceTemplate([_basic().BasicWorkspaceStarter]);
606
593
  return generator;
607
594
  }
608
595
  }
609
596
  exports.GeneratorMain = GeneratorMain;
610
597
  (0, _defineProperty2().default)(GeneratorMain, "slots", [_harmony().Slot.withType(), _harmony().Slot.withType(), _harmony().Slot.withType()]);
611
- (0, _defineProperty2().default)(GeneratorMain, "dependencies", [_workspace().default, _cli().CLIAspect, _graphql().GraphqlAspect, _envs().EnvsAspect, _aspectLoader().default, _newComponentHelper().default, _community().CommunityAspect, _component().default, _tracker().default, _logger().LoggerAspect, _git().default, _workspaceConfigFiles().default]);
598
+ (0, _defineProperty2().default)(GeneratorMain, "dependencies", [_workspace().default, _cli().CLIAspect, _graphql().GraphqlAspect, _envs().EnvsAspect, _aspectLoader().default, _newComponentHelper().default, _component().default, _tracker().default, _logger().LoggerAspect, _git().default, _workspaceConfigFiles().default]);
612
599
  (0, _defineProperty2().default)(GeneratorMain, "runtime", _cli().MainRuntime);
613
600
  _generator().GeneratorAspect.addRuntime(GeneratorMain);
614
601