create-umi 0.25.1 → 4.0.0-beta.12
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/README.md +2 -97
- package/bin/create-umi.js +3 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +31 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +105 -0
- package/package.json +18 -40
- package/templates/app/.gitignore.tpl +8 -0
- package/templates/app/.npmrc.tpl +1 -0
- package/templates/app/.umirc.ts.tpl +3 -0
- package/templates/app/layouts/index.tsx +22 -0
- package/templates/app/package.json.tpl +17 -0
- package/templates/app/pages/index.tsx +5 -0
- package/templates/app/pages/users/foo.tsx +3 -0
- package/templates/app/pages/users.tsx +9 -0
- package/templates/plugin/.fatherrc.ts +5 -0
- package/templates/plugin/.gitignore.tpl +2 -0
- package/templates/plugin/.npmrc.tpl +1 -0
- package/templates/plugin/README.md.tpl +38 -0
- package/templates/plugin/package.json.tpl +24 -0
- package/templates/plugin/src/index.ts.tpl +5 -0
- package/CHANGELOG.md +0 -44
- package/cli.js +0 -37
- package/index.js +0 -3
- package/lib/BasicGenerator.js +0 -70
- package/lib/generators/ant-design-pro/.babelrc +0 -10
- package/lib/generators/ant-design-pro/README.md +0 -57
- package/lib/generators/ant-design-pro/filterPkg.js +0 -15
- package/lib/generators/ant-design-pro/index.js +0 -232
- package/lib/generators/ant-design-pro/meta.json +0 -3
- package/lib/generators/app/index.js +0 -69
- package/lib/generators/app/meta.json +0 -3
- package/lib/generators/app/templates/.editorconfig +0 -16
- package/lib/generators/app/templates/.env +0 -2
- package/lib/generators/app/templates/.eslintrc +0 -3
- package/lib/generators/app/templates/.prettierignore +0 -7
- package/lib/generators/app/templates/.prettierrc +0 -11
- package/lib/generators/app/templates/.umirc.js +0 -37
- package/lib/generators/app/templates/.umirc.ts +0 -40
- package/lib/generators/app/templates/_gitignore +0 -18
- package/lib/generators/app/templates/mock/.gitkeep +0 -0
- package/lib/generators/app/templates/package.json +0 -60
- package/lib/generators/app/templates/src/app.js +0 -8
- package/lib/generators/app/templates/src/app.ts +0 -8
- package/lib/generators/app/templates/src/assets/welcomeImgs/0.jpg +0 -0
- package/lib/generators/app/templates/src/assets/welcomeImgs/1.jpg +0 -0
- package/lib/generators/app/templates/src/global.css +0 -7
- package/lib/generators/app/templates/src/layouts/__tests__/index.test.js +0 -14
- package/lib/generators/app/templates/src/layouts/__tests__/index.test.tsx +0 -16
- package/lib/generators/app/templates/src/layouts/index.css +0 -15
- package/lib/generators/app/templates/src/layouts/index.js +0 -12
- package/lib/generators/app/templates/src/layouts/index.tsx +0 -13
- package/lib/generators/app/templates/src/locales/en-US.js +0 -3
- package/lib/generators/app/templates/src/locales/en-US.ts +0 -3
- package/lib/generators/app/templates/src/models/.gitkeep +0 -0
- package/lib/generators/app/templates/src/pages/__tests__/__mocks__/umi-plugin-locale.js +0 -1
- package/lib/generators/app/templates/src/pages/__tests__/__mocks__/umi-plugin-locale.ts +0 -1
- package/lib/generators/app/templates/src/pages/__tests__/index.test.js +0 -19
- package/lib/generators/app/templates/src/pages/__tests__/index.test.tsx +0 -21
- package/lib/generators/app/templates/src/pages/index.css +0 -23
- package/lib/generators/app/templates/src/pages/index.js +0 -18
- package/lib/generators/app/templates/src/pages/index.tsx +0 -19
- package/lib/generators/app/templates/tsconfig.json +0 -18
- package/lib/generators/app/templates/typings.d.ts +0 -2
- package/lib/generators/app/templates/webpack.config.js +0 -12
- package/lib/generators/block/index.js +0 -56
- package/lib/generators/block/meta.json +0 -3
- package/lib/generators/block/templates/.prettierignore +0 -7
- package/lib/generators/block/templates/.prettierrc +0 -11
- package/lib/generators/block/templates/.umirc.js +0 -5
- package/lib/generators/block/templates/.umirc.ts +0 -9
- package/lib/generators/block/templates/LICENSE +0 -21
- package/lib/generators/block/templates/README.md +0 -13
- package/lib/generators/block/templates/_gitignore +0 -7
- package/lib/generators/block/templates/package.json +0 -27
- package/lib/generators/block/templates/src/index.css +0 -3
- package/lib/generators/block/templates/src/index.js +0 -9
- package/lib/generators/block/templates/src/index.tsx +0 -12
- package/lib/generators/block/templates/tsconfig.json +0 -18
- package/lib/generators/block/templates/typings.d.ts +0 -2
- package/lib/generators/library/index.js +0 -55
- package/lib/generators/library/meta.json +0 -3
- package/lib/generators/library/templates/.fatherrc.js +0 -4
- package/lib/generators/library/templates/.fatherrc.ts +0 -9
- package/lib/generators/library/templates/.prettierignore +0 -5
- package/lib/generators/library/templates/.prettierrc +0 -11
- package/lib/generators/library/templates/LICENSE +0 -21
- package/lib/generators/library/templates/README.md +0 -13
- package/lib/generators/library/templates/_gitignore +0 -5
- package/lib/generators/library/templates/package.json +0 -28
- package/lib/generators/library/templates/src/index.css +0 -4
- package/lib/generators/library/templates/src/index.js +0 -15
- package/lib/generators/library/templates/src/index.mdx +0 -18
- package/lib/generators/library/templates/src/index.tsx +0 -21
- package/lib/generators/library/templates/tsconfig.json +0 -17
- package/lib/generators/library/templates/typings.d.ts +0 -2
- package/lib/generators/plugin/index.js +0 -81
- package/lib/generators/plugin/meta.json +0 -3
- package/lib/generators/plugin/templates/.editorconfig +0 -16
- package/lib/generators/plugin/templates/.fatherrc.js +0 -35
- package/lib/generators/plugin/templates/.fatherrc.ts +0 -35
- package/lib/generators/plugin/templates/.gitignore +0 -8
- package/lib/generators/plugin/templates/.prettierignore +0 -8
- package/lib/generators/plugin/templates/.prettierrc +0 -14
- package/lib/generators/plugin/templates/CONTRIBUTING.md +0 -40
- package/lib/generators/plugin/templates/README.md +0 -51
- package/lib/generators/plugin/templates/example/.gitignore +0 -5
- package/lib/generators/plugin/templates/example/.umirc.js +0 -8
- package/lib/generators/plugin/templates/example/.umirc.ts +0 -8
- package/lib/generators/plugin/templates/example/app.jsx +0 -3
- package/lib/generators/plugin/templates/example/app.tsx +0 -3
- package/lib/generators/plugin/templates/example/package.json +0 -3
- package/lib/generators/plugin/templates/example/pages/index.css +0 -17
- package/lib/generators/plugin/templates/example/pages/index.jsx +0 -8
- package/lib/generators/plugin/templates/example/pages/index.tsx +0 -8
- package/lib/generators/plugin/templates/example/tsconfig.json +0 -37
- package/lib/generators/plugin/templates/example/typing.d.ts +0 -2
- package/lib/generators/plugin/templates/jest.config.js +0 -8
- package/lib/generators/plugin/templates/package.json +0 -65
- package/lib/generators/plugin/templates/src/index.js +0 -26
- package/lib/generators/plugin/templates/src/index.ts +0 -29
- package/lib/generators/plugin/templates/test/fixtures/normal/.umirc.js +0 -4
- package/lib/generators/plugin/templates/test/fixtures/normal/.umirc.ts +0 -4
- package/lib/generators/plugin/templates/test/fixtures/normal/pages/index.css +0 -4
- package/lib/generators/plugin/templates/test/fixtures/normal/pages/index.jsx +0 -10
- package/lib/generators/plugin/templates/test/fixtures/normal/pages/index.tsx +0 -11
- package/lib/generators/plugin/templates/test/fixtures/normal/test.js +0 -10
- package/lib/generators/plugin/templates/test/fixtures/normal/test.ts +0 -10
- package/lib/generators/plugin/templates/test/index.e2e.js +0 -5
- package/lib/generators/plugin/templates/test/index.e2e.ts +0 -5
- package/lib/generators/plugin/templates/tsconfig.json +0 -23
- package/lib/generators/plugin/templates/ui/index.jsx +0 -28
- package/lib/generators/plugin/templates/ui/index.tsx +0 -29
- package/lib/run.js +0 -76
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
# Ant Design Pro
|
|
2
|
-
|
|
3
|
-
This project is initialized with [Ant Design Pro](https://pro.ant.design). Follow is the quick guide for how to use.
|
|
4
|
-
|
|
5
|
-
## Environment Prepare
|
|
6
|
-
|
|
7
|
-
Install `node_modules`:
|
|
8
|
-
|
|
9
|
-
```bash
|
|
10
|
-
npm install
|
|
11
|
-
```
|
|
12
|
-
|
|
13
|
-
or
|
|
14
|
-
|
|
15
|
-
```bash
|
|
16
|
-
yarn
|
|
17
|
-
```
|
|
18
|
-
|
|
19
|
-
## Provided Scripts
|
|
20
|
-
|
|
21
|
-
Ant Design Pro provides some useful script to help you quick start and build with web project, code style check and test.
|
|
22
|
-
|
|
23
|
-
Scripts provided in `package.json`. It's safe to modify or add additional script:
|
|
24
|
-
|
|
25
|
-
### Start project
|
|
26
|
-
|
|
27
|
-
```bash
|
|
28
|
-
npm start
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
### Build project
|
|
32
|
-
|
|
33
|
-
```bash
|
|
34
|
-
npm run build
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
-
### Check code style
|
|
38
|
-
|
|
39
|
-
```bash
|
|
40
|
-
npm run lint
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
You can also use script to auto fix some lint error:
|
|
44
|
-
|
|
45
|
-
```bash
|
|
46
|
-
npm run lint:fix
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
### Test code
|
|
50
|
-
|
|
51
|
-
```bash
|
|
52
|
-
npm test
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
## More
|
|
56
|
-
|
|
57
|
-
You can view full document on our [official website](https://pro.ant.design). And welcome any feedback in our [github](https://github.com/ant-design/ant-design-pro).
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
const filterPkg = (pkgObject, ignoreList) => {
|
|
2
|
-
const devObj = {};
|
|
3
|
-
Object.keys(pkgObject).forEach(key => {
|
|
4
|
-
const isIgnore = ignoreList.some(reg => {
|
|
5
|
-
return new RegExp(reg).test(key);
|
|
6
|
-
});
|
|
7
|
-
if (isIgnore) {
|
|
8
|
-
return;
|
|
9
|
-
}
|
|
10
|
-
devObj[key] = pkgObject[key];
|
|
11
|
-
});
|
|
12
|
-
return devObj;
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
module.exports = filterPkg;
|
|
@@ -1,232 +0,0 @@
|
|
|
1
|
-
const fs = require('fs-extra');
|
|
2
|
-
const path = require('path');
|
|
3
|
-
const chalk = require('chalk');
|
|
4
|
-
const glob = require('glob');
|
|
5
|
-
const exec = require('execa');
|
|
6
|
-
const rimraf = require('rimraf');
|
|
7
|
-
const BasicGenerator = require('../../BasicGenerator');
|
|
8
|
-
const filterPkg = require('./filterPkg');
|
|
9
|
-
const prettier = require('prettier');
|
|
10
|
-
const sylvanas = require('sylvanas');
|
|
11
|
-
const sortPackage = require('sort-package-json');
|
|
12
|
-
const { getFastGithub } = require('umi-utils');
|
|
13
|
-
|
|
14
|
-
function log(...args) {
|
|
15
|
-
console.log(`${chalk.gray('>')}`, ...args);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
function globList(patternList, options) {
|
|
19
|
-
let fileList = [];
|
|
20
|
-
patternList.forEach(pattern => {
|
|
21
|
-
fileList = [...fileList, ...glob.sync(pattern, options)];
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
return fileList;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
const getGithubUrl = async () => {
|
|
28
|
-
const fastGithub = await getFastGithub();
|
|
29
|
-
if (fastGithub === 'gitee.com' || fastGithub === 'github.com.cnpmjs.org') {
|
|
30
|
-
return 'https://gitee.com/ant-design/ant-design-pro';
|
|
31
|
-
}
|
|
32
|
-
return 'https://github.com/ant-design/ant-design-pro';
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
class AntDesignProGenerator extends BasicGenerator {
|
|
36
|
-
prompting() {
|
|
37
|
-
if (this.opts.args.language) {
|
|
38
|
-
this.prompts = {
|
|
39
|
-
language: this.opts.args.language,
|
|
40
|
-
};
|
|
41
|
-
} else {
|
|
42
|
-
const prompts = [
|
|
43
|
-
{
|
|
44
|
-
name: 'nextPro',
|
|
45
|
-
type: 'list',
|
|
46
|
-
choices: ['Pro V5', 'Pro V4'],
|
|
47
|
-
message: '🧙 Be the first to experience the new umi@3 ?',
|
|
48
|
-
default: 'Pro V4',
|
|
49
|
-
when: () => {
|
|
50
|
-
// 为了测试,没有任何用处
|
|
51
|
-
process.send && process.send({ type: 'prompt' });
|
|
52
|
-
process.emit('message', { type: 'prompt' });
|
|
53
|
-
return true;
|
|
54
|
-
},
|
|
55
|
-
},
|
|
56
|
-
{
|
|
57
|
-
name: 'language',
|
|
58
|
-
type: 'list',
|
|
59
|
-
message: '🤓 Which language do you want to use?',
|
|
60
|
-
choices: ['TypeScript', 'JavaScript'],
|
|
61
|
-
default: 'TypeScript',
|
|
62
|
-
when: ({ nextPro }) => {
|
|
63
|
-
process.send && process.send({ type: 'prompt' });
|
|
64
|
-
process.emit('message', { type: 'prompt' });
|
|
65
|
-
return nextPro === 'Pro V4';
|
|
66
|
-
},
|
|
67
|
-
},
|
|
68
|
-
{
|
|
69
|
-
name: 'allBlocks',
|
|
70
|
-
type: 'list',
|
|
71
|
-
message: '🚀 Do you need all the blocks or a simple scaffold?',
|
|
72
|
-
choices: ['simple', 'complete'],
|
|
73
|
-
default: 'simple',
|
|
74
|
-
when: ({ nextPro }) => {
|
|
75
|
-
process.send && process.send({ type: 'prompt' });
|
|
76
|
-
process.emit('message', { type: 'prompt' });
|
|
77
|
-
return nextPro === 'Pro V4';
|
|
78
|
-
},
|
|
79
|
-
},
|
|
80
|
-
{
|
|
81
|
-
name: 'nextAntd',
|
|
82
|
-
type: 'list',
|
|
83
|
-
choices: ['antd@4', 'antd@3'],
|
|
84
|
-
when: ({ allBlocks, nextPro }) => {
|
|
85
|
-
process.send && process.send({ type: 'prompt' });
|
|
86
|
-
process.emit('message', { type: 'prompt' });
|
|
87
|
-
return allBlocks === 'simple' && nextPro === 'Pro V4';
|
|
88
|
-
},
|
|
89
|
-
message: '🦄 Time to use better, faster and latest antd@4!',
|
|
90
|
-
default: 'antd@4',
|
|
91
|
-
},
|
|
92
|
-
];
|
|
93
|
-
return this.prompt(prompts).then(props => {
|
|
94
|
-
this.prompts = props;
|
|
95
|
-
});
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
async writing() {
|
|
100
|
-
const { language = 'TypeScript', allBlocks, nextPro, nextAntd } = this.prompts;
|
|
101
|
-
|
|
102
|
-
const isTypeScript = language === 'TypeScript';
|
|
103
|
-
const projectName = this.opts.name || this.opts.env.cwd;
|
|
104
|
-
const projectPath = path.resolve(projectName);
|
|
105
|
-
|
|
106
|
-
const envOptions = {
|
|
107
|
-
cwd: projectPath,
|
|
108
|
-
};
|
|
109
|
-
|
|
110
|
-
const githubUrl = await getGithubUrl();
|
|
111
|
-
const gitArgs = [`clone`, githubUrl, `--depth=1`];
|
|
112
|
-
|
|
113
|
-
// 如果想要使用旧的 antd,使用 antd@3 分支
|
|
114
|
-
if (nextAntd === 'antd@3' && allBlocks === 'simple') {
|
|
115
|
-
gitArgs.push('--branch', 'antd@3');
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
if (nextPro === 'Pro V5') {
|
|
119
|
-
gitArgs.push('--branch', 'v5');
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
// all-blocks 分支上包含了所有的区块
|
|
123
|
-
if (allBlocks === 'complete') {
|
|
124
|
-
log(`🙈 complete mode can only use the version of antd@4`);
|
|
125
|
-
gitArgs.push('--branch', 'all-blocks');
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
// Set branch if provided
|
|
129
|
-
if (this.opts.args.branch && !nextPro) {
|
|
130
|
-
gitArgs.push('--branch', this.opts.args.branch);
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
gitArgs.push(projectName);
|
|
134
|
-
|
|
135
|
-
// // 没有提供关闭的配置
|
|
136
|
-
// // https://github.com/yeoman/environment/blob/9880bc7d5b26beff9f0b4d5048c672a85ce4bcaa/lib/util/repository.js#L50
|
|
137
|
-
const yoConfigPth = path.join(projectPath, '.yo-repository');
|
|
138
|
-
if (fs.existsSync(yoConfigPth)) {
|
|
139
|
-
// 删除 .yo-repository
|
|
140
|
-
rimraf.sync(yoConfigPth);
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
if (
|
|
144
|
-
fs.existsSync(projectPath) &&
|
|
145
|
-
fs.statSync(projectPath).isDirectory() &&
|
|
146
|
-
fs.readdirSync(projectPath).length > 0
|
|
147
|
-
) {
|
|
148
|
-
console.log('\n');
|
|
149
|
-
console.log(`🙈 请在空文件夹中使用,或者使用 ${chalk.red('yarn create umi myapp')}`);
|
|
150
|
-
console.log(`🙈 Please select an empty folder, or use ${chalk.red('yarn create umi myapp')}`);
|
|
151
|
-
process.exit(1);
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
// Clone remote branch
|
|
155
|
-
// log(`git ${[`clone`, githubUrl].join(' ')}`);
|
|
156
|
-
await exec(
|
|
157
|
-
`git`,
|
|
158
|
-
gitArgs,
|
|
159
|
-
process.env.TEST
|
|
160
|
-
? {}
|
|
161
|
-
: {
|
|
162
|
-
stdout: process.stdout,
|
|
163
|
-
stderr: process.stderr,
|
|
164
|
-
stdin: process.stdin,
|
|
165
|
-
},
|
|
166
|
-
);
|
|
167
|
-
|
|
168
|
-
log(`🚚 clone success`);
|
|
169
|
-
|
|
170
|
-
const packageJsonPath = path.resolve(projectPath, 'package.json');
|
|
171
|
-
const pkg = require(packageJsonPath);
|
|
172
|
-
// Handle js version
|
|
173
|
-
if (!isTypeScript) {
|
|
174
|
-
log('[Sylvanas] Prepare js environment...');
|
|
175
|
-
const tsFiles = globList(['**/*.tsx', '**/*.ts'], {
|
|
176
|
-
...envOptions,
|
|
177
|
-
ignore: ['**/*.d.ts'],
|
|
178
|
-
});
|
|
179
|
-
|
|
180
|
-
sylvanas(tsFiles, {
|
|
181
|
-
...envOptions,
|
|
182
|
-
action: 'overwrite',
|
|
183
|
-
});
|
|
184
|
-
|
|
185
|
-
log('[JS] Clean up...');
|
|
186
|
-
const removeTsFiles = globList(['tsconfig.json', '**/*.d.ts'], envOptions);
|
|
187
|
-
removeTsFiles.forEach(filePath => {
|
|
188
|
-
const targetPath = path.resolve(projectPath, filePath);
|
|
189
|
-
fs.removeSync(targetPath);
|
|
190
|
-
});
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
// copy readme
|
|
194
|
-
const babelConfig = path.resolve(__dirname, 'README.md');
|
|
195
|
-
fs.copySync(babelConfig, path.resolve(projectPath, 'README.md'));
|
|
196
|
-
|
|
197
|
-
// gen package.json
|
|
198
|
-
if (pkg['create-umi']) {
|
|
199
|
-
const { ignoreScript = [], ignoreDependencies = [] } = pkg['create-umi'];
|
|
200
|
-
// filter scripts and devDependencies
|
|
201
|
-
const projectPkg = {
|
|
202
|
-
...pkg,
|
|
203
|
-
scripts: filterPkg(pkg.scripts, ignoreScript),
|
|
204
|
-
devDependencies: filterPkg(pkg.devDependencies, ignoreDependencies),
|
|
205
|
-
};
|
|
206
|
-
// remove create-umi config
|
|
207
|
-
delete projectPkg['create-umi'];
|
|
208
|
-
fs.writeFileSync(
|
|
209
|
-
path.resolve(projectPath, 'package.json'),
|
|
210
|
-
// 删除一个包之后 json会多了一些空行。sortPackage 可以删除掉并且排序
|
|
211
|
-
// prettier 会容忍一个空行
|
|
212
|
-
prettier.format(JSON.stringify(sortPackage(projectPkg)), {
|
|
213
|
-
parser: 'json',
|
|
214
|
-
}),
|
|
215
|
-
);
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
// Clean up useless files
|
|
219
|
-
if (pkg['create-umi'] && pkg['create-umi'].ignore) {
|
|
220
|
-
log('Clean up...');
|
|
221
|
-
const ignoreFiles = pkg['create-umi'].ignore;
|
|
222
|
-
const fileList = globList(ignoreFiles, envOptions);
|
|
223
|
-
|
|
224
|
-
fileList.forEach(filePath => {
|
|
225
|
-
const targetPath = path.resolve(projectPath, filePath);
|
|
226
|
-
fs.removeSync(targetPath);
|
|
227
|
-
});
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
module.exports = AntDesignProGenerator;
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
const debug = require('debug')('create-umi:generator');
|
|
2
|
-
const BasicGenerator = require('../../BasicGenerator');
|
|
3
|
-
|
|
4
|
-
class Generator extends BasicGenerator {
|
|
5
|
-
prompting() {
|
|
6
|
-
if (this.opts.args && 'isTypeScript' in this.opts.args && 'reactFeatures' in this.opts.args) {
|
|
7
|
-
this.prompts = {
|
|
8
|
-
isTypeScript: this.opts.args.isTypeScript,
|
|
9
|
-
reactFeatures: this.opts.args.reactFeatures,
|
|
10
|
-
};
|
|
11
|
-
} else {
|
|
12
|
-
const prompts = [
|
|
13
|
-
{
|
|
14
|
-
name: 'isTypeScript',
|
|
15
|
-
type: 'confirm',
|
|
16
|
-
message: 'Do you want to use typescript?',
|
|
17
|
-
default: false,
|
|
18
|
-
},
|
|
19
|
-
{
|
|
20
|
-
name: 'reactFeatures',
|
|
21
|
-
message: 'What functionality do you want to enable?',
|
|
22
|
-
type: 'checkbox',
|
|
23
|
-
choices: [
|
|
24
|
-
{name: 'antd', value: 'antd'},
|
|
25
|
-
{name: 'dva', value: 'dva'},
|
|
26
|
-
{name: 'code splitting', value: 'dynamicImport'},
|
|
27
|
-
{name: 'dll', value: 'dll'},
|
|
28
|
-
{name: 'internationalization', value: 'locale'},
|
|
29
|
-
],
|
|
30
|
-
},
|
|
31
|
-
];
|
|
32
|
-
return this.prompt(prompts).then(props => {
|
|
33
|
-
this.prompts = props;
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
writing() {
|
|
39
|
-
this.writeFiles({
|
|
40
|
-
context: {
|
|
41
|
-
name: this.name,
|
|
42
|
-
...this.prompts,
|
|
43
|
-
},
|
|
44
|
-
filterFiles: f => {
|
|
45
|
-
const { isTypeScript, reactFeatures } = this.prompts;
|
|
46
|
-
if (isTypeScript) {
|
|
47
|
-
if (f.endsWith('.js')) return false;
|
|
48
|
-
if (!reactFeatures.includes('dva')) {
|
|
49
|
-
if (f.startsWith('src/models') || f === 'src/app.ts') return false;
|
|
50
|
-
}
|
|
51
|
-
if (!reactFeatures.includes('locale')) {
|
|
52
|
-
if (f.startsWith('src/locales') || f.includes('umi-plugin-locale')) return false;
|
|
53
|
-
}
|
|
54
|
-
} else {
|
|
55
|
-
if (this.isTsFile(f)) return false;
|
|
56
|
-
if (!reactFeatures.includes('dva')) {
|
|
57
|
-
if (f.startsWith('src/models') || f === 'src/app.js') return false;
|
|
58
|
-
}
|
|
59
|
-
if (!reactFeatures.includes('locale')) {
|
|
60
|
-
if (f.startsWith('src/locales') || f.includes('umi-plugin-locale')) return false;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
return true;
|
|
64
|
-
},
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
module.exports = Generator;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
# http://editorconfig.org
|
|
2
|
-
root = true
|
|
3
|
-
|
|
4
|
-
[*]
|
|
5
|
-
indent_style = space
|
|
6
|
-
indent_size = 2
|
|
7
|
-
end_of_line = lf
|
|
8
|
-
charset = utf-8
|
|
9
|
-
trim_trailing_whitespace = true
|
|
10
|
-
insert_final_newline = true
|
|
11
|
-
|
|
12
|
-
[*.md]
|
|
13
|
-
trim_trailing_whitespace = false
|
|
14
|
-
|
|
15
|
-
[Makefile]
|
|
16
|
-
indent_style = tab
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
// ref: https://umijs.org/config/
|
|
3
|
-
export default {
|
|
4
|
-
treeShaking: true,
|
|
5
|
-
routes: [
|
|
6
|
-
{
|
|
7
|
-
path: '/',
|
|
8
|
-
component: '../layouts/index',
|
|
9
|
-
routes: [
|
|
10
|
-
{ path: '/', component: '../pages/index' }
|
|
11
|
-
]
|
|
12
|
-
}
|
|
13
|
-
],
|
|
14
|
-
plugins: [
|
|
15
|
-
// ref: https://umijs.org/plugin/umi-plugin-react.html
|
|
16
|
-
['umi-plugin-react', {
|
|
17
|
-
antd: <% if (reactFeatures.includes('antd')) { %>true<% } else { %>false<% } %>,
|
|
18
|
-
dva: <% if (reactFeatures.includes('dva')) { %>true<% } else { %>false<% } %>,
|
|
19
|
-
dynamicImport: <% if (reactFeatures.includes('dynamicImport')) { %>{ webpackChunkName: true }<% } else { %>false<% } %>,
|
|
20
|
-
title: '<%= name %>',
|
|
21
|
-
dll: <% if (reactFeatures.includes('dll')) { %>true<% } else { %>false<% } %>,
|
|
22
|
-
<% if (reactFeatures.includes('locale')) { %>locale: {
|
|
23
|
-
enable: true,
|
|
24
|
-
default: 'en-US',
|
|
25
|
-
},<% } %>
|
|
26
|
-
routes: {
|
|
27
|
-
exclude: [<% if (reactFeatures.includes('dva')) { %>
|
|
28
|
-
/models\//,
|
|
29
|
-
/services\//,
|
|
30
|
-
/model\.(t|j)sx?$/,
|
|
31
|
-
/service\.(t|j)sx?$/,<% } %>
|
|
32
|
-
/components\//,
|
|
33
|
-
],
|
|
34
|
-
},
|
|
35
|
-
}],
|
|
36
|
-
],
|
|
37
|
-
}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { IConfig } from 'umi-types';
|
|
2
|
-
|
|
3
|
-
// ref: https://umijs.org/config/
|
|
4
|
-
const config: IConfig = {
|
|
5
|
-
treeShaking: true,
|
|
6
|
-
routes: [
|
|
7
|
-
{
|
|
8
|
-
path: '/',
|
|
9
|
-
component: '../layouts/index',
|
|
10
|
-
routes: [
|
|
11
|
-
{ path: '/', component: '../pages/index' }
|
|
12
|
-
]
|
|
13
|
-
}
|
|
14
|
-
],
|
|
15
|
-
plugins: [
|
|
16
|
-
// ref: https://umijs.org/plugin/umi-plugin-react.html
|
|
17
|
-
['umi-plugin-react', {
|
|
18
|
-
antd: <% if (reactFeatures.includes('antd')) { %>true<% } else { %>false<% } %>,
|
|
19
|
-
dva: <% if (reactFeatures.includes('dva')) { %>true<% } else { %>false<% } %>,
|
|
20
|
-
dynamicImport: <% if (reactFeatures.includes('dynamicImport')) { %>{ webpackChunkName: true }<% } else { %>false<% } %>,
|
|
21
|
-
title: '<%= name %>',
|
|
22
|
-
dll: <% if (reactFeatures.includes('dll')) { %>true<% } else { %>false<% } %>,
|
|
23
|
-
<% if (reactFeatures.includes('locale')) { %>locale: {
|
|
24
|
-
enable: true,
|
|
25
|
-
default: 'en-US',
|
|
26
|
-
},<% } %>
|
|
27
|
-
routes: {
|
|
28
|
-
exclude: [<% if (reactFeatures.includes('dva')) { %>
|
|
29
|
-
/models\//,
|
|
30
|
-
/services\//,
|
|
31
|
-
/model\.(t|j)sx?$/,
|
|
32
|
-
/service\.(t|j)sx?$/,<% } %>
|
|
33
|
-
/components\//,
|
|
34
|
-
],
|
|
35
|
-
},
|
|
36
|
-
}],
|
|
37
|
-
],
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export default config;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
|
|
2
|
-
|
|
3
|
-
# dependencies
|
|
4
|
-
/node_modules
|
|
5
|
-
/npm-debug.log*
|
|
6
|
-
/yarn-error.log
|
|
7
|
-
/yarn.lock
|
|
8
|
-
/package-lock.json
|
|
9
|
-
|
|
10
|
-
# production
|
|
11
|
-
/dist
|
|
12
|
-
|
|
13
|
-
# misc
|
|
14
|
-
.DS_Store
|
|
15
|
-
|
|
16
|
-
# umi
|
|
17
|
-
.umi
|
|
18
|
-
.umi-production
|
|
File without changes
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"private": true,
|
|
3
|
-
"scripts": {
|
|
4
|
-
"start": "umi dev",
|
|
5
|
-
"build": "umi build",
|
|
6
|
-
"test": "umi test",
|
|
7
|
-
<% if (isTypeScript) { -%>
|
|
8
|
-
"lint": "eslint {src,mock,tests}/**/*.{ts,tsx} --fix",
|
|
9
|
-
<% } -%>
|
|
10
|
-
<% if (!isTypeScript) { -%>
|
|
11
|
-
"lint": "eslint {src,mock,tests}/**/*.{js,jsx} --fix",
|
|
12
|
-
<% } -%>
|
|
13
|
-
"precommit": "lint-staged"
|
|
14
|
-
},
|
|
15
|
-
"dependencies": {
|
|
16
|
-
<% if (reactFeatures.includes('dva')) { -%>
|
|
17
|
-
"dva": "^2.6.0-beta.6",
|
|
18
|
-
<% } -%>
|
|
19
|
-
<% if (reactFeatures.includes('antd')) { -%>
|
|
20
|
-
"antd": "^3.19.5",
|
|
21
|
-
<% } -%>
|
|
22
|
-
"react": "^16.8.6",
|
|
23
|
-
"react-dom": "^16.8.6"
|
|
24
|
-
},
|
|
25
|
-
"devDependencies": {
|
|
26
|
-
<% if (isTypeScript) { -%>
|
|
27
|
-
"@types/jest": "^23.3.12",
|
|
28
|
-
"@types/react": "^16.7.18",
|
|
29
|
-
"@types/react-dom": "^16.0.11",
|
|
30
|
-
"@types/react-test-renderer": "^16.0.3",
|
|
31
|
-
<% } -%>
|
|
32
|
-
"babel-eslint": "^9.0.0",
|
|
33
|
-
"eslint": "^5.4.0",
|
|
34
|
-
"eslint-config-umi": "^1.4.0",
|
|
35
|
-
"eslint-plugin-flowtype": "^2.50.0",
|
|
36
|
-
"eslint-plugin-import": "^2.14.0",
|
|
37
|
-
"eslint-plugin-jsx-a11y": "^5.1.1",
|
|
38
|
-
"eslint-plugin-react": "^7.11.1",
|
|
39
|
-
"husky": "^0.14.3",
|
|
40
|
-
"lint-staged": "^7.2.2",
|
|
41
|
-
"react-test-renderer": "^16.7.0",
|
|
42
|
-
<% if (isTypeScript) { -%>
|
|
43
|
-
"umi": "^2.9.0",
|
|
44
|
-
"umi-plugin-react": "^1.8.0",
|
|
45
|
-
"umi-types": "^0.3.0"
|
|
46
|
-
<% } else { -%>
|
|
47
|
-
"umi": "^2.7.7",
|
|
48
|
-
"umi-plugin-react": "^1.8.4"
|
|
49
|
-
<% } -%>
|
|
50
|
-
},
|
|
51
|
-
"lint-staged": {
|
|
52
|
-
<% if (isTypeScript) { -%>
|
|
53
|
-
"*.{ts,tsx}": ["eslint --fix", "git add"],
|
|
54
|
-
<% } -%>
|
|
55
|
-
"*.{js,jsx}": ["eslint --fix", "git add"]
|
|
56
|
-
},
|
|
57
|
-
"engines": {
|
|
58
|
-
"node": ">=8.0.0"
|
|
59
|
-
}
|
|
60
|
-
}
|
|
Binary file
|
|
Binary file
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import BasicLayout from '..';
|
|
2
|
-
import renderer from 'react-test-renderer';
|
|
3
|
-
|
|
4
|
-
describe('Layout: BasicLayout', () => {
|
|
5
|
-
it('Render correctly', () => {
|
|
6
|
-
const wrapper = renderer.create(<BasicLayout />);
|
|
7
|
-
expect(wrapper.root.children.length).toBe(1);
|
|
8
|
-
const outerLayer = wrapper.root.children[0];
|
|
9
|
-
expect(outerLayer.type).toBe('div');
|
|
10
|
-
const title = outerLayer.children[0];
|
|
11
|
-
expect(title.type).toBe('h1');
|
|
12
|
-
expect(title.children[0]).toBe('Yay! Welcome to umi!');
|
|
13
|
-
});
|
|
14
|
-
});
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import 'jest';
|
|
2
|
-
import BasicLayout from '..';
|
|
3
|
-
import React from 'react';
|
|
4
|
-
import renderer, { ReactTestInstance, ReactTestRenderer } from 'react-test-renderer';
|
|
5
|
-
|
|
6
|
-
describe('Layout: BasicLayout', () => {
|
|
7
|
-
it('Render correctly', () => {
|
|
8
|
-
const wrapper: ReactTestRenderer = renderer.create(<BasicLayout />);
|
|
9
|
-
expect(wrapper.root.children.length).toBe(1);
|
|
10
|
-
const outerLayer = wrapper.root.children[0] as ReactTestInstance;
|
|
11
|
-
expect(outerLayer.type).toBe('div');
|
|
12
|
-
const title = outerLayer.children[0] as ReactTestInstance;
|
|
13
|
-
expect(title.type).toBe('h1');
|
|
14
|
-
expect(title.children[0]).toBe('Yay! Welcome to umi!');
|
|
15
|
-
});
|
|
16
|
-
});
|