@tsed/cli 7.0.0-beta.11 → 7.0.0-beta.13
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 +5 -10
- package/lib/esm/commands/generate/GenerateCmd.js +3 -9
- package/lib/esm/commands/init/InitCmd.js +13 -12
- package/lib/esm/commands/init/config/FeaturesPrompt.js +19 -0
- package/lib/esm/commands/run/RunCmd.js +0 -1
- package/lib/esm/commands/template/CreateTemplateCommand.js +1 -10
- package/lib/esm/commands/update/UpdateCmd.js +2 -7
- package/lib/esm/templates/command.template.js +1 -1
- package/lib/esm/templates/controller.template.js +6 -1
- package/lib/tsconfig.esm.tsbuildinfo +1 -1
- package/lib/types/commands/index.d.ts +6 -6
- package/lib/types/commands/init/InitCmd.d.ts +1 -0
- package/lib/types/commands/init/InitOptionsCmd.d.ts +3 -3
- package/lib/types/commands/init/config/FeaturesPrompt.d.ts +32 -4
- package/lib/types/commands/mcp/McpCommand.d.ts +3 -3
- package/lib/types/commands/run/RunCmd.d.ts +2 -2
- package/lib/types/commands/template/CreateTemplateCommand.d.ts +1 -1
- package/lib/types/fn/exec.d.ts +1 -1
- package/package.json +6 -4
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CliPlugins, command,
|
|
1
|
+
import { CliPlugins, command, inject, PackageManagersModule, ProjectPackageJson } from "@tsed/cli-core";
|
|
2
2
|
export class AddCmd {
|
|
3
3
|
constructor() {
|
|
4
4
|
this.cliPlugins = inject(CliPlugins);
|
|
@@ -13,30 +13,25 @@ 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
|
}
|
|
22
20
|
$exec(ctx) {
|
|
23
21
|
this.packageJson.addDevDependency(ctx.name, "latest");
|
|
24
22
|
return [
|
|
25
|
-
|
|
26
|
-
title: "Install plugins",
|
|
27
|
-
task: createSubTasks(() => this.packageManagers.install(ctx), { ...ctx, concurrent: false })
|
|
28
|
-
},
|
|
23
|
+
this.packageManagers.task("Install plugins", ctx),
|
|
29
24
|
{
|
|
30
25
|
title: "Load plugins",
|
|
31
26
|
task: () => this.cliPlugins.loadPlugins()
|
|
32
27
|
},
|
|
33
28
|
{
|
|
34
29
|
title: "Install plugins dependencies",
|
|
35
|
-
task:
|
|
30
|
+
task: () => this.cliPlugins.addPluginsDependencies(ctx)
|
|
36
31
|
},
|
|
37
32
|
{
|
|
38
33
|
title: "Transform files",
|
|
39
|
-
task:
|
|
34
|
+
task: () => this.cliPlugins.addPluginsDependencies(ctx)
|
|
40
35
|
}
|
|
41
36
|
];
|
|
42
37
|
}
|
|
@@ -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() {
|
|
@@ -30,7 +24,7 @@ export class GenerateCmd {
|
|
|
30
24
|
message: "Which template you want to use?",
|
|
31
25
|
default: data.type,
|
|
32
26
|
when: () => templates.length > 1,
|
|
33
|
-
|
|
27
|
+
choices: mapChoices(this.templates.find(data.type))
|
|
34
28
|
},
|
|
35
29
|
{
|
|
36
30
|
type: "input",
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { basename, join } from "node:path";
|
|
2
|
-
import { CliExeca, CliFs, CliLoadFile, cliPackageJson, CliPlugins, command, Configuration,
|
|
2
|
+
import { CliExeca, CliFs, CliLoadFile, cliPackageJson, CliPlugins, command, Configuration, inject, PackageManagersModule, ProjectPackageJson } from "@tsed/cli-core";
|
|
3
|
+
import { tasks } from "@tsed/cli-tasks";
|
|
3
4
|
import { isString } from "@tsed/core";
|
|
4
5
|
import { constant } from "@tsed/di";
|
|
5
6
|
import { $asyncAlter } from "@tsed/hooks";
|
|
@@ -74,7 +75,7 @@ export class InitCmd {
|
|
|
74
75
|
srcDir: constant("project.srcDir", "src")
|
|
75
76
|
};
|
|
76
77
|
}
|
|
77
|
-
|
|
78
|
+
preExec(ctx) {
|
|
78
79
|
this.fs.ensureDirSync(this.packageJson.cwd);
|
|
79
80
|
ctx.projectName && (this.packageJson.name = ctx.projectName);
|
|
80
81
|
ctx.packageManager && this.packageJson.setPreference("packageManager", ctx.packageManager);
|
|
@@ -83,7 +84,7 @@ export class InitCmd {
|
|
|
83
84
|
ctx.convention && this.packageJson.setPreference("convention", ctx.convention);
|
|
84
85
|
ctx.platform && this.packageJson.setPreference("platform", ctx.platform);
|
|
85
86
|
ctx.GH_TOKEN && this.packageJson.setGhToken(ctx.GH_TOKEN);
|
|
86
|
-
|
|
87
|
+
return tasks([
|
|
87
88
|
{
|
|
88
89
|
title: "Write RC files",
|
|
89
90
|
skip: () => !ctx.premium,
|
|
@@ -101,19 +102,19 @@ export class InitCmd {
|
|
|
101
102
|
this.addFeatures(ctx);
|
|
102
103
|
}
|
|
103
104
|
},
|
|
104
|
-
|
|
105
|
-
title: "Install plugins",
|
|
106
|
-
task: createSubTasks(() => this.packageManagers.install(ctx), { ...ctx, concurrent: false })
|
|
107
|
-
},
|
|
105
|
+
this.packageManagers.task("Install plugins", ctx),
|
|
108
106
|
{
|
|
109
107
|
title: "Load plugins",
|
|
110
108
|
task: () => this.cliPlugins.loadPlugins()
|
|
111
109
|
},
|
|
112
110
|
{
|
|
113
111
|
title: "Install plugins dependencies",
|
|
114
|
-
task:
|
|
112
|
+
task: () => this.cliPlugins.addPluginsDependencies(ctx)
|
|
115
113
|
}
|
|
116
114
|
], ctx);
|
|
115
|
+
}
|
|
116
|
+
async $exec(ctx) {
|
|
117
|
+
await this.preExec(ctx);
|
|
117
118
|
const runtime = this.runtimes.get();
|
|
118
119
|
ctx = {
|
|
119
120
|
...ctx,
|
|
@@ -128,13 +129,13 @@ export class InitCmd {
|
|
|
128
129
|
},
|
|
129
130
|
{
|
|
130
131
|
title: "Alter package json",
|
|
131
|
-
task: () => {
|
|
132
|
-
|
|
132
|
+
task: async () => {
|
|
133
|
+
await $asyncAlter("$alterPackageJson", this.packageJson, [ctx]);
|
|
133
134
|
}
|
|
134
135
|
},
|
|
135
136
|
{
|
|
136
137
|
title: "Generate additional project files",
|
|
137
|
-
task:
|
|
138
|
+
task: async () => {
|
|
138
139
|
const subTasks = [
|
|
139
140
|
...(await exec("generate", {
|
|
140
141
|
//...ctx,
|
|
@@ -153,7 +154,7 @@ export class InitCmd {
|
|
|
153
154
|
: [])
|
|
154
155
|
];
|
|
155
156
|
return $asyncAlter("$alterInitSubTasks", subTasks, [ctx]);
|
|
156
|
-
}
|
|
157
|
+
}
|
|
157
158
|
},
|
|
158
159
|
{
|
|
159
160
|
title: "transform generated files to the project configuration",
|
|
@@ -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";
|
|
@@ -449,6 +451,23 @@ export const FeaturesPrompt = (availableRuntimes, availablePackageManagers) => [
|
|
|
449
451
|
],
|
|
450
452
|
when: hasValue("featuresDB", FeatureType.TYPEORM)
|
|
451
453
|
},
|
|
454
|
+
{
|
|
455
|
+
type: "autocomplete",
|
|
456
|
+
name: "passportPackage",
|
|
457
|
+
message: "Which passport package ?",
|
|
458
|
+
when: hasFeature(FeatureType.PASSPORTJS),
|
|
459
|
+
async source(_) {
|
|
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 && o.name?.startsWith("passport-");
|
|
464
|
+
})
|
|
465
|
+
.map((item) => ({
|
|
466
|
+
name: `${item.name} - ${item.description}`,
|
|
467
|
+
value: item.name
|
|
468
|
+
}));
|
|
469
|
+
}
|
|
470
|
+
},
|
|
452
471
|
{
|
|
453
472
|
type: "password",
|
|
454
473
|
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",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CliPackageJson, command,
|
|
1
|
+
import { CliPackageJson, command, inject, NpmRegistryClient, PackageManagersModule, ProjectPackageJson } from "@tsed/cli-core";
|
|
2
2
|
import { getValue } from "@tsed/core";
|
|
3
3
|
import semver from "semver";
|
|
4
4
|
import { IGNORE_TAGS, IGNORE_VERSIONS, MINIMAL_TSED_VERSION } from "../../constants/index.js";
|
|
@@ -59,12 +59,7 @@ export class UpdateCmd {
|
|
|
59
59
|
}
|
|
60
60
|
});
|
|
61
61
|
}
|
|
62
|
-
return [
|
|
63
|
-
{
|
|
64
|
-
title: "Update packages",
|
|
65
|
-
task: createSubTasks(() => this.packageManagers.install(), { ...ctx, concurrent: false })
|
|
66
|
-
}
|
|
67
|
-
];
|
|
62
|
+
return [this.packageManagers.task("Update dependencies", ctx)];
|
|
68
63
|
}
|
|
69
64
|
async getAvailableVersions() {
|
|
70
65
|
const { versions } = await this.npmRegistryClient.info("@tsed/platform-http", 10);
|
|
@@ -42,7 +42,7 @@ export class ${symbolName} implements CommandProvider {
|
|
|
42
42
|
};
|
|
43
43
|
}
|
|
44
44
|
/**
|
|
45
|
-
* This step
|
|
45
|
+
* This step runs your tasks via the @clack/prompts-based @tsed/cli-tasks helpers.
|
|
46
46
|
*/
|
|
47
47
|
async $exec(ctx: ${symbolName}Context): Promise<any> {
|
|
48
48
|
return [
|
|
@@ -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",
|