@umijs/core 4.0.0-canary.20221020.1 → 4.0.0-canary.20221025.1

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.
@@ -97,6 +97,7 @@ export declare class Service {
97
97
  plugins: Plugin[];
98
98
  }): Promise<any>;
99
99
  isPluginEnable(hook: Hook | string): boolean;
100
+ commandGuessHelper(commands: string[], currentCmd: string): void;
100
101
  }
101
102
  export interface IServicePluginAPI {
102
103
  appData: typeof Service.prototype.appData;
@@ -223,7 +223,10 @@ var Service = class {
223
223
  await this.initPlugin({ plugin: plugins.shift(), plugins });
224
224
  }
225
225
  const command = this.commands[name];
226
- (0, import_assert.default)(command, `Invalid command ${name}, it's not registered.`);
226
+ if (!command) {
227
+ this.commandGuessHelper(Object.keys(this.commands), name);
228
+ throw Error(`Invalid command ${import_utils.chalk.red(name)}, it's not registered.`);
229
+ }
227
230
  for (const id of Object.keys(this.plugins)) {
228
231
  const { config: config2, key } = this.plugins[id];
229
232
  if (config2.schema)
@@ -393,6 +396,22 @@ var Service = class {
393
396
  });
394
397
  return true;
395
398
  }
399
+ commandGuessHelper(commands, currentCmd) {
400
+ const altCmds = commands.filter((cmd) => {
401
+ return import_utils.fastestLevenshtein.distance(currentCmd, cmd) < currentCmd.length * 0.6 && currentCmd !== cmd;
402
+ });
403
+ const printHelper = altCmds.slice(0, 3).map((cmd) => {
404
+ return ` - ${import_utils.chalk.green(cmd)}`;
405
+ }).join("\n");
406
+ if (altCmds.length) {
407
+ console.log();
408
+ console.log([
409
+ import_utils.chalk.cyan(altCmds.length === 1 ? "Did you mean this command ?" : "Did you mean one of these commands ?"),
410
+ printHelper
411
+ ].join("\n"));
412
+ console.log();
413
+ }
414
+ }
396
415
  };
397
416
  // Annotate the CommonJS export names for ESM import in node:
398
417
  0 && (module.exports = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umijs/core",
3
- "version": "4.0.0-canary.20221020.1",
3
+ "version": "4.0.0-canary.20221025.1",
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.0-canary.20221020.1",
25
- "@umijs/utils": "4.0.0-canary.20221020.1"
24
+ "@umijs/bundler-utils": "4.0.0-canary.20221025.1",
25
+ "@umijs/utils": "4.0.0-canary.20221025.1"
26
26
  },
27
27
  "devDependencies": {
28
28
  "dotenv": "16.0.0",