@teambit/generator 0.0.549 → 0.0.555

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.
@@ -19,6 +19,9 @@ export declare class ComponentGenerator {
19
19
  generate(): Promise<GenerateResult[]>;
20
20
  private deleteGeneratedComponents;
21
21
  private generateOneComponent;
22
+ /**
23
+ * writes the generated template files to the default directory set in the workspace config
24
+ */
22
25
  private writeComponentFiles;
23
26
  private getComponentPath;
24
27
  }
@@ -1,18 +1,55 @@
1
1
  import { ComponentID } from '@teambit/component-id';
2
2
  export interface ComponentFile {
3
+ /**
4
+ * relative path of the file within the component.
5
+ */
3
6
  relativePath: string;
7
+ /**
8
+ * file content
9
+ */
4
10
  content: string;
11
+ /**
12
+ * whether this file will be tracked as the main file
13
+ */
5
14
  isMain?: boolean;
6
15
  }
7
16
  export interface ComponentContext {
17
+ /**
18
+ * component-name as entered by the user, e.g. `use-date`.
19
+ * without the scope and the namespace.
20
+ */
8
21
  name: string;
22
+ /**
23
+ * component-name as upper camel case, e.g. `use-date` becomes `UseDate`.
24
+ * useful when generating the file content, for example for a class name.
25
+ */
9
26
  namePascalCase: string;
27
+ /**
28
+ * component-name as lower camel case, e.g. `use-date` becomes `useDate`.
29
+ * useful when generating the file content, for example for a function/variable name.
30
+ */
10
31
  nameCamelCase: string;
32
+ /**
33
+ * component id.
34
+ * the name is the name+namespace. the scope is the scope entered by --scope flag or the defaultScope
35
+ */
11
36
  componentId: ComponentID;
12
37
  }
13
38
  export interface ComponentTemplate {
39
+ /**
40
+ * name of the component template. for example: `hook`, `react-component` or `module`.
41
+ */
14
42
  name: string;
43
+ /**
44
+ * short description of the template. shown in the `bit templates` command.
45
+ */
15
46
  description?: string;
47
+ /**
48
+ * hide this template so that it is not listed with `bit templates`
49
+ */
16
50
  hidden?: boolean;
51
+ /**
52
+ * template function for generating the file of a certain component.,
53
+ */
17
54
  generateFiles(context: ComponentContext): ComponentFile[];
18
55
  }
@@ -19,6 +19,9 @@ export declare type TemplateDescriptor = {
19
19
  hidden?: boolean;
20
20
  };
21
21
  export declare type GeneratorConfig = {
22
+ /**
23
+ * array of aspects to include in the list of templates.
24
+ */
22
25
  aspects: string[];
23
26
  };
