@tsed/cli 3.26.0-beta.1 → 3.26.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tsed/cli",
3
- "version": "3.26.0-beta.1",
3
+ "version": "3.26.0",
4
4
  "source": "./src/index.ts",
5
5
  "main": "./lib/cjs/index.js",
6
6
  "module": "./lib/esm/index.js",
@@ -17,9 +17,11 @@
17
17
  "build:esm": "tsc --build tsconfig.compile.esm.json",
18
18
  "start:help": "cross-env NODE_ENV=development ts-node -r tsconfig-paths/register src/bin/tsed.ts -h",
19
19
  "start:help:g": "cross-env NODE_ENV=development ts-node -r tsconfig-paths/register src/bin/tsed.ts generate -h",
20
+ "start:help:i": "cross-env NODE_ENV=development ts-node -r tsconfig-paths/register src/bin/tsed.ts init -h",
20
21
  "start:version": "cross-env NODE_ENV=development ts-node -r tsconfig-paths/register src/bin/tsed.ts --version",
21
22
  "start:init:help": "cross-env NODE_ENV=development ts-node -r tsconfig-paths/register src/bin/tsed.ts init -h",
22
23
  "start:init:run": "cross-env NODE_ENV=development cross-env CI=true ts-node -r tsconfig-paths/register src/bin/tsed.ts init -r ./.tmp/init/default",
24
+ "start:init:params": "cross-env NODE_ENV=development cross-env CI=true ts-node -r tsconfig-paths/register src/bin/tsed.ts init -r ./.tmp/init/default --skip-prompt --features swagger,jest,lintstaged",
23
25
  "start:init:run:name": "cross-env NODE_ENV=development ts-node -r tsconfig-paths/register src/bin/tsed.ts init -r ./.tmp/init awesome --verbose",
24
26
  "start:add:run": "cross-env NODE_ENV=development ts-node -r tsconfig-paths/register src/bin/tsed.ts add -r ./.tmp",
25
27
  "start:generate": "cross-env NODE_ENV=development ts-node -r tsconfig-paths/register src/bin/tsed.ts generate -r ./.tmp/init/default",
@@ -56,7 +58,7 @@
56
58
  "node": ">=14"
57
59
  },
58
60
  "dependencies": {
59
- "@tsed/cli-core": "3.26.0-beta.1",
61
+ "@tsed/cli-core": "3.26.0",
60
62
  "@tsed/core": ">=6.114.14",
61
63
  "@tsed/di": ">=6.114.14",
62
64
  "@tsed/logger": ">=6.0.0",
@@ -80,10 +82,7 @@
80
82
  "bugs": {
81
83
  "url": "https://github.com/tsedio/tsed-cli/issues"
82
84
  },
83
- "homepage": "https://github.com/tsedio/tsed-cli/tree/beta/packages/cli",
85
+ "homepage": "https://github.com/tsedio/tsed-cli/tree/master/packages/cli",
84
86
  "author": "Romain Lenzotti",
85
- "license": "MIT",
86
- "publishConfig": {
87
- "tag": "beta"
88
- }
87
+ "license": "MIT"
89
88
  }
package/readme.md CHANGED
@@ -48,10 +48,101 @@ https_proxy=http://username:password@host:port
48
48
  > Note: The following environment variables can be also used to configure the proxy `HTTPS_PROXY`, `HTTP_PROXY`
49
49
  > and `NODE_TLS_REJECT_UNAUTHORIZED`.
50
50
 
51
+ ## Commands
52
+
53
+ ```shell
54
+ Usage: tsed [options] [command]
55
+
56
+ Options:
57
+ -V, --version output the version number
58
+ -h, --help display help for command
59
+
60
+ Commands:
61
+ add [options] [name] Add cli plugin to the current project
62
+ generate|g [options] [type] [name] Generate a new provider class
63
+ update [options] Update all Ts.ED packages used by your project
64
+ init [options] [root] Init a new Ts.ED project
65
+ run [options] <command> Run a project level command
66
+ help [command] display help for commands
67
+ ```
68
+
51
69
  ## Init project
52
70
 
