create-umi 0.27.0 → 4.0.0-beta.11
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 -89
- 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 +16 -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 -183
- 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/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 -66
- 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,29 +0,0 @@
|
|
|
1
|
-
// ref:
|
|
2
|
-
// - https://umijs.org/plugins/api
|
|
3
|
-
<% if (withUmiUI) { -%>
|
|
4
|
-
import { join } from 'path';
|
|
5
|
-
<% } -%>
|
|
6
|
-
import { IApi } from '@umijs/types';
|
|
7
|
-
|
|
8
|
-
export default function (api: IApi) {
|
|
9
|
-
api.logger.info('use plugin');
|
|
10
|
-
|
|
11
|
-
api.modifyHTML(($) => {
|
|
12
|
-
$('body').prepend(`<h1>hello umi plugin</h1>`);
|
|
13
|
-
return $;
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
<% if (withUmiUI) { -%>
|
|
17
|
-
// @ts-ignore
|
|
18
|
-
api.addUIPlugin(() => join(__dirname, '../dist/index.umd.js'));
|
|
19
|
-
|
|
20
|
-
// @ts-ignore
|
|
21
|
-
api.onUISocket(({ action, failure, success }) => {
|
|
22
|
-
if (action.type === 'org.xiaohuoni.demo.test') {
|
|
23
|
-
success({
|
|
24
|
-
data: 'demo.test',
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
});
|
|
28
|
-
<% } -%>
|
|
29
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "esnext",
|
|
4
|
-
"moduleResolution": "node",
|
|
5
|
-
"jsx": "preserve",
|
|
6
|
-
"allowJs": true,
|
|
7
|
-
"esModuleInterop": true,
|
|
8
|
-
"experimentalDecorators": true,
|
|
9
|
-
"strict": true,
|
|
10
|
-
"forceConsistentCasingInFileNames": true,
|
|
11
|
-
"noImplicitReturns": true,
|
|
12
|
-
"suppressImplicitAnyIndexErrors": true,
|
|
13
|
-
"declaration": true
|
|
14
|
-
},
|
|
15
|
-
"exclude": [
|
|
16
|
-
"node_modules",
|
|
17
|
-
"dist",
|
|
18
|
-
"**/*.spec.ts",
|
|
19
|
-
"lib",
|
|
20
|
-
"fixtures",
|
|
21
|
-
"examples"
|
|
22
|
-
]
|
|
23
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { Button } from 'antd';
|
|
2
|
-
|
|
3
|
-
export default (api) => {
|
|
4
|
-
const { callRemote } = api;
|
|
5
|
-
|
|
6
|
-
function PluginPanel() {
|
|
7
|
-
return (
|
|
8
|
-
<div style={{ padding: 20 }}>
|
|
9
|
-
<Button
|
|
10
|
-
type="primary"
|
|
11
|
-
onClick={async () => {
|
|
12
|
-
const { data } = await callRemote({
|
|
13
|
-
type: 'org.xiaohuoni.demo.test',
|
|
14
|
-
});
|
|
15
|
-
alert(data);
|
|
16
|
-
}}
|
|
17
|
-
>Test</Button>
|
|
18
|
-
</div>
|
|
19
|
-
);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
api.addPanel({
|
|
23
|
-
title: 'demo',
|
|
24
|
-
path: '/demo',
|
|
25
|
-
icon: 'home',
|
|
26
|
-
component: PluginPanel,
|
|
27
|
-
});
|
|
28
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { Button } from 'antd';
|
|
2
|
-
import { IUiApi } from '@umijs/ui-types';
|
|
3
|
-
|
|
4
|
-
export default (api: IUiApi) => {
|
|
5
|
-
const { callRemote } = api;
|
|
6
|
-
|
|
7
|
-
function PluginPanel() {
|
|
8
|
-
return (
|
|
9
|
-
<div style={{ padding: 20 }}>
|
|
10
|
-
<Button
|
|
11
|
-
type="primary"
|
|
12
|
-
onClick={async () => {
|
|
13
|
-
const { data } = await callRemote({
|
|
14
|
-
type: 'org.xiaohuoni.demo.test',
|
|
15
|
-
});
|
|
16
|
-
alert(data);
|
|
17
|
-
}}
|
|
18
|
-
>Test</Button>
|
|
19
|
-
</div>
|
|
20
|
-
);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
api.addPanel({
|
|
24
|
-
title: 'demo',
|
|
25
|
-
path: '/demo',
|
|
26
|
-
icon: 'home',
|
|
27
|
-
component: PluginPanel,
|
|
28
|
-
});
|
|
29
|
-
}
|
package/lib/run.js
DELETED
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
const fs = require('fs');
|
|
2
|
-
const path = require('path');
|
|
3
|
-
const chalk = require('chalk');
|
|
4
|
-
const mkdirp = require('mkdirp');
|
|
5
|
-
const inquirer = require('inquirer');
|
|
6
|
-
const clipboardy = require('clipboardy');
|
|
7
|
-
const yeoman = require('yeoman-environment');
|
|
8
|
-
|
|
9
|
-
const generators = fs
|
|
10
|
-
.readdirSync(`${__dirname}/generators`)
|
|
11
|
-
.filter(f => !f.startsWith('.'))
|
|
12
|
-
.map(f => {
|
|
13
|
-
return {
|
|
14
|
-
name: `${f.padEnd(15)} - ${chalk.gray(require(`./generators/${f}/meta.json`).description)}`,
|
|
15
|
-
value: f,
|
|
16
|
-
short: f,
|
|
17
|
-
};
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
const runGenerator = async (generatorPath, { name = '', cwd = process.cwd(), args = {} }) => {
|
|
21
|
-
return new Promise(resolve => {
|
|
22
|
-
if (name) {
|
|
23
|
-
mkdirp.sync(name);
|
|
24
|
-
cwd = path.join(cwd, name);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
const Generator = require(generatorPath);
|
|
28
|
-
const env = yeoman.createEnv([], {
|
|
29
|
-
cwd,
|
|
30
|
-
});
|
|
31
|
-
const generator = new Generator({
|
|
32
|
-
name,
|
|
33
|
-
env,
|
|
34
|
-
resolved: require.resolve(generatorPath),
|
|
35
|
-
args,
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
return generator.run(() => {
|
|
39
|
-
if (name) {
|
|
40
|
-
if (process.platform !== `linux` || process.env.DISPLAY) {
|
|
41
|
-
clipboardy.writeSync(`cd ${name}`);
|
|
42
|
-
console.log('📋 Copied to clipboard, just use Ctrl+V');
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
console.log('✨ File Generate Done');
|
|
46
|
-
resolve(true);
|
|
47
|
-
});
|
|
48
|
-
});
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
const run = async config => {
|
|
52
|
-
process.send && process.send({ type: 'prompt' });
|
|
53
|
-
process.emit('message', { type: 'prompt' });
|
|
54
|
-
|
|
55
|
-
let { type } = config;
|
|
56
|
-
if (!type) {
|
|
57
|
-
const answers = await inquirer.prompt([
|
|
58
|
-
{
|
|
59
|
-
name: 'type',
|
|
60
|
-
message: 'Select the boilerplate type',
|
|
61
|
-
type: 'list',
|
|
62
|
-
choices: generators,
|
|
63
|
-
},
|
|
64
|
-
]);
|
|
65
|
-
type = answers.type;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
try {
|
|
69
|
-
return runGenerator(`./generators/${type}`, config);
|
|
70
|
-
} catch (e) {
|
|
71
|
-
console.error(chalk.red(`> Generate failed`), e);
|
|
72
|
-
process.exit(1);
|
|
73
|
-
}
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
module.exports = run;
|