@tsed/cli 7.0.0-beta.3 → 7.0.0-beta.4

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 (47) hide show
  1. package/lib/esm/bin/tsed.js +3 -1
  2. package/lib/esm/commands/add/AddCmd.js +2 -1
  3. package/lib/esm/commands/generate/GenerateCmd.js +2 -1
  4. package/lib/esm/commands/index.js +3 -1
  5. package/lib/esm/commands/init/InitCmd.js +10 -103
  6. package/lib/esm/commands/init/InitOptionsCmd.js +17 -0
  7. package/lib/esm/commands/init/config/FeaturesPrompt.js +29 -29
  8. package/lib/esm/commands/init/config/InitSchema.js +297 -16
  9. package/lib/esm/commands/mcp/McpCommand.js +15 -0
  10. package/lib/esm/commands/mcp/schema/InitMCPSchema.js +9 -0
  11. package/lib/esm/{mcp → commands/mcp}/schema/ProjectPreferencesSchema.js +2 -2
  12. package/lib/esm/{mcp → commands/mcp}/tools/generateTool.js +3 -3
  13. package/lib/esm/{mcp → commands/mcp}/tools/getTemplateTool.js +2 -2
  14. package/lib/esm/{mcp → commands/mcp}/tools/index.js +2 -1
  15. package/lib/esm/commands/mcp/tools/initProjectTool.js +65 -0
  16. package/lib/esm/{mcp → commands/mcp}/tools/listTemplatesTool.js +2 -2
  17. package/lib/esm/commands/run/RunCmd.js +2 -1
  18. package/lib/esm/commands/template/CreateTemplateCommand.js +2 -1
  19. package/lib/esm/commands/update/UpdateCmd.js +3 -4
  20. package/lib/esm/index.js +2 -2
  21. package/lib/tsconfig.esm.tsbuildinfo +1 -1
  22. package/lib/types/commands/index.d.ts +103 -1
  23. package/lib/types/commands/init/InitCmd.d.ts +1 -4
  24. package/lib/types/commands/init/InitOptionsCmd.d.ts +52 -0
  25. package/lib/types/commands/init/config/FeaturesPrompt.d.ts +25 -25
  26. package/lib/types/commands/init/config/InitSchema.d.ts +12 -7
  27. package/lib/types/commands/mcp/McpCommand.d.ts +52 -0
  28. package/lib/types/commands/mcp/schema/InitMCPSchema.d.ts +5 -0
  29. package/lib/types/{mcp → commands/mcp}/schema/ProjectPreferencesSchema.d.ts +2 -2
  30. package/lib/types/{mcp → commands/mcp}/tools/generateTool.d.ts +6 -0
  31. package/lib/types/{mcp → commands/mcp}/tools/getTemplateTool.d.ts +6 -0
  32. package/lib/types/commands/mcp/tools/initProjectTool.d.ts +94 -0
  33. package/lib/types/{mcp → commands/mcp}/tools/listTemplatesTool.d.ts +6 -0
  34. package/lib/types/{mcp → commands/mcp}/tools/setWorkspaceTool.d.ts +6 -0
  35. package/lib/types/index.d.ts +2 -2
  36. package/lib/types/interfaces/InitCmdOptions.d.ts +1 -1
  37. package/package.json +11 -12
  38. package/lib/esm/bin/tsed-mcp.js +0 -42
  39. package/lib/types/bin/tsed-mcp.d.ts +0 -2
  40. /package/lib/esm/{mcp → commands/mcp}/resources/index.js +0 -0
  41. /package/lib/esm/{mcp → commands/mcp}/resources/projectInfoResource.js +0 -0
  42. /package/lib/esm/{mcp → commands/mcp}/resources/serverInfoResource.js +0 -0
  43. /package/lib/esm/{mcp → commands/mcp}/tools/setWorkspaceTool.js +0 -0
  44. /package/lib/types/{mcp → commands/mcp}/resources/index.d.ts +0 -0
  45. /package/lib/types/{mcp → commands/mcp}/resources/projectInfoResource.d.ts +0 -0
  46. /package/lib/types/{mcp → commands/mcp}/resources/serverInfoResource.d.ts +0 -0
  47. /package/lib/types/{mcp → commands/mcp}/tools/index.d.ts +0 -0
