@teambit/generator 1.0.9 → 1.0.11

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 (46) hide show
  1. package/dist/generator.composition.d.ts +2 -2
  2. package/dist/generator.main.runtime.js +2 -3
  3. package/dist/generator.main.runtime.js.map +1 -1
  4. package/dist/preview-1695901055662.js +7 -0
  5. package/dist/templates/basic/basic.starter.js +4 -8
  6. package/dist/templates/basic/basic.starter.js.map +1 -1
  7. package/dist/templates/basic/template/files/workspace-config.js +2 -2
  8. package/dist/templates/basic/template/files/workspace-config.js.map +1 -1
  9. package/dist/templates/starter/files/starter.js +0 -4
  10. package/dist/templates/starter/files/starter.js.map +1 -1
  11. package/dist/templates/starter/files/workspace-config-tpl.js +9 -19
  12. package/dist/templates/starter/files/workspace-config-tpl.js.map +1 -1
  13. package/dist/templates/starter-standalone/files/starter.js +0 -9
  14. package/dist/templates/starter-standalone/files/starter.js.map +1 -1
  15. package/dist/templates/starter-standalone/files/workspace-config-tpl.js +8 -19
  16. package/dist/templates/starter-standalone/files/workspace-config-tpl.js.map +1 -1
  17. package/package.json +24 -23
  18. package/templates/basic/basic.starter.ts +5 -10
  19. package/templates/basic/template/files/workspace-config.ts +2 -2
  20. package/templates/starter/files/starter.ts +1 -5
  21. package/templates/starter/files/workspace-config-tpl.ts +10 -20
  22. package/templates/starter-standalone/files/starter.ts +1 -10
  23. package/templates/starter-standalone/files/workspace-config-tpl.ts +9 -20
  24. package/tsconfig.json +40 -0
  25. package/types/asset.d.ts +29 -0
  26. package/types/style.d.ts +42 -0
  27. package/.bit-capsule-ready +0 -0
  28. package/component-generator.ts +0 -271
  29. package/component-template.ts +0 -122
  30. package/create.cmd.ts +0 -88
  31. package/generator-env-type.ts +0 -14
  32. package/generator.aspect.ts +0 -5
  33. package/generator.graphql.ts +0 -62
  34. package/generator.main.runtime.ts +0 -577
  35. package/index.ts +0 -14
  36. package/new.cmd.ts +0 -114
  37. package/package-tar/teambit-generator-1.0.9.tgz +0 -0
  38. package/schema.json +0 -10304
  39. package/starter-list.ts +0 -21
  40. package/starter.plugin.ts +0 -16
  41. package/teambit_generator_generator-preview.js +0 -11
  42. package/template-list.ts +0 -21
  43. package/templates.cmd.ts +0 -55
  44. package/types.ts +0 -3
  45. package/workspace-generator.ts +0 -205
  46. package/workspace-template.ts +0 -145
package/create.cmd.ts DELETED
@@ -1,88 +0,0 @@
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,14 +0,0 @@
1
- import { EnvHandler } from '@teambit/envs';
2
- import { TemplateList } from './template-list';
3
- import { StarterList } from './starter-list';
4
-
5
- export interface GeneratorEnv {
6
- /**
7
- * return a template list instance.
8
- */
9
- generators(): EnvHandler<TemplateList>;
10
- /**
11
- * return a starter list instance.
12
- */
13
- starters(): EnvHandler<StarterList>;
14
- }
@@ -1,5 +0,0 @@
1
- import { Aspect } from '@teambit/harmony';
2
-
3
- export const GeneratorAspect = Aspect.create({
4
- id: 'teambit.generator/generator',
5
- });
@@ -1,62 +0,0 @@
1
- import { Schema } from '@teambit/graphql';
2
- import gql from 'graphql-tag';
3
- import { GeneratorMain } from './generator.main.runtime';
4
- import { CreateOptions } from './create.cmd';
5
-
6
- export type CreateQueryOptions = CreateOptions & { templateName: string };
7
-
8
- export function generatorSchema(generator: GeneratorMain): Schema {
9
- return {
10
- typeDefs: gql`
11
- type GenerateResult {
12
- id: String
13
- dir: String
14
- files: [String]
15
- }
16
-
17
- type Mutation {
18
- # create Component by template
19
- createComponent(
20
- name: String!
21
- templateName: String!
22
- scope: String
23
- namespace: String
24
- aspect: String
25
- ): [GenerateResult]
26
- }
27
-
28
- type TemplateDescriptor {
29
- aspectId: String!
30
- name: String!
31
- }
32
-
33
- type Generator {
34
- templates: [TemplateDescriptor]
35
- }
36
-
37
- type Query {
38
- generator: Generator
39
- }
40
- `,
41
- resolvers: {
42
- Mutation: {
43
- createComponent: async (req: any, { name, templateName, ...options }: CreateQueryOptions) => {
44
- const res = await generator.generateComponentTemplate([name], templateName, { name, ...options });
45
- return res.map((component) => ({
46
- id: component.id.toString(),
47
- dir: component.dir,
48
- files: component.files,
49
- }));
50
- },
51
- },
52
- Generator: {
53
- templates: async () => {
54
- return generator.listTemplates();
55
- },
56
- },
57
- Query: {
58
- generator: () => generator,
59
- },
60
- },
61
- };
62
- }