@tsed/cli 3.25.0 → 3.26.1

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.
Files changed (91) hide show
  1. package/lib/cjs/Cli.js.map +1 -1
  2. package/lib/cjs/commands/generate/GenerateCmd.js +4 -8
  3. package/lib/cjs/commands/generate/GenerateCmd.js.map +1 -1
  4. package/lib/cjs/commands/init/InitCmd.js +102 -40
  5. package/lib/cjs/commands/init/InitCmd.js.map +1 -1
  6. package/lib/cjs/commands/init/config/FeaturesPrompt.js +406 -0
  7. package/lib/cjs/commands/init/config/FeaturesPrompt.js.map +1 -0
  8. package/lib/cjs/commands/init/config/InitFileSchema.js +53 -0
  9. package/lib/cjs/commands/init/config/InitFileSchema.js.map +1 -0
  10. package/lib/cjs/commands/init/interfaces/InitCmdContext.js +3 -0
  11. package/lib/cjs/commands/init/interfaces/InitCmdContext.js.map +1 -0
  12. package/lib/cjs/commands/init/interfaces/InitOptions.js +3 -0
  13. package/lib/cjs/commands/init/interfaces/InitOptions.js.map +1 -0
  14. package/lib/cjs/commands/init/interfaces/InitPromptAnswers.js +3 -0
  15. package/lib/cjs/commands/init/interfaces/InitPromptAnswers.js.map +1 -0
  16. package/lib/cjs/commands/init/mappers/mapToContext.js +16 -0
  17. package/lib/cjs/commands/init/mappers/mapToContext.js.map +1 -0
  18. package/lib/cjs/commands/init/mappers/mapUniqFeatures.js +18 -0
  19. package/lib/cjs/commands/init/mappers/mapUniqFeatures.js.map +1 -0
  20. package/lib/cjs/commands/init/prompts/getFeaturesPrompt.js +25 -0
  21. package/lib/cjs/commands/init/prompts/getFeaturesPrompt.js.map +1 -0
  22. package/lib/cjs/commands/init/utils/hasFeature.js +13 -0
  23. package/lib/cjs/commands/init/utils/hasFeature.js.map +1 -0
  24. package/lib/cjs/commands/init/utils/isPlatform.js +8 -0
  25. package/lib/cjs/commands/init/utils/isPlatform.js.map +1 -0
  26. package/lib/cjs/index.js +5 -1
  27. package/lib/cjs/index.js.map +1 -1
  28. package/lib/cjs/interfaces/PlatformType.js +9 -0
  29. package/lib/cjs/interfaces/PlatformType.js.map +1 -0
  30. package/lib/cjs/interfaces/index.js +1 -0
  31. package/lib/cjs/interfaces/index.js.map +1 -1
  32. package/lib/cjs/utils/fillImports.js +48 -0
  33. package/lib/cjs/utils/fillImports.js.map +1 -0
  34. package/lib/esm/Cli.js.map +1 -1
  35. package/lib/esm/commands/generate/GenerateCmd.js +4 -8
  36. package/lib/esm/commands/generate/GenerateCmd.js.map +1 -1
  37. package/lib/esm/commands/init/InitCmd.js +105 -43
  38. package/lib/esm/commands/init/InitCmd.js.map +1 -1
  39. package/lib/esm/commands/init/config/FeaturesPrompt.js +402 -0
  40. package/lib/esm/commands/init/config/FeaturesPrompt.js.map +1 -0
  41. package/lib/esm/commands/init/config/InitFileSchema.js +50 -0
  42. package/lib/esm/commands/init/config/InitFileSchema.js.map +1 -0
  43. package/lib/esm/commands/init/interfaces/InitCmdContext.js +2 -0
  44. package/lib/esm/commands/init/interfaces/InitCmdContext.js.map +1 -0
  45. package/lib/esm/commands/init/interfaces/InitOptions.js +2 -0
  46. package/lib/esm/commands/init/interfaces/InitOptions.js.map +1 -0
  47. package/lib/esm/commands/init/interfaces/InitPromptAnswers.js +2 -0
  48. package/lib/esm/commands/init/interfaces/InitPromptAnswers.js.map +1 -0
  49. package/lib/esm/commands/init/mappers/mapToContext.js +12 -0
  50. package/lib/esm/commands/init/mappers/mapToContext.js.map +1 -0
  51. package/lib/esm/commands/init/mappers/mapUniqFeatures.js +14 -0
  52. package/lib/esm/commands/init/mappers/mapUniqFeatures.js.map +1 -0
  53. package/lib/esm/commands/init/prompts/getFeaturesPrompt.js +21 -0
  54. package/lib/esm/commands/init/prompts/getFeaturesPrompt.js.map +1 -0
  55. package/lib/esm/commands/init/utils/hasFeature.js +8 -0
  56. package/lib/esm/commands/init/utils/hasFeature.js.map +1 -0
  57. package/lib/esm/commands/init/utils/isPlatform.js +4 -0
  58. package/lib/esm/commands/init/utils/isPlatform.js.map +1 -0
  59. package/lib/esm/index.js +5 -1
  60. package/lib/esm/index.js.map +1 -1
  61. package/lib/esm/interfaces/PlatformType.js +6 -0
  62. package/lib/esm/interfaces/PlatformType.js.map +1 -0
  63. package/lib/esm/interfaces/index.js +1 -0
  64. package/lib/esm/interfaces/index.js.map +1 -1
  65. package/lib/esm/utils/fillImports.js +44 -0
  66. package/lib/esm/utils/fillImports.js.map +1 -0
  67. package/lib/types/Cli.d.ts +2 -2
  68. package/lib/types/commands/init/InitCmd.d.ts +9 -24
  69. package/lib/types/commands/init/config/FeaturesPrompt.d.ts +98 -0
  70. package/lib/types/commands/init/config/InitFileSchema.d.ts +49 -0
  71. package/lib/types/commands/init/interfaces/InitCmdContext.d.ts +6 -0
  72. package/lib/types/commands/init/interfaces/InitOptions.d.ts +19 -0
  73. package/lib/types/commands/init/interfaces/InitPromptAnswers.d.ts +16 -0
  74. package/lib/types/commands/init/mappers/mapToContext.d.ts +2 -0
  75. package/lib/types/commands/init/mappers/mapUniqFeatures.d.ts +3 -0
  76. package/lib/types/commands/init/prompts/getFeaturesPrompt.d.ts +2 -0
  77. package/lib/types/commands/init/utils/hasFeature.d.ts +2 -0
  78. package/lib/types/commands/init/utils/isPlatform.d.ts +1 -0
  79. package/lib/types/index.d.ts +5 -1
  80. package/lib/types/interfaces/PlatformType.d.ts +4 -0
  81. package/lib/types/interfaces/index.d.ts +1 -0
  82. package/lib/types/utils/fillImports.d.ts +1 -0
  83. package/package.json +4 -2
  84. package/readme.md +97 -0
  85. package/templates/generate/server.hbs +4 -23
  86. package/templates/init/.barrelsby.json.hbs +1 -7
  87. package/lib/cjs/services/Features.js +0 -528
  88. package/lib/cjs/services/Features.js.map +0 -1
  89. package/lib/esm/services/Features.js +0 -519
  90. package/lib/esm/services/Features.js.map +0 -1
  91. package/lib/types/services/Features.d.ts +0 -412
