@teambit/generator 1.0.8 → 1.0.9

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 (48) hide show
  1. package/.bit-capsule-ready +0 -0
  2. package/component-generator.ts +271 -0
  3. package/component-template.ts +122 -0
  4. package/create.cmd.ts +88 -0
  5. package/dist/generator.composition.d.ts +2 -2
  6. package/dist/generator.graphql.js +2 -2
  7. package/dist/generator.graphql.js.map +1 -1
  8. package/dist/generator.main.runtime.js +5 -4
  9. package/dist/generator.main.runtime.js.map +1 -1
  10. package/dist/templates/basic/basic.starter.js +8 -4
  11. package/dist/templates/basic/basic.starter.js.map +1 -1
  12. package/dist/templates/basic/template/files/workspace-config.js +4 -4
  13. package/dist/templates/basic/template/files/workspace-config.js.map +1 -1
  14. package/dist/templates/starter/files/starter.js +4 -0
  15. package/dist/templates/starter/files/starter.js.map +1 -1
  16. package/dist/templates/starter/files/workspace-config-tpl.js +19 -9
  17. package/dist/templates/starter/files/workspace-config-tpl.js.map +1 -1
  18. package/dist/templates/starter-standalone/files/starter.js +9 -0
  19. package/dist/templates/starter-standalone/files/starter.js.map +1 -1
  20. package/dist/templates/starter-standalone/files/workspace-config-tpl.js +19 -8
  21. package/dist/templates/starter-standalone/files/workspace-config-tpl.js.map +1 -1
  22. package/generator-env-type.ts +14 -0
  23. package/generator.aspect.ts +5 -0
  24. package/generator.graphql.ts +62 -0
  25. package/generator.main.runtime.ts +577 -0
  26. package/index.ts +14 -0
  27. package/new.cmd.ts +114 -0
  28. package/package-tar/teambit-generator-1.0.9.tgz +0 -0
  29. package/package.json +22 -23
  30. package/schema.json +10304 -0
  31. package/starter-list.ts +21 -0
  32. package/starter.plugin.ts +16 -0
  33. package/teambit_generator_generator-preview.js +11 -0
  34. package/template-list.ts +21 -0
  35. package/templates/basic/basic.starter.ts +10 -5
  36. package/templates/basic/template/files/workspace-config.ts +2 -2
  37. package/templates/starter/files/starter.ts +5 -1
  38. package/templates/starter/files/workspace-config-tpl.ts +20 -10
  39. package/templates/starter-standalone/files/starter.ts +10 -1
  40. package/templates/starter-standalone/files/workspace-config-tpl.ts +20 -9
  41. package/templates.cmd.ts +55 -0
  42. package/types.ts +3 -0
  43. package/workspace-generator.ts +205 -0
  44. package/workspace-template.ts +145 -0
  45. package/dist/preview-1695698249502.js +0 -7
  46. package/tsconfig.json +0 -40
  47. package/types/asset.d.ts +0 -29
  48. package/types/style.d.ts +0 -42
