@tsed/cli-plugin-prisma 3.20.16 → 3.21.0-rc.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/lib/{CliPluginPrismaModule.js → cjs/CliPluginPrismaModule.js} +0 -0
  2. package/lib/cjs/CliPluginPrismaModule.js.map +1 -0
  3. package/lib/{commands → cjs/commands}/PrismaCmd.js +0 -0
  4. package/lib/cjs/commands/PrismaCmd.js.map +1 -0
  5. package/lib/{hooks → cjs/hooks}/PrismaInitHook.js +0 -0
  6. package/lib/cjs/hooks/PrismaInitHook.js.map +1 -0
  7. package/lib/{index.js → cjs/index.js} +1 -0
  8. package/lib/cjs/index.js.map +1 -0
  9. package/lib/cjs/package.json +3 -0
  10. package/lib/{services → cjs/services}/CliPrisma.js +0 -0
  11. package/lib/cjs/services/CliPrisma.js.map +1 -0
  12. package/lib/cjs/utils/templateDir.js +13 -0
  13. package/lib/cjs/utils/templateDir.js.map +1 -0
  14. package/lib/esm/CliPluginPrismaModule.js +18 -0
  15. package/lib/esm/CliPluginPrismaModule.js.map +1 -0
  16. package/lib/esm/commands/PrismaCmd.js +34 -0
  17. package/lib/esm/commands/PrismaCmd.js.map +1 -0
  18. package/lib/esm/hooks/PrismaInitHook.js +59 -0
  19. package/lib/esm/hooks/PrismaInitHook.js.map +1 -0
  20. package/lib/esm/index.js +6 -0
  21. package/lib/esm/index.js.map +1 -0
  22. package/lib/esm/package.json +3 -0
  23. package/lib/esm/services/CliPrisma.js +41 -0
  24. package/lib/esm/services/CliPrisma.js.map +1 -0
  25. package/lib/esm/utils/templateDir.js +9 -0
  26. package/lib/esm/utils/templateDir.js.map +1 -0
  27. package/lib/{CliPluginPrismaModule.d.ts → types/CliPluginPrismaModule.d.ts} +0 -0
  28. package/lib/{commands → types/commands}/PrismaCmd.d.ts +0 -0
  29. package/lib/{hooks → types/hooks}/PrismaInitHook.d.ts +0 -0
  30. package/lib/{index.d.ts → types/index.d.ts} +1 -0
  31. package/lib/{services → types/services}/CliPrisma.d.ts +0 -0
  32. package/lib/{utils → types/utils}/templateDir.d.ts +0 -0
  33. package/package.json +22 -10
  34. package/tsconfig.compile.esm.json +21 -0
  35. package/lib/CliPluginPrismaModule.js.map +0 -1
  36. package/lib/commands/PrismaCmd.js.map +0 -1
  37. package/lib/hooks/PrismaInitHook.js.map +0 -1
  38. package/lib/index.js.map +0 -1
  39. package/lib/services/CliPrisma.js.map +0 -1
  40. package/lib/utils/templateDir.js +0 -6
  41. package/lib/utils/templateDir.js.map +0 -1
@@ -0,0 +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;CAGjC,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"]}
File without changes
@@ -0,0 +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;IAIpB,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"]}
File without changes
@@ -0,0 +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;IAWzB,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"]}
@@ -4,5 +4,6 @@ const tslib_1 = require("tslib");
4
4
  const CliPluginPrismaModule_1 = require("./CliPluginPrismaModule");
5
5
  tslib_1.__exportStar(require("./hooks/PrismaInitHook"), exports);
6
6
  tslib_1.__exportStar(require("./services/CliPrisma"), exports);
7
+ tslib_1.__exportStar(require("./utils/templateDir"), exports);
7
8
  exports.default = CliPluginPrismaModule_1.CliPluginPrismaModule;
