@tsed/cli-plugin-prisma 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/CliPluginPrismaModule.js +1 -0
- package/lib/cjs/CliPluginPrismaModule.js.map +1 -1
- package/lib/cjs/commands/PrismaCmd.js +1 -0
- package/lib/cjs/commands/PrismaCmd.js.map +1 -1
- package/lib/cjs/hooks/PrismaInitHook.js +3 -0
- package/lib/cjs/hooks/PrismaInitHook.js.map +1 -1
- package/lib/cjs/services/CliPrisma.js +3 -0
- package/lib/cjs/services/CliPrisma.js.map +1 -1
- package/lib/cjs/utils/templateDir.js +3 -9
- package/lib/cjs/utils/templateDir.js.map +1 -1
- package/lib/esm/CliPluginPrismaModule.js +1 -0
- package/lib/esm/CliPluginPrismaModule.js.map +1 -1
- package/lib/esm/commands/PrismaCmd.js +1 -0
- package/lib/esm/commands/PrismaCmd.js.map +1 -1
- package/lib/esm/hooks/PrismaInitHook.js +3 -0
- package/lib/esm/hooks/PrismaInitHook.js.map +1 -1
- package/lib/esm/services/CliPrisma.js +3 -0
- package/lib/esm/services/CliPrisma.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
|
@@ -7,6 +7,7 @@ const di_1 = require("@tsed/di");
|
|
|
7
7
|
const PrismaCmd_1 = require("./commands/PrismaCmd");
|
|
8
8
|
const PrismaInitHook_1 = require("./hooks/PrismaInitHook");
|
|
9
9
|
let CliPluginPrismaModule = class CliPluginPrismaModule {
|
|
10
|
+
packageJson;
|
|
10
11
|
};
|
|
11
12
|
tslib_1.__decorate([
|
|
12
13
|
(0, di_1.Inject)(),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CliPluginPrismaModule.js","sourceRoot":"","sources":["../../src/CliPluginPrismaModule.ts"],"names":[],"mappings":";;;;AAAA,6CAA0D;AAC1D,iCAAgC;AAChC,oDAA+C;AAC/C,2DAAsD;AAKtD,IAAa,qBAAqB,GAAlC,MAAa,qBAAqB;
|
|
1
|
+
{"version":3,"file":"CliPluginPrismaModule.js","sourceRoot":"","sources":["../../src/CliPluginPrismaModule.ts"],"names":[],"mappings":";;;;AAAA,6CAA0D;AAC1D,iCAAgC;AAChC,oDAA+C;AAC/C,2DAAsD;AAKtD,IAAa,qBAAqB,GAAlC,MAAa,qBAAqB;IAEhC,WAAW,CAAqB;CACjC,CAAA;AADC;IADC,IAAA,WAAM,GAAE;sCACI,6BAAkB;0DAAC;AAFrB,qBAAqB;IAHjC,IAAA,iBAAM,EAAC;QACN,OAAO,EAAE,CAAC,+BAAc,EAAE,qBAAS,CAAC;KACrC,CAAC;GACW,qBAAqB,CAGjC;AAHY,sDAAqB","sourcesContent":["import {Module, ProjectPackageJson} from \"@tsed/cli-core\";\nimport {Inject} from \"@tsed/di\";\nimport {PrismaCmd} from \"./commands/PrismaCmd\";\nimport {PrismaInitHook} from \"./hooks/PrismaInitHook\";\n\n@Module({\n imports: [PrismaInitHook, PrismaCmd]\n})\nexport class CliPluginPrismaModule {\n @Inject()\n packageJson: ProjectPackageJson;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PrismaCmd.js","sourceRoot":"","sources":["../../../src/commands/PrismaCmd.ts"],"names":[],"mappings":";;;;AAAA,6CAAmF;AACnF,qDAAgD;AAmBhD,IAAa,SAAS,GAAtB,MAAa,SAAS;
|
|
1
|
+
{"version":3,"file":"PrismaCmd.js","sourceRoot":"","sources":["../../../src/commands/PrismaCmd.ts"],"names":[],"mappings":";;;;AAAA,6CAAmF;AACnF,qDAAgD;AAmBhD,IAAa,SAAS,GAAtB,MAAa,SAAS;IAEpB,GAAG,CAAY;IAEf,KAAK,CAAC,KAAK,CAAC,GAAkB;QAC5B,OAAO;YACL;gBACE,KAAK,EAAE,kBAAkB,GAAG,CAAC,OAAO,EAAE;gBACtC,IAAI,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,OAAO,EAAE,GAAG,CAAC,OAAO,CAAC;aACnD;SACF,CAAC;IACJ,CAAC;CACF,CAAA;AAVC;IADC,IAAA,iBAAM,GAAE;sCACJ,qBAAS;sCAAC;AAFJ,SAAS;IAbrB,IAAA,kBAAO,EAAC;QACP,IAAI,EAAE,QAAQ;QACd,WAAW,EAAE,sBAAsB;QACnC,IAAI,EAAE;YACJ,OAAO,EAAE;gBACP,WAAW,EAAE,oBAAoB;gBACjC,IAAI,EAAE,MAAM;gBACZ,QAAQ,EAAE,IAAI;aACf;SACF;QACD,OAAO,EAAE,EAAE;QACX,kBAAkB,EAAE,IAAI;KACzB,CAAC;GACW,SAAS,CAYrB;AAZY,8BAAS","sourcesContent":["import {Command, CliDefaultOptions, CommandProvider, Inject} from \"@tsed/cli-core\";\nimport {CliPrisma} from \"../services/CliPrisma\";\n\nexport interface PrismaContext extends CliDefaultOptions {\n command: string;\n}\n\n@Command({\n name: \"prisma\",\n description: \"Run a prisma command\",\n args: {\n command: {\n description: \"The prisma command\",\n type: String,\n required: true\n }\n },\n options: {},\n allowUnknownOption: true\n})\nexport class PrismaCmd implements CommandProvider {\n @Inject()\n cli: CliPrisma;\n\n async $exec(ctx: PrismaContext) {\n return [\n {\n title: `Run Prisma CLI ${ctx.command}`,\n task: () => this.cli.run(ctx.command, ctx.rawArgs)\n }\n ];\n }\n}\n"]}
|
|
@@ -6,6 +6,9 @@ const cli_core_1 = require("@tsed/cli-core");
|
|
|
6
6
|
const di_1 = require("@tsed/di");
|
|
7
7
|
const CliPrisma_1 = require("../services/CliPrisma");
|
|
8
8
|
let PrismaInitHook = class PrismaInitHook {
|
|
9
|
+
cliPrisma;
|
|
10
|
+
cliService;
|
|
11
|
+
packageJson;
|
|
9
12
|
async onExec(ctx) {
|
|
10
13
|
this.addScripts();
|
|
11
14
|
this.addDependencies(ctx);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PrismaInitHook.js","sourceRoot":"","sources":["../../../src/hooks/PrismaInitHook.ts"],"names":[],"mappings":";;;;AACA,6CAA8E;AAC9E,iCAAoC;AACpC,qDAAgD;AAGhD,IAAa,cAAc,GAA3B,MAAa,cAAc;
|
|
1
|
+
{"version":3,"file":"PrismaInitHook.js","sourceRoot":"","sources":["../../../src/hooks/PrismaInitHook.ts"],"names":[],"mappings":";;;;AACA,6CAA8E;AAC9E,iCAAoC;AACpC,qDAAgD;AAGhD,IAAa,cAAc,GAA3B,MAAa,cAAc;IAEf,SAAS,CAAY;IAGrB,UAAU,CAAa;IAGvB,WAAW,CAAqB;IAG1C,KAAK,CAAC,MAAM,CAAC,GAAmB;QAC9B,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,wBAAwB;gBAC/B,IAAI,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE;aAClC;YACD;gBACE,KAAK,EAAE,0CAA0C;gBACjD,IAAI,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,iBAAiB,EAAE;aAC/C;SACF,CAAC;IACJ,CAAC;IAED,UAAU;QACR,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC;YAC1B,gBAAgB,EAAE,oCAAoC;YACtD,iBAAiB,EAAE,qBAAqB;SACzC,CAAC,CAAC;IACL,CAAC;IAED,eAAe,CAAC,GAAmB;QACjC,IAAI,CAAC,WAAW,CAAC,eAAe,CAC9B;YACE,cAAc,EAAE,QAAQ;YACxB,gBAAgB,EAAE,QAAQ;SAC3B,EACD,GAAG,CACJ,CAAC;IACJ,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;sCACY,qBAAS;iDAAC;AAG/B;IADC,IAAA,iBAAM,GAAE;sCACa,qBAAU;kDAAC;AAGjC;IADC,IAAA,iBAAM,GAAE;sCACc,6BAAkB;mDAAC;AAG1C;IADC,IAAA,iBAAM,EAAC,MAAM,CAAC;;;;4CAgBd;AA1BU,cAAc;IAD1B,IAAA,eAAU,GAAE;GACA,cAAc,CAgD1B;AAhDY,wCAAc","sourcesContent":["import {InitCmdContext} from \"@tsed/cli\";\nimport {CliService, Inject, OnExec, ProjectPackageJson} from \"@tsed/cli-core\";\nimport {Injectable} from \"@tsed/di\";\nimport {CliPrisma} from \"../services/CliPrisma\";\n\n@Injectable()\nexport class PrismaInitHook {\n @Inject()\n protected cliPrisma: CliPrisma;\n\n @Inject()\n protected cliService: CliService;\n\n @Inject()\n protected packageJson: ProjectPackageJson;\n\n @OnExec(\"init\")\n async onExec(ctx: InitCmdContext) {\n this.addScripts();\n this.addDependencies(ctx);\n this.addDevDependencies(ctx);\n\n return [\n {\n title: \"Generate Prisma schema\",\n task: () => this.cliPrisma.init()\n },\n {\n title: \"Add Ts.ED configuration to Prisma schema\",\n task: () => this.cliPrisma.patchPrismaSchema()\n }\n ];\n }\n\n addScripts() {\n this.packageJson.addScripts({\n \"prisma:migrate\": \"npx prisma migrate dev --name init\",\n \"prisma:generate\": \"npx prisma generate\"\n });\n }\n\n addDependencies(ctx: InitCmdContext) {\n this.packageJson.addDependencies(\n {\n \"@tsed/prisma\": \"latest\",\n \"@prisma/client\": \"latest\"\n },\n ctx\n );\n }\n\n addDevDependencies(ctx: InitCmdContext) {\n this.packageJson.addDevDependencies({}, ctx);\n }\n}\n"]}
|
|
@@ -5,6 +5,9 @@ const tslib_1 = require("tslib");
|
|
|
5
5
|
const cli_core_1 = require("@tsed/cli-core");
|
|
6
6
|
const di_1 = require("@tsed/di");
|
|
7
7
|
let CliPrisma = class CliPrisma {
|
|
8
|
+
cliExeca;
|
|
9
|
+
cliFs;
|
|
10
|
+
projectPackageJson;
|
|
8
11
|
run(command, args = [], options = {}) {
|
|
9
12
|
return this.cliExeca.run("npx", ["prisma", command, ...args], {
|
|
10
13
|
...options,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CliPrisma.js","sourceRoot":"","sources":["../../../src/services/CliPrisma.ts"],"names":[],"mappings":";;;;AAAA,6CAA2E;AAC3E,iCAAoC;AAGpC,IAAa,SAAS,GAAtB,MAAa,SAAS;
|
|
1
|
+
{"version":3,"file":"CliPrisma.js","sourceRoot":"","sources":["../../../src/services/CliPrisma.ts"],"names":[],"mappings":";;;;AAAA,6CAA2E;AAC3E,iCAAoC;AAGpC,IAAa,SAAS,GAAtB,MAAa,SAAS;IAEV,QAAQ,CAAW;IAGnB,KAAK,CAAQ;IAGb,kBAAkB,CAAqB;IAEjD,GAAG,CAAC,OAAe,EAAE,OAAiB,EAAE,EAAE,UAAe,EAAE;QACzD,OAAO,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC,QAAQ,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC,EAAE;YAC5D,GAAG,OAAO;YACV,GAAG,EAAE,IAAI,CAAC,kBAAkB,CAAC,GAAG;SACjC,CAAC,CAAC;IACL,CAAC;IAED,IAAI;QACF,OAAO,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IAC1B,CAAC;IAED,KAAK,CAAC,iBAAiB;QACrB,MAAM,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,kBAAkB,CAAC,GAAG,EAAE,QAAQ,EAAE,eAAe,CAAC,CAAC;QAE3F,IAAI,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,UAAU,CAAC,EAAE;YACjC,IAAI,OAAO,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;YAE5D,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAC,EAAE;gBACvC,OAAO,IAAI,sBAAsB,GAAG,8BAA8B,GAAG,KAAK,CAAC;gBAE3E,OAAO,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,UAAU,EAAE,OAAO,EAAE,EAAC,QAAQ,EAAE,MAAM,EAAC,CAAC,CAAC;aACtE;SACF;IACH,CAAC;CACF,CAAA;AAhCC;IADC,IAAA,iBAAM,GAAE;sCACW,mBAAQ;2CAAC;AAG7B;IADC,IAAA,iBAAM,GAAE;sCACQ,gBAAK;wCAAC;AAGvB;IADC,IAAA,iBAAM,GAAE;sCACqB,6BAAkB;qDAAC;AARtC,SAAS;IADrB,IAAA,eAAU,GAAE;GACA,SAAS,CAkCrB;AAlCY,8BAAS","sourcesContent":["import {CliExeca, CliFs, Inject, ProjectPackageJson} from \"@tsed/cli-core\";\nimport {Injectable} from \"@tsed/di\";\n\n@Injectable()\nexport class CliPrisma {\n @Inject()\n protected cliExeca: CliExeca;\n\n @Inject()\n protected cliFs: CliFs;\n\n @Inject()\n protected projectPackageJson: ProjectPackageJson;\n\n run(command: string, args: string[] = [], options: any = {}) {\n return this.cliExeca.run(\"npx\", [\"prisma\", command, ...args], {\n ...options,\n cwd: this.projectPackageJson.dir\n });\n }\n\n init() {\n return this.run(\"init\");\n }\n\n async patchPrismaSchema() {\n const schemaPath = this.cliFs.join(this.projectPackageJson.dir, \"prisma\", \"schema.prisma\");\n\n if (this.cliFs.exists(schemaPath)) {\n let content = await this.cliFs.readFile(schemaPath, \"utf8\");\n\n if (!content.includes(\"generator tsed\")) {\n content += \"\\ngenerator tsed {\\n\" + ' provider = \"tsed-prisma\"\\n' + \"}\\n\";\n\n return this.cliFs.writeFile(schemaPath, content, {encoding: \"utf8\"});\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"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CliPluginPrismaModule.js","sourceRoot":"","sources":["../../src/CliPluginPrismaModule.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,MAAM,EAAE,kBAAkB,EAAC,MAAM,gBAAgB,CAAC;AAC1D,OAAO,EAAC,MAAM,EAAC,MAAM,UAAU,CAAC;AAChC,OAAO,EAAC,SAAS,EAAC,MAAM,sBAAsB,CAAC;AAC/C,OAAO,EAAC,cAAc,EAAC,MAAM,wBAAwB,CAAC;AAKtD,IAAa,qBAAqB,GAAlC,MAAa,qBAAqB;
|
|
1
|
+
{"version":3,"file":"CliPluginPrismaModule.js","sourceRoot":"","sources":["../../src/CliPluginPrismaModule.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,MAAM,EAAE,kBAAkB,EAAC,MAAM,gBAAgB,CAAC;AAC1D,OAAO,EAAC,MAAM,EAAC,MAAM,UAAU,CAAC;AAChC,OAAO,EAAC,SAAS,EAAC,MAAM,sBAAsB,CAAC;AAC/C,OAAO,EAAC,cAAc,EAAC,MAAM,wBAAwB,CAAC;AAKtD,IAAa,qBAAqB,GAAlC,MAAa,qBAAqB;IAEhC,WAAW,CAAqB;CACjC,CAAA;AADC;IADC,MAAM,EAAE;8BACI,kBAAkB;0DAAC;AAFrB,qBAAqB;IAHjC,MAAM,CAAC;QACN,OAAO,EAAE,CAAC,cAAc,EAAE,SAAS,CAAC;KACrC,CAAC;GACW,qBAAqB,CAGjC;SAHY,qBAAqB","sourcesContent":["import {Module, ProjectPackageJson} from \"@tsed/cli-core\";\nimport {Inject} from \"@tsed/di\";\nimport {PrismaCmd} from \"./commands/PrismaCmd\";\nimport {PrismaInitHook} from \"./hooks/PrismaInitHook\";\n\n@Module({\n imports: [PrismaInitHook, PrismaCmd]\n})\nexport class CliPluginPrismaModule {\n @Inject()\n packageJson: ProjectPackageJson;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PrismaCmd.js","sourceRoot":"","sources":["../../../src/commands/PrismaCmd.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,OAAO,EAAsC,MAAM,EAAC,MAAM,gBAAgB,CAAC;AACnF,OAAO,EAAC,SAAS,EAAC,MAAM,uBAAuB,CAAC;AAmBhD,IAAa,SAAS,GAAtB,MAAa,SAAS;
|
|
1
|
+
{"version":3,"file":"PrismaCmd.js","sourceRoot":"","sources":["../../../src/commands/PrismaCmd.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,OAAO,EAAsC,MAAM,EAAC,MAAM,gBAAgB,CAAC;AACnF,OAAO,EAAC,SAAS,EAAC,MAAM,uBAAuB,CAAC;AAmBhD,IAAa,SAAS,GAAtB,MAAa,SAAS;IAEpB,GAAG,CAAY;IAEf,KAAK,CAAC,KAAK,CAAC,GAAkB;QAC5B,OAAO;YACL;gBACE,KAAK,EAAE,kBAAkB,GAAG,CAAC,OAAO,EAAE;gBACtC,IAAI,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,OAAO,EAAE,GAAG,CAAC,OAAO,CAAC;aACnD;SACF,CAAC;IACJ,CAAC;CACF,CAAA;AAVC;IADC,MAAM,EAAE;8BACJ,SAAS;sCAAC;AAFJ,SAAS;IAbrB,OAAO,CAAC;QACP,IAAI,EAAE,QAAQ;QACd,WAAW,EAAE,sBAAsB;QACnC,IAAI,EAAE;YACJ,OAAO,EAAE;gBACP,WAAW,EAAE,oBAAoB;gBACjC,IAAI,EAAE,MAAM;gBACZ,QAAQ,EAAE,IAAI;aACf;SACF;QACD,OAAO,EAAE,EAAE;QACX,kBAAkB,EAAE,IAAI;KACzB,CAAC;GACW,SAAS,CAYrB;SAZY,SAAS","sourcesContent":["import {Command, CliDefaultOptions, CommandProvider, Inject} from \"@tsed/cli-core\";\nimport {CliPrisma} from \"../services/CliPrisma\";\n\nexport interface PrismaContext extends CliDefaultOptions {\n command: string;\n}\n\n@Command({\n name: \"prisma\",\n description: \"Run a prisma command\",\n args: {\n command: {\n description: \"The prisma command\",\n type: String,\n required: true\n }\n },\n options: {},\n allowUnknownOption: true\n})\nexport class PrismaCmd implements CommandProvider {\n @Inject()\n cli: CliPrisma;\n\n async $exec(ctx: PrismaContext) {\n return [\n {\n title: `Run Prisma CLI ${ctx.command}`,\n task: () => this.cli.run(ctx.command, ctx.rawArgs)\n }\n ];\n }\n}\n"]}
|
|
@@ -3,6 +3,9 @@ import { CliService, Inject, OnExec, ProjectPackageJson } from "@tsed/cli-core";
|
|
|
3
3
|
import { Injectable } from "@tsed/di";
|
|
4
4
|
import { CliPrisma } from "../services/CliPrisma.js";
|
|
5
5
|
let PrismaInitHook = class PrismaInitHook {
|
|
6
|
+
cliPrisma;
|
|
7
|
+
cliService;
|
|
8
|
+
packageJson;
|
|
6
9
|
async onExec(ctx) {
|
|
7
10
|
this.addScripts();
|
|
8
11
|
this.addDependencies(ctx);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PrismaInitHook.js","sourceRoot":"","sources":["../../../src/hooks/PrismaInitHook.ts"],"names":[],"mappings":";AACA,OAAO,EAAC,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,kBAAkB,EAAC,MAAM,gBAAgB,CAAC;AAC9E,OAAO,EAAC,UAAU,EAAC,MAAM,UAAU,CAAC;AACpC,OAAO,EAAC,SAAS,EAAC,MAAM,uBAAuB,CAAC;AAGhD,IAAa,cAAc,GAA3B,MAAa,cAAc;
|
|
1
|
+
{"version":3,"file":"PrismaInitHook.js","sourceRoot":"","sources":["../../../src/hooks/PrismaInitHook.ts"],"names":[],"mappings":";AACA,OAAO,EAAC,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,kBAAkB,EAAC,MAAM,gBAAgB,CAAC;AAC9E,OAAO,EAAC,UAAU,EAAC,MAAM,UAAU,CAAC;AACpC,OAAO,EAAC,SAAS,EAAC,MAAM,uBAAuB,CAAC;AAGhD,IAAa,cAAc,GAA3B,MAAa,cAAc;IAEf,SAAS,CAAY;IAGrB,UAAU,CAAa;IAGvB,WAAW,CAAqB;IAG1C,KAAK,CAAC,MAAM,CAAC,GAAmB;QAC9B,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,wBAAwB;gBAC/B,IAAI,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE;aAClC;YACD;gBACE,KAAK,EAAE,0CAA0C;gBACjD,IAAI,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,iBAAiB,EAAE;aAC/C;SACF,CAAC;IACJ,CAAC;IAED,UAAU;QACR,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC;YAC1B,gBAAgB,EAAE,oCAAoC;YACtD,iBAAiB,EAAE,qBAAqB;SACzC,CAAC,CAAC;IACL,CAAC;IAED,eAAe,CAAC,GAAmB;QACjC,IAAI,CAAC,WAAW,CAAC,eAAe,CAC9B;YACE,cAAc,EAAE,QAAQ;YACxB,gBAAgB,EAAE,QAAQ;SAC3B,EACD,GAAG,CACJ,CAAC;IACJ,CAAC;IAED,kBAAkB,CAAC,GAAmB;QACpC,IAAI,CAAC,WAAW,CAAC,kBAAkB,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC;IAC/C,CAAC;CACF,CAAA;AA9CC;IADC,MAAM,EAAE;8BACY,SAAS;iDAAC;AAG/B;IADC,MAAM,EAAE;8BACa,UAAU;kDAAC;AAGjC;IADC,MAAM,EAAE;8BACc,kBAAkB;mDAAC;AAG1C;IADC,MAAM,CAAC,MAAM,CAAC;;;;4CAgBd;AA1BU,cAAc;IAD1B,UAAU,EAAE;GACA,cAAc,CAgD1B;SAhDY,cAAc","sourcesContent":["import {InitCmdContext} from \"@tsed/cli\";\nimport {CliService, Inject, OnExec, ProjectPackageJson} from \"@tsed/cli-core\";\nimport {Injectable} from \"@tsed/di\";\nimport {CliPrisma} from \"../services/CliPrisma\";\n\n@Injectable()\nexport class PrismaInitHook {\n @Inject()\n protected cliPrisma: CliPrisma;\n\n @Inject()\n protected cliService: CliService;\n\n @Inject()\n protected packageJson: ProjectPackageJson;\n\n @OnExec(\"init\")\n async onExec(ctx: InitCmdContext) {\n this.addScripts();\n this.addDependencies(ctx);\n this.addDevDependencies(ctx);\n\n return [\n {\n title: \"Generate Prisma schema\",\n task: () => this.cliPrisma.init()\n },\n {\n title: \"Add Ts.ED configuration to Prisma schema\",\n task: () => this.cliPrisma.patchPrismaSchema()\n }\n ];\n }\n\n addScripts() {\n this.packageJson.addScripts({\n \"prisma:migrate\": \"npx prisma migrate dev --name init\",\n \"prisma:generate\": \"npx prisma generate\"\n });\n }\n\n addDependencies(ctx: InitCmdContext) {\n this.packageJson.addDependencies(\n {\n \"@tsed/prisma\": \"latest\",\n \"@prisma/client\": \"latest\"\n },\n ctx\n );\n }\n\n addDevDependencies(ctx: InitCmdContext) {\n this.packageJson.addDevDependencies({}, ctx);\n }\n}\n"]}
|
|
@@ -2,6 +2,9 @@ import { __decorate, __metadata } from "tslib";
|
|
|
2
2
|
import { CliExeca, CliFs, Inject, ProjectPackageJson } from "@tsed/cli-core";
|
|
3
3
|
import { Injectable } from "@tsed/di";
|
|
4
4
|
let CliPrisma = class CliPrisma {
|
|
5
|
+
cliExeca;
|
|
6
|
+
cliFs;
|
|
7
|
+
projectPackageJson;
|
|
5
8
|
run(command, args = [], options = {}) {
|
|
6
9
|
return this.cliExeca.run("npx", ["prisma", command, ...args], {
|
|
7
10
|
...options,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CliPrisma.js","sourceRoot":"","sources":["../../../src/services/CliPrisma.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,QAAQ,EAAE,KAAK,EAAE,MAAM,EAAE,kBAAkB,EAAC,MAAM,gBAAgB,CAAC;AAC3E,OAAO,EAAC,UAAU,EAAC,MAAM,UAAU,CAAC;AAGpC,IAAa,SAAS,GAAtB,MAAa,SAAS;
|
|
1
|
+
{"version":3,"file":"CliPrisma.js","sourceRoot":"","sources":["../../../src/services/CliPrisma.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,QAAQ,EAAE,KAAK,EAAE,MAAM,EAAE,kBAAkB,EAAC,MAAM,gBAAgB,CAAC;AAC3E,OAAO,EAAC,UAAU,EAAC,MAAM,UAAU,CAAC;AAGpC,IAAa,SAAS,GAAtB,MAAa,SAAS;IAEV,QAAQ,CAAW;IAGnB,KAAK,CAAQ;IAGb,kBAAkB,CAAqB;IAEjD,GAAG,CAAC,OAAe,EAAE,OAAiB,EAAE,EAAE,UAAe,EAAE;QACzD,OAAO,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC,QAAQ,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC,EAAE;YAC5D,GAAG,OAAO;YACV,GAAG,EAAE,IAAI,CAAC,kBAAkB,CAAC,GAAG;SACjC,CAAC,CAAC;IACL,CAAC;IAED,IAAI;QACF,OAAO,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IAC1B,CAAC;IAED,KAAK,CAAC,iBAAiB;QACrB,MAAM,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,kBAAkB,CAAC,GAAG,EAAE,QAAQ,EAAE,eAAe,CAAC,CAAC;QAE3F,IAAI,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,UAAU,CAAC,EAAE;YACjC,IAAI,OAAO,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;YAE5D,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAC,EAAE;gBACvC,OAAO,IAAI,sBAAsB,GAAG,8BAA8B,GAAG,KAAK,CAAC;gBAE3E,OAAO,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,UAAU,EAAE,OAAO,EAAE,EAAC,QAAQ,EAAE,MAAM,EAAC,CAAC,CAAC;aACtE;SACF;IACH,CAAC;CACF,CAAA;AAhCC;IADC,MAAM,EAAE;8BACW,QAAQ;2CAAC;AAG7B;IADC,MAAM,EAAE;8BACQ,KAAK;wCAAC;AAGvB;IADC,MAAM,EAAE;8BACqB,kBAAkB;qDAAC;AARtC,SAAS;IADrB,UAAU,EAAE;GACA,SAAS,CAkCrB;SAlCY,SAAS","sourcesContent":["import {CliExeca, CliFs, Inject, ProjectPackageJson} from \"@tsed/cli-core\";\nimport {Injectable} from \"@tsed/di\";\n\n@Injectable()\nexport class CliPrisma {\n @Inject()\n protected cliExeca: CliExeca;\n\n @Inject()\n protected cliFs: CliFs;\n\n @Inject()\n protected projectPackageJson: ProjectPackageJson;\n\n run(command: string, args: string[] = [], options: any = {}) {\n return this.cliExeca.run(\"npx\", [\"prisma\", command, ...args], {\n ...options,\n cwd: this.projectPackageJson.dir\n });\n }\n\n init() {\n return this.run(\"init\");\n }\n\n async patchPrismaSchema() {\n const schemaPath = this.cliFs.join(this.projectPackageJson.dir, \"prisma\", \"schema.prisma\");\n\n if (this.cliFs.exists(schemaPath)) {\n let content = await this.cliFs.readFile(schemaPath, \"utf8\");\n\n if (!content.includes(\"generator tsed\")) {\n content += \"\\ngenerator tsed {\\n\" + ' provider = \"tsed-prisma\"\\n' + \"}\\n\";\n\n return this.cliFs.writeFile(schemaPath, content, {encoding: \"utf8\"});\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-prisma",
|
|
3
|
-
"version": "3.21.
|
|
3
|
+
"version": "3.21.1",
|
|
4
4
|
"description": "Ts.ED CLI plugin. Add Prisma project initialisation support.",
|
|
5
5
|
"source": "./src/index.ts",
|
|
6
6
|
"main": "./lib/cjs/index.js",
|
|
@@ -22,8 +22,8 @@
|
|
|
22
22
|
"tslib": "2.3.1"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
|
-
"@tsed/cli": "3.21.
|
|
26
|
-
"@tsed/cli-core": "3.21.
|
|
25
|
+
"@tsed/cli": "3.21.1",
|
|
26
|
+
"@tsed/cli-core": "3.21.1"
|
|
27
27
|
},
|
|
28
28
|
"peerDependencies": {},
|
|
29
29
|
"repository": "https://github.com/tsedio/tsed-cli",
|
|
@@ -32,8 +32,5 @@
|
|
|
32
32
|
},
|
|
33
33
|
"homepage": "https://github.com/tsedio/tsed-cli/tree/master/packages/cli-plugin-prisma",
|
|
34
34
|
"author": "Romain Lenzotti",
|
|
35
|
-
"license": "MIT"
|
|
36
|
-
"publishConfig": {
|
|
37
|
-
"tag": "rc"
|
|
38
|
-
}
|
|
35
|
+
"license": "MIT"
|
|
39
36
|
}
|