@tsed/cli 3.25.0 → 3.26.1
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/cjs/Cli.js.map +1 -1
- package/lib/cjs/commands/generate/GenerateCmd.js +4 -8
- package/lib/cjs/commands/generate/GenerateCmd.js.map +1 -1
- package/lib/cjs/commands/init/InitCmd.js +102 -40
- package/lib/cjs/commands/init/InitCmd.js.map +1 -1
- package/lib/cjs/commands/init/config/FeaturesPrompt.js +406 -0
- package/lib/cjs/commands/init/config/FeaturesPrompt.js.map +1 -0
- package/lib/cjs/commands/init/config/InitFileSchema.js +53 -0
- package/lib/cjs/commands/init/config/InitFileSchema.js.map +1 -0
- package/lib/cjs/commands/init/interfaces/InitCmdContext.js +3 -0
- package/lib/cjs/commands/init/interfaces/InitCmdContext.js.map +1 -0
- package/lib/cjs/commands/init/interfaces/InitOptions.js +3 -0
- package/lib/cjs/commands/init/interfaces/InitOptions.js.map +1 -0
- package/lib/cjs/commands/init/interfaces/InitPromptAnswers.js +3 -0
- package/lib/cjs/commands/init/interfaces/InitPromptAnswers.js.map +1 -0
- package/lib/cjs/commands/init/mappers/mapToContext.js +16 -0
- package/lib/cjs/commands/init/mappers/mapToContext.js.map +1 -0
- package/lib/cjs/commands/init/mappers/mapUniqFeatures.js +18 -0
- package/lib/cjs/commands/init/mappers/mapUniqFeatures.js.map +1 -0
- package/lib/cjs/commands/init/prompts/getFeaturesPrompt.js +25 -0
- package/lib/cjs/commands/init/prompts/getFeaturesPrompt.js.map +1 -0
- package/lib/cjs/commands/init/utils/hasFeature.js +13 -0
- package/lib/cjs/commands/init/utils/hasFeature.js.map +1 -0
- package/lib/cjs/commands/init/utils/isPlatform.js +8 -0
- package/lib/cjs/commands/init/utils/isPlatform.js.map +1 -0
- package/lib/cjs/index.js +5 -1
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/interfaces/PlatformType.js +9 -0
- package/lib/cjs/interfaces/PlatformType.js.map +1 -0
- package/lib/cjs/interfaces/index.js +1 -0
- package/lib/cjs/interfaces/index.js.map +1 -1
- package/lib/cjs/utils/fillImports.js +48 -0
- package/lib/cjs/utils/fillImports.js.map +1 -0
- package/lib/esm/Cli.js.map +1 -1
- package/lib/esm/commands/generate/GenerateCmd.js +4 -8
- package/lib/esm/commands/generate/GenerateCmd.js.map +1 -1
- package/lib/esm/commands/init/InitCmd.js +105 -43
- package/lib/esm/commands/init/InitCmd.js.map +1 -1
- package/lib/esm/commands/init/config/FeaturesPrompt.js +402 -0
- package/lib/esm/commands/init/config/FeaturesPrompt.js.map +1 -0
- package/lib/esm/commands/init/config/InitFileSchema.js +50 -0
- package/lib/esm/commands/init/config/InitFileSchema.js.map +1 -0
- package/lib/esm/commands/init/interfaces/InitCmdContext.js +2 -0
- package/lib/esm/commands/init/interfaces/InitCmdContext.js.map +1 -0
- package/lib/esm/commands/init/interfaces/InitOptions.js +2 -0
- package/lib/esm/commands/init/interfaces/InitOptions.js.map +1 -0
- package/lib/esm/commands/init/interfaces/InitPromptAnswers.js +2 -0
- package/lib/esm/commands/init/interfaces/InitPromptAnswers.js.map +1 -0
- package/lib/esm/commands/init/mappers/mapToContext.js +12 -0
- package/lib/esm/commands/init/mappers/mapToContext.js.map +1 -0
- package/lib/esm/commands/init/mappers/mapUniqFeatures.js +14 -0
- package/lib/esm/commands/init/mappers/mapUniqFeatures.js.map +1 -0
- package/lib/esm/commands/init/prompts/getFeaturesPrompt.js +21 -0
- package/lib/esm/commands/init/prompts/getFeaturesPrompt.js.map +1 -0
- package/lib/esm/commands/init/utils/hasFeature.js +8 -0
- package/lib/esm/commands/init/utils/hasFeature.js.map +1 -0
- package/lib/esm/commands/init/utils/isPlatform.js +4 -0
- package/lib/esm/commands/init/utils/isPlatform.js.map +1 -0
- package/lib/esm/index.js +5 -1
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/interfaces/PlatformType.js +6 -0
- package/lib/esm/interfaces/PlatformType.js.map +1 -0
- package/lib/esm/interfaces/index.js +1 -0
- package/lib/esm/interfaces/index.js.map +1 -1
- package/lib/esm/utils/fillImports.js +44 -0
- package/lib/esm/utils/fillImports.js.map +1 -0
- package/lib/types/Cli.d.ts +2 -2
- package/lib/types/commands/init/InitCmd.d.ts +9 -24
- package/lib/types/commands/init/config/FeaturesPrompt.d.ts +98 -0
- package/lib/types/commands/init/config/InitFileSchema.d.ts +49 -0
- package/lib/types/commands/init/interfaces/InitCmdContext.d.ts +6 -0
- package/lib/types/commands/init/interfaces/InitOptions.d.ts +19 -0
- package/lib/types/commands/init/interfaces/InitPromptAnswers.d.ts +16 -0
- package/lib/types/commands/init/mappers/mapToContext.d.ts +2 -0
- package/lib/types/commands/init/mappers/mapUniqFeatures.d.ts +3 -0
- package/lib/types/commands/init/prompts/getFeaturesPrompt.d.ts +2 -0
- package/lib/types/commands/init/utils/hasFeature.d.ts +2 -0
- package/lib/types/commands/init/utils/isPlatform.d.ts +1 -0
- package/lib/types/index.d.ts +5 -1
- package/lib/types/interfaces/PlatformType.d.ts +4 -0
- package/lib/types/interfaces/index.d.ts +1 -0
- package/lib/types/utils/fillImports.d.ts +1 -0
- package/package.json +4 -2
- package/readme.md +97 -0
- package/templates/generate/server.hbs +4 -23
- package/templates/init/.barrelsby.json.hbs +1 -7
- package/lib/cjs/services/Features.js +0 -528
- package/lib/cjs/services/Features.js.map +0 -1
- package/lib/esm/services/Features.js +0 -519
- package/lib/esm/services/Features.js.map +0 -1
- package/lib/types/services/Features.d.ts +0 -412
package/lib/cjs/index.js
CHANGED
|
@@ -3,11 +3,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
4
|
tslib_1.__exportStar(require("./commands/add/AddCmd"), exports);
|
|
5
5
|
tslib_1.__exportStar(require("./commands/init/InitCmd"), exports);
|
|
6
|
+
tslib_1.__exportStar(require("./commands/init/interfaces/InitCmdContext"), exports);
|
|
7
|
+
tslib_1.__exportStar(require("./commands/init/interfaces/InitOptions"), exports);
|
|
8
|
+
tslib_1.__exportStar(require("./commands/init/config/FeaturesPrompt"), exports);
|
|
9
|
+
tslib_1.__exportStar(require("./commands/init/config/FeaturesPrompt"), exports);
|
|
6
10
|
tslib_1.__exportStar(require("./commands/generate/GenerateCmd"), exports);
|
|
7
11
|
tslib_1.__exportStar(require("./commands/update/UpdateCmd"), exports);
|
|
12
|
+
tslib_1.__exportStar(require("./commands/init/prompts/getFeaturesPrompt"), exports);
|
|
8
13
|
tslib_1.__exportStar(require("./interfaces"), exports);
|
|
9
14
|
tslib_1.__exportStar(require("./services/ProvidersInfoService"), exports);
|
|
10
|
-
tslib_1.__exportStar(require("./services/Features"), exports);
|
|
11
15
|
tslib_1.__exportStar(require("./pipes"), exports);
|
|
12
16
|
tslib_1.__exportStar(require("./constants"), exports);
|
|
13
17
|
tslib_1.__exportStar(require("./Cli"), exports);
|
package/lib/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAA,gEAAsC;AACtC,kEAAwC;AACxC,0EAAgD;AAChD,sEAA4C;AAC5C,uDAA6B;AAC7B,0EAAgD;AAChD,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAA,gEAAsC;AACtC,kEAAwC;AACxC,oFAA0D;AAC1D,iFAAuD;AACvD,gFAAsD;AACtD,gFAAsD;AACtD,0EAAgD;AAChD,sEAA4C;AAC5C,oFAA0D;AAC1D,uDAA6B;AAC7B,0EAAgD;AAChD,kDAAwB;AACxB,sDAA4B;AAC5B,gDAAsB","sourcesContent":["export * from \"./commands/add/AddCmd\";\nexport * from \"./commands/init/InitCmd\";\nexport * from \"./commands/init/interfaces/InitCmdContext\";\nexport * from \"./commands/init/interfaces/InitOptions\";\nexport * from \"./commands/init/config/FeaturesPrompt\";\nexport * from \"./commands/init/config/FeaturesPrompt\";\nexport * from \"./commands/generate/GenerateCmd\";\nexport * from \"./commands/update/UpdateCmd\";\nexport * from \"./commands/init/prompts/getFeaturesPrompt\";\nexport * from \"./interfaces\";\nexport * from \"./services/ProvidersInfoService\";\nexport * from \"./pipes\";\nexport * from \"./constants\";\nexport * from \"./Cli\";\n"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PlatformType = void 0;
|
|
4
|
+
var PlatformType;
|
|
5
|
+
(function (PlatformType) {
|
|
6
|
+
PlatformType["EXPRESS"] = "express";
|
|
7
|
+
PlatformType["KOA"] = "koa";
|
|
8
|
+
})(PlatformType = exports.PlatformType || (exports.PlatformType = {}));
|
|
9
|
+
//# sourceMappingURL=PlatformType.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PlatformType.js","sourceRoot":"","sources":["../../../src/interfaces/PlatformType.ts"],"names":[],"mappings":";;;AAAA,IAAY,YAGX;AAHD,WAAY,YAAY;IACtB,mCAAmB,CAAA;IACnB,2BAAW,CAAA;AACb,CAAC,EAHW,YAAY,GAAZ,oBAAY,KAAZ,oBAAY,QAGvB","sourcesContent":["export enum PlatformType {\n EXPRESS = \"express\",\n KOA = \"koa\"\n}\n"]}
|
|
@@ -2,5 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
4
|
tslib_1.__exportStar(require("./ProjectConvention"), exports);
|
|
5
|
+
tslib_1.__exportStar(require("./PlatformType"), exports);
|
|
5
6
|
tslib_1.__exportStar(require("./ArchitectureConvention"), exports);
|
|
6
7
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/interfaces/index.ts"],"names":[],"mappings":";;;AAAA,8DAAoC;AACpC,mEAAyC","sourcesContent":["export * from \"./ProjectConvention\";\nexport * from \"./ArchitectureConvention\";\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/interfaces/index.ts"],"names":[],"mappings":";;;AAAA,8DAAoC;AACpC,yDAA+B;AAC/B,mEAAyC","sourcesContent":["export * from \"./ProjectConvention\";\nexport * from \"./PlatformType\";\nexport * from \"./ArchitectureConvention\";\n"]}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.fillImports = void 0;
|
|
4
|
+
const interfaces_1 = require("../interfaces");
|
|
5
|
+
function fillImports(ctx) {
|
|
6
|
+
ctx = { ...ctx };
|
|
7
|
+
Object.values(interfaces_1.PlatformType).forEach((type) => {
|
|
8
|
+
ctx[type] = ctx.platform === type;
|
|
9
|
+
});
|
|
10
|
+
const isFeature = ctx.architecture === interfaces_1.ArchitectureConvention.FEATURE;
|
|
11
|
+
ctx.barrels = JSON.stringify([
|
|
12
|
+
isFeature ? "./src/rest" : "./src/controllers/rest",
|
|
13
|
+
(ctx.swagger || ctx.oidc) && (isFeature ? "./src/pages" : "./src/controllers/pages"),
|
|
14
|
+
ctx.oidc && "./src/interactions",
|
|
15
|
+
ctx.graphql && "./src/datasources",
|
|
16
|
+
"./src/resolvers"
|
|
17
|
+
].filter(Boolean));
|
|
18
|
+
ctx.imports = [
|
|
19
|
+
ctx.express && { from: "@tsed/platform-express", comment: " // /!\\ keep this import" },
|
|
20
|
+
ctx.express && { symbols: "bodyParser", from: "body-parser" },
|
|
21
|
+
ctx.express && { symbols: "compress", from: "compression" },
|
|
22
|
+
ctx.express && { symbols: "cookieParser", from: "cookie-parser" },
|
|
23
|
+
ctx.express && { symbols: "methodOverride", from: "method-override" },
|
|
24
|
+
ctx.express && { symbols: "cors", from: "cors" },
|
|
25
|
+
ctx.koa && { from: "@tsed/platform-koa", comment: " // /!\\ keep this import" },
|
|
26
|
+
ctx.koa && { symbols: "bodyParser", from: "koa-bodyparser" },
|
|
27
|
+
ctx.koa && { symbols: "compress", from: "koa-compress" },
|
|
28
|
+
ctx.koa && { symbols: "cors", from: "@koa/cors" },
|
|
29
|
+
ctx.koa && { symbols: "methodOverride", from: "koa-override", tsIgnore: true },
|
|
30
|
+
{ from: "@tsed/ajv" },
|
|
31
|
+
ctx.swagger && { from: "@tsed/swagger" },
|
|
32
|
+
ctx.mongoose && { from: "@tsed/mongoose" },
|
|
33
|
+
ctx.oidc && { from: "@tsed/oidc-provider" },
|
|
34
|
+
ctx.graphql && { from: "@tsed/typegraphql" },
|
|
35
|
+
ctx.graphql && { from: "./datasources/index" },
|
|
36
|
+
ctx.graphql && { from: "./resolvers/index" },
|
|
37
|
+
{ symbols: "{config}", from: "./config/index" },
|
|
38
|
+
{ symbols: "* as rest", from: isFeature ? "./rest/index" : "./controllers/rest/index" },
|
|
39
|
+
(ctx.swagger || ctx.oidc) && {
|
|
40
|
+
symbols: "* as pages",
|
|
41
|
+
from: isFeature ? "./pages/index" : "./controllers/pages/index"
|
|
42
|
+
},
|
|
43
|
+
ctx.oidc && { symbols: "{InteractionsController}", from: "./controllers/oidc/InteractionsController" }
|
|
44
|
+
].filter(Boolean);
|
|
45
|
+
return ctx;
|
|
46
|
+
}
|
|
47
|
+
exports.fillImports = fillImports;
|
|
48
|
+
//# sourceMappingURL=fillImports.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fillImports.js","sourceRoot":"","sources":["../../../src/utils/fillImports.ts"],"names":[],"mappings":";;;AAAA,8CAAmE;AAEnE,SAAgB,WAAW,CAAC,GAAQ;IAClC,GAAG,GAAG,EAAC,GAAG,GAAG,EAAC,CAAC;IACf,MAAM,CAAC,MAAM,CAAC,yBAAY,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;QAC3C,GAAG,CAAC,IAAI,CAAC,GAAG,GAAG,CAAC,QAAQ,KAAK,IAAI,CAAC;IACpC,CA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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 \"./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"]}
|
package/lib/esm/Cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Cli.js","sourceRoot":"","sources":["../../src/Cli.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAC,MAAM,gBAAgB,CAAC;AACvC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,6DAA6D;AAC7D,aAAa;AACb,OAAO,KAAK,MAAM,cAAc,CAAC;AACjC,OAAO,EAAC,GAAG,EAAE,YAAY,EAAC,MAAM,aAAa,CAAC;AAC9C,OAAO,QAAQ,MAAM,YAAY,CAAC;AAClC,OAAO,EAAC,sBAAsB,EAAE,iBAAiB,EAAC,MAAM,cAAc,CAAC;AAIvE,MAAM,OAAO,GAAI,SAAQ,OAAO;IAC9B,MAAM,CAAC,QAAQ,GAAG;QAChB,IAAI,EAAE,MAAM;QACZ,GAAG,EAAE,GAAG;QACR,WAAW,EAAE,YAAY;QACzB,OAAO,EAAE,IAAI;QACb,QAAQ;QACR,yBAAyB;YACvB,OAAO;gBACL,UAAU,EAAE,iBAAiB,CAAC,OAAO;gBACrC,YAAY,EAAE,sBAAsB,CAAC,OAAO;aAC7C,CAAC;QACJ,CAAC;QACD,OAAO,EAAE;YACP,iBAAiB,EAAE,IAAI;SACxB;QACD,MAAM,EAAE;YACN,KAAK,EAAE,MAAM;SACd;KACF,CAAC;IAEF,MAAM,CAAC,YAAY,CAAC,GAAQ;QAC1B,IAAI,CAAC,GAAG,EAAE;YACR,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,4FAA4F,CAAC,CAAC,CAAC;YACrH,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;SACjB;IACH,CAAC;IAED,MAAM,CAAC,SAAS,CAAC,IAAY;QAC3B,IAAI,CAAC,IAAI,EAAE;YACT,OAAO,CAAC,GAAG,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AAC,UAAU,CAAC;YACf,YAAY,EAAE,OAAO,CAAC,OAAO,CAAC,YAAY,CAAC;YAC3C,UAAU,EAAE,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC;YACvC,cAAc,EAAE,OAAO,CAAC,OAAO,CAAC,cAAc,CAAC;YAC/C,gBAAgB,EAAE,OAAO,CAAC,OAAO,CAAC,gBAAgB,CAAC;YACnD,WAAW,EAAE,OAAO,CAAC,OAAO,CAAC,WAAW,CAAC;SAC1C,CAAC,CAAC;IACL,CAAC","sourcesContent":["import {CliCore} from \"@tsed/cli-core\";\nimport chalk from \"chalk\";\n// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-ignore\nimport alias from \"module-alias\";\nimport {PKG, TEMPLATE_DIR} from \"./constants\";\nimport commands from \"./commands\";\nimport {ArchitectureConvention, ProjectConvention} from \"./interfaces\";\nimport {InitCmdContext} from \"./commands/init/
|
|
1
|
+
{"version":3,"file":"Cli.js","sourceRoot":"","sources":["../../src/Cli.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAC,MAAM,gBAAgB,CAAC;AACvC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,6DAA6D;AAC7D,aAAa;AACb,OAAO,KAAK,MAAM,cAAc,CAAC;AACjC,OAAO,EAAC,GAAG,EAAE,YAAY,EAAC,MAAM,aAAa,CAAC;AAC9C,OAAO,QAAQ,MAAM,YAAY,CAAC;AAClC,OAAO,EAAC,sBAAsB,EAAE,iBAAiB,EAAC,MAAM,cAAc,CAAC;AAIvE,MAAM,OAAO,GAAI,SAAQ,OAAO;IAC9B,MAAM,CAAC,QAAQ,GAAG;QAChB,IAAI,EAAE,MAAM;QACZ,GAAG,EAAE,GAAG;QACR,WAAW,EAAE,YAAY;QACzB,OAAO,EAAE,IAAI;QACb,QAAQ;QACR,yBAAyB;YACvB,OAAO;gBACL,UAAU,EAAE,iBAAiB,CAAC,OAAO;gBACrC,YAAY,EAAE,sBAAsB,CAAC,OAAO;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C,CAAC;QAEzB,OAAO,KAAK,CAAC,SAAS,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;IACpC,CAAC;IAID,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,GAAW,EAAE,OAAY;QAC7C,IAAI,CAAC,aAAa,EAAE,CAAC;QAErB,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,MAAM,CAAM,EAAC,GAAG,GAAG,CAAC,QAAQ,EAAQ,EAAE,GAAG,CAAC,CAAC;QAElE,MAAM,GAAG,CAAC,UAAU,CAAC,QAAQ,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IAC9C,CAAC;IAED,MAAM,CAAC,aAAa;QAClB,KAAK,CAAC,UAAU,CAAC;YACf,YAAY,EAAE,OAAO,CAAC,OAAO,CAAC,YAAY,CAAC;YAC3C,UAAU,EAAE,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC;YACvC,cAAc,EAAE,OAAO,CAAC,OAAO,CAAC,cAAc,CAAC;YAC/C,gBAAgB,EAAE,OAAO,CAAC,OAAO,CAAC,gBAAgB,CAAC;YACnD,WAAW,EAAE,OAAO,CAAC,OAAO,CAAC,WAAW,CAAC;SAC1C,CAAC,CAAC;IACL,CAAC","sourcesContent":["import {CliCore} from \"@tsed/cli-core\";\nimport chalk from \"chalk\";\n// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-ignore\nimport alias from \"module-alias\";\nimport {PKG, TEMPLATE_DIR} from \"./constants\";\nimport commands from \"./commands\";\nimport {ArchitectureConvention, ProjectConvention} from \"./interfaces\";\nimport {InitCmdContext} from \"./commands/init/interfaces/InitCmdContext\";\nimport {GenerateCmdContext} from \"./commands/generate/GenerateCmd\";\n\nexport class Cli extends CliCore {\n static defaults = {\n name: \"tsed\",\n pkg: PKG,\n templateDir: TEMPLATE_DIR,\n plugins: true,\n commands,\n defaultProjectPreferences() {\n return {\n convention: ProjectConvention.DEFAULT,\n architecture: ArchitectureConvention.DEFAULT\n };\n },\n project: {\n reinstallAfterRun: true\n },\n logger: {\n level: \"info\"\n }\n };\n\n static checkPackage(pkg: any) {\n if (!pkg) {\n console.log(chalk.red(`settings.pkg is required. Require the package.json of your CLI when you bootstrap the CLI.`));\n process.exit(1);\n }\n }\n\n static checkName(name: string) {\n if (!name) {\n console.log(chalk.red(`settings.name is required. Add the name of your CLI.`));\n process.exit(1);\n }\n }\n\n static checkPrecondition(settings: any) {\n const {pkg} = settings;\n\n this.checkPackage(pkg);\n this.checkName(pkg.name);\n\n if (pkg?.engines?.node) {\n this.checkNodeVersion(pkg.engines.node, pkg.name);\n }\n }\n\n static async bootstrap(settings: any = {}) {\n const opts: any = {\n ...Cli.defaults,\n ...settings\n };\n\n const {pkg} = opts;\n\n this.checkPrecondition(opts);\n this.createAliases();\n this.updateNotifier(pkg);\n\n return super.bootstrap(opts, Cli);\n }\n\n static async dispatch(cmd: \"init\", context: InitCmdContext): Promise<void>;\n static async dispatch(cmd: \"generate\", context: GenerateCmdContext): Promise<void>;\n static async dispatch(cmd: string, context: any) {\n this.createAliases();\n\n const cli = await this.create<Cli>({...Cli.defaults} as any, Cli);\n\n await cli.cliService.dispatch(cmd, context);\n }\n\n static createAliases() {\n alias.addAliases({\n \"@tsed/core\": require.resolve(\"@tsed/core\"),\n \"@tsed/di\": require.resolve(\"@tsed/di\"),\n \"@tsed/schema\": require.resolve(\"@tsed/schema\"),\n \"@tsed/cli-core\": require.resolve(\"@tsed/cli-core\"),\n \"@tsed/cli\": require.resolve(\"@tsed/cli\")\n });\n }\n}\n"]}
|
|
@@ -11,6 +11,7 @@ import { RoutePipe } from "../../pipes/RoutePipe.js";
|
|
|
11
11
|
import { ProvidersInfoService } from "../../services/ProvidersInfoService.js";
|
|
12
12
|
import { PROVIDER_TYPES } from "./ProviderTypes.js";
|
|
13
13
|
import { ProjectConvention } from "../../interfaces/ProjectConvention.js";
|
|
14
|
+
import { fillImports } from "../../utils/fillImports.js";
|
|
14
15
|
const DECORATOR_TYPES = [
|
|
15
16
|
{ name: "Class decorator", value: "class" },
|
|
16
17
|
{ name: "Ts.ED middleware and its decorator", value: "middleware" },
|
|
@@ -136,7 +137,7 @@ let GenerateCmd = GenerateCmd_1 = class GenerateCmd {
|
|
|
136
137
|
}
|
|
137
138
|
const symbolName = this.classNamePipe.transform({ name, type, format: ProjectConvention.DEFAULT });
|
|
138
139
|
const symbolParamName = paramCase(symbolName);
|
|
139
|
-
return {
|
|
140
|
+
return fillImports({
|
|
140
141
|
...ctx,
|
|
141
142
|
type,
|
|
142
143
|
route: ctx.route ? this.routePipe.transform(ctx.route) : "",
|
|
@@ -148,13 +149,8 @@ let GenerateCmd = GenerateCmd_1 = class GenerateCmd {
|
|
|
148
149
|
subDir: ctx.directory
|
|
149
150
|
})),
|
|
150
151
|
symbolPathBasename: normalizePath(this.classNamePipe.transform({ name, type })),
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
platformSymbol: ctx.platform && pascalCase(`Platform ${ctx.platform}`),
|
|
154
|
-
indexControllerPath: this.projectPackageJson.preferences.convention === ProjectConvention.ANGULAR
|
|
155
|
-
? "./controllers/pages/index.controller"
|
|
156
|
-
: "./controllers/pages/IndexController"
|
|
157
|
-
};
|
|
152
|
+
platformSymbol: ctx.platform && pascalCase(`Platform ${ctx.platform}`)
|
|
153
|
+
});
|
|
158
154
|
}
|
|
159
155
|
async $exec(ctx) {
|
|
160
156
|
const { symbolPath } = ctx;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GenerateCmd.js","sourceRoot":"","sources":["../../../../src/commands/generate/GenerateCmd.ts"],"names":[],"mappings":";;AAAA,OAAO,EAAoB,OAAO,EAAmB,MAAM,EAAE,kBAAkB,EAAE,kBAAkB,EAAC,MAAM,gBAAgB,CAAC;AAC3H,OAAO,EAAC,SAAS,EAAE,UAAU,EAAC,MAAM,aAAa,CAAC;AAClD,OAAO,EAAC,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAC,MAAM,MAAM,CAAC;AAC7C,OAAO,MA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C;CACF,CAAA;AA5MC;IADC,MAAM,EAAE;8BACM,aAAa;kDAAC;AAG7B;IADC,MAAM,EAAE;8BACW,kBAAkB;uDAAC;AAGvC;IADC,MAAM,EAAE;8BACE,SAAS;8CAAC;AAGrB;IADC,MAAM,EAAE;8BACS,kBAAkB;qDAAC;AAGrC;IADC,MAAM,EAAE;8BACW,kBAAkB;uDAAC;AAd5B,WAAW;IAfvB,OAAO,CAAC;QACP,IAAI,EAAE,UAAU;QAChB,KAAK,EAAE,GAAG;QACV,WAAW,EAAE,+BAA+B;QAC5C,IAAI,EAAE;YACJ,IAAI,EAAE;gBACJ,WAAW,EAAE,6DAA6D;gBAC1E,IAAI,EAAE,MAAM;aACb;YACD,IAAI,EAAE;gBACJ,WAAW,EAAE,mBAAmB;gBAChC,IAAI,EAAE,MAAM;aACb;SACF;KACF,CAAC;qCAiBmC,oBAAoB;GAhB5C,WAAW,CA8MvB;SA9MY,WAAW","sourcesContent":["import {CliDefaultOptions, Command, CommandProvider, Inject, ProjectPackageJson, SrcRendererService} from \"@tsed/cli-core\";\nimport {paramCase, pascalCase} from \"change-case\";\nimport {basename, dirname, join} from \"path\";\nimport globby from \"globby\";\nimport normalizePath from \"normalize-path\";\nimport {ClassNamePipe} from \"../../pipes/ClassNamePipe\";\nimport {OutputFilePathPipe} from \"../../pipes/OutputFilePathPipe\";\nimport {RoutePipe} from \"../../pipes/RoutePipe\";\nimport {ProvidersInfoService} from \"../../services/ProvidersInfoService\";\nimport {PROVIDER_TYPES} from \"./ProviderTypes\";\nimport {ProjectConvention} from \"../../interfaces/ProjectConvention\";\n\nexport interface GenerateCmdContext extends CliDefaultOptions {\n type: string;\n name: string;\n route: string;\n directory: string;\n platform: string;\n templateType: string;\n symbolName: string;\n symbolPath: string;\n symbolPathBasename: string;\n convention: ProjectConvention;\n}\n\nconst DECORATOR_TYPES = [\n {name: \"Class decorator\", value: \"class\"},\n {name: \"Ts.ED middleware and its decorator\", value: \"middleware\"},\n {name: \"Ts.ED endpoint decorator\", value: \"endpoint\"},\n {name: \"Ts.ED property decorator\", value: \"prop\"},\n {name: \"Ts.ED parameter decorator\", value: \"param\"},\n {name: \"Vanilla Method decorator\", value: \"method\"},\n {name: \"Vanilla Property decorator\", value: \"property\"},\n {name: \"Vanilla Parameter decorator\", value: \"parameter\"},\n {name: \"Generic decorator\", value: \"generic\"}\n];\n\nconst searchFactory = (list: any) => {\n return async (state: any, keyword: string) => {\n if (keyword) {\n return list.filter((item: any) => item.name.toLowerCase().includes(keyword.toLowerCase()));\n }\n\n return list;\n };\n};\n\n@Command({\n name: \"generate\",\n alias: \"g\",\n description: \"Generate a new provider class\",\n args: {\n type: {\n description: \"Type of the provider (Injectable, Controller, Pipe, etc...)\",\n type: String\n },\n name: {\n description: \"Name of the class\",\n type: String\n }\n }\n})\nexport class GenerateCmd implements CommandProvider {\n @Inject()\n classNamePipe: ClassNamePipe;\n\n @Inject()\n outputFilePathPipe: OutputFilePathPipe;\n\n @Inject()\n routePipe: RoutePipe;\n\n @Inject()\n srcRenderService: SrcRendererService;\n\n @Inject()\n projectPackageJson: ProjectPackageJson;\n\n constructor(private providersList: ProvidersInfoService) {\n PROVIDER_TYPES.forEach((info) => {\n this.providersList.add(\n {\n ...info\n },\n GenerateCmd\n );\n });\n }\n\n $prompt(initialOptions: Partial<GenerateCmdContext>) {\n const getName = (state: any) =>\n initialOptions.name || pascalCase(state.name || initialOptions.name || state.type || initialOptions.type);\n\n const proposedProviders = this.providersList.findProviders(initialOptions.type);\n\n return [\n {\n type: \"autocomplete\",\n name: \"type\",\n message: \"Which type of provider?\",\n default: initialOptions.type,\n when: () => proposedProviders.length > 1,\n source: searchFactory(proposedProviders)\n },\n {\n type: \"input\",\n name: \"name\",\n message: \"Which name?\",\n default: getName,\n when: !initialOptions.name\n },\n {\n message: \"Which platform?\",\n type: \"list\",\n name: \"platform\",\n when(state: any) {\n return [\"server\"].includes(state.type || initialOptions.type);\n },\n choices: [\n {\n name: \"Express.js\",\n checked: true,\n value: \"express\"\n },\n {\n name: \"Koa.js\",\n checked: false,\n value: \"koa\"\n }\n ]\n },\n {\n type: \"input\",\n name: \"route\",\n message: \"Which route?\",\n when(state: any) {\n return [\"controller\", \"server\"].includes(state.type || initialOptions.type);\n },\n default: (state: GenerateCmdContext) => {\n return state.type === \"server\" ? \"/rest\" : this.routePipe.transform(getName(state));\n }\n },\n {\n type: \"list\",\n name: \"directory\",\n message: \"Which directory?\",\n when(state: any) {\n return [\"controller\"].includes(state.type || initialOptions.type);\n },\n choices: this.getDirectories(\"controllers\")\n },\n {\n type: \"autocomplete\",\n name: \"templateType\",\n message: (state: any) => `Which type of ${state.type || initialOptions.type}?`,\n when(state: any) {\n return [\"decorator\"].includes(state.type || initialOptions.type);\n },\n source: searchFactory(DECORATOR_TYPES)\n },\n {\n type: \"list\",\n name: \"middlewarePosition\",\n message: () => `The middleware should be called:`,\n choices: [\n {name: \"Before the endpoint\", value: \"before\"},\n {name: \"After the endpoint\", value: \"after\"}\n ],\n when(state: any) {\n return [\"decorator\"].includes(state.type || initialOptions.type) && [\"middleware\"].includes(state.templateType);\n }\n }\n ];\n }\n\n $mapContext(ctx: Partial<GenerateCmdContext>): GenerateCmdContext {\n const {name = \"\"} = ctx;\n let {type = \"\"} = ctx;\n type = type.toLowerCase();\n\n if (ctx.name === \"prisma\" && ctx.name) {\n type = \"prisma.service\";\n }\n\n const symbolName = this.classNamePipe.transform({name, type, format: ProjectConvention.DEFAULT});\n const symbolParamName = paramCase(symbolName);\n\n return {\n ...ctx,\n type,\n route: ctx.route ? this.routePipe.transform(ctx.route) : \"\",\n symbolName,\n symbolParamName,\n symbolPath: normalizePath(\n this.outputFilePathPipe.transform({\n name,\n type,\n subDir: ctx.directory\n })\n ),\n symbolPathBasename: normalizePath(this.classNamePipe.transform({name, type})),\n express: ctx.platform === \"express\",\n koa: ctx.platform === \"koa\",\n platformSymbol: ctx.platform && pascalCase(`Platform ${ctx.platform}`),\n indexControllerPath:\n this.projectPackageJson.preferences.convention === ProjectConvention.ANGULAR\n ? \"./controllers/pages/index.controller\"\n : \"./controllers/pages/IndexController\"\n } as GenerateCmdContext;\n }\n\n async $exec(ctx: GenerateCmdContext) {\n const {symbolPath} = ctx;\n\n if (this.providersList.isMyProvider(ctx.type, GenerateCmd)) {\n const type = [ctx.type, ctx.templateType].filter(Boolean).join(\".\");\n\n const template = `generate/${type}.hbs`;\n\n return [\n {\n title: `Generate ${ctx.type} file to '${symbolPath}.ts'`,\n task: () =>\n this.srcRenderService.render(template, ctx, {\n output: `${symbolPath}.ts`\n })\n },\n {\n title: `Update bin/index`,\n skip() {\n return ctx.type !== \"command\";\n },\n task: () => {\n return this.srcRenderService.update(\"bin/index.ts\", [\n {\n type: \"import\",\n content: `import {${ctx.symbolName}} from \"./${basename(symbolPath)}\";`\n },\n {\n type: \"insert-after\",\n pattern: /commands: \\[/,\n content: ` ${ctx.symbolName}`\n }\n ]);\n }\n }\n ];\n }\n\n return [];\n }\n\n getDirectories(dir: string) {\n const directories = globby.sync(\"**/*\", {\n cwd: join(this.srcRenderService.rootDir, dir),\n ignore: [\"__*\"]\n });\n\n const set = new Set(\n directories.map((dir) => {\n return dirname(dir);\n })\n );\n\n set.delete(\".\");\n\n return [...set];\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"GenerateCmd.js","sourceRoot":"","sources":["../../../../src/commands/generate/GenerateCmd.ts"],"names":[],"mappings":";;AAAA,OAAO,EAAoB,OAAO,EAAmB,MAAM,EAAE,kBAAkB,EAAE,kBAAkB,EAAC,MAAM,gBAAgB,CAAC;AAC3H,OAAO,EAAC,SAAS,EAAE,UAAU,EAAC,MAAM,aAAa,CAAC;AAClD,OAAO,EAAC,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAC,MAAM,MAAM,CAAC;AAC7C,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,aAAa,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAC,aAAa,EAAC,MAAM,2BAA2B,CAAC;A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QAChB,KAAK,EAAE,GAAG;QACV,WAAW,EAAE,+BAA+B;QAC5C,IAAI,EAAE;YACJ,IAAI,EAAE;gBACJ,WAAW,EAAE,6DAA6D;gBAC1E,IAAI,EAAE,MAAM;aACb;YACD,IAAI,EAAE;gBACJ,WAAW,EAAE,mBAAmB;gBAChC,IAAI,EAAE,MAAM;aACb;SACF;KACF,CAAC;qCAiBmC,oBAAoB;GAhB5C,WAAW,CAwMvB;SAxMY,WAAW","sourcesContent":["import {CliDefaultOptions, Command, CommandProvider, Inject, ProjectPackageJson, SrcRendererService} from \"@tsed/cli-core\";\nimport {paramCase, pascalCase} from \"change-case\";\nimport {basename, dirname, join} from \"path\";\nimport globby from \"globby\";\nimport normalizePath from \"normalize-path\";\nimport {ClassNamePipe} from \"../../pipes/ClassNamePipe\";\nimport {OutputFilePathPipe} from \"../../pipes/OutputFilePathPipe\";\nimport {RoutePipe} from \"../../pipes/RoutePipe\";\nimport {ProvidersInfoService} from \"../../services/ProvidersInfoService\";\nimport {PROVIDER_TYPES} from \"./ProviderTypes\";\nimport {ProjectConvention} from \"../../interfaces/ProjectConvention\";\nimport {fillImports} from \"../../utils/fillImports\";\n\nexport interface GenerateCmdContext extends CliDefaultOptions {\n type: string;\n name: string;\n route: string;\n directory: string;\n platform: string;\n templateType: string;\n symbolName: string;\n symbolPath: string;\n symbolPathBasename: string;\n convention: ProjectConvention;\n}\n\nconst DECORATOR_TYPES = [\n {name: \"Class decorator\", value: \"class\"},\n {name: \"Ts.ED middleware and its decorator\", value: \"middleware\"},\n {name: \"Ts.ED endpoint decorator\", value: \"endpoint\"},\n {name: \"Ts.ED property decorator\", value: \"prop\"},\n {name: \"Ts.ED parameter decorator\", value: \"param\"},\n {name: \"Vanilla Method decorator\", value: \"method\"},\n {name: \"Vanilla Property decorator\", value: \"property\"},\n {name: \"Vanilla Parameter decorator\", value: \"parameter\"},\n {name: \"Generic decorator\", value: \"generic\"}\n];\n\nconst searchFactory = (list: any) => {\n return async (state: any, keyword: string) => {\n if (keyword) {\n return list.filter((item: any) => item.name.toLowerCase().includes(keyword.toLowerCase()));\n }\n\n return list;\n };\n};\n\n@Command({\n name: \"generate\",\n alias: \"g\",\n description: \"Generate a new provider class\",\n args: {\n type: {\n description: \"Type of the provider (Injectable, Controller, Pipe, etc...)\",\n type: String\n },\n name: {\n description: \"Name of the class\",\n type: String\n }\n }\n})\nexport class GenerateCmd implements CommandProvider {\n @Inject()\n classNamePipe: ClassNamePipe;\n\n @Inject()\n outputFilePathPipe: OutputFilePathPipe;\n\n @Inject()\n routePipe: RoutePipe;\n\n @Inject()\n srcRenderService: SrcRendererService;\n\n @Inject()\n projectPackageJson: ProjectPackageJson;\n\n constructor(private providersList: ProvidersInfoService) {\n PROVIDER_TYPES.forEach((info) => {\n this.providersList.add(\n {\n ...info\n },\n GenerateCmd\n );\n });\n }\n\n $prompt(initialOptions: Partial<GenerateCmdContext>) {\n const getName = (state: any) =>\n initialOptions.name || pascalCase(state.name || initialOptions.name || state.type || initialOptions.type);\n\n const proposedProviders = this.providersList.findProviders(initialOptions.type);\n\n return [\n {\n type: \"autocomplete\",\n name: \"type\",\n message: \"Which type of provider?\",\n default: initialOptions.type,\n when: () => proposedProviders.length > 1,\n source: searchFactory(proposedProviders)\n },\n {\n type: \"input\",\n name: \"name\",\n message: \"Which name?\",\n default: getName,\n when: !initialOptions.name\n },\n {\n message: \"Which platform?\",\n type: \"list\",\n name: \"platform\",\n when(state: any) {\n return [\"server\"].includes(state.type || initialOptions.type);\n },\n choices: [\n {\n name: \"Express.js\",\n checked: true,\n value: \"express\"\n },\n {\n name: \"Koa.js\",\n checked: false,\n value: \"koa\"\n }\n ]\n },\n {\n type: \"input\",\n name: \"route\",\n message: \"Which route?\",\n when(state: any) {\n return [\"controller\", \"server\"].includes(state.type || initialOptions.type);\n },\n default: (state: GenerateCmdContext) => {\n return state.type === \"server\" ? \"/rest\" : this.routePipe.transform(getName(state));\n }\n },\n {\n type: \"list\",\n name: \"directory\",\n message: \"Which directory?\",\n when(state: any) {\n return [\"controller\"].includes(state.type || initialOptions.type);\n },\n choices: this.getDirectories(\"controllers\")\n },\n {\n type: \"autocomplete\",\n name: \"templateType\",\n message: (state: any) => `Which type of ${state.type || initialOptions.type}?`,\n when(state: any) {\n return [\"decorator\"].includes(state.type || initialOptions.type);\n },\n source: searchFactory(DECORATOR_TYPES)\n },\n {\n type: \"list\",\n name: \"middlewarePosition\",\n message: () => `The middleware should be called:`,\n choices: [\n {name: \"Before the endpoint\", value: \"before\"},\n {name: \"After the endpoint\", value: \"after\"}\n ],\n when(state: any) {\n return [\"decorator\"].includes(state.type || initialOptions.type) && [\"middleware\"].includes(state.templateType);\n }\n }\n ];\n }\n\n $mapContext(ctx: Partial<GenerateCmdContext>): GenerateCmdContext {\n const {name = \"\"} = ctx;\n let {type = \"\"} = ctx;\n type = type.toLowerCase();\n\n if (ctx.name === \"prisma\" && ctx.name) {\n type = \"prisma.service\";\n }\n\n const symbolName = this.classNamePipe.transform({name, type, format: ProjectConvention.DEFAULT});\n const symbolParamName = paramCase(symbolName);\n\n return fillImports({\n ...ctx,\n type,\n route: ctx.route ? this.routePipe.transform(ctx.route) : \"\",\n symbolName,\n symbolParamName,\n symbolPath: normalizePath(\n this.outputFilePathPipe.transform({\n name,\n type,\n subDir: ctx.directory\n })\n ),\n symbolPathBasename: normalizePath(this.classNamePipe.transform({name, type})),\n platformSymbol: ctx.platform && pascalCase(`Platform ${ctx.platform}`)\n }) as GenerateCmdContext;\n }\n\n async $exec(ctx: GenerateCmdContext) {\n const {symbolPath} = ctx;\n\n if (this.providersList.isMyProvider(ctx.type, GenerateCmd)) {\n const type = [ctx.type, ctx.templateType].filter(Boolean).join(\".\");\n\n const template = `generate/${type}.hbs`;\n\n return [\n {\n title: `Generate ${ctx.type} file to '${symbolPath}.ts'`,\n task: () =>\n this.srcRenderService.render(template, ctx, {\n output: `${symbolPath}.ts`\n })\n },\n {\n title: `Update bin/index`,\n skip() {\n return ctx.type !== \"command\";\n },\n task: () => {\n return this.srcRenderService.update(\"bin/index.ts\", [\n {\n type: \"import\",\n content: `import {${ctx.symbolName}} from \"./${basename(symbolPath)}\";`\n },\n {\n type: \"insert-after\",\n pattern: /commands: \\[/,\n content: ` ${ctx.symbolName}`\n }\n ]);\n }\n }\n ];\n }\n\n return [];\n }\n\n getDirectories(dir: string) {\n const directories = globby.sync(\"**/*\", {\n cwd: join(this.srcRenderService.rootDir, dir),\n ignore: [\"__*\"]\n });\n\n const set = new Set(\n directories.map((dir) => {\n return dirname(dir);\n })\n );\n\n set.delete(\".\");\n\n return [...set];\n }\n}\n"]}
|
|
@@ -1,32 +1,43 @@
|
|
|
1
|
+
var InitCmd_1;
|
|
1
2
|
import { __decorate, __metadata } from "tslib";
|
|
2
|
-
import { CliExeca, CliFs, CliPlugins, CliService, Command, Configuration, createSubTasks, createTasksRunner, Inject, PackageManager, ProjectPackageJson, RootRendererService } from "@tsed/cli-core";
|
|
3
|
-
import {
|
|
4
|
-
import { basename, join
|
|
3
|
+
import { CliExeca, CliFs, CliLoadFile, CliPackageJson, CliPlugins, CliService, Command, Configuration, createSubTasks, createTasksRunner, Inject, PackageManager, ProjectPackageJson, RootRendererService } from "@tsed/cli-core";
|
|
4
|
+
import { paramCase, pascalCase } from "change-case";
|
|
5
|
+
import { basename, join } from "path";
|
|
5
6
|
import { DEFAULT_TSED_TAGS } from "../../constants.js";
|
|
7
|
+
import { ArchitectureConvention } from "../../interfaces/ArchitectureConvention.js";
|
|
8
|
+
import { ProjectConvention } from "../../interfaces/ProjectConvention.js";
|
|
6
9
|
import { OutputFilePathPipe } from "../../pipes/OutputFilePathPipe.js";
|
|
7
|
-
import {
|
|
8
|
-
|
|
10
|
+
import { InitFileSchema } from "./config/InitFileSchema.js";
|
|
11
|
+
import { mapToContext } from "./mappers/mapToContext.js";
|
|
12
|
+
import { FeaturesMap, FeatureType } from "./config/FeaturesPrompt.js";
|
|
13
|
+
import { getFeaturesPrompt } from "./prompts/getFeaturesPrompt.js";
|
|
14
|
+
import { PlatformType } from "../../interfaces.js";
|
|
15
|
+
import { fillImports } from "../../utils/fillImports.js";
|
|
16
|
+
let InitCmd = InitCmd_1 = class InitCmd {
|
|
9
17
|
configuration;
|
|
10
18
|
cliPlugins;
|
|
11
19
|
packageJson;
|
|
12
|
-
|
|
20
|
+
cliPackageJson;
|
|
13
21
|
cliService;
|
|
22
|
+
cliLoadFile;
|
|
14
23
|
rootRenderer;
|
|
15
24
|
outputFilePathPipe;
|
|
16
25
|
execa;
|
|
17
26
|
fs;
|
|
18
27
|
async $beforePrompt(initialOptions) {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
28
|
+
if (initialOptions.file) {
|
|
29
|
+
const file = join(this.packageJson.dir, initialOptions.file);
|
|
30
|
+
return {
|
|
31
|
+
...initialOptions,
|
|
32
|
+
...(await this.cliLoadFile.loadFile(file, InitFileSchema))
|
|
33
|
+
};
|
|
25
34
|
}
|
|
26
35
|
return initialOptions;
|
|
27
36
|
}
|
|
28
37
|
$prompt(initialOptions) {
|
|
29
|
-
|
|
38
|
+
if (initialOptions.skipPrompt) {
|
|
39
|
+
return [];
|
|
40
|
+
}
|
|
30
41
|
return [
|
|
31
42
|
{
|
|
32
43
|
type: "input",
|
|
@@ -38,34 +49,18 @@ let InitCmd = class InitCmd {
|
|
|
38
49
|
return paramCase(input);
|
|
39
50
|
}
|
|
40
51
|
},
|
|
41
|
-
...
|
|
52
|
+
...getFeaturesPrompt(initialOptions)
|
|
42
53
|
];
|
|
43
54
|
}
|
|
44
55
|
$mapContext(ctx) {
|
|
45
56
|
this.resolveRootDir(ctx);
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
.filter(([key]) => key.startsWith("features") && key !== "featuresFile")
|
|
49
|
-
.forEach(([key, value]) => {
|
|
50
|
-
delete ctx[key];
|
|
51
|
-
features.push(...[].concat(value));
|
|
52
|
-
});
|
|
53
|
-
features.forEach((feature) => {
|
|
54
|
-
feature.type.split(":").forEach((type) => {
|
|
55
|
-
ctx[camelCase(type)] = true;
|
|
56
|
-
});
|
|
57
|
-
});
|
|
58
|
-
return {
|
|
57
|
+
ctx = mapToContext(ctx);
|
|
58
|
+
return fillImports({
|
|
59
59
|
...ctx,
|
|
60
|
-
|
|
60
|
+
cliVersion: ctx.cliVersion || this.cliPackageJson.version,
|
|
61
61
|
srcDir: this.configuration.project?.srcDir,
|
|
62
|
-
pnpm: ctx.packageManager === PackageManager.PNPM,
|
|
63
|
-
npm: ctx.packageManager === PackageManager.NPM,
|
|
64
|
-
yarn: ctx.packageManager === PackageManager.YARN,
|
|
65
|
-
express: ctx.platform === "express",
|
|
66
|
-
koa: ctx.platform === "koa",
|
|
67
62
|
platformSymbol: ctx.platform && pascalCase(`Platform ${ctx.platform}`)
|
|
68
|
-
};
|
|
63
|
+
});
|
|
69
64
|
}
|
|
70
65
|
async $beforeExec(ctx) {
|
|
71
66
|
this.fs.ensureDirSync(this.packageJson.dir);
|
|
@@ -101,6 +96,7 @@ let InitCmd = class InitCmd {
|
|
|
101
96
|
], ctx);
|
|
102
97
|
}
|
|
103
98
|
async $exec(ctx) {
|
|
99
|
+
InitCmd_1.checkPrecondition(ctx);
|
|
104
100
|
const subTasks = [
|
|
105
101
|
...(await this.cliService.getTasks("generate", {
|
|
106
102
|
...ctx,
|
|
@@ -153,7 +149,8 @@ let InitCmd = class InitCmd {
|
|
|
153
149
|
ctx.swagger && "/init/views/swagger.ejs.hbs",
|
|
154
150
|
ctx.swagger && {
|
|
155
151
|
path: "/init/src/controllers/pages/IndexController.ts.hbs",
|
|
156
|
-
basename: indexCtrlBaseName
|
|
152
|
+
basename: indexCtrlBaseName,
|
|
153
|
+
output: ctx.architecture === "default" ? "/controllers/pages/IndexController.ts" : "/pages/IndexController.ts"
|
|
157
154
|
}
|
|
158
155
|
].filter(Boolean), ctx, {
|
|
159
156
|
baseDir: "/init"
|
|
@@ -253,7 +250,8 @@ let InitCmd = class InitCmd {
|
|
|
253
250
|
}
|
|
254
251
|
}
|
|
255
252
|
addFeatures(ctx) {
|
|
256
|
-
ctx.features.forEach((
|
|
253
|
+
ctx.features.forEach((value) => {
|
|
254
|
+
const feature = FeaturesMap[value.toLowerCase()];
|
|
257
255
|
if (feature.dependencies) {
|
|
258
256
|
this.packageJson.addDependencies(feature.dependencies, ctx);
|
|
259
257
|
}
|
|
@@ -269,7 +267,7 @@ let InitCmd = class InitCmd {
|
|
|
269
267
|
this.addKoaDependencies(ctx);
|
|
270
268
|
break;
|
|
271
269
|
}
|
|
272
|
-
if (ctx.features.find((
|
|
270
|
+
if (ctx.features.find((value) => value === FeatureType.GRAPHQL)) {
|
|
273
271
|
this.packageJson.addDependencies({
|
|
274
272
|
["apollo-server-" + ctx.platform]: "2.25.2"
|
|
275
273
|
}, ctx);
|
|
@@ -315,6 +313,29 @@ let InitCmd = class InitCmd {
|
|
|
315
313
|
"@types/koa__cors": "latest"
|
|
316
314
|
}, ctx);
|
|
317
315
|
}
|
|
316
|
+
static checkPrecondition(ctx) {
|
|
317
|
+
const isValid = (types, value) => (value ? Object.values(types).includes(value) : true);
|
|
318
|
+
if (!isValid(PlatformType, ctx.platform)) {
|
|
319
|
+
throw new Error(`Invalid selected platform: ${ctx.platform}. Possible values: ${Object.values(PlatformType).join(", ")}.`);
|
|
320
|
+
}
|
|
321
|
+
if (!isValid(ArchitectureConvention, ctx.architecture)) {
|
|
322
|
+
throw new Error(`Invalid selected architecture: ${ctx.architecture}. Possible values: ${Object.values(ArchitectureConvention).join(", ")}.`);
|
|
323
|
+
}
|
|
324
|
+
if (!isValid(ProjectConvention, ctx.convention)) {
|
|
325
|
+
throw new Error(`Invalid selected convention: ${ctx.convention}. Possible values: ${Object.values(ProjectConvention).join(", ")}.`);
|
|
326
|
+
}
|
|
327
|
+
if (!isValid(PackageManager, ctx.packageManager)) {
|
|
328
|
+
throw new Error(`Invalid selected convention: ${ctx.packageManager}. Possible values: ${Object.values(PackageManager).join(", ")}.`);
|
|
329
|
+
}
|
|
330
|
+
if (ctx.features) {
|
|
331
|
+
ctx.features.forEach((value) => {
|
|
332
|
+
const feature = FeaturesMap[value.toLowerCase()];
|
|
333
|
+
if (!feature) {
|
|
334
|
+
throw new Error(`Invalid selected feature: ${value}. Possible values: ${Object.values(FeatureType).join(", ")}.`);
|
|
335
|
+
}
|
|
336
|
+
});
|
|
337
|
+
}
|
|
338
|
+
}
|
|
318
339
|
};
|
|
319
340
|
__decorate([
|
|
320
341
|
Configuration(),
|
|
@@ -329,13 +350,17 @@ __decorate([
|
|
|
329
350
|
__metadata("design:type", ProjectPackageJson)
|
|
330
351
|
], InitCmd.prototype, "packageJson", void 0);
|
|
331
352
|
__decorate([
|
|
332
|
-
|
|
333
|
-
__metadata("design:type",
|
|
334
|
-
], InitCmd.prototype, "
|
|
353
|
+
CliPackageJson(),
|
|
354
|
+
__metadata("design:type", Object)
|
|
355
|
+
], InitCmd.prototype, "cliPackageJson", void 0);
|
|
335
356
|
__decorate([
|
|
336
357
|
Inject(),
|
|
337
358
|
__metadata("design:type", CliService)
|
|
338
359
|
], InitCmd.prototype, "cliService", void 0);
|
|
360
|
+
__decorate([
|
|
361
|
+
Inject(),
|
|
362
|
+
__metadata("design:type", CliLoadFile)
|
|
363
|
+
], InitCmd.prototype, "cliLoadFile", void 0);
|
|
339
364
|
__decorate([
|
|
340
365
|
Inject(),
|
|
341
366
|
__metadata("design:type", RootRendererService)
|
|
@@ -352,7 +377,7 @@ __decorate([
|
|
|
352
377
|
Inject(),
|
|
353
378
|
__metadata("design:type", CliFs)
|
|
354
379
|
], InitCmd.prototype, "fs", void 0);
|
|
355
|
-
InitCmd = __decorate([
|
|
380
|
+
InitCmd = InitCmd_1 = __decorate([
|
|
356
381
|
Command({
|
|
357
382
|
name: "init",
|
|
358
383
|
description: "Init a new Ts.ED project",
|
|
@@ -364,14 +389,51 @@ InitCmd = __decorate([
|
|
|
364
389
|
}
|
|
365
390
|
},
|
|
366
391
|
options: {
|
|
392
|
+
"-n, --project-name <projectName>": {
|
|
393
|
+
type: String,
|
|
394
|
+
defaultValue: "",
|
|
395
|
+
description: "Set the project name. By default, the project is the same as the name directory."
|
|
396
|
+
},
|
|
397
|
+
"-a, --arch <architecture>": {
|
|
398
|
+
type: String,
|
|
399
|
+
defaultValue: ArchitectureConvention.DEFAULT,
|
|
400
|
+
description: `Set the default architecture convention (${ArchitectureConvention.DEFAULT} or ${ArchitectureConvention.FEATURE})`
|
|
401
|
+
},
|
|
402
|
+
"-c, --convention <convention>": {
|
|
403
|
+
type: String,
|
|
404
|
+
defaultValue: ProjectConvention.DEFAULT,
|
|
405
|
+
description: `Set the default project convention (${ArchitectureConvention.DEFAULT} or ${ArchitectureConvention.FEATURE})`
|
|
406
|
+
},
|
|
407
|
+
"-p, --platform <platform>": {
|
|
408
|
+
type: String,
|
|
409
|
+
defaultValue: PlatformType.EXPRESS,
|
|
410
|
+
description: "Set the default platform for Ts.ED (express or koa)"
|
|
411
|
+
},
|
|
412
|
+
"--features <features...>": {
|
|
413
|
+
type: Array,
|
|
414
|
+
itemType: String,
|
|
415
|
+
defaultValue: [],
|
|
416
|
+
description: "List of the Ts.ED features."
|
|
417
|
+
},
|
|
418
|
+
"-m, --package-manager <packageManager>": {
|
|
419
|
+
type: Array,
|
|
420
|
+
itemType: String,
|
|
421
|
+
defaultValue: PackageManager.YARN,
|
|
422
|
+
description: "The default package manager to install the project"
|
|
423
|
+
},
|
|
367
424
|
"-t, --tsed-version <version>": {
|
|
368
425
|
type: String,
|
|
369
426
|
defaultValue: DEFAULT_TSED_TAGS,
|
|
370
|
-
description: "Use a specific version of Ts.ED (format: 5.x.x)"
|
|
427
|
+
description: "Use a specific version of Ts.ED (format: 5.x.x)."
|
|
371
428
|
},
|
|
372
|
-
"-f, --
|
|
429
|
+
"-f, --file <path>": {
|
|
373
430
|
type: String,
|
|
374
431
|
description: "Location of a file in which the features are defined."
|
|
432
|
+
},
|
|
433
|
+
"-s, --skip-prompt": {
|
|
434
|
+
type: Boolean,
|
|
435
|
+
defaultValue: false,
|
|
436
|
+
description: "Skip the prompt."
|
|
375
437
|
}
|
|
376
438
|
}
|
|
377
439
|
})
|