@@ -1 +1 @@
1
- {"version":3,"file":"Cli.js","sourceRoot":"","sources":["../../src/Cli.ts"],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\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/InitCmd\";\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"]}
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,OAAO;gBACrC,YAAY,EAAE,mCAAsB,CAAC,OAAO;aAC7C,CAAC;QACJ,CAAC;QACD,OAAO,EAAE;YACP,iBAAiB,EAAE,IAAI;SACxB;QACD,MAAM,EAAE;YACN,KAAK,EAAE,MAAM;SACd;KACF,CAAC;IAEF,MAAM,CAAC,YAAY,CAAC,GAAQ;QAC1B,IAAI,CAAC,GAAG,EAAE;YACR,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,GAAG,CAAC,4FAA4F,CAAC,CAAC,CAAC;YACrH,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;SACjB;IACH,CAAC;IAED,MAAM,CAAC,SAAS,CAAC,IAAY;QAC3B,IAAI,CAAC,IAAI,EAAE;YACT,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,GAAG,CAAC,sDAAsD,CAAC,CAAC,CAAC;YAC/E,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;SACjB;IACH,CAAC;IAED,MAAM,CAAC,iBAAiB,CAAC,QAAa;QACpC,MAAM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Ac,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"]}
@@ -14,6 +14,7 @@ const RoutePipe_1 = require("../../pipes/RoutePipe");
14
14
  const ProvidersInfoService_1 = require("../../services/ProvidersInfoService");
15
15
  const ProviderTypes_1 = require("./ProviderTypes");
16
16
  const ProjectConvention_1 = require("../../interfaces/ProjectConvention");
17
+ const fillImports_1 = require("../../utils/fillImports");
17
18
  const DECORATOR_TYPES = [
18
19
  { name: "Class decorator", value: "class" },
19
20
  { name: "Ts.ED middleware and its decorator", value: "middleware" },
@@ -139,7 +140,7 @@ let GenerateCmd = GenerateCmd_1 = class GenerateCmd {
139
140
  }
140
141
  const symbolName = this.classNamePipe.transform({ name, type, format: ProjectConvention_1.ProjectConvention.DEFAULT });
141
142
  const symbolParamName = (0, change_case_1.paramCase)(symbolName);
142
- return {
143
+ return (0, fillImports_1.fillImports)({
143
144
  ...ctx,
144
145
  type,
145
146
  route: ctx.route ? this.routePipe.transform(ctx.route) : "",
@@ -151,13 +152,8 @@ let GenerateCmd = GenerateCmd_1 = class GenerateCmd {
151
152
  subDir: ctx.directory
152
153
  })),
153
154
  symbolPathBasename: (0, normalize_path_1.default)(this.classNamePipe.transform({ name, type })),
154
- express: ctx.platform === "express",
155
- koa: ctx.platform === "koa",
156
- platformSymbol: ctx.platform && (0, change_case_1.pascalCase)(`Platform ${ctx.platform}`),
157
- indexControllerPath: this.projectPackageJson.preferences.convention === ProjectConvention_1.ProjectConvention.ANGULAR
158
- ? "./controllers/pages/index.controller"
159
- : "./controllers/pages/IndexController"
160
- };
155
+ platformSymbol: ctx.platform && (0, change_case_1.pascalCase)(`Platform ${ctx.platform}`)
156
+ });
161
157
  }
