@tsed/cli 3.26.0-beta.1 → 3.26.2

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 (32) hide show
  1. package/lib/cjs/commands/generate/GenerateCmd.js +4 -8
  2. package/lib/cjs/commands/generate/GenerateCmd.js.map +1 -1
  3. package/lib/cjs/commands/init/InitCmd.js +55 -17
  4. package/lib/cjs/commands/init/InitCmd.js.map +1 -1
  5. package/lib/cjs/commands/init/config/FeaturesPrompt.js +1 -1
  6. package/lib/cjs/commands/init/config/FeaturesPrompt.js.map +1 -1
  7. package/lib/cjs/commands/init/config/InitFileSchema.js +18 -14
  8. package/lib/cjs/commands/init/config/InitFileSchema.js.map +1 -1
  9. package/lib/cjs/utils/fillImports.js +48 -0
  10. package/lib/cjs/utils/fillImports.js.map +1 -0
  11. package/lib/esm/commands/generate/GenerateCmd.js +4 -8
  12. package/lib/esm/commands/generate/GenerateCmd.js.map +1 -1
  13. package/lib/esm/commands/init/InitCmd.js +56 -18
  14. package/lib/esm/commands/init/InitCmd.js.map +1 -1
  15. package/lib/esm/commands/init/config/FeaturesPrompt.js +1 -1
  16. package/lib/esm/commands/init/config/FeaturesPrompt.js.map +1 -1
  17. package/lib/esm/commands/init/config/InitFileSchema.js +18 -14
  18. package/lib/esm/commands/init/config/InitFileSchema.js.map +1 -1
  19. package/lib/esm/utils/fillImports.js +44 -0
  20. package/lib/esm/utils/fillImports.js.map +1 -0
  21. package/lib/types/commands/init/InitCmd.d.ts +1 -0
  22. package/lib/types/commands/init/config/InitFileSchema.d.ts +16 -12
  23. package/lib/types/utils/fillImports.d.ts +1 -0
  24. package/package.json +6 -7
  25. package/readme.md +92 -1
  26. package/templates/generate/server.hbs +4 -23
  27. package/templates/init/.barrelsby.json.hbs +1 -7
  28. package/lib/cjs/services/Features.js +0 -513
  29. package/lib/cjs/services/Features.js.map +0 -1
  30. package/lib/esm/services/Features.js +0 -508
  31. package/lib/esm/services/Features.js.map +0 -1
  32. package/lib/types/services/Features.d.ts +0 -394
