@tsed/cli-plugin-prisma 4.2.1 → 4.2.3
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.map +1 -1
- package/lib/cjs/commands/PrismaCmd.js.map +1 -1
- package/lib/cjs/hooks/PrismaInitHook.js +3 -1
- package/lib/cjs/hooks/PrismaInitHook.js.map +1 -1
- package/lib/cjs/services/CliPrisma.js.map +1 -1
- package/lib/esm/CliPluginPrismaModule.js.map +1 -1
- package/lib/esm/commands/PrismaCmd.js.map +1 -1
- package/lib/esm/hooks/PrismaInitHook.js +3 -1
- package/lib/esm/hooks/PrismaInitHook.js.map +1 -1
- package/lib/esm/services/CliPrisma.js.map +1 -1
- package/package.json +3 -3
|
@@ -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;
|
|
1
|
+
{"version":3,"file":"CliPluginPrismaModule.js","sourceRoot":"","sources":["../../src/CliPluginPrismaModule.ts"],"names":[],"mappings":";;;;AAAA,6CAA0D;AAC1D,iCAAgC;AAChC,oDAA+C;AAC/C,2DAAsD;AAK/C,IAAM,qBAAqB,GAA3B,MAAM,qBAAqB;IAEhC,WAAW,CAAqB;CACjC,CAAA;AAFC;IAAC,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;
|
|
1
|
+
{"version":3,"file":"PrismaCmd.js","sourceRoot":"","sources":["../../../src/commands/PrismaCmd.ts"],"names":[],"mappings":";;;;AAAA,6CAAmF;AACnF,qDAAgD;AAmBzC,IAAM,SAAS,GAAf,MAAM,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;AAXC;IAAC,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"]}
|
|
@@ -37,7 +37,9 @@ let PrismaInitHook = class PrismaInitHook {
|
|
|
37
37
|
}, ctx);
|
|
38
38
|
}
|
|
39
39
|
addDevDependencies(ctx) {
|
|
40
|
-
this.packageJson.addDevDependencies({
|
|
40
|
+
this.packageJson.addDevDependencies({
|
|
41
|
+
prisma: "latest"
|
|
42
|
+
}, ctx);
|
|
41
43
|
}
|
|
42
44
|
$onFinish() {
|
|
43
45
|
return new Promise((resolve) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PrismaInitHook.js","sourceRoot":"","sources":["../../../src/hooks/PrismaInitHook.ts"],"names":[],"mappings":";;;;AACA,6CAA8E;AAC9E,iCAAoC;AACpC,qDAAgD;
|
|
1
|
+
{"version":3,"file":"PrismaInitHook.js","sourceRoot":"","sources":["../../../src/hooks/PrismaInitHook.ts"],"names":[],"mappings":";;;;AACA,6CAA8E;AAC9E,iCAAoC;AACpC,qDAAgD;AAGzC,IAAM,cAAc,GAApB,MAAM,cAAc;IAEf,SAAS,CAAY;IAGrB,UAAU,CAAa;IAGvB,WAAW,CAAqB;IAGpC,AAAN,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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import {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(\n {\n prisma: \"latest\"\n },\n ctx\n );\n }\n\n $onFinish() {\n return new Promise((resolve) => {\n this.packageJson.runScript(\"prisma:generate\").subscribe({\n complete() {\n resolve([]);\n },\n error: () => {\n resolve([]);\n }\n });\n });\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CliPrisma.js","sourceRoot":"","sources":["../../../src/services/CliPrisma.ts"],"names":[],"mappings":";;;;AAAA,6CAA2E;AAC3E,iCAAoC;
|
|
1
|
+
{"version":3,"file":"CliPrisma.js","sourceRoot":"","sources":["../../../src/services/CliPrisma.ts"],"names":[],"mappings":";;;;AAAA,6CAA2E;AAC3E,iCAAoC;AAG7B,IAAM,SAAS,GAAf,MAAM,SAAS;IAEV,QAAQ,CAAW;IAGnB,KAAK,CAAQ;IAGb,kBAAkB,CAAqB;IAE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,GAAE;GACA,SAAS,CAwCrB;AAxCY,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 content +=\n \"\\nmodel User {\\n\" +\n \" id Int @default(autoincrement()) @id\\n\" +\n \" email String @unique\\n\" +\n \" name String?\\n\" +\n \"}\\n\";\n\n return this.cliFs.writeFile(schemaPath, content, {encoding: \"utf8\"});\n }\n }\n }\n}\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;
|
|
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;AAK/C,IAAM,qBAAqB,GAA3B,MAAM,qBAAqB;IAEhC,WAAW,CAAqB;CACjC,CAAA;AAFC;IAAC,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;
|
|
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;AAmBzC,IAAM,SAAS,GAAf,MAAM,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;AAXC;IAAC,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"]}
|
|
@@ -34,7 +34,9 @@ let PrismaInitHook = class PrismaInitHook {
|
|
|
34
34
|
}, ctx);
|
|
35
35
|
}
|
|
36
36
|
addDevDependencies(ctx) {
|
|
37
|
-
this.packageJson.addDevDependencies({
|
|
37
|
+
this.packageJson.addDevDependencies({
|
|
38
|
+
prisma: "latest"
|
|
39
|
+
}, ctx);
|
|
38
40
|
}
|
|
39
41
|
$onFinish() {
|
|
40
42
|
return new Promise((resolve) => {
|
|
@@ -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;
|
|
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;AAGzC,IAAM,cAAc,GAApB,MAAM,cAAc;IAEf,SAAS,CAAY;IAGrB,UAAU,CAAa;IAGvB,WAAW,CAAqB;IAGpC,AAAN,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,CACjC;YACE,MAAM,EAAE,QAAQ;SACjB,EACD,GAAG,CACJ,CAAC;IACJ,CAAC;IAED,SAAS;QACP,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;YAC7B,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC,iBAAiB,CAAC,CAAC,SAAS,CAAC;gBACtD,QAAQ;oBACN,OAAO,CAAC,EAAE,CAAC,CAAC;gBACd,CAAC;gBACD,KAAK,EAAE,GAAG,EAAE;oBACV,OAAO,CAAC,EAAE,CAAC,CAAC;gBACd,CAAC;aACF,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;CACF,CAAA;AAjEC;IAAC,MAAM,EAAE;8BACY,SAAS;iDAAC;AAE/B;IAAC,MAAM,EAAE;8BACa,UAAU;kDAAC;AAEjC;IAAC,MAAM,EAAE;8BACc,kBAAkB;mDAAC;AAGpC;IADL,MAAM,CAAC,MAAM,CAAC;;;;4CAgBd;AA1BU,cAAc;IAD1B,UAAU,EAAE;GACA,cAAc,CAkE1B;SAlEY,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(\n {\n prisma: \"latest\"\n },\n ctx\n );\n }\n\n $onFinish() {\n return new Promise((resolve) => {\n this.packageJson.runScript(\"prisma:generate\").subscribe({\n complete() {\n resolve([]);\n },\n error: () => {\n resolve([]);\n }\n });\n });\n }\n}\n"]}
|
|
@@ -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;
|
|
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;AAG7B,IAAM,SAAS,GAAf,MAAM,SAAS;IAEV,QAAQ,CAAW;IAGnB,KAAK,CAAQ;IAGb,kBAAkB,CAAqB;IAEjD,GAAG,CAAC,OAAe,EAAE,OAAiB,EAAE,EAAE,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ageJson} 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 content +=\n \"\\nmodel User {\\n\" +\n \" id Int @default(autoincrement()) @id\\n\" +\n \" email String @unique\\n\" +\n \" name String?\\n\" +\n \"}\\n\";\n\n return this.cliFs.writeFile(schemaPath, content, {encoding: \"utf8\"});\n }\n }\n }\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsed/cli-plugin-prisma",
|
|
3
|
-
"version": "4.2.
|
|
3
|
+
"version": "4.2.3",
|
|
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": "4.2.
|
|
26
|
-
"@tsed/cli-core": "4.2.
|
|
25
|
+
"@tsed/cli": "4.2.3",
|
|
26
|
+
"@tsed/cli-core": "4.2.3"
|
|
27
27
|
},
|
|
28
28
|
"peerDependencies": {},
|
|
29
29
|
"repository": "https://github.com/tsedio/tsed-cli",
|