umi 4.0.7 → 4.0.8
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 +263 -190
- package/client/client/utils.js +18 -11
- package/dist/cli/cli.js +66 -45
- package/dist/cli/dev.js +42 -23
- package/dist/cli/fork.js +59 -37
- package/dist/cli/forkedDev.js +34 -40
- package/dist/cli/node.js +48 -24
- package/dist/constants.js +42 -11
- package/dist/defineConfig.js +29 -5
- package/dist/defineMock.js +29 -5
- package/dist/index.js +36 -23
- package/dist/pluginUtils.js +38 -37
- 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 +78 -37
- package/dist/test.js +69 -59
- package/package.json +13 -14
- package/dist/client/plugin.d.ts +0 -34
- package/dist/client/plugin.js +0 -124
- package/dist/client/utils.d.ts +0 -6
- package/dist/client/utils.js +0 -20
package/client/client/plugin.js
CHANGED
|
@@ -1,197 +1,270 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
};
|
|
12
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
13
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
14
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
15
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
16
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
17
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
18
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
19
|
-
});
|
|
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
|
-
};
|
|
48
|
-
import { assert, compose, isPromiseLike } from './utils';
|
|
1
|
+
import _objectSpread from "@babel/runtime/helpers/objectSpread2";
|
|
2
|
+
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
3
|
+
import _typeof from "@babel/runtime/helpers/typeof";
|
|
4
|
+
import _createForOfIteratorHelper from "@babel/runtime/helpers/createForOfIteratorHelper";
|
|
5
|
+
import _toArray from "@babel/runtime/helpers/toArray";
|
|
6
|
+
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
7
|
+
import _createClass from "@babel/runtime/helpers/createClass";
|
|
8
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
9
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
10
|
+
import { assert, compose, isPromiseLike } from "./utils";
|
|
49
11
|
export var ApplyPluginsType;
|
|
12
|
+
|
|
50
13
|
(function (ApplyPluginsType) {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
14
|
+
ApplyPluginsType["compose"] = "compose";
|
|
15
|
+
ApplyPluginsType["modify"] = "modify";
|
|
16
|
+
ApplyPluginsType["event"] = "event";
|
|
54
17
|
})(ApplyPluginsType || (ApplyPluginsType = {}));
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
18
|
+
|
|
19
|
+
export var PluginManager = /*#__PURE__*/function () {
|
|
20
|
+
function PluginManager(opts) {
|
|
21
|
+
_classCallCheck(this, PluginManager);
|
|
22
|
+
|
|
23
|
+
_defineProperty(this, "opts", void 0);
|
|
24
|
+
|
|
25
|
+
_defineProperty(this, "hooks", {});
|
|
26
|
+
|
|
27
|
+
this.opts = opts;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
_createClass(PluginManager, [{
|
|
31
|
+
key: "register",
|
|
32
|
+
value: function register(plugin) {
|
|
33
|
+
var _this = this;
|
|
34
|
+
|
|
35
|
+
assert(plugin.apply, "plugin register failed, apply must supplied");
|
|
36
|
+
Object.keys(plugin.apply).forEach(function (key) {
|
|
37
|
+
assert(_this.opts.validKeys.indexOf(key) > -1, "register failed, invalid key ".concat(key, " ").concat(plugin.path ? "from plugin ".concat(plugin.path) : '', "."));
|
|
38
|
+
_this.hooks[key] = (_this.hooks[key] || []).concat(plugin.apply[key]);
|
|
39
|
+
});
|
|
59
40
|
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
case 9: return [2 /*return*/];
|
|
132
|
-
}
|
|
133
|
-
});
|
|
134
|
-
}); }, isPromiseLike(initialValue)
|
|
135
|
-
? initialValue
|
|
136
|
-
: Promise.resolve(initialValue));
|
|
137
|
-
}
|
|
138
|
-
else {
|
|
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."));
|
|
141
|
-
if (typeof hook === 'function') {
|
|
142
|
-
return hook(memo, args);
|
|
41
|
+
}, {
|
|
42
|
+
key: "getHooks",
|
|
43
|
+
value: function getHooks(keyWithDot) {
|
|
44
|
+
var _keyWithDot$split = keyWithDot.split('.'),
|
|
45
|
+
_keyWithDot$split2 = _toArray(_keyWithDot$split),
|
|
46
|
+
key = _keyWithDot$split2[0],
|
|
47
|
+
memberKeys = _keyWithDot$split2.slice(1);
|
|
48
|
+
|
|
49
|
+
var hooks = this.hooks[key] || [];
|
|
50
|
+
|
|
51
|
+
if (memberKeys.length) {
|
|
52
|
+
hooks = hooks.map(function (hook) {
|
|
53
|
+
try {
|
|
54
|
+
var ret = hook;
|
|
55
|
+
|
|
56
|
+
var _iterator = _createForOfIteratorHelper(memberKeys),
|
|
57
|
+
_step;
|
|
58
|
+
|
|
59
|
+
try {
|
|
60
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
61
|
+
var memberKey = _step.value;
|
|
62
|
+
ret = ret[memberKey];
|
|
63
|
+
}
|
|
64
|
+
} catch (err) {
|
|
65
|
+
_iterator.e(err);
|
|
66
|
+
} finally {
|
|
67
|
+
_iterator.f();
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return ret;
|
|
71
|
+
} catch (e) {
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
74
|
+
}).filter(Boolean);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
return hooks;
|
|
78
|
+
}
|
|
79
|
+
}, {
|
|
80
|
+
key: "applyPlugins",
|
|
81
|
+
value: function applyPlugins(_ref) {
|
|
82
|
+
var key = _ref.key,
|
|
83
|
+
type = _ref.type,
|
|
84
|
+
initialValue = _ref.initialValue,
|
|
85
|
+
args = _ref.args,
|
|
86
|
+
async = _ref.async;
|
|
87
|
+
var hooks = this.getHooks(key) || [];
|
|
88
|
+
|
|
89
|
+
if (args) {
|
|
90
|
+
assert(_typeof(args) === 'object', "applyPlugins failed, args must be plain object.");
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
if (async) {
|
|
94
|
+
assert(type === ApplyPluginsType.modify || type === ApplyPluginsType.event, "async only works with modify and event type.");
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
switch (type) {
|
|
98
|
+
case ApplyPluginsType.modify:
|
|
99
|
+
if (async) {
|
|
100
|
+
return hooks.reduce( /*#__PURE__*/function () {
|
|
101
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(memo, hook) {
|
|
102
|
+
var ret;
|
|
103
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
104
|
+
while (1) {
|
|
105
|
+
switch (_context.prev = _context.next) {
|
|
106
|
+
case 0:
|
|
107
|
+
assert(typeof hook === 'function' || _typeof(hook) === 'object' || isPromiseLike(hook), "applyPlugins failed, all hooks for key ".concat(key, " must be function, plain object or Promise."));
|
|
108
|
+
|
|
109
|
+
if (!isPromiseLike(memo)) {
|
|
110
|
+
_context.next = 5;
|
|
111
|
+
break;
|
|
143
112
|
}
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
113
|
+
|
|
114
|
+
_context.next = 4;
|
|
115
|
+
return memo;
|
|
116
|
+
|
|
117
|
+
case 4:
|
|
118
|
+
memo = _context.sent;
|
|
119
|
+
|
|
120
|
+
case 5:
|
|
121
|
+
if (!(typeof hook === 'function')) {
|
|
122
|
+
_context.next = 16;
|
|
123
|
+
break;
|
|
147
124
|
}
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
125
|
+
|
|
126
|
+
ret = hook(memo, args);
|
|
127
|
+
|
|
128
|
+
if (!isPromiseLike(ret)) {
|
|
129
|
+
_context.next = 13;
|
|
130
|
+
break;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
_context.next = 10;
|
|
134
|
+
return ret;
|
|
135
|
+
|
|
136
|
+
case 10:
|
|
137
|
+
return _context.abrupt("return", _context.sent);
|
|
138
|
+
|
|
139
|
+
case 13:
|
|
140
|
+
return _context.abrupt("return", ret);
|
|
141
|
+
|
|
142
|
+
case 14:
|
|
143
|
+
_context.next = 21;
|
|
144
|
+
break;
|
|
145
|
+
|
|
146
|
+
case 16:
|
|
147
|
+
if (!isPromiseLike(hook)) {
|
|
148
|
+
_context.next = 20;
|
|
149
|
+
break;
|
|
172
150
|
}
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
}());
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
151
|
+
|
|
152
|
+
_context.next = 19;
|
|
153
|
+
return hook;
|
|
154
|
+
|
|
155
|
+
case 19:
|
|
156
|
+
hook = _context.sent;
|
|
157
|
+
|
|
158
|
+
case 20:
|
|
159
|
+
return _context.abrupt("return", _objectSpread(_objectSpread({}, memo), hook));
|
|
160
|
+
|
|
161
|
+
case 21:
|
|
162
|
+
case "end":
|
|
163
|
+
return _context.stop();
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
}, _callee);
|
|
167
|
+
}));
|
|
168
|
+
|
|
169
|
+
return function (_x, _x2) {
|
|
170
|
+
return _ref2.apply(this, arguments);
|
|
171
|
+
};
|
|
172
|
+
}(), isPromiseLike(initialValue) ? initialValue : Promise.resolve(initialValue));
|
|
173
|
+
} else {
|
|
174
|
+
return hooks.reduce(function (memo, hook) {
|
|
175
|
+
assert(typeof hook === 'function' || _typeof(hook) === 'object', "applyPlugins failed, all hooks for key ".concat(key, " must be function or plain object."));
|
|
176
|
+
|
|
177
|
+
if (typeof hook === 'function') {
|
|
178
|
+
return hook(memo, args);
|
|
179
|
+
} else {
|
|
180
|
+
// TODO: deepmerge?
|
|
181
|
+
return _objectSpread(_objectSpread({}, memo), hook);
|
|
182
|
+
}
|
|
183
|
+
}, initialValue);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
case ApplyPluginsType.event:
|
|
187
|
+
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
188
|
+
var _iterator2, _step2, hook, ret;
|
|
189
|
+
|
|
190
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
191
|
+
while (1) {
|
|
192
|
+
switch (_context2.prev = _context2.next) {
|
|
193
|
+
case 0:
|
|
194
|
+
_iterator2 = _createForOfIteratorHelper(hooks);
|
|
195
|
+
_context2.prev = 1;
|
|
196
|
+
|
|
197
|
+
_iterator2.s();
|
|
198
|
+
|
|
199
|
+
case 3:
|
|
200
|
+
if ((_step2 = _iterator2.n()).done) {
|
|
201
|
+
_context2.next = 12;
|
|
202
|
+
break;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
hook = _step2.value;
|
|
206
|
+
assert(typeof hook === 'function', "applyPlugins failed, all hooks for key ".concat(key, " must be function."));
|
|
207
|
+
ret = hook(args);
|
|
208
|
+
|
|
209
|
+
if (!(async && isPromiseLike(ret))) {
|
|
210
|
+
_context2.next = 10;
|
|
211
|
+
break;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
_context2.next = 10;
|
|
215
|
+
return ret;
|
|
216
|
+
|
|
217
|
+
case 10:
|
|
218
|
+
_context2.next = 3;
|
|
219
|
+
break;
|
|
220
|
+
|
|
221
|
+
case 12:
|
|
222
|
+
_context2.next = 17;
|
|
223
|
+
break;
|
|
224
|
+
|
|
225
|
+
case 14:
|
|
226
|
+
_context2.prev = 14;
|
|
227
|
+
_context2.t0 = _context2["catch"](1);
|
|
228
|
+
|
|
229
|
+
_iterator2.e(_context2.t0);
|
|
230
|
+
|
|
231
|
+
case 17:
|
|
232
|
+
_context2.prev = 17;
|
|
233
|
+
|
|
234
|
+
_iterator2.f();
|
|
235
|
+
|
|
236
|
+
return _context2.finish(17);
|
|
237
|
+
|
|
238
|
+
case 20:
|
|
239
|
+
case "end":
|
|
240
|
+
return _context2.stop();
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
}, _callee2, null, [[1, 14, 17, 20]]);
|
|
244
|
+
}))();
|
|
245
|
+
|
|
246
|
+
case ApplyPluginsType.compose:
|
|
247
|
+
return function () {
|
|
248
|
+
return compose({
|
|
249
|
+
fns: hooks.concat(initialValue),
|
|
250
|
+
args: args
|
|
251
|
+
})();
|
|
252
|
+
};
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
}], [{
|
|
256
|
+
key: "create",
|
|
257
|
+
value: function create(opts) {
|
|
258
|
+
var pluginManager = new PluginManager({
|
|
259
|
+
validKeys: opts.validKeys
|
|
260
|
+
});
|
|
261
|
+
opts.plugins.forEach(function (plugin) {
|
|
262
|
+
pluginManager.register(plugin);
|
|
263
|
+
});
|
|
264
|
+
return pluginManager;
|
|
265
|
+
}
|
|
266
|
+
}]);
|
|
267
|
+
|
|
268
|
+
return PluginManager;
|
|
269
|
+
}(); // plugins meta info (in tmp file)
|
|
270
|
+
// hooks api: usePlugin
|
package/client/client/utils.js
CHANGED
|
@@ -1,15 +1,22 @@
|
|
|
1
|
+
import _typeof from "@babel/runtime/helpers/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
|
-
|
|
11
|
-
|
|
5
|
+
export function compose(_ref) {
|
|
6
|
+
var fns = _ref.fns,
|
|
7
|
+
args = _ref.args;
|
|
8
|
+
|
|
9
|
+
if (fns.length === 1) {
|
|
10
|
+
return fns[0];
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
var last = fns.pop();
|
|
14
|
+
return fns.reduce(function (a, b) {
|
|
15
|
+
return function () {
|
|
16
|
+
return b(a, args);
|
|
17
|
+
};
|
|
18
|
+
}, last);
|
|
12
19
|
}
|
|
13
20
|
export function isPromiseLike(obj) {
|
|
14
|
-
|
|
15
|
-
}
|
|
21
|
+
return !!obj && _typeof(obj) === 'object' && typeof obj.then === 'function';
|
|
22
|
+
}
|
package/dist/cli/cli.js
CHANGED
|
@@ -1,48 +1,69 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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 });
|
|
8
|
+
};
|
|
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
|
+
// 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
|
+
var import_node = require("./node");
|
|
9
30
|
async function run(opts) {
|
|
10
|
-
|
|
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
|
-
utils_1.logger.fatal(e);
|
|
43
|
-
utils_1.printHelp.exit();
|
|
44
|
-
process.exit(1);
|
|
45
|
-
}
|
|
31
|
+
(0, import_node.checkVersion)();
|
|
32
|
+
(0, import_node.checkLocal)();
|
|
33
|
+
(0, import_node.setNodeTitle)();
|
|
34
|
+
(0, import_node.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
|
+
if ([import_constants.DEV_COMMAND, "setup"].includes(command)) {
|
|
44
|
+
process.env.NODE_ENV = "development";
|
|
45
|
+
} else if (command === "build") {
|
|
46
|
+
process.env.NODE_ENV = "production";
|
|
47
|
+
}
|
|
48
|
+
if (opts == null ? void 0 : opts.presets) {
|
|
49
|
+
process.env.UMI_PRESETS = opts.presets.join(",");
|
|
50
|
+
}
|
|
51
|
+
if (command === import_constants.DEV_COMMAND) {
|
|
52
|
+
(0, import_dev.dev)();
|
|
53
|
+
} else {
|
|
54
|
+
try {
|
|
55
|
+
await new import_service.Service().run2({
|
|
56
|
+
name: args._[0],
|
|
57
|
+
args
|
|
58
|
+
});
|
|
59
|
+
} catch (e) {
|
|
60
|
+
import_utils.logger.fatal(e);
|
|
61
|
+
import_utils.printHelp.exit();
|
|
62
|
+
process.exit(1);
|
|
46
63
|
}
|
|
64
|
+
}
|
|
47
65
|
}
|
|
48
|
-
|
|
66
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
67
|
+
0 && (module.exports = {
|
|
68
|
+
run
|
|
69
|
+
});
|