task-script-support-cli 0.2.6 → 0.2.8
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 +1 -1
- package/dist/src/commands/configure.d.ts +2 -1
- package/dist/src/commands/configure.d.ts.map +1 -1
- package/dist/src/commands/configure.js +2 -1
- package/dist/src/commands/configure.js.map +1 -1
- package/dist/src/commands/gen.d.ts +2 -1
- package/dist/src/commands/gen.d.ts.map +1 -1
- package/dist/src/commands/gen.js +2 -0
- package/dist/src/commands/gen.js.map +1 -1
- package/dist/src/services/templater-service.d.ts +24 -0
- package/dist/src/services/templater-service.d.ts.map +1 -0
- package/dist/src/services/templater-service.js +134 -0
- package/dist/src/services/templater-service.js.map +1 -0
- package/dist/src/tasks/check-env.d.ts +0 -17
- package/dist/src/tasks/check-env.d.ts.map +1 -1
- package/dist/src/tasks/check-env.js +0 -53
- package/dist/src/tasks/check-env.js.map +1 -1
- package/dist/src/tasks/create-new-project.d.ts +12 -3
- package/dist/src/tasks/create-new-project.d.ts.map +1 -1
- package/dist/src/tasks/create-new-project.js +25 -15
- package/dist/src/tasks/create-new-project.js.map +1 -1
- package/dist/src/tasks/generate/project-context-guard.d.ts +42 -0
- package/dist/src/tasks/generate/project-context-guard.d.ts.map +1 -0
- package/dist/src/tasks/generate/project-context-guard.js +119 -0
- package/dist/src/tasks/generate/project-context-guard.js.map +1 -0
- package/dist/src/tasks/stdout/print-generated-results.d.ts +3 -1
- package/dist/src/tasks/stdout/print-generated-results.d.ts.map +1 -1
- package/dist/src/tasks/stdout/print-generated-results.js +14 -5
- package/dist/src/tasks/stdout/print-generated-results.js.map +1 -1
- package/package.json +1 -1
- package/src/commands/configure.ts +2 -1
- package/src/commands/gen.ts +2 -0
- package/src/services/templater-service.ts +136 -0
- package/src/tasks/check-env.ts +0 -55
- package/src/tasks/create-new-project.ts +28 -16
- package/src/tasks/generate/project-context-guard.ts +116 -0
- package/src/tasks/stdout/print-generated-results.ts +21 -4
- package/assets/yargs-template/task-runner/templater.sh +0 -69
- package/dist/assets/yargs-template/task-runner/templater.sh +0 -69
package/dist/package.json
CHANGED
|
@@ -2,7 +2,8 @@ import { Command } from "../wrappers/command";
|
|
|
2
2
|
import CheckEnv from "../tasks/check-env";
|
|
3
3
|
import ConfigureCache from "../tasks/configure";
|
|
4
4
|
import PrintBanner from "../tasks/stdout/print-banner";
|
|
5
|
+
import ProjectContextGuard from "../tasks/generate/project-context-guard";
|
|
5
6
|
export declare class ConfigureCommand extends Command {
|
|
6
|
-
tasks: (typeof PrintBanner | typeof CheckEnv | typeof ConfigureCache)[];
|
|
7
|
+
tasks: (typeof PrintBanner | typeof CheckEnv | typeof ProjectContextGuard | typeof ConfigureCache)[];
|
|
7
8
|
}
|
|
8
9
|
//# sourceMappingURL=configure.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"configure.d.ts","sourceRoot":"./src/","sources":["src/commands/configure.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,QAAQ,MAAM,oBAAoB,CAAC;AAC1C,OAAO,cAAc,MAAM,oBAAoB,CAAC;AAChD,OAAO,WAAW,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"configure.d.ts","sourceRoot":"./src/","sources":["src/commands/configure.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,QAAQ,MAAM,oBAAoB,CAAC;AAC1C,OAAO,cAAc,MAAM,oBAAoB,CAAC;AAChD,OAAO,WAAW,MAAM,8BAA8B,CAAC;AACvD,OAAO,mBAAmB,MAAM,yCAAyC,CAAC;AAE1E,qBACa,gBAAiB,SAAQ,OAAO;IAC3C,KAAK,gGAAgE;CACtE"}
|
|
@@ -15,8 +15,9 @@ const command_1 = require("../wrappers/command");
|
|
|
15
15
|
const check_env_1 = __importDefault(require("../tasks/check-env"));
|
|
16
16
|
const configure_1 = __importDefault(require("../tasks/configure"));
|
|
17
17
|
const print_banner_1 = __importDefault(require("../tasks/stdout/print-banner"));
|
|
18
|
+
const project_context_guard_1 = __importDefault(require("../tasks/generate/project-context-guard"));
|
|
18
19
|
let ConfigureCommand = class ConfigureCommand extends command_1.Command {
|
|
19
|
-
tasks = [print_banner_1.default, check_env_1.default, configure_1.default];
|
|
20
|
+
tasks = [print_banner_1.default, check_env_1.default, project_context_guard_1.default, configure_1.default];
|
|
20
21
|
};
|
|
21
22
|
exports.ConfigureCommand = ConfigureCommand;
|
|
22
23
|
exports.ConfigureCommand = ConfigureCommand = __decorate([
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"configure.js","sourceRoot":"./src/","sources":["src/commands/configure.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,uCAAqC;AACrC,iDAA8C;AAC9C,mEAA0C;AAC1C,mEAAgD;AAChD,gFAAuD;
|
|
1
|
+
{"version":3,"file":"configure.js","sourceRoot":"./src/","sources":["src/commands/configure.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,uCAAqC;AACrC,iDAA8C;AAC9C,mEAA0C;AAC1C,mEAAgD;AAChD,gFAAuD;AACvD,oGAA0E;AAGnE,IAAM,gBAAgB,GAAtB,MAAM,gBAAiB,SAAQ,iBAAO;IAC3C,KAAK,GAAG,CAAC,sBAAW,EAAE,mBAAQ,EAAE,+BAAmB,EAAE,mBAAc,CAAC,CAAC;CACtE,CAAA;AAFY,4CAAgB;2BAAhB,gBAAgB;IAD5B,IAAA,oBAAS,GAAE;GACC,gBAAgB,CAE5B"}
|
|
@@ -8,7 +8,8 @@ import GenerateTask from "../tasks/generate/generate-task";
|
|
|
8
8
|
import PrintGeneratedResults from "../tasks/stdout/print-generated-results";
|
|
9
9
|
import SyncConfiguration from "../tasks/sync-configuration";
|
|
10
10
|
import SelectGenTargetName from "../tasks/generate/select-gen-target-name";
|
|
11
|
+
import ProjectContextGuard from "../tasks/generate/project-context-guard";
|
|
11
12
|
export declare class GenCommand extends Command {
|
|
12
|
-
tasks: (typeof PrintBanner | typeof CheckEnvironment | typeof SelectGenTarget | typeof PrintGeneratedResults | typeof SyncConfiguration | typeof SelectGenTargetName | (typeof GenerateService | typeof GenerateCommand | typeof GenerateTask)[])[];
|
|
13
|
+
tasks: (typeof PrintBanner | typeof CheckEnvironment | typeof SelectGenTarget | typeof PrintGeneratedResults | typeof SyncConfiguration | typeof SelectGenTargetName | typeof ProjectContextGuard | (typeof GenerateService | typeof GenerateCommand | typeof GenerateTask)[])[];
|
|
13
14
|
}
|
|
14
15
|
//# sourceMappingURL=gen.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gen.d.ts","sourceRoot":"./src/","sources":["src/commands/gen.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,gBAAgB,MAAM,oBAAoB,CAAC;AAClD,OAAO,WAAW,MAAM,8BAA8B,CAAC;AACvD,OAAO,eAAe,MAAM,qCAAqC,CAAC;AAClE,OAAO,eAAe,MAAM,oCAAoC,CAAC;AACjE,OAAO,eAAe,MAAM,oCAAoC,CAAC;AACjE,OAAO,YAAY,MAAM,iCAAiC,CAAC;AAC3D,OAAO,qBAAqB,MAAM,yCAAyC,CAAC;AAC5E,OAAO,iBAAiB,MAAM,6BAA6B,CAAC;AAC5D,OAAO,mBAAmB,MAAM,0CAA0C,CAAC;
|
|
1
|
+
{"version":3,"file":"gen.d.ts","sourceRoot":"./src/","sources":["src/commands/gen.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,gBAAgB,MAAM,oBAAoB,CAAC;AAClD,OAAO,WAAW,MAAM,8BAA8B,CAAC;AACvD,OAAO,eAAe,MAAM,qCAAqC,CAAC;AAClE,OAAO,eAAe,MAAM,oCAAoC,CAAC;AACjE,OAAO,eAAe,MAAM,oCAAoC,CAAC;AACjE,OAAO,YAAY,MAAM,iCAAiC,CAAC;AAC3D,OAAO,qBAAqB,MAAM,yCAAyC,CAAC;AAC5E,OAAO,iBAAiB,MAAM,6BAA6B,CAAC;AAC5D,OAAO,mBAAmB,MAAM,0CAA0C,CAAC;AAC3E,OAAO,mBAAmB,MAAM,yCAAyC,CAAC;AAE1E,qBACa,UAAW,SAAQ,OAAO;IACrC,KAAK,4QASH;CACH"}
|
package/dist/src/commands/gen.js
CHANGED
|
@@ -21,10 +21,12 @@ const generate_task_1 = __importDefault(require("../tasks/generate/generate-task
|
|
|
21
21
|
const print_generated_results_1 = __importDefault(require("../tasks/stdout/print-generated-results"));
|
|
22
22
|
const sync_configuration_1 = __importDefault(require("../tasks/sync-configuration"));
|
|
23
23
|
const select_gen_target_name_1 = __importDefault(require("../tasks/generate/select-gen-target-name"));
|
|
24
|
+
const project_context_guard_1 = __importDefault(require("../tasks/generate/project-context-guard"));
|
|
24
25
|
let GenCommand = class GenCommand extends command_1.Command {
|
|
25
26
|
tasks = [
|
|
26
27
|
print_banner_1.default,
|
|
27
28
|
check_env_1.default,
|
|
29
|
+
project_context_guard_1.default,
|
|
28
30
|
select_gen_target_1.default,
|
|
29
31
|
sync_configuration_1.default,
|
|
30
32
|
select_gen_target_name_1.default,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gen.js","sourceRoot":"./src/","sources":["src/commands/gen.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,uCAAqC;AACrC,iDAA8C;AAC9C,mEAAkD;AAClD,gFAAuD;AACvD,4FAAkE;AAClE,0FAAiE;AACjE,0FAAiE;AACjE,oFAA2D;AAC3D,sGAA4E;AAC5E,qFAA4D;AAC5D,sGAA2E;
|
|
1
|
+
{"version":3,"file":"gen.js","sourceRoot":"./src/","sources":["src/commands/gen.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,uCAAqC;AACrC,iDAA8C;AAC9C,mEAAkD;AAClD,gFAAuD;AACvD,4FAAkE;AAClE,0FAAiE;AACjE,0FAAiE;AACjE,oFAA2D;AAC3D,sGAA4E;AAC5E,qFAA4D;AAC5D,sGAA2E;AAC3E,oGAA0E;AAGnE,IAAM,UAAU,GAAhB,MAAM,UAAW,SAAQ,iBAAO;IACrC,KAAK,GAAG;QACN,sBAAW;QACX,mBAAgB;QAChB,+BAAmB;QACnB,2BAAe;QACf,4BAAiB;QACjB,gCAAmB;QACnB,CAAC,0BAAe,EAAE,0BAAe,EAAE,uBAAY,CAAC;QAChD,iCAAqB;KACtB,CAAC;CACH,CAAA;AAXY,gCAAU;qBAAV,UAAU;IADtB,IAAA,oBAAS,GAAE;GACC,UAAU,CAWtB"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { SpawnService } from "./spawn-service";
|
|
2
|
+
import { LogService } from "./log-service";
|
|
3
|
+
export declare class TemplateService {
|
|
4
|
+
private spawnService;
|
|
5
|
+
private logger;
|
|
6
|
+
private loggerName;
|
|
7
|
+
private outputName;
|
|
8
|
+
private sourceDir;
|
|
9
|
+
private destination;
|
|
10
|
+
private dirListToCopy;
|
|
11
|
+
private fileListToCopy;
|
|
12
|
+
private nameRefList;
|
|
13
|
+
constructor(spawnService: SpawnService, logger: LogService);
|
|
14
|
+
runTemplater(outputName: string): Promise<void>;
|
|
15
|
+
private ensureDestinationExists;
|
|
16
|
+
private copyDirectories;
|
|
17
|
+
private copyFiles;
|
|
18
|
+
private fixNaming;
|
|
19
|
+
private createGitignore;
|
|
20
|
+
private removeDoubleNestedTestsDirectory;
|
|
21
|
+
private renameTaskRunner;
|
|
22
|
+
private initializeWithGit;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=templater-service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"templater-service.d.ts","sourceRoot":"./src/","sources":["src/services/templater-service.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAM3C,qBACa,eAAe;IA2BxB,OAAO,CAAC,YAAY;IACpB,OAAO,CAAC,MAAM;IA3BhB,OAAO,CAAC,UAAU,CAAsB;IAExC,OAAO,CAAC,UAAU,CAAU;IAC5B,OAAO,CAAC,SAAS,CAAU;IAC3B,OAAO,CAAC,WAAW,CAAU;IAE7B,OAAO,CAAC,aAAa,CAAyC;IAC9D,OAAO,CAAC,cAAc,CAUpB;IACF,OAAO,CAAC,WAAW,CAKjB;gBAGQ,YAAY,EAAE,YAAY,EAC1B,MAAM,EAAE,UAAU;IASf,YAAY,CAAC,UAAU,EAAE,MAAM;YAoB9B,uBAAuB;YAMvB,eAAe;YASf,SAAS;YAST,SAAS;YAWT,eAAe;YAOf,gCAAgC;YAUhC,gBAAgB;YAOhB,iBAAiB;CAQhC"}
|
|
@@ -0,0 +1,134 @@
|
|
|
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
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.TemplateService = void 0;
|
|
16
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
17
|
+
const node_fs_1 = __importDefault(require("node:fs"));
|
|
18
|
+
const tsyringe_1 = require("tsyringe");
|
|
19
|
+
const spawn_service_1 = require("./spawn-service");
|
|
20
|
+
const log_service_1 = require("./log-service");
|
|
21
|
+
const gitignoreContent = `node_modules
|
|
22
|
+
dist
|
|
23
|
+
.env`;
|
|
24
|
+
let TemplateService = class TemplateService {
|
|
25
|
+
spawnService;
|
|
26
|
+
logger;
|
|
27
|
+
loggerName = "Template Service";
|
|
28
|
+
outputName;
|
|
29
|
+
sourceDir;
|
|
30
|
+
destination;
|
|
31
|
+
dirListToCopy = [".vscode", "src", "tests"];
|
|
32
|
+
fileListToCopy = [
|
|
33
|
+
".prettierignore",
|
|
34
|
+
".prettierrc",
|
|
35
|
+
"task-runner",
|
|
36
|
+
"install-link.sh",
|
|
37
|
+
"eslint.config.ts",
|
|
38
|
+
"vitest.config.ts",
|
|
39
|
+
"package-lock.json",
|
|
40
|
+
"package.json",
|
|
41
|
+
"tsconfig.json",
|
|
42
|
+
];
|
|
43
|
+
nameRefList = [
|
|
44
|
+
// files that have name references
|
|
45
|
+
"package.json",
|
|
46
|
+
"package-lock.json",
|
|
47
|
+
"install-link.sh",
|
|
48
|
+
];
|
|
49
|
+
constructor(spawnService, logger) {
|
|
50
|
+
this.spawnService = spawnService;
|
|
51
|
+
this.logger = logger;
|
|
52
|
+
this.sourceDir = node_path_1.default.join(__dirname, "../../assets/yargs-template/task-runner/");
|
|
53
|
+
this.logger.setPrefix(this.loggerName);
|
|
54
|
+
}
|
|
55
|
+
async runTemplater(outputName) {
|
|
56
|
+
if (!outputName) {
|
|
57
|
+
throw new Error("Missing required parameter. Usage: Templater <output-name>");
|
|
58
|
+
}
|
|
59
|
+
this.outputName = outputName;
|
|
60
|
+
this.destination = node_path_1.default.join(process.cwd(), outputName);
|
|
61
|
+
await this.ensureDestinationExists();
|
|
62
|
+
await this.copyDirectories();
|
|
63
|
+
await this.copyFiles();
|
|
64
|
+
await this.fixNaming();
|
|
65
|
+
await this.createGitignore();
|
|
66
|
+
await this.removeDoubleNestedTestsDirectory();
|
|
67
|
+
await this.renameTaskRunner();
|
|
68
|
+
await this.initializeWithGit();
|
|
69
|
+
await this.logger.flush();
|
|
70
|
+
}
|
|
71
|
+
async ensureDestinationExists() {
|
|
72
|
+
if (!node_fs_1.default.existsSync(this.destination)) {
|
|
73
|
+
node_fs_1.default.mkdirSync(this.destination, { recursive: true });
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
async copyDirectories() {
|
|
77
|
+
for (const folder of this.dirListToCopy) {
|
|
78
|
+
const src = node_path_1.default.join(this.sourceDir, folder);
|
|
79
|
+
const dest = node_path_1.default.join(this.destination, folder);
|
|
80
|
+
this.logger.debug(`Running Copy: cp -R ${src} ${dest}`);
|
|
81
|
+
node_fs_1.default.cpSync(src, dest, { recursive: true });
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
async copyFiles() {
|
|
85
|
+
for (const filename of this.fileListToCopy) {
|
|
86
|
+
const src = node_path_1.default.join(this.sourceDir, filename);
|
|
87
|
+
const dest = node_path_1.default.join(this.destination, filename);
|
|
88
|
+
this.logger.debug(`Running Copy: cp ${src} ${dest}`);
|
|
89
|
+
node_fs_1.default.copyFileSync(src, dest);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
async fixNaming() {
|
|
93
|
+
for (const fileToEdit of this.nameRefList) {
|
|
94
|
+
const dest = node_path_1.default.join(this.destination, fileToEdit);
|
|
95
|
+
const replacePattern = new RegExp("task-runner", "g");
|
|
96
|
+
const content = node_fs_1.default
|
|
97
|
+
.readFileSync(dest, "utf-8")
|
|
98
|
+
.replaceAll(replacePattern, this.outputName);
|
|
99
|
+
node_fs_1.default.writeFileSync(dest, content);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
async createGitignore() {
|
|
103
|
+
node_fs_1.default.writeFileSync(node_path_1.default.join(this.destination, ".gitignore"), gitignoreContent);
|
|
104
|
+
}
|
|
105
|
+
async removeDoubleNestedTestsDirectory() {
|
|
106
|
+
const doubleNestedTestsPath = node_path_1.default.join(this.destination, "tests", "tests");
|
|
107
|
+
if (node_fs_1.default.existsSync(doubleNestedTestsPath)) {
|
|
108
|
+
this.logger.debug(`Removing double nested tests directory: ${doubleNestedTestsPath}`);
|
|
109
|
+
node_fs_1.default.rmSync(doubleNestedTestsPath, { recursive: true });
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
async renameTaskRunner() {
|
|
113
|
+
const src = node_path_1.default.join(this.destination, "task-runner");
|
|
114
|
+
const dest = node_path_1.default.join(this.destination, this.outputName);
|
|
115
|
+
this.logger.debug(`Renaming task-runner to ${this.outputName}`);
|
|
116
|
+
node_fs_1.default.renameSync(src, dest);
|
|
117
|
+
}
|
|
118
|
+
async initializeWithGit() {
|
|
119
|
+
try {
|
|
120
|
+
this.logger.debug("Initializing with git");
|
|
121
|
+
this.spawnService.execSyncFromDir(`git init -b main`, this.destination);
|
|
122
|
+
}
|
|
123
|
+
catch (error) {
|
|
124
|
+
console.error("Error initializing git:", error.message);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
exports.TemplateService = TemplateService;
|
|
129
|
+
exports.TemplateService = TemplateService = __decorate([
|
|
130
|
+
(0, tsyringe_1.autoInjectable)(),
|
|
131
|
+
__metadata("design:paramtypes", [spawn_service_1.SpawnService,
|
|
132
|
+
log_service_1.LogService])
|
|
133
|
+
], TemplateService);
|
|
134
|
+
//# sourceMappingURL=templater-service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"templater-service.js","sourceRoot":"./src/","sources":["src/services/templater-service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,0DAA6B;AAC7B,sDAAyB;AACzB,uCAA0C;AAC1C,mDAA+C;AAC/C,+CAA2C;AAE3C,MAAM,gBAAgB,GAAG;;KAE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D,MAAM,IAAI,GAAG,mBAAI,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;QAC1D,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,2BAA2B,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC;QAChE,iBAAE,CAAC,UAAU,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;IAC3B,CAAC;IAEO,KAAK,CAAC,iBAAiB;QAC7B,IAAI,CAAC;YACH,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,uBAAuB,CAAC,CAAC;YAC3C,IAAI,CAAC,YAAY,CAAC,eAAe,CAAC,kBAAkB,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;QAC1E,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,KAAK,CAAC,yBAAyB,EAAG,KAAe,CAAC,OAAO,CAAC,CAAC;QACrE,CAAC;IACH,CAAC;CACF,CAAA;AA5HY,0CAAe;0BAAf,eAAe;IAD3B,IAAA,yBAAc,GAAE;qCA4BS,4BAAY;QAClB,wBAAU;GA5BjB,eAAe,CA4H3B"}
|
|
@@ -10,23 +10,6 @@ export default class CheckEnvironment extends AppTask {
|
|
|
10
10
|
optionalEnvVars: string[];
|
|
11
11
|
constructor(fileService: FileService);
|
|
12
12
|
run(): Promise<void>;
|
|
13
|
-
/**
|
|
14
|
-
* Check for the folders we need to generate files in. Add errors
|
|
15
|
-
* when no target directories can be found. Saves project data to
|
|
16
|
-
* state so we don't have to refetch it later.
|
|
17
|
-
*
|
|
18
|
-
* @param projectDir the target project root directory path
|
|
19
|
-
* @param errors string array error messages are added to
|
|
20
|
-
*/
|
|
21
|
-
checkProjectDirectories(projectDir: string, errors: string[]): void;
|
|
22
|
-
/**
|
|
23
|
-
* Check that the project has the right dependencies installed. Adds
|
|
24
|
-
* to the errors array when they can't be found.
|
|
25
|
-
*
|
|
26
|
-
* @param projectDir the target project root directory path
|
|
27
|
-
* @param errors string array error messages are added to
|
|
28
|
-
*/
|
|
29
|
-
checkProjectDependencies(projectDir: string, errors: string[]): void;
|
|
30
13
|
/**
|
|
31
14
|
* Log and exit program if errors are present.
|
|
32
15
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"check-env.d.ts","sourceRoot":"./src/","sources":["src/tasks/check-env.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAG/C,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"check-env.d.ts","sourceRoot":"./src/","sources":["src/tasks/check-env.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAG/C,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAEvD;;GAEG;AAEH,MAAM,CAAC,OAAO,OAAO,gBAAiB,SAAQ,OAAO;IAcvC,OAAO,CAAC,WAAW;IAb/B,UAAU,SAAuB;IAEjC,eAAe,EAAE,MAAM,EAAE,CAAM;IAE/B,eAAe,WAOb;gBAEkB,WAAW,EAAE,WAAW;IAItC,GAAG;IAYT;;;;OAIG;IACH,OAAO,CAAC,WAAW;IAOnB;;;;OAIG;IACH,OAAO,CAAC,YAAY;IASpB,OAAO,CAAC,eAAe,CAKjB;IAEN,OAAO,CAAC,gBAAgB,CAGsC;CAC/D"}
|
|
@@ -17,7 +17,6 @@ const app_task_1 = require("../wrappers/app-task");
|
|
|
17
17
|
const tsyringe_1 = require("tsyringe");
|
|
18
18
|
const state_1 = require("../types/state");
|
|
19
19
|
const file_service_1 = require("../services/file-service");
|
|
20
|
-
const path_1 = __importDefault(require("path"));
|
|
21
20
|
/**
|
|
22
21
|
* Checks the environment configuration
|
|
23
22
|
*/
|
|
@@ -43,61 +42,9 @@ let CheckEnvironment = class CheckEnvironment extends app_task_1.AppTask {
|
|
|
43
42
|
this.getReadMessages(envVars).forEach((m) => this.logger.debug(m));
|
|
44
43
|
const errors = this.getErrorMessages(this.requiredEnvVars);
|
|
45
44
|
this.checkToExit(errors);
|
|
46
|
-
try {
|
|
47
|
-
const projectDir = this.fileService.getRunnerRootDir();
|
|
48
|
-
this.checkProjectDependencies(projectDir, errors);
|
|
49
|
-
this.checkProjectDirectories(projectDir, errors);
|
|
50
|
-
}
|
|
51
|
-
catch (err) {
|
|
52
|
-
errors.push(`Unexpected error checking project: ${err}`);
|
|
53
|
-
}
|
|
54
45
|
this.checkToExit(errors);
|
|
55
46
|
this.setData({ environmentValidated: true });
|
|
56
47
|
}
|
|
57
|
-
/**
|
|
58
|
-
* Check for the folders we need to generate files in. Add errors
|
|
59
|
-
* when no target directories can be found. Saves project data to
|
|
60
|
-
* state so we don't have to refetch it later.
|
|
61
|
-
*
|
|
62
|
-
* @param projectDir the target project root directory path
|
|
63
|
-
* @param errors string array error messages are added to
|
|
64
|
-
*/
|
|
65
|
-
checkProjectDirectories(projectDir, errors) {
|
|
66
|
-
const directories = {
|
|
67
|
-
taskFolders: this.fileService.getTaskDirs(projectDir),
|
|
68
|
-
serviceFolders: this.fileService.getServiceDirs(projectDir),
|
|
69
|
-
commandFolders: this.fileService.getCommandDirs(projectDir),
|
|
70
|
-
};
|
|
71
|
-
Object.keys(directories).forEach((k) => {
|
|
72
|
-
const key = k;
|
|
73
|
-
if (!directories[key] || !directories[key].length) {
|
|
74
|
-
errors.push(`Unable to find any ${k} in project`);
|
|
75
|
-
}
|
|
76
|
-
});
|
|
77
|
-
this.setData({
|
|
78
|
-
project: {
|
|
79
|
-
rootDir: projectDir,
|
|
80
|
-
...directories,
|
|
81
|
-
},
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
/**
|
|
85
|
-
* Check that the project has the right dependencies installed. Adds
|
|
86
|
-
* to the errors array when they can't be found.
|
|
87
|
-
*
|
|
88
|
-
* @param projectDir the target project root directory path
|
|
89
|
-
* @param errors string array error messages are added to
|
|
90
|
-
*/
|
|
91
|
-
checkProjectDependencies(projectDir, errors) {
|
|
92
|
-
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
93
|
-
const packagePath = require(path_1.default.join(projectDir, "package.json"));
|
|
94
|
-
const requireDeps = ["task-script-support", "tsyringe"];
|
|
95
|
-
requireDeps.forEach((d) => {
|
|
96
|
-
if (!Object.keys(packagePath.dependencies || {}).includes(d)) {
|
|
97
|
-
errors.push(`Missing required dependencies in project: '${d}'`);
|
|
98
|
-
}
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
48
|
/**
|
|
102
49
|
* Log and exit program if errors are present.
|
|
103
50
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"check-env.js","sourceRoot":"./src/","sources":["src/tasks/check-env.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,kDAA0B;AAC1B,mDAA+C;AAC/C,uCAA0C;AAC1C,0CAAuD;AACvD,2DAAuD;
|
|
1
|
+
{"version":3,"file":"check-env.js","sourceRoot":"./src/","sources":["src/tasks/check-env.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,kDAA0B;AAC1B,mDAA+C;AAC/C,uCAA0C;AAC1C,0CAAuD;AACvD,2DAAuD;AAEvD;;GAEG;AAEY,IAAM,gBAAgB,GAAtB,MAAM,gBAAiB,SAAQ,kBAAO;IAc/B;IAbpB,UAAU,GAAG,mBAAmB,CAAC;IAEjC,eAAe,GAAa,EAAE,CAAC;IAE/B,eAAe,GAAG;QAChB,6BAAqB,CAAC,QAAQ;QAC9B,6BAAqB,CAAC,eAAe;QACrC,6BAAqB,CAAC,iBAAiB;QACvC,6BAAqB,CAAC,iBAAiB;QACvC,6BAAqB,CAAC,cAAc;QACpC,6BAAqB,CAAC,mBAAmB;KAC1C,CAAC;IAEF,YAAoB,WAAwB;QAC1C,KAAK,EAAE,CAAC;QADU,gBAAW,GAAX,WAAW,CAAa;IAE5C,CAAC;IAED,KAAK,CAAC,GAAG;QACP,IAAI,CAAC,MAAM,CAAC,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EAAE,CAAC,kBAAkB,CAAC,KAAK,eAAK,CAAC,aAAa,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CACrE,CAAC;IAEE,gBAAgB,GAAG,CAAC,UAAoB,EAAE,EAAE,CAClD,UAAU;SACP,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;SAC9B,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,yCAAyC,CAAC,EAAE,CAAC,CAAC;CAC/D,CAAA;AAnEoB,gBAAgB;IADpC,IAAA,yBAAc,GAAE;qCAekB,0BAAW;GAdzB,gBAAgB,CAmEpC;kBAnEoB,gBAAgB"}
|
|
@@ -1,16 +1,18 @@
|
|
|
1
|
-
import { SpawnService } from "../services/spawn-service";
|
|
2
1
|
import { FileService } from "../services/file-service";
|
|
3
2
|
import { PromptService } from "../services/prompt-service";
|
|
4
3
|
import { AppTask } from "../wrappers/app-task";
|
|
4
|
+
import { TemplateService } from "../services/templater-service";
|
|
5
|
+
import { UtilService } from "../services/util-service";
|
|
5
6
|
/**
|
|
6
7
|
* Creates a New Task Script Support Project
|
|
7
8
|
*/
|
|
8
9
|
export default class CreateNewProject extends AppTask {
|
|
9
10
|
private fileService;
|
|
10
|
-
private
|
|
11
|
+
private utilService;
|
|
11
12
|
private promptService;
|
|
13
|
+
private templaterService;
|
|
12
14
|
loggerName: string;
|
|
13
|
-
constructor(fileService: FileService,
|
|
15
|
+
constructor(fileService: FileService, utilService: UtilService, promptService: PromptService, templaterService: TemplateService);
|
|
14
16
|
/**
|
|
15
17
|
* Generates a new project. Updates state with outputDestination of the
|
|
16
18
|
* newly generated project path.
|
|
@@ -22,5 +24,12 @@ export default class CreateNewProject extends AppTask {
|
|
|
22
24
|
* @returns the project name string
|
|
23
25
|
*/
|
|
24
26
|
getProjectName(): Promise<string>;
|
|
27
|
+
/**
|
|
28
|
+
* Normalize the name to the provided case or kebab.
|
|
29
|
+
*
|
|
30
|
+
* @param projectName the target project name to normalize
|
|
31
|
+
* @returns the normalized project name
|
|
32
|
+
*/
|
|
33
|
+
normalizeProjectName(projectName: string): string;
|
|
25
34
|
}
|
|
26
35
|
//# sourceMappingURL=create-new-project.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-new-project.d.ts","sourceRoot":"./src/","sources":["src/tasks/create-new-project.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"create-new-project.d.ts","sourceRoot":"./src/","sources":["src/tasks/create-new-project.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAE3D,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAE/C,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAGvD;;GAEG;AAEH,MAAM,CAAC,OAAO,OAAO,gBAAiB,SAAQ,OAAO;IAIjD,OAAO,CAAC,WAAW;IACnB,OAAO,CAAC,WAAW;IACnB,OAAO,CAAC,aAAa;IACrB,OAAO,CAAC,gBAAgB;IAN1B,UAAU,SAAwB;gBAGxB,WAAW,EAAE,WAAW,EACxB,WAAW,EAAE,WAAW,EACxB,aAAa,EAAE,aAAa,EAC5B,gBAAgB,EAAE,eAAe;IAK3C;;;OAGG;IACG,GAAG;IAeT;;;;OAIG;IACG,cAAc,IAAI,OAAO,CAAC,MAAM,CAAC;IAavC;;;;;OAKG;IACH,oBAAoB,CAAC,WAAW,EAAE,MAAM;CASzC"}
|
|
@@ -9,42 +9,41 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
9
9
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
const spawn_service_1 = require("../services/spawn-service");
|
|
13
12
|
const file_service_1 = require("../services/file-service");
|
|
14
13
|
const prompt_service_1 = require("../services/prompt-service");
|
|
15
14
|
const process_1 = require("../types/process");
|
|
16
15
|
const app_task_1 = require("../wrappers/app-task");
|
|
17
16
|
const tsyringe_1 = require("tsyringe");
|
|
17
|
+
const templater_service_1 = require("../services/templater-service");
|
|
18
|
+
const util_service_1 = require("../services/util-service");
|
|
19
|
+
const format_1 = require("../types/format");
|
|
18
20
|
/**
|
|
19
21
|
* Creates a New Task Script Support Project
|
|
20
22
|
*/
|
|
21
23
|
let CreateNewProject = class CreateNewProject extends app_task_1.AppTask {
|
|
22
24
|
fileService;
|
|
23
|
-
|
|
25
|
+
utilService;
|
|
24
26
|
promptService;
|
|
27
|
+
templaterService;
|
|
25
28
|
loggerName = "Create New Project";
|
|
26
|
-
constructor(fileService,
|
|
29
|
+
constructor(fileService, utilService, promptService, templaterService) {
|
|
27
30
|
super();
|
|
28
31
|
this.fileService = fileService;
|
|
29
|
-
this.
|
|
32
|
+
this.utilService = utilService;
|
|
30
33
|
this.promptService = promptService;
|
|
34
|
+
this.templaterService = templaterService;
|
|
31
35
|
}
|
|
32
36
|
/**
|
|
33
37
|
* Generates a new project. Updates state with outputDestination of the
|
|
34
38
|
* newly generated project path.
|
|
35
39
|
*/
|
|
36
40
|
async run() {
|
|
37
|
-
// get path of the templater
|
|
38
|
-
const templaterFullPath = this.fileService.join(__dirname, "../../assets/yargs-template/task-runner/templater.sh");
|
|
39
|
-
// get execution directory
|
|
40
|
-
const runnerDir = this.fileService.getRunnerDir();
|
|
41
41
|
// get project name user input
|
|
42
42
|
const projectName = await this.getProjectName();
|
|
43
|
-
//
|
|
44
|
-
|
|
45
|
-
this.spawnService.execSyncFromDir(shCmd, runnerDir);
|
|
43
|
+
// run the templater
|
|
44
|
+
await this.templaterService.runTemplater(projectName);
|
|
46
45
|
this.setData({
|
|
47
|
-
outputDestination: this.fileService.join(
|
|
46
|
+
outputDestination: this.fileService.join(this.fileService.getRunnerDir(), projectName),
|
|
48
47
|
});
|
|
49
48
|
}
|
|
50
49
|
/**
|
|
@@ -63,14 +62,25 @@ let CreateNewProject = class CreateNewProject extends app_task_1.AppTask {
|
|
|
63
62
|
if (!projectName) {
|
|
64
63
|
throw new Error("Unable to resolve projectName");
|
|
65
64
|
}
|
|
66
|
-
return projectName;
|
|
65
|
+
return this.normalizeProjectName(projectName);
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Normalize the name to the provided case or kebab.
|
|
69
|
+
*
|
|
70
|
+
* @param projectName the target project name to normalize
|
|
71
|
+
* @returns the normalized project name
|
|
72
|
+
*/
|
|
73
|
+
normalizeProjectName(projectName) {
|
|
74
|
+
const normalizedTarget = this.utilService.detectCase(`${projectName}.ts`) || format_1.CaseType.KEBAB_CASE;
|
|
75
|
+
return this.utilService.titleizedToCase(this.utilService.titleizeAll(projectName), normalizedTarget);
|
|
67
76
|
}
|
|
68
77
|
};
|
|
69
78
|
CreateNewProject = __decorate([
|
|
70
79
|
(0, tsyringe_1.autoInjectable)(),
|
|
71
80
|
__metadata("design:paramtypes", [file_service_1.FileService,
|
|
72
|
-
|
|
73
|
-
prompt_service_1.PromptService
|
|
81
|
+
util_service_1.UtilService,
|
|
82
|
+
prompt_service_1.PromptService,
|
|
83
|
+
templater_service_1.TemplateService])
|
|
74
84
|
], CreateNewProject);
|
|
75
85
|
exports.default = CreateNewProject;
|
|
76
86
|
//# sourceMappingURL=create-new-project.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-new-project.js","sourceRoot":"./src/","sources":["src/tasks/create-new-project.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"create-new-project.js","sourceRoot":"./src/","sources":["src/tasks/create-new-project.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,2DAAuD;AACvD,+DAA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A+B,CAAC,CAAC;QACnD,CAAC;QACD,OAAO,IAAI,CAAC,oBAAoB,CAAC,WAAW,CAAC,CAAC;IAChD,CAAC;IAED;;;;;OAKG;IACH,oBAAoB,CAAC,WAAmB;QACtC,MAAM,gBAAgB,GACpB,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,GAAG,WAAW,KAAK,CAAC,IAAI,iBAAQ,CAAC,UAAU,CAAC;QAE1E,OAAO,IAAI,CAAC,WAAW,CAAC,eAAe,CACrC,IAAI,CAAC,WAAW,CAAC,WAAW,CAAC,WAAW,CAAC,EACzC,gBAAgB,CACjB,CAAC;IACJ,CAAC;CACF,CAAA;AAhEoB,gBAAgB;IADpC,IAAA,yBAAc,GAAE;qCAKQ,0BAAW;QACX,0BAAW;QACT,8BAAa;QACV,mCAAe;GAPxB,gBAAgB,CAgEpC;kBAhEoB,gBAAgB"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { FileService } from "../../services/file-service";
|
|
2
|
+
import { AppTask } from "../../wrappers/app-task";
|
|
3
|
+
/**
|
|
4
|
+
* Checks so see if we are in the context of a task-script-support
|
|
5
|
+
* project or not and fails the process with a friendly error message.
|
|
6
|
+
*/
|
|
7
|
+
export default class ProjectContextGuard extends AppTask {
|
|
8
|
+
private fileService;
|
|
9
|
+
loggerName: string;
|
|
10
|
+
constructor(fileService: FileService);
|
|
11
|
+
run(): Promise<void>;
|
|
12
|
+
/**
|
|
13
|
+
* Check for the folders we need to generate files in. Add errors
|
|
14
|
+
* when no target directories can be found. Saves project data to
|
|
15
|
+
* state so we don't have to refetch it later.
|
|
16
|
+
*
|
|
17
|
+
* @param projectDir the target project root directory path
|
|
18
|
+
* @param errors string array error messages are added to
|
|
19
|
+
*/
|
|
20
|
+
checkProjectDirectories(projectDir: string, errors: string[]): void;
|
|
21
|
+
/**
|
|
22
|
+
* Check that the project has the right dependencies installed. Adds
|
|
23
|
+
* to the errors array when they can't be found.
|
|
24
|
+
*
|
|
25
|
+
* @param projectDir the target project root directory path
|
|
26
|
+
* @param errors string array error messages are added to
|
|
27
|
+
*/
|
|
28
|
+
checkProjectDependencies(projectDir: string, errors: string[]): void;
|
|
29
|
+
/**
|
|
30
|
+
* Log and exit program if errors are present.
|
|
31
|
+
*
|
|
32
|
+
* @param errors the error messages array to check
|
|
33
|
+
*/
|
|
34
|
+
private checkToExit;
|
|
35
|
+
/**
|
|
36
|
+
* Logs any error messages in the provided array.
|
|
37
|
+
*
|
|
38
|
+
* @param errors the error messages array to log
|
|
39
|
+
*/
|
|
40
|
+
private logEnvErrors;
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=project-context-guard.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project-context-guard.d.ts","sourceRoot":"./src/","sources":["src/tasks/generate/project-context-guard.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAC1D,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAGlD;;;GAGG;AAEH,MAAM,CAAC,OAAO,OAAO,mBAAoB,SAAQ,OAAO;IAG1C,OAAO,CAAC,WAAW;IAF/B,UAAU,SAA2B;gBAEjB,WAAW,EAAE,WAAW;IAItC,GAAG;IAwBT;;;;;;;OAOG;IACH,uBAAuB,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE;IAoB5D;;;;;;OAMG;IACH,wBAAwB,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE;IAa7D;;;;OAIG;IACH,OAAO,CAAC,WAAW;IAOnB;;;;OAIG;IACH,OAAO,CAAC,YAAY;CAQrB"}
|