@midwayjs/commander 4.0.1-beta.1 → 4.0.2

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.
@@ -8,6 +8,7 @@ export declare class EnquirerService {
8
8
  prompt<T extends PromptResult = PromptResult>(questionSet: string, initialAnswers?: PromptResult): Promise<T>;
9
9
  prompt<T extends PromptResult = PromptResult>(questionSet: QuestionSetModule, initialAnswers?: PromptResult): Promise<T>;
10
10
  private resolveQuestionSetModule;
11
+ private ensureQuestionSetDefinition;
11
12
  private buildQuestions;
12
13
  private applyQuestionFor;
13
14
  private runQuestions;
@@ -18,6 +18,7 @@ let EnquirerService = class EnquirerService {
18
18
  async prompt(questionSet, initialAnswers = {}) {
19
19
  // Resolve question set by name or class reference.
20
20
  const questionSetModule = this.resolveQuestionSetModule(questionSet);
21
+ this.ensureQuestionSetDefinition(questionSetModule);
21
22
  const questionSetInstance = (await this.applicationContext.getAsync(questionSetModule));
22
23
  // Build enquirer questions from decorators.
23
24
  const questions = this.buildQuestions(questionSetModule, questionSetInstance);
@@ -38,6 +39,15 @@ let EnquirerService = class EnquirerService {
38
39
  }
39
40
  throw new core_1.MidwayCommonError(`QuestionSet "${questionSetName}" not found`);
40
41
  }
42
+ ensureQuestionSetDefinition(questionSetModule) {
43
+ const providerId = core_1.DecoratorManager.getProviderUUId(questionSetModule);
44
+ if (!providerId) {
45
+ throw new core_1.MidwayCommonError(`QuestionSet "${questionSetModule.name}" is missing a provider id`);
46
+ }
47
+ if (!this.applicationContext.hasDefinition(providerId)) {
48
+ this.applicationContext.bindClass(questionSetModule);
49
+ }
50
+ }
41
51
  buildQuestions(module, instance) {
42
52
  const questionMetaList = core_1.MetadataManager.getMetadata(question_1.CLI_QUESTION_KEY, module) || [];
43
53
  const questionForMetaList = core_1.MetadataManager.getMetadata(question_1.CLI_QUESTION_FOR_KEY, module) || [];
package/dist/framework.js CHANGED
@@ -59,6 +59,7 @@ let MidwayCommanderFramework = class MidwayCommanderFramework extends core_1.Bas
59
59
  return;
60
60
  }
61
61
  this.logger.error(err);
62
+ process.stderr.write(`${err instanceof Error ? (err.stack ?? err.message) : String(err)}\n`);
62
63
  process.exit(1);
63
64
  }
64
65
  : undefined);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@midwayjs/commander",
3
- "version": "4.0.1-beta.1",
3
+ "version": "4.0.2",
4
4
  "description": "Midway Commander Framework",
5
5
  "main": "dist/index.js",
6
6
  "typings": "index.d.ts",
@@ -23,16 +23,16 @@
23
23
  "lint": "mwts check"
24
24
  },
25
25
  "dependencies": {
26
- "@midwayjs/core": "^4.0.1-beta.1",
26
+ "@midwayjs/core": "^4.0.2",
27
27
  "commander": "14.0.3",
28
28
  "enquirer": "2.4.1"
29
29
  },
30
30
  "devDependencies": {
31
- "@midwayjs/mock": "^4.0.1-beta.1"
31
+ "@midwayjs/mock": "^4.0.2"
32
32
  },
33
33
  "engines": {
34
34
  "node": ">=20"
35
35
  },
36
36
  "license": "MIT",
37
- "gitHead": "539d5305896972d43fda36d0c9758e77d3b5adbe"
37
+ "gitHead": "3a141047fcf2857cdfba761f79210d1b3327ad47"
38
38
  }