@teambit/generator 1.0.229 → 1.0.230

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. package/artifacts/__bit_junit.xml +1 -1
  2. package/artifacts/preview/teambit_generator_generator-preview.js +1 -1
  3. package/artifacts/schema.json +501 -118
  4. package/dist/component-generator.d.ts +56 -0
  5. package/dist/component-template.d.ts +130 -0
  6. package/dist/create.cmd.d.ts +35 -0
  7. package/dist/exceptions/workspace-path-exists.d.ts +5 -0
  8. package/dist/generator-env-type.d.ts +13 -0
  9. package/dist/generator.aspect.d.ts +2 -0
  10. package/dist/generator.composition.d.ts +1 -0
  11. package/dist/generator.graphql.d.ts +7 -0
  12. package/dist/generator.main.runtime.d.ts +173 -0
  13. package/dist/generator.service.d.ts +12 -0
  14. package/dist/index.d.ts +8 -0
  15. package/dist/new.cmd.d.ts +28 -0
  16. package/dist/{preview-1712805335812.js → preview-1712822929999.js} +2 -2
  17. package/dist/starter-list.d.ts +13 -0
  18. package/dist/starter.plugin.d.ts +9 -0
  19. package/dist/template-list.d.ts +13 -0
  20. package/dist/templates/basic/basic.starter.d.ts +3 -0
  21. package/dist/templates/basic/index.d.ts +1 -0
  22. package/dist/templates/basic/template/files/package-json.d.ts +1 -0
  23. package/dist/templates/basic/template/files/workspace-config.d.ts +2 -0
  24. package/dist/templates/component-generator/files/component-template-files/component.d.ts +1 -0
  25. package/dist/templates/component-generator/files/component-template-files/composition.d.ts +1 -0
  26. package/dist/templates/component-generator/files/component-template-files/index-file.d.ts +1 -0
  27. package/dist/templates/component-generator/files/component-template-files/test.d.ts +1 -0
  28. package/dist/templates/component-generator/files/component-template.d.ts +2 -0
  29. package/dist/templates/component-generator/files/index.d.ts +2 -0
  30. package/dist/templates/component-generator/index.d.ts +2 -0
  31. package/dist/templates/component-generator-standalone/files/aspect-file.d.ts +2 -0
  32. package/dist/templates/component-generator-standalone/files/docs-file.d.ts +1 -0
  33. package/dist/templates/component-generator-standalone/files/index.d.ts +2 -0
  34. package/dist/templates/component-generator-standalone/files/main-runtime.d.ts +2 -0
  35. package/dist/templates/component-generator-standalone/index.d.ts +2 -0
  36. package/dist/templates/index.d.ts +4 -0
  37. package/dist/templates/starter/files/doc-file.d.ts +2 -0
  38. package/dist/templates/starter/files/generate-files.d.ts +1 -0
  39. package/dist/templates/starter/files/git-ignore-tpl.d.ts +1 -0
  40. package/dist/templates/starter/files/index.d.ts +2 -0
  41. package/dist/templates/starter/files/starter.d.ts +2 -0
  42. package/dist/templates/starter/files/workspace-config-tpl.d.ts +1 -0
  43. package/dist/templates/starter/index.d.ts +2 -0
  44. package/dist/templates/starter-standalone/files/doc-file.d.ts +2 -0
  45. package/dist/templates/starter-standalone/files/git-ignore-tpl.d.ts +1 -0
  46. package/dist/templates/starter-standalone/files/index.d.ts +2 -0
  47. package/dist/templates/starter-standalone/files/starter.d.ts +2 -0
  48. package/dist/templates/starter-standalone/files/workspace-config-tpl.d.ts +1 -0
  49. package/dist/templates/starter-standalone/index.d.ts +2 -0
  50. package/dist/templates.cmd.d.ts +18 -0
  51. package/dist/types.d.ts +3 -0
  52. package/dist/workspace-generator.d.ts +43 -0
  53. package/dist/workspace-template.d.ts +156 -0
  54. package/package.json +21 -21
  55. package/tsconfig.json +1 -58
