@tsed/cli 3.25.0 → 4.0.0-rc.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/Cli.js.map +1 -1
- package/lib/cjs/commands/init/InitCmd.js +70 -35
- package/lib/cjs/commands/init/InitCmd.js.map +1 -1
- package/lib/cjs/commands/init/config/FeaturesPrompt.js +406 -0
- package/lib/cjs/commands/init/config/FeaturesPrompt.js.map +1 -0
- package/lib/cjs/commands/init/config/InitFileSchema.js +53 -0
- package/lib/cjs/commands/init/config/InitFileSchema.js.map +1 -0
- package/lib/cjs/commands/init/interfaces/InitCmdContext.js +3 -0
- package/lib/cjs/commands/init/interfaces/InitCmdContext.js.map +1 -0
- package/lib/cjs/commands/init/interfaces/InitOptions.js +3 -0
- package/lib/cjs/commands/init/interfaces/InitOptions.js.map +1 -0
- package/lib/cjs/commands/init/interfaces/InitPromptAnswers.js +3 -0
- package/lib/cjs/commands/init/interfaces/InitPromptAnswers.js.map +1 -0
- package/lib/cjs/commands/init/mappers/mapToContext.js +16 -0
- package/lib/cjs/commands/init/mappers/mapToContext.js.map +1 -0
- package/lib/cjs/commands/init/mappers/mapUniqFeatures.js +18 -0
- package/lib/cjs/commands/init/mappers/mapUniqFeatures.js.map +1 -0
- package/lib/cjs/commands/init/prompts/getFeaturesPrompt.js +25 -0
- package/lib/cjs/commands/init/prompts/getFeaturesPrompt.js.map +1 -0
- package/lib/cjs/commands/init/utils/hasFeature.js +13 -0
- package/lib/cjs/commands/init/utils/hasFeature.js.map +1 -0
- package/lib/cjs/commands/init/utils/isPlatform.js +8 -0
- package/lib/cjs/commands/init/utils/isPlatform.js.map +1 -0
- package/lib/cjs/constants/index.js +3 -3
- package/lib/cjs/constants/index.js.map +1 -1
- package/lib/cjs/index.js +5 -1
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/interfaces/PlatformType.js +9 -0
- package/lib/cjs/interfaces/PlatformType.js.map +1 -0
- package/lib/cjs/interfaces/index.js +1 -0
- package/lib/cjs/interfaces/index.js.map +1 -1
- package/lib/esm/Cli.js.map +1 -1
- package/lib/esm/commands/init/InitCmd.js +73 -38
- package/lib/esm/commands/init/InitCmd.js.map +1 -1
- package/lib/esm/commands/init/config/FeaturesPrompt.js +402 -0
- package/lib/esm/commands/init/config/FeaturesPrompt.js.map +1 -0
- package/lib/esm/commands/init/config/InitFileSchema.js +50 -0
- package/lib/esm/commands/init/config/InitFileSchema.js.map +1 -0
- package/lib/esm/commands/init/interfaces/InitCmdContext.js +2 -0
- package/lib/esm/commands/init/interfaces/InitCmdContext.js.map +1 -0
- package/lib/esm/commands/init/interfaces/InitOptions.js +2 -0
- package/lib/esm/commands/init/interfaces/InitOptions.js.map +1 -0
- package/lib/esm/commands/init/interfaces/InitPromptAnswers.js +2 -0
- package/lib/esm/commands/init/interfaces/InitPromptAnswers.js.map +1 -0
- package/lib/esm/commands/init/mappers/mapToContext.js +12 -0
- package/lib/esm/commands/init/mappers/mapToContext.js.map +1 -0
- package/lib/esm/commands/init/mappers/mapUniqFeatures.js +14 -0
- package/lib/esm/commands/init/mappers/mapUniqFeatures.js.map +1 -0
- package/lib/esm/commands/init/prompts/getFeaturesPrompt.js +21 -0
- package/lib/esm/commands/init/prompts/getFeaturesPrompt.js.map +1 -0
- package/lib/esm/commands/init/utils/hasFeature.js +8 -0
- package/lib/esm/commands/init/utils/hasFeature.js.map +1 -0
- package/lib/esm/commands/init/utils/isPlatform.js +4 -0
- package/lib/esm/commands/init/utils/isPlatform.js.map +1 -0
- package/lib/esm/constants/index.js +3 -3
- package/lib/esm/constants/index.js.map +1 -1
- package/lib/esm/index.js +5 -1
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/interfaces/PlatformType.js +6 -0
- package/lib/esm/interfaces/PlatformType.js.map +1 -0
- package/lib/esm/interfaces/index.js +1 -0
- package/lib/esm/interfaces/index.js.map +1 -1
- package/lib/types/Cli.d.ts +2 -2
- package/lib/types/commands/init/InitCmd.d.ts +8 -24
- package/lib/types/commands/init/config/FeaturesPrompt.d.ts +98 -0
- package/lib/types/commands/init/config/InitFileSchema.d.ts +49 -0
- package/lib/types/commands/init/interfaces/InitCmdContext.d.ts +6 -0
- package/lib/types/commands/init/interfaces/InitOptions.d.ts +19 -0
- package/lib/types/commands/init/interfaces/InitPromptAnswers.d.ts +16 -0
- package/lib/types/commands/init/mappers/mapToContext.d.ts +2 -0
- package/lib/types/commands/init/mappers/mapUniqFeatures.d.ts +3 -0
- package/lib/types/commands/init/prompts/getFeaturesPrompt.d.ts +2 -0
- package/lib/types/commands/init/utils/hasFeature.d.ts +2 -0
- package/lib/types/commands/init/utils/isPlatform.d.ts +1 -0
- package/lib/types/constants/index.d.ts +2 -2
- package/lib/types/index.d.ts +5 -1
- package/lib/types/interfaces/PlatformType.d.ts +4 -0
- package/lib/types/interfaces/index.d.ts +1 -0
- package/package.json +14 -9
- package/readme.md +104 -14
- package/templates/init/tsconfig.json.hbs +5 -3
- package/lib/cjs/services/Features.js +0 -528
- package/lib/cjs/services/Features.js.map +0 -1
- package/lib/esm/services/Features.js +0 -519
- package/lib/esm/services/Features.js.map +0 -1
- package/lib/types/services/Features.d.ts +0 -412
package/lib/cjs/Cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Cli.js","sourceRoot":"","sources":["../../src/Cli.ts"],"names":[],"mappings":";;;;AAAA,6CAAuC;AACvC,0DAA0B;AAC1B,6DAA6D;AAC7D,aAAa;AACb,wEAAiC;AACjC,2CAA8C;AAC9C,kEAAkC;AAClC,6CAAuE;AAIvE,MAAa,GAAI,SAAQ,kBAAO;IAC9B,MAAM,CAAC,QAAQ,GAAG;QAChB,IAAI,EAAE,MAAM;QACZ,GAAG,EAAE,eAAG;QACR,WAAW,EAAE,wBAAY;QACzB,OAAO,EAAE,IAAI;QACb,QAAQ,EAAR,kBAAQ;QACR,yBAAyB;YACvB,OAAO;gBACL,UAAU,EAAE,8BAAiB,CAAC,O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AAC;QACrB,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC;QAEzB,OAAO,KAAK,CAAC,SAAS,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;IACpC,CAAC;IAID,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,GAAW,EAAE,OAAY;QAC7C,IAAI,CAAC,aAAa,EAAE,CAAC;QAErB,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,MAAM,CAAM,EAAC,GAAG,GAAG,CAAC,QAAQ,EAAQ,EAAE,GAAG,CAAC,CAAC;QAElE,MAAM,GAAG,CAAC,UAAU,CAAC,QAAQ,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IAC9C,CAAC;IAED,MAAM,CAAC,aAAa;QAClB,sBAAK,CAAC,UAAU,CAAC;YACf,YAAY,EAAE,OAAO,CAAC,OAAO,CAAC,YAAY,CAAC;YAC3C,UAAU,EAAE,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC;YACvC,cAAc,EAAE,OAAO,CAAC,OAAO,CAAC,cAAc,CAAC;YAC/C,gBAAgB,EAAE,OAAO,CAAC,OAAO,CAAC,gBAAgB,CAAC;YACnD,WAAW,EAAE,OAAO,CAAC,OAAO,CAAC,WAAW,CAAC;SAC1C,CAAC,CAAC;IACL,CAAC;;AA/EH,kBAgFC","sourcesContent":["import {CliCore} from \"@tsed/cli-core\";\nimport chalk from \"chalk\";\n// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-ignore\nimport alias from \"module-alias\";\nimport {PKG, TEMPLATE_DIR} from \"./constants\";\nimport commands from \"./commands\";\nimport {ArchitectureConvention, ProjectConvention} from \"./interfaces\";\nimport {InitCmdContext} from \"./commands/init/
|
|
1
|
+
{"version":3,"file":"Cli.js","sourceRoot":"","sources":["../../src/Cli.ts"],"names":[],"mappings":";;;;AAAA,6CAAuC;AACvC,0DAA0B;AAC1B,6DAA6D;AAC7D,aAAa;AACb,wEAAiC;AACjC,2CAA8C;AAC9C,kEAAk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M,CAAC,KAAK,CAAC,SAAS,CAAC,WAAgB,EAAE;QACvC,MAAM,IAAI,GAAQ;YAChB,GAAG,GAAG,CAAC,QAAQ;YACf,GAAG,QAAQ;SACZ,CAAC;QAEF,MAAM,EAAC,GAAG,EAAC,GAAG,IAAI,CAAC;QAEnB,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC;QAC7B,IAAI,CAAC,aAAa,EAAE,CAAC;QACrB,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC;QAEzB,OAAO,KAAK,CAAC,SAAS,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;IACpC,CAAC;IAID,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,GAAW,EAAE,OAAY;QAC7C,IAAI,CAAC,aAAa,EAAE,CAAC;QAErB,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,MAAM,CAAM,EAAC,GAAG,GAAG,CAAC,QAAQ,EAAQ,EAAE,GAAG,CAAC,CAAC;QAElE,MAAM,GAAG,CAAC,UAAU,CAAC,QAAQ,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IAC9C,CAAC;IAED,MAAM,CAAC,aAAa;QAClB,sBAAK,CAAC,UAAU,CAAC;YACf,YAAY,EAAE,OAAO,CAAC,OAAO,CAAC,YAAY,CAAC;YAC3C,UAAU,EAAE,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC;YACvC,cAAc,EAAE,OAAO,CAAC,OAAO,CAAC,cAAc,CAAC;YAC/C,gBAAgB,EAAE,OAAO,CAAC,OAAO,CAAC,gBAAgB,CAAC;YACnD,WAAW,EAAE,OAAO,CAAC,OAAO,CAAC,WAAW,CAAC;SAC1C,CAAC,CAAC;IACL,CAAC;;AA/EH,kBAgFC","sourcesContent":["import {CliCore} from \"@tsed/cli-core\";\nimport chalk from \"chalk\";\n// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-ignore\nimport alias from \"module-alias\";\nimport {PKG, TEMPLATE_DIR} from \"./constants\";\nimport commands from \"./commands\";\nimport {ArchitectureConvention, ProjectConvention} from \"./interfaces\";\nimport {InitCmdContext} from \"./commands/init/interfaces/InitCmdContext\";\nimport {GenerateCmdContext} from \"./commands/generate/GenerateCmd\";\n\nexport class Cli extends CliCore {\n static defaults = {\n name: \"tsed\",\n pkg: PKG,\n templateDir: TEMPLATE_DIR,\n plugins: true,\n commands,\n defaultProjectPreferences() {\n return {\n convention: ProjectConvention.DEFAULT,\n architecture: ArchitectureConvention.DEFAULT\n };\n },\n project: {\n reinstallAfterRun: true\n },\n logger: {\n level: \"info\"\n }\n };\n\n static checkPackage(pkg: any) {\n if (!pkg) {\n console.log(chalk.red(`settings.pkg is required. Require the package.json of your CLI when you bootstrap the CLI.`));\n process.exit(1);\n }\n }\n\n static checkName(name: string) {\n if (!name) {\n console.log(chalk.red(`settings.name is required. Add the name of your CLI.`));\n process.exit(1);\n }\n }\n\n static checkPrecondition(settings: any) {\n const {pkg} = settings;\n\n this.checkPackage(pkg);\n this.checkName(pkg.name);\n\n if (pkg?.engines?.node) {\n this.checkNodeVersion(pkg.engines.node, pkg.name);\n }\n }\n\n static async bootstrap(settings: any = {}) {\n const opts: any = {\n ...Cli.defaults,\n ...settings\n };\n\n const {pkg} = opts;\n\n this.checkPrecondition(opts);\n this.createAliases();\n this.updateNotifier(pkg);\n\n return super.bootstrap(opts, Cli);\n }\n\n static async dispatch(cmd: \"init\", context: InitCmdContext): Promise<void>;\n static async dispatch(cmd: \"generate\", context: GenerateCmdContext): Promise<void>;\n static async dispatch(cmd: string, context: any) {\n this.createAliases();\n\n const cli = await this.create<Cli>({...Cli.defaults} as any, Cli);\n\n await cli.cliService.dispatch(cmd, context);\n }\n\n static createAliases() {\n alias.addAliases({\n \"@tsed/core\": require.resolve(\"@tsed/core\"),\n \"@tsed/di\": require.resolve(\"@tsed/di\"),\n \"@tsed/schema\": require.resolve(\"@tsed/schema\"),\n \"@tsed/cli-core\": require.resolve(\"@tsed/cli-core\"),\n \"@tsed/cli\": require.resolve(\"@tsed/cli\")\n });\n }\n}\n"]}
|
|
@@ -6,30 +6,39 @@ const cli_core_1 = require("@tsed/cli-core");
|
|
|
6
6
|
const change_case_1 = require("change-case");
|
|
7
7
|
const path_1 = require("path");
|
|
8
8
|
const constants_1 = require("../../constants");
|
|
9
|
+
const ArchitectureConvention_1 = require("../../interfaces/ArchitectureConvention");
|
|
10
|
+
const ProjectConvention_1 = require("../../interfaces/ProjectConvention");
|
|
9
11
|
const OutputFilePathPipe_1 = require("../../pipes/OutputFilePathPipe");
|
|
10
|
-
const
|
|
12
|
+
const InitFileSchema_1 = require("./config/InitFileSchema");
|
|
13
|
+
const mapToContext_1 = require("./mappers/mapToContext");
|
|
14
|
+
const FeaturesPrompt_1 = require("./config/FeaturesPrompt");
|
|
15
|
+
const getFeaturesPrompt_1 = require("./prompts/getFeaturesPrompt");
|
|
16
|
+
const interfaces_1 = require("../../interfaces");
|
|
11
17
|
let InitCmd = class InitCmd {
|
|
12
18
|
configuration;
|
|
13
19
|
cliPlugins;
|
|
14
20
|
packageJson;
|
|
15
|
-
|
|
21
|
+
cliPackageJson;
|
|
16
22
|
cliService;
|
|
23
|
+
cliLoadFile;
|
|
17
24
|
rootRenderer;
|
|
18
25
|
outputFilePathPipe;
|
|
19
26
|
execa;
|
|
20
27
|
fs;
|
|
21
28
|
async $beforePrompt(initialOptions) {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
29
|
+
if (initialOptions.file) {
|
|
30
|
+
const file = (0, path_1.join)(this.packageJson.dir, initialOptions.file);
|
|
31
|
+
return {
|
|
32
|
+
...initialOptions,
|
|
33
|
+
...(await this.cliLoadFile.loadFile(file, InitFileSchema_1.InitFileSchema))
|
|
34
|
+
};
|
|
28
35
|
}
|
|
29
36
|
return initialOptions;
|
|
30
37
|
}
|
|
31
38
|
$prompt(initialOptions) {
|
|
32
|
-
|
|
39
|
+
if (initialOptions.skipPrompt) {
|
|
40
|
+
return [];
|
|
41
|
+
}
|
|
33
42
|
return [
|
|
34
43
|
{
|
|
35
44
|
type: "input",
|
|
@@ -41,32 +50,16 @@ let InitCmd = class InitCmd {
|
|
|
41
50
|
return (0, change_case_1.paramCase)(input);
|
|
42
51
|
}
|
|
43
52
|
},
|
|
44
|
-
...
|
|
53
|
+
...(0, getFeaturesPrompt_1.getFeaturesPrompt)(initialOptions)
|
|
45
54
|
];
|
|
46
55
|
}
|
|
47
56
|
$mapContext(ctx) {
|
|
48
57
|
this.resolveRootDir(ctx);
|
|
49
|
-
|
|
50
|
-
Object.entries(ctx)
|
|
51
|
-
.filter(([key]) => key.startsWith("features") && key !== "featuresFile")
|
|
52
|
-
.forEach(([key, value]) => {
|
|
53
|
-
delete ctx[key];
|
|
54
|
-
features.push(...[].concat(value));
|
|
55
|
-
});
|
|
56
|
-
features.forEach((feature) => {
|
|
57
|
-
feature.type.split(":").forEach((type) => {
|
|
58
|
-
ctx[(0, change_case_1.camelCase)(type)] = true;
|
|
59
|
-
});
|
|
60
|
-
});
|
|
58
|
+
ctx = (0, mapToContext_1.mapToContext)(ctx);
|
|
61
59
|
return {
|
|
62
60
|
...ctx,
|
|
63
|
-
|
|
61
|
+
cliVersion: ctx.cliVersion || this.cliPackageJson.version,
|
|
64
62
|
srcDir: this.configuration.project?.srcDir,
|
|
65
|
-
pnpm: ctx.packageManager === cli_core_1.PackageManager.PNPM,
|
|
66
|
-
npm: ctx.packageManager === cli_core_1.PackageManager.NPM,
|
|
67
|
-
yarn: ctx.packageManager === cli_core_1.PackageManager.YARN,
|
|
68
|
-
express: ctx.platform === "express",
|
|
69
|
-
koa: ctx.platform === "koa",
|
|
70
63
|
platformSymbol: ctx.platform && (0, change_case_1.pascalCase)(`Platform ${ctx.platform}`)
|
|
71
64
|
};
|
|
72
65
|
}
|
|
@@ -256,7 +249,8 @@ let InitCmd = class InitCmd {
|
|
|
256
249
|
}
|
|
257
250
|
}
|
|
258
251
|
addFeatures(ctx) {
|
|
259
|
-
ctx.features.forEach((
|
|
252
|
+
ctx.features.forEach((value) => {
|
|
253
|
+
const feature = FeaturesPrompt_1.FeaturesMap[value];
|
|
260
254
|
if (feature.dependencies) {
|
|
261
255
|
this.packageJson.addDependencies(feature.dependencies, ctx);
|
|
262
256
|
}
|
|
@@ -272,7 +266,7 @@ let InitCmd = class InitCmd {
|
|
|
272
266
|
this.addKoaDependencies(ctx);
|
|
273
267
|
break;
|
|
274
268
|
}
|
|
275
|
-
if (ctx.features.find((
|
|
269
|
+
if (ctx.features.find((value) => value === FeaturesPrompt_1.FeatureType.GRAPHQL)) {
|
|
276
270
|
this.packageJson.addDependencies({
|
|
277
271
|
["apollo-server-" + ctx.platform]: "2.25.2"
|
|
278
272
|
}, ctx);
|
|
@@ -332,13 +326,17 @@ tslib_1.__decorate([
|
|
|
332
326
|
tslib_1.__metadata("design:type", cli_core_1.ProjectPackageJson)
|
|
333
327
|
], InitCmd.prototype, "packageJson", void 0);
|
|
334
328
|
tslib_1.__decorate([
|
|
335
|
-
(0,
|
|
336
|
-
tslib_1.__metadata("design:type",
|
|
337
|
-
], InitCmd.prototype, "
|
|
329
|
+
(0, cli_core_1.CliPackageJson)(),
|
|
330
|
+
tslib_1.__metadata("design:type", Object)
|
|
331
|
+
], InitCmd.prototype, "cliPackageJson", void 0);
|
|
338
332
|
tslib_1.__decorate([
|
|
339
333
|
(0, cli_core_1.Inject)(),
|
|
340
334
|
tslib_1.__metadata("design:type", cli_core_1.CliService)
|
|
341
335
|
], InitCmd.prototype, "cliService", void 0);
|
|
336
|
+
tslib_1.__decorate([
|
|
337
|
+
(0, cli_core_1.Inject)(),
|
|
338
|
+
tslib_1.__metadata("design:type", cli_core_1.CliLoadFile)
|
|
339
|
+
], InitCmd.prototype, "cliLoadFile", void 0);
|
|
342
340
|
tslib_1.__decorate([
|
|
343
341
|
(0, cli_core_1.Inject)(),
|
|
344
342
|
tslib_1.__metadata("design:type", cli_core_1.RootRendererService)
|
|
@@ -367,14 +365,51 @@ InitCmd = tslib_1.__decorate([
|
|
|
367
365
|
}
|
|
368
366
|
},
|
|
369
367
|
options: {
|
|
368
|
+
"-n, --project-name <projectName>": {
|
|
369
|
+
type: String,
|
|
370
|
+
defaultValue: "",
|
|
371
|
+
description: "Set the project name. By default, the project is the same as the name directory."
|
|
372
|
+
},
|
|
373
|
+
"-a, --arch <architecture>": {
|
|
374
|
+
type: String,
|
|
375
|
+
defaultValue: ArchitectureConvention_1.ArchitectureConvention.DEFAULT,
|
|
376
|
+
description: `Set the default architecture convention (${ArchitectureConvention_1.ArchitectureConvention.DEFAULT} or ${ArchitectureConvention_1.ArchitectureConvention.FEATURE})`
|
|
377
|
+
},
|
|
378
|
+
"-c, --convention <convention>": {
|
|
379
|
+
type: String,
|
|
380
|
+
defaultValue: ProjectConvention_1.ProjectConvention.DEFAULT,
|
|
381
|
+
description: `Set the default project convention (${ArchitectureConvention_1.ArchitectureConvention.DEFAULT} or ${ArchitectureConvention_1.ArchitectureConvention.FEATURE})`
|
|
382
|
+
},
|
|
383
|
+
"-p, --platform <platform>": {
|
|
384
|
+
type: String,
|
|
385
|
+
defaultValue: interfaces_1.PlatformType.EXPRESS,
|
|
386
|
+
description: "Set the default platform for Ts.ED (express or koa)"
|
|
387
|
+
},
|
|
388
|
+
"--features <features...>": {
|
|
389
|
+
type: Array,
|
|
390
|
+
itemType: String,
|
|
391
|
+
defaultValue: [],
|
|
392
|
+
description: "List of the Ts.ED features."
|
|
393
|
+
},
|
|
394
|
+
"-m, --package-manager <packageManager>": {
|
|
395
|
+
type: Array,
|
|
396
|
+
itemType: String,
|
|
397
|
+
defaultValue: cli_core_1.PackageManager.YARN,
|
|
398
|
+
description: "The default package manager to install the project"
|
|
399
|
+
},
|
|
370
400
|
"-t, --tsed-version <version>": {
|
|
371
401
|
type: String,
|
|
372
402
|
defaultValue: constants_1.DEFAULT_TSED_TAGS,
|
|
373
|
-
description: "Use a specific version of Ts.ED (format: 5.x.x)"
|
|
403
|
+
description: "Use a specific version of Ts.ED (format: 5.x.x)."
|
|
374
404
|
},
|
|
375
|
-
"-f, --
|
|
405
|
+
"-f, --file <path>": {
|
|
376
406
|
type: String,
|
|
377
407
|
description: "Location of a file in which the features are defined."
|
|
408
|
+
},
|
|
409
|
+
"-s, --skip-prompt": {
|
|
410
|
+
type: Boolean,
|
|
411
|
+
defaultValue: false,
|
|
412
|
+
description: "Skip the prompt."
|
|
378
413
|
}
|
|
379
414
|
}
|
|
380
415
|
})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InitCmd.js","sourceRoot":"","sources":["../../../../src/commands/init/InitCmd.ts"],"names":[],"mappings":";;;;AAAA,6CAiBwB;AACxB,6CAA6D;AAC7D,+BAA6C;AAC7C,+CAAkD;AAGlD,uEAAkE;AAClE,sDAAkF;AA0ClF,IAAa,OAAO,GAApB,MAAa,OAAO;IAER,aAAa,CAAgB;IAG7B,UAAU,CAAa;IAGvB,WAAW,CAAqB;IAGhC,QAAQ,CAAW;IAGnB,UAAU,CAAa;IAGvB,YAAY,CAAsB;IAGlC,kBAAkB,CAAqB;IAGvC,KAAK,CAAW;IAGhB,EAAE,CAAQ;IAEpB,KAAK,CAAC,aAAa,CAAC,cAAuC;QACzD,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;QAC/B,IAAI,QAAQ,IAAI,cAAc,CAAC,YAAY,EAAE;YAC3C,MAAM,gBAAgB,GAAG,IAAA,cAAO,EAAC,QAAQ,EAAE,cAAc,CAAC,YAAY,CAAC,CAAC;YACxE,MAAM,gBAAgB,GAAG,gEAAa,gBAAgB,GAAC,CAAC;YACxD,MAAM,cAAc,GAAG,IAAA,4BAAiB,EAAC,gBAAgB,EAAE,OAAO,CAAC,CAAC,CAAC,qBAAqB;YAC1F,cAAc,GAAG,EAAC,GAAG,cAAc,EAAE,GAAG,cAAc,EAAC,CAAC;SACzD;QACD,OAAO,cAAc,CAAC;IACxB,CAAC;IAED,OAAO,CAAC,cA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B,EAAE,QAAQ;YAC/B,iBAAiB,EAAE,QAAQ;YAC3B,kBAAkB,EAAE,QAAQ;SAC7B,EACD,GAAG,CACJ,CAAC;IACJ,CAAC;CACF,CAAA;AA1YC;IADC,IAAA,wBAAa,GAAE;;8CACuB;AAGvC;IADC,IAAA,iBAAM,GAAE;sCACa,qBAAU;2CAAC;AAGjC;IADC,IAAA,iBAAM,GAAE;sCACc,6BAAkB;4CAAC;AAG1C;IADC,IAAA,mBAAQ,GAAE;;yCACkB;AAG7B;IADC,IAAA,iBAAM,GAAE;sCACa,qBAAU;2CAAC;AAGjC;IADC,IAAA,iBAAM,GAAE;sCACe,8BAAmB;6CAAC;AAG5C;IADC,IAAA,iBAAM,GAAE;sCACqB,uCAAkB;mDAAC;AAGjD;IADC,IAAA,iBAAM,GAAE;sCACQ,mBAAQ;sCAAC;AAG1B;IADC,IAAA,iBAAM,GAAE;sCACK,gBAAK;mCAAC;AA1BT,OAAO;IAtBnB,IAAA,kBAAO,EAAC;QACP,IAAI,EAAE,MAAM;QACZ,WAAW,EAAE,0BAA0B;QACvC,IAAI,EAAE;YACJ,IAAI,EAAE;gBACJ,IAAI,EAAE,MAAM;gBACZ,YAAY,EAAE,GAAG;gBACjB,WAAW,EAAE,gDAAgD;aAC9D;SACF;QACD,OAAO,EAAE;YACP,8BAA8B,EAAE;gBAC9B,IAAI,EAAE,MAAM;gBACZ,YAAY,EAAE,6BAAiB;gBAC/B,WAAW,EAAE,iDAAiD;aAC/D;YACD,4BAA4B,EAAE;gBAC5B,IAAI,EAAE,MAAM;gBACZ,WAAW,EAAE,uDAAuD;aACrE;SACF;KACF,CAAC;GACW,OAAO,CA4YnB;AA5YY,0BAAO","sourcesContent":["import {\n CliDefaultOptions,\n CliExeca,\n CliFs,\n CliPlugins,\n CliService,\n Command,\n CommandProvider,\n Configuration,\n createSubTasks,\n createTasksRunner,\n Inject,\n InstallOptions,\n PackageManager,\n ProjectPackageJson,\n QuestionOptions,\n RootRendererService\n} from \"@tsed/cli-core\";\nimport {camelCase, paramCase, pascalCase} from \"change-case\";\nimport {basename, join, resolve} from \"path\";\nimport {DEFAULT_TSED_TAGS} from \"../../constants\";\nimport {ArchitectureConvention} from \"../../interfaces/ArchitectureConvention\";\nimport {ProjectConvention} from \"../../interfaces/ProjectConvention\";\nimport {OutputFilePathPipe} from \"../../pipes/OutputFilePathPipe\";\nimport {Features, FeatureValue, parseFeaturesFile} from \"../../services/Features\";\n\nexport interface InitCmdContext extends CliDefaultOptions, InstallOptions {\n platform: \"express\" | \"koa\";\n root: string;\n srcDir: string;\n projectName: string;\n tsedVersion: string;\n features: FeatureValue[];\n featuresTypeORM?: FeatureValue;\n babel?: boolean;\n webpack?: boolean;\n architecture?: ArchitectureConvention;\n convention?: ProjectConvention;\n commands?: boolean;\n GH_TOKEN?: string;\n\n [key: string]: any;\n}\n\n@Command({\n name: \"init\",\n description: \"Init a new Ts.ED project\",\n args: {\n root: {\n type: String,\n defaultValue: \".\",\n description: \"Root directory to initialize the Ts.ED project\"\n }\n },\n options: {\n \"-t, --tsed-version <version>\": {\n type: String,\n defaultValue: DEFAULT_TSED_TAGS,\n description: \"Use a specific version of Ts.ED (format: 5.x.x)\"\n },\n \"-f, --features-file <path>\": {\n type: String,\n description: \"Location of a file in which the features are defined.\"\n }\n }\n})\nexport class InitCmd implements CommandProvider {\n @Configuration()\n protected configuration: Configuration;\n\n @Inject()\n protected cliPlugins: CliPlugins;\n\n @Inject()\n protected packageJson: ProjectPackageJson;\n\n @Features()\n protected features: Features;\n\n @Inject()\n protected cliService: CliService;\n\n @Inject()\n protected rootRenderer: RootRendererService;\n\n @Inject()\n protected outputFilePathPipe: OutputFilePathPipe;\n\n @Inject()\n protected execa: CliExeca;\n\n @Inject()\n protected fs: CliFs;\n\n async $beforePrompt(initialOptions: Partial<InitCmdContext>) {\n const callPath = process.cwd();\n if (callPath && initialOptions.featuresFile) {\n const featuresFilePath = resolve(callPath, initialOptions.featuresFile);\n const featuresFromFile = await import(featuresFilePath);\n const mappedFeatures = parseFeaturesFile(featuresFromFile, \"3.8.0\"); // Inject CLI version\n initialOptions = {...initialOptions, ...mappedFeatures};\n }\n return initialOptions;\n }\n\n $prompt(initialOptions: Partial<InitCmdContext>): QuestionOptions {\n const featuresQuestions = initialOptions.features?.length ? [] : [...this.features];\n return [\n {\n type: \"input\",\n name: \"projectName\",\n message: \"What is your project name\",\n default: paramCase(initialOptions.root!),\n when: initialOptions.root !== \".\",\n transformer(input) {\n return paramCase(input);\n }\n },\n ...featuresQuestions\n ];\n }\n\n $mapContext(ctx: Partial<InitCmdContext>): InitCmdContext {\n this.resolveRootDir(ctx);\n\n const features: FeatureValue[] = [];\n\n Object.entries(ctx)\n .filter(([key]) => key.startsWith(\"features\") && key !== \"featuresFile\")\n .forEach(([key, value]: any[]) => {\n delete ctx[key];\n features.push(...[].concat(value));\n });\n\n features.forEach((feature) => {\n feature.type.split(\":\").forEach((type) => {\n ctx[camelCase(type)] = true;\n });\n });\n\n return {\n ...ctx,\n features,\n srcDir: this.configuration.project?.srcDir,\n pnpm: ctx.packageManager === PackageManager.PNPM,\n npm: ctx.packageManager === PackageManager.NPM,\n yarn: ctx.packageManager === PackageManager.YARN,\n express: ctx.platform === \"express\",\n koa: ctx.platform === \"koa\",\n platformSymbol: ctx.platform && pascalCase(`Platform ${ctx.platform}`)\n } as InitCmdContext;\n }\n\n async $beforeExec(ctx: InitCmdContext): Promise<any> {\n this.fs.ensureDirSync(this.packageJson.dir);\n this.packageJson.name = ctx.projectName;\n\n ctx.packageManager && this.packageJson.setPreference(\"packageManager\", ctx.packageManager);\n ctx.architecture && this.packageJson.setPreference(\"architecture\", ctx.architecture);\n ctx.convention && this.packageJson.setPreference(\"convention\", ctx.convention);\n ctx.GH_TOKEN && this.packageJson.setGhToken(ctx.GH_TOKEN);\n\n this.addDependencies(ctx);\n this.addDevDependencies(ctx);\n this.addScripts(ctx);\n this.addFeatures(ctx);\n\n await createTasksRunner(\n [\n {\n title: \"Write RC files\",\n skip: () => !ctx.GH_TOKEN,\n task: () =>\n this.rootRenderer.renderAll([\"/init/.npmrc.hbs\", \"/init/.yarnrc.hbs\"], ctx, {\n baseDir: \"/init\"\n })\n },\n {\n title: \"Install plugins\",\n task: createSubTasks(() => this.packageJson.install(ctx), {...ctx, concurrent: false})\n },\n {\n title: \"Load plugins\",\n task: () => this.cliPlugins.loadPlugins()\n },\n {\n title: \"Install plugins dependencies\",\n task: createSubTasks(this.cliPlugins.addPluginsDependencies(ctx), {...ctx, concurrent: false})\n }\n ],\n ctx\n );\n }\n\n async $exec(ctx: InitCmdContext) {\n const subTasks = [\n ...(await this.cliService.getTasks(\"generate\", {\n ...ctx,\n type: \"server\",\n name: \"Server\",\n route: \"/rest\"\n })),\n ...(await this.cliService.getTasks(\"generate\", {\n type: \"controller\",\n route: \"hello-world\",\n name: \"HelloWorld\",\n directory: \"rest\"\n })),\n ...(ctx.commands\n ? await this.cliService.getTasks(\"generate\", {\n type: \"command\",\n route: \"hello\",\n name: \"hello\"\n })\n : [])\n ];\n\n const indexCtrlBaseName = basename(\n `${this.outputFilePathPipe.transform({\n name: \"Index\",\n type: \"controller\",\n format: ctx.convention\n })}.ts`\n );\n\n return [\n {\n title: \"Generate project files\",\n task: createSubTasks(\n [\n {\n title: \"Root files\",\n task: () =>\n this.rootRenderer.renderAll(\n [\n \"/init/.dockerignore.hbs\",\n \"/init/.gitignore.hbs\",\n \"/init/.barrelsby.json.hbs\",\n \"/init/processes.config.js.hbs\",\n ctx.babel && \"/init/.babelrc.hbs\",\n ctx.webpack && \"/init/webpack.config.js.hbs\",\n \"/init/docker-compose.yml.hbs\",\n \"/init/Dockerfile.hbs\",\n \"/init/README.md.hbs\",\n \"/init/tsconfig.compile.json.hbs\",\n \"/init/tsconfig.json.hbs\",\n \"/init/src/index.ts.hbs\",\n \"/init/src/config/envs/index.ts.hbs\",\n \"/init/src/config/logger/index.ts.hbs\",\n \"/init/src/config/index.ts.hbs\",\n ctx.commands && \"/init/src/bin/index.ts.hbs\",\n ctx.swagger && \"/init/views/swagger.ejs.hbs\",\n ctx.swagger && {\n path: \"/init/src/controllers/pages/IndexController.ts.hbs\",\n basename: indexCtrlBaseName\n }\n ].filter(Boolean),\n ctx,\n {\n baseDir: \"/init\"\n }\n )\n },\n ...subTasks\n ],\n {...ctx, concurrent: false}\n )\n }\n ];\n }\n\n async $afterPostInstall() {\n return [\n {\n title: \"Generate barrels files\",\n task: () => {\n return this.packageJson.runScript(\"barrels\", {\n ignoreError: true\n });\n }\n }\n ];\n }\n\n resolveRootDir(ctx: Partial<InitCmdContext>) {\n const rootDirName = paramCase(ctx.projectName || basename(this.packageJson.dir));\n\n if (this.packageJson.dir.endsWith(rootDirName)) {\n ctx.projectName = ctx.projectName || rootDirName;\n ctx.root = \".\";\n return;\n }\n\n ctx.projectName = ctx.projectName || rootDirName;\n\n if (ctx.root && ctx.root !== \".\") {\n this.packageJson.dir = join(this.packageJson.dir, rootDirName);\n ctx.root = \".\";\n }\n }\n\n addScripts(ctx: InitCmdContext): void {\n const runner = this.packageJson.getRunCmd();\n\n this.packageJson.addScripts({\n build: `${runner} barrels && tsc --project tsconfig.compile.json`,\n barrels: \"barrelsby --config .barrelsby.json\",\n start: `${runner} barrels && tsnd --inspect --ignore-watch node_modules --respawn --transpile-only -r tsconfig-paths/register src/index.ts`,\n \"start:prod\": \"cross-env NODE_ENV=production node dist/index.js\"\n });\n\n if (ctx.babel) {\n this.packageJson.addScripts({\n build: `tsc && babel src --out-dir dist --extensions \".ts,.tsx\" --source-maps inline`,\n start: \"babel-watch --extensions .ts src/index.ts\"\n });\n }\n\n if (ctx.webpack) {\n this.packageJson.addScripts({\n bundle: `tsc && cross-env NODE_ENV=production webpack`,\n \"start:bundle\": \"cross-env NODE_ENV=production node dist/app.bundle.js\"\n });\n }\n }\n\n addDependencies(ctx: InitCmdContext) {\n this.packageJson.addDependencies({\n \"@tsed/common\": ctx.tsedVersion,\n \"@tsed/core\": ctx.tsedVersion,\n \"@tsed/di\": ctx.tsedVersion,\n \"@tsed/ajv\": ctx.tsedVersion,\n \"@tsed/exceptions\": ctx.tsedVersion,\n \"@tsed/schema\": ctx.tsedVersion,\n \"@tsed/json-mapper\": ctx.tsedVersion,\n \"@tsed/platform-cache\": ctx.tsedVersion,\n \"@tsed/platform-exceptions\": ctx.tsedVersion,\n \"@tsed/platform-log-middleware\": ctx.tsedVersion,\n \"@tsed/platform-middlewares\": ctx.tsedVersion,\n \"@tsed/platform-params\": ctx.tsedVersion,\n \"@tsed/platform-response-filter\": ctx.tsedVersion,\n \"@tsed/platform-views\": ctx.tsedVersion,\n \"@tsed/logger\": \"latest\",\n \"@tsed/logger-file\": \"latest\",\n \"@tsed/engines\": \"latest\",\n ajv: \"latest\",\n barrelsby: \"latest\",\n \"cross-env\": \"latest\",\n dotenv: \"latest\",\n \"dotenv-expand\": \"latest\",\n \"dotenv-flow\": \"latest\"\n });\n }\n\n addDevDependencies(ctx: InitCmdContext) {\n this.packageJson.addDevDependencies(\n {\n \"@types/node\": \"latest\",\n \"@types/multer\": \"latest\",\n tslib: \"latest\",\n \"ts-node\": \"latest\",\n \"tsconfig-paths\": \"latest\",\n typescript: \"latest\"\n },\n ctx\n );\n\n if (!ctx.babel) {\n this.packageJson.addDevDependencies(\n {\n \"ts-node-dev\": \"latest\"\n },\n ctx\n );\n }\n }\n\n addFeatures(ctx: InitCmdContext) {\n ctx.features.forEach((feature) => {\n if (feature.dependencies) {\n this.packageJson.addDependencies(feature.dependencies, ctx);\n }\n\n if (feature.devDependencies) {\n this.packageJson.addDevDependencies(feature.devDependencies, ctx);\n }\n });\n\n switch (ctx.platform) {\n case \"express\":\n this.addExpressDependencies(ctx);\n break;\n case \"koa\":\n this.addKoaDependencies(ctx);\n break;\n }\n\n if (ctx.features.find(({type}) => type === \"graphql\")) {\n this.packageJson.addDependencies(\n {\n [\"apollo-server-\" + ctx.platform]: \"2.25.2\"\n },\n ctx\n );\n }\n }\n\n private addExpressDependencies(ctx: InitCmdContext) {\n this.packageJson.addDependencies(\n {\n \"@tsed/platform-express\": ctx.tsedVersion,\n \"body-parser\": \"latest\",\n cors: \"latest\",\n compression: \"latest\",\n \"cookie-parser\": \"latest\",\n express: \"latest\",\n \"method-override\": \"latest\"\n },\n ctx\n );\n\n this.packageJson.addDevDependencies(\n {\n \"@types/cors\": \"latest\",\n \"@types/express\": \"latest\",\n \"@types/compression\": \"latest\",\n \"@types/cookie-parser\": \"latest\",\n \"@types/method-override\": \"latest\"\n },\n ctx\n );\n }\n\n private addKoaDependencies(ctx: InitCmdContext) {\n this.packageJson.addDependencies(\n {\n \"@tsed/platform-koa\": ctx.tsedVersion,\n koa: \"latest\",\n \"@koa/cors\": \"latest\",\n \"@koa/router\": \"latest\",\n \"koa-qs\": \"latest\",\n \"koa-bodyparser\": \"latest\",\n \"koa-override\": \"latest\",\n \"koa-compress\": \"latest\"\n },\n ctx\n );\n\n this.packageJson.addDevDependencies(\n {\n \"@types/koa\": \"latest\",\n \"@types/koa-qs\": \"latest\",\n \"@types/koa-json\": \"latest\",\n \"@types/koa-bodyparser\": \"latest\",\n \"@types/koa__router\": \"latest\",\n \"@types/koa-compress\": \"latest\",\n \"@types/koa-send\": \"latest\",\n \"@types/koa__cors\": \"latest\"\n },\n ctx\n );\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"InitCmd.js","sourceRoot":"","sources":["../../../../src/commands/init/InitCmd.ts"],"names":[],"mappings":";;;;AAAA,6CAiBwB;AACxB,6CAAkD;AAClD,+BAAoC;AACpC,+CAAkD;AAClD,oFAA+E;AAC/E,0EAAqE;AACrE,uEAAkE;AAElE,4DAAuD;AACvD,yDAAoD;AACpD,4DAAiE;AAEjE,mEAA8D;AAC9D,iDAA8C;AA6D9C,IAAa,OAAO,GAApB,MAAa,OAAO;IAER,aAAa,CAAgB;IAG7B,UAAU,CAAa;IAGvB,WAAW,CAAqB;IAGhC,cAAc,CAAiB;IAG/B,UAAU,CAAa;IAGvB,WAAW,CAAc;IAGzB,YAA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BAAc,CAAC,IAAI;gBACjC,WAAW,EAAE,oDAAoD;aAClE;YACD,8BAA8B,EAAE;gBAC9B,IAAI,EAAE,MAAM;gBACZ,YAAY,EAAE,6BAAiB;gBAC/B,WAAW,EAAE,kDAAkD;aAChE;YACD,mBAAmB,EAAE;gBACnB,IAAI,EAAE,MAAM;gBACZ,WAAW,EAAE,uDAAuD;aACrE;YACD,mBAAmB,EAAE;gBACnB,IAAI,EAAE,OAAO;gBACb,YAAY,EAAE,KAAK;gBACnB,WAAW,EAAE,kBAAkB;aAChC;SACF;KACF,CAAC;GACW,OAAO,CAmYnB;AAnYY,0BAAO","sourcesContent":["import {\n CliExeca,\n CliFs,\n CliLoadFile,\n CliPackageJson,\n CliPlugins,\n CliService,\n Command,\n CommandProvider,\n Configuration,\n createSubTasks,\n createTasksRunner,\n Inject,\n PackageManager,\n ProjectPackageJson,\n QuestionOptions,\n RootRendererService\n} from \"@tsed/cli-core\";\nimport {paramCase, pascalCase} from \"change-case\";\nimport {basename, join} from \"path\";\nimport {DEFAULT_TSED_TAGS} from \"../../constants\";\nimport {ArchitectureConvention} from \"../../interfaces/ArchitectureConvention\";\nimport {ProjectConvention} from \"../../interfaces/ProjectConvention\";\nimport {OutputFilePathPipe} from \"../../pipes/OutputFilePathPipe\";\nimport {InitCmdContext} from \"./interfaces/InitCmdContext\";\nimport {InitFileSchema} from \"./config/InitFileSchema\";\nimport {mapToContext} from \"./mappers/mapToContext\";\nimport {FeaturesMap, FeatureType} from \"./config/FeaturesPrompt\";\nimport {InitOptions} from \"./interfaces/InitOptions\";\nimport {getFeaturesPrompt} from \"./prompts/getFeaturesPrompt\";\nimport {PlatformType} from \"../../interfaces\";\n\n@Command({\n name: \"init\",\n description: \"Init a new Ts.ED project\",\n args: {\n root: {\n type: String,\n defaultValue: \".\",\n description: \"Root directory to initialize the Ts.ED project\"\n }\n },\n options: {\n \"-n, --project-name <projectName>\": {\n type: String,\n defaultValue: \"\",\n description: \"Set the project name. By default, the project is the same as the name directory.\"\n },\n \"-a, --arch <architecture>\": {\n type: String,\n defaultValue: ArchitectureConvention.DEFAULT,\n description: `Set the default architecture convention (${ArchitectureConvention.DEFAULT} or ${ArchitectureConvention.FEATURE})`\n },\n \"-c, --convention <convention>\": {\n type: String,\n defaultValue: ProjectConvention.DEFAULT,\n description: `Set the default project convention (${ArchitectureConvention.DEFAULT} or ${ArchitectureConvention.FEATURE})`\n },\n \"-p, --platform <platform>\": {\n type: String,\n defaultValue: PlatformType.EXPRESS,\n description: \"Set the default platform for Ts.ED (express or koa)\"\n },\n \"--features <features...>\": {\n type: Array,\n itemType: String,\n defaultValue: [],\n description: \"List of the Ts.ED features.\"\n },\n \"-m, --package-manager <packageManager>\": {\n type: Array,\n itemType: String,\n defaultValue: PackageManager.YARN,\n description: \"The default package manager to install the project\"\n },\n \"-t, --tsed-version <version>\": {\n type: String,\n defaultValue: DEFAULT_TSED_TAGS,\n description: \"Use a specific version of Ts.ED (format: 5.x.x).\"\n },\n \"-f, --file <path>\": {\n type: String,\n description: \"Location of a file in which the features are defined.\"\n },\n \"-s, --skip-prompt\": {\n type: Boolean,\n defaultValue: false,\n description: \"Skip the prompt.\"\n }\n }\n})\nexport class InitCmd implements CommandProvider {\n @Configuration()\n protected configuration: Configuration;\n\n @Inject()\n protected cliPlugins: CliPlugins;\n\n @Inject()\n protected packageJson: ProjectPackageJson;\n\n @CliPackageJson()\n protected cliPackageJson: CliPackageJson;\n\n @Inject()\n protected cliService: CliService;\n\n @Inject()\n protected cliLoadFile: CliLoadFile;\n\n @Inject()\n protected rootRenderer: RootRendererService;\n\n @Inject()\n protected outputFilePathPipe: OutputFilePathPipe;\n\n @Inject()\n protected execa: CliExeca;\n\n @Inject()\n protected fs: CliFs;\n\n async $beforePrompt(initialOptions: Partial<InitOptions>) {\n if (initialOptions.file) {\n const file = join(this.packageJson.dir, initialOptions.file);\n\n return {\n ...initialOptions,\n ...(await this.cliLoadFile.loadFile(file, InitFileSchema))\n };\n }\n\n return initialOptions;\n }\n\n $prompt(initialOptions: Partial<InitOptions>): QuestionOptions {\n if (initialOptions.skipPrompt) {\n return [];\n }\n\n return [\n {\n type: \"input\",\n name: \"projectName\",\n message: \"What is your project name\",\n default: paramCase(initialOptions.root!),\n when: initialOptions.root !== \".\",\n transformer(input) {\n return paramCase(input);\n }\n },\n ...getFeaturesPrompt(initialOptions)\n ];\n }\n\n $mapContext(ctx: any): InitCmdContext {\n this.resolveRootDir(ctx);\n ctx = mapToContext(ctx);\n\n return {\n ...ctx,\n cliVersion: ctx.cliVersion || this.cliPackageJson.version,\n srcDir: this.configuration.project?.srcDir,\n platformSymbol: ctx.platform && pascalCase(`Platform ${ctx.platform}`)\n } as InitCmdContext;\n }\n\n async $beforeExec(ctx: InitCmdContext): Promise<any> {\n this.fs.ensureDirSync(this.packageJson.dir);\n this.packageJson.name = ctx.projectName;\n\n ctx.packageManager && this.packageJson.setPreference(\"packageManager\", ctx.packageManager);\n ctx.architecture && this.packageJson.setPreference(\"architecture\", ctx.architecture);\n ctx.convention && this.packageJson.setPreference(\"convention\", ctx.convention);\n ctx.GH_TOKEN && this.packageJson.setGhToken(ctx.GH_TOKEN);\n\n this.addDependencies(ctx);\n this.addDevDependencies(ctx);\n this.addScripts(ctx);\n this.addFeatures(ctx);\n\n await createTasksRunner(\n [\n {\n title: \"Write RC files\",\n skip: () => !ctx.GH_TOKEN,\n task: () =>\n this.rootRenderer.renderAll([\"/init/.npmrc.hbs\", \"/init/.yarnrc.hbs\"], ctx, {\n baseDir: \"/init\"\n })\n },\n {\n title: \"Install plugins\",\n task: createSubTasks(() => this.packageJson.install(ctx), {...ctx, concurrent: false})\n },\n {\n title: \"Load plugins\",\n task: () => this.cliPlugins.loadPlugins()\n },\n {\n title: \"Install plugins dependencies\",\n task: createSubTasks(this.cliPlugins.addPluginsDependencies(ctx), {...ctx, concurrent: false})\n }\n ],\n ctx\n );\n }\n\n async $exec(ctx: InitCmdContext) {\n const subTasks = [\n ...(await this.cliService.getTasks(\"generate\", {\n ...ctx,\n type: \"server\",\n name: \"Server\",\n route: \"/rest\"\n })),\n ...(await this.cliService.getTasks(\"generate\", {\n type: \"controller\",\n route: \"hello-world\",\n name: \"HelloWorld\",\n directory: \"rest\"\n })),\n ...(ctx.commands\n ? await this.cliService.getTasks(\"generate\", {\n type: \"command\",\n route: \"hello\",\n name: \"hello\"\n })\n : [])\n ];\n\n const indexCtrlBaseName = basename(\n `${this.outputFilePathPipe.transform({\n name: \"Index\",\n type: \"controller\",\n format: ctx.convention\n })}.ts`\n );\n\n return [\n {\n title: \"Generate project files\",\n task: createSubTasks(\n [\n {\n title: \"Root files\",\n task: () =>\n this.rootRenderer.renderAll(\n [\n \"/init/.dockerignore.hbs\",\n \"/init/.gitignore.hbs\",\n \"/init/.barrelsby.json.hbs\",\n \"/init/processes.config.js.hbs\",\n ctx.babel && \"/init/.babelrc.hbs\",\n ctx.webpack && \"/init/webpack.config.js.hbs\",\n \"/init/docker-compose.yml.hbs\",\n \"/init/Dockerfile.hbs\",\n \"/init/README.md.hbs\",\n \"/init/tsconfig.compile.json.hbs\",\n \"/init/tsconfig.json.hbs\",\n \"/init/src/index.ts.hbs\",\n \"/init/src/config/envs/index.ts.hbs\",\n \"/init/src/config/logger/index.ts.hbs\",\n \"/init/src/config/index.ts.hbs\",\n ctx.commands && \"/init/src/bin/index.ts.hbs\",\n ctx.swagger && \"/init/views/swagger.ejs.hbs\",\n ctx.swagger && {\n path: \"/init/src/controllers/pages/IndexController.ts.hbs\",\n basename: indexCtrlBaseName\n }\n ].filter(Boolean),\n ctx,\n {\n baseDir: \"/init\"\n }\n )\n },\n ...subTasks\n ],\n {...ctx, concurrent: false}\n )\n }\n ];\n }\n\n async $afterPostInstall() {\n return [\n {\n title: \"Generate barrels files\",\n task: () => {\n return this.packageJson.runScript(\"barrels\", {\n ignoreError: true\n });\n }\n }\n ];\n }\n\n resolveRootDir(ctx: Partial<InitCmdContext>) {\n const rootDirName = paramCase(ctx.projectName || basename(this.packageJson.dir));\n\n if (this.packageJson.dir.endsWith(rootDirName)) {\n ctx.projectName = ctx.projectName || rootDirName;\n ctx.root = \".\";\n return;\n }\n\n ctx.projectName = ctx.projectName || rootDirName;\n\n if (ctx.root && ctx.root !== \".\") {\n this.packageJson.dir = join(this.packageJson.dir, rootDirName);\n ctx.root = \".\";\n }\n }\n\n addScripts(ctx: InitCmdContext): void {\n const runner = this.packageJson.getRunCmd();\n\n this.packageJson.addScripts({\n build: `${runner} barrels && tsc --project tsconfig.compile.json`,\n barrels: \"barrelsby --config .barrelsby.json\",\n start: `${runner} barrels && tsnd --inspect --ignore-watch node_modules --respawn --transpile-only -r tsconfig-paths/register src/index.ts`,\n \"start:prod\": \"cross-env NODE_ENV=production node dist/index.js\"\n });\n\n if (ctx.babel) {\n this.packageJson.addScripts({\n build: `tsc && babel src --out-dir dist --extensions \".ts,.tsx\" --source-maps inline`,\n start: \"babel-watch --extensions .ts src/index.ts\"\n });\n }\n\n if (ctx.webpack) {\n this.packageJson.addScripts({\n bundle: `tsc && cross-env NODE_ENV=production webpack`,\n \"start:bundle\": \"cross-env NODE_ENV=production node dist/app.bundle.js\"\n });\n }\n }\n\n addDependencies(ctx: InitCmdContext) {\n this.packageJson.addDependencies({\n \"@tsed/common\": ctx.tsedVersion,\n \"@tsed/core\": ctx.tsedVersion,\n \"@tsed/di\": ctx.tsedVersion,\n \"@tsed/ajv\": ctx.tsedVersion,\n \"@tsed/exceptions\": ctx.tsedVersion,\n \"@tsed/schema\": ctx.tsedVersion,\n \"@tsed/json-mapper\": ctx.tsedVersion,\n \"@tsed/platform-cache\": ctx.tsedVersion,\n \"@tsed/platform-exceptions\": ctx.tsedVersion,\n \"@tsed/platform-log-middleware\": ctx.tsedVersion,\n \"@tsed/platform-middlewares\": ctx.tsedVersion,\n \"@tsed/platform-params\": ctx.tsedVersion,\n \"@tsed/platform-response-filter\": ctx.tsedVersion,\n \"@tsed/platform-views\": ctx.tsedVersion,\n \"@tsed/logger\": \"latest\",\n \"@tsed/logger-file\": \"latest\",\n \"@tsed/engines\": \"latest\",\n ajv: \"latest\",\n barrelsby: \"latest\",\n \"cross-env\": \"latest\",\n dotenv: \"latest\",\n \"dotenv-expand\": \"latest\",\n \"dotenv-flow\": \"latest\"\n });\n }\n\n addDevDependencies(ctx: InitCmdContext) {\n this.packageJson.addDevDependencies(\n {\n \"@types/node\": \"latest\",\n \"@types/multer\": \"latest\",\n tslib: \"latest\",\n \"ts-node\": \"latest\",\n \"tsconfig-paths\": \"latest\",\n typescript: \"latest\"\n },\n ctx\n );\n\n if (!ctx.babel) {\n this.packageJson.addDevDependencies(\n {\n \"ts-node-dev\": \"latest\"\n },\n ctx\n );\n }\n }\n\n addFeatures(ctx: InitCmdContext) {\n ctx.features.forEach((value) => {\n const feature = FeaturesMap[value];\n\n if (feature.dependencies) {\n this.packageJson.addDependencies(feature.dependencies, ctx);\n }\n\n if (feature.devDependencies) {\n this.packageJson.addDevDependencies(feature.devDependencies, ctx);\n }\n });\n\n switch (ctx.platform) {\n case \"express\":\n this.addExpressDependencies(ctx);\n break;\n case \"koa\":\n this.addKoaDependencies(ctx);\n break;\n }\n\n if (ctx.features.find((value) => value === FeatureType.GRAPHQL)) {\n this.packageJson.addDependencies(\n {\n [\"apollo-server-\" + ctx.platform]: \"2.25.2\"\n },\n ctx\n );\n }\n }\n\n private addExpressDependencies(ctx: InitCmdContext) {\n this.packageJson.addDependencies(\n {\n \"@tsed/platform-express\": ctx.tsedVersion,\n \"body-parser\": \"latest\",\n cors: \"latest\",\n compression: \"latest\",\n \"cookie-parser\": \"latest\",\n express: \"latest\",\n \"method-override\": \"latest\"\n },\n ctx\n );\n\n this.packageJson.addDevDependencies(\n {\n \"@types/cors\": \"latest\",\n \"@types/express\": \"latest\",\n \"@types/compression\": \"latest\",\n \"@types/cookie-parser\": \"latest\",\n \"@types/method-override\": \"latest\"\n },\n ctx\n );\n }\n\n private addKoaDependencies(ctx: InitCmdContext) {\n this.packageJson.addDependencies(\n {\n \"@tsed/platform-koa\": ctx.tsedVersion,\n koa: \"latest\",\n \"@koa/cors\": \"latest\",\n \"@koa/router\": \"latest\",\n \"koa-qs\": \"latest\",\n \"koa-bodyparser\": \"latest\",\n \"koa-override\": \"latest\",\n \"koa-compress\": \"latest\"\n },\n ctx\n );\n\n this.packageJson.addDevDependencies(\n {\n \"@types/koa\": \"latest\",\n \"@types/koa-qs\": \"latest\",\n \"@types/koa-json\": \"latest\",\n \"@types/koa-bodyparser\": \"latest\",\n \"@types/koa__router\": \"latest\",\n \"@types/koa-compress\": \"latest\",\n \"@types/koa-send\": \"latest\",\n \"@types/koa__cors\": \"latest\"\n },\n ctx\n );\n }\n}\n"]}
|