53
- ```typescript
71
+ ```shell
72
+ Usage: tsed init [options] [root]
73
+
74
+ Init a new Ts.ED project
75
+
76
+ Arguments:
77
+ root Root directory to initialize the Ts.ED project (default: ".")
78
+
79
+ Options:
80
+ -n, --project-name <projectName> Set the project name. By default, the project is the same as the name directory. (default: "")
81
+ -a, --arch <architecture> Set the default architecture convention (default or feature) (default: "default")
82
+ -c, --convention <convention> Set the default project convention (default or feature) (default: "default")
83
+ -p, --platform <platform> Set the default platform for Ts.ED (express or koa) (default: "express")
84
+ --features <features...> List of the Ts.ED features. (default: [])
85
+ -m, --package-manager <packageManager> The default package manager to install the project (default: "yarn")
86
+ -t, --tsed-version <version> Use a specific version of Ts.ED (format: 5.x.x). (default: "latest")
87
+ -f, --file <path> Location of a file in which the features are defined.
88
+ -s, --skip-prompt Skip the prompt. (default: false)
89
+ -r, --root-dir <path> Project root directory
90
+ --verbose Verbose mode
91
+ -h, --help display help for command
92
+ ```
93
+
94
+ Interactive prompt:
95
+
96
+ ```shell
97
+ tsed init .
98
+ ```
99
+
100
+ Skip prompt:
101
+
102
+ ```shell
103
+ tsed init . --platform express --package-manager yarn --features swagger,jest,eslint,lintstaged,prettier --skip-prompt
104
+ ```
105
+
106
+ ## Use file to generate project
107
+
108
+ A file can be defined to generate project. For example create a `tsed.template.yml` and add this code:
109
+
110
+ ```yaml
111
+ projectName: project-example
112
+ platform: express
113
+ architecture: default
114
+ convention: default
115
+ skipPrompt: true
116
+ packageManager: yarn
117
+ features:
118
+ - graphql
119
+ - socketio
120
+ - swagger
121
+ - oidc
122
+ - passportjs
123
+ - commands
124
+ - db
125
+ - prisma
126
+ - mongoose
127
+ - typeorm
128
+ - typeorm:mysql
129
+ - testing
130
+ - jest
131
+ - mocha
132
+ - linter
133
+ - eslint
134
+ - lintstaged
135
+ - prettier
136
+ - bundler
137
+ - babel
138
+ - babel:webpack
139
+ ```
140
+ > Note: The CLI support `yml` and `json` file!
141
+
142
+ Then:
54
143
 
144
+ ```shell
145
+ tsed init . --file ./tsed.template.yml
55
146
  ```
56
147
 
57
148
  ## Run Cli from code
@@ -1,513 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getFeaturesChoicesValues = exports.parseFeaturesFile = exports.FEATURES_TYPEORM_CONNECTION_TYPES = void 0;
4
- const interfaces_1 = require("../interfaces");
5
- const isPlatform_1 = require("../commands/init/utils/isPlatform");
6
- exports.FEATURES_TYPEORM_CONNECTION_TYPES = [
7
- {
8
- name: "MySQL",
9
- value: {
10
- type: "typeorm:mysql",
11
- dependencies: {
12
- mysql2: "latest"
13
- }
14
- }
15
- },
16
- {
17
- name: "MariaDB",
18
- value: {
19
- type: "typeorm:mariadb",
20
- dependencies: {
21
- mariadb: "latest"
22
- }
23
- }
24
- },
25
- {
26
- name: "Postgres",
27
- value: {
28
- type: "typeorm:postgres",
29
- dependencies: {
30
- pg: "latest"
31
- }
32
- }
33
- },
34
- {
35
- name: "CockRoachDB",
36
- value: {
37
- type: "typeorm:postgres",
38
- dependencies: {
39
- cockroachdb: "latest"
40
- }
41
- }
42
- },
43
- {
44
- name: "SQLite",
45
- value: {
46
- type: "typeorm:sqlite",
47
- dependencies: {
48
- sqlite3: "latest"
49
- }
50
- }
51
- },
52
- {
53
- name: "Better SQLite3",
54
- value: {
55
- type: "typeorm:better-sqlite3",
56
- dependencies: {
57
- "better-sqlite3": "latest"
58
- }
59
- }
60
- },
61
- {
62
- name: "Cordova",
63
- value: {
64
- type: "typeorm:cordova"
65
- }
66
- },
67
- {
68
- name: "NativeScript",
69
- value: {
70
- type: "typeorm:nativescript"
71
- }
72
- },
73
- {
74
- name: "Oracle",
75
- value: {
76
- type: "typeorm:oracle",
77
- dependencies: {
78
- oracledb: "latest"
79
- }
80
- }
81
- },
82
- {
83
- name: "MsSQL",
84
- value: {
85
- type: "typeorm:mssql",
86
- dependencies: {
87
- mssql: "latest"
88
- }
89
- }
90
- },
91
- {
92
- name: "MongoDB",
93
- value: {
94
- type: "typeorm:mongodb",
95
- dependencies: {
96
- mongodb: "latest"
97
- }
98
- }
99
- },
100
- {
101
- name: "SQL.js",
102
- value: {
103
- type: "typeorm:sqljs",
104
- dependencies: {}
105
- }
106
- },
107
- {
108
- name: "ReactNative",
109
- value: {
110
- type: "typeorm:reactnative",
111
- dependencies: {}
112
- }
113
- },
114
- {
115
- name: "Expo",
116
- value: {
117
- type: "typeorm:expo",
118
- dependencies: {}
119
- }
120
- }
121
- ];
122
- const babelDevDependencies = {
123
- "@babel/cli": "latest",
124
- "@babel/core": "latest",
125
- "@babel/node": "latest",
126
- "@babel/plugin-proposal-class-properties": "latest",
127
- "@babel/plugin-proposal-decorators": "latest",
128
- "@babel/preset-env": "latest",
129
- "@babel/preset-typescript": "latest",
130
- "babel-plugin-transform-typescript-metadata": "latest",
131
- "babel-watch": "latest"
132
- };
133
- const platformChoices = [
134
- {
135
- name: "Express.js",
136
- checked: true,
137
- value: "express"
138
- },
139
- {
140
- name: "Koa.js",
141
- checked: false,
142
- value: "koa"
143
- }
144
- ];
145
- const conventionChoices = [
146
- {
147
- name: "Ts.ED",
148
- checked: true,
149
- value: interfaces_1.ProjectConvention.DEFAULT
150
- },
151
- {
152
- name: "Angular",
153
- checked: false,
154
- value: interfaces_1.ProjectConvention.ANGULAR
155
- }
156
- ];
157
- const featureChoices = (cliVersion) => [
158
- {
159
- name: "TypeGraphQL",
160
- value: {
161
- type: "graphql",
162
- dependencies: {
163
- "@tsed/typegraphql": "{{tsedVersion}}"
164
- },
165
- devDependencies: {
166
- "@tsed/cli-plugin-typegraphql": cliVersion
167
- }
168
- }
169
- },
170
- {
171
- name: "Database",
172
- value: { type: "db" }
173
- },
174
- {
175
- name: "Passport.js",
176
- when: (0, isPlatform_1.isPlatform)("express"),
177
- value: {
178
- type: "passportjs",
179
- devDependencies: {
180
- "@tsed/cli-plugin-passport": cliVersion
181
- }
182
- }
183
- },
184
- {
185
- name: "Socket.io",
186
- value: {
187
- type: "socketio",
188
- dependencies: {
189
- "@tsed/socketio": "{{tsedVersion}}",
190
- "socket.io": "latest"
191
- }
192
- }
193
- },
194
- {
195
- name: "Swagger",
196
- value: {
197
- type: "swagger",
198
- dependencies: {
199
- "@tsed/swagger": "{{tsedVersion}}"
200
- }
201
- }
202
- },
203
- {
204
- name: "OpenID Connect provider",
205
- value: {
206
- type: "oidc",
207
- devDependencies: {
208
- "@tsed/cli-plugin-oidc-provider": cliVersion
209
- }
210
- }
211
- },
212
- {
213
- name: "Testing",
214
- value: {
215
- type: "testing",
216
- dependencies: {},
217
- devDependencies: {
218
- "@types/supertest": "latest",
219
- supertest: "latest"
220
- }
221
- }
222
- },
223
- {
224
- name: "Linter",
225
- value: {
226
- type: "linter"
227
- }
228
- },
229
- {
230
- name: "Bundler",
231
- value: {
232
- type: "bundler"
233
- }
234
- },
235
- {
236
- name: "Commands",
237
- value: {
238
- type: "commands",
239
- dependencies: {
240
- "@tsed/cli-core": cliVersion
241
- },
242
- devDependencies: {
243
- "@types/inquirer": "latest"
244
- }
245
- }
246
- }
247
- ];
248
- const featuresDbChoices = (cliVersion) => [
249
- {
250
- name: "Prisma",
251
- value: {
252
- type: "prisma",
253
- devDependencies: {
254
- "@tsed/cli-plugin-prisma": cliVersion
255
- }
256
- }
257
- },
258
- {
259
- name: "Mongoose",
260
- value: {
261
- type: "mongoose",
262
- devDependencies: {
263
- "@tsed/cli-plugin-mongoose": cliVersion
264
- }
265
- }
266
- },
267
- {
268
- name: "TypeORM",
269
- value: {
270
- type: "typeorm",
271
- devDependencies: {
272
- "@tsed/cli-plugin-typeorm": cliVersion
273
- }
274
- }
275
- }
276
- ];
277
- const featuresTestingChoices = (cliVersion) => [
278
- {
279
- name: "Jest",
280
- value: {
281
- type: "jest",
282
- devDependencies: {
283
- "@tsed/cli-plugin-jest": cliVersion
284
- }
285
- }
286
- },
287
- {
288
- name: "Mocha + Chai + Sinon",
289
- value: {
290
- type: "mocha",
291
- devDependencies: {
292
- "@tsed/cli-plugin-mocha": cliVersion
293
- }
294
- }
295
- }
296
- ];
297
- const featuresLinterChoices = (cliVersion) => [
298
- {
299
- name: "EsLint",
300
- checked: true,
301
- value: {
302
- type: "eslint",
303
- devDependencies: {
304
- "@tsed/cli-plugin-eslint": cliVersion
305
- }
306
- }
307
- }
308
- ];
309
- const featuresExtraLinterChoices = [
310
- {
311
- name: "Prettier",
312
- value: {
313
- type: "prettier"
314
- }
315
- },
316
- {
317
- name: "Lint on commit",
318
- value: {
319
- type: "lintstaged"
320
- }
321
- }
322
- ];
323
- const featuresBundlerChoices = [
324
- {
325
- name: "Babel",
326
- value: {
327
- type: "babel",
328
- devDependencies: {
329
- ...babelDevDependencies
330
- }
331
- }
332
- },
333
- {
334
- name: "Webpack",
335
- value: {
336
- type: "babel:webpack",
337
- devDependencies: {
338
- ...babelDevDependencies,
339
- "babel-loader": "latest",
340
- webpack: "latest",
341
- "webpack-cli": "latest"
342
- }
343
- }
344
- }
345
- ];
346
- const packageManagerChoices = [
347
- {
348
- name: "Yarn",
349
- checked: true,
350
- value: "yarn"
351
- },
352
- {
353
- name: "NPM",
354
- checked: false,
355
- value: "npm"
356
- },
357
- {
358
- name: "PNPM - experimental",
359
- checked: false,
360
- value: "pnpm"
361
- }
362
- ];
363
- const parseFeaturesFile = (features, cliVersion) => {
364
- return {
365
- platform: features.platform,
366
- convention: features.convention,
367
- features: [
368
- ...featureChoices(cliVersion)
369
- .map((v) => v.value)
370
- .filter((v) => features.features.filter((v) => typeof v === "string").includes(v.type)),
371
- ...features.features.filter((v) => typeof v === "object")
372
- ],
373
- featuresDB: featuresDbChoices(cliVersion).find((v) => v.value.type === features.featuresDB)?.value,
374
- featuresTypeORM: exports.FEATURES_TYPEORM_CONNECTION_TYPES.find((v) => v.value.type === features.featuresTypeORM)?.value,
375
- featuresTesting: featuresTestingChoices(cliVersion).find((v) => v.value.type === features.featuresTesting)?.value,
376
- featuresLinter: featuresLinterChoices(cliVersion).find((v) => v.value.type === features.featuresLinter)?.value,
377
- featuresExtraLinter: featuresExtraLinterChoices.map((v) => v.value).filter((v) => features.featuresExtraLinter?.includes(v.type)),
378
- featuresBundler: featuresBundlerChoices.find((v) => v.value.type === features.featuresBundlerChoices)?.value,
379
- packageManager: features.packageManager
380
- };
381
- };
382
- exports.parseFeaturesFile = parseFeaturesFile;
383
- const getFeaturesChoicesValues = (cliVersion) => {
384
- return {
385
- platform: platformChoices.map((v) => v.value),
386
- convention: conventionChoices.map((v) => v.value),
387
- features: featureChoices(cliVersion).map((v) => v.value.type),
388
- featuresDB: featuresDbChoices(cliVersion).map((v) => v.value.type),
389
- featuresTypeORM: exports.FEATURES_TYPEORM_CONNECTION_TYPES.map((v) => v.value.type),
390
- featuresTesting: featuresTestingChoices(cliVersion).map((v) => v.value.type),
391
- featuresLinter: featuresLinterChoices(cliVersion).map((v) => v.value.type),
392
- featuresExtraLinter: featuresExtraLinterChoices.map((v) => v.value.type),
393
- featuresBundler: featuresBundlerChoices.map((v) => v.value.type),
394
- packageManager: packageManagerChoices.map((v) => v.value)
395
- };
396
- };
397
- exports.getFeaturesChoicesValues = getFeaturesChoicesValues;
398
- //
399
- // registerProvider({
400
- // provide: Features,
401
- // deps: [CliPackageJson],
402
- // useFactory(cliPackageJson: CliPackageJson) {
403
- // const cliVersion = cliPackageJson.version;
404
- //
405
- // return [
406
- // {
407
- // message: "Choose the target platform:",
408
- // type: "list",
409
- // name: "platform",
410
- // choices: platformChoices
411
- // },
412
- // {
413
- // message: "Choose the architecture for your project:",
414
- // type: "list",
415
- // name: "architecture",
416
- // choices: [
417
- // {
418
- // name: "Ts.ED",
419
- // checked: true,
420
- // value: ArchitectureConvention.DEFAULT
421
- // },
422
- // {
423
- // name: "feature",
424
- // checked: false,
425
- // value: ArchitectureConvention.FEATURE
426
- // }
427
- // ]
428
- // },
429
- // {
430
- // message: "Choose the convention file styling:",
431
- // type: "list",
432
- // name: "convention",
433
- // choices: conventionChoices
434
- // },
435
- // {
436
- // type: "checkbox",
437
- // name: "features",
438
- // message: "Check the features needed for your project",
439
- // choices: featureChoices(cliVersion)
440
- // },
441
- // {
442
- // message: "Choose a ORM manager",
443
- // type: "list",
444
- // name: "featuresDB",
445
- // when: hasFeature("db"),
446
- // choices: featuresDbChoices(cliVersion)
447
- // },
448
- // {
449
- // type: "list",
450
- // name: "featuresTypeORM",
451
- // message: "Which TypeORM you want to install?",
452
- // choices: FEATURES_TYPEORM_CONNECTION_TYPES,
453
- // when: hasValue("featuresDB.type", "typeorm")
454
- // },
455
- // // {
456
- // // type: "password",
457
- // // name: "GH_TOKEN",
458
- // // message:
459
- // // "Enter GH_TOKEN to use the premium @tsedio/prisma package or leave blank (see https://tsed.io/tutorials/prisma-client.html)",
460
- // // when: hasValue("featuresDB.type", "prisma")
461
- // // },
462
- // {
463
- // message: "Choose unit framework",
464
- // type: "list",
465
- // name: "featuresTesting",
466
- // when: hasFeature("testing"),
467
- // choices: featuresTestingChoices(cliVersion)
468
- // },
469
- // {
470
- // message: "Choose linter tools framework",
471
- // type: "list",
472
- // name: "featuresLinter",
473
- // when: hasFeature("linter"),
474
- // choices: featuresLinterChoices(cliVersion)
475
- // },
476
- // {
477
- // message: "Choose extra linter tools",
478
- // type: "checkbox",
479
- // name: "featuresExtraLinter",
480
- // when: hasFeature("linter"),
481
- // choices: featuresExtraLinterChoices
482
- // },
483
- // {
484
- // message: "Choose your bundler",
485
- // type: "list",
486
- // name: "featuresBundler",
487
- // when: hasFeature("bundler"),
488
- // choices: featuresBundlerChoices
489
- // },
490
- // {
491
- // message: "Choose the OIDC base path server",
492
- // name: "oidcBasePath",
493
- // default: "/oidc",
494
- // when: hasFeature("oidc"),
495
- // type: "input"
496
- // },
497
- // {
498
- // message: "Choose the OIDC base path server",
499
- // name: "oidcBasePath",
500
- // default: "/oidc",
501
- // when: hasFeature("oidc"),
502
- // type: "input"
503
- // },
504
- // {
505
- // message: "Choose the package manager:",
506
- // type: "list",
507
- // name: "packageManager",
508
- // choices: packageManagerChoices
509
- // }
510
- // ];
511
- // }
512
- // });
513
- //# sourceMappingURL=Features.js.map