24
27
  export declare class GeneratorMain {
@@ -30,15 +33,41 @@ export declare class GeneratorMain {
30
33
  private aspectLoader;
31
34
  private aspectLoaded;
32
35
  constructor(componentTemplateSlot: ComponentTemplateSlot, workspaceTemplateSlot: WorkspaceTemplateSlot, config: GeneratorConfig, workspace: Workspace, envs: EnvsMain, aspectLoader: AspectLoaderMain);
36
+ /**
37
+ * register a new component template.
38
+ */
33
39
  registerComponentTemplate(templates: ComponentTemplate[]): this;
40
+ /**
41
+ * register a new component template.
42
+ */
34
43
  registerWorkspaceTemplate(templates: WorkspaceTemplate[]): this;
44
+ /**
45
+ * list all component templates registered in the workspace or workspace templates in case the
46
+ * workspace is not available
47
+ */
35
48
  listTemplates(): Promise<TemplateDescriptor[]>;
49
+ /**
50
+ * @deprecated use this.listTemplates()
51
+ */
36
52
  listComponentTemplates(): Promise<TemplateDescriptor[]>;
37
53
  isRunningInsideWorkspace(): boolean;
54
+ /**
55
+ * get all component templates registered by a specific aspect ID.
56
+ */
38
57
  getComponentTemplateByAspect(aspectId: string): ComponentTemplate[];
58
+ /**
59
+ * returns a specific component template.
60
+ */
39
61
  getComponentTemplate(name: string, aspectId?: string): ComponentTemplate | undefined;
62
+ /**
63
+ * in the case the aspect-id is given and this aspect doesn't exist locally, import it to the
64
+ * global scope and load it from the capsule
65
+ */
40
66
  findTemplateInGlobalScope(aspectId: string, name?: string): Promise<WorkspaceTemplate | undefined>;
41
67
  findTemplateInOtherWorkspace(workspacePath: string, name: string, aspectId?: string): Promise<WorkspaceTemplate | undefined>;
68
+ /**
69
+ * returns a specific workspace template.
70
+ */
42
71
  getWorkspaceTemplate(name: string, aspectId?: string): Promise<{
43
72
  workspaceTemplate: WorkspaceTemplate;
44
73
  aspect?: Component;
@@ -21,6 +21,9 @@ export declare class WorkspaceGenerator {
21
21
  generate(): Promise<string>;
22
22
  private initGit;
23
23
  private buildUI;
24
+ /**
25
+ * writes the generated template files to the default directory set in the workspace config
26
+ */
24
27
  private writeWorkspaceFiles;
25
28
  private reloadBitInWorkspaceDir;
26
29
  private addComponentsFromRemote;
@@ -1,23 +1,68 @@
1
1
  import type { Component } from '@teambit/component';
2
2
  export interface WorkspaceFile {
3
+ /**
4
+ * relative path of the file within the workspace.
5
+ */
3
6
  relativePath: string;
7
+ /**
8
+ * file content
9
+ */
4
10
  content: string;
5
11
  }
6
12
  export interface WorkspaceContext {
13
+ /**
14
+ * workspace-name as entered by the user, e.g. `react-app`.
15
+ * it is used as the directory name for the workspace.
16
+ */
7
17
  name: string;
18
+ /**
19
+ * default scope as entered by the user.
20
+ * it will be set in the workspace.jsonc and be used for components
21
+ */
8
22
  defaultScope?: string;
23
+ /**
24
+ * whether user entered `--empty` flag in `bit new` to avoid creating components.
25
+ */
9
26
  empty?: boolean;
27
+ /**
28
+ * in case the "--aspect" flag used to import a remote aspect, this is populated with that aspect.
29
+ * useful to get the aspect-id and other info.
30
+ */
10
31
  aspectComponent?: Component;
11
32
  }
12
33
  export interface ComponentToImport {
34
+ /**
35
+ * full component id
36
+ */
13
37
  id: string;
38
+ /**
39
+ * path where to write the component
40
+ */
14
41
  path: string;
42
+ /**
43
+ * a new component name. if not specified, use the original id (without the scope)
44
+ */
15
45
  targetName?: string;
16
46
  }
17
47
  export interface WorkspaceTemplate {
48
+ /**
49
+ * name of the workspace template. for example: `react-workspace`.
50
+ */
18
51
  name: string;
52
+ /**
53
+ * short description of the template. shown in the `bit templates` command when outside of bit-workspace.
54
+ */
19
55
  description?: string;
56
+ /**
57
+ * hide this template so that it is not listed with `bit templates`
58
+ */
20
59
  hidden?: boolean;
60
+ /**
61
+ * template function for generating the template files,
62
+ */
21
63
  generateFiles(context: WorkspaceContext): Promise<WorkspaceFile[]>;
64
+ /**
65
+ * populate existing components into the new workspace and add them as new components
66
+ */
22
67
  importComponents?: () => ComponentToImport[];
23
68
  }
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@teambit/generator",
3
- "version": "0.0.549",
3
+ "version": "0.0.555",
4
4
  "homepage": "https://bit.dev/teambit/generator/generator",
5
5
  "main": "dist/index.js",
6
6
  "componentId": {
7
7
  "scope": "teambit.generator",
8
8
  "name": "generator",
9
- "version": "0.0.549"
9
+ "version": "0.0.555"
10
10
  },
11
11
  "dependencies": {
12
12
  "camelcase": "6.2.0",
@@ -21,21 +21,21 @@
21
21
  "isbinaryfile": "4.0.6",
22
22
  "@babel/runtime": "7.12.18",
23
23
  "core-js": "^3.0.0",
24
- "@teambit/bit-error": "0.0.366",
25
- "@teambit/component-id": "0.0.370",
26
- "@teambit/envs": "0.0.549",
27
- "@teambit/workspace": "0.0.549",
28
- "@teambit/cli": "0.0.380",
29
- "@teambit/graphql": "0.0.549",
30
- "@teambit/aspect-loader": "0.0.549",
31
- "@teambit/bit": "0.0.551",
32
- "@teambit/component": "0.0.549",
33
- "@teambit/legacy-bit-id": "0.0.369",
34
- "@teambit/compiler": "0.0.549",
35
- "@teambit/dependency-resolver": "0.0.549",
36
- "@teambit/logger": "0.0.465",
37
- "@teambit/pkg": "0.0.549",
38
- "@teambit/ui": "0.0.549"
24
+ "@teambit/bit-error": "0.0.372",
25
+ "@teambit/component-id": "0.0.376",
26
+ "@teambit/envs": "0.0.555",
27
+ "@teambit/workspace": "0.0.555",
28
+ "@teambit/cli": "0.0.386",
29
+ "@teambit/graphql": "0.0.555",
30
+ "@teambit/aspect-loader": "0.0.555",
31
+ "@teambit/bit": "0.0.557",
32
+ "@teambit/component": "0.0.555",
33
+ "@teambit/legacy-bit-id": "0.0.375",
34
+ "@teambit/compiler": "0.0.555",
35
+ "@teambit/dependency-resolver": "0.0.555",
36
+ "@teambit/logger": "0.0.471",
37
+ "@teambit/pkg": "0.0.555",
38
+ "@teambit/ui": "0.0.555"
39
39
  },
40
40
  "devDependencies": {
41
41
  "@types/fs-extra": "9.0.7",
@@ -46,10 +46,10 @@
46
46
  "@types/react-dom": "^17.0.5",
47
47
  "@types/react": "^17.0.8",
48
48
  "@types/node": "12.20.4",
49
- "@teambit/generator.aspect-docs.generator": "0.0.104"
49
+ "@teambit/generator.aspect-docs.generator": "0.0.108"
50
50
  },
51
51
  "peerDependencies": {
52
- "@teambit/legacy": "1.0.76",
52
+ "@teambit/legacy": "1.0.172",
53
53
  "react-dom": "^16.8.0 || ^17.0.0",
54
54
  "react": "^16.8.0 || ^17.0.0"
55
55
  },
@@ -77,7 +77,7 @@
77
77
  "react": "-"
78
78
  },
79
79
  "peerDependencies": {
80
- "@teambit/legacy": "1.0.76",
80
+ "@teambit/legacy": "1.0.172",
81
81
  "react-dom": "^16.8.0 || ^17.0.0",
82
82
  "react": "^16.8.0 || ^17.0.0"
83
83
  }
package/tsconfig.json CHANGED
@@ -25,7 +25,6 @@
25
25
  "strict": true,
26
26
  "noImplicitAny": false,
27
27
  "rootDir": ".",
28
- "removeComments": true,
29
28
  "preserveConstEnums": true,
30
29
  "resolveJsonModule": true
31
30
  },