@umijs/core 4.0.26 → 4.0.28
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/service/service.d.ts +10 -0
- package/dist/service/service.js +31 -9
- package/package.json +3 -3
|
@@ -81,6 +81,15 @@ export declare class Service {
|
|
|
81
81
|
name: string;
|
|
82
82
|
args?: any;
|
|
83
83
|
}): Promise<void>;
|
|
84
|
+
getPaths(): Promise<{
|
|
85
|
+
cwd: string;
|
|
86
|
+
absSrcPath: string;
|
|
87
|
+
absPagesPath: string;
|
|
88
|
+
absApiRoutesPath: string;
|
|
89
|
+
absTmpPath: string;
|
|
90
|
+
absNodeModulesPath: string;
|
|
91
|
+
absOutputPath: string;
|
|
92
|
+
}>;
|
|
84
93
|
resolveConfig(): Promise<{
|
|
85
94
|
config: any;
|
|
86
95
|
defaultConfig: any;
|
|
@@ -97,6 +106,7 @@ export declare class Service {
|
|
|
97
106
|
plugins: Plugin[];
|
|
98
107
|
}): Promise<any>;
|
|
99
108
|
isPluginEnable(hook: Hook | string): boolean;
|
|
109
|
+
commandGuessHelper(commands: string[], currentCmd: string): void;
|
|
100
110
|
}
|
|
101
111
|
export interface IServicePluginAPI {
|
|
102
112
|
appData: typeof Service.prototype.appData;
|
package/dist/service/service.js
CHANGED
|
@@ -194,12 +194,7 @@ var Service = class {
|
|
|
194
194
|
});
|
|
195
195
|
this.configManager = configManager;
|
|
196
196
|
this.userConfig = configManager.getUserConfig().config;
|
|
197
|
-
|
|
198
|
-
cwd: this.cwd,
|
|
199
|
-
env: this.env,
|
|
200
|
-
prefix: this.opts.frameworkName || import_constants.DEFAULT_FRAMEWORK_NAME
|
|
201
|
-
});
|
|
202
|
-
this.paths = paths;
|
|
197
|
+
this.paths = await this.getPaths();
|
|
203
198
|
const { plugins, presets } = import_plugin.Plugin.getPluginsAndPresets({
|
|
204
199
|
cwd: this.cwd,
|
|
205
200
|
pkg,
|
|
@@ -223,7 +218,10 @@ var Service = class {
|
|
|
223
218
|
await this.initPlugin({ plugin: plugins.shift(), plugins });
|
|
224
219
|
}
|
|
225
220
|
const command = this.commands[name];
|
|
226
|
-
|
|
221
|
+
if (!command) {
|
|
222
|
+
this.commandGuessHelper(Object.keys(this.commands), name);
|
|
223
|
+
throw Error(`Invalid command ${import_utils.chalk.red(name)}, it's not registered.`);
|
|
224
|
+
}
|
|
227
225
|
for (const id of Object.keys(this.plugins)) {
|
|
228
226
|
const { config: config2, key } = this.plugins[id];
|
|
229
227
|
if (config2.schema)
|
|
@@ -236,11 +234,11 @@ var Service = class {
|
|
|
236
234
|
this.stage = import_types.ServiceStage.resolveConfig;
|
|
237
235
|
const { config, defaultConfig } = await this.resolveConfig();
|
|
238
236
|
if (this.config.outputPath) {
|
|
239
|
-
paths.absOutputPath = (0, import_path.isAbsolute)(this.config.outputPath) ? this.config.outputPath : (0, import_path.join)(this.cwd, this.config.outputPath);
|
|
237
|
+
this.paths.absOutputPath = (0, import_path.isAbsolute)(this.config.outputPath) ? this.config.outputPath : (0, import_path.join)(this.cwd, this.config.outputPath);
|
|
240
238
|
}
|
|
241
239
|
this.paths = await this.applyPlugins({
|
|
242
240
|
key: "modifyPaths",
|
|
243
|
-
initialValue: paths
|
|
241
|
+
initialValue: this.paths
|
|
244
242
|
});
|
|
245
243
|
this.stage = import_types.ServiceStage.collectAppData;
|
|
246
244
|
this.appData = await this.applyPlugins({
|
|
@@ -272,6 +270,14 @@ var Service = class {
|
|
|
272
270
|
this._baconPlugins();
|
|
273
271
|
return ret;
|
|
274
272
|
}
|
|
273
|
+
async getPaths() {
|
|
274
|
+
const paths = (0, import_path2.getPaths)({
|
|
275
|
+
cwd: this.cwd,
|
|
276
|
+
env: this.env,
|
|
277
|
+
prefix: this.opts.frameworkName || import_constants.DEFAULT_FRAMEWORK_NAME
|
|
278
|
+
});
|
|
279
|
+
return paths;
|
|
280
|
+
}
|
|
275
281
|
async resolveConfig() {
|
|
276
282
|
(0, import_assert.default)(this.stage > import_types.ServiceStage.init, `Can't generate final config before init stage`);
|
|
277
283
|
const resolveMode = this.commands[this.name].configResolveMode;
|
|
@@ -393,6 +399,22 @@ var Service = class {
|
|
|
393
399
|
});
|
|
394
400
|
return true;
|
|
395
401
|
}
|
|
402
|
+
commandGuessHelper(commands, currentCmd) {
|
|
403
|
+
const altCmds = commands.filter((cmd) => {
|
|
404
|
+
return import_utils.fastestLevenshtein.distance(currentCmd, cmd) < currentCmd.length * 0.6 && currentCmd !== cmd;
|
|
405
|
+
});
|
|
406
|
+
const printHelper = altCmds.slice(0, 3).map((cmd) => {
|
|
407
|
+
return ` - ${import_utils.chalk.green(cmd)}`;
|
|
408
|
+
}).join("\n");
|
|
409
|
+
if (altCmds.length) {
|
|
410
|
+
console.log();
|
|
411
|
+
console.log([
|
|
412
|
+
import_utils.chalk.cyan(altCmds.length === 1 ? "Did you mean this command ?" : "Did you mean one of these commands ?"),
|
|
413
|
+
printHelper
|
|
414
|
+
].join("\n"));
|
|
415
|
+
console.log();
|
|
416
|
+
}
|
|
417
|
+
}
|
|
396
418
|
};
|
|
397
419
|
// Annotate the CommonJS export names for ESM import in node:
|
|
398
420
|
0 && (module.exports = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umijs/core",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.28",
|
|
4
4
|
"homepage": "https://github.com/umijs/umi/tree/master/packages/core#readme",
|
|
5
5
|
"bugs": "https://github.com/umijs/umi/issues",
|
|
6
6
|
"repository": {
|
|
@@ -21,8 +21,8 @@
|
|
|
21
21
|
"test": "umi-scripts jest-turbo"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@umijs/bundler-utils": "4.0.
|
|
25
|
-
"@umijs/utils": "4.0.
|
|
24
|
+
"@umijs/bundler-utils": "4.0.28",
|
|
25
|
+
"@umijs/utils": "4.0.28"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"dotenv": "16.0.0",
|