@teambit/generator 0.0.551 → 0.0.556

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 (37) hide show
  1. package/dist/component-generator.d.ts +3 -0
  2. package/dist/component-template.d.ts +37 -0
  3. package/dist/generator.main.runtime.d.ts +29 -0
  4. package/dist/workspace-generator.d.ts +3 -0
  5. package/dist/workspace-template.d.ts +45 -0
  6. package/package.json +26 -20
  7. package/component-generator.ts +0 -119
  8. package/component-template.ts +0 -66
  9. package/create.cmd.ts +0 -44
  10. package/generator.aspect.ts +0 -5
  11. package/generator.docs.mdx +0 -8
  12. package/generator.graphql.ts +0 -66
  13. package/generator.main.runtime.ts +0 -279
  14. package/index.ts +0 -4
  15. package/new.cmd.ts +0 -79
  16. package/package-tar/teambit-generator-0.0.551.tgz +0 -0
  17. package/templates/component-generator/files/aspect-file.ts +0 -10
  18. package/templates/component-generator/files/docs-file.ts +0 -54
  19. package/templates/component-generator/files/index.ts +0 -10
  20. package/templates/component-generator/files/main-runtime.ts +0 -125
  21. package/templates/component-generator/index.ts +0 -32
  22. package/templates/workspace-generator/files/aspect-file.ts +0 -10
  23. package/templates/workspace-generator/files/docs-file.ts +0 -37
  24. package/templates/workspace-generator/files/git-ignore-tpl.ts +0 -113
  25. package/templates/workspace-generator/files/index-tpl.ts +0 -29
  26. package/templates/workspace-generator/files/index.ts +0 -10
  27. package/templates/workspace-generator/files/main-runtime.ts +0 -24
  28. package/templates/workspace-generator/files/readme-tpl.ts +0 -39
  29. package/templates/workspace-generator/files/workspace-config-tpl.ts +0 -18
  30. package/templates/workspace-generator/index.ts +0 -52
  31. package/templates.cmd.ts +0 -48
  32. package/tsconfig.json +0 -35
  33. package/types/asset.d.ts +0 -29
  34. package/types/style.d.ts +0 -42
  35. package/types.ts +0 -3
  36. package/workspace-generator.ts +0 -246
  37. package/workspace-template.ts +0 -82
