task-script-support-cli 0.2.19 → 0.3.0
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 -2
- package/dist/src/commands/gen.d.ts +1 -2
- package/dist/src/commands/gen.d.ts.map +1 -1
- package/dist/src/index.js +3 -2
- package/dist/src/index.js.map +1 -1
- package/dist/src/services/arg-service.d.ts +3 -0
- package/dist/src/services/arg-service.d.ts.map +1 -1
- package/dist/src/services/arg-service.js +18 -2
- package/dist/src/services/arg-service.js.map +1 -1
- package/dist/src/services/file-service.d.ts.map +1 -1
- package/dist/src/services/file-service.js +2 -1
- package/dist/src/services/file-service.js.map +1 -1
- package/dist/src/services/prompt-service.js +1 -1
- package/dist/src/services/prompt-service.js.map +1 -1
- package/dist/src/services/spawn-service.d.ts +0 -9
- package/dist/src/services/spawn-service.d.ts.map +1 -1
- package/dist/src/services/spawn-service.js +4 -100
- package/dist/src/services/spawn-service.js.map +1 -1
- package/dist/src/tasks/create-new-project.d.ts.map +1 -1
- package/dist/src/tasks/create-new-project.js +3 -0
- package/dist/src/tasks/create-new-project.js.map +1 -1
- package/dist/src/tasks/generate/generate-command.d.ts +3 -18
- package/dist/src/tasks/generate/generate-command.d.ts.map +1 -1
- package/dist/src/tasks/generate/generate-command.js +7 -60
- package/dist/src/tasks/generate/generate-command.js.map +1 -1
- package/dist/src/tasks/generate/generate-service.d.ts +3 -10
- package/dist/src/tasks/generate/generate-service.d.ts.map +1 -1
- package/dist/src/tasks/generate/generate-service.js +9 -22
- package/dist/src/tasks/generate/generate-service.js.map +1 -1
- package/dist/src/tasks/generate/generate-task.d.ts +3 -10
- package/dist/src/tasks/generate/generate-task.d.ts.map +1 -1
- package/dist/src/tasks/generate/generate-task.js +9 -22
- package/dist/src/tasks/generate/generate-task.js.map +1 -1
- package/dist/src/templates/command.d.ts.map +1 -1
- package/dist/src/templates/command.js +8 -2
- package/dist/src/templates/command.js.map +1 -1
- package/dist/src/templates/service.d.ts +1 -1
- package/dist/src/templates/service.d.ts.map +1 -1
- package/dist/src/templates/service.js +29 -1
- package/dist/src/templates/service.js.map +1 -1
- package/dist/src/templates/task.d.ts +1 -1
- package/dist/src/templates/task.d.ts.map +1 -1
- package/dist/src/templates/task.js +37 -1
- package/dist/src/templates/task.js.map +1 -1
- package/dist/src/types/project.d.ts +4 -0
- package/dist/src/types/project.d.ts.map +1 -1
- package/dist/src/wrappers/gen-app-task.d.ts +50 -0
- package/dist/src/wrappers/gen-app-task.d.ts.map +1 -0
- package/dist/src/wrappers/gen-app-task.js +124 -0
- package/dist/src/wrappers/gen-app-task.js.map +1 -0
- package/package.json +2 -2
- package/src/index.ts +3 -2
- package/src/services/arg-service.ts +21 -2
- package/src/services/file-service.ts +2 -1
- package/src/services/prompt-service.ts +1 -1
- package/src/services/spawn-service.ts +1 -74
- package/src/tasks/create-new-project.ts +2 -0
- package/src/tasks/generate/generate-command.ts +7 -70
- package/src/tasks/generate/generate-service.ts +8 -14
- package/src/tasks/generate/generate-task.ts +8 -14
- package/src/templates/command.ts +10 -2
- package/src/templates/service.ts +34 -2
- package/src/templates/task.ts +42 -2
- package/src/types/project.ts +5 -0
- package/src/wrappers/gen-app-task.ts +150 -0
|
@@ -5,41 +5,27 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
5
5
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
6
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
7
|
};
|
|
8
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
-
};
|
|
11
8
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
9
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
10
|
};
|
|
14
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
12
|
const chalk_1 = __importDefault(require("chalk"));
|
|
16
|
-
const app_task_1 = require("../../wrappers/app-task");
|
|
17
13
|
const tsyringe_1 = require("tsyringe");
|
|
18
14
|
const state_1 = require("../../types/state");
|
|
19
15
|
const project_service_1 = require("../../services/project-service");
|
|
20
|
-
const util_service_1 = require("../../services/util-service");
|
|
21
|
-
const file_service_1 = require("../../services/file-service");
|
|
22
16
|
const format_1 = require("../../types/format");
|
|
23
17
|
const path_1 = __importDefault(require("path"));
|
|
24
18
|
const service_1 = require("../../templates/service");
|
|
19
|
+
const gen_app_task_1 = __importDefault(require("../../wrappers/gen-app-task"));
|
|
25
20
|
/**
|
|
26
21
|
* Generates a new service class
|
|
27
22
|
*/
|
|
28
|
-
let GenerateService = class GenerateService extends
|
|
29
|
-
projectService;
|
|
30
|
-
utilService;
|
|
31
|
-
fileService;
|
|
23
|
+
let GenerateService = class GenerateService extends gen_app_task_1.default {
|
|
32
24
|
loggerName = "Generate Service";
|
|
33
|
-
constructor(projectService, utilService, fileService) {
|
|
34
|
-
super();
|
|
35
|
-
this.projectService = projectService;
|
|
36
|
-
this.utilService = utilService;
|
|
37
|
-
this.fileService = fileService;
|
|
38
|
-
}
|
|
39
25
|
/**
|
|
40
26
|
* Generates a new service class file.
|
|
41
27
|
*
|
|
42
|
-
* @returns updated state with outputDestination set to generated result path.
|
|
28
|
+
* @returns updated state with outputDestination set to a generated result path.
|
|
43
29
|
*/
|
|
44
30
|
async run() {
|
|
45
31
|
if (this.state.data.genTargetType !== state_1.GenTargetType.Service) {
|
|
@@ -53,7 +39,11 @@ let GenerateService = class GenerateService extends app_task_1.AppTask {
|
|
|
53
39
|
const convention = projectService.getConvention();
|
|
54
40
|
this.logger.debug(`Using convention: ${chalk_1.default.magentaBright(convention)}`);
|
|
55
41
|
const className = utilService.titleizedToCase(targetName, format_1.CaseType.PASCAL_CASE);
|
|
56
|
-
const
|
|
42
|
+
const injectableMappings = new Map();
|
|
43
|
+
if (this.argService.hasFlag("inject")) {
|
|
44
|
+
await this.addServicesToMap(injectableMappings, targetDirectory);
|
|
45
|
+
}
|
|
46
|
+
const rendered = (0, service_1.getServiceTemplate)(className, injectableMappings);
|
|
57
47
|
const filename = `${utilService.titleizedToCase(targetName, convention)}${project_service_1.ProjectService.defaults.extention}`;
|
|
58
48
|
const destination = path_1.default.join(targetDirectory, filename);
|
|
59
49
|
// write contents
|
|
@@ -80,10 +70,7 @@ let GenerateService = class GenerateService extends app_task_1.AppTask {
|
|
|
80
70
|
}
|
|
81
71
|
};
|
|
82
72
|
GenerateService = __decorate([
|
|
83
|
-
(0, tsyringe_1.autoInjectable)()
|
|
84
|
-
__metadata("design:paramtypes", [project_service_1.ProjectService,
|
|
85
|
-
util_service_1.UtilService,
|
|
86
|
-
file_service_1.FileService])
|
|
73
|
+
(0, tsyringe_1.autoInjectable)()
|
|
87
74
|
], GenerateService);
|
|
88
75
|
exports.default = GenerateService;
|
|
89
76
|
//# sourceMappingURL=generate-service.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate-service.js","sourceRoot":"./src/","sources":["src/tasks/generate/generate-service.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"generate-service.js","sourceRoot":"./src/","sources":["src/tasks/generate/generate-service.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,kDAA0B;AAC1B,uCAA0C;AAC1C,6CAAkD;AAClD,oEAAgE;AAChE,+CAA8C;AAC9C,gDAAwB;AACxB,qDAA6D;AAC7D,+EAA0D;AAE1D;;GAEG;AAEY,IAAM,eAAe,GAArB,MAAM,eAAgB,SAAQ,sBAAe;IAC1D,UAAU,GAAG,kBAAkB,CAAC;IAEhC;;;;OAIG;IACH,KAAK,CAAC,GAAG;QACP,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,aAAa,KAAK,qBAAa,CAAC,OAAO,EAAE,CAAC;YAC5D,OAAO;QACT,CAAC;QAED,IAAI,CAAC,M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ED;;;OAGG;IACH,KAAK,CAAC,MAAM;QACV,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,aAAa,KAAK,qBAAa,CAAC,OAAO,EAAE,CAAC;YAC5D,OAAO,CAAC,8BAA8B;QACxC,CAAC;QACD,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,aAAa,EAAE,CAAC;YACnC,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAC;QACpD,CAAC;QACD,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;YAC7B,MAAM,IAAI,KAAK,CAAC,6BAA6B,CAAC,CAAC;QACjD,CAAC;QACD,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,kBAAkB,EAAE,CAAC;YAChD,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAC;QACzD,CAAC;IACH,CAAC;CACF,CAAA;AA1DoB,eAAe;IADnC,IAAA,yBAAc,GAAE;GACI,eAAe,CA0DnC;kBA1DoB,eAAe"}
|
|
@@ -1,20 +1,13 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { UtilService } from "../../services/util-service";
|
|
3
|
-
import { FileService } from "../../services/file-service";
|
|
4
|
-
import { ProjectService } from "../../services/project-service";
|
|
1
|
+
import GenAppTask from "../../wrappers/gen-app-task";
|
|
5
2
|
/**
|
|
6
3
|
* Generates a new task class
|
|
7
4
|
*/
|
|
8
|
-
export default class GenerateTask extends
|
|
9
|
-
private utilService;
|
|
10
|
-
private fileService;
|
|
11
|
-
private projectService;
|
|
5
|
+
export default class GenerateTask extends GenAppTask {
|
|
12
6
|
loggerName: string;
|
|
13
|
-
constructor(utilService: UtilService, fileService: FileService, projectService: ProjectService);
|
|
14
7
|
/**
|
|
15
8
|
* Generates a new task class file.
|
|
16
9
|
*
|
|
17
|
-
* @returns updated state with outputDestination set to generated result path.
|
|
10
|
+
* @returns updated state with outputDestination set to a generated result path.
|
|
18
11
|
*/
|
|
19
12
|
run(): Promise<{
|
|
20
13
|
data: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate-task.d.ts","sourceRoot":"./src/","sources":["src/tasks/generate/generate-task.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"generate-task.d.ts","sourceRoot":"./src/","sources":["src/tasks/generate/generate-task.ts"],"names":[],"mappings":"AAOA,OAAO,UAAU,MAAM,6BAA6B,CAAC;AAErD;;GAEG;AAEH,MAAM,CAAC,OAAO,OAAO,YAAa,SAAQ,UAAU;IAClD,UAAU,SAAmB;IAE7B;;;;OAIG;IACG,GAAG;;;;;IAiCT;;;OAGG;IACG,MAAM;CAcb"}
|
|
@@ -5,41 +5,27 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
5
5
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
6
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
7
|
};
|
|
8
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
-
};
|
|
11
8
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
9
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
10
|
};
|
|
14
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
12
|
const chalk_1 = __importDefault(require("chalk"));
|
|
16
|
-
const app_task_1 = require("../../wrappers/app-task");
|
|
17
13
|
const tsyringe_1 = require("tsyringe");
|
|
18
14
|
const state_1 = require("../../types/state");
|
|
19
15
|
const task_1 = require("../../templates/task");
|
|
20
16
|
const format_1 = require("../../types/format");
|
|
21
|
-
const util_service_1 = require("../../services/util-service");
|
|
22
|
-
const file_service_1 = require("../../services/file-service");
|
|
23
17
|
const project_service_1 = require("../../services/project-service");
|
|
24
18
|
const path_1 = __importDefault(require("path"));
|
|
19
|
+
const gen_app_task_1 = __importDefault(require("../../wrappers/gen-app-task"));
|
|
25
20
|
/**
|
|
26
21
|
* Generates a new task class
|
|
27
22
|
*/
|
|
28
|
-
let GenerateTask = class GenerateTask extends
|
|
29
|
-
utilService;
|
|
30
|
-
fileService;
|
|
31
|
-
projectService;
|
|
23
|
+
let GenerateTask = class GenerateTask extends gen_app_task_1.default {
|
|
32
24
|
loggerName = "Generate Task";
|
|
33
|
-
constructor(utilService, fileService, projectService) {
|
|
34
|
-
super();
|
|
35
|
-
this.utilService = utilService;
|
|
36
|
-
this.fileService = fileService;
|
|
37
|
-
this.projectService = projectService;
|
|
38
|
-
}
|
|
39
25
|
/**
|
|
40
26
|
* Generates a new task class file.
|
|
41
27
|
*
|
|
42
|
-
* @returns updated state with outputDestination set to generated result path.
|
|
28
|
+
* @returns updated state with outputDestination set to a generated result path.
|
|
43
29
|
*/
|
|
44
30
|
async run() {
|
|
45
31
|
if (this.state.data.genTargetType !== state_1.GenTargetType.Task) {
|
|
@@ -53,7 +39,11 @@ let GenerateTask = class GenerateTask extends app_task_1.AppTask {
|
|
|
53
39
|
const convention = this.projectService.getConvention();
|
|
54
40
|
this.logger.debug(`Using convention: ${chalk_1.default.magentaBright(convention)}`);
|
|
55
41
|
const className = utilService.titleizedToCase(targetName, format_1.CaseType.PASCAL_CASE);
|
|
56
|
-
const
|
|
42
|
+
const injectableMappings = new Map();
|
|
43
|
+
if (this.argService.hasFlag("inject")) {
|
|
44
|
+
await this.addServicesToMap(injectableMappings, targetDirectory);
|
|
45
|
+
}
|
|
46
|
+
const rendered = (0, task_1.getTaskTemplate)(className, injectableMappings);
|
|
57
47
|
const filename = `${utilService.titleizedToCase(targetName, convention)}${project_service_1.ProjectService.defaults.extention}`;
|
|
58
48
|
const destination = path_1.default.join(targetDirectory, filename);
|
|
59
49
|
// write contents
|
|
@@ -80,10 +70,7 @@ let GenerateTask = class GenerateTask extends app_task_1.AppTask {
|
|
|
80
70
|
}
|
|
81
71
|
};
|
|
82
72
|
GenerateTask = __decorate([
|
|
83
|
-
(0, tsyringe_1.autoInjectable)()
|
|
84
|
-
__metadata("design:paramtypes", [util_service_1.UtilService,
|
|
85
|
-
file_service_1.FileService,
|
|
86
|
-
project_service_1.ProjectService])
|
|
73
|
+
(0, tsyringe_1.autoInjectable)()
|
|
87
74
|
], GenerateTask);
|
|
88
75
|
exports.default = GenerateTask;
|
|
89
76
|
//# sourceMappingURL=generate-task.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate-task.js","sourceRoot":"./src/","sources":["src/tasks/generate/generate-task.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"generate-task.js","sourceRoot":"./src/","sources":["src/tasks/generate/generate-task.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,kDAA0B;AAC1B,uCAA0C;AAC1C,6CAAkD;AAClD,+CAAuD;AACvD,+CAA8C;AAC9C,oEAAgE;AAChE,gDAAwB;AACxB,+EAAqD;AAErD;;GAEG;AAEY,IAAM,YAAY,GAAlB,MAAM,YAAa,SAAQ,sBAAU;IAClD,UAAU,GAAG,eAAe,CAAC;IAE7B;;;;OAIG;IACH,KAAK,CAAC,GAAG;QACP,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,aAAa,KAAK,qBAAa,CAAC,IAAI,EAAE,CAAC;YACzD,OAAO;QACT,CAAC;QAED,MAAM,EAAE,WAAW,EAAE,GAAG,IAAI,CAAC;QAE7B,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,eAAK,CAAC,UAAU,CAAC,iBAAiB,CAAC,CAAC,CAAC;QAEtD,MAAM,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,aAAc,CAAC;QAClD,MAAM,eAAe,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,OAAQ,CAAC,eAAgB,CAAC;QAElE,cAAc;QACd,MA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AI,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;YAC7B,MAAM,IAAI,KAAK,CAAC,6BAA6B,CAAC,CAAC;QACjD,CAAC;QACD,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,eAAe,EAAE,CAAC;YAC7C,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAC;QACzD,CAAC;IACH,CAAC;CACF,CAAA;AA3DoB,YAAY;IADhC,IAAA,yBAAc,GAAE;GACI,YAAY,CA2DhC;kBA3DoB,YAAY"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"command.d.ts","sourceRoot":"./src/","sources":["src/templates/command.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"command.d.ts","sourceRoot":"./src/","sources":["src/templates/command.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,kBAAkB,GAC7B,WAAW,MAAM,EACjB,QAAO,GAAG,CAAC,MAAM,EAAE,MAAM,CAAa,WAmBvC,CAAC"}
|
|
@@ -1,17 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getCommandTemplate = void 0;
|
|
4
|
+
const nonClashingName = (name) => `${name}Task`;
|
|
5
|
+
const nameCheck = (name, className) => name === className ? nonClashingName(name) : name;
|
|
4
6
|
const getCommandTemplate = (className, tasks = new Map()) => `import { singleton } from "tsyringe";
|
|
5
7
|
import { Command } from "../wrappers/command";
|
|
6
8
|
${tasks
|
|
7
9
|
.keys()
|
|
8
10
|
.toArray()
|
|
9
|
-
.map((k) => `import ${k} from "${tasks.get(k)}";`)
|
|
11
|
+
.map((k) => `import ${nameCheck(k, className)} from "${tasks.get(k)}";`)
|
|
10
12
|
.join("\n")}
|
|
11
13
|
|
|
12
14
|
@singleton()
|
|
13
15
|
export class ${className} extends Command {
|
|
14
|
-
tasks = [${tasks
|
|
16
|
+
tasks = [${tasks
|
|
17
|
+
.keys()
|
|
18
|
+
.toArray()
|
|
19
|
+
.map((k) => nameCheck(k, className))
|
|
20
|
+
.join(", ")}];
|
|
15
21
|
}
|
|
16
22
|
|
|
17
23
|
`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"command.js","sourceRoot":"./src/","sources":["src/templates/command.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"command.js","sourceRoot":"./src/","sources":["src/templates/command.ts"],"names":[],"mappings":";;;AAAA,MAAM,eAAe,GAAG,CAAC,IAAY,EAAE,EAAE,CAAC,GAAG,IAAI,MAAM,CAAC;AACxD,MAAM,SAAS,GAAG,CAAC,IAAY,EAAE,SAAiB,EAAE,EAAE,CACpD,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;AAE7C,MAAM,kBAAkB,GAAG,CAChC,SAAiB,EACjB,QAA6B,IAAI,GAAG,EAAE,EACtC,EAAE,CACF;;EAEA,KAAK;KACJ,IAAI,EAAE;KACN,OAAO,EAAE;KACT,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,UAAU,SAAS,CAAC,CAAC,EAAE,SAAS,CAAC,UAAU,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC;KACvE,IAAI,CAAC,IAAI,CAAC;;;eAGE,SAAS;aACX,KAAK;KACb,IAAI,EAAE;KACN,OAAO,EAAE;KACT,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,SAAS,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC;KACnC,IAAI,CAAC,IAAI,CAAC;;;CAGd,CAAC;AArBW,QAAA,kBAAkB,sBAqB7B"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const getServiceTemplate: (className: string) => string;
|
|
1
|
+
export declare const getServiceTemplate: (className: string, injections: Map<string, string>) => string;
|
|
2
2
|
//# sourceMappingURL=service.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service.d.ts","sourceRoot":"./src/","sources":["src/templates/service.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"service.d.ts","sourceRoot":"./src/","sources":["src/templates/service.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,kBAAkB,GAC7B,WAAW,MAAM,EACjB,YAAY,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,WAuChC,CAAC"}
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getServiceTemplate = void 0;
|
|
4
|
-
const
|
|
4
|
+
const camelCase = (s) => s.charAt(0).toLowerCase() + s.slice(1);
|
|
5
|
+
const getServiceTemplate = (className, injections) => {
|
|
6
|
+
if (!injections || injections.size === 0) {
|
|
7
|
+
return `import { singleton } from "tsyringe";
|
|
5
8
|
|
|
6
9
|
/**
|
|
7
10
|
* ${className}
|
|
@@ -12,5 +15,30 @@ export class ${className} {
|
|
|
12
15
|
}
|
|
13
16
|
|
|
14
17
|
`;
|
|
18
|
+
}
|
|
19
|
+
return `import { singleton } from "tsyringe";
|
|
20
|
+
${injections
|
|
21
|
+
.keys()
|
|
22
|
+
.toArray()
|
|
23
|
+
.map((k) => `import { ${k} } from "${injections.get(k)}";`)
|
|
24
|
+
.join("\n")}
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* ${className}
|
|
29
|
+
*/
|
|
30
|
+
@singleton()
|
|
31
|
+
export class ${className} {
|
|
32
|
+
constructor(
|
|
33
|
+
${injections
|
|
34
|
+
.keys()
|
|
35
|
+
.toArray()
|
|
36
|
+
.map((k) => `private ${camelCase(k)}: ${k}`)
|
|
37
|
+
.join(",\n ")}
|
|
38
|
+
) {}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
`;
|
|
42
|
+
};
|
|
15
43
|
exports.getServiceTemplate = getServiceTemplate;
|
|
16
44
|
//# sourceMappingURL=service.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service.js","sourceRoot":"./src/","sources":["src/templates/service.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"service.js","sourceRoot":"./src/","sources":["src/templates/service.ts"],"names":[],"mappings":";;;AAAA,MAAM,SAAS,GAAG,CAAC,CAAS,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AAEjE,MAAM,kBAAkB,GAAG,CAChC,SAAiB,EACjB,UAA+B,EAC/B,EAAE;IACF,IAAI,CAAC,UAAU,IAAI,UAAU,CAAC,IAAI,KAAK,CAAC,EAAE,CAAC;QACzC,OAAO;;;KAGN,SAAS;;;eAGC,SAAS;;;;CAIvB,CAAC;IACA,CAAC;IAED,OAAO;EACP,UAAU;SACT,IAAI,EAAE;SACN,OAAO,EAAE;SACT,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,YAAY,CAAC,YAAY,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC;SAC1D,IAAI,CAAC,IAAI,CAAC;;;;KAIR,SAAS;;;eAGC,SAAS;;MAElB,UAAU;SACT,IAAI,EAAE;SACN,OAAO,EAAE;SACT,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,WAAW,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC;SAC3C,IAAI,CAAC,SAAS,CAAC;;;;CAIrB,CAAC;AACF,CAAC,CAAC;AAzCW,QAAA,kBAAkB,sBAyC7B"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const getTaskTemplate: (className: string) => string;
|
|
1
|
+
export declare const getTaskTemplate: (className: string, injections: Map<string, string>) => string;
|
|
2
2
|
//# sourceMappingURL=task.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"task.d.ts","sourceRoot":"./src/","sources":["src/templates/task.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"task.d.ts","sourceRoot":"./src/","sources":["src/templates/task.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,eAAe,GAC1B,WAAW,MAAM,EACjB,YAAY,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,WAmDhC,CAAC"}
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getTaskTemplate = void 0;
|
|
4
|
-
const
|
|
4
|
+
const camelCase = (s) => s.charAt(0).toLowerCase() + s.slice(1);
|
|
5
|
+
const getTaskTemplate = (className, injections) => {
|
|
6
|
+
if (!injections || injections.size === 0) {
|
|
7
|
+
return `import { AppTask } from "../wrappers/app-task";
|
|
5
8
|
import { autoInjectable } from "tsyringe";
|
|
6
9
|
|
|
7
10
|
/**
|
|
@@ -16,5 +19,38 @@ export default class ${className} extends AppTask {
|
|
|
16
19
|
}
|
|
17
20
|
|
|
18
21
|
`;
|
|
22
|
+
}
|
|
23
|
+
return `import { AppTask } from "../wrappers/app-task";
|
|
24
|
+
import { autoInjectable } from "tsyringe";
|
|
25
|
+
${injections
|
|
26
|
+
.keys()
|
|
27
|
+
.toArray()
|
|
28
|
+
.map((k) => `import { ${k} } from "${injections.get(k)}";`)
|
|
29
|
+
.join("\n")}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* ${className}
|
|
33
|
+
*/
|
|
34
|
+
@autoInjectable()
|
|
35
|
+
export default class ${className} extends AppTask {
|
|
36
|
+
loggerName = "${className}";
|
|
37
|
+
|
|
38
|
+
constructor(
|
|
39
|
+
${injections
|
|
40
|
+
.keys()
|
|
41
|
+
.toArray()
|
|
42
|
+
.map((k) => `private ${camelCase(k)}: ${k}`)
|
|
43
|
+
.join(",\n ")}
|
|
44
|
+
) {
|
|
45
|
+
super();
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
async run() {
|
|
49
|
+
// TODO: implement task
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
`;
|
|
54
|
+
};
|
|
19
55
|
exports.getTaskTemplate = getTaskTemplate;
|
|
20
56
|
//# sourceMappingURL=task.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"task.js","sourceRoot":"./src/","sources":["src/templates/task.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"task.js","sourceRoot":"./src/","sources":["src/templates/task.ts"],"names":[],"mappings":";;;AAAA,MAAM,SAAS,GAAG,CAAC,CAAS,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AAEjE,MAAM,eAAe,GAAG,CAC7B,SAAiB,EACjB,UAA+B,EAC/B,EAAE;IACF,IAAI,CAAC,UAAU,IAAI,UAAU,CAAC,IAAI,KAAK,CAAC,EAAE,CAAC;QACzC,OAAO;;;;KAIN,SAAS;;;uBAGS,SAAS;kBACd,SAAS;;;;;;CAM1B,CAAC;IACA,CAAC;IAED,OAAO;;EAEP,UAAU;SACT,IAAI,EAAE;SACN,OAAO,EAAE;SACT,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,YAAY,CAAC,YAAY,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC;SAC1D,IAAI,CAAC,IAAI,CAAC;;;KAGR,SAAS;;;uBAGS,SAAS;kBACd,SAAS;;;MAGrB,UAAU;SACT,IAAI,EAAE;SACN,OAAO,EAAE;SACT,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,WAAW,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC;SAC3C,IAAI,CAAC,SAAS,CAAC;;;;;;;;;;CAUrB,CAAC;AACF,CAAC,CAAC;AArDW,QAAA,eAAe,mBAqD1B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"project.d.ts","sourceRoot":"./src/","sources":["src/types/project.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,eAAe,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACrC,kBAAkB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACxC,kBAAkB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CACzC;AAED,MAAM,WAAW,WAAW;IAC1B,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,cAAc,EAAE,MAAM,EAAE,CAAC;CAC1B"}
|
|
1
|
+
{"version":3,"file":"project.d.ts","sourceRoot":"./src/","sources":["src/types/project.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,eAAe,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACrC,kBAAkB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACxC,kBAAkB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CACzC;AAED,MAAM,WAAW,WAAW;IAC1B,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,cAAc,EAAE,MAAM,EAAE,CAAC;CAC1B;AAED,MAAM,MAAM,aAAa,GAAG;IAC1B,eAAe,EAAE,MAAM,CAAC;IACxB,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { AppTask } from "./app-task";
|
|
2
|
+
import { UtilService } from "../services/util-service";
|
|
3
|
+
import { FileService } from "../services/file-service";
|
|
4
|
+
import { ProjectService } from "../services/project-service";
|
|
5
|
+
import { PromptService } from "../services/prompt-service";
|
|
6
|
+
/**
|
|
7
|
+
* Generation Task Type
|
|
8
|
+
*/
|
|
9
|
+
export default class GenAppTask extends AppTask {
|
|
10
|
+
protected utilService: UtilService;
|
|
11
|
+
protected fileService: FileService;
|
|
12
|
+
protected projectService: ProjectService;
|
|
13
|
+
protected promptService: PromptService;
|
|
14
|
+
constructor(utilService: UtilService, fileService: FileService, projectService: ProjectService, promptService: PromptService);
|
|
15
|
+
/**
|
|
16
|
+
* Prompt to select tasks to use in the command being generated.
|
|
17
|
+
*
|
|
18
|
+
* @param taskMappings the map to add picked tasks to import for the command
|
|
19
|
+
*/
|
|
20
|
+
addTasksToMap(taskMappings: Map<string, string>): Promise<void>;
|
|
21
|
+
/**
|
|
22
|
+
* Prompt to select services to use in the command being generated.
|
|
23
|
+
*
|
|
24
|
+
* @param serviceMappings the map to add picked services to import for the command
|
|
25
|
+
* @param sourcePath the path to the parent directory of the source file being
|
|
26
|
+
* generated to resolve relative paths for imports
|
|
27
|
+
*/
|
|
28
|
+
addServicesToMap(serviceMappings: Map<string, string>, sourcePath: string): Promise<void>;
|
|
29
|
+
/**
|
|
30
|
+
* Formalize the selected imports into a format that can be used in the source code being generated.
|
|
31
|
+
*
|
|
32
|
+
* 1. Generate a PascalCased import name from the filename
|
|
33
|
+
* 2. Convert to a relative path
|
|
34
|
+
* 3. Remove the file extension for TypeScript import
|
|
35
|
+
*
|
|
36
|
+
* @param selectedPaths the selected file paths to formalize
|
|
37
|
+
* @param relativeSource the path to the source file being generated to resolve relative paths
|
|
38
|
+
* @returns the formalized ProjectImport array ({ importClassName, importPath })
|
|
39
|
+
*/
|
|
40
|
+
private formalizeImports;
|
|
41
|
+
/**
|
|
42
|
+
* Prompt to select imports to use in the class being generated.
|
|
43
|
+
*
|
|
44
|
+
* @param messagePrompt the prompt message to display
|
|
45
|
+
* @param filePaths the file paths to select from
|
|
46
|
+
* @returns the selected file paths
|
|
47
|
+
*/
|
|
48
|
+
private promptForImports;
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=gen-app-task.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gen-app-task.d.ts","sourceRoot":"./src/","sources":["src/wrappers/gen-app-task.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAGrC,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC7D,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAG3D;;GAEG;AAEH,MAAM,CAAC,OAAO,OAAO,UAAW,SAAQ,OAAO;IAE3C,SAAS,CAAC,WAAW,EAAE,WAAW;IAClC,SAAS,CAAC,WAAW,EAAE,WAAW;IAClC,SAAS,CAAC,cAAc,EAAE,cAAc;IACxC,SAAS,CAAC,aAAa,EAAE,aAAa;gBAH5B,WAAW,EAAE,WAAW,EACxB,WAAW,EAAE,WAAW,EACxB,cAAc,EAAE,cAAc,EAC9B,aAAa,EAAE,aAAa;IAKxC;;;;OAIG;IACG,aAAa,CAAC,YAAY,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC;IAyBrD;;;;;;OAMG;IACG,gBAAgB,CACpB,eAAe,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,EACpC,UAAU,EAAE,MAAM;IA2BpB;;;;;;;;;;OAUG;IACH,OAAO,CAAC,gBAAgB;IAyBxB;;;;;;OAMG;YACW,gBAAgB;CAiB/B"}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
const app_task_1 = require("./app-task");
|
|
13
|
+
const tsyringe_1 = require("tsyringe");
|
|
14
|
+
const format_1 = require("../types/format");
|
|
15
|
+
const util_service_1 = require("../services/util-service");
|
|
16
|
+
const file_service_1 = require("../services/file-service");
|
|
17
|
+
const project_service_1 = require("../services/project-service");
|
|
18
|
+
const prompt_service_1 = require("../services/prompt-service");
|
|
19
|
+
/**
|
|
20
|
+
* Generation Task Type
|
|
21
|
+
*/
|
|
22
|
+
let GenAppTask = class GenAppTask extends app_task_1.AppTask {
|
|
23
|
+
utilService;
|
|
24
|
+
fileService;
|
|
25
|
+
projectService;
|
|
26
|
+
promptService;
|
|
27
|
+
constructor(utilService, fileService, projectService, promptService) {
|
|
28
|
+
super();
|
|
29
|
+
this.utilService = utilService;
|
|
30
|
+
this.fileService = fileService;
|
|
31
|
+
this.projectService = projectService;
|
|
32
|
+
this.promptService = promptService;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Prompt to select tasks to use in the command being generated.
|
|
36
|
+
*
|
|
37
|
+
* @param taskMappings the map to add picked tasks to import for the command
|
|
38
|
+
*/
|
|
39
|
+
async addTasksToMap(taskMappings) {
|
|
40
|
+
if (!this.state.data.project?.taskDestination) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
const taskFiles = this.fileService.getFilesInDir(this.state.data.project.taskDestination);
|
|
44
|
+
this.logger.debug(`Found ${taskFiles.length} task files`);
|
|
45
|
+
const pickedTasks = await this.promptForImports("Include Tasks", taskFiles);
|
|
46
|
+
this.logger.debug(`Selected ${pickedTasks.length} tasks`);
|
|
47
|
+
if (!pickedTasks.length) {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
// add them to the map
|
|
51
|
+
this.formalizeImports(pickedTasks, this.state.data.project.commandDestination).forEach((i) => taskMappings.set(i.importClassName, i.importPath));
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Prompt to select services to use in the command being generated.
|
|
55
|
+
*
|
|
56
|
+
* @param serviceMappings the map to add picked services to import for the command
|
|
57
|
+
* @param sourcePath the path to the parent directory of the source file being
|
|
58
|
+
* generated to resolve relative paths for imports
|
|
59
|
+
*/
|
|
60
|
+
async addServicesToMap(serviceMappings, sourcePath) {
|
|
61
|
+
if (!this.state.data.project?.serviceDestination) {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
const serviceFiles = this.fileService.getFilesInDir(this.state.data.project.serviceDestination);
|
|
65
|
+
this.logger.debug(`Found ${serviceFiles.length} service files`);
|
|
66
|
+
const pickedServices = await this.promptForImports("Include Services", serviceFiles);
|
|
67
|
+
this.logger.debug(`Selected ${pickedServices.length} services`);
|
|
68
|
+
if (!pickedServices.length) {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
// add them to the map
|
|
72
|
+
this.formalizeImports(pickedServices, sourcePath).forEach((i) => serviceMappings.set(i.importClassName, i.importPath));
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Formalize the selected imports into a format that can be used in the source code being generated.
|
|
76
|
+
*
|
|
77
|
+
* 1. Generate a PascalCased import name from the filename
|
|
78
|
+
* 2. Convert to a relative path
|
|
79
|
+
* 3. Remove the file extension for TypeScript import
|
|
80
|
+
*
|
|
81
|
+
* @param selectedPaths the selected file paths to formalize
|
|
82
|
+
* @param relativeSource the path to the source file being generated to resolve relative paths
|
|
83
|
+
* @returns the formalized ProjectImport array ({ importClassName, importPath })
|
|
84
|
+
*/
|
|
85
|
+
formalizeImports(selectedPaths, relativeSource) {
|
|
86
|
+
if (!selectedPaths?.length) {
|
|
87
|
+
return [];
|
|
88
|
+
}
|
|
89
|
+
const formalizedPaths = [];
|
|
90
|
+
for (const fullPath of selectedPaths) {
|
|
91
|
+
const filename = this.fileService.getFilenameNoExt(fullPath);
|
|
92
|
+
const importClassName = this.utilService.titleizedToCase(this.utilService.titleizeAll(filename), format_1.CaseType.PASCAL_CASE);
|
|
93
|
+
formalizedPaths.push({
|
|
94
|
+
importClassName,
|
|
95
|
+
importPath: this.fileService
|
|
96
|
+
.toRelativePath(relativeSource, fullPath)
|
|
97
|
+
.replace(project_service_1.ProjectService.defaults.extention, ""),
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
return formalizedPaths;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Prompt to select imports to use in the class being generated.
|
|
104
|
+
*
|
|
105
|
+
* @param messagePrompt the prompt message to display
|
|
106
|
+
* @param filePaths the file paths to select from
|
|
107
|
+
* @returns the selected file paths
|
|
108
|
+
*/
|
|
109
|
+
async promptForImports(messagePrompt, filePaths) {
|
|
110
|
+
return await this.promptService.pickMultiple(messagePrompt, filePaths.map((filePath) => ({
|
|
111
|
+
name: this.utilService.titleizedToCase(this.utilService.titleizeAll(this.fileService.getFilenameNoExt(filePath)), format_1.CaseType.PASCAL_CASE),
|
|
112
|
+
value: filePath,
|
|
113
|
+
})));
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
GenAppTask = __decorate([
|
|
117
|
+
(0, tsyringe_1.autoInjectable)(),
|
|
118
|
+
__metadata("design:paramtypes", [util_service_1.UtilService,
|
|
119
|
+
file_service_1.FileService,
|
|
120
|
+
project_service_1.ProjectService,
|
|
121
|
+
prompt_service_1.PromptService])
|
|
122
|
+
], GenAppTask);
|
|
123
|
+
exports.default = GenAppTask;
|
|
124
|
+
//# sourceMappingURL=gen-app-task.js.map
|
|
@@ -0,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"version": "0.3.0",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"preferGlobal": true,
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"format": "prettier --write ./",
|
|
18
18
|
"format-check": "prettier --check .",
|
|
19
19
|
"hooks-one-time-setup": "npx simple-git-hooks",
|
|
20
|
-
"
|
|
20
|
+
"format-watch": "onchange \"**/*\" -- prettier --write --ignore-unknown {{changed}}",
|
|
21
21
|
"build": "rm -rf ./dist && npx tsc && node dist/src/index.js -v && npm run cp-assets",
|
|
22
22
|
"prepack": "npm run build",
|
|
23
23
|
"test": "vitest run",
|
package/src/index.ts
CHANGED
|
@@ -30,15 +30,16 @@ program
|
|
|
30
30
|
.option("--rf, --random-font", "use a random font for app banner");
|
|
31
31
|
|
|
32
32
|
program
|
|
33
|
-
.command("gen")
|
|
33
|
+
.command("gen [name]")
|
|
34
34
|
.option("-n, --target-name <name>", "Name of Generated Target")
|
|
35
|
+
.option("-i, --inject", "Inject services")
|
|
35
36
|
.option("-s, --service", "Generate a service")
|
|
36
37
|
.option("-c, --command", "Generate a command")
|
|
37
38
|
.option("-t, --task", "Generate a task")
|
|
38
39
|
.action(container.resolve(GenCommand).handler);
|
|
39
40
|
|
|
40
41
|
program
|
|
41
|
-
.command("new")
|
|
42
|
+
.command("new [name]")
|
|
42
43
|
.option("-n, --name <name>", "Name of the New Project")
|
|
43
44
|
// .option("-d, --dest", "target destination path")
|
|
44
45
|
.action(container.resolve(NewCommand).handler);
|