162
158
  async $exec(ctx) {
163
159
  const { symbolPath } = ctx;
@@ -1 +1 @@
1
- {"version":3,"file":"GenerateCmd.js","sourceRoot":"","sources":["../../../../src/commands/generate/GenerateCmd.ts"],"names":[],"mappings":";;;;;AAAA,6CAA2H;AAC3H,6CAAkD;AAClD,+BAA6C;AAC7C,4DAA4B;AAC5B,4EAA2C;AAC3C,6DAAwD;AACxD,uEAAkE;AAClE,qDAAgD;AAChD,8EAAyE;AACzE,mDAA+C;AAC/C,0EAAqE;AAerE,MAAM,eAAe,GAAG;IACtB,EAAC,IAAI,EAAE,iBAAiB,EAAE,KAAK,EAAE,OAAO,EAAC;IACzC,EAAC,IAAI,EAAE,oCAAoC,EAAE,KAAK,EAAE,YAAY,EAAC;IACjE,EAAC,IAAI,EAAE,0BAA0B,EAAE,KAAK,EAAE,UAAU,EAAC;IACrD,EAAC,IAAI,EAAE,0BAA0B,EAAE,KAAK,EAAE,MAAM,EAAC;IACjD,EAAC,IAAI,EAAE,2BAA2B,EAAE,KAAK,EAAE,OAAO,EAAC;IACnD,EAAC,IAAI,EAAE,0BAA0B,EAAE,KAAK,EAAE,QAAQ,EAAC;IACnD,EAAC,IAAI,EAAE,4BAA4B,EAAE,KAAK,EAAE,UAAU,EAAC;IACvD,EAAC,IAAI,EAAE,6BAA6B,EAAE,KAAK,EAAE,WAAW,EAAC;IACzD,EAAC,IAAI,EAAE,mBAAmB,EAAE,KAAK,EAAE,SAAS,EAAC;CAC9C,CAAC;AAEF,MAAM,aAAa,GAAG,CAAC,IAAS,EAAE,EAAE;IAClC,OAAO,KAAK,EAAE,KAAU,EAAE,OAAe,EAAE,EAAE;QAC3C,IAAI,OAAO,EAAE;YACX,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC,IAAS,EAAE,EAAE,C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CAAC,CAAC,CACH,CAAC;QAEF,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QAEhB,OAAO,CAAC,GAAG,GAAG,CAAC,CAAC;IAClB,CAAC;CACF,CAAA;AA5MC;IADC,IAAA,iBAAM,GAAE;sCACM,6BAAa;kDAAC;AAG7B;IADC,IAAA,iBAAM,GAAE;sCACW,uCAAkB;uDAAC;AAGvC;IADC,IAAA,iBAAM,GAAE;sCACE,qBAAS;8CAAC;AAGrB;IADC,IAAA,iBAAM,GAAE;sCACS,6BAAkB;qDAAC;AAGrC;IADC,IAAA,iBAAM,GAAE;sCACW,6BAAkB;uDAAC;AAd5B,WAAW;IAfvB,IAAA,kBAAO,EAAC;QACP,IAAI,EAAE,UAAU;QAChB,KAAK,EAAE,GAAG;QACV,WAAW,EAAE,+BAA+B;QAC5C,IAAI,EAAE;YACJ,IAAI,EAAE;gBACJ,WAAW,EAAE,6DAA6D;gBAC1E,IAAI,EAAE,MAAM;aACb;YACD,IAAI,EAAE;gBACJ,WAAW,EAAE,mBAAmB;gBAChC,IAAI,EAAE,MAAM;aACb;SACF;KACF,CAAC;6CAiBmC,2CAAoB;GAhB5C,WAAW,CA8MvB;AA9MY,kCAAW","sourcesContent":["import {CliDefaultOptions, Command, CommandProvider, Inject, ProjectPackageJson, SrcRendererService} from \"@tsed/cli-core\";\nimport {paramCase, pascalCase} from \"change-case\";\nimport {basename, dirname, join} from \"path\";\nimport globby from \"globby\";\nimport normalizePath from \"normalize-path\";\nimport {ClassNamePipe} from \"../../pipes/ClassNamePipe\";\nimport {OutputFilePathPipe} from \"../../pipes/OutputFilePathPipe\";\nimport {RoutePipe} from \"../../pipes/RoutePipe\";\nimport {ProvidersInfoService} from \"../../services/ProvidersInfoService\";\nimport {PROVIDER_TYPES} from \"./ProviderTypes\";\nimport {ProjectConvention} from \"../../interfaces/ProjectConvention\";\n\nexport interface GenerateCmdContext extends CliDefaultOptions {\n type: string;\n name: string;\n route: string;\n directory: string;\n platform: string;\n templateType: string;\n symbolName: string;\n symbolPath: string;\n symbolPathBasename: string;\n convention: ProjectConvention;\n}\n\nconst DECORATOR_TYPES = [\n {name: \"Class decorator\", value: \"class\"},\n {name: \"Ts.ED middleware and its decorator\", value: \"middleware\"},\n {name: \"Ts.ED endpoint decorator\", value: \"endpoint\"},\n {name: \"Ts.ED property decorator\", value: \"prop\"},\n {name: \"Ts.ED parameter decorator\", value: \"param\"},\n {name: \"Vanilla Method decorator\", value: \"method\"},\n {name: \"Vanilla Property decorator\", value: \"property\"},\n {name: \"Vanilla Parameter decorator\", value: \"parameter\"},\n {name: \"Generic decorator\", value: \"generic\"}\n];\n\nconst searchFactory = (list: any) => {\n return async (state: any, keyword: string) => {\n if (keyword) {\n return list.filter((item: any) => item.name.toLowerCase().includes(keyword.toLowerCase()));\n }\n\n return list;\n };\n};\n\n@Command({\n name: \"generate\",\n alias: \"g\",\n description: \"Generate a new provider class\",\n args: {\n type: {\n description: \"Type of the provider (Injectable, Controller, Pipe, etc...)\",\n type: String\n },\n name: {\n description: \"Name of the class\",\n type: String\n }\n }\n})\nexport class GenerateCmd implements CommandProvider {\n @Inject()\n classNamePipe: ClassNamePipe;\n\n @Inject()\n outputFilePathPipe: OutputFilePathPipe;\n\n @Inject()\n routePipe: RoutePipe;\n\n @Inject()\n srcRenderService: SrcRendererService;\n\n @Inject()\n projectPackageJson: ProjectPackageJson;\n\n constructor(private providersList: ProvidersInfoService) {\n PROVIDER_TYPES.forEach((info) => {\n this.providersList.add(\n {\n ...info\n },\n GenerateCmd\n );\n });\n }\n\n $prompt(initialOptions: Partial<GenerateCmdContext>) {\n const getName = (state: any) =>\n initialOptions.name || pascalCase(state.name || initialOptions.name || state.type || initialOptions.type);\n\n const proposedProviders = this.providersList.findProviders(initialOptions.type);\n\n return [\n {\n type: \"autocomplete\",\n name: \"type\",\n message: \"Which type of provider?\",\n default: initialOptions.type,\n when: () => proposedProviders.length > 1,\n source: searchFactory(proposedProviders)\n },\n {\n type: \"input\",\n name: \"name\",\n message: \"Which name?\",\n default: getName,\n when: !initialOptions.name\n },\n {\n message: \"Which platform?\",\n type: \"list\",\n name: \"platform\",\n when(state: any) {\n return [\"server\"].includes(state.type || initialOptions.type);\n },\n choices: [\n {\n name: \"Express.js\",\n checked: true,\n value: \"express\"\n },\n {\n name: \"Koa.js\",\n checked: false,\n value: \"koa\"\n }\n ]\n },\n {\n type: \"input\",\n name: \"route\",\n message: \"Which route?\",\n when(state: any) {\n return [\"controller\", \"server\"].includes(state.type || initialOptions.type);\n },\n default: (state: GenerateCmdContext) => {\n return state.type === \"server\" ? \"/rest\" : this.routePipe.transform(getName(state));\n }\n },\n {\n type: \"list\",\n name: \"directory\",\n message: \"Which directory?\",\n when(state: any) {\n return [\"controller\"].includes(state.type || initialOptions.type);\n },\n choices: this.getDirectories(\"controllers\")\n },\n {\n type: \"autocomplete\",\n name: \"templateType\",\n message: (state: any) => `Which type of ${state.type || initialOptions.type}?`,\n when(state: any) {\n return [\"decorator\"].includes(state.type || initialOptions.type);\n },\n source: searchFactory(DECORATOR_TYPES)\n },\n {\n type: \"list\",\n name: \"middlewarePosition\",\n message: () => `The middleware should be called:`,\n choices: [\n {name: \"Before the endpoint\", value: \"before\"},\n {name: \"After the endpoint\", value: \"after\"}\n ],\n when(state: any) {\n return [\"decorator\"].includes(state.type || initialOptions.type) && [\"middleware\"].includes(state.templateType);\n }\n }\n ];\n }\n\n $mapContext(ctx: Partial<GenerateCmdContext>): GenerateCmdContext {\n const {name = \"\"} = ctx;\n let {type = \"\"} = ctx;\n type = type.toLowerCase();\n\n if (ctx.name === \"prisma\" && ctx.name) {\n type = \"prisma.service\";\n }\n\n const symbolName = this.classNamePipe.transform({name, type, format: ProjectConvention.DEFAULT});\n const symbolParamName = paramCase(symbolName);\n\n return {\n ...ctx,\n type,\n route: ctx.route ? this.routePipe.transform(ctx.route) : \"\",\n symbolName,\n symbolParamName,\n symbolPath: normalizePath(\n this.outputFilePathPipe.transform({\n name,\n type,\n subDir: ctx.directory\n })\n ),\n symbolPathBasename: normalizePath(this.classNamePipe.transform({name, type})),\n express: ctx.platform === \"express\",\n koa: ctx.platform === \"koa\",\n platformSymbol: ctx.platform && pascalCase(`Platform ${ctx.platform}`),\n indexControllerPath:\n this.projectPackageJson.preferences.convention === ProjectConvention.ANGULAR\n ? \"./controllers/pages/index.controller\"\n : \"./controllers/pages/IndexController\"\n } as GenerateCmdContext;\n }\n\n async $exec(ctx: GenerateCmdContext) {\n const {symbolPath} = ctx;\n\n if (this.providersList.isMyProvider(ctx.type, GenerateCmd)) {\n const type = [ctx.type, ctx.templateType].filter(Boolean).join(\".\");\n\n const template = `generate/${type}.hbs`;\n\n return [\n {\n title: `Generate ${ctx.type} file to '${symbolPath}.ts'`,\n task: () =>\n this.srcRenderService.render(template, ctx, {\n output: `${symbolPath}.ts`\n })\n },\n {\n title: `Update bin/index`,\n skip() {\n return ctx.type !== \"command\";\n },\n task: () => {\n return this.srcRenderService.update(\"bin/index.ts\", [\n {\n type: \"import\",\n content: `import {${ctx.symbolName}} from \"./${basename(symbolPath)}\";`\n },\n {\n type: \"insert-after\",\n pattern: /commands: \\[/,\n content: ` ${ctx.symbolName}`\n }\n ]);\n }\n }\n ];\n }\n\n return [];\n }\n\n getDirectories(dir: string) {\n const directories = globby.sync(\"**/*\", {\n cwd: join(this.srcRenderService.rootDir, dir),\n ignore: [\"__*\"]\n });\n\n const set = new Set(\n directories.map((dir) => {\n return dirname(dir);\n })\n );\n\n set.delete(\".\");\n\n return [...set];\n }\n}\n"]}
1
+ {"version":3,"file":"GenerateCmd.js","sourceRoot":"","sources":["../../../../src/commands/generate/GenerateCmd.ts"],"names":[],"mappings":";;;;;AAAA,6CAA2H;AAC3H,6CAAkD;AAClD,+BAA6C;AAC7C,4DAA4B;AAC5B,4EAA2C;AAC3C,6DAAwD;AACxD,uEAAkE;AAClE,qDAAgD;AAChD,8EAAyE;AACzE,mDAA+C;AAC/C,0EAAqE;AACrE,yDAAoD;AAepD,MAAM,e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;aACb;SACF;KACF,CAAC;6CAiBmC,2CAAoB;GAhB5C,WAAW,CAwMvB;AAxMY,kCAAW","sourcesContent":["import {CliDefaultOptions, Command, CommandProvider, Inject, ProjectPackageJson, SrcRendererService} from \"@tsed/cli-core\";\nimport {paramCase, pascalCase} from \"change-case\";\nimport {basename, dirname, join} from \"path\";\nimport globby from \"globby\";\nimport normalizePath from \"normalize-path\";\nimport {ClassNamePipe} from \"../../pipes/ClassNamePipe\";\nimport {OutputFilePathPipe} from \"../../pipes/OutputFilePathPipe\";\nimport {RoutePipe} from \"../../pipes/RoutePipe\";\nimport {ProvidersInfoService} from \"../../services/ProvidersInfoService\";\nimport {PROVIDER_TYPES} from \"./ProviderTypes\";\nimport {ProjectConvention} from \"../../interfaces/ProjectConvention\";\nimport {fillImports} from \"../../utils/fillImports\";\n\nexport interface GenerateCmdContext extends CliDefaultOptions {\n type: string;\n name: string;\n route: string;\n directory: string;\n platform: string;\n templateType: string;\n symbolName: string;\n symbolPath: string;\n symbolPathBasename: string;\n convention: ProjectConvention;\n}\n\nconst DECORATOR_TYPES = [\n {name: \"Class decorator\", value: \"class\"},\n {name: \"Ts.ED middleware and its decorator\", value: \"middleware\"},\n {name: \"Ts.ED endpoint decorator\", value: \"endpoint\"},\n {name: \"Ts.ED property decorator\", value: \"prop\"},\n {name: \"Ts.ED parameter decorator\", value: \"param\"},\n {name: \"Vanilla Method decorator\", value: \"method\"},\n {name: \"Vanilla Property decorator\", value: \"property\"},\n {name: \"Vanilla Parameter decorator\", value: \"parameter\"},\n {name: \"Generic decorator\", value: \"generic\"}\n];\n\nconst searchFactory = (list: any) => {\n return async (state: any, keyword: string) => {\n if (keyword) {\n return list.filter((item: any) => item.name.toLowerCase().includes(keyword.toLowerCase()));\n }\n\n return list;\n };\n};\n\n@Command({\n name: \"generate\",\n alias: \"g\",\n description: \"Generate a new provider class\",\n args: {\n type: {\n description: \"Type of the provider (Injectable, Controller, Pipe, etc...)\",\n type: String\n },\n name: {\n description: \"Name of the class\",\n type: String\n }\n }\n})\nexport class GenerateCmd implements CommandProvider {\n @Inject()\n classNamePipe: ClassNamePipe;\n\n @Inject()\n outputFilePathPipe: OutputFilePathPipe;\n\n @Inject()\n routePipe: RoutePipe;\n\n @Inject()\n srcRenderService: SrcRendererService;\n\n @Inject()\n projectPackageJson: ProjectPackageJson;\n\n constructor(private providersList: ProvidersInfoService) {\n PROVIDER_TYPES.forEach((info) => {\n this.providersList.add(\n {\n ...info\n },\n GenerateCmd\n );\n });\n }\n\n $prompt(initialOptions: Partial<GenerateCmdContext>) {\n const getName = (state: any) =>\n initialOptions.name || pascalCase(state.name || initialOptions.name || state.type || initialOptions.type);\n\n const proposedProviders = this.providersList.findProviders(initialOptions.type);\n\n return [\n {\n type: \"autocomplete\",\n name: \"type\",\n message: \"Which type of provider?\",\n default: initialOptions.type,\n when: () => proposedProviders.length > 1,\n source: searchFactory(proposedProviders)\n },\n {\n type: \"input\",\n name: \"name\",\n message: \"Which name?\",\n default: getName,\n when: !initialOptions.name\n },\n {\n message: \"Which platform?\",\n type: \"list\",\n name: \"platform\",\n when(state: any) {\n return [\"server\"].includes(state.type || initialOptions.type);\n },\n choices: [\n {\n name: \"Express.js\",\n checked: true,\n value: \"express\"\n },\n {\n name: \"Koa.js\",\n checked: false,\n value: \"koa\"\n }\n ]\n },\n {\n type: \"input\",\n name: \"route\",\n message: \"Which route?\",\n when(state: any) {\n return [\"controller\", \"server\"].includes(state.type || initialOptions.type);\n },\n default: (state: GenerateCmdContext) => {\n return state.type === \"server\" ? \"/rest\" : this.routePipe.transform(getName(state));\n }\n },\n {\n type: \"list\",\n name: \"directory\",\n message: \"Which directory?\",\n when(state: any) {\n return [\"controller\"].includes(state.type || initialOptions.type);\n },\n choices: this.getDirectories(\"controllers\")\n },\n {\n type: \"autocomplete\",\n name: \"templateType\",\n message: (state: any) => `Which type of ${state.type || initialOptions.type}?`,\n when(state: any) {\n return [\"decorator\"].includes(state.type || initialOptions.type);\n },\n source: searchFactory(DECORATOR_TYPES)\n },\n {\n type: \"list\",\n name: \"middlewarePosition\",\n message: () => `The middleware should be called:`,\n choices: [\n {name: \"Before the endpoint\", value: \"before\"},\n {name: \"After the endpoint\", value: \"after\"}\n ],\n when(state: any) {\n return [\"decorator\"].includes(state.type || initialOptions.type) && [\"middleware\"].includes(state.templateType);\n }\n }\n ];\n }\n\n $mapContext(ctx: Partial<GenerateCmdContext>): GenerateCmdContext {\n const {name = \"\"} = ctx;\n let {type = \"\"} = ctx;\n type = type.toLowerCase();\n\n if (ctx.name === \"prisma\" && ctx.name) {\n type = \"prisma.service\";\n }\n\n const symbolName = this.classNamePipe.transform({name, type, format: ProjectConvention.DEFAULT});\n const symbolParamName = paramCase(symbolName);\n\n return fillImports({\n ...ctx,\n type,\n route: ctx.route ? this.routePipe.transform(ctx.route) : \"\",\n symbolName,\n symbolParamName,\n symbolPath: normalizePath(\n this.outputFilePathPipe.transform({\n name,\n type,\n subDir: ctx.directory\n })\n ),\n symbolPathBasename: normalizePath(this.classNamePipe.transform({name, type})),\n platformSymbol: ctx.platform && pascalCase(`Platform ${ctx.platform}`)\n }) as GenerateCmdContext;\n }\n\n async $exec(ctx: GenerateCmdContext) {\n const {symbolPath} = ctx;\n\n if (this.providersList.isMyProvider(ctx.type, GenerateCmd)) {\n const type = [ctx.type, ctx.templateType].filter(Boolean).join(\".\");\n\n const template = `generate/${type}.hbs`;\n\n return [\n {\n title: `Generate ${ctx.type} file to '${symbolPath}.ts'`,\n task: () =>\n this.srcRenderService.render(template, ctx, {\n output: `${symbolPath}.ts`\n })\n },\n {\n title: `Update bin/index`,\n skip() {\n return ctx.type !== \"command\";\n },\n task: () => {\n return this.srcRenderService.update(\"bin/index.ts\", [\n {\n type: \"import\",\n content: `import {${ctx.symbolName}} from \"./${basename(symbolPath)}\";`\n },\n {\n type: \"insert-after\",\n pattern: /commands: \\[/,\n content: ` ${ctx.symbolName}`\n }\n ]);\n }\n }\n ];\n }\n\n return [];\n }\n\n getDirectories(dir: string) {\n const directories = globby.sync(\"**/*\", {\n cwd: join(this.srcRenderService.rootDir, dir),\n ignore: [\"__*\"]\n });\n\n const set = new Set(\n directories.map((dir) => {\n return dirname(dir);\n })\n );\n\n set.delete(\".\");\n\n return [...set];\n }\n}\n"]}
@@ -1,4 +1,5 @@
1
1
  "use strict";
2
+ var InitCmd_1;
2
3
  Object.defineProperty(exports, "__esModule", { value: true });
3
4
  exports.InitCmd = void 0;
4
5
  const tslib_1 = require("tslib");
@@ -6,30 +7,40 @@ const cli_core_1 = require("@tsed/cli-core");
6
7
  const change_case_1 = require("change-case");
7
8
  const path_1 = require("path");
8
9
  const constants_1 = require("../../constants");
10
+ const ArchitectureConvention_1 = require("../../interfaces/ArchitectureConvention");
11
+ const ProjectConvention_1 = require("../../interfaces/ProjectConvention");
9
12
  const OutputFilePathPipe_1 = require("../../pipes/OutputFilePathPipe");
10
- const Features_1 = require("../../services/Features");
11
- let InitCmd = class InitCmd {
13
+ const InitFileSchema_1 = require("./config/InitFileSchema");
14
+ const mapToContext_1 = require("./mappers/mapToContext");
15
+ const FeaturesPrompt_1 = require("./config/FeaturesPrompt");
16
+ const getFeaturesPrompt_1 = require("./prompts/getFeaturesPrompt");
17
+ const interfaces_1 = require("../../interfaces");
18
+ const fillImports_1 = require("../../utils/fillImports");
19
+ let InitCmd = InitCmd_1 = class InitCmd {
12
20
  configuration;
13
21
  cliPlugins;
14
22
  packageJson;
15
- features;
23
+ cliPackageJson;
16
24
  cliService;
25
+ cliLoadFile;
17
26
  rootRenderer;
18
27
  outputFilePathPipe;
19
28
  execa;
20
29
  fs;
21
30
  async $beforePrompt(initialOptions) {
22
- const callPath = process.cwd();
23
- if (callPath && initialOptions.featuresFile) {
24
- const featuresFilePath = (0, path_1.resolve)(callPath, initialOptions.featuresFile);
25
- const featuresFromFile = await Promise.resolve().then(() => tslib_1.__importStar(require(featuresFilePath)));
26
- const mappedFeatures = (0, Features_1.parseFeaturesFile)(featuresFromFile, "3.8.0"); // Inject CLI version
27
- initialOptions = { ...initialOptions, ...mappedFeatures };
31
+ if (initialOptions.file) {
32
+ const file = (0, path_1.join)(this.packageJson.dir, initialOptions.file);
33
+ return {
34
+ ...initialOptions,
35
+ ...(await this.cliLoadFile.loadFile(file, InitFileSchema_1.InitFileSchema))
36
+ };
28
37
  }
29
38
  return initialOptions;
30
39
  }
31
40
  $prompt(initialOptions) {
32
- const featuresQuestions = initialOptions.features?.length ? [] : [...this.features];
41
+ if (initialOptions.skipPrompt) {
42
+ return [];
43
+ }
33
44
  return [
34
45
  {
35
46
  type: "input",
@@ -41,34 +52,18 @@ let InitCmd = class InitCmd {
41
52
  return (0, change_case_1.paramCase)(input);
42
53
  }
43
54
  },
44
- ...featuresQuestions
55
+ ...(0, getFeaturesPrompt_1.getFeaturesPrompt)(initialOptions)
45
56
  ];
46
57
  }
47
58
  $mapContext(ctx) {
48
59
  this.resolveRootDir(ctx);
49
- const features = [];
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
- });
61
- return {
60
+ ctx = (0, mapToContext_1.mapToContext)(ctx);
61
+ return (0, fillImports_1.fillImports)({
62
62
  ...ctx,
63
- features,
63
+ cliVersion: ctx.cliVersion || this.cliPackageJson.version,
64
64
  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
65
  platformSymbol: ctx.platform && (0, change_case_1.pascalCase)(`Platform ${ctx.platform}`)
71
- };
66
+ });
72
67
  }
73
68
  async $beforeExec(ctx) {
74
69
  this.fs.ensureDirSync(this.packageJson.dir);
@@ -104,6 +99,7 @@ let InitCmd = class InitCmd {
104
99
  ], ctx);
105
100
  }
106
101
  async $exec(ctx) {
102
+ InitCmd_1.checkPrecondition(ctx);
107
103
  const subTasks = [
108
104
  ...(await this.cliService.getTasks("generate", {
109
105
  ...ctx,
@@ -156,7 +152,8 @@ let InitCmd = class InitCmd {
156
152
  ctx.swagger && "/init/views/swagger.ejs.hbs",
157
153
  ctx.swagger && {
158
154
  path: "/init/src/controllers/pages/IndexController.ts.hbs",
159
- basename: indexCtrlBaseName
155
+ basename: indexCtrlBaseName,
156
+ output: ctx.architecture === "default" ? "/controllers/pages/IndexController.ts" : "/pages/IndexController.ts"
160
157
  }
161
158
  ].filter(Boolean), ctx, {
162
159
  baseDir: "/init"
@@ -256,7 +253,8 @@ let InitCmd = class InitCmd {
256
253
  }
257
254
  }
258
255
  addFeatures(ctx) {
259
- ctx.features.forEach((feature) => {
256
+ ctx.features.forEach((value) => {
257
+ const feature = FeaturesPrompt_1.FeaturesMap[value.toLowerCase()];
260
258
  if (feature.dependencies) {
261
259
  this.packageJson.addDependencies(feature.dependencies, ctx);
262
260
  }
@@ -272,7 +270,7 @@ let InitCmd = class InitCmd {
272
270
  this.addKoaDependencies(ctx);
273
271
  break;
274
272
  }
275
- if (ctx.features.find(({ type }) => type === "graphql")) {
273
+ if (ctx.features.find((value) => value === FeaturesPrompt_1.FeatureType.GRAPHQL)) {
276
274
  this.packageJson.addDependencies({
277
275
  ["apollo-server-" + ctx.platform]: "2.25.2"
278
276
  }, ctx);
@@ -318,6 +316,29 @@ let InitCmd = class InitCmd {
318
316
  "@types/koa__cors": "latest"
319
317
  }, ctx);
320
318
  }
319
+ static checkPrecondition(ctx) {
320
+ const isValid = (types, value) => (value ? Object.values(types).includes(value) : true);
321
+ if (!isValid(interfaces_1.PlatformType, ctx.platform)) {
322
+ throw new Error(`Invalid selected platform: ${ctx.platform}. Possible values: ${Object.values(interfaces_1.PlatformType).join(", ")}.`);
323
+ }
324
+ if (!isValid(ArchitectureConvention_1.ArchitectureConvention, ctx.architecture)) {
325
+ throw new Error(`Invalid selected architecture: ${ctx.architecture}. Possible values: ${Object.values(ArchitectureConvention_1.ArchitectureConvention).join(", ")}.`);
326
+ }
327
+ if (!isValid(ProjectConvention_1.ProjectConvention, ctx.convention)) {
328
+ throw new Error(`Invalid selected convention: ${ctx.convention}. Possible values: ${Object.values(ProjectConvention_1.ProjectConvention).join(", ")}.`);
329
+ }
330
+ if (!isValid(cli_core_1.PackageManager, ctx.packageManager)) {
331
+ throw new Error(`Invalid selected convention: ${ctx.packageManager}. Possible values: ${Object.values(cli_core_1.PackageManager).join(", ")}.`);
332
+ }
333
+ if (ctx.features) {
334
+ ctx.features.forEach((value) => {
335
+ const feature = FeaturesPrompt_1.FeaturesMap[value.toLowerCase()];
336
+ if (!feature) {
337
+ throw new Error(`Invalid selected feature: ${value}. Possible values: ${Object.values(FeaturesPrompt_1.FeatureType).join(", ")}.`);
338
+ }
339
+ });
340
+ }
341
+ }
321
342
  };
322
343
  tslib_1.__decorate([
323
344
  (0, cli_core_1.Configuration)(),
@@ -332,13 +353,17 @@ tslib_1.__decorate([
332
353
  tslib_1.__metadata("design:type", cli_core_1.ProjectPackageJson)
333
354
  ], InitCmd.prototype, "packageJson", void 0);
334
355
  tslib_1.__decorate([
335
- (0, Features_1.Features)(),
336
- tslib_1.__metadata("design:type", Array)
337
- ], InitCmd.prototype, "features", void 0);
356
+ (0, cli_core_1.CliPackageJson)(),
357
+ tslib_1.__metadata("design:type", Object)
358
+ ], InitCmd.prototype, "cliPackageJson", void 0);
338
359
  tslib_1.__decorate([
339
360
  (0, cli_core_1.Inject)(),
340
361
  tslib_1.__metadata("design:type", cli_core_1.CliService)
341
362
  ], InitCmd.prototype, "cliService", void 0);
363
+ tslib_1.__decorate([
364
+ (0, cli_core_1.Inject)(),
365
+ tslib_1.__metadata("design:type", cli_core_1.CliLoadFile)
366
+ ], InitCmd.prototype, "cliLoadFile", void 0);
342
367
  tslib_1.__decorate([
343
368
  (0, cli_core_1.Inject)(),
344
369
  tslib_1.__metadata("design:type", cli_core_1.RootRendererService)
@@ -355,7 +380,7 @@ tslib_1.__decorate([
355
380
  (0, cli_core_1.Inject)(),
356
381
  tslib_1.__metadata("design:type", cli_core_1.CliFs)
357
382
  ], InitCmd.prototype, "fs", void 0);
358
- InitCmd = tslib_1.__decorate([
383
+ InitCmd = InitCmd_1 = tslib_1.__decorate([
359
384
  (0, cli_core_1.Command)({
360
385
  name: "init",
361
386
  description: "Init a new Ts.ED project",
@@ -367,14 +392,51 @@ InitCmd = tslib_1.__decorate([
367
392
  }
368
393
  },
369
394
  options: {
395
+ "-n, --project-name <projectName>": {
396
+ type: String,
397
+ defaultValue: "",
398
+ description: "Set the project name. By default, the project is the same as the name directory."
399
+ },
400
+ "-a, --arch <architecture>": {
401
+ type: String,
402
+ defaultValue: ArchitectureConvention_1.ArchitectureConvention.DEFAULT,
403
+ description: `Set the default architecture convention (${ArchitectureConvention_1.ArchitectureConvention.DEFAULT} or ${ArchitectureConvention_1.ArchitectureConvention.FEATURE})`
404
+ },
405
+ "-c, --convention <convention>": {
406
+ type: String,
407
+ defaultValue: ProjectConvention_1.ProjectConvention.DEFAULT,
408
+ description: `Set the default project convention (${ArchitectureConvention_1.ArchitectureConvention.DEFAULT} or ${ArchitectureConvention_1.ArchitectureConvention.FEATURE})`
409
+ },
410
+ "-p, --platform <platform>": {
411
+ type: String,
412
+ defaultValue: interfaces_1.PlatformType.EXPRESS,
413
+ description: "Set the default platform for Ts.ED (express or koa)"
414
+ },
415
+ "--features <features...>": {
416
+ type: Array,
417
+ itemType: String,
418
+ defaultValue: [],
419
+ description: "List of the Ts.ED features."
420
+ },
421
+ "-m, --package-manager <packageManager>": {
422
+ type: Array,
423
+ itemType: String,
424
+ defaultValue: cli_core_1.PackageManager.YARN,
425
+ description: "The default package manager to install the project"
426
+ },
370
427
  "-t, --tsed-version <version>": {
371
428
  type: String,
372
429
  defaultValue: constants_1.DEFAULT_TSED_TAGS,
373
- description: "Use a specific version of Ts.ED (format: 5.x.x)"
430
+ description: "Use a specific version of Ts.ED (format: 5.x.x)."
374
431
  },
375
- "-f, --features-file <path>": {
432
+ "-f, --file <path>": {
376
433
  type: String,
377
434
  description: "Location of a file in which the features are defined."
435
+ },
436
+ "-s, --skip-prompt": {
437
+ type: Boolean,
438
+ defaultValue: false,
439
+ description: "Skip the prompt."
378
440
  }
379
441
  }
380
442
  })
@@ -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,cAAuC;QAC7C,MAAM,iBAAiB,G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iB,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;AAC9C,yDAAoD;AA6DpD,IAAa,OAAO,eAApB,MAAa,OAAO;IAER,aAAa,CAAgB;IAG7B,UAAU,CAAa;IAGvB,WAAW,CAAqB;IAGhC,cAAc,CAAiB;IAG/B,UAAU,CAAa;IAGvB,WAAW,CAAc;IAGzB,YAAY,CAAsB;IAGlC,k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ACD,+BAA+B,EAAE;gBAC/B,IAAI,EAAE,MAAM;gBACZ,YAAY,EAAE,qCAAiB,CAAC,OAAO;gBACvC,WAAW,EAAE,uCAAuC,+CAAsB,CAAC,OAAO,OAAO,+CAAsB,CAAC,OAAO,GAAG;aAC3H;YACD,2BAA2B,EAAE;gBAC3B,IAAI,EAAE,MAAM;gBACZ,YAAY,EAAE,yBAAY,CAAC,OAAO;gBAClC,WAAW,EAAE,qDAAqD;aACnE;YACD,0BAA0B,EAAE;gBAC1B,IAAI,EAAE,KAAK;gBACX,QAAQ,EAAE,MAAM;gBAChB,YAAY,EAAE,EAAE;gBAChB,WAAW,EAAE,6BAA6B;aAC3C;YACD,wCAAwC,EAAE;gBACxC,IAAI,EAAE,KAAK;gBACX,QAAQ,EAAE,MAAM;gBAChB,YAAY,EAAE,yBAAc,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,CAsanB;AAtaY,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\";\nimport {fillImports} from \"../../utils/fillImports\";\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 fillImports({\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 InitCmd.checkPrecondition(ctx);\n\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 output: ctx.architecture === \"default\" ? \"/controllers/pages/IndexController.ts\" : \"/pages/IndexController.ts\"\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.toLowerCase()];\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 static checkPrecondition(ctx: InitCmdContext) {\n const isValid = (types: any, value: any) => (value ? Object.values(types).includes(value) : true);\n\n if (!isValid(PlatformType, ctx.platform)) {\n throw new Error(`Invalid selected platform: ${ctx.platform}. Possible values: ${Object.values(PlatformType).join(\", \")}.`);\n }\n\n if (!isValid(ArchitectureConvention, ctx.architecture)) {\n throw new Error(\n `Invalid selected architecture: ${ctx.architecture}. Possible values: ${Object.values(ArchitectureConvention).join(\", \")}.`\n );\n }\n\n if (!isValid(ProjectConvention, ctx.convention)) {\n throw new Error(`Invalid selected convention: ${ctx.convention}. Possible values: ${Object.values(ProjectConvention).join(\", \")}.`);\n }\n\n if (!isValid(PackageManager, ctx.packageManager)) {\n throw new Error(`Invalid selected convention: ${ctx.packageManager}. Possible values: ${Object.values(PackageManager).join(\", \")}.`);\n }\n\n if (ctx.features) {\n ctx.features.forEach((value) => {\n const feature = FeaturesMap[value.toLowerCase()];\n\n if (!feature) {\n throw new Error(`Invalid selected feature: ${value}. Possible values: ${Object.values(FeatureType).join(\", \")}.`);\n }\n });\n }\n }\n}\n"]}