@@ -1,113 +0,0 @@
1
- export function gitIgnoreTemplate() {
2
- return `export function gitIgnore() {
3
- return \`# Bit
4
- .bit
5
- public
6
-
7
- # Logs
8
- logs
9
- *.log
10
- npm-debug.log*
11
- yarn-debug.log*
12
- yarn-error.log*
13
- lerna-debug.log*
14
-
15
- # Diagnostic reports (https://nodejs.org/api/report.html)
16
- report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
17
-
18
- # Runtime data
19
- pids
20
- *.pid
21
- *.seed
22
- *.pid.lock
23
-
24
- # Directory for instrumented libs generated by jscoverage/JSCover
25
- lib-cov
26
-
27
- # Coverage directory used by tools like istanbul
28
- coverage
29
- *.lcov
30
-
31
- # nyc test coverage
32
- .nyc_output
33
-
34
- # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
35
- .grunt
36
-
37
- # Bower dependency directory (https://bower.io/)
38
- bower_components
39
-
40
- # node-waf configuration
41
- .lock-wscript
42
-
43
- # Compiled binary addons (https://nodejs.org/api/addons.html)
44
- build/Release
45
-
46
- # Dependency directories
47
- node_modules/
48
- jspm_packages/
49
-
50
- # TypeScript v1 declaration files
51
- typings/
52
-
53
- # TypeScript cache
54
- *.tsbuildinfo
55
-
56
- # Optional npm cache directory
57
- .npm
58
-
59
- # Optional eslint cache
60
- .eslintcache
61
-
62
- # Microbundle cache
63
- .rpt2_cache/
64
- .rts2_cache_cjs/
65
- .rts2_cache_es/
66
- .rts2_cache_umd/
67
-
68
- # Optional REPL history
69
- .node_repl_history
70
-
71
- # Output of 'npm pack'
72
- *.tgz
73
-
74
- # Yarn Integrity file
75
- .yarn-integrity
76
-
77
- # dotenv environment variables file
78
- .env
79
- .env.test
80
-
81
- # parcel-bundler cache (https://parceljs.org/)
82
- .cache
83
-
84
- # Next.js build output
85
- .next
86
-
87
- # Nuxt.js build / generate output
88
- .nuxt
89
- dist
90
-
91
- # Gatsby files
92
- .cache/
93
-
94
- # vuepress build output
95
- .vuepress/dist
96
-
97
- # Serverless directories
98
- .serverless/
99
-
100
- # FuseBox cache
101
- .fusebox/
102
-
103
- # DynamoDB Local files
104
- .dynamodb/
105
-
106
- # TernJS port file
107
- .tern-port
108
-
109
- .history
110
- \`;
111
- }
112
- `;
113
- }
@@ -1,29 +0,0 @@
1
- export function indexTemplate() {
2
- return `import { WorkspaceContext, WorkspaceTemplate } from '@teambit/generator';
3
- import { workspaceConfig } from './files/workspace-config';
4
- import { readme } from './files/readme-file';
5
- import { gitIgnore } from './files/git-ignore';
6
-
7
- export const workspaceTemplate: WorkspaceTemplate = {
8
- name: 'template-example',
9
- description: 'demonstration of a workspace template',
10
- generateFiles: async (context: WorkspaceContext) => [
11
- {
12
- relativePath: 'workspace.jsonc',
13
- content: await workspaceConfig(context),
14
- },
15
- {
16
- relativePath: '.gitignore',
17
- content: gitIgnore(),
18
- },
19
- {
20
- relativePath: 'README.md',
21
- content: readme(),
22
- },
23
- ],
24
- importComponents: () => [
25
- { id: 'teambit.react/templates/ui/text', path: 'ui/text' },
26
- ],
27
- };
28
- `;
29
- }
@@ -1,10 +0,0 @@
1
- import { ComponentContext } from '@teambit/generator';
2
-
3
- export function indexFile({ namePascalCase, name }: ComponentContext) {
4
- return `import { ${namePascalCase}Aspect } from './${name}.aspect';
5
-
6
- export type { ${namePascalCase}Main } from './${name}.main.runtime';
7
- export default ${namePascalCase}Aspect;
8
- export { ${namePascalCase}Aspect };
9
- `;
10
- }
@@ -1,24 +0,0 @@
1
- import { ComponentContext } from '@teambit/generator';
2
-
3
- export function mainRuntime({ name, namePascalCase }: ComponentContext) {
4
- return `import { MainRuntime } from '@teambit/cli';
5
- import { GeneratorMain, GeneratorAspect } from '@teambit/generator';
6
- import { ${namePascalCase}Aspect } from './${name}.aspect';
7
- import { workspaceTemplate } from './template';
8
-
9
- export class ${namePascalCase}Main {
10
- static slots = [];
11
-
12
- static dependencies = [GeneratorAspect];
13
-
14
- static runtime = MainRuntime;
15
-
16
- static async provider([generator]: [GeneratorMain]) {
17
- generator.registerWorkspaceTemplate([workspaceTemplate]);
18
- return new ${namePascalCase}Main();
19
- }
20
- }
21
-
22
- ${namePascalCase}Aspect.addRuntime(${namePascalCase}Main);
23
- `;
24
- }
@@ -1,39 +0,0 @@
1
- export function readmeTemplate() {
2
- return `export function readme() {
3
- return \`## Workspace Generator
4
-
5
- Easily generate a new workspace with a single command.
6
-
7
- ## Registering your Workspace
8
-
9
- Register your workspace template under the aspect environment in the variants section of the workspace.jsonc file.
10
-
11
- \\\`\\\`\\\`json
12
- "teambit.workspace/variants": {
13
- "{workspace-name}": {
14
- "teambit.harmony/aspect": {}
15
- }
16
- }
17
- \\\`\\\`\\\`
18
-
19
- ## Customizing your Workspace
20
-
21
- See the docs for more info on [Customizing your Generator](https://harmony-docs.bit.dev/extending-bit/creating-a-custom-workspace-generator)
22
-
23
- ## Using the Workspace Generator
24
-
25
- How to use this generator locally, essentially for development purposes:
26
-
27
- \\\`\\\`\\\`js
28
- bit new <template-name> <workspace-name> --load-from /Users/me/path/to/this/dir --aspect <workspace-template-id>
29
- \\\`\\\`\\\`
30
-
31
- How to use this generator after exporting to a remote scope:
32
-
33
- \\\`\\\`\\\`js
34
- bit new <template-name> <workspace-name> --aspect <workspace-template-id>
35
- \\\`\\\`\\\`
36
- \`;
37
- }
38
- `;
39
- }
@@ -1,18 +0,0 @@
1
- export function workspaceConfigTemplate() {
2
- return `import { WorkspaceContext } from '@teambit/generator';
3
- import { getWorkspaceConfigTemplateParsed, stringifyWorkspaceConfig } from '@teambit/config';
4
-
5
- export async function workspaceConfig({ name, defaultScope }: WorkspaceContext) {
6
- const configParsed = await getWorkspaceConfigTemplateParsed();
7
- configParsed['teambit.workspace/workspace'].name = name;
8
- configParsed['teambit.workspace/workspace'].defaultScope = defaultScope || 'company.scope';
9
- configParsed['teambit.workspace/variants'] = {
10
- '*': {
11
- 'teambit.react/react': {},
12
- },
13
- };
14
-
15
- return stringifyWorkspaceConfig(configParsed);
16
- }
17
- `;
18
- }
@@ -1,52 +0,0 @@
1
- import { ComponentContext, ComponentTemplate } from '@teambit/generator';
2
- import { indexFile } from './files/index';
3
- import { aspectFile } from './files/aspect-file';
4
- import { docsFile } from './files/docs-file';
5
- import { mainRuntime } from './files/main-runtime';
6
- import { gitIgnoreTemplate } from './files/git-ignore-tpl';
7
- import { readmeTemplate } from './files/readme-tpl';
8
- import { indexTemplate } from './files/index-tpl';
9
- import { workspaceConfigTemplate } from './files/workspace-config-tpl';
10
-
11
- export const workspaceGeneratorTemplate: ComponentTemplate = {
12
- name: 'workspace-generator',
13
- description:
14
- 'create your own workspace generator - \nDocs: https://harmony-docs.bit.dev/extending-bit/creating-a-custom-workspace-generator',
15
- generateFiles: (context: ComponentContext) => {
16
- return [
17
- {
18
- relativePath: 'index.ts',
19
- content: indexFile(context),
20
- isMain: true,
21
- },
22
- {
23
- relativePath: `${context.name}.aspect.ts`,
24
- content: aspectFile(context),
25
- },
26
- {
27
- relativePath: `${context.name}.main.runtime.ts`,
28
- content: mainRuntime(context),
29
- },
30
- {
31
- relativePath: `${context.name}.docs.mdx`,
32
- content: docsFile(),
33
- },
34
- {
35
- relativePath: 'template/files/git-ignore.ts',
36
- content: gitIgnoreTemplate(),
37
- },
38
- {
39
- relativePath: 'template/files/readme-file.ts',
40
- content: readmeTemplate(),
41
- },
42
- {
43
- relativePath: 'template/files/workspace-config.ts',
44
- content: workspaceConfigTemplate(),
45
- },
46
- {
47
- relativePath: 'template/index.ts',
48
- content: indexTemplate(),
49
- },
50
- ];
51
- },
52
- };
package/templates.cmd.ts DELETED
@@ -1,48 +0,0 @@
1
- import { Command, CommandOptions } from '@teambit/cli';
2
- import chalk from 'chalk';
3
- import { groupBy } from 'lodash';
4
- import { GeneratorMain, TemplateDescriptor } from './generator.main.runtime';
5
-
6
- export type TemplatesOptions = {
7
- showAll?: boolean;
8
- };
9
-
10
- export class TemplatesCmd implements Command {
11
- name = 'templates';
12
- description =
13
- 'list components templates when inside bit-workspace (for bit-create), otherwise, list workspace templates (for bit-new)';
14
- shortDescription = 'list templates for "bit create" and "bit new"';
15
- alias = '';
16
- loader = true;
17
- group = 'development';
18
- options = [['s', 'show-all', 'show hidden templates']] as CommandOptions;
19
-
20
- constructor(private generator: GeneratorMain) {}
21
-
22
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
23
- async report(args: [], templatesOptions: TemplatesOptions) {
24
- let results = await this.generator.listTemplates();
25
-
26
- // Make sure that we don't list hidden templates
27
- if (!templatesOptions.showAll) {
28
- results = results.filter((template) => !template.hidden);
29
- }
30
-
31
- const grouped = groupBy(results, 'aspectId');
32
- const titleStr = this.generator.isRunningInsideWorkspace()
33
- ? `The following template(s) are available with the command bit create: \nExample - bit create <template-name> <component-name>`
34
- : `The following template(s) are available with the command bit new: \nExample - bit new <template-name> <workspace-name>`;
35
- const title = chalk.green(`\n${titleStr}\n`);
36
- const templateOutput = (template: TemplateDescriptor) => {
37
- const desc = template.description ? ` (${template.description})` : '';
38
- return ` ${template.name}${chalk.dim(desc)}`;
39
- };
40
- const output = Object.keys(grouped)
41
- .map((aspectId) => {
42
- const names = grouped[aspectId].map(templateOutput).join('\n');
43
- return `${chalk.blue.bold(aspectId)}\n${names}\n`;
44
- })
45
- .join('\n');
46
- return title + output;
47
- }
48
- }
package/tsconfig.json DELETED
@@ -1,35 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "lib": [
4
- "es2019",
5
- "DOM",
6
- "ES6",
7
- "DOM.Iterable",
8
- "ScriptHost"
9
- ],
10
- "target": "es2015",
11
- "module": "commonjs",
12
- "jsx": "react",
13
- "declaration": true,
14
- "sourceMap": true,
15
- "skipLibCheck": true,
16
- "moduleResolution": "node",
17
- "esModuleInterop": true,
18
- "outDir": "dist",
19
- "composite": true,
20
- "emitDeclarationOnly": true,
21
- "experimentalDecorators": true,
22
- "emitDecoratorMetadata": true,
23
- "allowSyntheticDefaultImports": true,
24
- "strictPropertyInitialization": false,
25
- "strict": true,
26
- "noImplicitAny": false,
27
- "rootDir": ".",
28
- "removeComments": true,
29
- "preserveConstEnums": true,
30
- "resolveJsonModule": true
31
- },
32
- "exclude": [
33
- "dist"
34
- ]
35
- }
package/types/asset.d.ts DELETED
@@ -1,29 +0,0 @@
1
- declare module '*.png' {
2
- const value: any;
3
- export = value;
4
- }
5
- declare module '*.svg' {
6
- import type { FunctionComponent, SVGProps } from 'react';
7
-
8
- export const ReactComponent: FunctionComponent<SVGProps<SVGSVGElement> & { title?: string }>;
9
- const src: string;
10
- export default src;
11
- }
12
-
13
- // @TODO Gilad
14
- declare module '*.jpg' {
15
- const value: any;
16
- export = value;
17
- }
18
- declare module '*.jpeg' {
19
- const value: any;
20
- export = value;
21
- }
22
- declare module '*.gif' {
23
- const value: any;
24
- export = value;
25
- }
26
- declare module '*.bmp' {
27
- const value: any;
28
- export = value;
29
- }
package/types/style.d.ts DELETED
@@ -1,42 +0,0 @@
1
- declare module '*.module.css' {
2
- const classes: { readonly [key: string]: string };
3
- export default classes;
4
- }
5
- declare module '*.module.scss' {
6
- const classes: { readonly [key: string]: string };
7
- export default classes;
8
- }
9
- declare module '*.module.sass' {
10
- const classes: { readonly [key: string]: string };
11
- export default classes;
12
- }
13
-
14
- declare module '*.module.less' {
15
- const classes: { readonly [key: string]: string };
16
- export default classes;
17
- }
18
-
19
- declare module '*.less' {
20
- const classes: { readonly [key: string]: string };
21
- export default classes;
22
- }
23
-
24
- declare module '*.css' {
25
- const classes: { readonly [key: string]: string };
26
- export default classes;
27
- }
28
-
29
- declare module '*.sass' {
30
- const classes: { readonly [key: string]: string };
31
- export default classes;
32
- }
33
-
34
- declare module '*.scss' {
35
- const classes: { readonly [key: string]: string };
36
- export default classes;
37
- }
38
-
39
- declare module '*.mdx' {
40
- const component: any;
41
- export default component;
42
- }
package/types.ts DELETED
@@ -1,3 +0,0 @@
1
- export interface CreateExtConfig {
2
- template: string;
3
- }