umi 4.0.0-beta.9 → 4.0.0-canary-20240513.3
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/LICENSE +21 -0
- package/bin/forkedDev.js +1 -1
- package/bin/umi.js +20 -1
- package/client/client/plugin.js +213 -116
- package/client/client/utils.js +16 -10
- package/dist/cli/cli.js +68 -56
- package/dist/cli/dev.js +49 -23
- package/dist/cli/fork.js +86 -36
- package/dist/cli/forkedDev.js +35 -50
- package/dist/constants.d.ts +2 -2
- package/dist/constants.js +45 -12
- package/dist/defineConfig.d.ts +10 -0
- package/dist/defineConfig.js +31 -0
- package/dist/defineMock.d.ts +8 -0
- package/dist/defineMock.js +31 -0
- package/dist/index.d.ts +5 -3
- package/dist/index.js +39 -26
- package/dist/pluginUtils.d.ts +5 -0
- package/dist/pluginUtils.js +48 -0
- package/dist/service/cwd.js +35 -11
- package/dist/service/requireHook.d.ts +1 -0
- package/dist/service/requireHook.js +14 -0
- package/dist/service/service.js +69 -40
- package/dist/test-setup.d.ts +1 -0
- package/dist/test-setup.js +3 -0
- package/dist/test.d.ts +119 -0
- package/dist/test.js +82 -0
- package/eslint.js +7 -0
- package/index.d.ts +10 -3
- package/package.json +38 -20
- package/plugin-utils.d.ts +1 -0
- package/plugin-utils.js +1 -0
- package/plugin.js +1 -0
- package/prettier.js +13 -0
- package/stylelint.js +7 -0
- package/test-setup.js +1 -0
- package/test.d.ts +1 -0
- package/test.js +1 -0
- package/dist/cli/node.d.ts +0 -4
- package/dist/cli/node.js +0 -32
- package/dist/client/plugin.d.ts +0 -34
- package/dist/client/plugin.js +0 -125
- package/dist/client/utils.d.ts +0 -6
- package/dist/client/utils.js +0 -20
- package/index.esm.js +0 -2
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2017-present ChenCheng (sorrycc@gmail.com)
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
package/bin/forkedDev.js
CHANGED
package/bin/umi.js
CHANGED
|
@@ -1,6 +1,25 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
// disable since it's conflicted with typescript cjs + dynamic import
|
|
4
|
+
// require('v8-compile-cache');
|
|
5
|
+
|
|
6
|
+
// patch console for debug
|
|
7
|
+
// ref: https://remysharp.com/2014/05/23/where-is-that-console-log
|
|
8
|
+
if (process.env.DEBUG_CONSOLE) {
|
|
9
|
+
['log', 'warn', 'error'].forEach((method) => {
|
|
10
|
+
const old = console[method];
|
|
11
|
+
console[method] = function () {
|
|
12
|
+
let stack = new Error().stack.split(/\n/);
|
|
13
|
+
// Chrome includes a single "Error" line, FF doesn't.
|
|
14
|
+
if (stack[0].indexOf('Error') === 0) {
|
|
15
|
+
stack = stack.slice(1);
|
|
16
|
+
}
|
|
17
|
+
const args = [].slice.apply(arguments).concat([stack[1].trim()]);
|
|
18
|
+
return old.apply(console, args);
|
|
19
|
+
};
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
|
|
4
23
|
require('../dist/cli/cli')
|
|
5
24
|
.run()
|
|
6
25
|
.catch((e) => {
|
package/client/client/plugin.js
CHANGED
|
@@ -1,121 +1,218 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
import { assert, compose, isPromiseLike } from
|
|
11
|
-
export var ApplyPluginsType
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
17
|
-
export
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
1
|
+
import _regeneratorRuntime from "@babel/runtime/helpers/esm/regeneratorRuntime";
|
|
2
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
3
|
+
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
4
|
+
import _typeof from "@babel/runtime/helpers/esm/typeof";
|
|
5
|
+
import _createForOfIteratorHelper from "@babel/runtime/helpers/esm/createForOfIteratorHelper";
|
|
6
|
+
import _toArray from "@babel/runtime/helpers/esm/toArray";
|
|
7
|
+
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
8
|
+
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
9
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
10
|
+
import { assert, compose, isPromiseLike } from "./utils";
|
|
11
|
+
export var ApplyPluginsType = /*#__PURE__*/function (ApplyPluginsType) {
|
|
12
|
+
ApplyPluginsType["compose"] = "compose";
|
|
13
|
+
ApplyPluginsType["modify"] = "modify";
|
|
14
|
+
ApplyPluginsType["event"] = "event";
|
|
15
|
+
return ApplyPluginsType;
|
|
16
|
+
}({});
|
|
17
|
+
export var PluginManager = /*#__PURE__*/function () {
|
|
18
|
+
function PluginManager(opts) {
|
|
19
|
+
_classCallCheck(this, PluginManager);
|
|
20
|
+
_defineProperty(this, "opts", void 0);
|
|
21
|
+
_defineProperty(this, "hooks", {});
|
|
22
|
+
this.opts = opts;
|
|
23
|
+
}
|
|
24
|
+
_createClass(PluginManager, [{
|
|
25
|
+
key: "register",
|
|
26
|
+
value: function register(plugin) {
|
|
27
|
+
var _this = this;
|
|
28
|
+
assert(plugin.apply, "plugin register failed, apply must supplied");
|
|
29
|
+
Object.keys(plugin.apply).forEach(function (key) {
|
|
30
|
+
assert(_this.opts.validKeys.indexOf(key) > -1, "register failed, invalid key ".concat(key, " ").concat(plugin.path ? "from plugin ".concat(plugin.path) : '', "."));
|
|
31
|
+
_this.hooks[key] = (_this.hooks[key] || []).concat(plugin.apply[key]);
|
|
32
|
+
});
|
|
21
33
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
34
|
+
}, {
|
|
35
|
+
key: "getHooks",
|
|
36
|
+
value: function getHooks(keyWithDot) {
|
|
37
|
+
var _keyWithDot$split = keyWithDot.split('.'),
|
|
38
|
+
_keyWithDot$split2 = _toArray(_keyWithDot$split),
|
|
39
|
+
key = _keyWithDot$split2[0],
|
|
40
|
+
memberKeys = _keyWithDot$split2.slice(1);
|
|
41
|
+
var hooks = this.hooks[key] || [];
|
|
42
|
+
if (memberKeys.length) {
|
|
43
|
+
hooks = hooks.map(function (hook) {
|
|
44
|
+
try {
|
|
45
|
+
var ret = hook;
|
|
46
|
+
var _iterator = _createForOfIteratorHelper(memberKeys),
|
|
47
|
+
_step;
|
|
48
|
+
try {
|
|
49
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
50
|
+
var memberKey = _step.value;
|
|
51
|
+
ret = ret[memberKey];
|
|
52
|
+
}
|
|
53
|
+
} catch (err) {
|
|
54
|
+
_iterator.e(err);
|
|
55
|
+
} finally {
|
|
56
|
+
_iterator.f();
|
|
57
|
+
}
|
|
58
|
+
return ret;
|
|
59
|
+
} catch (e) {
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
}).filter(Boolean);
|
|
63
|
+
}
|
|
64
|
+
return hooks;
|
|
28
65
|
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
66
|
+
}, {
|
|
67
|
+
key: "applyPlugins",
|
|
68
|
+
value: function applyPlugins(_ref) {
|
|
69
|
+
var key = _ref.key,
|
|
70
|
+
type = _ref.type,
|
|
71
|
+
initialValue = _ref.initialValue,
|
|
72
|
+
args = _ref.args,
|
|
73
|
+
async = _ref.async;
|
|
74
|
+
var hooks = this.getHooks(key) || [];
|
|
75
|
+
if (args) {
|
|
76
|
+
assert(_typeof(args) === 'object', "applyPlugins failed, args must be plain object.");
|
|
77
|
+
}
|
|
78
|
+
if (async) {
|
|
79
|
+
assert(type === ApplyPluginsType.modify || type === ApplyPluginsType.event, "async only works with modify and event type.");
|
|
80
|
+
}
|
|
81
|
+
switch (type) {
|
|
82
|
+
case ApplyPluginsType.modify:
|
|
83
|
+
if (async) {
|
|
84
|
+
return hooks.reduce( /*#__PURE__*/function () {
|
|
85
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(memo, hook) {
|
|
86
|
+
var ret;
|
|
87
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
88
|
+
while (1) switch (_context.prev = _context.next) {
|
|
89
|
+
case 0:
|
|
90
|
+
assert(typeof hook === 'function' || _typeof(hook) === 'object' || isPromiseLike(hook), "applyPlugins failed, all hooks for key ".concat(key, " must be function, plain object or Promise."));
|
|
91
|
+
if (!isPromiseLike(memo)) {
|
|
92
|
+
_context.next = 5;
|
|
93
|
+
break;
|
|
94
|
+
}
|
|
95
|
+
_context.next = 4;
|
|
96
|
+
return memo;
|
|
97
|
+
case 4:
|
|
98
|
+
memo = _context.sent;
|
|
99
|
+
case 5:
|
|
100
|
+
if (!(typeof hook === 'function')) {
|
|
101
|
+
_context.next = 16;
|
|
102
|
+
break;
|
|
103
|
+
}
|
|
104
|
+
ret = hook(memo, args);
|
|
105
|
+
if (!isPromiseLike(ret)) {
|
|
106
|
+
_context.next = 13;
|
|
107
|
+
break;
|
|
108
|
+
}
|
|
109
|
+
_context.next = 10;
|
|
110
|
+
return ret;
|
|
111
|
+
case 10:
|
|
112
|
+
return _context.abrupt("return", _context.sent);
|
|
113
|
+
case 13:
|
|
114
|
+
return _context.abrupt("return", ret);
|
|
115
|
+
case 14:
|
|
116
|
+
_context.next = 21;
|
|
117
|
+
break;
|
|
118
|
+
case 16:
|
|
119
|
+
if (!isPromiseLike(hook)) {
|
|
120
|
+
_context.next = 20;
|
|
121
|
+
break;
|
|
122
|
+
}
|
|
123
|
+
_context.next = 19;
|
|
124
|
+
return hook;
|
|
125
|
+
case 19:
|
|
126
|
+
hook = _context.sent;
|
|
127
|
+
case 20:
|
|
128
|
+
return _context.abrupt("return", _objectSpread(_objectSpread({}, memo), hook));
|
|
129
|
+
case 21:
|
|
130
|
+
case "end":
|
|
131
|
+
return _context.stop();
|
|
132
|
+
}
|
|
133
|
+
}, _callee);
|
|
134
|
+
}));
|
|
135
|
+
return function (_x, _x2) {
|
|
136
|
+
return _ref2.apply(this, arguments);
|
|
137
|
+
};
|
|
138
|
+
}(), isPromiseLike(initialValue) ? initialValue : Promise.resolve(initialValue));
|
|
139
|
+
} else {
|
|
140
|
+
return hooks.reduce(function (memo, hook) {
|
|
141
|
+
assert(typeof hook === 'function' || _typeof(hook) === 'object', "applyPlugins failed, all hooks for key ".concat(key, " must be function or plain object."));
|
|
142
|
+
if (typeof hook === 'function') {
|
|
143
|
+
return hook(memo, args);
|
|
144
|
+
} else {
|
|
145
|
+
// TODO: deepmerge?
|
|
146
|
+
return _objectSpread(_objectSpread({}, memo), hook);
|
|
147
|
+
}
|
|
148
|
+
}, initialValue);
|
|
149
|
+
}
|
|
150
|
+
case ApplyPluginsType.event:
|
|
151
|
+
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
152
|
+
var _iterator2, _step2, hook, ret;
|
|
153
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
154
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
155
|
+
case 0:
|
|
156
|
+
_iterator2 = _createForOfIteratorHelper(hooks);
|
|
157
|
+
_context2.prev = 1;
|
|
158
|
+
_iterator2.s();
|
|
159
|
+
case 3:
|
|
160
|
+
if ((_step2 = _iterator2.n()).done) {
|
|
161
|
+
_context2.next = 12;
|
|
162
|
+
break;
|
|
163
|
+
}
|
|
164
|
+
hook = _step2.value;
|
|
165
|
+
assert(typeof hook === 'function', "applyPlugins failed, all hooks for key ".concat(key, " must be function."));
|
|
166
|
+
ret = hook(args);
|
|
167
|
+
if (!(async && isPromiseLike(ret))) {
|
|
168
|
+
_context2.next = 10;
|
|
169
|
+
break;
|
|
170
|
+
}
|
|
171
|
+
_context2.next = 10;
|
|
172
|
+
return ret;
|
|
173
|
+
case 10:
|
|
174
|
+
_context2.next = 3;
|
|
175
|
+
break;
|
|
176
|
+
case 12:
|
|
177
|
+
_context2.next = 17;
|
|
178
|
+
break;
|
|
179
|
+
case 14:
|
|
180
|
+
_context2.prev = 14;
|
|
181
|
+
_context2.t0 = _context2["catch"](1);
|
|
182
|
+
_iterator2.e(_context2.t0);
|
|
183
|
+
case 17:
|
|
184
|
+
_context2.prev = 17;
|
|
185
|
+
_iterator2.f();
|
|
186
|
+
return _context2.finish(17);
|
|
187
|
+
case 20:
|
|
188
|
+
case "end":
|
|
189
|
+
return _context2.stop();
|
|
190
|
+
}
|
|
191
|
+
}, _callee2, null, [[1, 14, 17, 20]]);
|
|
192
|
+
}))();
|
|
193
|
+
case ApplyPluginsType.compose:
|
|
194
|
+
return function () {
|
|
195
|
+
return compose({
|
|
196
|
+
fns: hooks.concat(initialValue),
|
|
197
|
+
args: args
|
|
198
|
+
})();
|
|
199
|
+
};
|
|
200
|
+
}
|
|
49
201
|
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
typeof hook === 'object' ||
|
|
61
|
-
isPromiseLike(hook), `applyPlugins failed, all hooks for key ${key} must be function, plain object or Promise.`);
|
|
62
|
-
if (isPromiseLike(memo)) {
|
|
63
|
-
memo = yield memo;
|
|
64
|
-
}
|
|
65
|
-
if (typeof hook === 'function') {
|
|
66
|
-
const ret = hook(memo, args);
|
|
67
|
-
if (isPromiseLike(ret)) {
|
|
68
|
-
return yield ret;
|
|
69
|
-
}
|
|
70
|
-
else {
|
|
71
|
-
return ret;
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
else {
|
|
75
|
-
if (isPromiseLike(hook)) {
|
|
76
|
-
hook = yield hook;
|
|
77
|
-
}
|
|
78
|
-
return Object.assign(Object.assign({}, memo), hook);
|
|
79
|
-
}
|
|
80
|
-
}), isPromiseLike(initialValue)
|
|
81
|
-
? initialValue
|
|
82
|
-
: Promise.resolve(initialValue));
|
|
83
|
-
}
|
|
84
|
-
else {
|
|
85
|
-
return hooks.reduce((memo, hook) => {
|
|
86
|
-
assert(typeof hook === 'function' || typeof hook === 'object', `applyPlugins failed, all hooks for key ${key} must be function or plain object.`);
|
|
87
|
-
if (typeof hook === 'function') {
|
|
88
|
-
return hook(memo, args);
|
|
89
|
-
}
|
|
90
|
-
else {
|
|
91
|
-
// TODO: deepmerge?
|
|
92
|
-
return Object.assign(Object.assign({}, memo), hook);
|
|
93
|
-
}
|
|
94
|
-
}, initialValue);
|
|
95
|
-
}
|
|
96
|
-
case ApplyPluginsType.event:
|
|
97
|
-
return hooks.forEach((hook) => {
|
|
98
|
-
assert(typeof hook === 'function', `applyPlugins failed, all hooks for key ${key} must be function.`);
|
|
99
|
-
hook(args);
|
|
100
|
-
});
|
|
101
|
-
case ApplyPluginsType.compose:
|
|
102
|
-
return () => {
|
|
103
|
-
return compose({
|
|
104
|
-
fns: hooks.concat(initialValue),
|
|
105
|
-
args,
|
|
106
|
-
})();
|
|
107
|
-
};
|
|
108
|
-
}
|
|
202
|
+
}], [{
|
|
203
|
+
key: "create",
|
|
204
|
+
value: function create(opts) {
|
|
205
|
+
var pluginManager = new PluginManager({
|
|
206
|
+
validKeys: opts.validKeys
|
|
207
|
+
});
|
|
208
|
+
opts.plugins.forEach(function (plugin) {
|
|
209
|
+
pluginManager.register(plugin);
|
|
210
|
+
});
|
|
211
|
+
return pluginManager;
|
|
109
212
|
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
opts.plugins.forEach((plugin) => {
|
|
115
|
-
pluginManager.register(plugin);
|
|
116
|
-
});
|
|
117
|
-
return pluginManager;
|
|
118
|
-
}
|
|
119
|
-
}
|
|
213
|
+
}]);
|
|
214
|
+
return PluginManager;
|
|
215
|
+
}();
|
|
216
|
+
|
|
120
217
|
// plugins meta info (in tmp file)
|
|
121
|
-
// hooks api: usePlugin
|
|
218
|
+
// hooks api: usePlugin
|
package/client/client/utils.js
CHANGED
|
@@ -1,14 +1,20 @@
|
|
|
1
|
+
import _typeof from "@babel/runtime/helpers/esm/typeof";
|
|
1
2
|
export function assert(value, message) {
|
|
2
|
-
|
|
3
|
-
throw new Error(message);
|
|
3
|
+
if (!value) throw new Error(message);
|
|
4
4
|
}
|
|
5
|
-
export function compose(
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
5
|
+
export function compose(_ref) {
|
|
6
|
+
var fns = _ref.fns,
|
|
7
|
+
args = _ref.args;
|
|
8
|
+
if (fns.length === 1) {
|
|
9
|
+
return fns[0];
|
|
10
|
+
}
|
|
11
|
+
var last = fns.pop();
|
|
12
|
+
return fns.reduce(function (a, b) {
|
|
13
|
+
return function () {
|
|
14
|
+
return b(a, args);
|
|
15
|
+
};
|
|
16
|
+
}, last);
|
|
11
17
|
}
|
|
12
18
|
export function isPromiseLike(obj) {
|
|
13
|
-
|
|
14
|
-
}
|
|
19
|
+
return !!obj && _typeof(obj) === 'object' && typeof obj.then === 'function';
|
|
20
|
+
}
|
package/dist/cli/cli.js
CHANGED
|
@@ -1,58 +1,70 @@
|
|
|
1
|
-
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
8
|
};
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/cli/cli.ts
|
|
20
|
+
var cli_exports = {};
|
|
21
|
+
__export(cli_exports, {
|
|
22
|
+
run: () => run
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(cli_exports);
|
|
25
|
+
var import_utils = require("@umijs/utils");
|
|
26
|
+
var import_constants = require("../constants");
|
|
27
|
+
var import_service = require("../service/service");
|
|
28
|
+
var import_dev = require("./dev");
|
|
29
|
+
(0, import_utils.catchUnhandledRejection)();
|
|
30
|
+
async function run(opts) {
|
|
31
|
+
(0, import_utils.checkVersion)(import_constants.MIN_NODE_VERSION);
|
|
32
|
+
(0, import_utils.checkLocal)();
|
|
33
|
+
(0, import_utils.setNodeTitle)(import_constants.FRAMEWORK_NAME);
|
|
34
|
+
(0, import_utils.setNoDeprecation)();
|
|
35
|
+
const args = (0, import_utils.yParser)(process.argv.slice(2), {
|
|
36
|
+
alias: {
|
|
37
|
+
version: ["v"],
|
|
38
|
+
help: ["h"]
|
|
39
|
+
},
|
|
40
|
+
boolean: ["version"]
|
|
41
|
+
});
|
|
42
|
+
const command = args._[0];
|
|
43
|
+
const FEATURE_COMMANDS = ["mfsu", "setup", "deadcode"];
|
|
44
|
+
if ([import_constants.DEV_COMMAND, ...FEATURE_COMMANDS].includes(command)) {
|
|
45
|
+
process.env.NODE_ENV = "development";
|
|
46
|
+
} else if (command === "build") {
|
|
47
|
+
process.env.NODE_ENV = "production";
|
|
48
|
+
}
|
|
49
|
+
if (opts == null ? void 0 : opts.presets) {
|
|
50
|
+
process.env[`${import_constants.FRAMEWORK_NAME}_PRESETS`.toUpperCase()] = opts.presets.join(",");
|
|
51
|
+
}
|
|
52
|
+
if (command === import_constants.DEV_COMMAND) {
|
|
53
|
+
(0, import_dev.dev)();
|
|
54
|
+
} else {
|
|
55
|
+
try {
|
|
56
|
+
await new import_service.Service().run2({
|
|
57
|
+
name: args._[0],
|
|
58
|
+
args
|
|
59
|
+
});
|
|
60
|
+
} catch (e) {
|
|
61
|
+
import_utils.logger.fatal(e);
|
|
62
|
+
import_utils.printHelp.exit();
|
|
63
|
+
process.exit(1);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
57
66
|
}
|
|
58
|
-
|
|
67
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
68
|
+
0 && (module.exports = {
|
|
69
|
+
run
|
|
70
|
+
});
|
package/dist/cli/dev.js
CHANGED
|
@@ -1,26 +1,52 @@
|
|
|
1
|
-
|
|
2
|
-
var
|
|
3
|
-
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
4
10
|
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
|
|
29
|
+
// src/cli/dev.ts
|
|
30
|
+
var dev_exports = {};
|
|
31
|
+
__export(dev_exports, {
|
|
32
|
+
dev: () => dev
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(dev_exports);
|
|
35
|
+
var import_fork = __toESM(require("./fork"));
|
|
8
36
|
function dev() {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
});
|
|
21
|
-
process.on('SIGTERM', () => {
|
|
22
|
-
child.kill('SIGTERM');
|
|
23
|
-
process.exit(1);
|
|
24
|
-
});
|
|
37
|
+
const child = (0, import_fork.default)({
|
|
38
|
+
scriptPath: require.resolve("../../bin/forkedDev")
|
|
39
|
+
});
|
|
40
|
+
process.on("SIGINT", () => {
|
|
41
|
+
child.kill("SIGINT");
|
|
42
|
+
process.exit(0);
|
|
43
|
+
});
|
|
44
|
+
process.on("SIGTERM", () => {
|
|
45
|
+
child.kill("SIGTERM");
|
|
46
|
+
process.exit(1);
|
|
47
|
+
});
|
|
25
48
|
}
|
|
26
|
-
|
|
49
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
50
|
+
0 && (module.exports = {
|
|
51
|
+
dev
|
|
52
|
+
});
|