create-umi 4.0.51 → 4.0.53
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/index.d.ts +32 -3
- package/dist/index.js +103 -93
- package/package.json +2 -2
- package/templates/max/src/access.ts +1 -1
- package/templates/max/src/app.ts +1 -1
- package/templates/plugin/.fatherrc.ts +5 -5
- package/templates/plugin/.gitignore.tpl +1 -1
- package/templates/plugin/README.md.tpl +5 -14
- package/templates/plugin/package.json.tpl +11 -10
- package/templates/plugin/src/index.ts.tpl +2 -2
- package/templates/plugin/tsconfig.json +19 -0
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,41 @@
|
|
|
1
1
|
import { yParser } from '@umijs/utils';
|
|
2
2
|
interface IArgs extends yParser.Arguments {
|
|
3
3
|
default?: boolean;
|
|
4
|
-
plugin?: boolean;
|
|
5
4
|
git?: boolean;
|
|
6
5
|
install?: boolean;
|
|
7
6
|
}
|
|
8
|
-
|
|
7
|
+
interface ITemplatePluginParams {
|
|
8
|
+
pluginName?: string;
|
|
9
|
+
}
|
|
10
|
+
interface ITemplateParams extends ITemplatePluginParams {
|
|
11
|
+
version: string;
|
|
12
|
+
npmClient: ENpmClient;
|
|
13
|
+
registry: string;
|
|
14
|
+
author: string;
|
|
15
|
+
email: string;
|
|
16
|
+
withHusky: boolean;
|
|
17
|
+
extraNpmrc: string;
|
|
18
|
+
}
|
|
19
|
+
declare enum ENpmClient {
|
|
20
|
+
npm = "npm",
|
|
21
|
+
cnpm = "cnpm",
|
|
22
|
+
tnpm = "tnpm",
|
|
23
|
+
yarn = "yarn",
|
|
24
|
+
pnpm = "pnpm"
|
|
25
|
+
}
|
|
26
|
+
declare enum ETemplate {
|
|
27
|
+
app = "app",
|
|
28
|
+
max = "max",
|
|
29
|
+
vueApp = "vue-app",
|
|
30
|
+
plugin = "plugin"
|
|
31
|
+
}
|
|
32
|
+
export interface IDefaultData extends ITemplateParams {
|
|
33
|
+
appTemplate?: ETemplate;
|
|
34
|
+
}
|
|
35
|
+
interface IGeneratorOpts {
|
|
9
36
|
cwd: string;
|
|
10
37
|
args: IArgs;
|
|
11
|
-
|
|
38
|
+
defaultData?: IDefaultData;
|
|
39
|
+
}
|
|
40
|
+
declare const _default: ({ cwd, args, defaultData, }: IGeneratorOpts) => Promise<void>;
|
|
12
41
|
export default _default;
|
package/dist/index.js
CHANGED
|
@@ -25,122 +25,133 @@ module.exports = __toCommonJS(src_exports);
|
|
|
25
25
|
var import_utils = require("@umijs/utils");
|
|
26
26
|
var import_fs = require("fs");
|
|
27
27
|
var import_path = require("path");
|
|
28
|
-
var
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
author: "
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
28
|
+
var pkg = require("../package");
|
|
29
|
+
var DEFAULT_DATA = {
|
|
30
|
+
pluginName: "umi-plugin-demo",
|
|
31
|
+
email: "i@domain.com",
|
|
32
|
+
author: "umijs",
|
|
33
|
+
version: pkg.version,
|
|
34
|
+
npmClient: "pnpm" /* pnpm */,
|
|
35
|
+
registry: "https://registry.npmjs.com/" /* npm */,
|
|
36
|
+
withHusky: false,
|
|
37
|
+
extraNpmrc: "",
|
|
38
|
+
appTemplate: "app" /* app */
|
|
37
39
|
};
|
|
38
|
-
var src_default = async ({
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
40
|
+
var src_default = async ({
|
|
41
|
+
cwd,
|
|
42
|
+
args,
|
|
43
|
+
defaultData = DEFAULT_DATA
|
|
44
|
+
}) => {
|
|
45
|
+
let [name] = args._;
|
|
46
|
+
let npmClient = "pnpm" /* pnpm */;
|
|
47
|
+
let registry = "https://registry.npmjs.com/" /* npm */;
|
|
48
|
+
let appTemplate = (defaultData == null ? void 0 : defaultData.appTemplate) || "app" /* app */;
|
|
43
49
|
const { username, email } = await (0, import_utils.getGitInfo)();
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
50
|
+
const author = email && username ? `${username} <${email}>` : "";
|
|
51
|
+
let pluginName = `umi-plugin-${name || "demo"}`;
|
|
52
|
+
const { isCancel, text, select, intro, outro } = import_utils.clackPrompts;
|
|
53
|
+
const exitPrompt = () => {
|
|
54
|
+
outro(import_utils.chalk.red("Exit create-umi"));
|
|
55
|
+
process.exit(1);
|
|
56
|
+
};
|
|
57
|
+
const useDefaultData = args.default;
|
|
58
|
+
if (!useDefaultData) {
|
|
59
|
+
intro(import_utils.chalk.bgHex("#19BDD2")(" create-umi "));
|
|
60
|
+
appTemplate = await select({
|
|
61
|
+
message: "Pick Umi App Template",
|
|
62
|
+
options: [
|
|
63
|
+
{ label: "Simple App", value: "app" /* app */ },
|
|
48
64
|
{
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
choices: [
|
|
53
|
-
{ title: "Simple App", value: "app" },
|
|
54
|
-
{ title: "Ant Design Pro", value: "max" },
|
|
55
|
-
{ title: "Vue Simple App", value: "vue-app" }
|
|
56
|
-
],
|
|
57
|
-
initial: 0
|
|
65
|
+
label: "Ant Design Pro",
|
|
66
|
+
value: "max" /* max */,
|
|
67
|
+
hint: "more plugins and ready to use features"
|
|
58
68
|
},
|
|
69
|
+
{ label: "Vue Simple App", value: "vue-app" /* vueApp */ },
|
|
59
70
|
{
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
+
label: "Umi Plugin",
|
|
72
|
+
value: "plugin" /* plugin */,
|
|
73
|
+
hint: "for plugin development"
|
|
74
|
+
}
|
|
75
|
+
],
|
|
76
|
+
initialValue: "app" /* app */
|
|
77
|
+
});
|
|
78
|
+
if (isCancel(appTemplate)) {
|
|
79
|
+
exitPrompt();
|
|
80
|
+
}
|
|
81
|
+
npmClient = await select({
|
|
82
|
+
message: "Pick Npm Client",
|
|
83
|
+
options: [
|
|
84
|
+
{ label: "npm" /* npm */, value: "npm" /* npm */ },
|
|
85
|
+
{ label: "cnpm" /* cnpm */, value: "cnpm" /* cnpm */ },
|
|
86
|
+
{ label: "tnpm" /* tnpm */, value: "tnpm" /* tnpm */ },
|
|
87
|
+
{ label: "yarn" /* yarn */, value: "yarn" /* yarn */ },
|
|
88
|
+
{ label: "pnpm" /* pnpm */, value: "pnpm" /* pnpm */, hint: "recommended" }
|
|
89
|
+
],
|
|
90
|
+
initialValue: "pnpm" /* pnpm */
|
|
91
|
+
});
|
|
92
|
+
if (isCancel(npmClient)) {
|
|
93
|
+
exitPrompt();
|
|
94
|
+
}
|
|
95
|
+
registry = await select({
|
|
96
|
+
message: "Pick Npm Registry",
|
|
97
|
+
options: [
|
|
98
|
+
{
|
|
99
|
+
label: "npm",
|
|
100
|
+
value: "https://registry.npmjs.com/" /* npm */
|
|
71
101
|
},
|
|
72
102
|
{
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
choices: [
|
|
77
|
-
{
|
|
78
|
-
title: "npm",
|
|
79
|
-
value: "https://registry.npmjs.org/",
|
|
80
|
-
selected: true
|
|
81
|
-
},
|
|
82
|
-
{ title: "taobao", value: "https://registry.npmmirror.com" }
|
|
83
|
-
]
|
|
103
|
+
label: "taobao",
|
|
104
|
+
value: "https://registry.npmmirror.com" /* taobao */,
|
|
105
|
+
hint: "recommended for China"
|
|
84
106
|
}
|
|
85
107
|
],
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
108
|
+
initialValue: "https://registry.npmjs.com/" /* npm */
|
|
109
|
+
});
|
|
110
|
+
if (isCancel(registry)) {
|
|
111
|
+
exitPrompt();
|
|
112
|
+
}
|
|
113
|
+
const isPlugin = appTemplate === "plugin" /* plugin */;
|
|
114
|
+
if (isPlugin) {
|
|
115
|
+
pluginName = await text({
|
|
116
|
+
message: `What's the plugin name?`,
|
|
117
|
+
placeholder: pluginName,
|
|
118
|
+
validate: (value) => {
|
|
119
|
+
if (!(value == null ? void 0 : value.length)) {
|
|
120
|
+
return "Please input plugin name";
|
|
121
|
+
}
|
|
89
122
|
}
|
|
123
|
+
});
|
|
124
|
+
if (isCancel(pluginName)) {
|
|
125
|
+
exitPrompt();
|
|
90
126
|
}
|
|
91
|
-
);
|
|
92
|
-
npmClient = response.npmClient;
|
|
93
|
-
registry = response.registry;
|
|
94
|
-
appTemplate = response.appTemplate;
|
|
95
|
-
}
|
|
96
|
-
const pluginPrompts = [
|
|
97
|
-
{
|
|
98
|
-
name: "name",
|
|
99
|
-
type: "text",
|
|
100
|
-
message: `What's the plugin name?`,
|
|
101
|
-
default: name
|
|
102
|
-
},
|
|
103
|
-
{
|
|
104
|
-
name: "description",
|
|
105
|
-
type: "text",
|
|
106
|
-
message: `What's your plugin used for?`
|
|
107
|
-
},
|
|
108
|
-
{
|
|
109
|
-
name: "mail",
|
|
110
|
-
type: "text",
|
|
111
|
-
message: `What's your email?`
|
|
112
|
-
},
|
|
113
|
-
{
|
|
114
|
-
name: "author",
|
|
115
|
-
type: "text",
|
|
116
|
-
message: `What's your name?`
|
|
117
|
-
},
|
|
118
|
-
{
|
|
119
|
-
name: "org",
|
|
120
|
-
type: "text",
|
|
121
|
-
message: `Which organization is your plugin stored under github?`
|
|
122
127
|
}
|
|
123
|
-
|
|
128
|
+
outro(import_utils.chalk.green(`You're all set!`));
|
|
129
|
+
}
|
|
124
130
|
const target = name ? (0, import_path.join)(cwd, name) : cwd;
|
|
125
|
-
const
|
|
126
|
-
const version = require("../package").version;
|
|
131
|
+
const version = pkg.version;
|
|
127
132
|
const monorepoRoot = await detectMonorepoRoot({ target });
|
|
128
133
|
const inMonorepo = !!monorepoRoot;
|
|
129
134
|
const projectRoot = inMonorepo ? monorepoRoot : target;
|
|
130
135
|
const shouldInitGit = args.git !== false;
|
|
131
136
|
const withHusky = shouldInitGit && !inMonorepo;
|
|
137
|
+
const isPnpm = npmClient === "pnpm" /* pnpm */;
|
|
132
138
|
const generator = new import_utils.BaseGenerator({
|
|
133
|
-
path: (0, import_path.join)(__dirname, "..", "templates",
|
|
139
|
+
path: (0, import_path.join)(__dirname, "..", "templates", appTemplate),
|
|
134
140
|
target,
|
|
135
|
-
|
|
141
|
+
slient: true,
|
|
142
|
+
data: useDefaultData ? defaultData : {
|
|
136
143
|
version: version.includes("-canary.") ? version : `^${version}`,
|
|
137
144
|
npmClient,
|
|
138
145
|
registry,
|
|
139
146
|
author,
|
|
147
|
+
email,
|
|
140
148
|
withHusky,
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
149
|
+
// suppress pnpm v7 warning
|
|
150
|
+
// No need when `pnpm` > v7.13.5 , but we are forward compatible
|
|
151
|
+
// https://pnpm.io/npmrc#strict-peer-dependencies
|
|
152
|
+
extraNpmrc: isPnpm ? `strict-peer-dependencies=false` : "",
|
|
153
|
+
pluginName
|
|
154
|
+
}
|
|
144
155
|
});
|
|
145
156
|
await generator.run();
|
|
146
157
|
const context = {
|
|
@@ -159,7 +170,7 @@ var src_default = async ({ cwd, args }) => {
|
|
|
159
170
|
} else {
|
|
160
171
|
import_utils.logger.info(`Skip Git init`);
|
|
161
172
|
}
|
|
162
|
-
if (!
|
|
173
|
+
if (!useDefaultData && args.install !== false) {
|
|
163
174
|
(0, import_utils.installWithNpmClient)({ npmClient, cwd: target });
|
|
164
175
|
} else {
|
|
165
176
|
import_utils.logger.info(`Skip install deps`);
|
|
@@ -196,7 +207,6 @@ async function initGit(opts) {
|
|
|
196
207
|
return;
|
|
197
208
|
try {
|
|
198
209
|
await import_utils.execa.execa("git", ["init"], { cwd: projectRoot });
|
|
199
|
-
import_utils.logger.ready(`Git initialized successfully`);
|
|
200
210
|
} catch {
|
|
201
211
|
import_utils.logger.error(`Initial the git repo failed`);
|
|
202
212
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-umi",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.53",
|
|
4
4
|
"description": "create-umi",
|
|
5
5
|
"homepage": "https://github.com/umijs/umi/tree/master/packages/create-umi#readme",
|
|
6
6
|
"bugs": "https://github.com/umijs/umi/issues",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"test": "umi-scripts jest-turbo"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@umijs/utils": "4.0.
|
|
28
|
+
"@umijs/utils": "4.0.53"
|
|
29
29
|
},
|
|
30
30
|
"publishConfig": {
|
|
31
31
|
"access": "public"
|
package/templates/max/src/app.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// 运行时配置
|
|
2
2
|
|
|
3
3
|
// 全局初始化数据配置,用于 Layout 用户信息和权限初始化
|
|
4
|
-
// 更多信息见文档:https://
|
|
4
|
+
// 更多信息见文档:https://umijs.org/docs/api/runtime-config#getinitialstate
|
|
5
5
|
export async function getInitialState(): Promise<{ name: string }> {
|
|
6
6
|
return { name: '@umijs/max' };
|
|
7
7
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
};
|
|
1
|
+
import { defineConfig } from 'father';
|
|
2
|
+
|
|
3
|
+
export default defineConfig({
|
|
4
|
+
cjs: {},
|
|
5
|
+
});
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
node_modules
|
|
2
|
-
|
|
2
|
+
/dist
|
|
@@ -1,30 +1,21 @@
|
|
|
1
|
-
# {{{
|
|
1
|
+
# {{{ pluginName }}}
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
[](https://npmjs.org/package/{{{ name }}})
|
|
5
|
-
|
|
6
|
-
{{{ description }}}
|
|
3
|
+
A umi plugin
|
|
7
4
|
|
|
8
5
|
## Install
|
|
9
6
|
|
|
10
7
|
```bash
|
|
11
|
-
|
|
12
|
-
$ npm install
|
|
13
|
-
```
|
|
14
|
-
|
|
15
|
-
```bash
|
|
16
|
-
$ npm run build --watch
|
|
17
|
-
$ npm run start
|
|
8
|
+
pnpm i {{{ pluginName }}}
|
|
18
9
|
```
|
|
19
10
|
|
|
20
11
|
## Usage
|
|
21
12
|
|
|
22
|
-
Configure in `.umirc.
|
|
13
|
+
Configure in `.umirc.ts`,
|
|
23
14
|
|
|
24
15
|
```js
|
|
25
16
|
export default {
|
|
26
17
|
plugins: [
|
|
27
|
-
['{{{
|
|
18
|
+
['{{{ pluginName }}}'],
|
|
28
19
|
],
|
|
29
20
|
}
|
|
30
21
|
```
|
|
@@ -1,25 +1,26 @@
|
|
|
1
1
|
{
|
|
2
|
-
"name": "{{{
|
|
2
|
+
"name": "{{{ pluginName }}}",
|
|
3
3
|
"author": "{{{ author }}}",
|
|
4
4
|
"version": "0.0.1",
|
|
5
|
-
"
|
|
6
|
-
"
|
|
7
|
-
"types": "lib/index.d.ts",
|
|
5
|
+
"main": "dist/cjs/index.js",
|
|
6
|
+
"types": "dist/cjs/index.d.ts",
|
|
8
7
|
"scripts": {
|
|
9
|
-
"
|
|
8
|
+
"dev": "father dev",
|
|
9
|
+
"build": "father build"
|
|
10
10
|
},
|
|
11
11
|
"keywords": [],
|
|
12
|
-
"repository": "{{{ org }}}/{{{ name }}}",
|
|
13
12
|
"authors": {
|
|
14
13
|
"name": "{{{ author }}}",
|
|
15
|
-
"email": "{{{
|
|
14
|
+
"email": "{{{ email }}}"
|
|
16
15
|
},
|
|
17
16
|
"license": "MIT",
|
|
18
17
|
"files": [
|
|
19
|
-
"
|
|
18
|
+
"dist"
|
|
20
19
|
],
|
|
21
20
|
"devDependencies": {
|
|
22
|
-
"
|
|
23
|
-
"
|
|
21
|
+
"father": "^4.0.0",
|
|
22
|
+
"umi": "{{{ version }}}",
|
|
23
|
+
"@types/node": "^18.0.0",
|
|
24
|
+
"typescript": "^4.0.0"
|
|
24
25
|
}
|
|
25
26
|
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "es2019",
|
|
4
|
+
"lib": ["dom", "dom.iterable", "esnext"],
|
|
5
|
+
"allowJs": true,
|
|
6
|
+
"skipLibCheck": true,
|
|
7
|
+
"esModuleInterop": true,
|
|
8
|
+
"allowSyntheticDefaultImports": true,
|
|
9
|
+
"strict": true,
|
|
10
|
+
"forceConsistentCasingInFileNames": true,
|
|
11
|
+
"noFallthroughCasesInSwitch": true,
|
|
12
|
+
"module": "commonjs",
|
|
13
|
+
"moduleResolution": "node",
|
|
14
|
+
"resolveJsonModule": true,
|
|
15
|
+
"isolatedModules": false,
|
|
16
|
+
"noEmit": false,
|
|
17
|
+
"declaration": true
|
|
18
|
+
}
|
|
19
|
+
}
|