@tsed/cli 7.0.0-beta.6 → 7.0.0-beta.7

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.
@@ -4,305 +4,334 @@ import { s } from "@tsed/schema";
4
4
  import { DEFAULT_TSED_TAGS } from "../../../constants/index.js";
5
5
  import { ArchitectureConvention, PlatformType, ProjectConvention } from "../../../interfaces/index.js";
6
6
  import { RuntimesModule } from "../../../runtimes/RuntimesModule.js";
7
- import { FeaturesMap, FeatureType } from "../../init/config/FeaturesPrompt.js";
8
- export const InitSchema = () => s
9
- .object({
10
- root: s.string().description("Current working directory to initialize Ts.ED project").default("."),
11
- projectName: s
12
- .string()
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)
20
- .default(PlatformType.EXPRESS)
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
42
- .string()
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)
60
- .default(ProjectConvention.DEFAULT)
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...>"),
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
300
- .string()
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")
307
- })
308
- .unknown();
7
+ import { FeatureType } from "../../init/config/FeaturesPrompt.js";
8
+ export const InitSchema = () => {
9
+ const availablePackageManagers = inject(PackageManagersModule).list();
10
+ const availableRuntimes = inject(RuntimesModule).list();
11
+ return s
12
+ .object({
13
+ root: s.string().description("Current working directory to initialize Ts.ED project").default("."),
14
+ projectName: s
15
+ .string()
16
+ .optional()
17
+ .prompt("What is your project name")
18
+ .when((ctx) => ctx.root !== ".")
19
+ .description("Set the project name. By default, the project is the same as the name directory.")
20
+ .opt("-n, --project-name <projectName>"),
21
+ platform: s
22
+ .enums(PlatformType)
23
+ .default(PlatformType.EXPRESS)
24
+ .prompt("Choose the target Framework:")
25
+ .choices([
26
+ {
27
+ label: "Express.js",
28
+ value: PlatformType.EXPRESS,
29
+ checked: (options) => options.platform === PlatformType.EXPRESS || !options.platform // todo maybe it can be infered by default() and item value()
30
+ },
31
+ {
32
+ label: "Koa.js",
33
+ value: PlatformType.KOA,
34
+ checked: (options) => options.platform === PlatformType.KOA || !options.platform
35
+ },
36
+ {
37
+ label: "Fastify.js (beta)",
38
+ value: PlatformType.KOA,
39
+ checked: (options) => options.platform === PlatformType.KOA || !options.platform
40
+ }
41
+ ])
42
+ .description("Set the default platform for Ts.ED (Express.js, Koa.js or Fastify.js)")
43
+ .opt("-p, --platform <platform>"),
44
+ architecture: s
45
+ .string()
46
+ .enum(ArchitectureConvention)
47
+ .default(ArchitectureConvention.DEFAULT)
48
+ .prompt("Choose the architecture for your project:")
49
+ .description("Architecture convention for tree directory")
50
+ .choices([
51
+ {
52
+ label: "Ts.ED",
53
+ value: ArchitectureConvention.DEFAULT
54
+ },
55
+ {
56
+ label: "Feature",
57
+ value: ArchitectureConvention.FEATURE
58
+ }
59
+ ])
60
+ .opt("-a, --arch <architecture>"),
61
+ convention: s
62
+ .enums(ProjectConvention)
63
+ .default(ProjectConvention.DEFAULT)
64
+ .prompt("Choose the file naming convention:")
65
+ .description("Set the default file naming convention (Ts.ED, Angular).")
66
+ .choices([
67
+ {
68
+ label: "Ts.ED",
69
+ value: ProjectConvention.DEFAULT
70
+ },
71
+ {
72
+ label: "Angular",
73
+ value: ProjectConvention.ANGULAR
74
+ }
75
+ ])
76
+ .opt("-c, --convention <convention>"),
77
+ features: s
78
+ .array()
79
+ .items(s.enums(FeatureType))
80
+ .prompt("Choose the features needed for your project")
81
+ .description("List of features to enable (swagger, graphql, prisma, etc.).")
82
+ .choices([
83
+ {
84
+ label: "Commands",
85
+ value: FeatureType.COMMANDS
86
+ },
87
+ {
88
+ label: "Configuration sources",
89
+ value: FeatureType.CONFIG,
90
+ items: [
91
+ {
92
+ label: "Envs",
93
+ value: FeatureType.CONFIG_ENVS
94
+ },
95
+ {
96
+ label: "Dotenv",
97
+ value: FeatureType.CONFIG_DOTENV
98
+ },
99
+ {
100
+ label: "JSON",
101
+ value: FeatureType.CONFIG_JSON
102
+ },
103
+ {
104
+ label: "YAML",
105
+ value: FeatureType.CONFIG_YAML
106
+ },
107
+ {
108
+ label: "AWS Secrets Manager (Premium)",
109
+ value: FeatureType.CONFIG_AWS_SECRETS
110
+ },
111
+ {
112
+ label: "IORedis (Premium)",
113
+ value: FeatureType.CONFIG_IOREDIS
114
+ },
115
+ {
116
+ label: "MongoDB (Premium)",
117
+ value: FeatureType.CONFIG_MONGO
118
+ },
119
+ {
120
+ label: "Vault (Premium)",
121
+ value: FeatureType.CONFIG_VAULT
122
+ },
123
+ {
124
+ label: "Postgres (Premium)",
125
+ value: FeatureType.CONFIG_POSTGRES
126
+ }
127
+ ]
128
+ },
129
+ {
130
+ label: "ORM",
131
+ value: FeatureType.ORM,
132
+ items: [
133
+ {
134
+ label: "Prisma",
135
+ value: FeatureType.PRISMA
136
+ },
137
+ {
138
+ label: "Mongoose",
139
+ value: FeatureType.MONGOOSE
140
+ },
141
+ {
142
+ label: "TypeORM",
143
+ value: FeatureType.TYPEORM,
144
+ items: [
145
+ {
146
+ label: "MySQL",
147
+ value: FeatureType.TYPEORM_MYSQL
148
+ },
149
+ {
150
+ label: "MariaDB",
151
+ value: FeatureType.TYPEORM_MARIADB
152
+ },
153
+ {
154
+ label: "Postgres",
155
+ value: FeatureType.TYPEORM_POSTGRES
156
+ },
157
+ {
158
+ label: "CockRoachDB",
159
+ value: FeatureType.TYPEORM_COCKROACHDB
160
+ },
161
+ {
162
+ label: "SQLite",
163
+ value: FeatureType.TYPEORM_SQLITE
164
+ },
165
+ {
166
+ label: "Better SQLite3",
167
+ value: FeatureType.TYPEORM_BETTER_SQLITE3
168
+ },
169
+ {
170
+ label: "Cordova",
171
+ value: FeatureType.TYPEORM_CORDOVA
172
+ },
173
+ {
174
+ label: "NativeScript",
175
+ value: FeatureType.TYPEORM_NATIVESCRIPT
176
+ },
177
+ {
178
+ label: "Oracle",
179
+ value: FeatureType.TYPEORM_ORACLE
180
+ },
181
+ {
182
+ label: "MsSQL",
183
+ value: FeatureType.TYPEORM_MSSQL
184
+ },
185
+ {
186
+ label: "MongoDB",
187
+ value: FeatureType.TYPEORM_MONGODB
188
+ },
189
+ {
190
+ label: "SQL.js",
191
+ value: FeatureType.TYPEORM_SQLJS
192
+ },
193
+ {
194
+ label: "ReactNative",
195
+ value: FeatureType.TYPEORM_REACTNATIVE
196
+ },
197
+ {
198
+ label: "Expo",
199
+ value: FeatureType.TYPEORM_EXPO
200
+ }
201
+ ]
202
+ }
203
+ ]
204
+ },
205
+ {
206
+ label: "Documentation",
207
+ value: "doc",
208
+ items: [
209
+ {
210
+ label: "Swagger",
211
+ value: "doc:swagger"
212
+ },
213
+ {
214
+ label: "Scalar",
215
+ value: "doc:scalar"
216
+ }
217
+ ]
218
+ },
219
+ {
220
+ label: "TypeGraphQL",
221
+ value: "graphql",
222
+ items: []
223
+ },
224
+ {
225
+ label: "Linter",
226
+ value: FeatureType.LINTER,
227
+ items: [
228
+ {
229
+ label: "EsLint",
230
+ value: FeatureType.ESLINT
231
+ },
232
+ {
233
+ label: "Prettier",
234
+ value: FeatureType.PRETTIER
235
+ },
236
+ {
237
+ label: "Lint on commit",
238
+ value: FeatureType.LINT_STAGED
239
+ }
240
+ ]
241
+ },
242
+ {
243
+ label: "OpenID Connect provider",
244
+ value: FeatureType.OIDC,
245
+ items: []
246
+ },
247
+ {
248
+ label: "Passport.js",
249
+ value: FeatureType.PASSPORTJS,
250
+ items: []
251
+ },
252
+ {
253
+ label: "Socket.io",
254
+ value: FeatureType.SOCKETIO,
255
+ items: []
256
+ },
257
+ {
258
+ label: "Testing",
259
+ value: FeatureType.TESTING,
260
+ items: [
261
+ {
262
+ label: "Vitest",
263
+ value: FeatureType.VITEST
264
+ },
265
+ {
266
+ label: "Jest (unstable with ESM)",
267
+ value: FeatureType.JEST
268
+ }
269
+ ]
270
+ }
271
+ ])
272
+ .opt("--features <features...>"),
273
+ runtime: s
274
+ .enums(availableRuntimes)
275
+ .prompt("Choose the runtime:")
276
+ .choices([
277
+ {
278
+ label: "Node.js + SWC",
279
+ value: "node"
280
+ },
281
+ {
282
+ label: "Node.js + Babel",
283
+ value: "babel"
284
+ },
285
+ {
286
+ label: "Node.js + Webpack",
287
+ value: "webpack"
288
+ },
289
+ {
290
+ label: "Bun",
291
+ value: "bun"
292
+ }
293
+ ].filter((o) => availableRuntimes.includes(o.value)))
294
+ .default("node")
295
+ .description("Runtime (node, bun, ...).")
296
+ .opt("--runtime <runtime>"),
297
+ packageManager: s
298
+ .enums(availablePackageManagers)
299
+ .prompt("Choose the package manager:")
300
+ .when((answers) => answers.runtime !== "bun")
301
+ .default(PackageManager.NPM)
302
+ .choices([
303
+ {
304
+ label: "NPM",
305
+ value: PackageManager.NPM
306
+ },
307
+ {
308
+ label: "Yarn Berry",
309
+ value: PackageManager.YARN_BERRY
310
+ },
311
+ {
312
+ label: "PNPM",
313
+ value: PackageManager.PNPM
314
+ },
315
+ {
316
+ label: "Bun.js",
317
+ value: PackageManager.BUN
318
+ }
319
+ ].filter((o) => availablePackageManagers.includes(o.value)))
320
+ .description("Package manager (npm, pnpm, yarn, bun).")
321
+ .opt("-m, --package-manager <packageManager>"),
322
+ GH_TOKEN: s
323
+ .string()
324
+ .optional()
325
+ .description("GitHub token to install premium plugins. For example config:aws_secrets:premium or all features endings by `:premium` needs a GH_TOKEN")
326
+ .opt("--gh-token <ghToken>"),
327
+ tsedVersion: s
328
+ .string()
329
+ .optional()
330
+ .default(DEFAULT_TSED_TAGS)
331
+ .description("Use a specific version of Ts.ED (format: x.x.x).")
332
+ .opt("-t, --tsed-version <version>"),
333
+ file: s.string().optional().description("Location of a file in which the features are defined.").opt("-f, --file <file>"),
334
+ skipPrompt: s.boolean().optional().default(false).description("Skip the prompt installation").opt("-s, --skip-prompt")
335
+ })
336
+ .unknown();
337
+ };
@@ -1,5 +1,5 @@
1
1
  import { cleanObject, isFunction } from "@tsed/core";
2
- import { FeaturesMap, FeaturesPrompt, FrameworksPrompt } from "../config/FeaturesPrompt.js";
2
+ import { FeaturesMap, FeaturesPrompt } from "../config/FeaturesPrompt.js";
3
3
  function mapChoices(item, options) {
4
4
  return item.choices.map((choice) => {
5
5
  const { checked } = FeaturesMap[choice];