task-script-support-cli 0.2.3 → 0.2.4
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/package.json +2 -1
- package/dist/src/commands/about.d.ts +2 -2
- package/dist/src/commands/about.d.ts.map +1 -1
- package/dist/src/commands/about.js +2 -2
- package/dist/src/commands/about.js.map +1 -1
- package/dist/src/commands/configure.d.ts +8 -0
- package/dist/src/commands/configure.d.ts.map +1 -0
- package/dist/src/commands/configure.js +25 -0
- package/dist/src/commands/configure.js.map +1 -0
- package/dist/src/commands/gen.d.ts +8 -8
- package/dist/src/commands/gen.d.ts.map +1 -1
- package/dist/src/commands/gen.js +9 -9
- package/dist/src/commands/gen.js.map +1 -1
- package/dist/src/commands/new.d.ts +2 -2
- package/dist/src/commands/new.d.ts.map +1 -1
- package/dist/src/commands/new.js +2 -2
- package/dist/src/commands/new.js.map +1 -1
- package/dist/src/index.js +4 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/services/file-service.d.ts +3 -1
- package/dist/src/services/file-service.d.ts.map +1 -1
- package/dist/src/services/file-service.js +22 -4
- package/dist/src/services/file-service.js.map +1 -1
- package/dist/src/services/log-service.d.ts +1 -0
- package/dist/src/services/log-service.d.ts.map +1 -1
- package/dist/src/services/log-service.js +7 -0
- package/dist/src/services/log-service.js.map +1 -1
- package/dist/src/services/project-service.d.ts +1 -1
- package/dist/src/services/project-service.d.ts.map +1 -1
- package/dist/src/services/project-service.js +5 -3
- package/dist/src/services/project-service.js.map +1 -1
- package/dist/src/services/prompt-service.d.ts +7 -0
- package/dist/src/services/prompt-service.d.ts.map +1 -1
- package/dist/src/services/prompt-service.js +16 -3
- package/dist/src/services/prompt-service.js.map +1 -1
- package/dist/src/tasks/configure.d.ts +44 -0
- package/dist/src/tasks/configure.d.ts.map +1 -0
- package/dist/src/tasks/configure.js +102 -0
- package/dist/src/tasks/configure.js.map +1 -0
- package/dist/src/tasks/create-new-project.d.ts +1 -1
- package/dist/src/tasks/create-new-project.js +1 -1
- package/dist/src/tasks/{generate-command.d.ts → generate/generate-command.d.ts} +6 -6
- package/dist/src/tasks/generate/generate-command.d.ts.map +1 -0
- package/dist/src/tasks/{generate-command.js → generate/generate-command.js} +10 -10
- package/dist/src/tasks/generate/generate-command.js.map +1 -0
- package/dist/src/tasks/{generate-service.d.ts → generate/generate-service.d.ts} +4 -4
- package/dist/src/tasks/generate/generate-service.d.ts.map +1 -0
- package/dist/src/tasks/{generate-service.js → generate/generate-service.js} +7 -7
- package/dist/src/tasks/generate/generate-service.js.map +1 -0
- package/dist/src/tasks/{generate-task.d.ts → generate/generate-task.d.ts} +4 -4
- package/dist/src/tasks/generate/generate-task.d.ts.map +1 -0
- package/dist/src/tasks/{generate-task.js → generate/generate-task.js} +7 -7
- package/dist/src/tasks/generate/generate-task.js.map +1 -0
- package/dist/src/tasks/{select-gen-target-name.d.ts → generate/select-gen-target-name.d.ts} +3 -3
- package/dist/src/tasks/generate/select-gen-target-name.d.ts.map +1 -0
- package/dist/src/tasks/{select-gen-target-name.js → generate/select-gen-target-name.js} +6 -5
- package/dist/src/tasks/generate/select-gen-target-name.js.map +1 -0
- package/dist/src/tasks/generate/select-gen-target.d.ts +14 -0
- package/dist/src/tasks/generate/select-gen-target.d.ts.map +1 -0
- package/dist/src/tasks/{select-gen-target.js → generate/select-gen-target.js} +13 -11
- package/dist/src/tasks/generate/select-gen-target.js.map +1 -0
- package/dist/src/tasks/{print-about-information.d.ts → stdout/print-about-information.d.ts} +1 -1
- package/dist/src/tasks/stdout/print-about-information.d.ts.map +1 -0
- package/dist/src/tasks/{print-about-information.js → stdout/print-about-information.js} +2 -2
- package/dist/src/tasks/stdout/print-about-information.js.map +1 -0
- package/dist/src/tasks/stdout/print-banner.d.ts +12 -0
- package/dist/src/tasks/stdout/print-banner.d.ts.map +1 -0
- package/dist/src/tasks/{print-banner.js → stdout/print-banner.js} +4 -4
- package/dist/src/tasks/stdout/print-banner.js.map +1 -0
- package/dist/src/tasks/{print-generated-results.d.ts → stdout/print-generated-results.d.ts} +2 -2
- package/dist/src/tasks/stdout/print-generated-results.d.ts.map +1 -0
- package/dist/src/tasks/{print-generated-results.js → stdout/print-generated-results.js} +4 -3
- package/dist/src/tasks/stdout/print-generated-results.js.map +1 -0
- package/dist/src/tasks/sync-configuration.d.ts +6 -2
- package/dist/src/tasks/sync-configuration.d.ts.map +1 -1
- package/dist/src/tasks/sync-configuration.js +27 -22
- package/dist/src/tasks/sync-configuration.js.map +1 -1
- package/dist/src/wrappers/app-task.d.ts +1 -0
- package/dist/src/wrappers/app-task.d.ts.map +1 -1
- package/dist/src/wrappers/app-task.js +4 -0
- package/dist/src/wrappers/app-task.js.map +1 -1
- package/package.json +2 -1
- package/src/commands/about.ts +2 -2
- package/src/commands/configure.ts +10 -0
- package/src/commands/gen.ts +8 -8
- package/src/commands/new.ts +2 -2
- package/src/index.ts +5 -0
- package/src/services/file-service.ts +28 -4
- package/src/services/log-service.ts +8 -0
- package/src/services/project-service.ts +6 -3
- package/src/services/prompt-service.ts +14 -3
- package/src/tasks/configure.ts +105 -0
- package/src/tasks/create-new-project.ts +1 -1
- package/src/tasks/{generate-command.ts → generate/generate-command.ts} +10 -14
- package/src/tasks/{generate-service.ts → generate/generate-service.ts} +7 -7
- package/src/tasks/{generate-task.ts → generate/generate-task.ts} +7 -7
- package/src/tasks/{select-gen-target-name.ts → generate/select-gen-target-name.ts} +6 -6
- package/src/tasks/{select-gen-target.ts → generate/select-gen-target.ts} +10 -8
- package/src/tasks/{print-about-information.ts → stdout/print-about-information.ts} +2 -2
- package/src/tasks/{print-banner.ts → stdout/print-banner.ts} +4 -4
- package/src/tasks/{print-generated-results.ts → stdout/print-generated-results.ts} +4 -3
- package/src/tasks/sync-configuration.ts +31 -23
- package/src/wrappers/app-task.ts +5 -0
- package/dist/src/tasks/generate-command.d.ts.map +0 -1
- package/dist/src/tasks/generate-command.js.map +0 -1
- package/dist/src/tasks/generate-service.d.ts.map +0 -1
- package/dist/src/tasks/generate-service.js.map +0 -1
- package/dist/src/tasks/generate-task.d.ts.map +0 -1
- package/dist/src/tasks/generate-task.js.map +0 -1
- package/dist/src/tasks/print-about-information.d.ts.map +0 -1
- package/dist/src/tasks/print-about-information.js.map +0 -1
- package/dist/src/tasks/print-banner.d.ts +0 -12
- package/dist/src/tasks/print-banner.d.ts.map +0 -1
- package/dist/src/tasks/print-banner.js.map +0 -1
- package/dist/src/tasks/print-generated-results.d.ts.map +0 -1
- package/dist/src/tasks/print-generated-results.js.map +0 -1
- package/dist/src/tasks/select-gen-target-name.d.ts.map +0 -1
- package/dist/src/tasks/select-gen-target-name.js.map +0 -1
- package/dist/src/tasks/select-gen-target.d.ts +0 -14
- package/dist/src/tasks/select-gen-target.d.ts.map +0 -1
- package/dist/src/tasks/select-gen-target.js.map +0 -1
|
@@ -12,7 +12,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.SyncConfiguration = void 0;
|
|
16
15
|
const tsyringe_1 = require("tsyringe");
|
|
17
16
|
const app_task_1 = require("../wrappers/app-task");
|
|
18
17
|
const prompt_service_1 = require("../services/prompt-service");
|
|
@@ -20,6 +19,9 @@ const chalk_1 = __importDefault(require("chalk"));
|
|
|
20
19
|
const cache_service_1 = require("../services/cache-service");
|
|
21
20
|
const state_1 = require("../types/state");
|
|
22
21
|
const util_service_1 = require("../services/util-service");
|
|
22
|
+
/**
|
|
23
|
+
* Syncs cache to project state
|
|
24
|
+
*/
|
|
23
25
|
let SyncConfiguration = class SyncConfiguration extends app_task_1.AppTask {
|
|
24
26
|
promptService;
|
|
25
27
|
cacheService;
|
|
@@ -44,25 +46,24 @@ let SyncConfiguration = class SyncConfiguration extends app_task_1.AppTask {
|
|
|
44
46
|
project = { ...this.state.data.project, ...cachedProject };
|
|
45
47
|
}
|
|
46
48
|
// get target destination if not cached yet
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
this.
|
|
52
|
-
|
|
53
|
-
case state_1.GenTargetType.Service:
|
|
54
|
-
project.serviceDestination =
|
|
55
|
-
project.serviceDestination || (await this.getDestination("service"));
|
|
56
|
-
this.logDestination(project.serviceDestination);
|
|
57
|
-
break;
|
|
58
|
-
case state_1.GenTargetType.Task:
|
|
59
|
-
project.taskDestination =
|
|
60
|
-
project.taskDestination || (await this.getDestination("task"));
|
|
61
|
-
this.logDestination(project.taskDestination);
|
|
62
|
-
break;
|
|
63
|
-
default:
|
|
64
|
-
throw new Error(`Uknown target type: ${this.state.data.genTargetType}`);
|
|
49
|
+
if (this.state.data.genTargetType) {
|
|
50
|
+
const targetType = this.state.data.genTargetType;
|
|
51
|
+
const destinationKey = `${targetType}Destination`;
|
|
52
|
+
project[destinationKey] =
|
|
53
|
+
project[destinationKey] || (await this.getDestination(targetType));
|
|
54
|
+
this.logDestination(project[destinationKey]);
|
|
65
55
|
}
|
|
56
|
+
// attempt to determine others config without prompting
|
|
57
|
+
const isPassive = true;
|
|
58
|
+
project.commandDestination =
|
|
59
|
+
project.commandDestination ||
|
|
60
|
+
(await this.getDestination(state_1.GenTargetType.Command, isPassive));
|
|
61
|
+
project.serviceDestination =
|
|
62
|
+
project.serviceDestination ||
|
|
63
|
+
(await this.getDestination(state_1.GenTargetType.Service, isPassive));
|
|
64
|
+
project.taskDestination =
|
|
65
|
+
project.taskDestination ||
|
|
66
|
+
(await this.getDestination(state_1.GenTargetType.Task, isPassive));
|
|
66
67
|
// cache any changes
|
|
67
68
|
await this.cacheService.writeProject(project);
|
|
68
69
|
this.setData({ project });
|
|
@@ -80,15 +81,19 @@ let SyncConfiguration = class SyncConfiguration extends app_task_1.AppTask {
|
|
|
80
81
|
* otherwise the user is prompted to select one from the found folders.
|
|
81
82
|
*
|
|
82
83
|
* @param keyType the type of destination to resolve
|
|
84
|
+
* @param isPassive whether or not to skip prompting for user input
|
|
83
85
|
* @returns the path of the resolved destination
|
|
84
86
|
*/
|
|
85
|
-
async getDestination(keyType) {
|
|
87
|
+
async getDestination(keyType, isPassive = false) {
|
|
86
88
|
const foldersKey = `${keyType}Folders`;
|
|
87
89
|
const nonTestFolders = this.state.data.project[foldersKey].filter((folder) => !(folder || "").includes("/tests/"));
|
|
88
90
|
// if we only have one folder found, use this as the destination
|
|
89
91
|
if (nonTestFolders.length === 1) {
|
|
90
92
|
return nonTestFolders[0] || "";
|
|
91
93
|
}
|
|
94
|
+
if (isPassive) {
|
|
95
|
+
return undefined;
|
|
96
|
+
}
|
|
92
97
|
// otherwise prompt to pick one
|
|
93
98
|
const userSelection = await this.promptService.select(`Multiple folders found. Select correct ${chalk_1.default.blueBright(this.utilService.titleize(keyType))} folder`, nonTestFolders);
|
|
94
99
|
this.logger.debug(chalk_1.default.blackBright(`caching for next time`));
|
|
@@ -106,11 +111,11 @@ let SyncConfiguration = class SyncConfiguration extends app_task_1.AppTask {
|
|
|
106
111
|
}
|
|
107
112
|
}
|
|
108
113
|
};
|
|
109
|
-
|
|
110
|
-
exports.SyncConfiguration = SyncConfiguration = __decorate([
|
|
114
|
+
SyncConfiguration = __decorate([
|
|
111
115
|
(0, tsyringe_1.autoInjectable)(),
|
|
112
116
|
__metadata("design:paramtypes", [prompt_service_1.PromptService,
|
|
113
117
|
cache_service_1.CacheService,
|
|
114
118
|
util_service_1.UtilService])
|
|
115
119
|
], SyncConfiguration);
|
|
120
|
+
exports.default = SyncConfiguration;
|
|
116
121
|
//# sourceMappingURL=sync-configuration.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sync-configuration.js","sourceRoot":"./src/","sources":["src/tasks/sync-configuration.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"sync-configuration.js","sourceRoot":"./src/","sources":["src/tasks/sync-configuration.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,uCAA0C;AAC1C,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AE,EAAE,CAAC,CAAC,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC;QAElE,gEAAgE;QAChE,IAAI,cAAc,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAChC,OAAO,cAAc,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;QACjC,CAAC;QAED,IAAI,SAAS,EAAE,CAAC;YACd,OAAO,SAAS,CAAC;QACnB,CAAC;QAED,+BAA+B;QAC/B,MAAM,aAAa,GAAW,MAAM,IAAI,CAAC,aAAa,CAAC,MAAM,CAC3D,0CAA0C,eAAK,CAAC,UAAU,CAAC,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,SAAS,EACvG,cAAc,CACf,CAAC;QACF,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,eAAK,CAAC,WAAW,CAAC,uBAAuB,CAAC,CAAC,CAAC;QAC9D,OAAO,aAAa,CAAC;IACvB,CAAC;IAED;;OAEG;IACH,WAAW;QACT,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC;YACjE,MAAM,IAAI,KAAK,CACb,gGAAgG,CACjG,CAAC;QACJ,CAAC;QAED,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,aAAa,EAAE,CAAC;YACnC,MAAM,IAAI,KAAK,CACb,6FAA6F,CAC9F,CAAC;QACJ,CAAC;IACH,CAAC;CACF,CAAA;AAnHoB,iBAAiB;IADrC,IAAA,yBAAc,GAAE;qCAKU,8BAAa;QACd,4BAAY;QACb,0BAAW;GANf,iBAAiB,CAmHrC;kBAnHoB,iBAAiB"}
|
|
@@ -14,6 +14,7 @@ export declare class AppTask extends Task<AppStateData, CLIArg[]> {
|
|
|
14
14
|
constructor(_logService?: LogService | undefined, _argService?: ArgService | undefined, _commandService?: CommandService<AppStateData, CLIArg[]> | undefined);
|
|
15
15
|
initialize(): Promise<void>;
|
|
16
16
|
run(state: AppState): Promise<Partial<AppState> | void>;
|
|
17
|
+
postRun(): Promise<void>;
|
|
17
18
|
setData(data: Partial<AppStateData>): AppState;
|
|
18
19
|
}
|
|
19
20
|
//# sourceMappingURL=app-task.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app-task.d.ts","sourceRoot":"./src/","sources":["src/wrappers/app-task.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC7D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAE/C,qBACa,OAAQ,SAAQ,IAAI,CAAC,YAAY,EAAE,MAAM,EAAE,CAAC;IAgB9C,WAAW,CAAC,EAAE,UAAU;IACxB,WAAW,CAAC,EAAE,UAAU;IACxB,eAAe,CAAC,EAAE,cAAc,CAAC,YAAY,EAAE,MAAM,EAAE,CAAC;IAjBjE,KAAK,EAAE,QAAQ,CAIb;IACF,UAAU,EAAE,MAAM,CAAM;IAExB,IAAI,UAAU,eAEb;IACD,IAAI,MAAM,IAAI,UAAU,CAEvB;gBAGQ,WAAW,CAAC,EAAE,UAAU,YAAA,EACxB,WAAW,CAAC,EAAE,UAAU,YAAA,EACxB,eAAe,CAAC,EAAE,cAAc,CAAC,YAAY,EAAE,MAAM,EAAE,CAAC,YAAA;IAM3D,UAAU;IAOV,GAAG,CAAC,KAAK,EAAE,QAAQ,GAAG,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"app-task.d.ts","sourceRoot":"./src/","sources":["src/wrappers/app-task.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC7D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAE/C,qBACa,OAAQ,SAAQ,IAAI,CAAC,YAAY,EAAE,MAAM,EAAE,CAAC;IAgB9C,WAAW,CAAC,EAAE,UAAU;IACxB,WAAW,CAAC,EAAE,UAAU;IACxB,eAAe,CAAC,EAAE,cAAc,CAAC,YAAY,EAAE,MAAM,EAAE,CAAC;IAjBjE,KAAK,EAAE,QAAQ,CAIb;IACF,UAAU,EAAE,MAAM,CAAM;IAExB,IAAI,UAAU,eAEb;IACD,IAAI,MAAM,IAAI,UAAU,CAEvB;gBAGQ,WAAW,CAAC,EAAE,UAAU,YAAA,EACxB,WAAW,CAAC,EAAE,UAAU,YAAA,EACxB,eAAe,CAAC,EAAE,cAAc,CAAC,YAAY,EAAE,MAAM,EAAE,CAAC,YAAA;IAM3D,UAAU;IAOV,GAAG,CAAC,KAAK,EAAE,QAAQ,GAAG,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG,IAAI,CAAC;IAKvD,OAAO;IAIb,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,YAAY,CAAC;CAIpC"}
|
|
@@ -46,6 +46,10 @@ let AppTask = class AppTask extends task_script_support_1.Task {
|
|
|
46
46
|
async run(state) {
|
|
47
47
|
throw new Error(`run not implemented (${state.id})`);
|
|
48
48
|
}
|
|
49
|
+
//@override
|
|
50
|
+
async postRun() {
|
|
51
|
+
await this.logger.flush();
|
|
52
|
+
}
|
|
49
53
|
setData(data) {
|
|
50
54
|
this.state = this._commandService.setData(this.state, data);
|
|
51
55
|
return this.state;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app-task.js","sourceRoot":"./src/","sources":["src/wrappers/app-task.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,uCAA0C;AAC1C,6DAA2D;AAC3D,yDAAqD;AACrD,yDAAqD;AAK9C,IAAM,OAAO,GAAb,MAAM,OAAQ,SAAQ,0BAA4B;IAgB9C;IACA;IACA;IAjBT,KAAK,GAAa;QAChB,EAAE,EAAE,eAAe;QACnB,IAAI,EAAE,EAAE;QACR,IAAI,EAAE,EAAE;KACT,CAAC;IACF,UAAU,GAAW,EAAE,CAAC;IAExB,IAAI,UAAU;QACZ,OAAO,IAAI,CAAC,WAAY,CAAC;IAC3B,CAAC;IACD,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,WAAY,CAAC;IAC3B,CAAC;IAED,YACS,WAAwB,EACxB,WAAwB,EACxB,eAAwD;QAE/D,KAAK,EAAE,CAAC;QAJD,gBAAW,GAAX,WAAW,CAAa;QACxB,gBAAW,GAAX,WAAW,CAAa;QACxB,oBAAe,GAAf,eAAe,CAAyC;IAGjE,CAAC;IAED,WAAW;IACX,KAAK,CAAC,UAAU;QACd,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;YACpB,IAAI,CAAC,MAAO,CAAC,SAAS,CAAC,GAAG,IAAI,CAAC,UAAU,MAAM,CAAC,CAAC;QACnD,CAAC;IACH,CAAC;IAED,WAAW;IACX,KAAK,CAAC,GAAG,CAAC,KAAe;QACvB,MAAM,IAAI,KAAK,CAAC,wBAAwB,KAAK,CAAC,EAAE,GAAG,CAAC,CAAC;IACvD,CAAC;IAED,OAAO,CAAC,IAA2B;QACjC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,eAAgB,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;QAC7D,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,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QAC7D,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;CACF,CAAA;AA5CY,0BAAO;kBAAP,OAAO;IADnB,IAAA,yBAAc,GAAE;qCAiBQ,wBAAU;QACV,wBAAU;QACN,oCAAc;GAlB9B,OAAO,CA4CnB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "task-script-support-cli",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.4",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"preferGlobal": true,
|
|
@@ -37,6 +37,7 @@
|
|
|
37
37
|
"dotenv": "^17.2.3",
|
|
38
38
|
"figlet": "^1.9.4",
|
|
39
39
|
"immutable": "^5.1.4",
|
|
40
|
+
"inquirer-sortable-checkbox": "^1.0.1",
|
|
40
41
|
"lodash": "^4.18.1",
|
|
41
42
|
"node-persist": "^4.0.4",
|
|
42
43
|
"reflect-metadata": "^0.2.2",
|
package/src/commands/about.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { singleton } from "tsyringe";
|
|
2
2
|
import { Command } from "../wrappers/command";
|
|
3
|
-
import PrintAboutInformation from "../tasks/print-about-information";
|
|
4
|
-
import PrintBanner from "../tasks/print-banner";
|
|
3
|
+
import PrintAboutInformation from "../tasks/stdout/print-about-information";
|
|
4
|
+
import PrintBanner from "../tasks/stdout/print-banner";
|
|
5
5
|
|
|
6
6
|
@singleton()
|
|
7
7
|
export class AboutCommand extends Command {
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { singleton } from "tsyringe";
|
|
2
|
+
import { Command } from "../wrappers/command";
|
|
3
|
+
import CheckEnv from "../tasks/check-env";
|
|
4
|
+
import ConfigureCache from "../tasks/configure";
|
|
5
|
+
import PrintBanner from "../tasks/stdout/print-banner";
|
|
6
|
+
|
|
7
|
+
@singleton()
|
|
8
|
+
export class ConfigureCommand extends Command {
|
|
9
|
+
tasks = [PrintBanner, CheckEnv, ConfigureCache];
|
|
10
|
+
}
|
package/src/commands/gen.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { singleton } from "tsyringe";
|
|
2
2
|
import { Command } from "../wrappers/command";
|
|
3
3
|
import CheckEnvironment from "../tasks/check-env";
|
|
4
|
-
import PrintBanner from "../tasks/print-banner";
|
|
5
|
-
import SelectGenTarget from "../tasks/select-gen-target";
|
|
6
|
-
import GenerateService from "../tasks/generate-service";
|
|
7
|
-
import GenerateCommand from "../tasks/generate-command";
|
|
8
|
-
import GenerateTask from "../tasks/generate-task";
|
|
9
|
-
import PrintGeneratedResults from "../tasks/print-generated-results";
|
|
10
|
-
import
|
|
11
|
-
import SelectGenTargetName from "../tasks/select-gen-target-name";
|
|
4
|
+
import PrintBanner from "../tasks/stdout/print-banner";
|
|
5
|
+
import SelectGenTarget from "../tasks/generate/select-gen-target";
|
|
6
|
+
import GenerateService from "../tasks/generate/generate-service";
|
|
7
|
+
import GenerateCommand from "../tasks/generate/generate-command";
|
|
8
|
+
import GenerateTask from "../tasks/generate/generate-task";
|
|
9
|
+
import PrintGeneratedResults from "../tasks/stdout/print-generated-results";
|
|
10
|
+
import SyncConfiguration from "../tasks/sync-configuration";
|
|
11
|
+
import SelectGenTargetName from "../tasks/generate/select-gen-target-name";
|
|
12
12
|
|
|
13
13
|
@singleton()
|
|
14
14
|
export class GenCommand extends Command {
|
package/src/commands/new.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { singleton } from "tsyringe";
|
|
2
2
|
import { Command } from "../wrappers/command";
|
|
3
|
-
import PrintBanner from "../tasks/print-banner";
|
|
3
|
+
import PrintBanner from "../tasks/stdout/print-banner";
|
|
4
4
|
import CreateNewProject from "../tasks/create-new-project";
|
|
5
|
-
import PrintGeneratedResults from "../tasks/print-generated-results";
|
|
5
|
+
import PrintGeneratedResults from "../tasks/stdout/print-generated-results";
|
|
6
6
|
|
|
7
7
|
@singleton()
|
|
8
8
|
export class NewCommand extends Command {
|
package/src/index.ts
CHANGED
|
@@ -14,6 +14,7 @@ UtilService.initializeDependencies();
|
|
|
14
14
|
import { AboutCommand } from "./commands/about";
|
|
15
15
|
import { GenCommand } from "./commands/gen";
|
|
16
16
|
import { NewCommand } from "./commands/new";
|
|
17
|
+
import { ConfigureCommand } from "./commands/configure";
|
|
17
18
|
|
|
18
19
|
const { program } = commander;
|
|
19
20
|
const name = UtilService.getAppName();
|
|
@@ -42,4 +43,8 @@ program
|
|
|
42
43
|
// .option("-d, --dest", "target destination path")
|
|
43
44
|
.action(container.resolve(NewCommand).handler);
|
|
44
45
|
|
|
46
|
+
program
|
|
47
|
+
.command("configure")
|
|
48
|
+
.action(container.resolve(ConfigureCommand).handler);
|
|
49
|
+
|
|
45
50
|
program.parse(process.argv);
|
|
@@ -23,6 +23,7 @@ export class FileService {
|
|
|
23
23
|
return path.resolve(relativePath);
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
+
getFilename = (somePath: string) => path.basename(somePath);
|
|
26
27
|
getFilenameNoExt(somePath: string) {
|
|
27
28
|
const filename = path.basename(somePath);
|
|
28
29
|
return filename.includes(".") ? filename.split(".")[0] || "" : filename;
|
|
@@ -32,7 +33,9 @@ export class FileService {
|
|
|
32
33
|
if (!fs.existsSync(dirPath) || !fs.statSync(dirPath).isDirectory()) {
|
|
33
34
|
throw new Error(`Directory not found: ${dirPath}`);
|
|
34
35
|
}
|
|
35
|
-
|
|
36
|
+
const files: string[] = [];
|
|
37
|
+
this.getFilesRecursively(dirPath, (file) => files.push(file));
|
|
38
|
+
return files;
|
|
36
39
|
}
|
|
37
40
|
|
|
38
41
|
getRunnerRootDir(): string {
|
|
@@ -73,7 +76,7 @@ export class FileService {
|
|
|
73
76
|
|
|
74
77
|
private findDirsByName(dirPath: string, dirNameSuffix: string): string[] {
|
|
75
78
|
const dirs: string[] = [];
|
|
76
|
-
this.
|
|
79
|
+
this.getDirectoriesRecursively(dirPath, (dir) => {
|
|
77
80
|
if (path.basename(dir).includes(dirNameSuffix) && !dirs.includes(dir)) {
|
|
78
81
|
dirs.push(dir);
|
|
79
82
|
}
|
|
@@ -81,15 +84,36 @@ export class FileService {
|
|
|
81
84
|
return dirs;
|
|
82
85
|
}
|
|
83
86
|
|
|
84
|
-
private
|
|
87
|
+
private getDirectoriesRecursively(
|
|
88
|
+
dirPath: string,
|
|
89
|
+
callback: (dir: string) => void,
|
|
90
|
+
) {
|
|
85
91
|
const entries = fs.readdirSync(dirPath, { withFileTypes: true });
|
|
86
92
|
for (const entry of entries) {
|
|
87
93
|
const fullPath = path.join(dirPath, entry.name);
|
|
88
94
|
if (entry.isDirectory() && !ignoredDirectories.has(entry.name)) {
|
|
89
|
-
this.
|
|
95
|
+
this.getDirectoriesRecursively(fullPath, callback);
|
|
90
96
|
} else {
|
|
91
97
|
callback(path.dirname(fullPath));
|
|
92
98
|
}
|
|
93
99
|
}
|
|
94
100
|
}
|
|
101
|
+
|
|
102
|
+
private getFilesRecursively(
|
|
103
|
+
dirPath: string,
|
|
104
|
+
callback: (dir: string) => void,
|
|
105
|
+
) {
|
|
106
|
+
const entries = fs.readdirSync(dirPath, { withFileTypes: true });
|
|
107
|
+
for (const entry of entries) {
|
|
108
|
+
if (ignoredDirectories.has(entry.name)) {
|
|
109
|
+
continue;
|
|
110
|
+
}
|
|
111
|
+
const fullPath = path.join(dirPath, entry.name);
|
|
112
|
+
if (entry.isDirectory()) {
|
|
113
|
+
this.getFilesRecursively(fullPath, callback);
|
|
114
|
+
} else {
|
|
115
|
+
callback(fullPath);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
95
119
|
}
|
|
@@ -17,6 +17,14 @@ export class LogService {
|
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
+
flush(): Promise<void> {
|
|
21
|
+
return new Promise((res, rej) => {
|
|
22
|
+
this.logger.flush((err?: Error) => {
|
|
23
|
+
return err ? rej(err) : res();
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
|
|
20
28
|
setPrefix(prefix: string) {
|
|
21
29
|
if (!LogService.ParentInstance) {
|
|
22
30
|
this.logger = this.pinoLogger.getLogger(prefix);
|
|
@@ -51,16 +51,19 @@ export class ProjectService {
|
|
|
51
51
|
* the first found convention or the default one if it can't be detected.
|
|
52
52
|
*
|
|
53
53
|
* @param existingFiles the files to check for a convention on.
|
|
54
|
-
* @returns
|
|
54
|
+
* @returns the first found case type convention or the default one
|
|
55
55
|
*/
|
|
56
56
|
getConvention(): CaseType {
|
|
57
57
|
const existingFiles: string[] = this.getSourceFiles();
|
|
58
58
|
|
|
59
|
-
if (!existingFiles || !existingFiles.length)
|
|
59
|
+
if (!existingFiles || !existingFiles.length) {
|
|
60
60
|
return ProjectService.defaults.convention;
|
|
61
|
+
}
|
|
62
|
+
|
|
61
63
|
let convention: CaseType | null = null;
|
|
62
64
|
for (const file of existingFiles) {
|
|
63
|
-
|
|
65
|
+
const filename = this.fileService.getFilename(file);
|
|
66
|
+
convention = this.utilService.detectCase(filename);
|
|
64
67
|
if (convention !== null) {
|
|
65
68
|
break;
|
|
66
69
|
}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { autoInjectable } from "tsyringe";
|
|
2
2
|
import { UtilService } from "./util-service";
|
|
3
3
|
|
|
4
|
+
import sortableCheckbox from "inquirer-sortable-checkbox";
|
|
5
|
+
|
|
4
6
|
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
5
|
-
const { search, input
|
|
7
|
+
const { search, input } = require("@inquirer/prompts");
|
|
6
8
|
|
|
7
9
|
@autoInjectable()
|
|
8
10
|
export class PromptService {
|
|
@@ -18,7 +20,7 @@ export class PromptService {
|
|
|
18
20
|
*/
|
|
19
21
|
async select(message: string, options: string[]) {
|
|
20
22
|
// wait for logging to catch up before prompting
|
|
21
|
-
await this.utilService.sleep(
|
|
23
|
+
await this.utilService.sleep(800);
|
|
22
24
|
|
|
23
25
|
const choices = options.map((opt) => ({ value: opt }));
|
|
24
26
|
|
|
@@ -37,7 +39,15 @@ export class PromptService {
|
|
|
37
39
|
return answer;
|
|
38
40
|
}
|
|
39
41
|
|
|
42
|
+
/**
|
|
43
|
+
* Get a simple input string from the user.
|
|
44
|
+
*
|
|
45
|
+
* @param message the message to prompt the user with
|
|
46
|
+
* @param required whether or not to throw an error on empty input.
|
|
47
|
+
* @returns the read input string or undefined if not required
|
|
48
|
+
*/
|
|
40
49
|
async getInput(message: string, required: boolean = true) {
|
|
50
|
+
await this.utilService.sleep(800);
|
|
41
51
|
return await input({ message, required });
|
|
42
52
|
}
|
|
43
53
|
|
|
@@ -52,7 +62,8 @@ export class PromptService {
|
|
|
52
62
|
message: string,
|
|
53
63
|
options: { name: string; value: T }[],
|
|
54
64
|
): Promise<T[]> {
|
|
55
|
-
|
|
65
|
+
await this.utilService.sleep(800);
|
|
66
|
+
return await sortableCheckbox({
|
|
56
67
|
message,
|
|
57
68
|
choices: options,
|
|
58
69
|
});
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import chalk from "chalk";
|
|
2
|
+
import { AppTask } from "../wrappers/app-task";
|
|
3
|
+
import { autoInjectable } from "tsyringe";
|
|
4
|
+
import { GenTargetType } from "../types/state";
|
|
5
|
+
import { ProjectConfig, ProjectData } from "../types/project";
|
|
6
|
+
import { PromptService } from "../services/prompt-service";
|
|
7
|
+
import { CacheService } from "../services/cache-service";
|
|
8
|
+
import { UtilService } from "../services/util-service";
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Configures the Project Settings Cache in a Proactive way.
|
|
12
|
+
* Prompts for each resource type destination if not
|
|
13
|
+
* yet configured and multiple directories are found.
|
|
14
|
+
*/
|
|
15
|
+
@autoInjectable()
|
|
16
|
+
export default class ConfigureCache extends AppTask {
|
|
17
|
+
loggerName = "Configure";
|
|
18
|
+
|
|
19
|
+
constructor(
|
|
20
|
+
private promptService: PromptService,
|
|
21
|
+
private cacheService: CacheService,
|
|
22
|
+
private utilService: UtilService,
|
|
23
|
+
) {
|
|
24
|
+
super();
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Configure each resource type's output destination directory. Allows
|
|
29
|
+
* the user to reset these values if their project has changed since
|
|
30
|
+
* last cached.
|
|
31
|
+
*/
|
|
32
|
+
async run() {
|
|
33
|
+
this.logger.info(chalk.blueBright("Checking Configuration"));
|
|
34
|
+
const project: ProjectConfig & ProjectData = this.state.data.project!;
|
|
35
|
+
|
|
36
|
+
project.commandDestination = await this.getDestination(
|
|
37
|
+
GenTargetType.Command,
|
|
38
|
+
);
|
|
39
|
+
project.serviceDestination = await this.getDestination(
|
|
40
|
+
GenTargetType.Service,
|
|
41
|
+
);
|
|
42
|
+
project.taskDestination = await this.getDestination(GenTargetType.Task);
|
|
43
|
+
|
|
44
|
+
this.logger.debug(chalk.blackBright(`Saving configuration`));
|
|
45
|
+
await this.cacheService.writeProject(project);
|
|
46
|
+
this.setData({ project });
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Prints the target destination path string
|
|
51
|
+
*
|
|
52
|
+
* @param dest the destination path to log
|
|
53
|
+
* @returns
|
|
54
|
+
*/
|
|
55
|
+
logDestination = (dest: string = "") =>
|
|
56
|
+
this.logger.debug(`Destination: ${chalk.magentaBright(dest)}`);
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Gets the destination path for generating resources by resource type.
|
|
60
|
+
* If only one resource destination folder was found it is returned
|
|
61
|
+
* otherwise the user is prompted to select one from the found folders.
|
|
62
|
+
*
|
|
63
|
+
* @param keyType the type of destination to resolve
|
|
64
|
+
* @returns the path of the resolved destination
|
|
65
|
+
*/
|
|
66
|
+
async getDestination(keyType: "command" | "task" | "service") {
|
|
67
|
+
const foldersKey: keyof typeof this.state.data.project =
|
|
68
|
+
`${keyType}Folders` as keyof typeof this.state.data.project;
|
|
69
|
+
|
|
70
|
+
const nonTestFolders: string[] = (
|
|
71
|
+
this.state.data.project![foldersKey] as string[]
|
|
72
|
+
).filter((folder: string) => !(folder || "").includes("/tests/"));
|
|
73
|
+
|
|
74
|
+
// if we only have one folder found, use this as the destination
|
|
75
|
+
const titleizedKey = chalk.blueBright(this.utilService.titleize(keyType));
|
|
76
|
+
if (nonTestFolders.length === 1) {
|
|
77
|
+
this.logger.debug(`Configuring single found ${titleizedKey} folder`);
|
|
78
|
+
return nonTestFolders[0] || "";
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// otherwise prompt to pick one
|
|
82
|
+
await this.logger.flush();
|
|
83
|
+
const userSelection: string = await this.promptService.select(
|
|
84
|
+
`Multiple folders found. Select correct ${titleizedKey} folder`,
|
|
85
|
+
nonTestFolders,
|
|
86
|
+
);
|
|
87
|
+
return userSelection;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
//@override
|
|
91
|
+
async preRun() {
|
|
92
|
+
this.verifyState();
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Check we have all the required state set
|
|
97
|
+
*/
|
|
98
|
+
verifyState() {
|
|
99
|
+
if (!this.state.data.project || !this.state.data.project.rootDir) {
|
|
100
|
+
throw new Error(
|
|
101
|
+
`Missing project rootDir! ${this.constructor.name} requires the CheckEnvironment task to be ran first.`,
|
|
102
|
+
);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import chalk from "chalk";
|
|
2
|
-
import { AppTask } from "
|
|
2
|
+
import { AppTask } from "../../wrappers/app-task";
|
|
3
3
|
import { autoInjectable } from "tsyringe";
|
|
4
|
-
import { AppState, GenTargetType } from "
|
|
5
|
-
import { FileService } from "
|
|
6
|
-
import { UtilService } from "
|
|
7
|
-
import { CaseType } from "
|
|
4
|
+
import { AppState, GenTargetType } from "../../types/state";
|
|
5
|
+
import { FileService } from "../../services/file-service";
|
|
6
|
+
import { UtilService } from "../../services/util-service";
|
|
7
|
+
import { CaseType } from "../../types/format";
|
|
8
8
|
import path from "path";
|
|
9
|
-
import { getCommandTemplate } from "
|
|
10
|
-
import { ProjectService } from "
|
|
11
|
-
import { PromptService } from "
|
|
9
|
+
import { getCommandTemplate } from "../../templates/command";
|
|
10
|
+
import { ProjectService } from "../../services/project-service";
|
|
11
|
+
import { PromptService } from "../../services/prompt-service";
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* Generates a new command class
|
|
@@ -96,6 +96,7 @@ export default class GenerateCommand extends AppTask {
|
|
|
96
96
|
);
|
|
97
97
|
|
|
98
98
|
this.logger.debug(`Found ${taskFiles.length} task files`);
|
|
99
|
+
await this.logger.flush();
|
|
99
100
|
|
|
100
101
|
// prompt for tasks to use in the new command
|
|
101
102
|
const pickedTasks = await this.promptService.pickMultiple(
|
|
@@ -114,8 +115,6 @@ export default class GenerateCommand extends AppTask {
|
|
|
114
115
|
return;
|
|
115
116
|
}
|
|
116
117
|
|
|
117
|
-
console.log(JSON.stringify(pickedTasks));
|
|
118
|
-
|
|
119
118
|
// add them to the map
|
|
120
119
|
for (const picked of pickedTasks) {
|
|
121
120
|
const filename = this.fileService.getFilenameNoExt(picked);
|
|
@@ -124,10 +123,7 @@ export default class GenerateCommand extends AppTask {
|
|
|
124
123
|
CaseType.PASCAL_CASE,
|
|
125
124
|
);
|
|
126
125
|
const relativeSource = this.state.data.project!.commandDestination!;
|
|
127
|
-
const relativeDest =
|
|
128
|
-
this.state.data.project.taskDestination,
|
|
129
|
-
picked,
|
|
130
|
-
);
|
|
126
|
+
const relativeDest = picked;
|
|
131
127
|
taskMappings.set(
|
|
132
128
|
taskClassName,
|
|
133
129
|
this.fileService
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import chalk from "chalk";
|
|
2
|
-
import { AppTask } from "
|
|
2
|
+
import { AppTask } from "../../wrappers/app-task";
|
|
3
3
|
import { autoInjectable } from "tsyringe";
|
|
4
|
-
import { GenTargetType } from "
|
|
5
|
-
import { ProjectService } from "
|
|
6
|
-
import { UtilService } from "
|
|
7
|
-
import { FileService } from "
|
|
8
|
-
import { CaseType } from "
|
|
4
|
+
import { GenTargetType } from "../../types/state";
|
|
5
|
+
import { ProjectService } from "../../services/project-service";
|
|
6
|
+
import { UtilService } from "../../services/util-service";
|
|
7
|
+
import { FileService } from "../../services/file-service";
|
|
8
|
+
import { CaseType } from "../../types/format";
|
|
9
9
|
import path from "path";
|
|
10
|
-
import { getServiceTemplate } from "
|
|
10
|
+
import { getServiceTemplate } from "../../templates/service";
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* Generates a new service class
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import chalk from "chalk";
|
|
2
|
-
import { AppTask } from "
|
|
2
|
+
import { AppTask } from "../../wrappers/app-task";
|
|
3
3
|
import { autoInjectable } from "tsyringe";
|
|
4
|
-
import { GenTargetType } from "
|
|
5
|
-
import { getTaskTemplate } from "
|
|
6
|
-
import { CaseType } from "
|
|
7
|
-
import { UtilService } from "
|
|
8
|
-
import { FileService } from "
|
|
9
|
-
import { ProjectService } from "
|
|
4
|
+
import { GenTargetType } from "../../types/state";
|
|
5
|
+
import { getTaskTemplate } from "../../templates/task";
|
|
6
|
+
import { CaseType } from "../../types/format";
|
|
7
|
+
import { UtilService } from "../../services/util-service";
|
|
8
|
+
import { FileService } from "../../services/file-service";
|
|
9
|
+
import { ProjectService } from "../../services/project-service";
|
|
10
10
|
import path from "path";
|
|
11
11
|
|
|
12
12
|
/**
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import chalk from "chalk";
|
|
2
|
-
import { AppTask } from "
|
|
2
|
+
import { AppTask } from "../../wrappers/app-task";
|
|
3
3
|
import { autoInjectable } from "tsyringe";
|
|
4
|
-
import { PromptService } from "
|
|
5
|
-
import { ProjectService } from "
|
|
6
|
-
import { UtilService } from "
|
|
4
|
+
import { PromptService } from "../../services/prompt-service";
|
|
5
|
+
import { ProjectService } from "../../services/project-service";
|
|
6
|
+
import { UtilService } from "../../services/util-service";
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* SelectGenTargetName
|
|
@@ -31,8 +31,8 @@ export default class SelectGenTargetName extends AppTask {
|
|
|
31
31
|
if (!targetName) {
|
|
32
32
|
throw new Error("Unable to resolve targetName");
|
|
33
33
|
}
|
|
34
|
-
|
|
35
|
-
this.
|
|
34
|
+
this.logger.debug(`Name selected: ${chalk.magentaBright(targetName)}`);
|
|
35
|
+
targetName = this.utilService.titleizeAll(targetName);
|
|
36
36
|
this.setData({ genTargetName: targetName });
|
|
37
37
|
}
|
|
38
38
|
|