8
9
  //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAA,mEAA8D;AAE9D,iEAAuC;AACvC,+DAAqC;AACrC,8DAAoC;AAEpC,kBAAe,6CAAqB,CAAC","sourcesContent":["import {CliPluginPrismaModule} from \"./CliPluginPrismaModule\";\n\nexport * from \"./hooks/PrismaInitHook\";\nexport * from \"./services/CliPrisma\";\nexport * from \"./utils/templateDir\";\n\nexport default CliPluginPrismaModule;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;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"]}
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TEMPLATE_DIR = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const read_pkg_up_1 = tslib_1.__importDefault(require("read-pkg-up"));
6
+ const path_1 = require("path");
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: dir
11
+ });
12
+ exports.TEMPLATE_DIR = (0, path_1.join)((0, path_1.dirname)(path), "templates");
13
+ //# sourceMappingURL=templateDir.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"templateDir.js","sourceRoot":"","sources":["../../../src/utils/templateDir.ts"],"names":[],"mappings":";;;;AAAA,sEAAoC;AACpC,+BAAmC;AACnC,sEAAsC;AACtC,MAAM,CAAC,EAAE,GAAG,CAAC,GAAG,IAAA,qBAAW,GAAE,CAAC;AAE9B,MAAM,EAAC,IAAI,EAAC,GAAG,qBAAS,CAAC,IAAI,CAAC;IAC5B,GAAG,EAAE,GAAG;CACT,CAAE,CAAC;AAES,QAAA,YAAY,GAAG,IAAA,WAAI,EAAC,IAAA,cAAO,EAAC,IAAI,CAAC,EAAE,WAAW,CAAC,CAAC","sourcesContent":["import readPkgUp from \"read-pkg-up\";\nimport {dirname, join} from \"path\";\nimport filedirname from \"filedirname\";\nconst [, dir] = filedirname();\n\nconst {path} = readPkgUp.sync({\n cwd: dir\n})!;\n\nexport const TEMPLATE_DIR = join(dirname(path), \"templates\");\n"]}
@@ -0,0 +1,18 @@
1
+ import { __decorate, __metadata } from "tslib";
2
+ import { Module, ProjectPackageJson } from "@tsed/cli-core";
3
+ import { Inject } from "@tsed/di";
4
+ import { PrismaCmd } from "./commands/PrismaCmd.js";
5
+ import { PrismaInitHook } from "./hooks/PrismaInitHook.js";
6
+ let CliPluginPrismaModule = class CliPluginPrismaModule {
7
+ };
8
+ __decorate([
9
+ Inject(),
10
+ __metadata("design:type", ProjectPackageJson)
11
+ ], CliPluginPrismaModule.prototype, "packageJson", void 0);
12
+ CliPluginPrismaModule = __decorate([
13
+ Module({
14
+ imports: [PrismaInitHook, PrismaCmd]
15
+ })
16
+ ], CliPluginPrismaModule);
17
+ export { CliPluginPrismaModule };
18
+ //# sourceMappingURL=CliPluginPrismaModule.js.map
@@ -0,0 +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;CAGjC,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"]}
@@ -0,0 +1,34 @@
1
+ import { __decorate, __metadata } from "tslib";
2
+ import { Command, Inject } from "@tsed/cli-core";
3
+ import { CliPrisma } from "../services/CliPrisma.js";
4
+ let PrismaCmd = class PrismaCmd {
5
+ async $exec(ctx) {
6
+ return [
7
+ {
8
+ title: `Run Prisma CLI ${ctx.command}`,
9
+ task: () => this.cli.run(ctx.command, ctx.rawArgs)
10
+ }
11
+ ];
12
+ }
13
+ };
14
+ __decorate([
15
+ Inject(),
16
+ __metadata("design:type", CliPrisma)
17
+ ], PrismaCmd.prototype, "cli", void 0);
18
+ PrismaCmd = __decorate([
19
+ Command({
20
+ name: "prisma",
21
+ description: "Run a prisma command",
22
+ args: {
23
+ command: {
24
+ description: "The prisma command",
25
+ type: String,
26
+ required: true
27
+ }
28
+ },
29
+ options: {},
30
+ allowUnknownOption: true
31
+ })
32
+ ], PrismaCmd);
33
+ export { PrismaCmd };
34
+ //# sourceMappingURL=PrismaCmd.js.map
@@ -0,0 +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;IAIpB,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"]}
@@ -0,0 +1,59 @@
1
+ import { __decorate, __metadata } from "tslib";
2
+ import { CliService, Inject, OnExec, ProjectPackageJson } from "@tsed/cli-core";
3
+ import { Injectable } from "@tsed/di";
4
+ import { CliPrisma } from "../services/CliPrisma.js";
5
+ let PrismaInitHook = class PrismaInitHook {
6
+ async onExec(ctx) {
7
+ this.addScripts();
8
+ this.addDependencies(ctx);
9
+ this.addDevDependencies(ctx);
10
+ return [
11
+ {
12
+ title: "Generate Prisma schema",
13
+ task: () => this.cliPrisma.init()
14
+ },
15
+ {
16
+ title: "Add Ts.ED configuration to Prisma schema",
17
+ task: () => this.cliPrisma.patchPrismaSchema()
18
+ }
19
+ ];
20
+ }
21
+ addScripts() {
22
+ this.packageJson.addScripts({
23
+ "prisma:migrate": "npx prisma migrate dev --name init",
24
+ "prisma:generate": "npx prisma generate"
25
+ });
26
+ }
27
+ addDependencies(ctx) {
28
+ this.packageJson.addDependencies({
29
+ "@tsed/prisma": "latest",
30
+ "@prisma/client": "latest"
31
+ }, ctx);
32
+ }
33
+ addDevDependencies(ctx) {
34
+ this.packageJson.addDevDependencies({}, ctx);
35
+ }
36
+ };
37
+ __decorate([
38
+ Inject(),
39
+ __metadata("design:type", CliPrisma)
40
+ ], PrismaInitHook.prototype, "cliPrisma", void 0);
41
+ __decorate([
42
+ Inject(),
43
+ __metadata("design:type", CliService)
44
+ ], PrismaInitHook.prototype, "cliService", void 0);
45
+ __decorate([
46
+ Inject(),
47
+ __metadata("design:type", ProjectPackageJson)
48
+ ], PrismaInitHook.prototype, "packageJson", void 0);
49
+ __decorate([
50
+ OnExec("init"),
51
+ __metadata("design:type", Function),
52
+ __metadata("design:paramtypes", [Object]),
53
+ __metadata("design:returntype", Promise)
54
+ ], PrismaInitHook.prototype, "onExec", null);
55
+ PrismaInitHook = __decorate([
56
+ Injectable()
57
+ ], PrismaInitHook);
58
+ export { PrismaInitHook };
59
+ //# sourceMappingURL=PrismaInitHook.js.map
@@ -0,0 +1 @@
1
+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,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"]}
@@ -0,0 +1,6 @@
1
+ import { CliPluginPrismaModule } from "./CliPluginPrismaModule.js";
2
+ export * from "./hooks/PrismaInitHook.js";
3
+ export * from "./services/CliPrisma.js";
4
+ export * from "./utils/templateDir.js";
5
+ export default CliPluginPrismaModule;
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,qBAAqB,EAAC,MAAM,yBAAyB,CAAC;AAE9D,cAAc,wBAAwB,CAAC;AACvC,cAAc,sBAAsB,CAAC;AACrC,cAAc,qBAAqB,CAAC;AAEpC,eAAe,qBAAqB,CAAC","sourcesContent":["import {CliPluginPrismaModule} from \"./CliPluginPrismaModule\";\n\nexport * from \"./hooks/PrismaInitHook\";\nexport * from \"./services/CliPrisma\";\nexport * from \"./utils/templateDir\";\n\nexport default CliPluginPrismaModule;\n"]}
@@ -0,0 +1,3 @@
1
+ {
2
+ "type": "module"
3
+ }
@@ -0,0 +1,41 @@
1
+ import { __decorate, __metadata } from "tslib";
2
+ import { CliExeca, CliFs, Inject, ProjectPackageJson } from "@tsed/cli-core";
3
+ import { Injectable } from "@tsed/di";
4
+ let CliPrisma = class CliPrisma {
5
+ run(command, args = [], options = {}) {
6
+ return this.cliExeca.run("npx", ["prisma", command, ...args], {
7
+ ...options,
8
+ cwd: this.projectPackageJson.dir
9
+ });
10
+ }
11
+ init() {
12
+ return this.run("init");
13
+ }
14
+ async patchPrismaSchema() {
15
+ const schemaPath = this.cliFs.join(this.projectPackageJson.dir, "prisma", "schema.prisma");
16
+ if (this.cliFs.exists(schemaPath)) {
17
+ let content = await this.cliFs.readFile(schemaPath, "utf8");
18
+ if (!content.includes("generator tsed")) {
19
+ content += "\ngenerator tsed {\n" + ' provider = "tsed-prisma"\n' + "}\n";
20
+ return this.cliFs.writeFile(schemaPath, content, { encoding: "utf8" });
21
+ }
22
+ }
23
+ }
24
+ };
25
+ __decorate([
26
+ Inject(),
27
+ __metadata("design:type", CliExeca)
28
+ ], CliPrisma.prototype, "cliExeca", void 0);
29
+ __decorate([
30
+ Inject(),
31
+ __metadata("design:type", CliFs)
32
+ ], CliPrisma.prototype, "cliFs", void 0);
33
+ __decorate([
34
+ Inject(),
35
+ __metadata("design:type", ProjectPackageJson)
36
+ ], CliPrisma.prototype, "projectPackageJson", void 0);
37
+ CliPrisma = __decorate([
38
+ Injectable()
39
+ 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AAC,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"]}
@@ -0,0 +1,9 @@
1
+ import readPkgUp from "read-pkg-up";
2
+ import { dirname, join } from "path";
3
+ import filedirname from "filedirname";
4
+ const [, dir] = filedirname();
5
+ const { path } = readPkgUp.sync({
6
+ cwd: dir
7
+ });
8
+ export const TEMPLATE_DIR = join(dirname(path), "templates");
9
+ //# sourceMappingURL=templateDir.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"templateDir.js","sourceRoot":"","sources":["../../../src/utils/templateDir.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,aAAa,CAAC;AACpC,OAAO,EAAC,OAAO,EAAE,IAAI,EAAC,MAAM,MAAM,CAAC;AACnC,OAAO,WAAW,MAAM,aAAa,CAAC;AACtC,MAAM,CAAC,EAAE,GAAG,CAAC,GAAG,WAAW,EAAE,CAAC;AAE9B,MAAM,EAAC,IAAI,EAAC,GAAG,SAAS,CAAC,IAAI,CAAC;IAC5B,GAAG,EAAE,GAAG;CACT,CAAE,CAAC;AAEJ,MAAM,CAAC,MAAM,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,WAAW,CAAC,CAAC","sourcesContent":["import readPkgUp from \"read-pkg-up\";\nimport {dirname, join} from \"path\";\nimport filedirname from \"filedirname\";\nconst [, dir] = filedirname();\n\nconst {path} = readPkgUp.sync({\n cwd: dir\n})!;\n\nexport const TEMPLATE_DIR = join(dirname(path), \"templates\");\n"]}
File without changes
File without changes
@@ -1,4 +1,5 @@
1
1
  import { CliPluginPrismaModule } from "./CliPluginPrismaModule";
2
2
  export * from "./hooks/PrismaInitHook";
3
3
  export * from "./services/CliPrisma";
4
+ export * from "./utils/templateDir";
4
5
  export default CliPluginPrismaModule;
File without changes
File without changes
package/package.json CHANGED
@@ -1,20 +1,29 @@
1
1
  {
2
2
  "name": "@tsed/cli-plugin-prisma",
3
- "version": "3.20.16",
4
- "main": "./lib/index.js",
5
- "typings": "./lib/index.d.ts",
3
+ "version": "3.21.0-rc.2",
6
4
  "description": "Ts.ED CLI plugin. Add Prisma project initialisation support.",
5
+ "source": "./src/index.ts",
6
+ "main": "./lib/cjs/index.js",
7
+ "module": "./lib/esm/index.js",
8
+ "typings": "./lib/types/index.d.ts",
9
+ "exports": {
10
+ "types": "./lib/types/index.d.ts",
11
+ "import": "./lib/esm/index.js",
12
+ "require": "./lib/cjs/index.js",
13
+ "default": "./lib/esm/index.js"
14
+ },
15
+ "scripts": {
16
+ "build": "yarn run build:esm && yarn run build:cjs",
17
+ "build:cjs": "tsc --build tsconfig.compile.json",
18
+ "build:esm": "tsc --build tsconfig.compile.esm.json"
19
+ },
7
20
  "dependencies": {
8
21
  "change-case": "4.1.2",
9
22
  "tslib": "2.3.1"
10
23
  },
11
24
  "devDependencies": {
12
- "@tsed/cli": "3.20.16",
13
- "@tsed/cli-core": "3.20.16"
14
- },
15
- "scripts": {
16
- "build": "tsc --build tsconfig.compile.json",
17
- "build:doc": "tsc --build tsconfig.doc.json"
25
+ "@tsed/cli": "3.21.0-rc.2",
26
+ "@tsed/cli-core": "3.21.0-rc.2"
18
27
  },
19
28
  "peerDependencies": {},
20
29
  "repository": "https://github.com/tsedio/tsed-cli",
@@ -23,5 +32,8 @@
23
32
  },
24
33
  "homepage": "https://github.com/tsedio/tsed-cli/tree/master/packages/cli-plugin-prisma",
25
34
  "author": "Romain Lenzotti",
26
- "license": "MIT"
35
+ "license": "MIT",
36
+ "publishConfig": {
37
+ "tag": "rc"
38
+ }
27
39
  }
@@ -0,0 +1,21 @@
1
+ {
2
+ "extends": "./tsconfig.compile.json",
3
+ "compilerOptions": {
4
+ "baseUrl": ".",
5
+ "module": "ES2020",
6
+ "rootDir": "src",
7
+ "outDir": "./lib/esm",
8
+ "declaration": true,
9
+ "declarationDir": "./lib/types"
10
+ },
11
+ "exclude": [
12
+ "node_modules",
13
+ "test",
14
+ "lib",
15
+ "coverage",
16
+ ".nyc_output",
17
+ "**/*.spec.ts",
18
+ "jest.config.js",
19
+ "templates"
20
+ ]
21
+ }
@@ -1 +0,0 @@
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;CAGjC,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 +0,0 @@
1
- {"version":3,"file":"PrismaCmd.js","sourceRoot":"","sources":["../../src/commands/PrismaCmd.ts"],"names":[],"mappings":";;;;AAAA,6CAAmF;AACnF,qDAAgD;AAmBhD,IAAa,SAAS,GAAtB,MAAa,SAAS;IAIpB,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"]}
@@ -1 +0,0 @@
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;IAWzB,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"]}
package/lib/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,mEAA8D;AAE9D,iEAAuC;AACvC,+DAAqC;AAErC,kBAAe,6CAAqB,CAAC","sourcesContent":["import {CliPluginPrismaModule} from \"./CliPluginPrismaModule\";\n\nexport * from \"./hooks/PrismaInitHook\";\nexport * from \"./services/CliPrisma\";\n\nexport default CliPluginPrismaModule;\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"CliPrisma.js","sourceRoot":"","sources":["../../src/services/CliPrisma.ts"],"names":[],"mappings":";;;;AAAA,6CAA2E;AAC3E,iCAAoC;AAGpC,IAAa,SAAS,GAAtB,MAAa,SAAS;IAUpB,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,6 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TEMPLATE_DIR = void 0;
4
- const path_1 = require("path");
5
- exports.TEMPLATE_DIR = (0, path_1.resolve)(__dirname, "..", "..", "templates");
6
- //# sourceMappingURL=templateDir.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"templateDir.js","sourceRoot":"","sources":["../../src/utils/templateDir.ts"],"names":[],"mappings":";;;AAAA,+BAA6B;AAEhB,QAAA,YAAY,GAAG,IAAA,cAAO,EAAC,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,WAAW,CAAC,CAAC","sourcesContent":["import {resolve} from \"path\";\n\nexport const TEMPLATE_DIR = resolve(__dirname, \"..\", \"..\", \"templates\");\n"]}