@tsed/cli 7.0.0-beta.10 → 7.0.0-beta.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/esm/commands/add/AddCmd.js +1 -3
- package/lib/esm/commands/generate/GenerateCmd.js +6 -15
- package/lib/esm/commands/init/config/FeaturesPrompt.js +20 -3
- package/lib/esm/commands/template/CreateTemplateCommand.js +1 -10
- package/lib/esm/templates/command.template.js +5 -3
- package/lib/esm/templates/controller.template.js +6 -1
- package/lib/tsconfig.esm.tsbuildinfo +1 -1
- package/lib/types/commands/add/AddCmd.d.ts +2 -2
- package/lib/types/commands/generate/GenerateCmd.d.ts +2 -39
- package/lib/types/commands/index.d.ts +6 -6
- package/lib/types/commands/init/InitCmd.d.ts +3 -2
- package/lib/types/commands/init/InitOptionsCmd.d.ts +3 -3
- package/lib/types/commands/init/config/FeaturesPrompt.d.ts +12 -0
- package/lib/types/commands/mcp/McpCommand.d.ts +3 -3
- package/lib/types/commands/template/CreateTemplateCommand.d.ts +5 -5
- package/lib/types/commands/update/UpdateCmd.d.ts +3 -2
- package/lib/types/templates/agents.template.d.ts +1 -1
- package/lib/types/templates/asyncFactory.template.d.ts +1 -1
- package/lib/types/templates/barrels.template.d.ts +1 -1
- package/lib/types/templates/command.template.d.ts +1 -1
- package/lib/types/templates/config.template.d.ts +1 -1
- package/lib/types/templates/controller.template.d.ts +1 -1
- package/lib/types/templates/decorator.template.d.ts +1 -1
- package/lib/types/templates/docker-compose.template.d.ts +1 -1
- package/lib/types/templates/exception-filter.template.d.ts +1 -1
- package/lib/types/templates/factory.template.d.ts +1 -1
- package/lib/types/templates/index.command.template.d.ts +1 -1
- package/lib/types/templates/index.config.utils.template.d.ts +1 -1
- package/lib/types/templates/index.controller.template.d.ts +1 -1
- package/lib/types/templates/index.logger.template.d.ts +1 -1
- package/lib/types/templates/index.template.d.ts +1 -1
- package/lib/types/templates/interceptor.template.d.ts +1 -1
- package/lib/types/templates/interface.template.d.ts +1 -1
- package/lib/types/templates/middleware.template.d.ts +1 -1
- package/lib/types/templates/model.template.d.ts +1 -1
- package/lib/types/templates/module.template.d.ts +1 -1
- package/lib/types/templates/pipe.template.d.ts +1 -1
- package/lib/types/templates/prisma.service.template.d.ts +1 -1
- package/lib/types/templates/readme.template.d.ts +1 -1
- package/lib/types/templates/repository.template.d.ts +1 -1
- package/lib/types/templates/response-filter.template.d.ts +1 -1
- package/lib/types/templates/server.template.d.ts +1 -1
- package/lib/types/templates/service.template.d.ts +1 -1
- package/lib/types/templates/tsconfig.spec.template.d.ts +1 -1
- package/lib/types/templates/value.template.d.ts +1 -1
- package/lib/types/utils/defineTemplate.d.ts +3 -3
- package/package.json +4 -4
|
@@ -13,9 +13,7 @@ export class AddCmd {
|
|
|
13
13
|
message: "Which cli plugin ?",
|
|
14
14
|
default: initialOptions.name,
|
|
15
15
|
when: !initialOptions.name,
|
|
16
|
-
source: (
|
|
17
|
-
return this.cliPlugins.searchPlugins(keyword);
|
|
18
|
-
}
|
|
16
|
+
source: () => this.cliPlugins.searchPlugins()
|
|
19
17
|
}
|
|
20
18
|
];
|
|
21
19
|
}
|
|
@@ -3,14 +3,8 @@ import { CliProjectService } from "../../services/CliProjectService.js";
|
|
|
3
3
|
import { CliTemplatesService } from "../../services/CliTemplatesService.js";
|
|
4
4
|
import { addContextMethods } from "../../services/mappers/addContextMethods.js";
|
|
5
5
|
import { mapDefaultTemplateOptions } from "../../services/mappers/mapDefaultTemplateOptions.js";
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
return (_, keyword) => {
|
|
9
|
-
if (keyword) {
|
|
10
|
-
return items.filter((item) => item.name.toLowerCase().includes(keyword.toLowerCase()));
|
|
11
|
-
}
|
|
12
|
-
return items;
|
|
13
|
-
};
|
|
6
|
+
const mapChoices = (list) => {
|
|
7
|
+
return list.map((item) => ({ label: item.label, value: item.id }));
|
|
14
8
|
};
|
|
15
9
|
export class GenerateCmd {
|
|
16
10
|
constructor() {
|
|
@@ -21,11 +15,8 @@ export class GenerateCmd {
|
|
|
21
15
|
async $prompt(data) {
|
|
22
16
|
data = addContextMethods(data);
|
|
23
17
|
const templates = this.templates.find();
|
|
24
|
-
const templatesPrompts = await Promise.all(templates
|
|
25
|
-
|
|
26
|
-
.map((template) => {
|
|
27
|
-
return template.prompts(data);
|
|
28
|
-
}));
|
|
18
|
+
const templatesPrompts = await Promise.all(templates.filter((template) => template.prompts).map((template) => template.prompts(data)));
|
|
19
|
+
const additionalPrompts = templatesPrompts.flat();
|
|
29
20
|
return [
|
|
30
21
|
{
|
|
31
22
|
type: "autocomplete",
|
|
@@ -33,7 +24,7 @@ export class GenerateCmd {
|
|
|
33
24
|
message: "Which template you want to use?",
|
|
34
25
|
default: data.type,
|
|
35
26
|
when: () => templates.length > 1,
|
|
36
|
-
|
|
27
|
+
choices: mapChoices(this.templates.find(data.type))
|
|
37
28
|
},
|
|
38
29
|
{
|
|
39
30
|
type: "input",
|
|
@@ -42,7 +33,7 @@ export class GenerateCmd {
|
|
|
42
33
|
default: data.getName,
|
|
43
34
|
when: !data.name
|
|
44
35
|
},
|
|
45
|
-
...
|
|
36
|
+
...additionalPrompts
|
|
46
37
|
];
|
|
47
38
|
}
|
|
48
39
|
$mapContext(ctx) {
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { CliHttpClient } from "@tsed/cli-core";
|
|
2
|
+
import { inject } from "@tsed/di";
|
|
1
3
|
import { ArchitectureConvention, PlatformType, ProjectConvention } from "../../../interfaces/index.js";
|
|
2
4
|
import { hasFeature, hasValue, hasValuePremium } from "../utils/hasFeature.js";
|
|
3
5
|
import { isPlatform } from "../utils/isPlatform.js";
|
|
@@ -127,9 +129,6 @@ export const FeaturesMap = {
|
|
|
127
129
|
name: "Commands",
|
|
128
130
|
dependencies: {
|
|
129
131
|
"@tsed/cli-core": "{{cliVersion}}"
|
|
130
|
-
},
|
|
131
|
-
devDependencies: {
|
|
132
|
-
"@types/inquirer": "^8.2.4"
|
|
133
132
|
}
|
|
134
133
|
},
|
|
135
134
|
[ProjectConvention.DEFAULT]: {
|
|
@@ -452,6 +451,24 @@ export const FeaturesPrompt = (availableRuntimes, availablePackageManagers) => [
|
|
|
452
451
|
],
|
|
453
452
|
when: hasValue("featuresDB", FeatureType.TYPEORM)
|
|
454
453
|
},
|
|
454
|
+
{
|
|
455
|
+
type: "autocomplete",
|
|
456
|
+
name: "passportPackage",
|
|
457
|
+
message: "Which passport package ?",
|
|
458
|
+
when: hasFeature(FeatureType.PASSPORTJS),
|
|
459
|
+
async source(_, input) {
|
|
460
|
+
const result = await inject(CliHttpClient).get(`https://www.passportjs.org/packages/-/all.json`, {});
|
|
461
|
+
return Object.values(result)
|
|
462
|
+
.filter((o) => {
|
|
463
|
+
return o.name?.startsWith("passport-");
|
|
464
|
+
})
|
|
465
|
+
.filter((item) => item.name.toLowerCase().includes(input.toLowerCase()))
|
|
466
|
+
.map((item) => ({
|
|
467
|
+
name: `${item.name} - ${item.description}`,
|
|
468
|
+
value: item.name
|
|
469
|
+
}));
|
|
470
|
+
}
|
|
471
|
+
},
|
|
455
472
|
{
|
|
456
473
|
type: "password",
|
|
457
474
|
name: "GH_TOKEN",
|
|
@@ -3,15 +3,6 @@ import { snakeCase } from "change-case";
|
|
|
3
3
|
import { PKG } from "../../constants/index.js";
|
|
4
4
|
import { render } from "../../fn/render.js";
|
|
5
5
|
import { CliTemplatesService } from "../../services/CliTemplatesService.js";
|
|
6
|
-
const searchFactory = (list) => {
|
|
7
|
-
const items = list.map((item) => ({ name: item.label, value: item.id }));
|
|
8
|
-
return (_, keyword) => {
|
|
9
|
-
if (keyword) {
|
|
10
|
-
return items.filter((item) => item.name.toLowerCase().includes(keyword.toLowerCase()));
|
|
11
|
-
}
|
|
12
|
-
return items;
|
|
13
|
-
};
|
|
14
|
-
};
|
|
15
6
|
export class CreateTemplateCommand {
|
|
16
7
|
constructor() {
|
|
17
8
|
this.projectPackageJson = inject(ProjectPackageJson);
|
|
@@ -38,7 +29,7 @@ export class CreateTemplateCommand {
|
|
|
38
29
|
when: (ctx) => {
|
|
39
30
|
return ctx.from === "existing";
|
|
40
31
|
},
|
|
41
|
-
source:
|
|
32
|
+
source: () => this.templates.find().map((item) => ({ name: item.label, value: item.id }))
|
|
42
33
|
},
|
|
43
34
|
{
|
|
44
35
|
type: "confirm",
|
|
@@ -8,7 +8,8 @@ export default defineTemplate({
|
|
|
8
8
|
outputDir: "{{srcDir}}/bin/commands",
|
|
9
9
|
render(symbolName) {
|
|
10
10
|
const symbolParamName = kebabCase(symbolName);
|
|
11
|
-
return `import {Command, CommandProvider
|
|
11
|
+
return `import {Command, CommandProvider} from "@tsed/cli-core";
|
|
12
|
+
import type {PromptOptions} from "@tsed/cli-prompts";
|
|
12
13
|
|
|
13
14
|
export interface ${symbolName}Context {
|
|
14
15
|
}
|
|
@@ -24,9 +25,10 @@ export interface ${symbolName}Context {
|
|
|
24
25
|
})
|
|
25
26
|
export class ${symbolName} implements CommandProvider {
|
|
26
27
|
/**
|
|
27
|
-
* Ask questions with
|
|
28
|
+
* Ask questions with the Ts.ED prompt runner (powered by @clack/prompts).
|
|
29
|
+
* Return an empty array or don't implement the method to skip this step.
|
|
28
30
|
*/
|
|
29
|
-
async $prompt(initialOptions: Partial<${symbolName}Context>): Promise<
|
|
31
|
+
async $prompt(initialOptions: Partial<${symbolName}Context>): Promise<PromptOptions[]> {
|
|
30
32
|
return [];
|
|
31
33
|
}
|
|
32
34
|
|
|
@@ -20,7 +20,12 @@ export default defineTemplate({
|
|
|
20
20
|
when(state) {
|
|
21
21
|
return !!(["controller"].includes(state.type || context.type) || context.directory);
|
|
22
22
|
},
|
|
23
|
-
choices: context.getDirectories("controllers")
|
|
23
|
+
choices: context.getDirectories("controllers").map((value) => {
|
|
24
|
+
return {
|
|
25
|
+
label: value,
|
|
26
|
+
value
|
|
27
|
+
};
|
|
28
|
+
})
|
|
24
29
|
},
|
|
25
30
|
{
|
|
26
31
|
type: "input",
|