@@ -0,0 +1,2 @@
1
+ import { ComponentTemplate } from '../../component-template';
2
+ export declare const starterTemplate: ComponentTemplate;
@@ -0,0 +1,18 @@
1
+ import { Command, CommandOptions } from '@teambit/cli';
2
+ import { GeneratorMain } from './generator.main.runtime';
3
+ export type TemplatesOptions = {
4
+ showAll?: boolean;
5
+ aspect?: string;
6
+ };
7
+ export declare class TemplatesCmd implements Command {
8
+ private generator;
9
+ name: string;
10
+ description: string;
11
+ extendedDescription: string;
12
+ alias: string;
13
+ loader: boolean;
14
+ group: string;
15
+ options: CommandOptions;
16
+ constructor(generator: GeneratorMain);
17
+ report(args: [], templatesOptions: TemplatesOptions): Promise<string>;
18
+ }
@@ -0,0 +1,3 @@
1
+ export interface CreateExtConfig {
2
+ template: string;
3
+ }
@@ -0,0 +1,43 @@
1
+ import { Component } from '@teambit/component';
2
+ import { ComponentID } from '@teambit/component-id';
3
+ import { WorkspaceTemplate } from './workspace-template';
4
+ import { NewOptions } from './new.cmd';
5
+ export type GenerateResult = {
6
+ id: ComponentID;
7
+ dir: string;
8
+ files: string[];
9
+ envId: string;
10
+ };
11
+ export declare class WorkspaceGenerator {
12
+ private workspaceName;
13
+ private workspacePath;
14
+ private options;
15
+ private template;
16
+ private aspectComponent?;
17
+ private harmony;
18
+ private workspace;
19
+ private install;
20
+ private importer;
21
+ private logger?;
22
+ private forking;
23
+ private git;
24
+ private wsConfigFiles;
25
+ private generator;
26
+ constructor(workspaceName: string, workspacePath: string, options: NewOptions & {
27
+ currentDir?: boolean;
28
+ }, template: WorkspaceTemplate, aspectComponent?: Component | undefined);
29
+ generate(): Promise<string>;
30
+ private initGit;
31
+ private setupGitBitmapMergeDriver;
32
+ private buildUI;
33
+ private getWorkspaceContext;
34
+ /**
35
+ * writes the generated template files to the default directory set in the workspace config
36
+ */
37
+ private writeWorkspaceFiles;
38
+ private reloadBitInWorkspaceDir;
39
+ private createComponentsFromRemote;
40
+ private forkComponentsFromRemote;
41
+ private importComponentsFromRemote;
42
+ private compileComponents;
43
+ }
@@ -0,0 +1,156 @@
1
+ import type { Component } from '@teambit/component';
2
+ import { ComponentConfig } from './component-template';
3
+ /**
4
+ * BaseWorkspaceOptions describes the foundational properties for workspaces.
5
+ */
6
+ export interface BaseWorkspaceOptions {
7
+ /**
8
+ * The name of the workspace as provided by the user (e.g., `react-app`).
9
+ * This is also used as the directory name for the workspace.
10
+ */
11
+ name: string;
12
+ /**
13
+ * The default scope provided by the user.
14
+ * This is set in the workspace.jsonc and is utilized for components within the workspace.
15
+ */
16
+ defaultScope?: string;
17
+ /**
18
+ * Indicates whether the user has opted to avoid creating components (typically with a `--empty` flag).
19
+ */
20
+ empty?: boolean;
21
+ /**
22
+ * Represents the aspect in the context where a remote aspect is imported (often via the `--aspect` flag).
23
+ * This is useful for obtaining the aspect-id and other related information.
24
+ */
25
+ aspectComponent?: Component;
26
+ /**
27
+ * Represents the selected template to initialize or create the workspace.
28
+ */
29
+ template: WorkspaceTemplate;
30
+ /**
31
+ * Flag to check if Git repository generation should be skipped.
32
+ */
33
+ skipGit?: boolean;
34
+ /**
35
+ * Local path to the workspace template.
36
+ * Useful during the development of a workspace-template.
37
+ */
38
+ loadFrom?: string;
39
+ }
40
+ /**
41
+ * WorkspaceContext represents foundational properties for a workspace context.
42
+ */
43
+ export type WorkspaceContext = BaseWorkspaceOptions;
44
+ export interface WorkspaceFile {
45
+ /**
46
+ * relative path of the file within the workspace.
47
+ */
48
+ relativePath: string;
49
+ /**
50
+ * file content
51
+ */
52
+ content: string;
53
+ }
54
+ export interface CreateComponentInfo {
55
+ /**
56
+ * the template for generating the component
57
+ */
58
+ templateName: string;
59
+ /**
60
+ * component name to generate
61
+ */
62
+ componentName: string;
63
+ /**
64
+ * sets the component's scope-name. if not entered, the default-scope will be used
65
+ */
66
+ scope?: string;
67
+ /**
68
+ * relative path in the workspace. by default the path is `<scope>/<namespace>/<name>`
69
+ */
70
+ path?: string;
71
+ /**
72
+ * set the component's environment. (overrides the env from variants and the template)
73
+ */
74
+ env?: string;
75
+ /**
76
+ * aspect-id of the template.
77
+ */
78
+ aspect?: string;
79
+ }
80
+ export interface ForkComponentInfo extends ImportComponentInfo {
81
+ /**
82
+ * a new component name. if not specified, use the original id (without the scope)
83
+ */
84
+ targetName?: string;
85
+ /**
86
+ * a new scope for the component. if not specified, use the original scope
87
+ */
88
+ targetScope?: string;
89
+ /**
90
+ * env to use for the component.
91
+ */
92
+ env?: string;
93
+ /**
94
+ * component config. gets saved in the .bitmap file and overrides the workspace.jsonc config.
95
+ * for example, you can set the env that will be used for this component as follows:
96
+ * "teambit.envs/envs": {
97
+ * "env": "teambit.harmony/aspect"
98
+ * },
99
+ */
100
+ config?: ComponentConfig;
101
+ }
102
+ /**
103
+ * @deprecated use ForkComponentInfo instead.
104
+ */
105
+ export type ComponentToImport = ForkComponentInfo;
106
+ export interface ImportComponentInfo {
107
+ /**
108
+ * full component id
109
+ */
110
+ id: string;
111
+ /**
112
+ * path where to write the component
113
+ */
114
+ path?: string;
115
+ }
116
+ export interface WorkspaceTemplate {
117
+ /**
118
+ * name of the workspace starter. for example: `react-workspace`.
119
+ */
120
+ name: string;
121
+ /**
122
+ * name of an app created in the workspace. for example: `my-app`.
123
+ * This will be used to instruct the user to run `bit run <appName>` in the new workspace.
124
+ */
125
+ appName?: string;
126
+ /**
127
+ * short description of the starter. shown in the `bit starter` command when outside of bit-workspace.
128
+ */
129
+ description?: string;
130
+ /**
131
+ * hide this starter so that it is not listed with `bit starter`
132
+ */
133
+ hidden?: boolean;
134
+ /**
135
+ * starter function for generating the template files,
136
+ */
137
+ generateFiles(context: WorkspaceContext): Promise<WorkspaceFile[]>;
138
+ /**
139
+ * @deprecated use `fork()` or `import()` instead
140
+ * this is working similarly to `fork()`
141
+ */
142
+ importComponents?: (context: WorkspaceContext) => ForkComponentInfo[];
143
+ /**
144
+ * import components into the new workspace, don't change their source code.
145
+ */
146
+ import?: (context: WorkspaceContext) => ImportComponentInfo[];
147
+ /**
148
+ * populate existing components into the new workspace and add them as new components.
149
+ * change their source code and update the dependency names according to the new component names.
150
+ */
151
+ fork?: (context: WorkspaceContext) => ForkComponentInfo[];
152
+ /**
153
+ * populate new components into the new workspace and add them as new components.
154
+ */
155
+ create?: (context: WorkspaceContext) => CreateComponentInfo[];
156
+ }
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@teambit/generator",
3
- "version": "1.0.229",
3
+ "version": "1.0.230",
4
4
  "homepage": "https://bit.cloud/teambit/generator/generator",