@@ -15,7 +15,7 @@ register(pathToFileURL(join(import.meta.dirname, `../loaders/alias.hook.${EXT}`)
15
15
  },
16
16
  transferList: []
17
17
  });
18
- const { commands, CliCore, PKG, TEMPLATE_DIR, ArchitectureConvention, ProjectConvention } = await import("../index.js");
18
+ const { tools, commands, resources, CliCore, PKG, TEMPLATE_DIR, ArchitectureConvention, ProjectConvention } = await import("../index.js");
19
19
  CliCore.bootstrap({
20
20
  name: "tsed",
21
21
  pkg: PKG,
@@ -24,6 +24,8 @@ CliCore.bootstrap({
24
24
  updateNotifier: true,
25
25
  checkPrecondition: true,
26
26
  commands,
27
+ tools,
28
+ resources,
27
29
  defaultProjectPreferences() {
28
30
  return {
29
31
  convention: ProjectConvention.DEFAULT,
@@ -41,7 +41,8 @@ export class AddCmd {
41
41
  ];
42
42
  }
43
43
  }
44
- command(AddCmd, {
44
+ command({
45
+ token: AddCmd,
45
46
  name: "add",
46
47
  description: "Add cli plugin to the current project",
47
48
  args: {
@@ -63,7 +63,8 @@ export class GenerateCmd {
63
63
  ];
64
64
  }
65
65
  }
66
- command(GenerateCmd, {
66
+ command({
67
+ token: GenerateCmd,
67
68
  name: "generate",
68
69
  alias: "g",
69
70
  description: "Generate a new provider class",
@@ -1,7 +1,9 @@
1
1
  import { AddCmd } from "./add/AddCmd.js";
2
2
  import { GenerateCmd } from "./generate/GenerateCmd.js";
3
3
  import { InitCmd } from "./init/InitCmd.js";
4
+ import { InitOptionsCommand } from "./init/InitOptionsCmd.js";
5
+ import { McpCommand } from "./mcp/McpCommand.js";
4
6
  import { RunCmd } from "./run/RunCmd.js";
5
7
  import { CreateTemplateCommand } from "./template/CreateTemplateCommand.js";
6
8
  import { UpdateCmd } from "./update/UpdateCmd.js";
7
- export default [AddCmd, InitCmd, GenerateCmd, UpdateCmd, RunCmd, CreateTemplateCommand];
9
+ export default [AddCmd, InitCmd, InitOptionsCommand, GenerateCmd, UpdateCmd, RunCmd, CreateTemplateCommand, McpCommand];
@@ -1,16 +1,14 @@
1
1
  import { basename, join } from "node:path";
2
- import { CliExeca, CliFs, CliLoadFile, cliPackageJson, CliPlugins, command, Configuration, createSubTasks, createTasksRunner, inject, PackageManager, PackageManagersModule, ProjectPackageJson } from "@tsed/cli-core";
2
+ import { CliExeca, CliFs, CliLoadFile, cliPackageJson, CliPlugins, command, Configuration, createSubTasks, createTasksRunner, inject, PackageManagersModule, ProjectPackageJson } from "@tsed/cli-core";
3
3
  import { isString } from "@tsed/core";
4
4
  import { constant } from "@tsed/di";
5
5
  import { $asyncAlter } from "@tsed/hooks";
6
6
  import { kebabCase } from "change-case";
7
- import { DEFAULT_TSED_TAGS, TEMPLATE_DIR } from "../../constants/index.js";
7
+ import { TEMPLATE_DIR } from "../../constants/index.js";
8
8
  import { exec } from "../../fn/exec.js";
9
9
  import { render } from "../../fn/render.js";
10
10
  import { taskOutput } from "../../fn/taskOutput.js";
11
- import { ArchitectureConvention } from "../../interfaces/ArchitectureConvention.js";
12
- import { PlatformType } from "../../interfaces/index.js";
13
- import { ProjectConvention } from "../../interfaces/ProjectConvention.js";
11
+ import {} from "../../interfaces/index.js";
14
12
  import { PlatformsModule } from "../../platforms/PlatformsModule.js";
15
13
  import { RuntimesModule } from "../../runtimes/RuntimesModule.js";
16
14
  import { BunRuntime } from "../../runtimes/supports/BunRuntime.js";
@@ -34,45 +32,14 @@ export class InitCmd {
34
32
  this.execa = inject(CliExeca);
35
33
  this.fs = inject(CliFs);
36
34
  }
37
- checkPrecondition(ctx) {
38
- const isValid = (types, value) => (value ? Object.values(types).includes(value) : true);
39
- if (!isValid(PlatformType, ctx.platform)) {
40
- throw new Error(`Invalid selected platform: ${ctx.platform}. Possible values: ${Object.values(PlatformType).join(", ")}.`);
41
- }
42
- if (!isValid(ArchitectureConvention, ctx.architecture)) {
43
- throw new Error(`Invalid selected architecture: ${ctx.architecture}. Possible values: ${Object.values(ArchitectureConvention).join(", ")}.`);
44
- }
45
- if (!isValid(ProjectConvention, ctx.convention)) {
46
- throw new Error(`Invalid selected convention: ${ctx.convention}. Possible values: ${Object.values(ProjectConvention).join(", ")}.`);
47
- }
48
- const runtimes = this.runtimes.list();
49
- if (!runtimes.includes(ctx.runtime)) {
50
- throw new Error(`Invalid selected runtime: ${ctx.runtime}. Possible values: ${runtimes.join(", ")}.`);
51
- }
52
- const managers = this.packageManagers.list();
53
- if (!managers.includes(ctx.packageManager)) {
54
- throw new Error(`Invalid selected package manager: ${ctx.packageManager}. Possible values: ${managers.join(", ")}.`);
55
- }
56
- if (ctx.features) {
57
- ctx.features.forEach((value) => {
58
- const feature = FeaturesMap[value.toLowerCase()];
59
- if (!feature) {
60
- throw new Error(`Invalid selected feature: ${value}. Possible values: ${Object.values(FeatureType).join(", ")}.`);
61
- }
62
- });
63
- }
64
- }
65
- async $beforePrompt(initialOptions) {
35
+ async $prompt(initialOptions) {
66
36
  if (initialOptions.file) {
67
37
  const file = join(this.packageJson.cwd, initialOptions.file);
68
- return {
38
+ initialOptions = {
69
39
  ...initialOptions,
70
- ...(await this.cliLoadFile.loadFile(file, InitSchema))
40
+ ...(await this.cliLoadFile.loadFile(file, InitSchema()))
71
41
  };
72
42
  }
73
- return initialOptions;
74
- }
75
- $prompt(initialOptions) {
76
43
  if (initialOptions.skipPrompt) {
77
44
  return [];
78
45
  }
@@ -108,7 +75,7 @@ export class InitCmd {
108
75
  srcDir: constant("project.srcDir", "src")
109
76
  };
110
77
  }
111
- async $beforeExec(ctx) {
78
+ async $exec(ctx) {
112
79
  this.fs.ensureDirSync(this.packageJson.cwd);
113
80
  ctx.projectName && (this.packageJson.name = ctx.projectName);
114
81
  ctx.packageManager && this.packageJson.setPreference("packageManager", ctx.packageManager);
@@ -148,9 +115,6 @@ export class InitCmd {
148
115
  task: createSubTasks(() => this.cliPlugins.addPluginsDependencies(ctx), { ...ctx, concurrent: false })
149
116
  }
150
117
  ], ctx);
151
- }
152
- async $exec(ctx) {
153
- this.checkPrecondition(ctx);
154
118
  const runtime = this.runtimes.get();
155
119
  ctx = {
156
120
  ...ctx,
@@ -355,67 +319,10 @@ export class InitCmd {
355
319
  taskOutput(`Plugins files rendered (${Date.now() - startTime}ms)`);
356
320
  }
357
321
  }
358
- command(InitCmd, {
322
+ command({
323
+ token: InitCmd,
359
324
  name: "init",
360
325
  description: "Init a new Ts.ED project",
361
- args: {
362
- root: {
363
- type: String,
364
- defaultValue: ".",
365
- description: "Root directory to initialize the Ts.ED project"
366
- }
367
- },
368
- options: {
369
- "-n, --project-name <projectName>": {
370
- type: String,
371
- defaultValue: "",
372
- description: "Set the project name. By default, the project is the same as the name directory."
373
- },
374
- "-a, --arch <architecture>": {
375
- type: String,
376
- defaultValue: ArchitectureConvention.DEFAULT,
377
- description: `Set the default architecture convention (${ArchitectureConvention.DEFAULT} or ${ArchitectureConvention.FEATURE})`
378
- },
379
- "-c, --convention <convention>": {
380
- type: String,
381
- defaultValue: ProjectConvention.DEFAULT,
382
- description: `Set the default project convention (${ArchitectureConvention.DEFAULT} or ${ArchitectureConvention.FEATURE})`
383
- },
384
- "-p, --platform <platform>": {
385
- type: String,
386
- defaultValue: PlatformType.EXPRESS,
387
- description: "Set the default platform for Ts.ED (express, koa or fastify)"
388
- },
389
- "--features <features...>": {
390
- type: Array,
391
- itemType: String,
392
- defaultValue: [],
393
- description: "List of the Ts.ED features."
394
- },
395
- "--runtime <runtime>": {
396
- itemType: String,
397
- defaultValue: "node",
398
- description: "The default runtime used to run the project"
399
- },
400
- "-m, --package-manager <packageManager>": {
401
- itemType: String,
402
- defaultValue: PackageManager.YARN,
403
- description: "The default package manager to install the project"
404
- },
405
- "-t, --tsed-version <version>": {
406
- type: String,
407
- defaultValue: DEFAULT_TSED_TAGS,
408
- description: "Use a specific version of Ts.ED (format: 5.x.x)."
409
- },
410
- "-f, --file <path>": {
411
- type: String,
412
- description: "Location of a file in which the features are defined."
413
- },
414
- "-s, --skip-prompt": {
415
- type: Boolean,
416
- defaultValue: false,
417
- description: "Skip the prompt."
418
- }
419
- },
326
+ inputSchema: InitSchema,
420
327
  disableReadUpPkg: true
421
328
  });
@@ -0,0 +1,17 @@
1
+ import { command } from "@tsed/cli-core";
2
+ import { s } from "@tsed/schema";
3
+ import { InitSchema } from "./config/InitSchema.js";
4
+ export const InitOptionsCommand = command({
5
+ name: "init-options",
6
+ description: "Display available options for Ts.ED init command for external tool",
7
+ disableReadUpPkg: true,
8
+ inputSchema: s.object({
9
+ indent: s.number().default(0).description("Json indentation value").opt("-i, --indent <indent>")
10
+ }),
11
+ handler(data) {
12
+ console.log(JSON.stringify(InitSchema().toJSON({
13
+ useAlias: false,
14
+ customKeys: true
15
+ }), null, data.indent));
16
+ }
17
+ }).token();
@@ -9,7 +9,7 @@ export var FeatureType;
9
9
  FeatureType["PASSPORTJS"] = "passportjs";
10
10
  FeatureType["CONFIG"] = "config";
11
11
  FeatureType["COMMANDS"] = "commands";
12
- FeatureType["DB"] = "db";
12
+ FeatureType["ORM"] = "orm";
13
13
  FeatureType["DOC"] = "doc";
14
14
  // CONFIG
15
15
  FeatureType["CONFIG_ENVS"] = "config:envs";
@@ -22,35 +22,35 @@ export var FeatureType;
22
22
  FeatureType["CONFIG_VAULT"] = "config:vault:premium";
23
23
  FeatureType["CONFIG_POSTGRES"] = "config:postgres:premium";
24
24
  // DOC
25
- FeatureType["SWAGGER"] = "swagger";
26
- FeatureType["SCALAR"] = "scalar";
25
+ FeatureType["SWAGGER"] = "doc:swagger";
26
+ FeatureType["SCALAR"] = "doc:scalar";
27
27
  // ORM
28
- FeatureType["PRISMA"] = "prisma";
29
- FeatureType["MONGOOSE"] = "mongoose";
28
+ FeatureType["PRISMA"] = "orm:prisma";
29
+ FeatureType["MONGOOSE"] = "orm:mongoose";
30
30
  // TYPEORM
31
- FeatureType["TYPEORM"] = "typeorm";
32
- FeatureType["TYPEORM_MYSQL"] = "typeorm:mysql";
33
- FeatureType["TYPEORM_MARIADB"] = "typeorm:mariadb";
34
- FeatureType["TYPEORM_POSTGRES"] = "typeorm:postgres";
35
- FeatureType["TYPEORM_COCKROACHDB"] = "typeorm:cockroachdb";
36
- FeatureType["TYPEORM_SQLITE"] = "typeorm:sqlite";
37
- FeatureType["TYPEORM_BETTER_SQLITE3"] = "typeorm:better-sqlite3";
38
- FeatureType["TYPEORM_CORDOVA"] = "typeorm:cordova";
39
- FeatureType["TYPEORM_NATIVESCRIPT"] = "typeorm:nativescript";
40
- FeatureType["TYPEORM_ORACLE"] = "typeorm:oracle";
41
- FeatureType["TYPEORM_MSSQL"] = "typeorm:mssql";
42
- FeatureType["TYPEORM_MONGODB"] = "typeorm:mongodb";
43
- FeatureType["TYPEORM_SQLJS"] = "typeorm:sqljs";
44
- FeatureType["TYPEORM_REACTNATIVE"] = "typeorm:reactnative";
45
- FeatureType["TYPEORM_EXPO"] = "typeorm:expo";
31
+ FeatureType["TYPEORM"] = "orm:typeorm";
32
+ FeatureType["TYPEORM_MYSQL"] = "orm:typeorm:mysql";
33
+ FeatureType["TYPEORM_MARIADB"] = "orm:typeorm:mariadb";
34
+ FeatureType["TYPEORM_POSTGRES"] = "orm:typeorm:postgres";
35
+ FeatureType["TYPEORM_COCKROACHDB"] = "orm:typeorm:cockroachdb";
36
+ FeatureType["TYPEORM_SQLITE"] = "orm:typeorm:sqlite";
37
+ FeatureType["TYPEORM_BETTER_SQLITE3"] = "orm:typeorm:better-sqlite3";
38
+ FeatureType["TYPEORM_CORDOVA"] = "orm:typeorm:cordova";
39
+ FeatureType["TYPEORM_NATIVESCRIPT"] = "orm:typeorm:nativescript";
40
+ FeatureType["TYPEORM_ORACLE"] = "orm:typeorm:oracle";
41
+ FeatureType["TYPEORM_MSSQL"] = "orm:typeorm:mssql";
42
+ FeatureType["TYPEORM_MONGODB"] = "orm:typeorm:mongodb";
43
+ FeatureType["TYPEORM_SQLJS"] = "orm:typeorm:sqljs";
44
+ FeatureType["TYPEORM_REACTNATIVE"] = "orm:typeorm:reactnative";
45
+ FeatureType["TYPEORM_EXPO"] = "orm:typeorm:expo";
46
46
  // TESTING & LINTER
47
47
  FeatureType["TESTING"] = "testing";
48
- FeatureType["JEST"] = "jest";
49
- FeatureType["VITEST"] = "vitest";
48
+ FeatureType["JEST"] = "testing:jest";
49
+ FeatureType["VITEST"] = "testing:vitest";
50
50
  FeatureType["LINTER"] = "linter";
51
- FeatureType["ESLINT"] = "eslint";
52
- FeatureType["LINT_STAGED"] = "lintstaged";
53
- FeatureType["PRETTIER"] = "prettier";
51
+ FeatureType["ESLINT"] = "linter:eslint";
52
+ FeatureType["LINT_STAGED"] = "linter:lintstaged";
53
+ FeatureType["PRETTIER"] = "linter:prettier";
54
54
  })(FeatureType || (FeatureType = {}));
55
55
  export const FeaturesMap = {
56
56
  [PlatformType.EXPRESS]: {
@@ -77,7 +77,7 @@ export const FeaturesMap = {
77
77
  [FeatureType.DOC]: {
78
78
  name: "Documentation"
79
79
  },
80
- [FeatureType.DB]: {
80
+ [FeatureType.ORM]: {
81
81
  name: "Database"
82
82
  },
83
83
  [FeatureType.PASSPORTJS]: {
@@ -386,11 +386,11 @@ export const FeaturesPrompt = (availableRuntimes, availablePackageManagers) => [
386
386
  {
387
387
  type: "checkbox",
388
388
  name: "features",
389
- message: "Check the features needed for your project",
389
+ message: "Choose the features needed for your project",
390
390
  choices: [
391
391
  FeatureType.CONFIG,
392
392
  FeatureType.GRAPHQL,
393
- FeatureType.DB,
393
+ FeatureType.ORM,
394
394
  FeatureType.PASSPORTJS,
395
395
  FeatureType.SOCKETIO,
396
396
  FeatureType.DOC,
@@ -428,7 +428,7 @@ export const FeaturesPrompt = (availableRuntimes, availablePackageManagers) => [
428
428
  message: "Choose a ORM manager",
429
429
  type: "list",
430
430
  name: "featuresDB",
431
- when: hasFeature(FeatureType.DB),
431
+ when: hasFeature(FeatureType.ORM),
432
432
  choices: [FeatureType.PRISMA, FeatureType.MONGOOSE, FeatureType.TYPEORM]
433
433
  },
434
434
  {
@@ -1,27 +1,308 @@
1
- import { PackageManager } from "@tsed/cli-core";
1
+ import { PackageManager, PackageManagersModule } from "@tsed/cli-core";
2
+ import { inject } from "@tsed/di";
2
3
  import { s } from "@tsed/schema";
4
+ import { DEFAULT_TSED_TAGS } from "../../../constants/index.js";
3
5
  import { ArchitectureConvention, PlatformType, ProjectConvention } from "../../../interfaces/index.js";
4
- import { FeatureType } from "./FeaturesPrompt.js";
5
- export const InitSchema = s
6
+ import { RuntimesModule } from "../../../runtimes/RuntimesModule.js";
7
+ import { FeaturesMap, FeatureType } from "../../init/config/FeaturesPrompt.js";
8
+ export const InitSchema = () => s
6
9
  .object({
7
- tsedVersion: s.string().optional().description("The CLI will use the given tsed version to generate the project"),
8
- projectName: s.string().optional().description("The project name"),
9
- platform: s
10
+ root: s.string().required().description("Current working directory to initialize Ts.ED project"),
11
+ projectName: s
10
12
  .string()
11
- .enum(PlatformType)
13
+ .optional()
14
+ .prompt("What is your project name")
15
+ .when((ctx) => ctx.root !== ".")
16
+ .description("Set the project name. By default, the project is the same as the name directory.")
17
+ .opt("-n, --project-name <projectName>"),
18
+ platform: s
19
+ .enums(PlatformType)
12
20
  .default(PlatformType.EXPRESS)
13
- .description("Node.js framework used to run server (Express, Koa, Fastify)"),
14
- convention: s
21
+ .prompt("Choose the target Framework:")
22
+ .choices([
23
+ {
24
+ label: "Express.js",
25
+ value: PlatformType.EXPRESS,
26
+ checked: (options) => options.platform === PlatformType.EXPRESS || !options.platform // todo maybe it can be infered by default() and item value()
27
+ },
28
+ {
29
+ label: "Koa.js",
30
+ value: PlatformType.KOA,
31
+ checked: (options) => options.platform === PlatformType.KOA || !options.platform
32
+ },
33
+ {
34
+ label: "Fastify.js (beta)",
35
+ value: PlatformType.KOA,
36
+ checked: (options) => options.platform === PlatformType.KOA || !options.platform
37
+ }
38
+ ])
39
+ .description("Set the default platform for Ts.ED (Express.js, Koa.js or Fastify.js)")
40
+ .opt("-p, --platform <platform>"),
41
+ architecture: s
15
42
  .string()
16
- .enum(ProjectConvention)
43
+ .enum(ArchitectureConvention)
44
+ .default(ArchitectureConvention.DEFAULT)
45
+ .prompt("Choose the architecture for your project:")
46
+ .description("Architecture convention for tree directory")
47
+ .choices([
48
+ {
49
+ label: "Ts.ED",
50
+ value: ArchitectureConvention.DEFAULT
51
+ },
52
+ {
53
+ label: "Feature",
54
+ value: ArchitectureConvention.FEATURE
55
+ }
56
+ ])
57
+ .opt("-a, --arch <architecture>"),
58
+ convention: s
59
+ .enums(ProjectConvention)
17
60
  .default(ProjectConvention.DEFAULT)
18
- .description("Project convention (Ts.ED or Angular style)"),
19
- packageManager: s.string().enum(PackageManager).default(PackageManager.NPM).description("Used project manager to install dependencies"),
61
+ .prompt("Choose the file naming convention:")
62
+ .description("Set the default file naming convention (Ts.ED, Angular).")
63
+ .choices([
64
+ {
65
+ label: "Ts.ED",
66
+ value: ProjectConvention.DEFAULT
67
+ },
68
+ {
69
+ label: "Angular",
70
+ value: ProjectConvention.ANGULAR
71
+ }
72
+ ])
73
+ .opt("-c, --convention <convention>"),
74
+ features: s
75
+ .array()
76
+ .items(s.enums(FeatureType))
77
+ .prompt("Choose the features needed for your project")
78
+ .description("List of features to enable (swagger, graphql, prisma, etc.).")
79
+ .choices([
80
+ {
81
+ label: "Commands",
82
+ value: FeatureType.COMMANDS
83
+ },
84
+ {
85
+ label: "Configuration sources",
86
+ value: FeatureType.CONFIG,
87
+ items: [
88
+ {
89
+ label: "Envs",
90
+ value: FeatureType.CONFIG_ENVS
91
+ },
92
+ {
93
+ label: "Dotenv",
94
+ value: FeatureType.CONFIG_DOTENV
95
+ },
96
+ {
97
+ label: "JSON",
98
+ value: FeatureType.CONFIG_JSON
99
+ },
100
+ {
101
+ label: "YAML",
102
+ value: FeatureType.CONFIG_YAML
103
+ },
104
+ {
105
+ label: "AWS Secrets Manager (Premium)",
106
+ value: FeatureType.CONFIG_AWS_SECRETS
107
+ },
108
+ {
109
+ label: "IORedis (Premium)",
110
+ value: FeatureType.CONFIG_IOREDIS
111
+ },
112
+ {
113
+ label: "MongoDB (Premium)",
114
+ value: FeatureType.CONFIG_MONGO
115
+ },
116
+ {
117
+ label: "Vault (Premium)",
118
+ value: FeatureType.CONFIG_VAULT
119
+ },
120
+ {
121
+ label: "Postgres (Premium)",
122
+ value: FeatureType.CONFIG_POSTGRES
123
+ }
124
+ ]
125
+ },
126
+ {
127
+ label: "ORM",
128
+ value: FeatureType.ORM,
129
+ items: [
130
+ {
131
+ label: "Prisma",
132
+ value: FeatureType.PRISMA
133
+ },
134
+ {
135
+ label: "Mongoose",
136
+ value: FeatureType.MONGOOSE
137
+ },
138
+ {
139
+ label: "TypeORM",
140
+ value: FeatureType.TYPEORM,
141
+ items: [
142
+ {
143
+ label: "MySQL",
144
+ value: FeatureType.TYPEORM_MYSQL
145
+ },
146
+ {
147
+ label: "MariaDB",
148
+ value: "db:typeorm:mariadb"
149
+ },
150
+ {
151
+ label: "Postgres",
152
+ value: "db:typeorm:postgres"
153
+ },
154
+ {
155
+ label: "CockRoachDB",
156
+ value: "db:typeorm:cockroachdb"
157
+ },
158
+ {
159
+ label: "SQLite",
160
+ value: "db:typeorm:sqlite"
161
+ },
162
+ {
163
+ label: "Better SQLite3",
164
+ value: "db:typeorm:better-sqlite3"
165
+ },
166
+ {
167
+ label: "Cordova",
168
+ value: "db:typeorm:cordova"
169
+ },
170
+ {
171
+ label: "NativeScript",
172
+ value: "db:typeorm:nativescript"
173
+ },
174
+ {
175
+ label: "Oracle",
176
+ value: "db:typeorm:oracle"
177
+ },
178
+ {
179
+ label: "MsSQL",
180
+ value: "db:typeorm:mssql"
181
+ },
182
+ {
183
+ label: "MongoDB",
184
+ value: "db:typeorm:mongodb"
185
+ },
186
+ {
187
+ label: "SQL.js",
188
+ value: "db:typeorm:sqljs"
189
+ },
190
+ {
191
+ label: "ReactNative",
192
+ value: "db:typeorm:reactnative"
193
+ },
194
+ {
195
+ label: "Expo",
196
+ value: "db:typeorm:expo"
197
+ }
198
+ ]
199
+ }
200
+ ]
201
+ },
202
+ {
203
+ label: "Documentation",
204
+ value: "doc",
205
+ items: [
206
+ {
207
+ label: "Swagger",
208
+ value: "doc:swagger"
209
+ },
210
+ {
211
+ label: "Scalar",
212
+ value: "doc:scalar"
213
+ }
214
+ ]
215
+ },
216
+ {
217
+ label: "TypeGraphQL",
218
+ value: "graphql",
219
+ items: []
220
+ },
221
+ {
222
+ label: "Linter",
223
+ value: "linter",
224
+ items: [
225
+ {
226
+ label: "EsLint",
227
+ value: "linter:eslint"
228
+ },
229
+ {
230
+ label: "Prettier",
231
+ value: "linter:prettier"
232
+ },
233
+ {
234
+ label: "Lint on commit",
235
+ value: "linter:lintstaged"
236
+ }
237
+ ]
238
+ },
239
+ {
240
+ label: "OpenID Connect provider",
241
+ value: "oidc",
242
+ items: []
243
+ },
244
+ {
245
+ label: "Passport.js",
246
+ value: "passportjs",
247
+ items: []
248
+ },
249
+ {
250
+ label: "Socket.io",
251
+ value: "socketio",
252
+ items: []
253
+ },
254
+ {
255
+ label: "Testing",
256
+ value: "testing",
257
+ items: [
258
+ {
259
+ label: "Vitest",
260
+ value: "testing:vitest"
261
+ },
262
+ {
263
+ label: "Jest (unstable with ESM)",
264
+ value: "testing:jest"
265
+ }
266
+ ]
267
+ }
268
+ ])
269
+ .opt("--features <features...>"),
20
270
  runtime: s
271
+ .enums(inject(RuntimesModule).list())
272
+ .default("node")
273
+ .description("Runtime (node, bun, ...).")
274
+ .opt("--runtime <runtime>"),
275
+ packageManager: s
276
+ .enums(inject(PackageManagersModule).list())
277
+ .default(PackageManager.NPM)
278
+ .choices([
279
+ {
280
+ label: FeaturesMap[PackageManager.NPM].name,
281
+ value: PackageManager.NPM
282
+ },
283
+ {
284
+ label: FeaturesMap[PackageManager.YARN_BERRY].name,
285
+ value: PackageManager.YARN_BERRY
286
+ },
287
+ {
288
+ label: FeaturesMap[PackageManager.PNPM].name,
289
+ value: PackageManager.PNPM
290
+ }
291
+ ])
292
+ .description("Package manager (npm, pnpm, yarn, bun).")
293
+ .opt("-m, --package-manager <packageManager>"),
294
+ GH_TOKEN: s
295
+ .string()
296
+ .optional()
297
+ .description("GitHub token to install premium plugins. For example config:aws_secrets:premium or all features endings by `:premium` needs a GH_TOKEN")
298
+ .opt("--gh-token <ghToken>"),
299
+ tsedVersion: s
21
300
  .string()
22
- .enum("node", "babel", "swc", "webpack", "bun")
23
- .description("The javascript runtime used to start application (node, node + webpack, node + swc, node + babel, bun)"),
24
- features: s.array().items(s.string().enum(FeatureType)).required().minItems(1).description("List of feature to create the projet"),
25
- skipPrompt: s.boolean().default(false).description("Skip the prompt")
301
+ .optional()
302
+ .default(DEFAULT_TSED_TAGS)
303
+ .description("Use a specific version of Ts.ED (format: x.x.x).")
304
+ .opt("-t, --tsed-version <version>"),
305
+ file: s.string().optional().description("Location of a file in which the features are defined.").opt("-f, --file <file>"),
306
+ skipPrompt: s.boolean().optional().default(false).description("Skip the prompt installation").opt("-s, --skip-prompt")
26
307
  })
27
308
  .unknown();
@@ -0,0 +1,15 @@
1
+ import { command } from "@tsed/cli-core";
2
+ import { MCP_SERVER } from "@tsed/cli-mcp";
3
+ import { inject } from "@tsed/di";
4
+ import { s } from "@tsed/schema";
5
+ const McpSchema = s.object({
6
+ http: s.boolean().default(false).description("Run MCP using HTTP server").opt("--http")
7
+ });
8
+ export const McpCommand = command({
9
+ name: "mcp",
10
+ description: "Run a MCP server",
11
+ inputSchema: McpSchema,
12
+ handler(data) {
13
+ return inject(MCP_SERVER).connect(data.http ? "streamable-http" : "stdio");
14
+ }
15
+ }).token();