task-script-support-cli 0.2.7 ā 0.2.9
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/assets/yargs-template/task-runner/Dockerfile +42 -0
- package/assets/yargs-template/task-runner/task-runner +4 -1
- package/dist/assets/yargs-template/task-runner/.dockerignore +34 -0
- package/dist/assets/yargs-template/task-runner/Dockerfile +42 -0
- package/dist/assets/yargs-template/task-runner/task-runner +4 -1
- 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 +2 -1
- package/dist/src/services/templater-service.d.ts.map +1 -1
- package/dist/src/services/templater-service.js +10 -3
- package/dist/src/services/templater-service.js.map +1 -1
- 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/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 +120 -0
- package/dist/src/tasks/generate/project-context-guard.js.map +1 -0
- package/dist/src/templates/docker-ignore.d.ts +2 -0
- package/dist/src/templates/docker-ignore.d.ts.map +1 -0
- package/dist/src/templates/docker-ignore.js +41 -0
- package/dist/src/templates/docker-ignore.js.map +1 -0
- 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 +14 -3
- package/src/tasks/check-env.ts +0 -55
- package/src/tasks/generate/project-context-guard.ts +116 -0
- package/src/templates/docker-ignore.ts +36 -0
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
ARG NODE_VERSION=22
|
|
2
|
+
|
|
3
|
+
# Builder stage
|
|
4
|
+
FROM node:${NODE_VERSION}-alpine AS builder
|
|
5
|
+
|
|
6
|
+
WORKDIR /app
|
|
7
|
+
|
|
8
|
+
# Install necessary build tools
|
|
9
|
+
RUN apk add python3 gcc make g++
|
|
10
|
+
|
|
11
|
+
# Copy package.json and package-lock.json first for efficient caching
|
|
12
|
+
COPY package*.json ./
|
|
13
|
+
|
|
14
|
+
# Install dependencies only if package.json or package-lock.json have changed
|
|
15
|
+
RUN npm install
|
|
16
|
+
|
|
17
|
+
# Copy the rest of the application code
|
|
18
|
+
COPY . .
|
|
19
|
+
|
|
20
|
+
# Build the TypeScript application
|
|
21
|
+
RUN npm run build
|
|
22
|
+
|
|
23
|
+
# Production stage
|
|
24
|
+
FROM node:${NODE_VERSION}-alpine
|
|
25
|
+
|
|
26
|
+
WORKDIR /usr/src/app
|
|
27
|
+
|
|
28
|
+
# Install just the production dependencies
|
|
29
|
+
COPY --from=builder /app/package*.json ./
|
|
30
|
+
RUN npm install --only=prod
|
|
31
|
+
|
|
32
|
+
# Use multi-stage copy to avoid copying unnecessary files
|
|
33
|
+
COPY --from=builder /app/task-runner /usr/src/app/task-runner
|
|
34
|
+
COPY --from=builder /app/dist /usr/src/app/dist
|
|
35
|
+
|
|
36
|
+
# Use non-root user for security
|
|
37
|
+
RUN addgroup appuser && adduser -S appuser -G appuser && chown -R appuser:appuser /usr/src/app
|
|
38
|
+
USER appuser
|
|
39
|
+
|
|
40
|
+
# Set default ENTRYPOINT and CMD
|
|
41
|
+
ENTRYPOINT ["sh", "/usr/src/app/task-runner"]
|
|
42
|
+
CMD ["--help"]
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# Include any files or directories that you don't want to be copied to your
|
|
2
|
+
# container here (e.g., local build artifacts, temporary files, etc.).
|
|
3
|
+
#
|
|
4
|
+
# For more help, visit the .dockerignore file reference guide at
|
|
5
|
+
# https://docs.docker.com/go/build-context-dockerignore/
|
|
6
|
+
|
|
7
|
+
**/.classpath
|
|
8
|
+
**/.dockerignore
|
|
9
|
+
**/.env
|
|
10
|
+
**/.git
|
|
11
|
+
**/.gitignore
|
|
12
|
+
**/.project
|
|
13
|
+
**/.settings
|
|
14
|
+
**/.toolstarget
|
|
15
|
+
**/.vs
|
|
16
|
+
**/.vscode
|
|
17
|
+
**/.next
|
|
18
|
+
**/.cache
|
|
19
|
+
**/*.*proj.user
|
|
20
|
+
**/*.dbmdl
|
|
21
|
+
**/*.jfm
|
|
22
|
+
**/charts
|
|
23
|
+
**/docker-compose*
|
|
24
|
+
**/compose.y*ml
|
|
25
|
+
**/Dockerfile*
|
|
26
|
+
**/node_modules
|
|
27
|
+
**/npm-debug.log
|
|
28
|
+
**/obj
|
|
29
|
+
**/secrets.dev.yaml
|
|
30
|
+
**/values.dev.yaml
|
|
31
|
+
**/build
|
|
32
|
+
**/dist
|
|
33
|
+
LICENSE
|
|
34
|
+
README.md
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
ARG NODE_VERSION=22
|
|
2
|
+
|
|
3
|
+
# Builder stage
|
|
4
|
+
FROM node:${NODE_VERSION}-alpine AS builder
|
|
5
|
+
|
|
6
|
+
WORKDIR /app
|
|
7
|
+
|
|
8
|
+
# Install necessary build tools
|
|
9
|
+
RUN apk add python3 gcc make g++
|
|
10
|
+
|
|
11
|
+
# Copy package.json and package-lock.json first for efficient caching
|
|
12
|
+
COPY package*.json ./
|
|
13
|
+
|
|
14
|
+
# Install dependencies only if package.json or package-lock.json have changed
|
|
15
|
+
RUN npm install
|
|
16
|
+
|
|
17
|
+
# Copy the rest of the application code
|
|
18
|
+
COPY . .
|
|
19
|
+
|
|
20
|
+
# Build the TypeScript application
|
|
21
|
+
RUN npm run build
|
|
22
|
+
|
|
23
|
+
# Production stage
|
|
24
|
+
FROM node:${NODE_VERSION}-alpine
|
|
25
|
+
|
|
26
|
+
WORKDIR /usr/src/app
|
|
27
|
+
|
|
28
|
+
# Install just the production dependencies
|
|
29
|
+
COPY --from=builder /app/package*.json ./
|
|
30
|
+
RUN npm install --only=prod
|
|
31
|
+
|
|
32
|
+
# Use multi-stage copy to avoid copying unnecessary files
|
|
33
|
+
COPY --from=builder /app/task-runner /usr/src/app/task-runner
|
|
34
|
+
COPY --from=builder /app/dist /usr/src/app/dist
|
|
35
|
+
|
|
36
|
+
# Use non-root user for security
|
|
37
|
+
RUN addgroup appuser && adduser -S appuser -G appuser && chown -R appuser:appuser /usr/src/app
|
|
38
|
+
USER appuser
|
|
39
|
+
|
|
40
|
+
# Set default ENTRYPOINT and CMD
|
|
41
|
+
ENTRYPOINT ["sh", "/usr/src/app/task-runner"]
|
|
42
|
+
CMD ["--help"]
|
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"}
|
|
@@ -16,7 +16,8 @@ export declare class TemplateService {
|
|
|
16
16
|
private copyDirectories;
|
|
17
17
|
private copyFiles;
|
|
18
18
|
private fixNaming;
|
|
19
|
-
private
|
|
19
|
+
private createGitIgnore;
|
|
20
|
+
private createDockerIgnore;
|
|
20
21
|
private removeDoubleNestedTestsDirectory;
|
|
21
22
|
private renameTaskRunner;
|
|
22
23
|
private initializeWithGit;
|
|
@@ -1 +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;
|
|
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;AAO3C,qBACa,eAAe;IA6BxB,OAAO,CAAC,YAAY;IACpB,OAAO,CAAC,MAAM;IA7BhB,OAAO,CAAC,UAAU,CAA0B;IAE5C,OAAO,CAAC,UAAU,CAAU;IAC5B,OAAO,CAAC,SAAS,CAAU;IAC3B,OAAO,CAAC,WAAW,CAAU;IAE7B,OAAO,CAAC,aAAa,CAAyC;IAC9D,OAAO,CAAC,cAAc,CAWpB;IACF,OAAO,CAAC,WAAW,CAMjB;gBAGQ,YAAY,EAAE,YAAY,EAC1B,MAAM,EAAE,UAAU;IASf,YAAY,CAAC,UAAU,EAAE,MAAM;YAqB9B,uBAAuB;YAMvB,eAAe;YASf,SAAS;YAST,SAAS;YAWT,eAAe;YAOf,kBAAkB;YAOlB,gCAAgC;YAUhC,gBAAgB;YAOhB,iBAAiB;CAQhC"}
|
|
@@ -18,13 +18,14 @@ const node_fs_1 = __importDefault(require("node:fs"));
|
|
|
18
18
|
const tsyringe_1 = require("tsyringe");
|
|
19
19
|
const spawn_service_1 = require("./spawn-service");
|
|
20
20
|
const log_service_1 = require("./log-service");
|
|
21
|
+
const docker_ignore_1 = require("../templates/docker-ignore");
|
|
21
22
|
const gitignoreContent = `node_modules
|
|
22
23
|
dist
|
|
23
24
|
.env`;
|
|
24
25
|
let TemplateService = class TemplateService {
|
|
25
26
|
spawnService;
|
|
26
27
|
logger;
|
|
27
|
-
loggerName = "Template Service";
|
|
28
|
+
loggerName = "Template Service :: ";
|
|
28
29
|
outputName;
|
|
29
30
|
sourceDir;
|
|
30
31
|
destination;
|
|
@@ -34,6 +35,7 @@ let TemplateService = class TemplateService {
|
|
|
34
35
|
".prettierrc",
|
|
35
36
|
"task-runner",
|
|
36
37
|
"install-link.sh",
|
|
38
|
+
"Dockerfile",
|
|
37
39
|
"eslint.config.ts",
|
|
38
40
|
"vitest.config.ts",
|
|
39
41
|
"package-lock.json",
|
|
@@ -45,6 +47,7 @@ let TemplateService = class TemplateService {
|
|
|
45
47
|
"package.json",
|
|
46
48
|
"package-lock.json",
|
|
47
49
|
"install-link.sh",
|
|
50
|
+
"Dockerfile",
|
|
48
51
|
];
|
|
49
52
|
constructor(spawnService, logger) {
|
|
50
53
|
this.spawnService = spawnService;
|
|
@@ -62,7 +65,8 @@ let TemplateService = class TemplateService {
|
|
|
62
65
|
await this.copyDirectories();
|
|
63
66
|
await this.copyFiles();
|
|
64
67
|
await this.fixNaming();
|
|
65
|
-
await this.
|
|
68
|
+
await this.createGitIgnore();
|
|
69
|
+
await this.createDockerIgnore();
|
|
66
70
|
await this.removeDoubleNestedTestsDirectory();
|
|
67
71
|
await this.renameTaskRunner();
|
|
68
72
|
await this.initializeWithGit();
|
|
@@ -99,9 +103,12 @@ let TemplateService = class TemplateService {
|
|
|
99
103
|
node_fs_1.default.writeFileSync(dest, content);
|
|
100
104
|
}
|
|
101
105
|
}
|
|
102
|
-
async
|
|
106
|
+
async createGitIgnore() {
|
|
103
107
|
node_fs_1.default.writeFileSync(node_path_1.default.join(this.destination, ".gitignore"), gitignoreContent);
|
|
104
108
|
}
|
|
109
|
+
async createDockerIgnore() {
|
|
110
|
+
node_fs_1.default.writeFileSync(node_path_1.default.join(this.destination, ".dockerignore"), (0, docker_ignore_1.dockerIgnoreTemplate)());
|
|
111
|
+
}
|
|
105
112
|
async removeDoubleNestedTestsDirectory() {
|
|
106
113
|
const doubleNestedTestsPath = node_path_1.default.join(this.destination, "tests", "tests");
|
|
107
114
|
if (node_fs_1.default.existsSync(doubleNestedTestsPath)) {
|
|
@@ -1 +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;
|
|
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;AAC3C,8DAAkE;AAElE,MAAM,gBAAgB,GAAG;;KAEpB,CAAC;AAGC,IAAM,eAAe,GAArB,MAAM,eAAe;IA6BhB;IACA;IA7BF,UAAU,GAAG,sBAAsB,CAAC;IAEpC,UAAU,CAAU;IACpB,SAAS,CAAU;IACnB,WAAW,CAAU;IAErB,aAAa,GAAa,CAAC,SAAS,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;IACtD,cAAc,GAAa;QACjC,iBAAiB;QACjB,aAAa;QACb,aAAa;QACb,iBAAiB;QACjB,YAAY;QACZ,kBAAkB;QAClB,kBAAkB;QAClB,mBAAmB;QACnB,cAAc;QACd,eAAe;KAChB,CAAC;IACM,WAAW,GAAa;QAC9B,kCAAkC;QAClC,cAAc;QACd,mBAAmB;QACnB,iBAAiB;QACjB,YAAY;KACb,CAAC;IAEF,YACU,YAA0B,EAC1B,MAAkB;QADlB,iBAAY,GAAZ,YAAY,CAAc;QAC1B,WAAM,GAAN,MAAM,CAAY;QAE1B,IAAI,CAAC,SAAS,GAAG,mBAAI,CAAC,IAAI,CACxB,SAAS,EACT,0CAA0C,CAC3C,CAAC;QACF,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IACzC,CAAC;IAEM,KAAK,CAAC,YAAY,CAAC,UAAkB;QAC1C,IAAI,CAAC,UAAU,EAAE,CAAC;YAChB,MAAM,IAAI,KAAK,CACb,4DAA4D,CAC7D,CAAC;QACJ,CAAC;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IAD3B,IAAA,yBAAc,GAAE;qCA8BS,4BAAY;QAClB,wBAAU;GA9BjB,eAAe,CAsI3B"}
|
|
@@ -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-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AC,MAAM,EAAE,CAAC;YAClB,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;YAC1B,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;IACH,CAAC;IAED;;;;OAIG;IACK,YAAY,CAAC,MAAgB;QACnC,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;YAClB,IAAI,CAAC,MAAM,CAAC,KAAK,CACf,IAAI,KAAK,CAAC,2BAA2B,CAAC,EACtC,eAAK,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAC7B,CAAC;QACJ,CAAC;IACH,CAAC;IAEO,eAAe,GAAG,CAAC,UAAoB,EAAE,EAAE,CACjD,UAAU;SACP,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;SAC/B,GAAG,CACF,CAAC,CAAC,EAAE,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"}
|
|
@@ -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;IAyBT;;;;;;;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"}
|
|
@@ -0,0 +1,120 @@
|
|
|
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
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
16
|
+
const file_service_1 = require("../../services/file-service");
|
|
17
|
+
const app_task_1 = require("../../wrappers/app-task");
|
|
18
|
+
const tsyringe_1 = require("tsyringe");
|
|
19
|
+
/**
|
|
20
|
+
* Checks so see if we are in the context of a task-script-support
|
|
21
|
+
* project or not and fails the process with a friendly error message.
|
|
22
|
+
*/
|
|
23
|
+
let ProjectContextGuard = class ProjectContextGuard extends app_task_1.AppTask {
|
|
24
|
+
fileService;
|
|
25
|
+
loggerName = "Project Context Check";
|
|
26
|
+
constructor(fileService) {
|
|
27
|
+
super();
|
|
28
|
+
this.fileService = fileService;
|
|
29
|
+
}
|
|
30
|
+
async run() {
|
|
31
|
+
this.logger.info(chalk_1.default.blueBright("Running Project Check"));
|
|
32
|
+
const errors = [];
|
|
33
|
+
try {
|
|
34
|
+
const projectDir = this.fileService.getRunnerRootDir();
|
|
35
|
+
this.checkProjectDependencies(projectDir, errors);
|
|
36
|
+
this.checkProjectDirectories(projectDir, errors);
|
|
37
|
+
}
|
|
38
|
+
catch (err) {
|
|
39
|
+
errors.push(`Unexpected error checking project: ${err}`);
|
|
40
|
+
}
|
|
41
|
+
if (errors.length) {
|
|
42
|
+
// give jimmy a message
|
|
43
|
+
this.logger.error(`\n\nš§ ${chalk_1.default.yellowBright("Note")}: This command requires execution from a ${chalk_1.default.blueBright("task-script-support")} project (folder)` +
|
|
44
|
+
`\n - Try running the ${chalk_1.default.blueBright("tssc " + chalk_1.default.bold("new"))} command to create a new project \n`, "Error Note");
|
|
45
|
+
}
|
|
46
|
+
this.checkToExit(errors);
|
|
47
|
+
this.setData({ environmentValidated: true });
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Check for the folders we need to generate files in. Add errors
|
|
51
|
+
* when no target directories can be found. Saves project data to
|
|
52
|
+
* state so we don't have to refetch it later.
|
|
53
|
+
*
|
|
54
|
+
* @param projectDir the target project root directory path
|
|
55
|
+
* @param errors string array error messages are added to
|
|
56
|
+
*/
|
|
57
|
+
checkProjectDirectories(projectDir, errors) {
|
|
58
|
+
const directories = {
|
|
59
|
+
taskFolders: this.fileService.getTaskDirs(projectDir),
|
|
60
|
+
serviceFolders: this.fileService.getServiceDirs(projectDir),
|
|
61
|
+
commandFolders: this.fileService.getCommandDirs(projectDir),
|
|
62
|
+
};
|
|
63
|
+
Object.keys(directories).forEach((k) => {
|
|
64
|
+
const key = k;
|
|
65
|
+
if (!directories[key] || !directories[key].length) {
|
|
66
|
+
errors.push(`Unable to find any ${k} in project`);
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
this.setData({
|
|
70
|
+
project: {
|
|
71
|
+
rootDir: projectDir,
|
|
72
|
+
...directories,
|
|
73
|
+
},
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Check that the project has the right dependencies installed. Adds
|
|
78
|
+
* to the errors array when they can't be found.
|
|
79
|
+
*
|
|
80
|
+
* @param projectDir the target project root directory path
|
|
81
|
+
* @param errors string array error messages are added to
|
|
82
|
+
*/
|
|
83
|
+
checkProjectDependencies(projectDir, errors) {
|
|
84
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
85
|
+
const packagePath = require(this.fileService.join(projectDir, "package.json"));
|
|
86
|
+
const requireDeps = ["task-script-support", "tsyringe"];
|
|
87
|
+
requireDeps.forEach((d) => {
|
|
88
|
+
if (!Object.keys(packagePath.dependencies || {}).includes(d)) {
|
|
89
|
+
errors.push(`Missing required dependencies in project: '${d}'`);
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Log and exit program if errors are present.
|
|
95
|
+
*
|
|
96
|
+
* @param errors the error messages array to check
|
|
97
|
+
*/
|
|
98
|
+
checkToExit(errors) {
|
|
99
|
+
if (errors.length) {
|
|
100
|
+
this.logEnvErrors(errors);
|
|
101
|
+
process.exit(1);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Logs any error messages in the provided array.
|
|
106
|
+
*
|
|
107
|
+
* @param errors the error messages array to log
|
|
108
|
+
*/
|
|
109
|
+
logEnvErrors(errors) {
|
|
110
|
+
if (errors.length) {
|
|
111
|
+
this.logger.error(new Error("Misconfigured Environment"), `Errors: \n${chalk_1.default.red(errors.join("\n"))}`);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
ProjectContextGuard = __decorate([
|
|
116
|
+
(0, tsyringe_1.autoInjectable)(),
|
|
117
|
+
__metadata("design:paramtypes", [file_service_1.FileService])
|
|
118
|
+
], ProjectContextGuard);
|
|
119
|
+
exports.default = ProjectContextGuard;
|
|
120
|
+
//# sourceMappingURL=project-context-guard.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project-context-guard.js","sourceRoot":"./src/","sources":["src/tasks/generate/project-context-guard.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,kDAA0B;AAC1B,8DAA0D;AAC1D,sDAAkD;AAClD,uCAA0C;AAE1C;;;GAGG;AAEY,IAAM,mBAAmB,GAAzB,MAAM,mBAAoB,SAAQ,kBAAO;IAGlC;IAFpB,UAAU,GAAG,uBAAuB,CAAC;IAErC,YAAoB,WAAwB;QAC1C,KAAK,EAAE,CAAC;QADU,gBAAW,GAAX,WAAW,CAAa;IAE5C,CAAC;IAED,KAAK,CAAC,GAAG;QACP,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,eAAK,CAAC,UAAU,CAAC,uBAAuB,CAAC,CAAC,CAAC;QAE5D,MAAM,MAAM,GAAa,EAAE,CAAC;QAC5B,IAAI,CAAC;YACH,MAAM,UAAU,GAAG,IAAI,CAAC,WAAW,CAAC,gBAAgB,EAAE,CAAC;YACvD,IAAI,CAAC,wBAAwB,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;YAClD,IAAI,CAAC,uBAAuB,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;QACnD,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,MAAM,CAAC,IAAI,CAAC,sCAAsC,GAAG,EAAE,CAAC,CAAC;QAC3D,CAAC;QAED,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;YAClB,uBAAuB;YACvB,IAAI,CAAC,MAAM,CAAC,KAAK,CACf,UAAU,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CAAC,IAAI,CAAC,UAAU,EAAE,cAAc,CAAC,CAClD,CAAC;QACF,MAAM,WAAW,GAAG,CAAC,qBAAqB,EAAE,UAAU,CAAC,CAAC;QACxD,WAAW,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE;YACxB,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,YAAY,IAAI,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC;gBAC7D,MAAM,CAAC,IAAI,CAAC,8CAA8C,CAAC,GAAG,CAAC,CAAC;YAClE,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC;IAED;;;;OAIG;IACK,WAAW,CAAC,MAAgB;QAClC,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;YAClB,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;YAC1B,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;IACH,CAAC;IAED;;;;OAIG;IACK,YAAY,CAAC,MAAgB;QACnC,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;YAClB,IAAI,CAAC,MAAM,CAAC,KAAK,CACf,IAAI,KAAK,CAAC,2BAA2B,CAAC,EACtC,aAAa,eAAK,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,EAAE,CAC5C,CAAC;QACJ,CAAC;IACH,CAAC;CACF,CAAA;AAzGoB,mBAAmB;IADvC,IAAA,yBAAc,GAAE;qCAIkB,0BAAW;GAHzB,mBAAmB,CAyGvC;kBAzGoB,mBAAmB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"docker-ignore.d.ts","sourceRoot":"./src/","sources":["src/templates/docker-ignore.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,oBAAoB,cAmChC,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.dockerIgnoreTemplate = void 0;
|
|
4
|
+
const dockerIgnoreTemplate = () => `
|
|
5
|
+
# Include any files or directories that you don't want to be copied to your
|
|
6
|
+
# container here (e.g., local build artifacts, temporary files, etc.).
|
|
7
|
+
#
|
|
8
|
+
# For more help, visit the .dockerignore file reference guide at
|
|
9
|
+
# https://docs.docker.com/go/build-context-dockerignore/
|
|
10
|
+
|
|
11
|
+
**/.classpath
|
|
12
|
+
**/.dockerignore
|
|
13
|
+
**/.env
|
|
14
|
+
**/.git
|
|
15
|
+
**/.gitignore
|
|
16
|
+
**/.project
|
|
17
|
+
**/.settings
|
|
18
|
+
**/.toolstarget
|
|
19
|
+
**/.vs
|
|
20
|
+
**/.vscode
|
|
21
|
+
**/.next
|
|
22
|
+
**/.cache
|
|
23
|
+
**/*.*proj.user
|
|
24
|
+
**/*.dbmdl
|
|
25
|
+
**/*.jfm
|
|
26
|
+
**/charts
|
|
27
|
+
**/docker-compose*
|
|
28
|
+
**/compose.y*ml
|
|
29
|
+
**/Dockerfile*
|
|
30
|
+
**/node_modules
|
|
31
|
+
**/npm-debug.log
|
|
32
|
+
**/obj
|
|
33
|
+
**/secrets.dev.yaml
|
|
34
|
+
**/values.dev.yaml
|
|
35
|
+
**/build
|
|
36
|
+
**/dist
|
|
37
|
+
LICENSE
|
|
38
|
+
README.md
|
|
39
|
+
`;
|
|
40
|
+
exports.dockerIgnoreTemplate = dockerIgnoreTemplate;
|
|
41
|
+
//# sourceMappingURL=docker-ignore.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"docker-ignore.js","sourceRoot":"./src/","sources":["src/templates/docker-ignore.ts"],"names":[],"mappings":";;;AAAO,MAAM,oBAAoB,GAAG,GAAG,EAAE,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAmCzC,CAAC;AAnCW,QAAA,oBAAoB,wBAmC/B"}
|
package/package.json
CHANGED
|
@@ -3,8 +3,9 @@ import { Command } from "../wrappers/command";
|
|
|
3
3
|
import CheckEnv from "../tasks/check-env";
|
|
4
4
|
import ConfigureCache from "../tasks/configure";
|
|
5
5
|
import PrintBanner from "../tasks/stdout/print-banner";
|
|
6
|
+
import ProjectContextGuard from "../tasks/generate/project-context-guard";
|
|
6
7
|
|
|
7
8
|
@singleton()
|
|
8
9
|
export class ConfigureCommand extends Command {
|
|
9
|
-
tasks = [PrintBanner, CheckEnv, ConfigureCache];
|
|
10
|
+
tasks = [PrintBanner, CheckEnv, ProjectContextGuard, ConfigureCache];
|
|
10
11
|
}
|
package/src/commands/gen.ts
CHANGED
|
@@ -9,12 +9,14 @@ import GenerateTask from "../tasks/generate/generate-task";
|
|
|
9
9
|
import PrintGeneratedResults from "../tasks/stdout/print-generated-results";
|
|
10
10
|
import SyncConfiguration from "../tasks/sync-configuration";
|
|
11
11
|
import SelectGenTargetName from "../tasks/generate/select-gen-target-name";
|
|
12
|
+
import ProjectContextGuard from "../tasks/generate/project-context-guard";
|
|
12
13
|
|
|
13
14
|
@singleton()
|
|
14
15
|
export class GenCommand extends Command {
|
|
15
16
|
tasks = [
|
|
16
17
|
PrintBanner,
|
|
17
18
|
CheckEnvironment,
|
|
19
|
+
ProjectContextGuard,
|
|
18
20
|
SelectGenTarget,
|
|
19
21
|
SyncConfiguration,
|
|
20
22
|
SelectGenTargetName,
|
|
@@ -3,6 +3,7 @@ import fs from "node:fs";
|
|
|
3
3
|
import { autoInjectable } from "tsyringe";
|
|
4
4
|
import { SpawnService } from "./spawn-service";
|
|
5
5
|
import { LogService } from "./log-service";
|
|
6
|
+
import { dockerIgnoreTemplate } from "../templates/docker-ignore";
|
|
6
7
|
|
|
7
8
|
const gitignoreContent = `node_modules
|
|
8
9
|
dist
|
|
@@ -10,7 +11,7 @@ dist
|
|
|
10
11
|
|
|
11
12
|
@autoInjectable()
|
|
12
13
|
export class TemplateService {
|
|
13
|
-
private loggerName = "Template Service";
|
|
14
|
+
private loggerName = "Template Service :: ";
|
|
14
15
|
|
|
15
16
|
private outputName!: string;
|
|
16
17
|
private sourceDir!: string;
|
|
@@ -22,6 +23,7 @@ export class TemplateService {
|
|
|
22
23
|
".prettierrc",
|
|
23
24
|
"task-runner",
|
|
24
25
|
"install-link.sh",
|
|
26
|
+
"Dockerfile",
|
|
25
27
|
"eslint.config.ts",
|
|
26
28
|
"vitest.config.ts",
|
|
27
29
|
"package-lock.json",
|
|
@@ -33,6 +35,7 @@ export class TemplateService {
|
|
|
33
35
|
"package.json",
|
|
34
36
|
"package-lock.json",
|
|
35
37
|
"install-link.sh",
|
|
38
|
+
"Dockerfile",
|
|
36
39
|
];
|
|
37
40
|
|
|
38
41
|
constructor(
|
|
@@ -59,7 +62,8 @@ export class TemplateService {
|
|
|
59
62
|
await this.copyDirectories();
|
|
60
63
|
await this.copyFiles();
|
|
61
64
|
await this.fixNaming();
|
|
62
|
-
await this.
|
|
65
|
+
await this.createGitIgnore();
|
|
66
|
+
await this.createDockerIgnore();
|
|
63
67
|
await this.removeDoubleNestedTestsDirectory();
|
|
64
68
|
await this.renameTaskRunner();
|
|
65
69
|
await this.initializeWithGit();
|
|
@@ -101,13 +105,20 @@ export class TemplateService {
|
|
|
101
105
|
}
|
|
102
106
|
}
|
|
103
107
|
|
|
104
|
-
private async
|
|
108
|
+
private async createGitIgnore() {
|
|
105
109
|
fs.writeFileSync(
|
|
106
110
|
path.join(this.destination, ".gitignore"),
|
|
107
111
|
gitignoreContent,
|
|
108
112
|
);
|
|
109
113
|
}
|
|
110
114
|
|
|
115
|
+
private async createDockerIgnore() {
|
|
116
|
+
fs.writeFileSync(
|
|
117
|
+
path.join(this.destination, ".dockerignore"),
|
|
118
|
+
dockerIgnoreTemplate(),
|
|
119
|
+
);
|
|
120
|
+
}
|
|
121
|
+
|
|
111
122
|
private async removeDoubleNestedTestsDirectory() {
|
|
112
123
|
const doubleNestedTestsPath = path.join(this.destination, "tests", "tests");
|
|
113
124
|
if (fs.existsSync(doubleNestedTestsPath)) {
|
package/src/tasks/check-env.ts
CHANGED
|
@@ -3,7 +3,6 @@ import { AppTask } from "../wrappers/app-task";
|
|
|
3
3
|
import { autoInjectable } from "tsyringe";
|
|
4
4
|
import { EnvironmentConfigKeys } from "../types/state";
|
|
5
5
|
import { FileService } from "../services/file-service";
|
|
6
|
-
import path from "path";
|
|
7
6
|
|
|
8
7
|
/**
|
|
9
8
|
* Checks the environment configuration
|
|
@@ -35,64 +34,10 @@ export default class CheckEnvironment extends AppTask {
|
|
|
35
34
|
const errors: string[] = this.getErrorMessages(this.requiredEnvVars);
|
|
36
35
|
this.checkToExit(errors);
|
|
37
36
|
|
|
38
|
-
try {
|
|
39
|
-
const projectDir = this.fileService.getRunnerRootDir();
|
|
40
|
-
this.checkProjectDependencies(projectDir, errors);
|
|
41
|
-
this.checkProjectDirectories(projectDir, errors);
|
|
42
|
-
} catch (err) {
|
|
43
|
-
errors.push(`Unexpected error checking project: ${err}`);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
37
|
this.checkToExit(errors);
|
|
47
38
|
this.setData({ environmentValidated: true });
|
|
48
39
|
}
|
|
49
40
|
|
|
50
|
-
/**
|
|
51
|
-
* Check for the folders we need to generate files in. Add errors
|
|
52
|
-
* when no target directories can be found. Saves project data to
|
|
53
|
-
* state so we don't have to refetch it later.
|
|
54
|
-
*
|
|
55
|
-
* @param projectDir the target project root directory path
|
|
56
|
-
* @param errors string array error messages are added to
|
|
57
|
-
*/
|
|
58
|
-
checkProjectDirectories(projectDir: string, errors: string[]) {
|
|
59
|
-
const directories = {
|
|
60
|
-
taskFolders: this.fileService.getTaskDirs(projectDir),
|
|
61
|
-
serviceFolders: this.fileService.getServiceDirs(projectDir),
|
|
62
|
-
commandFolders: this.fileService.getCommandDirs(projectDir),
|
|
63
|
-
};
|
|
64
|
-
Object.keys(directories).forEach((k: string) => {
|
|
65
|
-
const key: keyof typeof directories = k as keyof typeof directories;
|
|
66
|
-
if (!directories[key] || !directories[key].length) {
|
|
67
|
-
errors.push(`Unable to find any ${k} in project`);
|
|
68
|
-
}
|
|
69
|
-
});
|
|
70
|
-
this.setData({
|
|
71
|
-
project: {
|
|
72
|
-
rootDir: projectDir,
|
|
73
|
-
...directories,
|
|
74
|
-
},
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* Check that the project has the right dependencies installed. Adds
|
|
80
|
-
* to the errors array when they can't be found.
|
|
81
|
-
*
|
|
82
|
-
* @param projectDir the target project root directory path
|
|
83
|
-
* @param errors string array error messages are added to
|
|
84
|
-
*/
|
|
85
|
-
checkProjectDependencies(projectDir: string, errors: string[]) {
|
|
86
|
-
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
87
|
-
const packagePath = require(path.join(projectDir, "package.json"));
|
|
88
|
-
const requireDeps = ["task-script-support", "tsyringe"];
|
|
89
|
-
requireDeps.forEach((d) => {
|
|
90
|
-
if (!Object.keys(packagePath.dependencies || {}).includes(d)) {
|
|
91
|
-
errors.push(`Missing required dependencies in project: '${d}'`);
|
|
92
|
-
}
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
-
|
|
96
41
|
/**
|
|
97
42
|
* Log and exit program if errors are present.
|
|
98
43
|
*
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import chalk from "chalk";
|
|
2
|
+
import { FileService } from "../../services/file-service";
|
|
3
|
+
import { AppTask } from "../../wrappers/app-task";
|
|
4
|
+
import { autoInjectable } from "tsyringe";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Checks so see if we are in the context of a task-script-support
|
|
8
|
+
* project or not and fails the process with a friendly error message.
|
|
9
|
+
*/
|
|
10
|
+
@autoInjectable()
|
|
11
|
+
export default class ProjectContextGuard extends AppTask {
|
|
12
|
+
loggerName = "Project Context Check";
|
|
13
|
+
|
|
14
|
+
constructor(private fileService: FileService) {
|
|
15
|
+
super();
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
async run() {
|
|
19
|
+
this.logger.info(chalk.blueBright("Running Project Check"));
|
|
20
|
+
|
|
21
|
+
const errors: string[] = [];
|
|
22
|
+
try {
|
|
23
|
+
const projectDir = this.fileService.getRunnerRootDir();
|
|
24
|
+
this.checkProjectDependencies(projectDir, errors);
|
|
25
|
+
this.checkProjectDirectories(projectDir, errors);
|
|
26
|
+
} catch (err) {
|
|
27
|
+
errors.push(`Unexpected error checking project: ${err}`);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
if (errors.length) {
|
|
31
|
+
// give jimmy a message
|
|
32
|
+
this.logger.error(
|
|
33
|
+
`\n\nš§ ${chalk.yellowBright("Note")}: This command requires execution from a ${chalk.blueBright("task-script-support")} project (folder)` +
|
|
34
|
+
`\n - Try running the ${chalk.blueBright("tssc " + chalk.bold("new"))} command to create a new project \n`,
|
|
35
|
+
"Error Note",
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
this.checkToExit(errors);
|
|
40
|
+
this.setData({ environmentValidated: true });
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Check for the folders we need to generate files in. Add errors
|
|
45
|
+
* when no target directories can be found. Saves project data to
|
|
46
|
+
* state so we don't have to refetch it later.
|
|
47
|
+
*
|
|
48
|
+
* @param projectDir the target project root directory path
|
|
49
|
+
* @param errors string array error messages are added to
|
|
50
|
+
*/
|
|
51
|
+
checkProjectDirectories(projectDir: string, errors: string[]) {
|
|
52
|
+
const directories = {
|
|
53
|
+
taskFolders: this.fileService.getTaskDirs(projectDir),
|
|
54
|
+
serviceFolders: this.fileService.getServiceDirs(projectDir),
|
|
55
|
+
commandFolders: this.fileService.getCommandDirs(projectDir),
|
|
56
|
+
};
|
|
57
|
+
Object.keys(directories).forEach((k: string) => {
|
|
58
|
+
const key: keyof typeof directories = k as keyof typeof directories;
|
|
59
|
+
if (!directories[key] || !directories[key].length) {
|
|
60
|
+
errors.push(`Unable to find any ${k} in project`);
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
this.setData({
|
|
64
|
+
project: {
|
|
65
|
+
rootDir: projectDir,
|
|
66
|
+
...directories,
|
|
67
|
+
},
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Check that the project has the right dependencies installed. Adds
|
|
73
|
+
* to the errors array when they can't be found.
|
|
74
|
+
*
|
|
75
|
+
* @param projectDir the target project root directory path
|
|
76
|
+
* @param errors string array error messages are added to
|
|
77
|
+
*/
|
|
78
|
+
checkProjectDependencies(projectDir: string, errors: string[]) {
|
|
79
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
80
|
+
const packagePath = require(
|
|
81
|
+
this.fileService.join(projectDir, "package.json"),
|
|
82
|
+
);
|
|
83
|
+
const requireDeps = ["task-script-support", "tsyringe"];
|
|
84
|
+
requireDeps.forEach((d) => {
|
|
85
|
+
if (!Object.keys(packagePath.dependencies || {}).includes(d)) {
|
|
86
|
+
errors.push(`Missing required dependencies in project: '${d}'`);
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Log and exit program if errors are present.
|
|
93
|
+
*
|
|
94
|
+
* @param errors the error messages array to check
|
|
95
|
+
*/
|
|
96
|
+
private checkToExit(errors: string[]) {
|
|
97
|
+
if (errors.length) {
|
|
98
|
+
this.logEnvErrors(errors);
|
|
99
|
+
process.exit(1);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Logs any error messages in the provided array.
|
|
105
|
+
*
|
|
106
|
+
* @param errors the error messages array to log
|
|
107
|
+
*/
|
|
108
|
+
private logEnvErrors(errors: string[]): void {
|
|
109
|
+
if (errors.length) {
|
|
110
|
+
this.logger.error(
|
|
111
|
+
new Error("Misconfigured Environment"),
|
|
112
|
+
`Errors: \n${chalk.red(errors.join("\n"))}`,
|
|
113
|
+
);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
export const dockerIgnoreTemplate = () => `
|
|
2
|
+
# Include any files or directories that you don't want to be copied to your
|
|
3
|
+
# container here (e.g., local build artifacts, temporary files, etc.).
|
|
4
|
+
#
|
|
5
|
+
# For more help, visit the .dockerignore file reference guide at
|
|
6
|
+
# https://docs.docker.com/go/build-context-dockerignore/
|
|
7
|
+
|
|
8
|
+
**/.classpath
|
|
9
|
+
**/.dockerignore
|
|
10
|
+
**/.env
|
|
11
|
+
**/.git
|
|
12
|
+
**/.gitignore
|
|
13
|
+
**/.project
|
|
14
|
+
**/.settings
|
|
15
|
+
**/.toolstarget
|
|
16
|
+
**/.vs
|
|
17
|
+
**/.vscode
|
|
18
|
+
**/.next
|
|
19
|
+
**/.cache
|
|
20
|
+
**/*.*proj.user
|
|
21
|
+
**/*.dbmdl
|
|
22
|
+
**/*.jfm
|
|
23
|
+
**/charts
|
|
24
|
+
**/docker-compose*
|
|
25
|
+
**/compose.y*ml
|
|
26
|
+
**/Dockerfile*
|
|
27
|
+
**/node_modules
|
|
28
|
+
**/npm-debug.log
|
|
29
|
+
**/obj
|
|
30
|
+
**/secrets.dev.yaml
|
|
31
|
+
**/values.dev.yaml
|
|
32
|
+
**/build
|
|
33
|
+
**/dist
|
|
34
|
+
LICENSE
|
|
35
|
+
README.md
|
|
36
|
+
`;
|