File without changes
@@ -0,0 +1,271 @@
1
+ import Vinyl from 'vinyl';
2
+ import fs from 'fs-extra';
3
+ import pMapSeries from 'p-map-series';
4
+ import path from 'path';
5
+ import { Workspace } from '@teambit/workspace';
6
+ import EnvsAspect, { EnvsMain } from '@teambit/envs';
7
+ import camelcase from 'camelcase';
8
+ import { BitError } from '@teambit/bit-error';
9
+ import { Logger } from '@teambit/logger';
10
+ import { TrackerMain } from '@teambit/tracker';
11
+ import { linkToNodeModulesByIds } from '@teambit/workspace.modules.node-modules-linker';
12
+ import { PathOsBasedRelative } from '@teambit/legacy/dist/utils/path';
13
+ import { AbstractVinyl } from '@teambit/legacy/dist/consumer/component/sources';
14
+ import componentIdToPackageName from '@teambit/legacy/dist/utils/bit/component-id-to-package-name';
15
+ import DataToPersist from '@teambit/legacy/dist/consumer/component/sources/data-to-persist';
16
+ import { NewComponentHelperMain } from '@teambit/new-component-helper';
17
+ import { ComponentID } from '@teambit/component-id';
18
+ import { WorkspaceConfigFilesMain } from '@teambit/workspace-config-files';
19
+
20
+ import { ComponentTemplate, ComponentFile, ComponentConfig } from './component-template';
21
+ import { CreateOptions } from './create.cmd';
22
+ import { OnComponentCreateSlot } from './generator.main.runtime';
23
+
24
+ export type GenerateResult = {
25
+ id: ComponentID;
26
+ dir: string;
27
+ files: string[];
28
+ envId: string;
29
+ envSetBy: string;
30
+ packageName: string;
31
+ };
32
+
33
+ export type OnComponentCreateFn = (generateResults: GenerateResult[]) => Promise<void>;
34
+
35
+ export class ComponentGenerator {
36
+ constructor(
37
+ private workspace: Workspace,
38
+ private componentIds: ComponentID[],
39
+ private options: Partial<CreateOptions>,
40
+ private template: ComponentTemplate,
41
+ private envs: EnvsMain,
42
+ private newComponentHelper: NewComponentHelperMain,
43
+ private tracker: TrackerMain,
44
+ private wsConfigFiles: WorkspaceConfigFilesMain,
45
+ private logger: Logger,
46
+ private onComponentCreateSlot: OnComponentCreateSlot,
47
+ private aspectId: string,
48
+ private envId?: ComponentID
49
+ ) {}
50
+
51
+ async generate(): Promise<GenerateResult[]> {
52
+ const dirsToDeleteIfFailed: string[] = [];
53
+ const generateResults = await pMapSeries(this.componentIds, async (componentId) => {
54
+ try {
55
+ const componentPath = this.newComponentHelper.getNewComponentPath(
56
+ componentId,
57
+ this.options.path,
58
+ this.componentIds.length
59
+ );
60
+ if (fs.existsSync(path.join(this.workspace.path, componentPath))) {
61
+ throw new BitError(`unable to create a component at "${componentPath}", this path already exist`);
62
+ }
63
+ if (await this.workspace.hasName(componentId.fullName)) {
64
+ throw new BitError(
65
+ `unable to create a component "${componentId.fullName}", a component with the same name already exist`
66
+ );
67
+ }
68
+ dirsToDeleteIfFailed.push(componentPath);
69
+ return await this.generateOneComponent(componentId, componentPath);
70
+ } catch (err: any) {
71
+ await this.deleteGeneratedComponents(dirsToDeleteIfFailed);
72
+ throw err;
73
+ }
74
+ });
75
+
76
+ await this.workspace.bitMap.write();
77
+
78
+ const ids = generateResults.map((r) => r.id);
79
+ await this.tryLinkToNodeModules(ids);
80
+ await this.runOnComponentCreateHook(generateResults);
81
+ // We are running this after the runOnComponentCreateHook as it require
82
+ // the env to be installed to work properly, and the hook might install
83
+ // the env.
84
+ await this.tryWriteConfigFiles(ids);
85
+
86
+ return generateResults;
87
+ }
88
+
89
+ private async tryLinkToNodeModules(ids: ComponentID[]) {
90
+ try {
91
+ await linkToNodeModulesByIds(
92
+ this.workspace,
93
+ ids.map((id) => id._legacy)
94
+ );
95
+ } catch (err: any) {
96
+ this.logger.consoleFailure(
97
+ `failed linking the new components to node_modules, please run "bit link" manually. error: ${err.message}`
98
+ );
99
+ }
100
+ }
101
+
102
+ private async runOnComponentCreateHook(generateResults: GenerateResult[]) {
103
+ const fns = this.onComponentCreateSlot.values();
104
+ if (!fns.length) return;
105
+ await Promise.all(fns.map((fn) => fn(generateResults)));
106
+ }
107
+
108
+ /**
109
+ * The function `tryWriteConfigFiles` attempts to write workspace config files, and if it fails, it logs an error
110
+ * message.
111
+ * @returns If the condition `!shouldWrite` is true, then nothing is being returned. Otherwise, if the `writeConfigFiles`
112
+ * function is successfully executed, nothing is being returned. If an error occurs during the execution of
113
+ * `writeConfigFiles`, an error message is being returned.
114
+ */
115
+ private async tryWriteConfigFiles(ids: ComponentID[]) {
116
+ try {
117
+ const shouldWrite = this.wsConfigFiles.isWorkspaceConfigWriteEnabled();
118
+ if (!shouldWrite) return;
119
+ ids.map((id) => this.workspace.clearComponentCache(id));
120
+ await this.wsConfigFiles.writeConfigFiles({
121
+ clean: true,
122
+ silent: true,
123
+ dedupe: true,
124
+ });
125
+ } catch (err: any) {
126
+ this.logger.consoleFailure(
127
+ `failed generating workspace config files, please run "bit ws-config write" manually. error: ${err.message}`
128
+ );
129
+ }
130
+ }
131
+
132
+ private async deleteGeneratedComponents(dirs: string[]) {
133
+ await Promise.all(
134
+ dirs.map(async (dir) => {
135
+ const absoluteDir = path.join(this.workspace.path, dir);
136
+ try {
137
+ await fs.remove(absoluteDir);
138
+ } catch (err: any) {
139
+ if (err.code !== 'ENOENT') {
140
+ // if not exist, it's fine
141
+ throw err;
142
+ }
143
+ }
144
+ })
145
+ );
146
+ }
147
+
148
+ private async generateOneComponent(componentId: ComponentID, componentPath: string): Promise<GenerateResult> {
149
+ const name = componentId.name;
150
+ const namePascalCase = camelcase(name, { pascalCase: true });
151
+ const nameCamelCase = camelcase(name);
152
+ const aspectId = ComponentID.fromString(this.aspectId);
153
+
154
+ const files = await this.template.generateFiles({
155
+ name,
156
+ namePascalCase,
157
+ nameCamelCase,
158
+ componentId,
159
+ aspectId,
160
+ envId: this.envId,
161
+ });
162
+ const mainFile = files.find((file) => file.isMain);
163
+ await this.writeComponentFiles(componentPath, files);
164
+ const addResults = await this.tracker.track({
165
+ rootDir: componentPath,
166
+ mainFile: mainFile?.relativePath,
167
+ componentName: componentId.fullName,
168
+ defaultScope: this.options.scope,
169
+ });
170
+ const component = await this.workspace.get(componentId);
171
+ const hasEnvConfiguredOriginally = this.envs.hasEnvConfigured(component);
172
+ const envBeforeConfigChanges = this.envs.getEnv(component);
173
+ let config = this.template.config;
174
+ if (config && typeof config === 'function') {
175
+ const boundConfig = this.template.config?.bind(this.template);
176
+ config = boundConfig({ aspectId: this.aspectId });
177
+ }
178
+
179
+ if (!config && this.envId) {
180
+ const isInWorkspace = this.workspace.exists(this.envId);
181
+ config = {
182
+ [isInWorkspace ? this.envId.toStringWithoutVersion() : this.envId.toString()]: {},
183
+ 'teambit.envs/envs': {
184
+ env: this.envId.toStringWithoutVersion(),
185
+ },
186
+ };
187
+ }
188
+
189
+ const templateEnv = config?.[EnvsAspect.id]?.env;
190
+
191
+ if (config && templateEnv && hasEnvConfiguredOriginally) {
192
+ // remove the env we got from the template.
193
+ delete config[templateEnv];
194
+ delete config[EnvsAspect.id].env;
195
+ if (Object.keys(config[EnvsAspect.id]).length === 0) delete config[EnvsAspect.id];
196
+ if (Object.keys(config).length === 0) config = undefined;
197
+ }
198
+
199
+ const configWithEnv = await this.addEnvIfProvidedByFlag(config);
200
+ if (configWithEnv) this.workspace.bitMap.setEntireConfig(component.id, configWithEnv);
201
+
202
+ const getEnvData = () => {
203
+ const envFromFlag = this.options.env; // env entered by the user when running `bit create --env`
204
+ const envFromTemplate = config?.[EnvsAspect.id]?.env;
205
+ if (envFromFlag) {
206
+ return {
207
+ envId: envFromFlag,
208
+ setBy: '--env flag',
209
+ };
210
+ }
211
+ if (envFromTemplate) {
212
+ return {
213
+ envId: envFromTemplate,
214
+ setBy: 'template',
215
+ };
216
+ }
217
+ return {
218
+ envId: envBeforeConfigChanges.id,
219
+ setBy: hasEnvConfiguredOriginally ? 'workspace variants' : '<default>',
220
+ };
221
+ };
222
+ const { envId, setBy } = getEnvData();
223
+ return {
224
+ id: componentId,
225
+ dir: componentPath,
226
+ files: addResults.files,
227
+ packageName: componentIdToPackageName(component.state._consumer),
228
+ envId,
229
+ envSetBy: setBy,
230
+ };
231
+ }
232
+
233
+ private async addEnvIfProvidedByFlag(config?: ComponentConfig): Promise<ComponentConfig | undefined> {
234
+ const userEnv = this.options.env; // env entered by the user when running `bit create --env`
235
+ const templateEnv = config?.[EnvsAspect.id]?.env;
236
+ if (!userEnv || userEnv === templateEnv) {
237
+ return config;
238
+ }
239
+ config = config || {};
240
+ if (templateEnv) {
241
+ // the component template has an env and the user wants a different env.
242
+ delete config[templateEnv];
243
+ }
244
+ await this.tracker.addEnvToConfig(userEnv, config);
245
+
246
+ return config;
247
+ }
248
+
249
+ /**
250
+ * writes the generated template files to the default directory set in the workspace config
251
+ */
252
+ private async writeComponentFiles(
253
+ componentPath: string,
254
+ templateFiles: ComponentFile[]
255
+ ): Promise<PathOsBasedRelative[]> {
256
+ const dataToPersist = new DataToPersist();
257
+ const vinylFiles = templateFiles.map((templateFile) => {
258
+ const templateFileVinyl = new Vinyl({
259
+ base: componentPath,
260
+ path: path.join(componentPath, templateFile.relativePath),
261
+ contents: Buffer.from(templateFile.content),
262
+ });
263
+ return AbstractVinyl.fromVinyl(templateFileVinyl);
264
+ });
265
+ const results = vinylFiles.map((v) => v.path);
266
+ dataToPersist.addManyFiles(vinylFiles);
267
+ dataToPersist.addBasePath(this.workspace.path);
268
+ await dataToPersist.persistAllToFS();
269
+ return results;
270
+ }
271
+ }
@@ -0,0 +1,122 @@
1
+ import { ComponentID } from '@teambit/component';
2
+
3
+ /**
4
+ * BaseComponentTemplateOptions describes the foundational properties for components.
5
+ */
6
+ export interface BaseComponentTemplateOptions {
7
+ /**
8
+ * component-name as entered by the user, e.g. `use-date`.
9
+ * without the scope and the namespace.
10
+ */
11
+ name: string;
12
+
13
+ /**
14
+ * component-name as upper camel case, e.g. `use-date` becomes `UseDate`.
15
+ * useful when generating the file content, for example for a class name.
16
+ */
17
+ namePascalCase: string;
18
+
19
+ /**
20
+ * component-name as lower camel case, e.g. `use-date` becomes `useDate`.
21
+ * useful when generating the file content, for example for a function/variable name.
22
+ */
23
+ nameCamelCase: string;
24
+
25
+ /**
26
+ * component id.
27
+ * the name is the name+namespace. the scope is the scope entered by --scope flag or the defaultScope
28
+ */
29
+ componentId: ComponentID;
30
+
31
+ /**
32
+ * aspect id of the aspect that register the template itself
33
+ */
34
+ aspectId: ComponentID | string;
35
+
36
+ /**
37
+ * env id of the env that register the template itself.
38
+ * This will be usually identical to the aspectId but aspectId will always exist,
39
+ * while envId will be undefined if the template is not registered by an env.
40
+ */
41
+ envId?: ComponentID;
42
+
43
+ /**
44
+ * path of the component.
45
+ */
46
+ path?: string;
47
+ /**
48
+ * scope of the component.
49
+ */
50
+ scope?: string;
51
+ /**
52
+ * namespace of the component.
53
+ */
54
+ namespace?: string;
55
+ }
56
+
57
+ /**
58
+ * ComponentContext represents foundational properties for a component context.
59
+ */
60
+ export type ComponentContext = BaseComponentTemplateOptions;
61
+
62
+ export interface ComponentFile {
63
+ /**
64
+ * relative path of the file within the component.
65
+ */
66
+ relativePath: string;
67
+
68
+ /**
69
+ * file content
70
+ */
71
+ content: string;
72
+
73
+ /**
74
+ * whether this file will be tracked as the main file
75
+ */
76
+ isMain?: boolean;
77
+ }
78
+
79
+ export interface ConfigContext {
80
+ /**
81
+ * Aspect id of the aspect that register the template itself
82
+ */
83
+ aspectId: string;
84
+ }
85
+
86
+ export type ComponentConfig = { [aspectName: string]: any };
87
+
88
+ export interface ComponentTemplate {
89
+ /**
90
+ * name of the component template. for example: `hook`, `react-component` or `module`.
91
+ */
92
+ name: string;
93
+
94
+ /**
95
+ * short description of the template. shown in the `bit templates` command.
96
+ */
97
+ description?: string;
98
+
99
+ /**
100
+ * hide this template so that it is not listed with `bit templates`
101
+ */
102
+ hidden?: boolean;
103
+
104
+ /**
105
+ * env to use for the component.
106
+ */
107
+ env?: string;
108
+
109
+ /**
110
+ * template function for generating the file of a certain component.,
111
+ */
112
+ generateFiles(context: ComponentContext): Promise<ComponentFile[]> | ComponentFile[];
113
+
114
+ /**
115
+ * component config. gets saved in the .bitmap file and it overrides the workspace.jsonc config.
116
+ * for example, you can set the env that will be used for this component as follows:
117
+ * "teambit.envs/envs": {
118
+ * "env": "teambit.harmony/aspect"
119
+ * },
120
+ */
121
+ config?: ComponentConfig | ((context: ConfigContext) => ComponentConfig);
122
+ }
package/create.cmd.ts ADDED
@@ -0,0 +1,88 @@
1
+ import { Command, CommandOptions } from '@teambit/cli';
2
+ import { ComponentID } from '@teambit/component';
3
+ import chalk from 'chalk';
4
+ import { GeneratorMain } from './generator.main.runtime';
5
+ import type { BaseComponentTemplateOptions } from './component-template';
6
+
7
+ /**
8
+ * CreateOptions combines foundational properties with additional options for creating a component.
9
+ */
10
+ export type CreateOptions = BaseComponentTemplateOptions & {
11
+ env?: string;
12
+ aspect?: string;
13
+ };
14
+
15
+ export class CreateCmd implements Command {
16
+ name = 'create <template-name> <component-names...>';
17
+ description = 'create a new component (source files and config) using a template.';
18
+ alias = '';
19
+ loader = true;
20
+ helpUrl = 'reference/starters/create-starter';
21
+ arguments = [
22
+ {
23
+ name: 'template-name',
24
+ description:
25
+ "the template for generating the component \n(run 'bit templates' for a list of available templates)",
26
+ },
27
+ {
28
+ name: 'component-names...',
29
+ description: 'a list of component names to generate',
30
+ },
31
+ ];
32
+ examples = [
33
+ {
34
+ cmd: 'bit create react ui/button --aspect teambit.react/react-env',
35
+ description: "creates a component named 'ui/button' using the 'react' template",
36
+ },
37
+ {
38
+ cmd: 'bit create node utils/is-string utils/is-number --aspect teambit.node/node',
39
+ description:
40
+ "creates two components, 'utils/is-string' and 'utils/is-number' using the 'node' template from the 'node' aspect(env)",
41
+ },
42
+ {
43
+ cmd: 'bit create mdx docs/create-components --aspect teambit.mdx/mdx-env --scope my-org.my-scope',
44
+ description:
45
+ "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`.",
46
+ },
47
+ {
48
+ cmd: 'bit create react ui/button --aspect teambit.react/react-env --env teambit.community/envs/community-react@3.0.3',
49
+ description:
50
+ "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').",
51
+ },
52
+ ];
53
+ group = 'development';
54
+ options = [
55
+ ['n', 'namespace <string>', `sets the component's namespace and nested dirs inside the scope`],
56
+ ['s', 'scope <string>', `sets the component's scope-name. if not entered, the default-scope will be used`],
57
+ ['a', 'aspect <string>', 'aspect-id of the template. helpful when multiple aspects use the same template name'],
58
+ ['t', 'template <string>', 'env-id of the template. alias for --aspect.'],
59
+ ['p', 'path <string>', 'relative path in the workspace. by default the path is `<scope>/<namespace>/<name>`'],
60
+ ['e', 'env <string>', "set the component's environment. (overrides the env from variants and the template)"],
61
+ ] as CommandOptions;
62
+
63
+ constructor(private generator: GeneratorMain) {}
64
+
65
+ async report(
66
+ [templateName, componentNames]: [string, string[]],
67
+ options: Partial<CreateOptions> & {
68
+ template?: string | ComponentID;
69
+ }
70
+ ) {
71
+ options.aspectId = options.aspectId ?? options.template;
72
+ const results = await this.generator.generateComponentTemplate(componentNames, templateName, options);
73
+ const title = `${results.length} component(s) were created`;
74
+
75
+ const componentsData = results
76
+ .map((result) => {
77
+ return `${chalk.bold(result.id.toString())}
78
+ location: ${result.dir}
79
+ env: ${result.envId} (set by ${result.envSetBy})
80
+ package: ${result.packageName}
81
+ `;
82
+ })
83
+ .join('\n');
84
+ const footer = `env configuration is according to workspace variants, template config or --env flag.`;
85
+
86
+ return `${chalk.green(title)}\n\n${componentsData}\n\n${footer}`;
87
+ }
88
+ }
@@ -1,2 +1,2 @@
1
- /// <reference types="react" />
2
- export declare const Logo: () => JSX.Element;
1
+ import React from 'react';
2
+ export declare const Logo: () => React.JSX.Element;
@@ -13,8 +13,8 @@ function _graphqlTag() {
13
13
  }
