umi 4.0.0-rc.10 → 4.0.0-rc.13
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/client/client/plugin.js +128 -60
- package/client/client/utils.js +4 -3
- package/dist/cli/node.js +2 -2
- package/dist/constants.d.ts +0 -1
- package/dist/constants.js +1 -2
- package/dist/pluginUtils.d.ts +3 -0
- package/dist/pluginUtils.js +8 -0
- package/eslint.js +7 -0
- package/package.json +13 -8
- package/stylelint.js +7 -0
package/client/client/plugin.js
CHANGED
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
1
12
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
13
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
14
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -7,6 +18,33 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
18
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
19
|
});
|
|
9
20
|
};
|
|
21
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
22
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
23
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
24
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
25
|
+
function step(op) {
|
|
26
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
27
|
+
while (_) try {
|
|
28
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
29
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
30
|
+
switch (op[0]) {
|
|
31
|
+
case 0: case 1: t = op; break;
|
|
32
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
33
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
34
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
35
|
+
default:
|
|
36
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
37
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
38
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
39
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
40
|
+
if (t[2]) _.ops.pop();
|
|
41
|
+
_.trys.pop(); continue;
|
|
42
|
+
}
|
|
43
|
+
op = body.call(thisArg, _);
|
|
44
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
45
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
46
|
+
}
|
|
47
|
+
};
|
|
10
48
|
import { assert, compose, isPromiseLike } from './utils';
|
|
11
49
|
export var ApplyPluginsType;
|
|
12
50
|
(function (ApplyPluginsType) {
|
|
@@ -14,27 +52,29 @@ export var ApplyPluginsType;
|
|
|
14
52
|
ApplyPluginsType["modify"] = "modify";
|
|
15
53
|
ApplyPluginsType["event"] = "event";
|
|
16
54
|
})(ApplyPluginsType || (ApplyPluginsType = {}));
|
|
17
|
-
|
|
18
|
-
|
|
55
|
+
var PluginManager = /** @class */ (function () {
|
|
56
|
+
function PluginManager(opts) {
|
|
19
57
|
this.hooks = {};
|
|
20
58
|
this.opts = opts;
|
|
21
59
|
}
|
|
22
|
-
register(plugin) {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
60
|
+
PluginManager.prototype.register = function (plugin) {
|
|
61
|
+
var _this = this;
|
|
62
|
+
assert(plugin.apply && plugin.path, "plugin register failed, apply and path must supplied");
|
|
63
|
+
Object.keys(plugin.apply).forEach(function (key) {
|
|
64
|
+
assert(_this.opts.validKeys.indexOf(key) > -1, "register failed, invalid key ".concat(key, " from plugin ").concat(plugin.path, "."));
|
|
65
|
+
_this.hooks[key] = (_this.hooks[key] || []).concat(plugin.apply[key]);
|
|
27
66
|
});
|
|
28
|
-
}
|
|
29
|
-
getHooks(keyWithDot) {
|
|
30
|
-
|
|
31
|
-
|
|
67
|
+
};
|
|
68
|
+
PluginManager.prototype.getHooks = function (keyWithDot) {
|
|
69
|
+
var _a = keyWithDot.split('.'), key = _a[0], memberKeys = _a.slice(1);
|
|
70
|
+
var hooks = this.hooks[key] || [];
|
|
32
71
|
if (memberKeys.length) {
|
|
33
72
|
hooks = hooks
|
|
34
|
-
.map((hook)
|
|
73
|
+
.map(function (hook) {
|
|
35
74
|
try {
|
|
36
|
-
|
|
37
|
-
for (
|
|
75
|
+
var ret = hook;
|
|
76
|
+
for (var _i = 0, memberKeys_1 = memberKeys; _i < memberKeys_1.length; _i++) {
|
|
77
|
+
var memberKey = memberKeys_1[_i];
|
|
38
78
|
ret = ret[memberKey];
|
|
39
79
|
}
|
|
40
80
|
return ret;
|
|
@@ -46,84 +86,112 @@ export class PluginManager {
|
|
|
46
86
|
.filter(Boolean);
|
|
47
87
|
}
|
|
48
88
|
return hooks;
|
|
49
|
-
}
|
|
50
|
-
applyPlugins
|
|
51
|
-
|
|
89
|
+
};
|
|
90
|
+
PluginManager.prototype.applyPlugins = function (_a) {
|
|
91
|
+
var _this = this;
|
|
92
|
+
var key = _a.key, type = _a.type, initialValue = _a.initialValue, args = _a.args, async = _a.async;
|
|
93
|
+
var hooks = this.getHooks(key) || [];
|
|
52
94
|
if (args) {
|
|
53
|
-
assert(typeof args === 'object',
|
|
95
|
+
assert(typeof args === 'object', "applyPlugins failed, args must be plain object.");
|
|
54
96
|
}
|
|
55
97
|
if (async) {
|
|
56
|
-
assert(type === ApplyPluginsType.modify || type === ApplyPluginsType.event,
|
|
98
|
+
assert(type === ApplyPluginsType.modify || type === ApplyPluginsType.event, "async only works with modify and event type.");
|
|
57
99
|
}
|
|
58
100
|
switch (type) {
|
|
59
101
|
case ApplyPluginsType.modify:
|
|
60
102
|
if (async) {
|
|
61
|
-
return hooks.reduce((memo, hook)
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
103
|
+
return hooks.reduce(function (memo, hook) { return __awaiter(_this, void 0, void 0, function () {
|
|
104
|
+
var ret;
|
|
105
|
+
return __generator(this, function (_a) {
|
|
106
|
+
switch (_a.label) {
|
|
107
|
+
case 0:
|
|
108
|
+
assert(typeof hook === 'function' ||
|
|
109
|
+
typeof hook === 'object' ||
|
|
110
|
+
isPromiseLike(hook), "applyPlugins failed, all hooks for key ".concat(key, " must be function, plain object or Promise."));
|
|
111
|
+
if (!isPromiseLike(memo)) return [3 /*break*/, 2];
|
|
112
|
+
return [4 /*yield*/, memo];
|
|
113
|
+
case 1:
|
|
114
|
+
memo = _a.sent();
|
|
115
|
+
_a.label = 2;
|
|
116
|
+
case 2:
|
|
117
|
+
if (!(typeof hook === 'function')) return [3 /*break*/, 6];
|
|
118
|
+
ret = hook(memo, args);
|
|
119
|
+
if (!isPromiseLike(ret)) return [3 /*break*/, 4];
|
|
120
|
+
return [4 /*yield*/, ret];
|
|
121
|
+
case 3: return [2 /*return*/, _a.sent()];
|
|
122
|
+
case 4: return [2 /*return*/, ret];
|
|
123
|
+
case 5: return [3 /*break*/, 9];
|
|
124
|
+
case 6:
|
|
125
|
+
if (!isPromiseLike(hook)) return [3 /*break*/, 8];
|
|
126
|
+
return [4 /*yield*/, hook];
|
|
127
|
+
case 7:
|
|
128
|
+
hook = _a.sent();
|
|
129
|
+
_a.label = 8;
|
|
130
|
+
case 8: return [2 /*return*/, __assign(__assign({}, memo), hook)];
|
|
131
|
+
case 9: return [2 /*return*/];
|
|
72
132
|
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
else {
|
|
78
|
-
if (isPromiseLike(hook)) {
|
|
79
|
-
hook = yield hook;
|
|
80
|
-
}
|
|
81
|
-
return Object.assign(Object.assign({}, memo), hook);
|
|
82
|
-
}
|
|
83
|
-
}), isPromiseLike(initialValue)
|
|
133
|
+
});
|
|
134
|
+
}); }, isPromiseLike(initialValue)
|
|
84
135
|
? initialValue
|
|
85
136
|
: Promise.resolve(initialValue));
|
|
86
137
|
}
|
|
87
138
|
else {
|
|
88
|
-
return hooks.reduce((memo, hook)
|
|
89
|
-
assert(typeof hook === 'function' || typeof hook === 'object',
|
|
139
|
+
return hooks.reduce(function (memo, hook) {
|
|
140
|
+
assert(typeof hook === 'function' || typeof hook === 'object', "applyPlugins failed, all hooks for key ".concat(key, " must be function or plain object."));
|
|
90
141
|
if (typeof hook === 'function') {
|
|
91
142
|
return hook(memo, args);
|
|
92
143
|
}
|
|
93
144
|
else {
|
|
94
145
|
// TODO: deepmerge?
|
|
95
|
-
return
|
|
146
|
+
return __assign(__assign({}, memo), hook);
|
|
96
147
|
}
|
|
97
148
|
}, initialValue);
|
|
98
149
|
}
|
|
99
150
|
case ApplyPluginsType.event:
|
|
100
|
-
return (()
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
151
|
+
return (function () { return __awaiter(_this, void 0, void 0, function () {
|
|
152
|
+
var _i, hooks_1, hook, ret;
|
|
153
|
+
return __generator(this, function (_a) {
|
|
154
|
+
switch (_a.label) {
|
|
155
|
+
case 0:
|
|
156
|
+
_i = 0, hooks_1 = hooks;
|
|
157
|
+
_a.label = 1;
|
|
158
|
+
case 1:
|
|
159
|
+
if (!(_i < hooks_1.length)) return [3 /*break*/, 4];
|
|
160
|
+
hook = hooks_1[_i];
|
|
161
|
+
assert(typeof hook === 'function', "applyPlugins failed, all hooks for key ".concat(key, " must be function."));
|
|
162
|
+
ret = hook(args);
|
|
163
|
+
if (!(async && isPromiseLike(ret))) return [3 /*break*/, 3];
|
|
164
|
+
return [4 /*yield*/, ret];
|
|
165
|
+
case 2:
|
|
166
|
+
_a.sent();
|
|
167
|
+
_a.label = 3;
|
|
168
|
+
case 3:
|
|
169
|
+
_i++;
|
|
170
|
+
return [3 /*break*/, 1];
|
|
171
|
+
case 4: return [2 /*return*/];
|
|
106
172
|
}
|
|
107
|
-
}
|
|
108
|
-
}))();
|
|
173
|
+
});
|
|
174
|
+
}); })();
|
|
109
175
|
case ApplyPluginsType.compose:
|
|
110
|
-
return ()
|
|
176
|
+
return function () {
|
|
111
177
|
return compose({
|
|
112
178
|
fns: hooks.concat(initialValue),
|
|
113
|
-
args,
|
|
179
|
+
args: args,
|
|
114
180
|
})();
|
|
115
181
|
};
|
|
116
182
|
}
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
|
|
183
|
+
};
|
|
184
|
+
PluginManager.create = function (opts) {
|
|
185
|
+
var pluginManager = new PluginManager({
|
|
120
186
|
validKeys: opts.validKeys,
|
|
121
187
|
});
|
|
122
|
-
opts.plugins.forEach((plugin)
|
|
188
|
+
opts.plugins.forEach(function (plugin) {
|
|
123
189
|
pluginManager.register(plugin);
|
|
124
190
|
});
|
|
125
191
|
return pluginManager;
|
|
126
|
-
}
|
|
127
|
-
|
|
192
|
+
};
|
|
193
|
+
return PluginManager;
|
|
194
|
+
}());
|
|
195
|
+
export { PluginManager };
|
|
128
196
|
// plugins meta info (in tmp file)
|
|
129
197
|
// hooks api: usePlugin
|
package/client/client/utils.js
CHANGED
|
@@ -2,12 +2,13 @@ export function assert(value, message) {
|
|
|
2
2
|
if (!value)
|
|
3
3
|
throw new Error(message);
|
|
4
4
|
}
|
|
5
|
-
export function compose(
|
|
5
|
+
export function compose(_a) {
|
|
6
|
+
var fns = _a.fns, args = _a.args;
|
|
6
7
|
if (fns.length === 1) {
|
|
7
8
|
return fns[0];
|
|
8
9
|
}
|
|
9
|
-
|
|
10
|
-
return fns.reduce((a, b)
|
|
10
|
+
var last = fns.pop();
|
|
11
|
+
return fns.reduce(function (a, b) { return function () { return b(a, args); }; }, last);
|
|
11
12
|
}
|
|
12
13
|
export function isPromiseLike(obj) {
|
|
13
14
|
return !!obj && typeof obj === 'object' && typeof obj.then === 'function';
|
package/dist/cli/node.js
CHANGED
|
@@ -5,8 +5,8 @@ const utils_1 = require("@umijs/utils");
|
|
|
5
5
|
const constants_1 = require("../constants");
|
|
6
6
|
function checkVersion() {
|
|
7
7
|
const v = parseInt(process.version.slice(1));
|
|
8
|
-
if (v < constants_1.MIN_NODE_VERSION || v ===
|
|
9
|
-
utils_1.logger.error(`Your node version ${v} is not supported, please upgrade to ${constants_1.MIN_NODE_VERSION} or above except
|
|
8
|
+
if (v < constants_1.MIN_NODE_VERSION || v === 15 || v === 17) {
|
|
9
|
+
utils_1.logger.error(`Your node version ${v} is not supported, please upgrade to ${constants_1.MIN_NODE_VERSION} or above except 15 or 17.`);
|
|
10
10
|
process.exit(1);
|
|
11
11
|
}
|
|
12
12
|
}
|
package/dist/constants.d.ts
CHANGED
package/dist/constants.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.FRAMEWORK_NAME = exports.DEFAULT_CONFIG_FILES = exports.DEV_COMMAND = exports.
|
|
3
|
+
exports.FRAMEWORK_NAME = exports.DEFAULT_CONFIG_FILES = exports.DEV_COMMAND = exports.MIN_NODE_VERSION = void 0;
|
|
4
4
|
exports.MIN_NODE_VERSION = 14;
|
|
5
|
-
exports.EXCLUDE_NODE_VERSION = 15;
|
|
6
5
|
exports.DEV_COMMAND = 'dev';
|
|
7
6
|
exports.DEFAULT_CONFIG_FILES = [
|
|
8
7
|
'.umirc.ts',
|
package/dist/pluginUtils.d.ts
CHANGED
package/dist/pluginUtils.js
CHANGED
|
@@ -13,5 +13,13 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
|
|
|
13
13
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
17
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
|
+
};
|
|
16
19
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
+
exports.express = exports.httpProxyMiddleware = void 0;
|
|
21
|
+
const express_1 = __importDefault(require("@umijs/bundler-utils/compiled/express"));
|
|
22
|
+
exports.express = express_1.default;
|
|
23
|
+
const http_proxy_middleware_1 = __importDefault(require("@umijs/bundler-webpack/compiled/http-proxy-middleware"));
|
|
24
|
+
exports.httpProxyMiddleware = http_proxy_middleware_1.default;
|
|
17
25
|
__exportStar(require("@umijs/utils"), exports);
|
package/eslint.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
try {
|
|
2
|
+
require.resolve('@umijs/lint/package.json');
|
|
3
|
+
} catch (err) {
|
|
4
|
+
throw new Error('@umijs/lint is not built-in, please install it manually before run umi lint.');
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
module.exports = process.env.LEGACY_ESLINT ? require('@umijs/lint/dist/config/eslint/legacy') : require('@umijs/lint/dist/config/eslint');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "umi",
|
|
3
|
-
"version": "4.0.0-rc.
|
|
3
|
+
"version": "4.0.0-rc.13",
|
|
4
4
|
"description": "umi",
|
|
5
5
|
"homepage": "https://github.com/umijs/umi-next/tree/master/packages/umi#readme",
|
|
6
6
|
"bugs": "https://github.com/umijs/umi-next/issues",
|
|
@@ -25,7 +25,9 @@
|
|
|
25
25
|
"plugin-utils.js",
|
|
26
26
|
"prettier.js",
|
|
27
27
|
"test.d.ts",
|
|
28
|
-
"test.js"
|
|
28
|
+
"test.js",
|
|
29
|
+
"eslint.js",
|
|
30
|
+
"stylelint.js"
|
|
29
31
|
],
|
|
30
32
|
"scripts": {
|
|
31
33
|
"build": "pnpm tsc",
|
|
@@ -35,13 +37,16 @@
|
|
|
35
37
|
"test": "jest -c ../../jest.turbo.config.ts"
|
|
36
38
|
},
|
|
37
39
|
"dependencies": {
|
|
38
|
-
"@umijs/
|
|
39
|
-
"@umijs/
|
|
40
|
-
"@umijs/
|
|
41
|
-
"@umijs/
|
|
42
|
-
"@umijs/
|
|
40
|
+
"@umijs/bundler-utils": "4.0.0-rc.13",
|
|
41
|
+
"@umijs/bundler-webpack": "4.0.0-rc.13",
|
|
42
|
+
"@umijs/core": "4.0.0-rc.13",
|
|
43
|
+
"@umijs/lint": "4.0.0-rc.13",
|
|
44
|
+
"@umijs/preset-umi": "4.0.0-rc.13",
|
|
45
|
+
"@umijs/renderer-react": "4.0.0-rc.13",
|
|
46
|
+
"@umijs/test": "4.0.0-rc.13",
|
|
47
|
+
"@umijs/utils": "4.0.0-rc.13",
|
|
43
48
|
"prettier-plugin-organize-imports": "^2.3.4",
|
|
44
|
-
"prettier-plugin-packagejson": "^2.2.
|
|
49
|
+
"prettier-plugin-packagejson": "^2.2.17"
|
|
45
50
|
},
|
|
46
51
|
"engines": {
|
|
47
52
|
"node": ">=14"
|