5
5
  "main": "dist/index.js",
6
6
  "componentId": {
7
7
  "scope": "teambit.generator",
8
8
  "name": "generator",
9
- "version": "1.0.229"
9
+ "version": "1.0.230"
10
10
  },
11
11
  "dependencies": {
12
12
  "camelcase": "6.2.0",
@@ -21,32 +21,32 @@
21
21
  "@teambit/component-id": "1.2.0",
22
22
  "@teambit/harmony": "0.4.6",
23
23
  "@teambit/git.modules.git-ignore": "1.0.2",
24
- "@teambit/envs": "1.0.228",
25
- "@teambit/logger": "0.0.954",
26
- "@teambit/new-component-helper": "1.0.228",
27
- "@teambit/tracker": "1.0.228",
28
- "@teambit/workspace-config-files": "1.0.228",
24
+ "@teambit/envs": "1.0.229",
25
+ "@teambit/logger": "0.0.955",
26
+ "@teambit/new-component-helper": "1.0.229",
27
+ "@teambit/tracker": "1.0.229",
28
+ "@teambit/workspace-config-files": "1.0.229",
29
29
  "@teambit/workspace.modules.node-modules-linker": "0.0.167",
30
- "@teambit/workspace": "1.0.228",
31
- "@teambit/component": "1.0.228",
32
- "@teambit/cli": "0.0.861",
33
- "@teambit/graphql": "1.0.228",
34
- "@teambit/aspect-loader": "1.0.228",
35
- "@teambit/bit": "1.6.121",
36
- "@teambit/git": "1.0.228",
37
- "@teambit/compiler": "1.0.228",
38
- "@teambit/forking": "1.0.228",
39
- "@teambit/importer": "1.0.228",
40
- "@teambit/install": "1.0.228",
41
- "@teambit/ui": "1.0.228",
42
- "@teambit/config": "0.0.979"
30
+ "@teambit/workspace": "1.0.229",
31
+ "@teambit/component": "1.0.229",
32
+ "@teambit/cli": "0.0.862",
33
+ "@teambit/graphql": "1.0.229",
34
+ "@teambit/aspect-loader": "1.0.229",
35
+ "@teambit/bit": "1.6.122",
36
+ "@teambit/git": "1.0.229",
37
+ "@teambit/compiler": "1.0.229",
38
+ "@teambit/forking": "1.0.229",
39
+ "@teambit/importer": "1.0.229",
40
+ "@teambit/install": "1.0.229",
41
+ "@teambit/ui": "1.0.229",
42
+ "@teambit/config": "0.0.980"
43
43
  },