@@ -4,25 +4,18 @@ import { FeatureType } from "./FeaturesPrompt.js";
4
4
  export const InitFileSchema = {
5
5
  type: "object",
6
6
  properties: {
7
- platform: {
8
- type: "string",
9
- description: "The project name. By default, the project is the same as the name directory.",
10
- enum: Object.values(PlatformType),
11
- default: PlatformType.EXPRESS
7
+ tsedVersion: {
8
+ type: "string"
12
9
  },
13
10
  projectName: {
14
11
  type: "string",
15
12
  maxLength: 100
16
13
  },
17
- tsedVersion: {
18
- type: "string"
19
- },
20
- features: {
21
- type: "array",
22
- items: {
23
- type: "string",
24
- enum: Object.values(FeatureType)
25
- }
14
+ platform: {
15
+ type: "string",
16
+ description: "The project name. By default, the project is the same as the name directory.",
17
+ enum: Object.values(PlatformType),
18
+ default: PlatformType.EXPRESS
26
19
  },
27
20
  architecture: {
28
21
  type: "string",
@@ -34,10 +27,21 @@ export const InitFileSchema = {
34
27
  enum: Object.values(ProjectConvention),
35
28
  default: ProjectConvention.DEFAULT
36
29
  },
30
+ features: {
31
+ type: "array",
32
+ items: {
33
+ type: "string",
34
+ enum: Object.values(FeatureType)
35
+ }
36
+ },
37
37
  packageManager: {
38
38
  type: "string",
39
39
  enum: Object.values(PackageManager),
40
40
  default: PackageManager.YARN
41
+ },
42
+ skipPrompt: {
43
+ type: "boolean",
44
+ default: false
41
45
  }
42
46
  },
43
47
  required: ["features"],
@@ -1 +1 @@
1
- {"version":3,"file":"InitFileSchema.js","sourceRoot":"","sources":["../../../../../src/commands/init/config/InitFileSchema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,cAAc,EAAC,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAC,sBAAsB,EAAE,YAAY,EAAE,iBAAiB,EAAC,MAAM,qBAAqB,CAAC;AAC5F,OAAO,EAAC,WAAW,EAAC,MAAM,kBAAkB,CAAC;AAE7C,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,IAAI,EAAE,QAAQ;IACd,UAAU,EAAE;QACV,QAAQ,EAAE;YACR,IAAI,EAAE,QAAQ;YACd,WAAW,EAAE,8EAA8E;YAC3F,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,YAAY,CAAC;YACjC,OAAO,EAAE,YAAY,CAAC,OAAO;SAC9B;QACD,WAAW,EAAE;YACX,IAAI,EAAE,QAAQ;YACd,SAAS,EAAE,GAAG;SACf;QACD,WAAW,EAAE;YACX,IAAI,EAAE,QAAQ;SACf;QACD,QAAQ,EAAE;YACR,IAAI,EAAE,OAAO;YACb,KAAK,EAAE;gBACL,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC;aACjC;SACF;QACD,YAAY,EAAE;YACZ,IAAI,EAAE,QAAQ;YACd,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,sBAAsB,CAAC;YAC3C,OAAO,EAAE,sBAAsB,CAAC,OAAO;SACxC;QACD,UAAU,EAAE;YACV,IAAI,EAAE,QAAQ;YACd,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,iBAAiB,CAAC;YACtC,OAAO,EAAE,iBAAiB,CAAC,OAAO;SACnC;QACD,cAAc,EAAE;YACd,IAAI,EAAE,QAAQ;YACd,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,cAAc,CAAC;YACnC,OAAO,EAAE,cAAc,CAAC,IAAI;SAC7B;KACF;IACD,QAAQ,EAAE,CAAC,UAAU,CAAC;IACtB,oBAAoB,EAAE,IAAI;CAC3B,CAAC","sourcesContent":["import {PackageManager} from \"@tsed/cli-core\";\nimport {ArchitectureConvention, PlatformType, ProjectConvention} from \"../../../interfaces\";\nimport {FeatureType} from \"./FeaturesPrompt\";\n\nexport const InitFileSchema = {\n type: \"object\",\n properties: {\n platform: {\n type: \"string\",\n description: \"The project name. By default, the project is the same as the name directory.\",\n enum: Object.values(PlatformType),\n default: PlatformType.EXPRESS\n },\n projectName: {\n type: \"string\",\n maxLength: 100\n },\n tsedVersion: {\n type: \"string\"\n },\n features: {\n type: \"array\",\n items: {\n type: \"string\",\n enum: Object.values(FeatureType)\n }\n },\n architecture: {\n type: \"string\",\n enum: Object.values(ArchitectureConvention),\n default: ArchitectureConvention.DEFAULT\n },\n convention: {\n type: \"string\",\n enum: Object.values(ProjectConvention),\n default: ProjectConvention.DEFAULT\n },\n packageManager: {\n type: \"string\",\n enum: Object.values(PackageManager),\n default: PackageManager.YARN\n }\n },\n required: [\"features\"],\n additionalProperties: true\n};\n"]}
1
+ {"version":3,"file":"InitFileSchema.js","sourceRoot":"","sources":["../../../../../src/commands/init/config/InitFileSchema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,cAAc,EAAC,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAC,sBAAsB,EAAE,YAAY,EAAE,iBAAiB,EAAC,MAAM,qBAAqB,CAAC;AAC5F,OAAO,EAAC,WAAW,EAAC,MAAM,kBAAkB,CAAC;AAE7C,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,IAAI,EAAE,QAAQ;IACd,UAAU,EAAE;QACV,WAAW,EAAE;YACX,IAAI,EAAE,QAAQ;SACf;QACD,WAAW,EAAE;YACX,IAAI,EAAE,QAAQ;YACd,SAAS,EAAE,GAAG;SACf;QACD,QAAQ,EAAE;YACR,IAAI,EAAE,QAAQ;YACd,WAAW,EAAE,8EAA8E;YAC3F,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,YAAY,CAAC;YACjC,OAAO,EAAE,YAAY,CAAC,OAAO;SAC9B;QACD,YAAY,EAAE;YACZ,IAAI,EAAE,QAAQ;YACd,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,sBAAsB,CAAC;YAC3C,OAAO,EAAE,sBAAsB,CAAC,OAAO;SACxC;QACD,UAAU,EAAE;YACV,IAAI,EAAE,QAAQ;YACd,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,iBAAiB,CAAC;YACtC,OAAO,EAAE,iBAAiB,CAAC,OAAO;SACnC;QACD,QAAQ,EAAE;YACR,IAAI,EAAE,OAAO;YACb,KAAK,EAAE;gBACL,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC;aACjC;SACF;QACD,cAAc,EAAE;YACd,IAAI,EAAE,QAAQ;YACd,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,cAAc,CAAC;YACnC,OAAO,EAAE,cAAc,CAAC,IAAI;SAC7B;QACD,UAAU,EAAE;YACV,IAAI,EAAE,SAAS;YACf,OAAO,EAAE,KAAK;SACf;KACF;IACD,QAAQ,EAAE,CAAC,UAAU,CAAC;IACtB,oBAAoB,EAAE,IAAI;CAC3B,CAAC","sourcesContent":["import {PackageManager} from \"@tsed/cli-core\";\nimport {ArchitectureConvention, PlatformType, ProjectConvention} from \"../../../interfaces\";\nimport {FeatureType} from \"./FeaturesPrompt\";\n\nexport const InitFileSchema = {\n type: \"object\",\n properties: {\n tsedVersion: {\n type: \"string\"\n },\n projectName: {\n type: \"string\",\n maxLength: 100\n },\n platform: {\n type: \"string\",\n description: \"The project name. By default, the project is the same as the name directory.\",\n enum: Object.values(PlatformType),\n default: PlatformType.EXPRESS\n },\n architecture: {\n type: \"string\",\n enum: Object.values(ArchitectureConvention),\n default: ArchitectureConvention.DEFAULT\n },\n convention: {\n type: \"string\",\n enum: Object.values(ProjectConvention),\n default: ProjectConvention.DEFAULT\n },\n features: {\n type: \"array\",\n items: {\n type: \"string\",\n enum: Object.values(FeatureType)\n }\n },\n packageManager: {\n type: \"string\",\n enum: Object.values(PackageManager),\n default: PackageManager.YARN\n },\n skipPrompt: {\n type: \"boolean\",\n default: false\n }\n },\n required: [\"features\"],\n additionalProperties: true\n};\n"]}
@@ -0,0 +1,44 @@
1
+ import { ArchitectureConvention, PlatformType } from "../interfaces.js";
2
+ export function fillImports(ctx) {
3
+ ctx = { ...ctx };
4
+ Object.values(PlatformType).forEach((type) => {
5
+ ctx[type] = ctx.platform === type;
6
+ });
7
+ const isFeature = ctx.architecture === ArchitectureConvention.FEATURE;
8
+ ctx.barrels = JSON.stringify([
9
+ isFeature ? "./src/rest" : "./src/controllers/rest",
10
+ (ctx.swagger || ctx.oidc) && (isFeature ? "./src/pages" : "./src/controllers/pages"),
11
+ ctx.oidc && "./src/interactions",
12
+ ctx.graphql && "./src/datasources",
13
+ ctx.graphql && "./src/resolvers"
14
+ ].filter(Boolean));
15
+ ctx.imports = [
16
+ ctx.express && { from: "@tsed/platform-express", comment: " // /!\\ keep this import" },
17
+ ctx.express && { symbols: "bodyParser", from: "body-parser" },
18
+ ctx.express && { symbols: "compress", from: "compression" },
19
+ ctx.express && { symbols: "cookieParser", from: "cookie-parser" },
20
+ ctx.express && { symbols: "methodOverride", from: "method-override" },
21
+ ctx.express && { symbols: "cors", from: "cors" },
22
+ ctx.koa && { from: "@tsed/platform-koa", comment: " // /!\\ keep this import" },
23
+ ctx.koa && { symbols: "bodyParser", from: "koa-bodyparser" },
24
+ ctx.koa && { symbols: "compress", from: "koa-compress" },
25
+ ctx.koa && { symbols: "cors", from: "@koa/cors" },
26
+ ctx.koa && { symbols: "methodOverride", from: "koa-override", tsIgnore: true },
27
+ { from: "@tsed/ajv" },
28
+ ctx.swagger && { from: "@tsed/swagger" },
29
+ ctx.mongoose && { from: "@tsed/mongoose" },
30
+ ctx.oidc && { from: "@tsed/oidc-provider" },
31
+ ctx.graphql && { from: "@tsed/typegraphql" },
32
+ ctx.graphql && { from: "./datasources/index" },
33
+ ctx.graphql && { from: "./resolvers/index" },
34
+ { symbols: "{config}", from: "./config/index" },
35
+ { symbols: "* as rest", from: isFeature ? "./rest/index" : "./controllers/rest/index" },
36
+ (ctx.swagger || ctx.oidc) && {
37
+ symbols: "* as pages",
38
+ from: isFeature ? "./pages/index" : "./controllers/pages/index"
39
+ },
40
+ ctx.oidc && { symbols: "{InteractionsController}", from: "./controllers/oidc/InteractionsController" }
41
+ ].filter(Boolean);
42
+ return ctx;
43
+ }
44
+ //# sourceMappingURL=fillImports.js.map
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C,CAAC,cAAc,CAAC,CAAC,CAAC,0BAA0B,EAAC;QACrF,CAAC,GAAG,CAAC,OAAO,IAAI,GAAG,CAAC,IAAI,CAAC,IAAI;YAC3B,OAAO,EAAE,YAAY;YACrB,IAAI,EAAE,SAAS,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,2BAA2B;SAChE;QACD,GAAG,CAAC,IAAI,IAAI,EAAC,OAAO,EAAE,0BAA0B,EAAE,IAAI,EAAE,2CAA2C,EAAC;KACrG,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IAElB,OAAO,GAAG,CAAC;AACb,CAAC","sourcesContent":["import {ArchitectureConvention, PlatformType} from \"../interfaces\";\n\nexport function fillImports(ctx: any) {\n ctx = {...ctx};\n Object.values(PlatformType).forEach((type) => {\n ctx[type] = ctx.platform === type;\n });\n\n const isFeature = ctx.architecture === ArchitectureConvention.FEATURE;\n\n ctx.barrels = JSON.stringify(\n [\n isFeature ? \"./src/rest\" : \"./src/controllers/rest\",\n (ctx.swagger || ctx.oidc) && (isFeature ? \"./src/pages\" : \"./src/controllers/pages\"),\n ctx.oidc && \"./src/interactions\",\n ctx.graphql && \"./src/datasources\",\n ctx.graphql && \"./src/resolvers\"\n ].filter(Boolean)\n );\n\n ctx.imports = [\n ctx.express && {from: \"@tsed/platform-express\", comment: \" // /!\\\\ keep this import\"},\n ctx.express && {symbols: \"bodyParser\", from: \"body-parser\"},\n ctx.express && {symbols: \"compress\", from: \"compression\"},\n ctx.express && {symbols: \"cookieParser\", from: \"cookie-parser\"},\n ctx.express && {symbols: \"methodOverride\", from: \"method-override\"},\n ctx.express && {symbols: \"cors\", from: \"cors\"},\n ctx.koa && {from: \"@tsed/platform-koa\", comment: \" // /!\\\\ keep this import\"},\n ctx.koa && {symbols: \"bodyParser\", from: \"koa-bodyparser\"},\n ctx.koa && {symbols: \"compress\", from: \"koa-compress\"},\n ctx.koa && {symbols: \"cors\", from: \"@koa/cors\"},\n ctx.koa && {symbols: \"methodOverride\", from: \"koa-override\", tsIgnore: true},\n {from: \"@tsed/ajv\"},\n ctx.swagger && {from: \"@tsed/swagger\"},\n ctx.mongoose && {from: \"@tsed/mongoose\"},\n ctx.oidc && {from: \"@tsed/oidc-provider\"},\n ctx.graphql && {from: \"@tsed/typegraphql\"},\n ctx.graphql && {from: \"./datasources/index\"},\n ctx.graphql && {from: \"./resolvers/index\"},\n {symbols: \"{config}\", from: \"./config/index\"},\n {symbols: \"* as rest\", from: isFeature ? \"./rest/index\" : \"./controllers/rest/index\"},\n (ctx.swagger || ctx.oidc) && {\n symbols: \"* as pages\",\n from: isFeature ? \"./pages/index\" : \"./controllers/pages/index\"\n },\n ctx.oidc && {symbols: \"{InteractionsController}\", from: \"./controllers/oidc/InteractionsController\"}\n ].filter(Boolean);\n\n return ctx;\n}\n"]}
@@ -32,4 +32,5 @@ export declare class InitCmd implements CommandProvider {
32
32
  addFeatures(ctx: InitCmdContext): void;
33
33
  private addExpressDependencies;
34
34
  private addKoaDependencies;
35
+ static checkPrecondition(ctx: InitCmdContext): void;
35
36
  }
@@ -4,25 +4,18 @@ import { FeatureType } from "./FeaturesPrompt";
4
4
  export declare const InitFileSchema: {
5
5
  type: string;
6
6
  properties: {
7
- platform: {
7
+ tsedVersion: {
8
8
  type: string;
9
- description: string;
10
- enum: PlatformType[];
11
- default: PlatformType;
12
9
  };
13
10
  projectName: {
14
11
  type: string;
15
12
  maxLength: number;
16
13
  };
17
- tsedVersion: {
18
- type: string;
19
- };
20
- features: {
14
+ platform: {
21
15
  type: string;
22
- items: {
23
- type: string;
24
- enum: FeatureType[];
25
- };
16
+ description: string;
17
+ enum: PlatformType[];
18
+ default: PlatformType;
26
19
  };
27
20
  architecture: {
28
21
  type: string;
@@ -34,11 +27,22 @@ export declare const InitFileSchema: {
34
27
  enum: ProjectConvention[];
35
28
  default: ProjectConvention;
36
29
  };
30
+ features: {
31
+ type: string;
32
+ items: {
33
+ type: string;
34
+ enum: FeatureType[];
35
+ };
36
+ };
37
37
  packageManager: {
38
38
  type: string;
39
39
  enum: PackageManager[];
40
40
  default: PackageManager;
41
41
  };
42
+ skipPrompt: {
43
+ type: string;
44
+ default: boolean;
45
+ };
42
46
  };
43
47
  required: string[];
44
48
  additionalProperties: boolean;
@@ -0,0 +1 @@
1
+ export declare function fillImports(ctx: any): any;
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.2",
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.2",
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,29 +1,10 @@
1
1
  import {join} from "path";
2
2
  import {Configuration, Inject} from "@tsed/di";
3
3
  import {PlatformApplication} from "@tsed/common";
4
- {{#if express}}import "@tsed/platform-express"; // /!\ keep this import
5
- import bodyParser from "body-parser";
6
- import compress from "compression";
7
- import cookieParser from "cookie-parser";
8
- import methodOverride from "method-override";
9
- import cors from "cors";
10
- {{/if}}{{#if koa}}import "@tsed/platform-koa"; // /!\ keep this import
11
- import bodyParser from "koa-bodyparser";
12
- import compress from "koa-compress";
13
- import cors from "@koa/cors";
14
- import methodOverride from "koa-override";
15
- {{/if}}
16
- import "@tsed/ajv";{{#if swagger}}
17
- import "@tsed/swagger";{{/if}}{{#if mongoose}}
18
- import "@tsed/mongoose";{{/if}}{{#if oidc}}
19
- import "@tsed/oidc-provider";{{/if}}{{#if graphql}}
20
- import "@tsed/typegraphql";
21
- import "./datasources/index";
22
- import "./resolvers/index";{{/if}}
23
- import {config} from "./config/index";
24
- import * as rest from "./controllers/rest/index";{{#if swagger}}
25
- import * as pages from "./controllers/pages/index";{{/if}}{{#if oidc}}
26
- import {InteractionsController} from "./controllers/oidc/InteractionsController";{{/if}}
4
+ {{#forEach imports}}{{#if tsIngore}}
5
+ // @ts-ignore
6
+ {{/if}}import {{symbols}}{{#if symbols}} from {{/if}}"{{from}}";{{comment}}
7
+ {{/forEach}}
27
8
 
28
9
  @Configuration({
29
10
  ...config,
@@ -1,11 +1,5 @@
1
1
  {
2
- "directory": [
3
- "./src/controllers/rest"{{#or swagger oidc}},
4
- "./src/controllers/pages"{{/or}}{{#if oidc}},
5
- "./src/interactions"{{/if}}{{#if graphql}},
6
- "./src/datasources",
7
- "./src/resolvers"{{/if}}
8
- ],
2
+ "directory": {{{barrels}}},
9
3
  "exclude": [
10
4
  "__mock__",
11
5
  "__mocks__",