@teambit/generator 0.0.1144 → 0.0.1146
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.
- package/dist/component-template.d.ts +39 -22
- package/dist/component-template.js.map +1 -1
- package/dist/create.cmd.d.ts +10 -9
- package/dist/create.cmd.js +15 -12
- package/dist/create.cmd.js.map +1 -1
- package/dist/generator.graphql.d.ts +4 -0
- package/dist/generator.graphql.js +12 -1
- package/dist/generator.graphql.js.map +1 -1
- package/dist/generator.main.runtime.d.ts +5 -5
- package/dist/generator.main.runtime.js +16 -29
- package/dist/generator.main.runtime.js.map +1 -1
- package/dist/new.cmd.d.ts +6 -7
- package/dist/new.cmd.js +4 -0
- package/dist/new.cmd.js.map +1 -1
- package/dist/{preview-1693279117198.js → preview-1693538278577.js} +2 -2
- package/dist/templates/basic/basic.starter.d.ts +3 -0
- package/dist/templates/basic/basic.starter.js +39 -0
- package/dist/templates/basic/basic.starter.js.map +1 -0
- package/dist/templates/basic/index.d.ts +1 -0
- package/dist/templates/basic/index.js +20 -0
- package/dist/templates/basic/index.js.map +1 -0
- package/dist/templates/basic/template/files/git-ignore.d.ts +1 -0
- package/dist/templates/basic/template/files/git-ignore.js +118 -0
- package/dist/templates/basic/template/files/git-ignore.js.map +1 -0
- package/dist/templates/basic/template/files/workspace-config.d.ts +2 -0
- package/dist/templates/{workspace-generator/index.js → basic/template/files/workspace-config.js} +35 -11
- package/dist/templates/basic/template/files/workspace-config.js.map +1 -0
- package/dist/templates/component-generator/files/component-template-files/component.d.ts +1 -0
- package/dist/templates/component-generator/files/component-template-files/component.js +35 -0
- package/dist/templates/component-generator/files/component-template-files/component.js.map +1 -0
- package/dist/templates/component-generator/files/component-template-files/composition.d.ts +1 -0
- package/dist/templates/component-generator/files/component-template-files/composition.js +29 -0
- package/dist/templates/component-generator/files/component-template-files/composition.js.map +1 -0
- package/dist/templates/component-generator/files/component-template-files/index-file.d.ts +1 -0
- package/dist/templates/component-generator/files/component-template-files/index-file.js +24 -0
- package/dist/templates/component-generator/files/component-template-files/index-file.js.map +1 -0
- package/dist/templates/component-generator/files/component-template-files/test.d.ts +1 -0
- package/dist/templates/component-generator/files/component-template-files/test.js +31 -0
- package/dist/templates/component-generator/files/component-template-files/test.js.map +1 -0
- package/dist/templates/component-generator/files/component-template.d.ts +2 -0
- package/dist/templates/component-generator/files/component-template.js +67 -0
- package/dist/templates/component-generator/files/component-template.js.map +1 -0
- package/dist/templates/component-generator/files/index.d.ts +1 -1
- package/dist/templates/component-generator/files/index.js +1 -5
- package/dist/templates/component-generator/files/index.js.map +1 -1
- package/dist/templates/component-generator/index.d.ts +1 -1
- package/dist/templates/component-generator/index.js +36 -16
- package/dist/templates/component-generator/index.js.map +1 -1
- package/dist/templates/{component-generator → component-generator-standalone}/files/aspect-file.d.ts +1 -1
- package/dist/templates/component-generator-standalone/files/aspect-file.js.map +1 -0
- package/dist/templates/component-generator-standalone/files/index.d.ts +2 -0
- package/dist/templates/component-generator-standalone/files/index.js +19 -0
- package/dist/templates/component-generator-standalone/files/index.js.map +1 -0
- package/dist/templates/{component-generator → component-generator-standalone}/files/main-runtime.d.ts +1 -1
- package/dist/templates/component-generator-standalone/files/main-runtime.js.map +1 -0
- package/dist/templates/component-generator-standalone/index.d.ts +2 -0
- package/dist/templates/component-generator-standalone/index.js +64 -0
- package/dist/templates/component-generator-standalone/index.js.map +1 -0
- package/dist/templates/index.d.ts +4 -0
- package/dist/templates/index.js +59 -0
- package/dist/templates/index.js.map +1 -0
- package/dist/templates/starter/files/doc-file.d.ts +2 -0
- package/dist/templates/starter/files/doc-file.js +33 -0
- package/dist/templates/starter/files/doc-file.js.map +1 -0
- package/dist/templates/starter/files/generate-files.d.ts +1 -0
- package/dist/templates/starter/files/generate-files.js +35 -0
- package/dist/templates/starter/files/generate-files.js.map +1 -0
- package/dist/templates/starter/files/index.d.ts +1 -1
- package/dist/templates/starter/files/index.js +1 -1
- package/dist/templates/starter/files/index.js.map +1 -1
- package/dist/templates/starter/files/starter.d.ts +2 -1
- package/dist/templates/starter/files/starter.js +39 -29
- package/dist/templates/starter/files/starter.js.map +1 -1
- package/dist/templates/starter/files/workspace-config-tpl.js +7 -1
- package/dist/templates/starter/files/workspace-config-tpl.js.map +1 -1
- package/dist/templates/starter/index.d.ts +1 -1
- package/dist/templates/starter/index.js +16 -16
- package/dist/templates/starter/index.js.map +1 -1
- package/dist/templates/starter-standalone/files/doc-file.d.ts +2 -0
- package/dist/templates/starter-standalone/files/doc-file.js +33 -0
- package/dist/templates/starter-standalone/files/doc-file.js.map +1 -0
- package/dist/templates/starter-standalone/files/git-ignore-tpl.d.ts +1 -0
- package/dist/templates/starter-standalone/files/git-ignore-tpl.js +121 -0
- package/dist/templates/starter-standalone/files/git-ignore-tpl.js.map +1 -0
- package/dist/templates/starter-standalone/files/index.d.ts +2 -0
- package/dist/templates/starter-standalone/files/index.js +15 -0
- package/dist/templates/starter-standalone/files/index.js.map +1 -0
- package/dist/templates/starter-standalone/files/starter.d.ts +2 -0
- package/dist/templates/starter-standalone/files/starter.js +44 -0
- package/dist/templates/starter-standalone/files/starter.js.map +1 -0
- package/dist/templates/starter-standalone/files/workspace-config-tpl.d.ts +1 -0
- package/dist/templates/starter-standalone/files/workspace-config-tpl.js +30 -0
- package/dist/templates/starter-standalone/files/workspace-config-tpl.js.map +1 -0
- package/dist/templates/starter-standalone/index.d.ts +2 -0
- package/dist/templates/starter-standalone/index.js +73 -0
- package/dist/templates/starter-standalone/index.js.map +1 -0
- package/dist/workspace-generator.js +17 -1
- package/dist/workspace-generator.js.map +1 -1
- package/dist/workspace-template.d.ts +37 -29
- package/dist/workspace-template.js.map +1 -1
- package/package.json +22 -22
- package/templates/basic/basic.starter.ts +22 -0
- package/templates/basic/index.ts +1 -0
- package/templates/basic/template/files/git-ignore.ts +110 -0
- package/templates/basic/template/files/workspace-config.ts +33 -0
- package/templates/component-generator/files/component-template-files/component.ts +26 -0
- package/templates/component-generator/files/component-template-files/composition.ts +20 -0
- package/templates/component-generator/files/component-template-files/index-file.ts +15 -0
- package/templates/component-generator/files/component-template-files/test.ts +22 -0
- package/templates/component-generator/files/component-template.ts +58 -0
- package/templates/component-generator/files/index.ts +2 -6
- package/templates/component-generator/index.ts +22 -12
- package/templates/{component-generator → component-generator-standalone}/files/aspect-file.ts +1 -1
- package/templates/component-generator-standalone/files/index.ts +10 -0
- package/templates/{component-generator → component-generator-standalone}/files/main-runtime.ts +1 -1
- package/templates/component-generator-standalone/index.ts +39 -0
- package/templates/index.ts +4 -0
- package/templates/starter/files/doc-file.ts +24 -0
- package/templates/starter/files/generate-files.ts +27 -0
- package/templates/starter/files/index.ts +2 -2
- package/templates/starter/files/starter.ts +37 -28
- package/templates/starter/files/workspace-config-tpl.ts +7 -1
- package/templates/starter/index.ts +13 -11
- package/templates/starter-standalone/files/doc-file.ts +24 -0
- package/templates/starter-standalone/files/git-ignore-tpl.ts +113 -0
- package/templates/starter-standalone/files/index.ts +6 -0
- package/templates/starter-standalone/files/starter.ts +35 -0
- package/templates/starter-standalone/files/workspace-config-tpl.ts +22 -0
- package/templates/starter-standalone/index.ts +44 -0
- package/dist/templates/component-generator/files/aspect-file.js.map +0 -1
- package/dist/templates/component-generator/files/main-runtime.js.map +0 -1
- package/dist/templates/starter/files/docs-file.d.ts +0 -1
- package/dist/templates/starter/files/docs-file.js +0 -45
- package/dist/templates/starter/files/docs-file.js.map +0 -1
- package/dist/templates/starter/files/readme-tpl.d.ts +0 -1
- package/dist/templates/starter/files/readme-tpl.js +0 -47
- package/dist/templates/starter/files/readme-tpl.js.map +0 -1
- package/dist/templates/workspace-generator/index.d.ts +0 -2
- package/dist/templates/workspace-generator/index.js.map +0 -1
- package/templates/starter/files/docs-file.ts +0 -37
- package/templates/starter/files/readme-tpl.ts +0 -39
- package/templates/workspace-generator/index.ts +0 -10
- /package/dist/templates/{component-generator → component-generator-standalone}/files/aspect-file.js +0 -0
- /package/dist/templates/{component-generator → component-generator-standalone}/files/docs-file.d.ts +0 -0
- /package/dist/templates/{component-generator → component-generator-standalone}/files/docs-file.js +0 -0
- /package/dist/templates/{component-generator → component-generator-standalone}/files/docs-file.js.map +0 -0
- /package/dist/templates/{component-generator → component-generator-standalone}/files/main-runtime.js +0 -0
- /package/templates/{component-generator → component-generator-standalone}/files/docs-file.ts +0 -0
@@ -0,0 +1,22 @@
|
|
1
|
+
export const generateTestFileContent = () => {
|
2
|
+
return `import { ComponentContext } from '@teambit/generator';
|
3
|
+
|
4
|
+
export const testFile = (context: ComponentContext) => {
|
5
|
+
const { name, namePascalCase: Name } = context;
|
6
|
+
|
7
|
+
return {
|
8
|
+
relativePath: name + '.spec.tsx',
|
9
|
+
content: \`import React from 'react';
|
10
|
+
import { render } from '@testing-library/react';
|
11
|
+
import { Basic\${Name} } from './\${name}.composition';
|
12
|
+
|
13
|
+
it('renders with the correct text', () => {
|
14
|
+
const { getByText } = render(<Basic\${Name} />);
|
15
|
+
const rendered = getByText('hello world!');
|
16
|
+
expect(rendered).toBeTruthy();
|
17
|
+
});
|
18
|
+
\`,
|
19
|
+
};
|
20
|
+
};
|
21
|
+
`;
|
22
|
+
};
|
@@ -0,0 +1,58 @@
|
|
1
|
+
import { ComponentContext } from '@teambit/generator';
|
2
|
+
|
3
|
+
export function componentTemplate({ namePascalCase, name }: ComponentContext) {
|
4
|
+
return `import {
|
5
|
+
ComponentContext,
|
6
|
+
ComponentFile,
|
7
|
+
ComponentTemplate,
|
8
|
+
} from '@teambit/generator';
|
9
|
+
import { indexFile } from './files/index-file';
|
10
|
+
import { componentFile } from './files/component-file';
|
11
|
+
import { testFile } from './files/test-file';
|
12
|
+
import { compositionFile } from './files/composition-file';
|
13
|
+
|
14
|
+
export type ${namePascalCase}ComponentTemplateOptions = {
|
15
|
+
/**
|
16
|
+
* name of the template
|
17
|
+
*/
|
18
|
+
name?: string;
|
19
|
+
|
20
|
+
/**
|
21
|
+
* description of the template.
|
22
|
+
*/
|
23
|
+
description?: string;
|
24
|
+
|
25
|
+
/**
|
26
|
+
* hide the template from the templates command.
|
27
|
+
*/
|
28
|
+
hidden?: boolean;
|
29
|
+
};
|
30
|
+
|
31
|
+
export class ${namePascalCase}ComponentTemplate implements ComponentTemplate {
|
32
|
+
constructor(
|
33
|
+
readonly name = '${name}',
|
34
|
+
readonly description = 'a template for ${name} components',
|
35
|
+
readonly hidden = false
|
36
|
+
) {}
|
37
|
+
|
38
|
+
generateFiles(context: ComponentContext): ComponentFile[] {
|
39
|
+
return [
|
40
|
+
indexFile(context),
|
41
|
+
compositionFile(context),
|
42
|
+
componentFile(context),
|
43
|
+
testFile(context),
|
44
|
+
];
|
45
|
+
}
|
46
|
+
|
47
|
+
static from(options: ${namePascalCase}ComponentTemplateOptions = {}) {
|
48
|
+
return () =>
|
49
|
+
new ${namePascalCase}ComponentTemplate(
|
50
|
+
options.name,
|
51
|
+
options.description,
|
52
|
+
options.hidden
|
53
|
+
);
|
54
|
+
}
|
55
|
+
}
|
56
|
+
|
57
|
+
`;
|
58
|
+
}
|
@@ -1,10 +1,6 @@
|
|
1
|
-
import { ComponentContext } from '
|
1
|
+
import { ComponentContext } from '../../..';
|
2
2
|
|
3
3
|
export function indexFile({ namePascalCase, name }: ComponentContext) {
|
4
|
-
return `
|
5
|
-
|
6
|
-
export type { ${namePascalCase}Main } from './${name}.main.runtime';
|
7
|
-
export default ${namePascalCase}Aspect;
|
8
|
-
export { ${namePascalCase}Aspect };
|
4
|
+
return `export { ${namePascalCase}ComponentTemplate } from './${name}';
|
9
5
|
`;
|
10
6
|
}
|
@@ -1,13 +1,14 @@
|
|
1
|
-
import { ComponentContext, ComponentTemplate } from '
|
1
|
+
import { ComponentContext, ComponentTemplate } from '../..';
|
2
2
|
import { indexFile } from './files/index';
|
3
|
-
import {
|
4
|
-
import {
|
5
|
-
import {
|
3
|
+
import { generateTestFileContent } from './files/component-template-files/test';
|
4
|
+
import { generateComponentFileContent } from './files/component-template-files/component';
|
5
|
+
import { generateCompositionFileContent } from './files/component-template-files/composition';
|
6
|
+
import { generateIndexFileContent } from './files/component-template-files/index-file';
|
7
|
+
import { componentTemplate } from './files/component-template';
|
6
8
|
|
7
9
|
export const componentGeneratorTemplate: ComponentTemplate = {
|
8
10
|
name: 'component-generator',
|
9
|
-
description:
|
10
|
-
'create your own component generator \nDocs: https://bit.dev/docs/dev-services/generator/generate-component',
|
11
|
+
description: 'create your own component generator \nDocs: https://bit.dev/reference/generator/create-generator',
|
11
12
|
generateFiles: (context: ComponentContext) => {
|
12
13
|
return [
|
13
14
|
{
|
@@ -15,17 +16,26 @@ export const componentGeneratorTemplate: ComponentTemplate = {
|
|
15
16
|
content: indexFile(context),
|
16
17
|
isMain: true,
|
17
18
|
},
|
19
|
+
|
20
|
+
{
|
21
|
+
relativePath: `./${context.name}.ts`,
|
22
|
+
content: componentTemplate(context),
|
23
|
+
},
|
24
|
+
{
|
25
|
+
relativePath: `./files/test-file.ts`,
|
26
|
+
content: generateTestFileContent(),
|
27
|
+
},
|
18
28
|
{
|
19
|
-
relativePath:
|
20
|
-
content:
|
29
|
+
relativePath: `./files/composition-file.ts`,
|
30
|
+
content: generateCompositionFileContent(),
|
21
31
|
},
|
22
32
|
{
|
23
|
-
relativePath:
|
24
|
-
content:
|
33
|
+
relativePath: `./files/component-file.ts`,
|
34
|
+
content: generateComponentFileContent(),
|
25
35
|
},
|
26
36
|
{
|
27
|
-
relativePath:
|
28
|
-
content:
|
37
|
+
relativePath: `./files/index-file.ts`,
|
38
|
+
content: generateIndexFileContent(),
|
29
39
|
},
|
30
40
|
];
|
31
41
|
},
|
@@ -0,0 +1,10 @@
|
|
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
|
+
}
|
@@ -0,0 +1,39 @@
|
|
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
|
+
|
7
|
+
export const componentGeneratorTemplate: ComponentTemplate = {
|
8
|
+
name: 'component-generator',
|
9
|
+
description:
|
10
|
+
'create your own component generator \nDocs: https://bit.dev/docs/dev-services/generator/generate-component',
|
11
|
+
hidden: true,
|
12
|
+
generateFiles: (context: ComponentContext) => {
|
13
|
+
return [
|
14
|
+
{
|
15
|
+
relativePath: 'index.ts',
|
16
|
+
content: indexFile(context),
|
17
|
+
isMain: true,
|
18
|
+
},
|
19
|
+
{
|
20
|
+
relativePath: `${context.name}.aspect.ts`,
|
21
|
+
content: aspectFile(context),
|
22
|
+
},
|
23
|
+
{
|
24
|
+
relativePath: `${context.name}.docs.mdx`,
|
25
|
+
content: docsFile(),
|
26
|
+
},
|
27
|
+
{
|
28
|
+
relativePath: `${context.name}.main.runtime.ts`,
|
29
|
+
content: mainRuntime(context),
|
30
|
+
},
|
31
|
+
];
|
32
|
+
},
|
33
|
+
config: {
|
34
|
+
'teambit.harmony/aspect': {},
|
35
|
+
'teambit.envs/envs': {
|
36
|
+
env: 'teambit.harmony/aspect',
|
37
|
+
},
|
38
|
+
},
|
39
|
+
};
|
@@ -0,0 +1,4 @@
|
|
1
|
+
export { starterTemplate as starterTemplateStandalone } from './starter-standalone';
|
2
|
+
export { starterTemplate } from './starter';
|
3
|
+
export { componentGeneratorTemplate as componentGeneratorTemplateStandalone } from './component-generator-standalone';
|
4
|
+
export { componentGeneratorTemplate } from './component-generator';
|
@@ -0,0 +1,24 @@
|
|
1
|
+
import { ComponentContext } from '@teambit/generator';
|
2
|
+
|
3
|
+
export function docFile(context: ComponentContext) {
|
4
|
+
const { name, componentId } = context;
|
5
|
+
return `---
|
6
|
+
description: Starter for generating a ${name} workspace
|
7
|
+
labels: ['generator', 'templates', '${name}-workspace']
|
8
|
+
---
|
9
|
+
|
10
|
+
## Using the ${name} Workspace Starter
|
11
|
+
|
12
|
+
How to use this generator locally, essentially for development purposes:
|
13
|
+
|
14
|
+
\`\`\`js
|
15
|
+
bit new ${name} my-${name}-workspace --load-from /Users/me/path/to/this/dir --aspect ${componentId.toString()}
|
16
|
+
\`\`\`
|
17
|
+
|
18
|
+
How to use this generator after exporting to a remote scope:
|
19
|
+
|
20
|
+
\`\`\`js
|
21
|
+
bit new ${name} my-${name}-workspace --aspect ${componentId.toString()}
|
22
|
+
\`\`\`
|
23
|
+
`;
|
24
|
+
}
|
@@ -0,0 +1,27 @@
|
|
1
|
+
export function generateFiles() {
|
2
|
+
return `import { WorkspaceContext, WorkspaceFile } from '@teambit/generator';
|
3
|
+
import { workspaceConfig } from './workspace-config';
|
4
|
+
import { gitIgnore } from './git-ignore';
|
5
|
+
|
6
|
+
export async function generateFiles(
|
7
|
+
context: WorkspaceContext,
|
8
|
+
): Promise<WorkspaceFile[]> {
|
9
|
+
const files: WorkspaceFile[] = [
|
10
|
+
{
|
11
|
+
relativePath: 'workspace.jsonc',
|
12
|
+
content: await workspaceConfig(context),
|
13
|
+
},
|
14
|
+
];
|
15
|
+
|
16
|
+
if (!context.skipGit) {
|
17
|
+
files.push({
|
18
|
+
relativePath: '.gitignore',
|
19
|
+
content: gitIgnore(),
|
20
|
+
});
|
21
|
+
}
|
22
|
+
|
23
|
+
return files;
|
24
|
+
}
|
25
|
+
|
26
|
+
`;
|
27
|
+
}
|
@@ -1,6 +1,6 @@
|
|
1
|
-
import { ComponentContext } from '
|
1
|
+
import { ComponentContext } from '../../..';
|
2
2
|
|
3
3
|
export function indexFile({ namePascalCase, name }: ComponentContext) {
|
4
|
-
return `export {
|
4
|
+
return `export { ${namePascalCase}WorkspaceStarter } from './${name}.starter';
|
5
5
|
`;
|
6
6
|
}
|
@@ -1,31 +1,40 @@
|
|
1
|
-
|
2
|
-
return `import { WorkspaceContext, Starter } from '@teambit/generator';
|
3
|
-
import { workspaceConfig } from './template/files/workspace-config';
|
4
|
-
import { readme } from './template/files/readme-file';
|
5
|
-
import { gitIgnore } from './template/files/git-ignore';
|
1
|
+
import { ComponentContext } from '@teambit/generator';
|
6
2
|
|
7
|
-
export
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
}
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
}
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
3
|
+
export function starterFile({ namePascalCase, name }: ComponentContext) {
|
4
|
+
return `import { WorkspaceContext, WorkspaceTemplate } from '@teambit/generator';
|
5
|
+
import { generateFiles as generateCommonFiles } from './template/files/generate-files';
|
6
|
+
|
7
|
+
export type ${namePascalCase}StarterOptions = Pick<WorkspaceTemplate, 'name' | 'description' | 'hidden'>;
|
8
|
+
|
9
|
+
export class ${namePascalCase}WorkspaceStarter implements WorkspaceTemplate {
|
10
|
+
constructor(
|
11
|
+
readonly name = '${name}-workspace',
|
12
|
+
readonly description = '${namePascalCase} workspace with a custom react env',
|
13
|
+
readonly hidden = false
|
14
|
+
) {}
|
15
|
+
|
16
|
+
async generateFiles(context: WorkspaceContext) {
|
17
|
+
return generateCommonFiles(context);
|
18
|
+
}
|
19
|
+
|
20
|
+
fork() {
|
21
|
+
return [
|
22
|
+
{
|
23
|
+
id: 'teambit.react/react-env-extension',
|
24
|
+
targetName: 'envs/my-react-env',
|
25
|
+
},
|
26
|
+
];
|
27
|
+
}
|
28
|
+
|
29
|
+
static from(options: Partial<${namePascalCase}StarterOptions>) {
|
30
|
+
return () =>
|
31
|
+
new ${namePascalCase}WorkspaceStarter(
|
32
|
+
options.name,
|
33
|
+
options.description,
|
34
|
+
options.hidden
|
35
|
+
);
|
36
|
+
}
|
37
|
+
}
|
38
|
+
|
30
39
|
`;
|
31
40
|
}
|
@@ -3,9 +3,15 @@ export function workspaceConfigTemplate() {
|
|
3
3
|
import { getWorkspaceConfigTemplateParsed, stringifyWorkspaceConfig } from '@teambit/config';
|
4
4
|
|
5
5
|
export async function workspaceConfig({ name, defaultScope }: WorkspaceContext) {
|
6
|
+
const scope = defaultScope || 'org.scope';
|
6
7
|
const configParsed = await getWorkspaceConfigTemplateParsed();
|
7
8
|
configParsed['teambit.workspace/workspace'].name = name;
|
8
|
-
configParsed['teambit.workspace/workspace'].defaultScope =
|
9
|
+
configParsed['teambit.workspace/workspace'].defaultScope = scope;
|
10
|
+
configParsed['teambit.generator/generator'] = {
|
11
|
+
envs: [
|
12
|
+
scope + '/react/react-env',
|
13
|
+
],
|
14
|
+
};
|
9
15
|
configParsed['teambit.workspace/variants'] = {
|
10
16
|
'*': {},
|
11
17
|
};
|
@@ -1,14 +1,15 @@
|
|
1
|
-
import { ComponentContext, ComponentTemplate } from '
|
1
|
+
import { ComponentContext, ComponentTemplate } from '../../';
|
2
2
|
import { indexFile } from './files/index';
|
3
3
|
import { starterFile } from './files/starter';
|
4
|
-
import {
|
4
|
+
import { docFile } from './files/doc-file';
|
5
5
|
import { gitIgnoreTemplate } from './files/git-ignore-tpl';
|
6
|
-
import { readmeTemplate } from './files/readme-tpl';
|
7
6
|
import { workspaceConfigTemplate } from './files/workspace-config-tpl';
|
7
|
+
import { generateFiles } from './files/generate-files';
|
8
8
|
|
9
9
|
export const starterTemplate: ComponentTemplate = {
|
10
10
|
name: 'starter',
|
11
|
-
description:
|
11
|
+
description:
|
12
|
+
'create your own workspace starter (env integrated) - \nDocs: https://bit.dev/reference/starters/create-starter',
|
12
13
|
generateFiles: (context: ComponentContext) => {
|
13
14
|
return [
|
14
15
|
{
|
@@ -18,30 +19,31 @@ export const starterTemplate: ComponentTemplate = {
|
|
18
19
|
},
|
19
20
|
{
|
20
21
|
relativePath: `${context.name}.starter.ts`,
|
21
|
-
content: starterFile(),
|
22
|
+
content: starterFile(context),
|
22
23
|
},
|
23
24
|
{
|
24
25
|
relativePath: `${context.name}.docs.mdx`,
|
25
|
-
content:
|
26
|
+
content: docFile(context),
|
26
27
|
},
|
27
28
|
{
|
28
29
|
relativePath: 'template/files/git-ignore.ts',
|
29
30
|
content: gitIgnoreTemplate(),
|
30
31
|
},
|
31
|
-
|
32
|
-
relativePath: 'template/files/readme-file.ts',
|
33
|
-
content: readmeTemplate(),
|
34
|
-
},
|
32
|
+
|
35
33
|
{
|
36
34
|
relativePath: 'template/files/workspace-config.ts',
|
37
35
|
content: workspaceConfigTemplate(),
|
38
36
|
},
|
37
|
+
{
|
38
|
+
relativePath: 'template/files/generate-files.ts',
|
39
|
+
content: generateFiles(),
|
40
|
+
},
|
39
41
|
];
|
40
42
|
},
|
41
43
|
config: {
|
42
44
|
'teambit.harmony/aspect': {},
|
43
45
|
'teambit.envs/envs': {
|
44
|
-
env: 'teambit.harmony/
|
46
|
+
env: 'teambit.harmony/node',
|
45
47
|
},
|
46
48
|
},
|
47
49
|
};
|
@@ -0,0 +1,24 @@
|
|
1
|
+
import { ComponentContext } from '@teambit/generator';
|
2
|
+
|
3
|
+
export function docFile(context: ComponentContext) {
|
4
|
+
const { name, componentId } = context;
|
5
|
+
return `---
|
6
|
+
description: Starter for generating a ${name} workspace
|
7
|
+
labels: ['generator', 'templates', '${name}-workspace']
|
8
|
+
---
|
9
|
+
|
10
|
+
## Using the ${name} Workspace Starter
|
11
|
+
|
12
|
+
How to use this generator locally, essentially for development purposes:
|
13
|
+
|
14
|
+
\`\`\`js
|
15
|
+
bit new ${name} my-${name}-workspace --load-from /Users/me/path/to/this/dir --aspect ${componentId.toString()}
|
16
|
+
\`\`\`
|
17
|
+
|
18
|
+
How to use this generator after exporting to a remote scope:
|
19
|
+
|
20
|
+
\`\`\`js
|
21
|
+
bit new ${name} my-${name}-workspace --aspect ${componentId.toString()}
|
22
|
+
\`\`\`
|
23
|
+
`;
|
24
|
+
}
|
@@ -0,0 +1,113 @@
|
|
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
|
+
}
|
@@ -0,0 +1,35 @@
|
|
1
|
+
import { ComponentContext } from '@teambit/generator';
|
2
|
+
|
3
|
+
export function starterFile({ namePascalCase, name }: ComponentContext) {
|
4
|
+
return `import { WorkspaceContext, Starter } from '@teambit/generator';
|
5
|
+
import { workspaceConfig } from './template/files/workspace-config';
|
6
|
+
import { gitIgnore } from './template/files/git-ignore';
|
7
|
+
|
8
|
+
export const ${namePascalCase}WorkspaceStarter: Starter = {
|
9
|
+
name: '${name}-workspace',
|
10
|
+
description: 'a ${name} workspace',
|
11
|
+
generateFiles: async (context: WorkspaceContext) => {
|
12
|
+
const files = [
|
13
|
+
{
|
14
|
+
relativePath: 'workspace.jsonc',
|
15
|
+
content: await workspaceConfig(context),
|
16
|
+
},
|
17
|
+
];
|
18
|
+
|
19
|
+
if (!context.skipGit) {
|
20
|
+
files.push({
|
21
|
+
relativePath: '.gitignore',
|
22
|
+
content: gitIgnore(),
|
23
|
+
});
|
24
|
+
}
|
25
|
+
|
26
|
+
return files;
|
27
|
+
},
|
28
|
+
import: () => [
|
29
|
+
{ id: 'teambit.community/component-showcase' },
|
30
|
+
]
|
31
|
+
};
|
32
|
+
|
33
|
+
export default ${namePascalCase}WorkspaceStarter;
|
34
|
+
`;
|
35
|
+
}
|
@@ -0,0 +1,22 @@
|
|
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 || 'org.scope';
|
9
|
+
configParsed['teambit.generator/generator'] = {
|
10
|
+
envs: [
|
11
|
+
'teambit.react/react-env',
|
12
|
+
'teambit.node/node',
|
13
|
+
],
|
14
|
+
};
|
15
|
+
configParsed['teambit.workspace/variants'] = {
|
16
|
+
'*': {},
|
17
|
+
};
|
18
|
+
|
19
|
+
return stringifyWorkspaceConfig(configParsed);
|
20
|
+
}
|
21
|
+
`;
|
22
|
+
}
|