44
44
  "devDependencies": {
45
45
  "@types/fs-extra": "9.0.7",
46
46
  "@types/lodash": "4.14.165",
47
47
  "@types/mocha": "9.1.0",
48
48
  "chai": "4.3.0",
49
- "@teambit/harmony.envs.core-aspect-env": "0.0.30",
49
+ "@teambit/harmony.envs.core-aspect-env": "0.0.33",
50
50
  "@teambit/generator.aspect-docs.generator": "0.0.171"
51
51
  },
52
52
  "peerDependencies": {
package/tsconfig.json CHANGED
@@ -20,8 +20,7 @@
20
20
  "emitDeclarationOnly": true,
21
21
  "strict": true,
22
22
  "strictPropertyInitialization": false,
23
- "noImplicitAny": false,
24
- "composite": true
23
+ "noImplicitAny": false
25
24
  },
26
25
  "exclude": [
27
26
  "artifacts",
@@ -36,61 +35,5 @@
36
35
  "include": [
37
36
  "**/*",
38
37
  "**/*.json"
39
- ],
40
- "references": [
41
- {
42
- "path": "/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.envs_envs@1.0.228"
43
- },
44
- {
45
- "path": "/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.harmony_logger@0.0.954"
46
- },
47
- {
48
- "path": "/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.component_new-component-helper@1.0.228"
49
- },
50
- {
51
- "path": "/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.component_tracker@1.0.228"
52
- },
53
- {
54
- "path": "/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.workspace_workspace-config-files@1.0.228"
55
- },
56
- {
57
- "path": "/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.workspace_workspace@1.0.228"
58
- },
59
- {
60
- "path": "/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.component_component@1.0.228"
61
- },
62
- {
63
- "path": "/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.harmony_cli@0.0.861"
64
- },
65
- {
66
- "path": "/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.harmony_graphql@1.0.228"
67
- },
68
- {
69
- "path": "/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.harmony_aspect-loader@1.0.228"
70
- },
71
- {
72
- "path": "/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.harmony_bit@1.6.121"
73
- },
74
- {
75
- "path": "/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.git_git@1.0.228"
76
- },
77
- {
78
- "path": "/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.compilation_compiler@1.0.228"
79
- },
80
- {
81
- "path": "/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.component_forking@1.0.228"
82
- },
83
- {
84
- "path": "/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.scope_importer@1.0.228"
85
- },
86
- {
87
- "path": "/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.workspace_install@1.0.228"
88
- },
89
- {
90
- "path": "/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.ui-foundation_ui@1.0.228"
91
- },
92
- {
93
- "path": "/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.harmony_config@0.0.979"
94
- }
95
38
  ]
96
39
  }