14
14
  const _excluded = ["name", "templateName"];
15
15
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
16
- 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; }
17
- 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) { _defineProperty(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; }
16
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
17
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
18
18
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
19
19
  function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
20
20
  function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
@@ -1 +1 @@
1
- {"version":3,"names":["_graphqlTag","data","_interopRequireDefault","require","_excluded","obj","__esModule","default","ownKeys","object","enumerableOnly","keys","Object","getOwnPropertySymbols","symbols","filter","sym","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","target","i","arguments","length","source","forEach","key","_defineProperty","getOwnPropertyDescriptors","defineProperties","defineProperty","value","_toPropertyKey","configurable","writable","arg","_toPrimitive","String","input","hint","prim","Symbol","toPrimitive","undefined","res","call","TypeError","Number","_objectWithoutProperties","excluded","_objectWithoutPropertiesLoose","sourceSymbolKeys","indexOf","prototype","propertyIsEnumerable","sourceKeys","generatorSchema","generator","typeDefs","gql","resolvers","Mutation","createComponent","req","_ref","name","templateName","options","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,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AS,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,OAAOnB,SAAS,CAACoB,aAAa,CAAC,CAAC;QAClC;MACF,CAAC;MACDC,KAAK,EAAE;QACLrB,SAAS,EAAEA,CAAA,KAAMA;MACnB;IACF;EACF,CAAC;AACH"}
1
+ {"version":3,"names":["_graphqlTag","data","_interopRequireDefault","require","_excluded","obj","__esModule","default","ownKeys","e","r","t","Object","keys","getOwnPropertySymbols","o","filter","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty","getOwnPropertyDescriptors","defineProperties","defineProperty","key","value","_toPropertyKey","configurable","writable","arg","_toPrimitive","String","input","hint","prim","Symbol","toPrimitive","undefined","res","call","TypeError","Number","_objectWithoutProperties","source","excluded","target","_objectWithoutPropertiesLoose","i","sourceSymbolKeys","indexOf","prototype","propertyIsEnumerable","sourceKeys","generatorSchema","generator","typeDefs","gql","resolvers","Mutation","createComponent","req","_ref","name","templateName","options","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,MAAAG,SAAA;AAAA,SAAAF,uBAAAG,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAAA,SAAAG,QAAAC,CAAA,EAAAC,CAAA,QAAAC,CAAA,GAAAC,MAAA,CAAAC,IAAA,CAAAJ,CAAA,OAAAG,MAAA,CAAAE,qBAAA,QAAAC,CAAA,GAAAH,MAAA,CAAAE,qBAAA,CAAAL,CAAA,GAAAC,CAAA,KAAAK,CAAA,GAAAA,CAAA,CAAAC,MAAA,WAAAN,CAAA,WAAAE,MAAA,CAAAK,wBAAA,CAAAR,CAAA,EAAAC,CAAA,EAAAQ,UAAA,OAAAP,CAAA,CAAAQ,IAAA,CAAAC,KAAA,CAAAT,CAAA,EAAAI,CAAA,YAAAJ,CAAA;AAAA,SAAAU,cAAAZ,CAAA,aAAAC,CAAA,MAAAA,CAAA,GAAAY,SAAA,CAAAC,MAAA,EAAAb,CAAA,UAAAC,CAAA,WAAAW,SAAA,CAAAZ,CAAA,IAAAY,SAAA,CAAAZ,CAAA,QAAAA,CAAA,OAAAF,OAAA,CAAAI,MAAA,CAAAD,CAAA,OAAAa,OAAA,WAAAd,CAAA,IAAA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AAAmB,IAAA,EAAA9D,SAAA;UAChE,MAAMuC,GAAG,GAAG,MAAMgB,SAAS,CAACW,yBAAyB,CAAC,CAACH,IAAI,CAAC,EAAEC,YAAY,EAAA/C,aAAA;YAAI8C;UAAI,GAAKE,OAAO,CAAE,CAAC;UACjG,OAAO1B,GAAG,CAAC4B,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,OAAOnB,SAAS,CAACoB,aAAa,CAAC,CAAC;QAClC;MACF,CAAC;MACDC,KAAK,EAAE;QACLrB,SAAS,EAAEA,CAAA,KAAMA;MACnB;IACF;EACF,CAAC;AACH"}
@@ -196,8 +196,8 @@ function _generator3() {
196
196
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
197
197
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
198
198
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
199
- 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; }
200
- 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) { _defineProperty(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; }
199
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
200
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
201
201
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
202
202
  function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
203
203
  function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
@@ -533,9 +533,10 @@ class GeneratorMain {
533
533
  remoteEnvsAspect = globals.remoteEnvsAspect;
534
534
  fullAspectId = globals.fullAspectId;
535
535
  }
536
- const allIds = configEnvs === null || configEnvs === void 0 ? void 0 : configEnvs.concat(ids).concat([aspectId, fullAspectId]).filter(Boolean);
536
+ const allIds = [...new Set(configEnvs.concat(ids).concat([aspectId, fullAspectId]).filter(Boolean))];
537
537
  const envs = await this.loadEnvs(allIds, remoteEnvsAspect);
538
- const templates = envs.flatMap(env => {
538
+ const uniqueEnvs = envs.filter((v, i, a) => a.findIndex(t => t.id === v.id) === i);
539
+ const templates = uniqueEnvs.flatMap(env => {
539
540
  if (!env.env.getGeneratorTemplates) return [];
540
541
  const tpls = env.env.getGeneratorTemplates() || [];
541
542
  const componentId = _component().ComponentID.fromString(env.id);