@tsed/cli-plugin-mongoose 3.21.0-rc.4 → 3.21.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/CliPluginMongooseModule.js +1 -0
- package/lib/cjs/CliPluginMongooseModule.js.map +1 -1
- package/lib/cjs/hooks/MongooseGenerateHook.js +6 -0
- package/lib/cjs/hooks/MongooseGenerateHook.js.map +1 -1
- package/lib/cjs/hooks/MongooseInitHook.js +5 -0
- package/lib/cjs/hooks/MongooseInitHook.js.map +1 -1
- package/lib/cjs/services/CliMongoose.js +2 -0
- package/lib/cjs/services/CliMongoose.js.map +1 -1
- package/lib/cjs/utils/templateDir.js +3 -9
- package/lib/cjs/utils/templateDir.js.map +1 -1
- package/lib/esm/CliPluginMongooseModule.js +1 -0
- package/lib/esm/CliPluginMongooseModule.js.map +1 -1
- package/lib/esm/hooks/MongooseGenerateHook.js +6 -0
- package/lib/esm/hooks/MongooseGenerateHook.js.map +1 -1
- package/lib/esm/hooks/MongooseInitHook.js +5 -0
- package/lib/esm/hooks/MongooseInitHook.js.map +1 -1
- package/lib/esm/services/CliMongoose.js +2 -0
- package/lib/esm/services/CliMongoose.js.map +1 -1
- package/lib/esm/utils/templateDir.js +2 -7
- package/lib/esm/utils/templateDir.js.map +1 -1
- package/package.json +4 -7
|
@@ -8,6 +8,7 @@ const MongooseGenerateHook_1 = require("./hooks/MongooseGenerateHook");
|
|
|
8
8
|
const MongooseInitHook_1 = require("./hooks/MongooseInitHook");
|
|
9
9
|
const CliMongoose_1 = require("./services/CliMongoose");
|
|
10
10
|
let CliPluginMongooseModule = class CliPluginMongooseModule {
|
|
11
|
+
packageJson;
|
|
11
12
|
install() {
|
|
12
13
|
this.packageJson.addDependencies({
|
|
13
14
|
"@tsed/mongoose": this.packageJson.dependencies["@tsed/common"],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CliPluginMongooseModule.js","sourceRoot":"","sources":["../../src/CliPluginMongooseModule.ts"],"names":[],"mappings":";;;;AAAA,6CAAiE;AACjE,iCAAgC;AAChC,uEAAkE;AAClE,+DAA0D;AAC1D,wDAAmD;AAKnD,IAAa,uBAAuB,GAApC,MAAa,uBAAuB;
|
|
1
|
+
{"version":3,"file":"CliPluginMongooseModule.js","sourceRoot":"","sources":["../../src/CliPluginMongooseModule.ts"],"names":[],"mappings":";;;;AAAA,6CAAiE;AACjE,iCAAgC;AAChC,uEAAkE;AAClE,+DAA0D;AAC1D,wDAAmD;AAKnD,IAAa,uBAAuB,GAApC,MAAa,uBAAuB;IAElC,WAAW,CAAqB;IAGhC,OAAO;QACL,IAAI,CAAC,WAAW,CAAC,eAAe,CAAC;YAC/B,gBAAgB,EAAE,IAAI,CAAC,WAAW,CAAC,YAAY,CAAC,cAAc,CAAC;YAC/D,QAAQ,EAAE,QAAQ;SACnB,CAAC,CAAC;QAEH,IAAI,CAAC,WAAW,CAAC,kBAAkB,CAAC;YAClC,wBAAwB,EAAE,IAAI,CAAC,WAAW,CAAC,YAAY,CAAC,cAAc,CAAC;SACxE,CAAC,CAAC;IACL,CAAC;CACF,CAAA;AAbC;IADC,IAAA,WAAM,GAAE;sCACI,6BAAkB;4DAAC;AAGhC;IADC,IAAA,gBAAK,EAAC,2BAA2B,CAAC;;;;sDAUlC;AAdU,uBAAuB;IAHnC,IAAA,iBAAM,EAAC;QACN,OAAO,EAAE,CAAC,mCAAgB,EAAE,2CAAoB,EAAE,yBAAW,CAAC;KAC/D,CAAC;GACW,uBAAuB,CAenC;AAfY,0DAAuB","sourcesContent":["import {Module, OnAdd, ProjectPackageJson} from \"@tsed/cli-core\";\nimport {Inject} from \"@tsed/di\";\nimport {MongooseGenerateHook} from \"./hooks/MongooseGenerateHook\";\nimport {MongooseInitHook} from \"./hooks/MongooseInitHook\";\nimport {CliMongoose} from \"./services/CliMongoose\";\n\n@Module({\n imports: [MongooseInitHook, MongooseGenerateHook, CliMongoose]\n})\nexport class CliPluginMongooseModule {\n @Inject()\n packageJson: ProjectPackageJson;\n\n @OnAdd(\"@tsed/cli-plugin-mongoose\")\n install() {\n this.packageJson.addDependencies({\n \"@tsed/mongoose\": this.packageJson.dependencies[\"@tsed/common\"],\n mongoose: \"latest\"\n });\n\n this.packageJson.addDevDependencies({\n \"@tsed/testing-mongoose\": this.packageJson.dependencies[\"@tsed/common\"]\n });\n }\n}\n"]}
|
|
@@ -13,6 +13,12 @@ const change_case_1 = require("change-case");
|
|
|
13
13
|
const CliMongoose_1 = require("../services/CliMongoose");
|
|
14
14
|
const templateDir_1 = require("../utils/templateDir");
|
|
15
15
|
let MongooseGenerateHook = MongooseGenerateHook_1 = class MongooseGenerateHook {
|
|
16
|
+
providersInfoService;
|
|
17
|
+
projectPackageJson;
|
|
18
|
+
srcRenderService;
|
|
19
|
+
cliMongoose;
|
|
20
|
+
packages;
|
|
21
|
+
cliDockerComposeYaml;
|
|
16
22
|
constructor(providersInfoService) {
|
|
17
23
|
this.providersInfoService = providersInfoService;
|
|
18
24
|
providersInfoService
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MongooseGenerateHook.js","sourceRoot":"","sources":["../../../src/hooks/MongooseGenerateHook.ts"],"names":[],"mappings":";;;;;AAAA,mCAAmE;AACnE,6CAAmH;AACnH,iCAAoC;AACpC,6DAA6D;AAC7D,aAAa;AACb,yCAAiC;AACjC,6CAAiD;AACjD,yDAAoD;AACpD,sDAAkD;AAGlD,IAAa,oBAAoB,4BAAjC,MAAa,oBAAoB;
|
|
1
|
+
{"version":3,"file":"MongooseGenerateHook.js","sourceRoot":"","sources":["../../../src/hooks/MongooseGenerateHook.ts"],"names":[],"mappings":";;;;;AAAA,mCAAmE;AACnE,6CAAmH;AACnH,iCAAoC;AACpC,6DAA6D;AAC7D,aAAa;AACb,yCAAiC;AACjC,6CAAiD;AACjD,yDAAoD;AACpD,sDAAkD;AAGlD,IAAa,oBAAoB,4BAAjC,MAAa,oBAAoB;IAcX;IAZpB,kBAAkB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nimport {CliDockerComposeYaml, Inject, OnExec, ProjectPackageJson, SrcRendererService, Tasks} from \"@tsed/cli-core\";\nimport {Injectable} from \"@tsed/di\";\n// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-ignore\nimport {plural} from \"pluralize\";\nimport {camelCase, paramCase} from \"change-case\";\nimport {CliMongoose} from \"../services/CliMongoose\";\nimport {TEMPLATE_DIR} from \"../utils/templateDir\";\n\n@Injectable()\nexport class MongooseGenerateHook {\n @Inject()\n projectPackageJson: ProjectPackageJson;\n\n @Inject()\n srcRenderService: SrcRendererService;\n\n @Inject()\n cliMongoose: CliMongoose;\n\n packages: any[];\n @Inject()\n protected cliDockerComposeYaml: CliDockerComposeYaml;\n\n constructor(private providersInfoService: ProvidersInfoService) {\n providersInfoService\n .add(\n {\n name: \"Mongoose model\",\n value: \"mongoose:model\",\n model: \"{{symbolName}}.model\",\n baseDir: \"models\"\n },\n MongooseGenerateHook\n )\n .add(\n {\n name: \"Mongoose schema\",\n value: \"mongoose:schema\",\n model: \"{{symbolName}}.schema\",\n baseDir: \"models\"\n },\n MongooseGenerateHook\n )\n .add(\n {\n name: \"Mongoose connection\",\n value: \"mongoose:connection\"\n },\n MongooseGenerateHook\n );\n }\n\n @OnExec(\"generate\")\n onGenerateExec(ctx: GenerateCmdContext): Tasks {\n if (this.providersInfoService.isMyProvider(ctx.type, MongooseGenerateHook)) {\n switch (ctx.type) {\n case \"mongoose:connection\":\n return this.generateConnection(ctx);\n case \"mongoose:model\":\n case \"mongoose:schema\":\n return this.generateTemplate(ctx);\n }\n }\n\n return [];\n }\n\n private generateTemplate(ctx: GenerateCmdContext) {\n const {symbolPath, type, symbolName} = ctx;\n const template = `mongoose.${type.split(\":\")[1]}.hbs`;\n const newCtx = {\n ...ctx,\n collectionName: plural(camelCase(symbolName.replace(/Schema|Model/gi, \"\")))\n };\n\n return [\n {\n title: `Generate ${ctx.type} file to '${symbolPath}.ts'`,\n task: () =>\n this.srcRenderService.render(template, newCtx, {\n output: `${symbolPath}.ts`,\n templateDir: TEMPLATE_DIR\n })\n }\n ];\n }\n\n private generateConnection(ctx: GenerateCmdContext) {\n return [\n {\n title: `Generate Mongoose configuration file to '${paramCase(ctx.name)}.config.ts'`,\n task: () => this.cliMongoose.writeConfig(ctx.name, ctx)\n },\n {\n title: \"Generate docker-compose configuration\",\n task: async () => this.cliDockerComposeYaml.addDatabaseService(ctx.name, \"mongodb\")\n }\n ];\n }\n}\n"]}
|
|
@@ -6,6 +6,11 @@ const cli_core_1 = require("@tsed/cli-core");
|
|
|
6
6
|
const di_1 = require("@tsed/di");
|
|
7
7
|
const CliMongoose_1 = require("../services/CliMongoose");
|
|
8
8
|
let MongooseInitHook = class MongooseInitHook {
|
|
9
|
+
cliMongoose;
|
|
10
|
+
packageJson;
|
|
11
|
+
rootRenderer;
|
|
12
|
+
srcRenderer;
|
|
13
|
+
cliDockerComposeYaml;
|
|
9
14
|
onExec(ctx) {
|
|
10
15
|
this.addScripts();
|
|
11
16
|
this.addDependencies(ctx);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MongooseInitHook.js","sourceRoot":"","sources":["../../../src/hooks/MongooseInitHook.ts"],"names":[],"mappings":";;;;AACA,6CAAiI;AACjI,iCAAoC;AACpC,yDAAoD;AAGpD,IAAa,gBAAgB,GAA7B,MAAa,gBAAgB;
|
|
1
|
+
{"version":3,"file":"MongooseInitHook.js","sourceRoot":"","sources":["../../../src/hooks/MongooseInitHook.ts"],"names":[],"mappings":";;;;AACA,6CAAiI;AACjI,iCAAoC;AACpC,yDAAoD;AAGpD,IAAa,gBAAgB,GAA7B,MAAa,gBAAgB;IAE3B,WAAW,CAAc;IAGf,WAAW,CAAqB;IAGhC,YAAY,CAAsB;IAGlC,WAAW,CAAqB;IAGhC,oBAAoB,CAAuB;IAGrD,MAAM,CAAC,GAAmB;QACxB,IAAI,CAAC,UAAU,EAAE,CAAC;QAClB,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC;QAC1B,IAAI,CAAC,kBAAkB,CAAC,GAAG,CAAC,CAAC;QAE7B,OAAO;YACL;gBACE,KAAK,EAAE,iCAAiC;gBACxC,IAAI,EAAE,KAAK,IAAI,EAAE,CACf,IAAI,CAAC,WAAW,CAAC,WAAW,CAAC,SAAS,EAAE;oBACtC,UAAU,EAAE,kBAAkB;iBAC/B,CAAC;aACL;YACD;gBACE,KAAK,EAAE,uCAAuC;gBAC9C,IAAI,EAAE,KAAK,IAAI,EAAE,CAAC,IAAI,CAAC,oBAAoB,CAAC,kBAAkB,CAAC,SAAS,EAAE,SAAS,CAAC;aACrF;SACF,CAAC;IACJ,CAAC;IAED,UAAU;QACR,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC;IAClC,CAAC;IAED,eAAe,CAAC,GAAmB;QACjC,IAAI,CAAC,WAAW,CAAC,eAAe,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC;IAC5C,CAAC;IAED,kBAAkB,CAAC,GAAmB;QACpC,IAAI,CAAC,WAAW,CAAC,kBAAkB,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC;IAC/C,CAAC;CACF,CAAA;AA9CC;IADC,IAAA,iBAAM,GAAE;sCACI,yBAAW;qDAAC;AAGzB;IADC,IAAA,iBAAM,GAAE;sCACc,6BAAkB;qDAAC;AAG1C;IADC,IAAA,iBAAM,GAAE;sCACe,8BAAmB;sDAAC;AAG5C;IADC,IAAA,iBAAM,GAAE;sCACc,6BAAkB;qDAAC;AAG1C;IADC,IAAA,iBAAM,GAAE;sCACuB,+BAAoB;8DAAC;AAGrD;IADC,IAAA,iBAAM,EAAC,MAAM,CAAC;;;;8CAmBd;AAnCU,gBAAgB;IAD5B,IAAA,eAAU,GAAE;GACA,gBAAgB,CAgD5B;AAhDY,4CAAgB","sourcesContent":["import {InitCmdContext} from \"@tsed/cli\";\nimport {CliDockerComposeYaml, Inject, OnExec, ProjectPackageJson, RootRendererService, SrcRendererService} from \"@tsed/cli-core\";\nimport {Injectable} from \"@tsed/di\";\nimport {CliMongoose} from \"../services/CliMongoose\";\n\n@Injectable()\nexport class MongooseInitHook {\n @Inject()\n cliMongoose: CliMongoose;\n\n @Inject()\n protected packageJson: ProjectPackageJson;\n\n @Inject()\n protected rootRenderer: RootRendererService;\n\n @Inject()\n protected srcRenderer: SrcRendererService;\n\n @Inject()\n protected cliDockerComposeYaml: CliDockerComposeYaml;\n\n @OnExec(\"init\")\n onExec(ctx: InitCmdContext) {\n this.addScripts();\n this.addDependencies(ctx);\n this.addDevDependencies(ctx);\n\n return [\n {\n title: \"Generate Mongoose configuration\",\n task: async () =>\n this.cliMongoose.writeConfig(\"default\", {\n symbolName: \"MONGOOSE_DEFAULT\"\n })\n },\n {\n title: \"Generate docker-compose configuration\",\n task: async () => this.cliDockerComposeYaml.addDatabaseService(\"mongodb\", \"mongodb\")\n }\n ];\n }\n\n addScripts() {\n this.packageJson.addScripts({});\n }\n\n addDependencies(ctx: InitCmdContext) {\n this.packageJson.addDependencies({}, ctx);\n }\n\n addDevDependencies(ctx: InitCmdContext) {\n this.packageJson.addDevDependencies({}, ctx);\n }\n}\n"]}
|
|
@@ -7,6 +7,8 @@ const change_case_1 = require("change-case");
|
|
|
7
7
|
const path_1 = require("path");
|
|
8
8
|
const templateDir_1 = require("../utils/templateDir");
|
|
9
9
|
let CliMongoose = class CliMongoose {
|
|
10
|
+
projectPackageJson;
|
|
11
|
+
srcRenderer;
|
|
10
12
|
async writeConfig(name, options = {}) {
|
|
11
13
|
await this.srcRenderer.render("config.hbs", {
|
|
12
14
|
...options,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CliMongoose.js","sourceRoot":"","sources":["../../../src/services/CliMongoose.ts"],"names":[],"mappings":";;;;AAAA,6CAA0F;AAC1F,6CAA+D;AAC/D,+BAAoC;AACpC,sDAAkD;AAGlD,IAAa,WAAW,GAAxB,MAAa,WAAW;
|
|
1
|
+
{"version":3,"file":"CliMongoose.js","sourceRoot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AAU;YAClB,OAAO,EAAE,IAAA,WAAI,EAAC,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE,QAAQ,EAAE,UAAU,CAAC;SAC9D,CACF,CAAC;IACJ,CAAC;CACF,CAAA;AA/CC;IADC,IAAA,iBAAM,GAAE;sCACW,6BAAkB;uDAAC;AAGvC;IADC,IAAA,iBAAM,GAAE;sCACc,6BAAkB;gDAAC;AAL/B,WAAW;IADvB,IAAA,qBAAU,GAAE;GACA,WAAW,CAiDvB;AAjDY,kCAAW","sourcesContent":["import {Inject, Injectable, ProjectPackageJson, SrcRendererService} from \"@tsed/cli-core\";\nimport {camelCase, constantCase, paramCase} from \"change-case\";\nimport {basename, join} from \"path\";\nimport {TEMPLATE_DIR} from \"../utils/templateDir\";\n\n@Injectable()\nexport class CliMongoose {\n @Inject()\n projectPackageJson: ProjectPackageJson;\n\n @Inject()\n protected srcRenderer: SrcRendererService;\n\n async writeConfig(name: string, options: any = {}) {\n await this.srcRenderer.render(\n \"config.hbs\",\n {\n ...options,\n symbolName: constantCase(name),\n name: paramCase(name)\n },\n {\n output: `${paramCase(name)}.config.ts`,\n rootDir: join(this.srcRenderer.rootDir, \"config\", \"mongoose\"),\n templateDir: TEMPLATE_DIR\n }\n );\n\n return this.regenerateIndexConfig();\n }\n\n async regenerateIndexConfig() {\n const list = await this.srcRenderer.scan([\"config/mongoose/*.config.ts\"]);\n\n const configs = list.map((file) => {\n const name = basename(file).replace(/\\.config\\.ts/gi, \"\");\n\n return {\n name,\n symbolName: camelCase(name)\n };\n });\n\n return this.srcRenderer.render(\n \"index.hbs\",\n {\n configs\n },\n {\n templateDir: TEMPLATE_DIR,\n output: \"index.ts\",\n rootDir: join(this.srcRenderer.rootDir, \"config\", \"mongoose\")\n }\n );\n }\n}\n"]}
|
|
@@ -1,13 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.TEMPLATE_DIR = void 0;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
const filedirname_1 = tslib_1.__importDefault(require("filedirname"));
|
|
8
|
-
const [, dir] = (0, filedirname_1.default)();
|
|
9
|
-
const { path } = read_pkg_up_1.default.sync({
|
|
10
|
-
cwd: (0, path_1.join)(dir, "..", "..")
|
|
11
|
-
});
|
|
12
|
-
exports.TEMPLATE_DIR = (0, path_1.join)((0, path_1.dirname)(path), "templates");
|
|
4
|
+
const cli_core_1 = require("@tsed/cli-core");
|
|
5
|
+
const [, dir] = (0, cli_core_1.filedirname)();
|
|
6
|
+
exports.TEMPLATE_DIR = (0, cli_core_1.getTemplateDirectory)(dir);
|
|
13
7
|
//# sourceMappingURL=templateDir.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"templateDir.js","sourceRoot":"","sources":["../../../src/utils/templateDir.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"templateDir.js","sourceRoot":"","sources":["../../../src/utils/templateDir.ts"],"names":[],"mappings":";;;AAAA,6CAAiE;AAEjE,MAAM,CAAC,EAAE,GAAG,CAAC,GAAG,IAAA,sBAAW,GAAE,CAAC;AAEjB,QAAA,YAAY,GAAG,IAAA,+BAAoB,EAAC,GAAG,CAAC,CAAC","sourcesContent":["import {getTemplateDirectory, filedirname} from \"@tsed/cli-core\";\n\nconst [, dir] = filedirname();\n\nexport const TEMPLATE_DIR = getTemplateDirectory(dir);\n"]}
|
|
@@ -5,6 +5,7 @@ import { MongooseGenerateHook } from "./hooks/MongooseGenerateHook.js";
|
|
|
5
5
|
import { MongooseInitHook } from "./hooks/MongooseInitHook.js";
|
|
6
6
|
import { CliMongoose } from "./services/CliMongoose.js";
|
|
7
7
|
let CliPluginMongooseModule = class CliPluginMongooseModule {
|
|
8
|
+
packageJson;
|
|
8
9
|
install() {
|
|
9
10
|
this.packageJson.addDependencies({
|
|
10
11
|
"@tsed/mongoose": this.packageJson.dependencies["@tsed/common"],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CliPluginMongooseModule.js","sourceRoot":"","sources":["../../src/CliPluginMongooseModule.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,MAAM,EAAE,KAAK,EAAE,kBAAkB,EAAC,MAAM,gBAAgB,CAAC;AACjE,OAAO,EAAC,MAAM,EAAC,MAAM,UAAU,CAAC;AAChC,OAAO,EAAC,oBAAoB,EAAC,MAAM,8BAA8B,CAAC;AAClE,OAAO,EAAC,gBAAgB,EAAC,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAC,WAAW,EAAC,MAAM,wBAAwB,CAAC;AAKnD,IAAa,uBAAuB,GAApC,MAAa,uBAAuB;
|
|
1
|
+
{"version":3,"file":"CliPluginMongooseModule.js","sourceRoot":"","sources":["../../src/CliPluginMongooseModule.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,MAAM,EAAE,KAAK,EAAE,kBAAkB,EAAC,MAAM,gBAAgB,CAAC;AACjE,OAAO,EAAC,MAAM,EAAC,MAAM,UAAU,CAAC;AAChC,OAAO,EAAC,oBAAoB,EAAC,MAAM,8BAA8B,CAAC;AAClE,OAAO,EAAC,gBAAgB,EAAC,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAC,WAAW,EAAC,MAAM,wBAAwB,CAAC;AAKnD,IAAa,uBAAuB,GAApC,MAAa,uBAAuB;IAElC,WAAW,CAAqB;IAGhC,OAAO;QACL,IAAI,CAAC,WAAW,CAAC,eAAe,CAAC;YAC/B,gBAAgB,EAAE,IAAI,CAAC,WAAW,CAAC,YAAY,CAAC,cAAc,CAAC;YAC/D,QAAQ,EAAE,QAAQ;SACnB,CAAC,CAAC;QAEH,IAAI,CAAC,WAAW,CAAC,kBAAkB,CAAC;YAClC,wBAAwB,EAAE,IAAI,CAAC,WAAW,CAAC,YAAY,CAAC,cAAc,CAAC;SACxE,CAAC,CAAC;IACL,CAAC;CACF,CAAA;AAbC;IADC,MAAM,EAAE;8BACI,kBAAkB;4DAAC;AAGhC;IADC,KAAK,CAAC,2BAA2B,CAAC;;;;sDAUlC;AAdU,uBAAuB;IAHnC,MAAM,CAAC;QACN,OAAO,EAAE,CAAC,gBAAgB,EAAE,oBAAoB,EAAE,WAAW,CAAC;KAC/D,CAAC;GACW,uBAAuB,CAenC;SAfY,uBAAuB","sourcesContent":["import {Module, OnAdd, ProjectPackageJson} from \"@tsed/cli-core\";\nimport {Inject} from \"@tsed/di\";\nimport {MongooseGenerateHook} from \"./hooks/MongooseGenerateHook\";\nimport {MongooseInitHook} from \"./hooks/MongooseInitHook\";\nimport {CliMongoose} from \"./services/CliMongoose\";\n\n@Module({\n imports: [MongooseInitHook, MongooseGenerateHook, CliMongoose]\n})\nexport class CliPluginMongooseModule {\n @Inject()\n packageJson: ProjectPackageJson;\n\n @OnAdd(\"@tsed/cli-plugin-mongoose\")\n install() {\n this.packageJson.addDependencies({\n \"@tsed/mongoose\": this.packageJson.dependencies[\"@tsed/common\"],\n mongoose: \"latest\"\n });\n\n this.packageJson.addDevDependencies({\n \"@tsed/testing-mongoose\": this.packageJson.dependencies[\"@tsed/common\"]\n });\n }\n}\n"]}
|
|
@@ -10,6 +10,12 @@ import { camelCase, paramCase } from "change-case";
|
|
|
10
10
|
import { CliMongoose } from "../services/CliMongoose.js";
|
|
11
11
|
import { TEMPLATE_DIR } from "../utils/templateDir.js";
|
|
12
12
|
let MongooseGenerateHook = MongooseGenerateHook_1 = class MongooseGenerateHook {
|
|
13
|
+
providersInfoService;
|
|
14
|
+
projectPackageJson;
|
|
15
|
+
srcRenderService;
|
|
16
|
+
cliMongoose;
|
|
17
|
+
packages;
|
|
18
|
+
cliDockerComposeYaml;
|
|
13
19
|
constructor(providersInfoService) {
|
|
14
20
|
this.providersInfoService = providersInfoService;
|
|
15
21
|
providersInfoService
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MongooseGenerateHook.js","sourceRoot":"","sources":["../../../src/hooks/MongooseGenerateHook.ts"],"names":[],"mappings":";;AA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C,IAAI,aAAa,UAAU,MAAM;gBACxD,IAAI,EAAE,GAAG,EAAE,CACT,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAE;oBAC7C,MAAM,EAAE,GAAG,UAAU,KAAK;oBAC1B,WAAW,EAAE,YAAY;iBAC1B,CAAC;aACL;SACF,CAAC;IACJ,CAAC;IAEO,kBAAkB,CAAC,GAAuB;QAChD,OAAO;YACL;gBACE,KAAK,EAAE,4CAA4C,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,aAAa;gBACnF,IAAI,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,WAAW,CAAC,WAAW,CAAC,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC;aACxD;YACD;gBACE,KAAK,EAAE,uCAAuC;gBAC9C,IAAI,EAAE,KAAK,IAAI,EAAE,CAAC,IAAI,CAAC,oBAAoB,CAAC,kBAAkB,CAAC,GAAG,CAAC,IAAI,EAAE,SAAS,CAAC;aACpF;SACF,CAAC;IACJ,CAAC;CACF,CAAA;AAxFC;IADC,MAAM,EAAE;8BACW,kBAAkB;gEAAC;AAGvC;IADC,MAAM,EAAE;8BACS,kBAAkB;8DAAC;AAGrC;IADC,MAAM,EAAE;8BACI,WAAW;yDAAC;AAIzB;IADC,MAAM,EAAE;8BACuB,oBAAoB;kEAAC;AAgCrD;IADC,MAAM,CAAC,UAAU,CAAC;;;;0DAalB;AAxDU,oBAAoB;IADhC,UAAU,EAAE;qCAe+B,oBAAoB;GAdnD,oBAAoB,CA0FhC;SA1FY,oBAAoB","sourcesContent":["import {GenerateCmdContext, ProvidersInfoService} from \"@tsed/cli\";\nimport {CliDockerComposeYaml, Inject, OnExec, ProjectPackageJson, SrcRendererService, Tasks} from \"@tsed/cli-core\";\nimport {Injectable} from \"@tsed/di\";\n// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-ignore\nimport {plural} from \"pluralize\";\nimport {camelCase, paramCase} from \"change-case\";\nimport {CliMongoose} from \"../services/CliMongoose\";\nimport {TEMPLATE_DIR} from \"../utils/templateDir\";\n\n@Injectable()\nexport class MongooseGenerateHook {\n @Inject()\n projectPackageJson: ProjectPackageJson;\n\n @Inject()\n srcRenderService: SrcRendererService;\n\n @Inject()\n cliMongoose: CliMongoose;\n\n packages: any[];\n @Inject()\n protected cliDockerComposeYaml: CliDockerComposeYaml;\n\n constructor(private providersInfoService: ProvidersInfoService) {\n providersInfoService\n .add(\n {\n name: \"Mongoose model\",\n value: \"mongoose:model\",\n model: \"{{symbolName}}.model\",\n baseDir: \"models\"\n },\n MongooseGenerateHook\n )\n .add(\n {\n name: \"Mongoose schema\",\n value: \"mongoose:schema\",\n model: \"{{symbolName}}.schema\",\n baseDir: \"models\"\n },\n MongooseGenerateHook\n )\n .add(\n {\n name: \"Mongoose connection\",\n value: \"mongoose:connection\"\n },\n MongooseGenerateHook\n );\n }\n\n @OnExec(\"generate\")\n onGenerateExec(ctx: GenerateCmdContext): Tasks {\n if (this.providersInfoService.isMyProvider(ctx.type, MongooseGenerateHook)) {\n switch (ctx.type) {\n case \"mongoose:connection\":\n return this.generateConnection(ctx);\n case \"mongoose:model\":\n case \"mongoose:schema\":\n return this.generateTemplate(ctx);\n }\n }\n\n return [];\n }\n\n private generateTemplate(ctx: GenerateCmdContext) {\n const {symbolPath, type, symbolName} = ctx;\n const template = `mongoose.${type.split(\":\")[1]}.hbs`;\n const newCtx = {\n ...ctx,\n collectionName: plural(camelCase(symbolName.replace(/Schema|Model/gi, \"\")))\n };\n\n return [\n {\n title: `Generate ${ctx.type} file to '${symbolPath}.ts'`,\n task: () =>\n this.srcRenderService.render(template, newCtx, {\n output: `${symbolPath}.ts`,\n templateDir: TEMPLATE_DIR\n })\n }\n ];\n }\n\n private generateConnection(ctx: GenerateCmdContext) {\n return [\n {\n title: `Generate Mongoose configuration file to '${paramCase(ctx.name)}.config.ts'`,\n task: () => this.cliMongoose.writeConfig(ctx.name, ctx)\n },\n {\n title: \"Generate docker-compose configuration\",\n task: async () => this.cliDockerComposeYaml.addDatabaseService(ctx.name, \"mongodb\")\n }\n ];\n }\n}\n"]}
|
|
@@ -3,6 +3,11 @@ import { CliDockerComposeYaml, Inject, OnExec, ProjectPackageJson, RootRendererS
|
|
|
3
3
|
import { Injectable } from "@tsed/di";
|
|
4
4
|
import { CliMongoose } from "../services/CliMongoose.js";
|
|
5
5
|
let MongooseInitHook = class MongooseInitHook {
|
|
6
|
+
cliMongoose;
|
|
7
|
+
packageJson;
|
|
8
|
+
rootRenderer;
|
|
9
|
+
srcRenderer;
|
|
10
|
+
cliDockerComposeYaml;
|
|
6
11
|
onExec(ctx) {
|
|
7
12
|
this.addScripts();
|
|
8
13
|
this.addDependencies(ctx);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MongooseInitHook.js","sourceRoot":"","sources":["../../../src/hooks/MongooseInitHook.ts"],"names":[],"mappings":";AACA,OAAO,EAAC,oBAAoB,EAAE,MAAM,EAAE,MAAM,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,kBAAkB,EAAC,MAAM,gBAAgB,CAAC;AACjI,OAAO,EAAC,UAAU,EAAC,MAAM,UAAU,CAAC;AACpC,OAAO,EAAC,WAAW,EAAC,MAAM,yBAAyB,CAAC;AAGpD,IAAa,gBAAgB,GAA7B,MAAa,gBAAgB;
|
|
1
|
+
{"version":3,"file":"MongooseInitHook.js","sourceRoot":"","sources":["../../../src/hooks/MongooseInitHook.ts"],"names":[],"mappings":";AACA,OAAO,EAAC,oBAAoB,EAAE,MAAM,EAAE,MAAM,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,kBAAkB,EAAC,MAAM,gBAAgB,CAAC;AACjI,OAAO,EAAC,UAAU,EAAC,MAAM,UAAU,CAAC;AACpC,OAAO,EAAC,WAAW,EAAC,MAAM,yBAAyB,CAAC;AAGpD,IAAa,gBAAgB,GAA7B,MAAa,gBAAgB;IAE3B,WAAW,CAAc;IAGf,WAAW,CAAqB;IAGhC,YAA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ourcesContent":["import {InitCmdContext} from \"@tsed/cli\";\nimport {CliDockerComposeYaml, Inject, OnExec, ProjectPackageJson, RootRendererService, SrcRendererService} from \"@tsed/cli-core\";\nimport {Injectable} from \"@tsed/di\";\nimport {CliMongoose} from \"../services/CliMongoose\";\n\n@Injectable()\nexport class MongooseInitHook {\n @Inject()\n cliMongoose: CliMongoose;\n\n @Inject()\n protected packageJson: ProjectPackageJson;\n\n @Inject()\n protected rootRenderer: RootRendererService;\n\n @Inject()\n protected srcRenderer: SrcRendererService;\n\n @Inject()\n protected cliDockerComposeYaml: CliDockerComposeYaml;\n\n @OnExec(\"init\")\n onExec(ctx: InitCmdContext) {\n this.addScripts();\n this.addDependencies(ctx);\n this.addDevDependencies(ctx);\n\n return [\n {\n title: \"Generate Mongoose configuration\",\n task: async () =>\n this.cliMongoose.writeConfig(\"default\", {\n symbolName: \"MONGOOSE_DEFAULT\"\n })\n },\n {\n title: \"Generate docker-compose configuration\",\n task: async () => this.cliDockerComposeYaml.addDatabaseService(\"mongodb\", \"mongodb\")\n }\n ];\n }\n\n addScripts() {\n this.packageJson.addScripts({});\n }\n\n addDependencies(ctx: InitCmdContext) {\n this.packageJson.addDependencies({}, ctx);\n }\n\n addDevDependencies(ctx: InitCmdContext) {\n this.packageJson.addDevDependencies({}, ctx);\n }\n}\n"]}
|
|
@@ -4,6 +4,8 @@ import { camelCase, constantCase, paramCase } from "change-case";
|
|
|
4
4
|
import { basename, join } from "path";
|
|
5
5
|
import { TEMPLATE_DIR } from "../utils/templateDir.js";
|
|
6
6
|
let CliMongoose = class CliMongoose {
|
|
7
|
+
projectPackageJson;
|
|
8
|
+
srcRenderer;
|
|
7
9
|
async writeConfig(name, options = {}) {
|
|
8
10
|
await this.srcRenderer.render("config.hbs", {
|
|
9
11
|
...options,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CliMongoose.js","sourceRoot":"","sources":["../../../src/services/CliMongoose.ts"],"names":[],"mappings":";AAAA,OAAO,EA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,CAAC,qBAAqB;QACzB,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,6BAA6B,CAAC,CAAC,CAAC;QAE1E,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;YAChC,MAAM,IAAI,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,gBAAgB,EAAE,EAAE,CAAC,CAAC;YAE1D,OAAO;gBACL,IAAI;gBACJ,UAAU,EAAE,SAAS,CAAC,IAAI,CAAC;aAC5B,CAAC;QACJ,CAAC,CAAC,CAAC;QAEH,OAAO,IAAI,CAAC,WAAW,CAAC,MAAM,CAC5B,WAAW,EACX;YACE,OAAO;SACR,EACD;YACE,WAAW,EAAE,YAAY;YACzB,MAAM,EAAE,UAAU;YAClB,OAAO,EAAE,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE,QAAQ,EAAE,UAAU,CAAC;SAC9D,CACF,CAAC;IACJ,CAAC;CACF,CAAA;AA/CC;IADC,MAAM,EAAE;8BACW,kBAAkB;uDAAC;AAGvC;IADC,MAAM,EAAE;8BACc,kBAAkB;gDAAC;AAL/B,WAAW;IADvB,UAAU,EAAE;GACA,WAAW,CAiDvB;SAjDY,WAAW","sourcesContent":["import {Inject, Injectable, ProjectPackageJson, SrcRendererService} from \"@tsed/cli-core\";\nimport {camelCase, constantCase, paramCase} from \"change-case\";\nimport {basename, join} from \"path\";\nimport {TEMPLATE_DIR} from \"../utils/templateDir\";\n\n@Injectable()\nexport class CliMongoose {\n @Inject()\n projectPackageJson: ProjectPackageJson;\n\n @Inject()\n protected srcRenderer: SrcRendererService;\n\n async writeConfig(name: string, options: any = {}) {\n await this.srcRenderer.render(\n \"config.hbs\",\n {\n ...options,\n symbolName: constantCase(name),\n name: paramCase(name)\n },\n {\n output: `${paramCase(name)}.config.ts`,\n rootDir: join(this.srcRenderer.rootDir, \"config\", \"mongoose\"),\n templateDir: TEMPLATE_DIR\n }\n );\n\n return this.regenerateIndexConfig();\n }\n\n async regenerateIndexConfig() {\n const list = await this.srcRenderer.scan([\"config/mongoose/*.config.ts\"]);\n\n const configs = list.map((file) => {\n const name = basename(file).replace(/\\.config\\.ts/gi, \"\");\n\n return {\n name,\n symbolName: camelCase(name)\n };\n });\n\n return this.srcRenderer.render(\n \"index.hbs\",\n {\n configs\n },\n {\n templateDir: TEMPLATE_DIR,\n output: \"index.ts\",\n rootDir: join(this.srcRenderer.rootDir, \"config\", \"mongoose\")\n }\n );\n }\n}\n"]}
|
|
@@ -1,9 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { dirname, join } from "path";
|
|
3
|
-
import filedirname from "filedirname";
|
|
1
|
+
import { getTemplateDirectory, filedirname } from "@tsed/cli-core";
|
|
4
2
|
const [, dir] = filedirname();
|
|
5
|
-
const
|
|
6
|
-
cwd: join(dir, "..", "..")
|
|
7
|
-
});
|
|
8
|
-
export const TEMPLATE_DIR = join(dirname(path), "templates");
|
|
3
|
+
export const TEMPLATE_DIR = getTemplateDirectory(dir);
|
|
9
4
|
//# sourceMappingURL=templateDir.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"templateDir.js","sourceRoot":"","sources":["../../../src/utils/templateDir.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"templateDir.js","sourceRoot":"","sources":["../../../src/utils/templateDir.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,oBAAoB,EAAE,WAAW,EAAC,MAAM,gBAAgB,CAAC;AAEjE,MAAM,CAAC,EAAE,GAAG,CAAC,GAAG,WAAW,EAAE,CAAC;AAE9B,MAAM,CAAC,MAAM,YAAY,GAAG,oBAAoB,CAAC,GAAG,CAAC,CAAC","sourcesContent":["import {getTemplateDirectory, filedirname} from \"@tsed/cli-core\";\n\nconst [, dir] = filedirname();\n\nexport const TEMPLATE_DIR = getTemplateDirectory(dir);\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsed/cli-plugin-mongoose",
|
|
3
|
-
"version": "3.21.
|
|
3
|
+
"version": "3.21.1",
|
|
4
4
|
"description": "Ts.ED CLI plugin. Add Mongoose support",
|
|
5
5
|
"source": "./src/index.ts",
|
|
6
6
|
"main": "./lib/cjs/index.js",
|
|
@@ -23,8 +23,8 @@
|
|
|
23
23
|
"tslib": "2.3.1"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
|
-
"@tsed/cli": "3.21.
|
|
27
|
-
"@tsed/cli-core": "3.21.
|
|
26
|
+
"@tsed/cli": "3.21.1",
|
|
27
|
+
"@tsed/cli-core": "3.21.1"
|
|
28
28
|
},
|
|
29
29
|
"peerDependencies": {},
|
|
30
30
|
"repository": "https://github.com/tsedio/tsed-cli",
|
|
@@ -33,8 +33,5 @@
|
|
|
33
33
|
},
|
|
34
34
|
"homepage": "https://github.com/tsedio/tsed-cli/tree/master/packages/cli-plugin-mongoose",
|
|
35
35
|
"author": "Romain Lenzotti",
|
|
36
|
-
"license": "MIT"
|
|
37
|
-
"publishConfig": {
|
|
38
|
-
"tag": "rc"
|
|
39
|
-
}
|
|
36
|
+
"license": "MIT"
|
|
40
37
|
}
|