@umijs/core 4.0.0-rc.8 → 4.0.0-rc.9
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.
|
@@ -48,9 +48,9 @@ umi generate
|
|
|
48
48
|
}
|
|
49
49
|
else {
|
|
50
50
|
const getEnableGenerators = (generators) => __awaiter(this, void 0, void 0, function* () {
|
|
51
|
+
var _b, _c;
|
|
51
52
|
const questions = [];
|
|
52
|
-
Object.keys(generators)
|
|
53
|
-
var _b, _c;
|
|
53
|
+
for (const key of Object.keys(generators)) {
|
|
54
54
|
if (generators[key].type === generator_1.GeneratorType.generate) {
|
|
55
55
|
questions.push({
|
|
56
56
|
title: `${generators[key].name} -- ${generators[key].description}` ||
|
|
@@ -70,7 +70,7 @@ umi generate
|
|
|
70
70
|
});
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
|
-
}
|
|
73
|
+
}
|
|
74
74
|
return questions;
|
|
75
75
|
});
|
|
76
76
|
const questions = yield getEnableGenerators(api.service.generators);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { generateFile } from '@umijs/utils';
|
|
2
2
|
import { Plugin } from './plugin';
|
|
3
3
|
export declare enum GeneratorType {
|
|
4
4
|
generate = "generate",
|
|
@@ -17,14 +17,7 @@ export interface IGeneratorOpts {
|
|
|
17
17
|
fn: {
|
|
18
18
|
(opts: {
|
|
19
19
|
args: any;
|
|
20
|
-
generateFile:
|
|
21
|
-
(opts: {
|
|
22
|
-
path: string;
|
|
23
|
-
target: string;
|
|
24
|
-
data?: any;
|
|
25
|
-
questions?: prompts.PromptObject[];
|
|
26
|
-
}): Promise<void>;
|
|
27
|
-
};
|
|
20
|
+
generateFile: typeof generateFile;
|
|
28
21
|
updatePackageJSON: {
|
|
29
22
|
(opts: {
|
|
30
23
|
opts: object;
|
package/dist/service/plugin.js
CHANGED
|
@@ -38,6 +38,7 @@ class Plugin {
|
|
|
38
38
|
this.apply = () => {
|
|
39
39
|
utils_1.register.register({
|
|
40
40
|
implementor: esbuild_1.default,
|
|
41
|
+
exts: ['.ts', '.mjs'],
|
|
41
42
|
});
|
|
42
43
|
utils_1.register.clearFiles();
|
|
43
44
|
let ret;
|
|
@@ -47,10 +48,9 @@ class Plugin {
|
|
|
47
48
|
catch (e) {
|
|
48
49
|
throw new Error(`Register ${this.type} ${this.path} failed, since ${e.message}`);
|
|
49
50
|
}
|
|
50
|
-
|
|
51
|
-
|
|
51
|
+
finally {
|
|
52
|
+
utils_1.register.restore();
|
|
52
53
|
}
|
|
53
|
-
utils_1.register.restore();
|
|
54
54
|
// use the default member for es modules
|
|
55
55
|
return ret.__esModule ? ret.default : ret;
|
|
56
56
|
};
|
package/dist/service/service.js
CHANGED
|
@@ -25,7 +25,6 @@ const env_1 = require("./env");
|
|
|
25
25
|
const path_2 = require("./path");
|
|
26
26
|
const plugin_1 = require("./plugin");
|
|
27
27
|
const pluginAPI_1 = require("./pluginAPI");
|
|
28
|
-
const utils_2 = require("./utils");
|
|
29
28
|
class Service {
|
|
30
29
|
constructor(opts) {
|
|
31
30
|
this.appData = {};
|
|
@@ -167,11 +166,13 @@ class Service {
|
|
|
167
166
|
}
|
|
168
167
|
this.pkg = pkg;
|
|
169
168
|
this.pkgPath = pkgPath || (0, path_1.join)(this.cwd, 'package.json');
|
|
169
|
+
const prefix = this.opts.frameworkName || constants_1.DEFAULT_FRAMEWORK_NAME;
|
|
170
170
|
// get user config
|
|
171
171
|
const configManager = new config_1.Config({
|
|
172
172
|
cwd: this.cwd,
|
|
173
173
|
env: this.env,
|
|
174
174
|
defaultConfigFiles: this.opts.defaultConfigFiles,
|
|
175
|
+
specifiedEnv: process.env[`${prefix}_ENV`.toUpperCase()],
|
|
175
176
|
});
|
|
176
177
|
this.configManager = configManager;
|
|
177
178
|
this.userConfig = configManager.getUserConfig().config;
|
|
@@ -183,7 +184,7 @@ class Service {
|
|
|
183
184
|
plugins: [require.resolve('./generatePlugin')].concat(this.opts.plugins || []),
|
|
184
185
|
presets: [require.resolve('./servicePlugin')].concat(this.opts.presets || []),
|
|
185
186
|
userConfig: this.userConfig,
|
|
186
|
-
prefix
|
|
187
|
+
prefix,
|
|
187
188
|
});
|
|
188
189
|
// register presets and plugins
|
|
189
190
|
this.stage = types_1.ServiceStage.initPresets;
|
|
@@ -285,10 +286,7 @@ class Service {
|
|
|
285
286
|
this.stage = types_1.ServiceStage.runCommand;
|
|
286
287
|
const command = this.commands[name];
|
|
287
288
|
(0, assert_1.default)(command, `Invalid command ${name}, it's not registered.`);
|
|
288
|
-
let ret = command.fn({ args });
|
|
289
|
-
if ((0, utils_2.isPromise)(ret)) {
|
|
290
|
-
ret = yield ret;
|
|
291
|
-
}
|
|
289
|
+
let ret = yield command.fn({ args });
|
|
292
290
|
this._baconPlugins();
|
|
293
291
|
return ret;
|
|
294
292
|
});
|
|
@@ -353,10 +351,7 @@ class Service {
|
|
|
353
351
|
},
|
|
354
352
|
});
|
|
355
353
|
let dateStart = new Date();
|
|
356
|
-
let ret = opts.plugin.apply()(proxyPluginAPI);
|
|
357
|
-
if ((0, utils_2.isPromise)(ret)) {
|
|
358
|
-
ret = yield ret;
|
|
359
|
-
}
|
|
354
|
+
let ret = yield opts.plugin.apply()(proxyPluginAPI);
|
|
360
355
|
opts.plugin.time.register = new Date().getTime() - dateStart.getTime();
|
|
361
356
|
if (opts.plugin.type === 'plugin') {
|
|
362
357
|
(0, assert_1.default)(!ret, `plugin should return nothing`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umijs/core",
|
|
3
|
-
"version": "4.0.0-rc.
|
|
3
|
+
"version": "4.0.0-rc.9",
|
|
4
4
|
"homepage": "https://github.com/umijs/umi-next/tree/master/packages/core#readme",
|
|
5
5
|
"bugs": "https://github.com/umijs/umi-next/issues",
|
|
6
6
|
"repository": {
|
|
@@ -21,8 +21,8 @@
|
|
|
21
21
|
"test": "jest -c ../../jest.turbo.config.ts"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@umijs/bundler-utils": "4.0.0-rc.
|
|
25
|
-
"@umijs/utils": "4.0.0-rc.
|
|
24
|
+
"@umijs/bundler-utils": "4.0.0-rc.9",
|
|
25
|
+
"@umijs/utils": "4.0.0-rc.9"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"@hapi/joi": "17.1.1",
|