@teambit/react 0.0.568 → 0.0.569
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/compositions-app.tsx +31 -0
- package/highlighter-widget.tsx +19 -0
- package/mount.tsx +17 -0
- package/package-tar/teambit-react-0.0.569.tgz +0 -0
- package/package.json +44 -59
- package/react.composition.tsx +7 -0
- package/react.ui.runtime.tsx +35 -0
- package/templates/react-app/files/app-root.ts +10 -0
- package/templates/react-app/files/app.ts +30 -0
- package/templates/react-app/files/aspect.ts +10 -0
- package/templates/react-app/files/compositions.ts +11 -0
- package/templates/react-app/files/doc.ts +29 -0
- package/templates/react-app/files/index.ts +10 -0
- package/templates/react-app/files/main.runtime.ts +22 -0
- package/templates/react-app/index.ts +47 -0
- package/templates/react-component/files/component.ts +25 -0
- package/templates/react-component/files/composition.ts +16 -0
- package/templates/react-component/files/docs.ts +32 -0
- package/templates/react-component/files/test.ts +19 -0
- package/templates/react-component/index.ts +40 -0
- package/templates/react-component-js/files/component.ts +18 -0
- package/templates/react-component-js/files/composition.ts +16 -0
- package/templates/react-component-js/files/docs.ts +32 -0
- package/templates/react-component-js/files/test.ts +21 -0
- package/templates/react-component-js/index.ts +38 -0
- package/templates/react-context/files/composition.ts +27 -0
- package/templates/react-context/files/context-provider.ts +27 -0
- package/templates/react-context/files/context.ts +21 -0
- package/templates/react-context/files/docs.ts +51 -0
- package/templates/react-context/files/test.ts +18 -0
- package/templates/react-context/index.ts +32 -0
- package/templates/react-env/files/aspect.ts +10 -0
- package/templates/react-env/files/doc.ts +163 -0
- package/templates/react-env/files/index.ts +10 -0
- package/templates/react-env/files/jest.config.ts +21 -0
- package/templates/react-env/files/main.runtime.ts +84 -0
- package/templates/react-env/files/preview.runtime.ts +27 -0
- package/templates/react-env/files/typescript.config.ts +21 -0
- package/templates/react-env/files/webpack.config.ts +48 -0
- package/templates/react-env/index.ts +51 -0
- package/templates/react-hook/files/component.ts +16 -0
- package/templates/react-hook/files/composition.ts +23 -0
- package/templates/react-hook/files/docs.ts +33 -0
- package/templates/react-hook/files/test.ts +20 -0
- package/templates/react-hook/index.ts +21 -0
- package/templates/react-workspace/index.ts +27 -0
- package/templates/react-workspace-app/index.ts +20 -0
- package/templates/react-workspace-deprecated/index.ts +28 -0
- package/templates/react-workspace-lib/index.ts +21 -0
- package/templates/workspace-common/files/eslint-config.ts +6 -0
- package/templates/workspace-common/files/git-ignore.ts +113 -0
- package/templates/workspace-common/files/prettier-config.ts +5 -0
- package/templates/workspace-common/files/readme-file.ts +36 -0
- package/templates/workspace-common/files/ts-config.ts +7 -0
- package/templates/workspace-common/files/types/asset.ts +28 -0
- package/templates/workspace-common/files/types/style.ts +43 -0
- package/templates/workspace-common/files/workspace-config.ts +58 -0
- package/templates/workspace-common/generate-files.ts +51 -0
- package/templates/workspace-common/index.ts +1 -0
- package/types/asset.d.ts +29 -0
- package/types/style.d.ts +42 -0
- package/typescript/asset.d.ts +29 -0
- package/typescript/style.d.ts +42 -0
- package/webpack/postcss.config.ts +21 -0
- package/webpack/webpack.config.base.prod.ts +123 -0
- package/webpack/webpack.config.base.ts +365 -0
- package/webpack/webpack.config.component.dev.ts +99 -0
- package/webpack/webpack.config.component.prod.ts +39 -0
- package/webpack/webpack.config.env.dev.ts +21 -0
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ComponentContext } from '@teambit/generator';
|
|
2
|
+
|
|
3
|
+
export const componentFile = (context: ComponentContext) => {
|
|
4
|
+
const { name, nameCamelCase: Name } = context;
|
|
5
|
+
return {
|
|
6
|
+
relativePath: `${name}.tsx`,
|
|
7
|
+
content: `import { useState } from 'react';
|
|
8
|
+
|
|
9
|
+
export function ${Name}() {
|
|
10
|
+
const [count, setCount] = useState(0)
|
|
11
|
+
const increment = () => setCount((c) => c + 1)
|
|
12
|
+
return { count, increment }
|
|
13
|
+
}
|
|
14
|
+
`,
|
|
15
|
+
};
|
|
16
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { ComponentContext } from '@teambit/generator';
|
|
2
|
+
|
|
3
|
+
export const compositionFile = (context: ComponentContext) => {
|
|
4
|
+
const { name, nameCamelCase: Name } = context;
|
|
5
|
+
|
|
6
|
+
return {
|
|
7
|
+
relativePath: `${name}.composition.tsx`,
|
|
8
|
+
content: `import React from 'react';
|
|
9
|
+
import { ${Name} } from './${name}';
|
|
10
|
+
|
|
11
|
+
export const Basic${Name} = () => {
|
|
12
|
+
const { count, increment } = ${Name}();
|
|
13
|
+
|
|
14
|
+
return (
|
|
15
|
+
<>
|
|
16
|
+
<h1>The count is {count}</h1>
|
|
17
|
+
<button onClick={increment}>increment</button>
|
|
18
|
+
</>
|
|
19
|
+
);
|
|
20
|
+
};
|
|
21
|
+
`,
|
|
22
|
+
};
|
|
23
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { ComponentContext } from '@teambit/generator';
|
|
2
|
+
|
|
3
|
+
export const docsFile = (context: ComponentContext) => {
|
|
4
|
+
const { name, nameCamelCase: Name } = context;
|
|
5
|
+
|
|
6
|
+
return {
|
|
7
|
+
relativePath: `${name}.docs.mdx`,
|
|
8
|
+
content: `---
|
|
9
|
+
description: 'A React Hook that increments a count by 1 each time it is called.'
|
|
10
|
+
labels: ['hook', 'counter']
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
import { ${Name} } from './${name}';
|
|
14
|
+
|
|
15
|
+
## A React Hook to increment a count
|
|
16
|
+
|
|
17
|
+
Increments the state of \`count\` by 1 each time \`increment\` is called
|
|
18
|
+
|
|
19
|
+
### Component usage
|
|
20
|
+
|
|
21
|
+
In this example clicking the button calls \`increment\` which increments the \`count\` by 1
|
|
22
|
+
|
|
23
|
+
\`\`\`js
|
|
24
|
+
import { ${Name} } from './${name}';
|
|
25
|
+
|
|
26
|
+
const { count, increment } = ${Name}();
|
|
27
|
+
|
|
28
|
+
<h1>The count is {count}</h1>
|
|
29
|
+
<button onClick={increment}>increment</button>
|
|
30
|
+
\`\`\`
|
|
31
|
+
`,
|
|
32
|
+
};
|
|
33
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ComponentContext } from '@teambit/generator';
|
|
2
|
+
|
|
3
|
+
export const testFile = (context: ComponentContext) => {
|
|
4
|
+
const { name, nameCamelCase: Name } = context;
|
|
5
|
+
|
|
6
|
+
return {
|
|
7
|
+
relativePath: `${name}.spec.tsx`,
|
|
8
|
+
content: `import { renderHook, act } from '@testing-library/react-hooks';
|
|
9
|
+
import { ${Name} } from './${name}';
|
|
10
|
+
|
|
11
|
+
it('should increment counter', () => {
|
|
12
|
+
const { result } = renderHook(() => ${Name}())
|
|
13
|
+
act(() => {
|
|
14
|
+
result.current.increment()
|
|
15
|
+
})
|
|
16
|
+
expect(result.current.count).toBe(1)
|
|
17
|
+
})
|
|
18
|
+
`,
|
|
19
|
+
};
|
|
20
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ComponentTemplate, ComponentContext } from '@teambit/generator';
|
|
2
|
+
import { componentFile } from './files/component';
|
|
3
|
+
import { compositionFile } from './files/composition';
|
|
4
|
+
import { docsFile } from './files/docs';
|
|
5
|
+
import { testFile } from './files/test';
|
|
6
|
+
|
|
7
|
+
export const reactHook: ComponentTemplate = {
|
|
8
|
+
name: 'react-hook',
|
|
9
|
+
description: 'a react hook component',
|
|
10
|
+
|
|
11
|
+
generateFiles: (context: ComponentContext) => {
|
|
12
|
+
const { name, nameCamelCase: Name } = context;
|
|
13
|
+
const indexFile = {
|
|
14
|
+
relativePath: 'index.ts',
|
|
15
|
+
content: `export { ${Name} } from './${name}';
|
|
16
|
+
`,
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
return [indexFile, componentFile(context), compositionFile(context), docsFile(context), testFile(context)];
|
|
20
|
+
},
|
|
21
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { WorkspaceContext, WorkspaceTemplate } from '@teambit/generator';
|
|
2
|
+
import { generateFiles as generateCommonFiles } from '../workspace-common';
|
|
3
|
+
|
|
4
|
+
export const reactWorkspaceTemplate: WorkspaceTemplate = {
|
|
5
|
+
name: 'react',
|
|
6
|
+
description: 'React workspace with demo components',
|
|
7
|
+
generateFiles: async (context: WorkspaceContext) => {
|
|
8
|
+
return generateCommonFiles(context);
|
|
9
|
+
},
|
|
10
|
+
importComponents: () => {
|
|
11
|
+
return [
|
|
12
|
+
{
|
|
13
|
+
id: 'teambit.react/templates/envs/my-react',
|
|
14
|
+
targetName: 'envs/my-react',
|
|
15
|
+
path: 'demo/envs/my-react',
|
|
16
|
+
},
|
|
17
|
+
{ id: 'teambit.react/templates/ui/text', targetName: 'ui/text', path: 'demo/ui/text' },
|
|
18
|
+
{ id: 'teambit.react/templates/ui/heading', targetName: 'ui/heading', path: 'demo/ui/heading' },
|
|
19
|
+
{ id: 'teambit.react/templates/ui/card', targetName: 'ui/card', path: 'demo/ui/card' },
|
|
20
|
+
{
|
|
21
|
+
id: 'teambit.react/templates/pages/welcome',
|
|
22
|
+
targetName: 'pages/welcome',
|
|
23
|
+
path: 'demo/pages/welcome',
|
|
24
|
+
},
|
|
25
|
+
];
|
|
26
|
+
},
|
|
27
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { WorkspaceContext, WorkspaceTemplate } from '@teambit/generator';
|
|
2
|
+
import { generateFiles as generateCommonFiles } from '../workspace-common';
|
|
3
|
+
|
|
4
|
+
export const reactWorkspaceAppTemplate: WorkspaceTemplate = {
|
|
5
|
+
name: 'react-app',
|
|
6
|
+
description: 'EXPERIMENTAL. react workspace for an app',
|
|
7
|
+
hidden: true,
|
|
8
|
+
generateFiles: async (context: WorkspaceContext) => {
|
|
9
|
+
return generateCommonFiles(context);
|
|
10
|
+
},
|
|
11
|
+
importComponents: () => {
|
|
12
|
+
return [
|
|
13
|
+
{ id: 'teambit.react/templates/apps/my-app', path: 'apps/my-app' },
|
|
14
|
+
{ id: 'teambit.react/templates/envs/my-react', path: 'envs/my-react' },
|
|
15
|
+
{ id: 'teambit.react/templates/themes/theme', path: 'themes/theme' },
|
|
16
|
+
{ id: 'teambit.react/templates/styles/colors', path: 'styles/colors' },
|
|
17
|
+
{ id: 'teambit.react/templates/ui/heading', path: 'ui/heading' },
|
|
18
|
+
];
|
|
19
|
+
},
|
|
20
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { WorkspaceContext, WorkspaceTemplate } from '@teambit/generator';
|
|
2
|
+
import { generateFiles as generateCommonFiles } from '../workspace-common';
|
|
3
|
+
|
|
4
|
+
export const deprecatedReactWorkspaceTemplate: WorkspaceTemplate = {
|
|
5
|
+
name: 'react-workspace',
|
|
6
|
+
description: 'React workspace with demo components',
|
|
7
|
+
hidden: true,
|
|
8
|
+
generateFiles: async (context: WorkspaceContext) => {
|
|
9
|
+
return generateCommonFiles(context);
|
|
10
|
+
},
|
|
11
|
+
importComponents: () => {
|
|
12
|
+
return [
|
|
13
|
+
{
|
|
14
|
+
id: 'teambit.react/templates/envs/my-react',
|
|
15
|
+
targetName: 'envs/my-react',
|
|
16
|
+
path: 'demo/envs/my-react',
|
|
17
|
+
},
|
|
18
|
+
{ id: 'teambit.react/templates/ui/text', targetName: 'ui/text', path: 'demo/ui/text' },
|
|
19
|
+
{ id: 'teambit.react/templates/ui/heading', targetName: 'ui/heading', path: 'demo/ui/heading' },
|
|
20
|
+
{ id: 'teambit.react/templates/ui/card', targetName: 'ui/card', path: 'demo/ui/card' },
|
|
21
|
+
{
|
|
22
|
+
id: 'teambit.react/templates/pages/welcome',
|
|
23
|
+
targetName: 'pages/welcome',
|
|
24
|
+
path: 'demo/pages/welcome',
|
|
25
|
+
},
|
|
26
|
+
];
|
|
27
|
+
},
|
|
28
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { WorkspaceContext, WorkspaceTemplate } from '@teambit/generator';
|
|
2
|
+
import { generateFiles as generateCommonFiles } from '../workspace-common';
|
|
3
|
+
|
|
4
|
+
export const reactWorkspaceLibTemplate: WorkspaceTemplate = {
|
|
5
|
+
name: 'react-lib',
|
|
6
|
+
description: 'EXPERIMENTAL. react workspace for a component library',
|
|
7
|
+
hidden: true,
|
|
8
|
+
generateFiles: async (context: WorkspaceContext) => {
|
|
9
|
+
return generateCommonFiles(context);
|
|
10
|
+
},
|
|
11
|
+
importComponents: () => {
|
|
12
|
+
return [
|
|
13
|
+
{ id: 'teambit.react/templates/envs/my-react', targetName: 'envs/my-react', path: 'demo/envs/my-react' },
|
|
14
|
+
{ id: 'teambit.react/templates/ui/text', targetName: 'ui/text', path: 'demo/ui/text' },
|
|
15
|
+
{ id: 'teambit.react/templates/ui/heading', targetName: 'ui/heading', path: 'demo/ui/heading' },
|
|
16
|
+
{ id: 'teambit.react/templates/ui/card', targetName: 'ui/card', path: 'demo/ui/card' },
|
|
17
|
+
{ id: 'teambit.react/templates/styles/colors', targetName: 'styles/colors', path: 'demo/styles/colors' },
|
|
18
|
+
{ id: 'teambit.react/templates/themes/theme', targetName: 'themes/theme', path: 'demo/themes/theme' },
|
|
19
|
+
];
|
|
20
|
+
},
|
|
21
|
+
};
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
export function gitIgnore() {
|
|
2
|
+
return `# Bit
|
|
3
|
+
.bit
|
|
4
|
+
public
|
|
5
|
+
|
|
6
|
+
# Logs
|
|
7
|
+
logs
|
|
8
|
+
*.log
|
|
9
|
+
npm-debug.log*
|
|
10
|
+
yarn-debug.log*
|
|
11
|
+
yarn-error.log*
|
|
12
|
+
lerna-debug.log*
|
|
13
|
+
|
|
14
|
+
# Diagnostic reports (https://nodejs.org/api/report.html)
|
|
15
|
+
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
|
|
16
|
+
|
|
17
|
+
# Runtime data
|
|
18
|
+
pids
|
|
19
|
+
*.pid
|
|
20
|
+
*.seed
|
|
21
|
+
*.pid.lock
|
|
22
|
+
|
|
23
|
+
# Directory for instrumented libs generated by jscoverage/JSCover
|
|
24
|
+
lib-cov
|
|
25
|
+
|
|
26
|
+
# Coverage directory used by tools like istanbul
|
|
27
|
+
coverage
|
|
28
|
+
*.lcov
|
|
29
|
+
|
|
30
|
+
# nyc test coverage
|
|
31
|
+
.nyc_output
|
|
32
|
+
|
|
33
|
+
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
|
|
34
|
+
.grunt
|
|
35
|
+
|
|
36
|
+
# Bower dependency directory (https://bower.io/)
|
|
37
|
+
bower_components
|
|
38
|
+
|
|
39
|
+
# node-waf configuration
|
|
40
|
+
.lock-wscript
|
|
41
|
+
|
|
42
|
+
# Compiled binary addons (https://nodejs.org/api/addons.html)
|
|
43
|
+
build/Release
|
|
44
|
+
|
|
45
|
+
# Dependency directories
|
|
46
|
+
node_modules/
|
|
47
|
+
jspm_packages/
|
|
48
|
+
|
|
49
|
+
# TypeScript v1 declaration files
|
|
50
|
+
typings/
|
|
51
|
+
|
|
52
|
+
# TypeScript cache
|
|
53
|
+
*.tsbuildinfo
|
|
54
|
+
|
|
55
|
+
# Optional npm cache directory
|
|
56
|
+
.npm
|
|
57
|
+
|
|
58
|
+
# Optional eslint cache
|
|
59
|
+
.eslintcache
|
|
60
|
+
|
|
61
|
+
# Microbundle cache
|
|
62
|
+
.rpt2_cache/
|
|
63
|
+
.rts2_cache_cjs/
|
|
64
|
+
.rts2_cache_es/
|
|
65
|
+
.rts2_cache_umd/
|
|
66
|
+
|
|
67
|
+
# Optional REPL history
|
|
68
|
+
.node_repl_history
|
|
69
|
+
|
|
70
|
+
# Output of 'npm pack'
|
|
71
|
+
*.tgz
|
|
72
|
+
|
|
73
|
+
# Yarn Integrity file
|
|
74
|
+
.yarn-integrity
|
|
75
|
+
|
|
76
|
+
# dotenv environment variables file
|
|
77
|
+
.env
|
|
78
|
+
.env.test
|
|
79
|
+
|
|
80
|
+
# parcel-bundler cache (https://parceljs.org/)
|
|
81
|
+
.cache
|
|
82
|
+
|
|
83
|
+
# Next.js build output
|
|
84
|
+
.next
|
|
85
|
+
|
|
86
|
+
# Nuxt.js build / generate output
|
|
87
|
+
.nuxt
|
|
88
|
+
dist
|
|
89
|
+
|
|
90
|
+
# Gatsby files
|
|
91
|
+
.cache/
|
|
92
|
+
|
|
93
|
+
# vuepress build output
|
|
94
|
+
.vuepress/dist
|
|
95
|
+
|
|
96
|
+
# Serverless directories
|
|
97
|
+
.serverless/
|
|
98
|
+
|
|
99
|
+
# FuseBox cache
|
|
100
|
+
.fusebox/
|
|
101
|
+
|
|
102
|
+
# DynamoDB Local files
|
|
103
|
+
.dynamodb/
|
|
104
|
+
|
|
105
|
+
# TernJS port file
|
|
106
|
+
.tern-port
|
|
107
|
+
|
|
108
|
+
.history
|
|
109
|
+
|
|
110
|
+
.DS_Store
|
|
111
|
+
|
|
112
|
+
`;
|
|
113
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
export function readme() {
|
|
2
|
+
return `# Welcome to your Bit Workspace
|
|
3
|
+
|
|
4
|
+
To get started straight away run \`bit start\` and open [localhost:3000](http://localhost:3000). It may take a while to build the first time you run this command as it is building the whole User Interface for your development environment.
|
|
5
|
+
|
|
6
|
+
\`\`\`bash
|
|
7
|
+
bit start
|
|
8
|
+
\`\`\`
|
|
9
|
+
|
|
10
|
+
## What's included
|
|
11
|
+
|
|
12
|
+
- **workspace.jsonc**
|
|
13
|
+
|
|
14
|
+
This is the main configuration file of your bit workspace. Here you can modify the workspace name and icon as well as default directory and scope. It is where dependencies are found when you install anything. It is also where you register aspects, bit extensions as well as apply the environments for your components. This workspace has been setup so that all components use the React env. However you can create other components and apply other envs to them such as node, html, angular and aspect envs.
|
|
15
|
+
|
|
16
|
+
- **.bitmap**
|
|
17
|
+
|
|
18
|
+
This is an auto-generated file and includes the mapping of your components. There is one component included here. In order to remove this component you can run the following command.
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
- **Demo Components**
|
|
22
|
+
|
|
23
|
+
A folder (unless the --empty flag was used) containing demo components are included in this workspace. These components are used to demonstrate the different features of Bit. If you would like to remove these components you can run the following command.
|
|
24
|
+
|
|
25
|
+
\`\`\`jsx
|
|
26
|
+
bit remove "ui/*" --delete files
|
|
27
|
+
\`\`\`
|
|
28
|
+
|
|
29
|
+
This removes the components from the bitmap as well as removes the files.
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
- **.gitignore**
|
|
33
|
+
|
|
34
|
+
Ignoring any files from version control
|
|
35
|
+
`;
|
|
36
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export const assetTypes = `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
|
+
declare module '*.jpg' {
|
|
13
|
+
const value: any;
|
|
14
|
+
export = value;
|
|
15
|
+
}
|
|
16
|
+
declare module '*.jpeg' {
|
|
17
|
+
const value: any;
|
|
18
|
+
export = value;
|
|
19
|
+
}
|
|
20
|
+
declare module '*.gif' {
|
|
21
|
+
const value: any;
|
|
22
|
+
export = value;
|
|
23
|
+
}
|
|
24
|
+
declare module '*.bmp' {
|
|
25
|
+
const value: any;
|
|
26
|
+
export = value;
|
|
27
|
+
}
|
|
28
|
+
`;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
export const styleTypes = `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
|
+
}
|
|
43
|
+
`;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { WorkspaceContext } from '@teambit/generator';
|
|
2
|
+
import { getWorkspaceConfigTemplateParsed, stringifyWorkspaceConfig } from '@teambit/config';
|
|
3
|
+
import { parse, assign } from 'comment-json';
|
|
4
|
+
|
|
5
|
+
export async function workspaceConfig({ name, defaultScope, empty }: WorkspaceContext) {
|
|
6
|
+
const scope = defaultScope || 'company.scope';
|
|
7
|
+
const configParsed = await getWorkspaceConfigTemplateParsed();
|
|
8
|
+
configParsed['teambit.workspace/workspace'].name = name;
|
|
9
|
+
configParsed['teambit.workspace/workspace'].defaultScope = scope;
|
|
10
|
+
configParsed['teambit.dependencies/dependency-resolver'].packageManager = 'teambit.dependencies/pnpm';
|
|
11
|
+
configParsed['teambit.dependencies/dependency-resolver'].policy = {
|
|
12
|
+
dependencies: {
|
|
13
|
+
'@teambit/eslint-config-bit-react': '~0.0.367',
|
|
14
|
+
'@typescript-eslint/eslint-plugin': '4.29.3',
|
|
15
|
+
'eslint-import-resolver-node': '0.3.6',
|
|
16
|
+
'eslint-plugin-import': '2.22.1',
|
|
17
|
+
'eslint-plugin-jest': '24.4.0',
|
|
18
|
+
'eslint-plugin-jsx-a11y': '6.4.1',
|
|
19
|
+
'eslint-plugin-mdx': '1.15.0',
|
|
20
|
+
'eslint-plugin-react': '7.25.1',
|
|
21
|
+
},
|
|
22
|
+
peerDependencies: {
|
|
23
|
+
'@testing-library/react': '12.0.0',
|
|
24
|
+
react: '17.0.2',
|
|
25
|
+
'react-dom': '17.0.2',
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
const variants = {
|
|
30
|
+
'teambit.workspace/variants': empty
|
|
31
|
+
? {
|
|
32
|
+
'*': {
|
|
33
|
+
'teambit.react/react': {},
|
|
34
|
+
},
|
|
35
|
+
}
|
|
36
|
+
: parse(`{
|
|
37
|
+
"{ui/**}, {pages/**}": {
|
|
38
|
+
// uses the custom env
|
|
39
|
+
"${scope}/envs/my-react": {},
|
|
40
|
+
// uncomment the line below if you remove the custom env and remove the line above
|
|
41
|
+
// "teambit.react/react": {},
|
|
42
|
+
},
|
|
43
|
+
"{themes/**}": {
|
|
44
|
+
"teambit.react/react": {},
|
|
45
|
+
},
|
|
46
|
+
"{content/**}": {
|
|
47
|
+
"teambit.mdx/mdx": {},
|
|
48
|
+
},
|
|
49
|
+
"{envs/**}, {extensions/**}": {
|
|
50
|
+
"teambit.harmony/aspect": {},
|
|
51
|
+
},
|
|
52
|
+
}`),
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
const configMerged = assign(configParsed, variants);
|
|
56
|
+
|
|
57
|
+
return stringifyWorkspaceConfig(configMerged);
|
|
58
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { WorkspaceContext } from '@teambit/generator';
|
|
2
|
+
import { workspaceConfig } from './files/workspace-config';
|
|
3
|
+
import { readme } from './files/readme-file';
|
|
4
|
+
import { gitIgnore } from './files/git-ignore';
|
|
5
|
+
import { assetTypes } from './files/types/asset';
|
|
6
|
+
import { styleTypes } from './files/types/style';
|
|
7
|
+
import { eslintConfig } from './files/eslint-config';
|
|
8
|
+
import { tsConfig } from './files/ts-config';
|
|
9
|
+
import { prettierConfig } from './files/prettier-config';
|
|
10
|
+
|
|
11
|
+
type GeneratedFile = {
|
|
12
|
+
relativePath: string;
|
|
13
|
+
content: string;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export async function generateFiles(context: WorkspaceContext): Promise<GeneratedFile[]> {
|
|
17
|
+
return [
|
|
18
|
+
{
|
|
19
|
+
relativePath: 'workspace.jsonc',
|
|
20
|
+
content: await workspaceConfig(context),
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
relativePath: `.gitignore`,
|
|
24
|
+
content: gitIgnore(),
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
relativePath: `README.md`,
|
|
28
|
+
content: readme(),
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
relativePath: `.eslintrc.js`,
|
|
32
|
+
content: eslintConfig,
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
relativePath: `tsconfig.json`,
|
|
36
|
+
content: tsConfig,
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
relativePath: `.prettierrc.js`,
|
|
40
|
+
content: prettierConfig,
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
relativePath: `types/asset.d.ts`,
|
|
44
|
+
content: assetTypes,
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
relativePath: `types/style.d.ts`,
|
|
48
|
+
content: styleTypes,
|
|
49
|
+
},
|
|
50
|
+
];
|
|
51
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { generateFiles } from './generate-files';
|
package/types/asset.d.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
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
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
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
|
+
}
|