@powerlines/plugin-prisma 0.2.71 → 0.2.72

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 (46) hide show
  1. package/dist/_virtual/rolldown_runtime.cjs +29 -1
  2. package/dist/api/client/client.gen.cjs +176 -1
  3. package/dist/api/client/client.gen.mjs +176 -1
  4. package/dist/api/client/index.cjs +14 -1
  5. package/dist/api/client/index.mjs +7 -1
  6. package/dist/api/client/types.gen.mjs +1 -1
  7. package/dist/api/client/utils.gen.cjs +187 -1
  8. package/dist/api/client/utils.gen.mjs +180 -1
  9. package/dist/api/client.gen.cjs +9 -1
  10. package/dist/api/client.gen.mjs +9 -1
  11. package/dist/api/core/auth.gen.cjs +12 -1
  12. package/dist/api/core/auth.gen.mjs +11 -1
  13. package/dist/api/core/bodySerializer.gen.cjs +35 -1
  14. package/dist/api/core/bodySerializer.gen.mjs +32 -1
  15. package/dist/api/core/params.gen.cjs +65 -1
  16. package/dist/api/core/params.gen.mjs +64 -1
  17. package/dist/api/core/pathSerializer.gen.cjs +87 -1
  18. package/dist/api/core/pathSerializer.gen.mjs +81 -1
  19. package/dist/api/core/queryKeySerializer.gen.cjs +66 -1
  20. package/dist/api/core/queryKeySerializer.gen.mjs +63 -1
  21. package/dist/api/core/serverSentEvents.gen.cjs +94 -6
  22. package/dist/api/core/serverSentEvents.gen.mjs +93 -6
  23. package/dist/api/core/types.gen.mjs +1 -1
  24. package/dist/api/core/utils.gen.cjs +81 -1
  25. package/dist/api/core/utils.gen.mjs +78 -1
  26. package/dist/api/sdk.gen.cjs +256 -1
  27. package/dist/api/sdk.gen.mjs +256 -1
  28. package/dist/api/types.gen.mjs +1 -1
  29. package/dist/helpers/get-schema.cjs +81 -1
  30. package/dist/helpers/get-schema.mjs +78 -1
  31. package/dist/helpers/index.cjs +7 -1
  32. package/dist/helpers/index.mjs +5 -1
  33. package/dist/helpers/prisma-postgres.cjs +16 -1
  34. package/dist/helpers/prisma-postgres.mjs +15 -1
  35. package/dist/helpers/schema-creator.cjs +59 -12
  36. package/dist/helpers/schema-creator.mjs +58 -12
  37. package/dist/index.cjs +127 -1
  38. package/dist/index.mjs +121 -1
  39. package/dist/powerlines/src/plugin-utils/get-config-path.cjs +49 -1
  40. package/dist/powerlines/src/plugin-utils/get-config-path.mjs +48 -1
  41. package/dist/powerlines/src/plugin-utils/paths.cjs +36 -1
  42. package/dist/powerlines/src/plugin-utils/paths.mjs +35 -1
  43. package/dist/types/index.mjs +1 -1
  44. package/dist/types/plugin.mjs +1 -1
  45. package/dist/types/prisma.mjs +1 -1
  46. package/package.json +11 -11
@@ -1 +1,5 @@
1
- import{getSchema as e}from"./get-schema.mjs";import{PrismaSchemaCreator as t}from"./schema-creator.mjs";import{findDatabaseByName as n}from"./prisma-postgres.mjs";export{t as PrismaSchemaCreator,n as findDatabaseByName,e as getSchema};
1
+ import { getSchema } from "./get-schema.mjs";
2
+ import { PrismaSchemaCreator } from "./schema-creator.mjs";
3
+ import { findDatabaseByName } from "./prisma-postgres.mjs";
4
+
5
+ export { PrismaSchemaCreator, findDatabaseByName, getSchema };
@@ -1 +1,16 @@
1
- async function e(e,t){if(!e.config.prisma.prismaPostgres?.projectId)throw Error(`Prisma Postgres project ID is not configured. Please set "prisma.prismaPostgres.projectId" in your Powerlines configuration.`);return(await e.prisma.api.listDatabases({path:{projectId:e.config.prisma.prismaPostgres.projectId}})).data.data.find(e=>e.name===t)}exports.findDatabaseByName=e;
1
+
2
+ //#region src/helpers/prisma-postgres.ts
3
+ /**
4
+ * Find a Postgres database by name.
5
+ *
6
+ * @param context - The Prisma plugin context.
7
+ * @param name - The name of the database to find.
8
+ * @returns The database object if found, otherwise undefined.
9
+ */
10
+ async function findDatabaseByName(context, name) {
11
+ if (!context.config.prisma.prismaPostgres?.projectId) throw new Error(`Prisma Postgres project ID is not configured. Please set "prisma.prismaPostgres.projectId" in your Powerlines configuration.`);
12
+ return (await context.prisma.api.listDatabases({ path: { projectId: context.config.prisma.prismaPostgres.projectId } })).data.data.find((db) => db.name === name);
13
+ }
14
+
15
+ //#endregion
16
+ exports.findDatabaseByName = findDatabaseByName;
@@ -1 +1,15 @@
1
- async function e(e,t){if(!e.config.prisma.prismaPostgres?.projectId)throw Error(`Prisma Postgres project ID is not configured. Please set "prisma.prismaPostgres.projectId" in your Powerlines configuration.`);return(await e.prisma.api.listDatabases({path:{projectId:e.config.prisma.prismaPostgres.projectId}})).data.data.find(e=>e.name===t)}export{e as findDatabaseByName};
1
+ //#region src/helpers/prisma-postgres.ts
2
+ /**
3
+ * Find a Postgres database by name.
4
+ *
5
+ * @param context - The Prisma plugin context.
6
+ * @param name - The name of the database to find.
7
+ * @returns The database object if found, otherwise undefined.
8
+ */
9
+ async function findDatabaseByName(context, name) {
10
+ if (!context.config.prisma.prismaPostgres?.projectId) throw new Error(`Prisma Postgres project ID is not configured. Please set "prisma.prismaPostgres.projectId" in your Powerlines configuration.`);
11
+ return (await context.prisma.api.listDatabases({ path: { projectId: context.config.prisma.prismaPostgres.projectId } })).data.data.find((db) => db.name === name);
12
+ }
13
+
14
+ //#endregion
15
+ export { findDatabaseByName };
@@ -1,14 +1,61 @@
1
- const e=require(`../_virtual/rolldown_runtime.cjs`);let t=require(`prisma-util/schema-creator`);var n=class extends t.SchemaCreator{#e;get generators(){return this.#e.prisma.schema.generators}set generators(e){this.#e.prisma.schema.generators=e}constructor(e){super(),this.#e=e,this.#e.prisma??={},this.#e.prisma.schema??={generators:[],datasources:[],warnings:[]},this.#e.prisma.schema.generators.forEach(e=>{this.pushGenerator(e)})}pushGenerator(e){return this.generators.some(t=>t.name===e.name)?this.generators=[...this.generators.filter(t=>t.name!==e.name),e]:this.generators.push(e),this}build(){let e=super.build();for(let t of this.generators)e=`
2
- generator ${t.name} {
3
- provider = "${t.provider.value}"
4
- output = "${t.output?.value}"${t.previewFeatures&&t.previewFeatures.length>0?`
5
- previewFeatures = [${t.previewFeatures.map(e=>`"${e}"`).join(`, `)}]`:``}${t.config&&Object.keys(t.config).length>0?Object.entries(t.config).map(([e,t])=>Array.isArray(t)?`${e} = [${t.map(e=>`"${e}"`).join(`, `)}]`:`${e} = "${t}"`).join(`
6
- `):``}${t.binaryTargets&&t.binaryTargets.length>0?`
7
- binaryTargets = [${t.binaryTargets.map(e=>`"${e.value}"`).join(`, `)}]`:``}${t.envPaths?.rootEnvPath||t.envPaths?.schemaEnvPath?`
8
- env = {${t.envPaths?.rootEnvPath?`
9
- root = "${t.envPaths.rootEnvPath}"`:``}${t.envPaths?.schemaEnvPath?`
10
- schema = "${t.envPaths.schemaEnvPath}"`:``}
11
- }`:``}
1
+ const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
2
+ let prisma_util_schema_creator = require("prisma-util/schema-creator");
3
+
4
+ //#region src/helpers/schema-creator.ts
5
+ /**
6
+ * Prisma schema creator that allows building a schema via code.
7
+ */
8
+ var PrismaSchemaCreator = class extends prisma_util_schema_creator.SchemaCreator {
9
+ /** Prisma plugin context */
10
+ #context;
11
+ get generators() {
12
+ return this.#context.prisma.schema.generators;
13
+ }
14
+ set generators(value) {
15
+ this.#context.prisma.schema.generators = value;
16
+ }
17
+ constructor(context) {
18
+ super();
19
+ this.#context = context;
20
+ this.#context.prisma ??= {};
21
+ this.#context.prisma.schema ??= {
22
+ generators: [],
23
+ datasources: [],
24
+ warnings: []
25
+ };
26
+ this.#context.prisma.schema.generators.forEach((generator) => {
27
+ this.pushGenerator(generator);
28
+ });
29
+ }
30
+ pushGenerator(generator) {
31
+ if (this.generators.some((gen) => gen.name === generator.name)) this.generators = [...this.generators.filter((gen) => gen.name !== generator.name), generator];
32
+ else this.generators.push(generator);
33
+ return this;
34
+ }
35
+ build() {
36
+ let schema = super.build();
37
+ for (const generator of this.generators) schema = `
38
+ generator ${generator.name} {
39
+ provider = "${generator.provider.value}"
40
+ output = "${generator.output?.value}"${generator.previewFeatures && generator.previewFeatures.length > 0 ? `
41
+ previewFeatures = [${generator.previewFeatures.map((feature) => `"${feature}"`).join(", ")}]` : ""}${generator.config && Object.keys(generator.config).length > 0 ? Object.entries(generator.config).map(([key, value]) => {
42
+ if (Array.isArray(value)) return `${key} = [${value.map((v) => `"${v}"`).join(", ")}]`;
43
+ else return `${key} = "${value}"`;
44
+ }).join("\n ") : ""}${generator.binaryTargets && generator.binaryTargets.length > 0 ? `
45
+ binaryTargets = [${generator.binaryTargets.map((bt) => `"${bt.value}"`).join(", ")}]` : ""}${generator.envPaths?.rootEnvPath || generator.envPaths?.schemaEnvPath ? `
46
+ env = {${generator.envPaths?.rootEnvPath ? `
47
+ root = "${generator.envPaths.rootEnvPath}"` : ""}${generator.envPaths?.schemaEnvPath ? `
48
+ schema = "${generator.envPaths.schemaEnvPath}"` : ""}
49
+ }` : ""}
12
50
  }
13
51
 
14
- ${e}`;return e}async write(){await this.#e.fs.write(this.#e.config.prisma.schema,this.build())}};exports.PrismaSchemaCreator=n;
52
+ ${schema}`;
53
+ return schema;
54
+ }
55
+ async write() {
56
+ await this.#context.fs.write(this.#context.config.prisma.schema, this.build());
57
+ }
58
+ };
59
+
60
+ //#endregion
61
+ exports.PrismaSchemaCreator = PrismaSchemaCreator;
@@ -1,14 +1,60 @@
1
- import{SchemaCreator as e}from"prisma-util/schema-creator";var t=class extends e{#e;get generators(){return this.#e.prisma.schema.generators}set generators(e){this.#e.prisma.schema.generators=e}constructor(e){super(),this.#e=e,this.#e.prisma??={},this.#e.prisma.schema??={generators:[],datasources:[],warnings:[]},this.#e.prisma.schema.generators.forEach(e=>{this.pushGenerator(e)})}pushGenerator(e){return this.generators.some(t=>t.name===e.name)?this.generators=[...this.generators.filter(t=>t.name!==e.name),e]:this.generators.push(e),this}build(){let e=super.build();for(let t of this.generators)e=`
2
- generator ${t.name} {
3
- provider = "${t.provider.value}"
4
- output = "${t.output?.value}"${t.previewFeatures&&t.previewFeatures.length>0?`
5
- previewFeatures = [${t.previewFeatures.map(e=>`"${e}"`).join(`, `)}]`:``}${t.config&&Object.keys(t.config).length>0?Object.entries(t.config).map(([e,t])=>Array.isArray(t)?`${e} = [${t.map(e=>`"${e}"`).join(`, `)}]`:`${e} = "${t}"`).join(`
6
- `):``}${t.binaryTargets&&t.binaryTargets.length>0?`
7
- binaryTargets = [${t.binaryTargets.map(e=>`"${e.value}"`).join(`, `)}]`:``}${t.envPaths?.rootEnvPath||t.envPaths?.schemaEnvPath?`
8
- env = {${t.envPaths?.rootEnvPath?`
9
- root = "${t.envPaths.rootEnvPath}"`:``}${t.envPaths?.schemaEnvPath?`
10
- schema = "${t.envPaths.schemaEnvPath}"`:``}
11
- }`:``}
1
+ import { SchemaCreator } from "prisma-util/schema-creator";
2
+
3
+ //#region src/helpers/schema-creator.ts
4
+ /**
5
+ * Prisma schema creator that allows building a schema via code.
6
+ */
7
+ var PrismaSchemaCreator = class extends SchemaCreator {
8
+ /** Prisma plugin context */
9
+ #context;
10
+ get generators() {
11
+ return this.#context.prisma.schema.generators;
12
+ }
13
+ set generators(value) {
14
+ this.#context.prisma.schema.generators = value;
15
+ }
16
+ constructor(context) {
17
+ super();
18
+ this.#context = context;
19
+ this.#context.prisma ??= {};
20
+ this.#context.prisma.schema ??= {
21
+ generators: [],
22
+ datasources: [],
23
+ warnings: []
24
+ };
25
+ this.#context.prisma.schema.generators.forEach((generator) => {
26
+ this.pushGenerator(generator);
27
+ });
28
+ }
29
+ pushGenerator(generator) {
30
+ if (this.generators.some((gen) => gen.name === generator.name)) this.generators = [...this.generators.filter((gen) => gen.name !== generator.name), generator];
31
+ else this.generators.push(generator);
32
+ return this;
33
+ }
34
+ build() {
35
+ let schema = super.build();
36
+ for (const generator of this.generators) schema = `
37
+ generator ${generator.name} {
38
+ provider = "${generator.provider.value}"
39
+ output = "${generator.output?.value}"${generator.previewFeatures && generator.previewFeatures.length > 0 ? `
40
+ previewFeatures = [${generator.previewFeatures.map((feature) => `"${feature}"`).join(", ")}]` : ""}${generator.config && Object.keys(generator.config).length > 0 ? Object.entries(generator.config).map(([key, value]) => {
41
+ if (Array.isArray(value)) return `${key} = [${value.map((v) => `"${v}"`).join(", ")}]`;
42
+ else return `${key} = "${value}"`;
43
+ }).join("\n ") : ""}${generator.binaryTargets && generator.binaryTargets.length > 0 ? `
44
+ binaryTargets = [${generator.binaryTargets.map((bt) => `"${bt.value}"`).join(", ")}]` : ""}${generator.envPaths?.rootEnvPath || generator.envPaths?.schemaEnvPath ? `
45
+ env = {${generator.envPaths?.rootEnvPath ? `
46
+ root = "${generator.envPaths.rootEnvPath}"` : ""}${generator.envPaths?.schemaEnvPath ? `
47
+ schema = "${generator.envPaths.schemaEnvPath}"` : ""}
48
+ }` : ""}
12
49
  }
13
50
 
14
- ${e}`;return e}async write(){await this.#e.fs.write(this.#e.config.prisma.schema,this.build())}};export{t as PrismaSchemaCreator};
51
+ ${schema}`;
52
+ return schema;
53
+ }
54
+ async write() {
55
+ await this.#context.fs.write(this.#context.config.prisma.schema, this.build());
56
+ }
57
+ };
58
+
59
+ //#endregion
60
+ export { PrismaSchemaCreator };
package/dist/index.cjs CHANGED
@@ -1 +1,127 @@
1
- Object.defineProperty(exports,`__esModule`,{value:!0});const e=require(`./_virtual/rolldown_runtime.cjs`),t=require(`./powerlines/src/plugin-utils/get-config-path.cjs`),n=require(`./powerlines/src/plugin-utils/paths.cjs`),r=require(`./api/client/utils.gen.cjs`),i=require(`./api/client/client.gen.cjs`),a=require(`./api/client.gen.cjs`),o=require(`./api/sdk.gen.cjs`),s=require(`./helpers/get-schema.cjs`),c=require(`./helpers/schema-creator.cjs`);let l=require(`@stryke/cli/execute`),u=require(`@stryke/fs/exists`),d=require(`@stryke/fs/package-fns`),f=require(`@stryke/path/join-paths`),p=require(`@stryke/path/replace`),m=require(`defu`);m=e.__toESM(m);const h=(e={})=>({name:`prisma`,config(){return{prisma:(0,m.default)(e,{schema:(0,f.joinPaths)(this.config.projectRoot,`prisma`,`schema.prisma`),configFile:e.configFile||t.getConfigPath(this,`prisma.config`),outputPath:(0,f.joinPaths)(`{builtinPath}`,`prisma`),prismaPostgres:e?.prismaPostgres?{projectId:this.config.name,region:`us-east-1`}:void 0})}},async configResolved(){if(this.dependencies[`@prisma/client`]=`latest`,this.config.prisma.configFile=n.replacePathTokens(this,this.config.prisma.configFile),!this.config.prisma.schema)throw Error(`Prisma schema path is not defined. Please specify a valid path in the plugin configuration.`);if(this.config.prisma.schema=n.replacePathTokens(this,this.config.prisma.schema),this.config.prisma.prismaPostgres){let t=process.env.PRISMA_SERVICE_TOKEN;if(!t)if(t=e.serviceToken,t)this.warn("If possible, please use the `PRISMA_SERVICE_TOKEN` environment variable instead of using the `serviceToken` option directly. The `serviceToken` option will work; however, this is a less secure method of configuration.");else throw Error("Unable to determine the Prisma service token. Please set the `PRISMA_SERVICE_TOKEN` environment variable.");let n=i.createClient(r.createConfig({baseUrl:`https://api.prisma.io`,throwOnError:!0,headers:{Authorization:`Bearer ${t}`,"User-Agent":`powerlines/1.0`}}));this.prisma.api=new o.PrismaClient({client:n}),await this.prisma.api.createDatabase({path:{projectId:this.config.prisma.prismaPostgres.projectId},body:{isDefault:!1,name:this.config.prisma.prismaPostgres.databaseName||`${this.config.prisma.prismaPostgres.region}.${this.config.mode}.${this.config.name}`,region:this.config.prisma.prismaPostgres.region}}).then(e=>e.data.data)}if(!this.config.prisma.outputPath)throw Error(`Prisma generated path is not defined. Please specify a valid path in the plugin configuration.`);this.config.prisma.outputPath=n.replacePathTokens(this,this.config.prisma.outputPath),this.prisma??={},(0,u.existsSync)(this.config.prisma.schema)?this.prisma.schema=await s.getSchema({datamodel:this.config.prisma.schema}):this.prisma.schema??={generators:[],datasources:[],warnings:[]};let t=this.prisma.schema.generators.find(e=>e.provider.value===`prisma-client-js`);t?t.output??={value:this.config.prisma.outputPath,fromEnvVar:null}:this.prisma.schema.generators.push({name:`prisma-client-js`,provider:{value:`prisma-client-js`,fromEnvVar:null},output:{value:this.config.prisma.outputPath,fromEnvVar:null},config:{},binaryTargets:[],previewFeatures:[],sourceFilePath:this.config.prisma.schema}),this.prisma.builder=new c.PrismaSchemaCreator(this)},async prepare(){await this.prisma.builder.write();let e=[`generate`,`--schema`,this.config.prisma.schema];if(this.config.prisma.prismaPath){e.unshift(this.config.prisma.prismaPath);let t=await(0,l.execute)(e.join(` `),this.config.projectRoot);if(t.failed)throw Error(`Prisma process exited with code ${t.exitCode}.`)}else{let t=await(0,d.isPackageListed)(`prisma`,this.config.projectRoot);e.unshift(t?(0,p.replacePath)(this.config.sourceRoot,this.config.projectRoot):this.config.sourceRoot);let n=await(0,l.executePackage)(`prisma`,e,(0,f.joinPaths)(this.workspaceConfig.workspaceRoot,this.config.projectRoot));if(n.failed)throw Error(`Prisma process exited with code ${n.exitCode}.`)}}});var g=h;exports.PrismaClient=o.PrismaClient,exports.client=a.client,exports.default=g,exports.plugin=h;
1
+ Object.defineProperty(exports, '__esModule', { value: true });
2
+ const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
3
+ const require_get_config_path = require('./powerlines/src/plugin-utils/get-config-path.cjs');
4
+ const require_paths = require('./powerlines/src/plugin-utils/paths.cjs');
5
+ const require_api_client_utils_gen = require('./api/client/utils.gen.cjs');
6
+ const require_api_client_client_gen = require('./api/client/client.gen.cjs');
7
+ const require_api_client_gen = require('./api/client.gen.cjs');
8
+ const require_api_sdk_gen = require('./api/sdk.gen.cjs');
9
+ const require_helpers_get_schema = require('./helpers/get-schema.cjs');
10
+ const require_helpers_schema_creator = require('./helpers/schema-creator.cjs');
11
+ let __stryke_cli_execute = require("@stryke/cli/execute");
12
+ let __stryke_fs_exists = require("@stryke/fs/exists");
13
+ let __stryke_fs_package_fns = require("@stryke/fs/package-fns");
14
+ let __stryke_path_join_paths = require("@stryke/path/join-paths");
15
+ let __stryke_path_replace = require("@stryke/path/replace");
16
+ let defu = require("defu");
17
+ defu = require_rolldown_runtime.__toESM(defu);
18
+
19
+ //#region src/index.ts
20
+ /**
21
+ * A Powerlines plugin to integrate Prisma for code generation.
22
+ *
23
+ * @param options - The plugin options.
24
+ * @returns A Powerlines plugin instance.
25
+ */
26
+ const plugin = (options = {}) => {
27
+ return {
28
+ name: "prisma",
29
+ config() {
30
+ return { prisma: (0, defu.default)(options, {
31
+ schema: (0, __stryke_path_join_paths.joinPaths)(this.config.projectRoot, "prisma", "schema.prisma"),
32
+ configFile: options.configFile || require_get_config_path.getConfigPath(this, "prisma.config"),
33
+ outputPath: (0, __stryke_path_join_paths.joinPaths)("{builtinPath}", "prisma"),
34
+ prismaPostgres: options?.prismaPostgres ? {
35
+ projectId: this.config.name,
36
+ region: "us-east-1"
37
+ } : void 0
38
+ }) };
39
+ },
40
+ async configResolved() {
41
+ this.dependencies["@prisma/client"] = "latest";
42
+ this.config.prisma.configFile = require_paths.replacePathTokens(this, this.config.prisma.configFile);
43
+ if (!this.config.prisma.schema) throw new Error(`Prisma schema path is not defined. Please specify a valid path in the plugin configuration.`);
44
+ this.config.prisma.schema = require_paths.replacePathTokens(this, this.config.prisma.schema);
45
+ if (this.config.prisma.prismaPostgres) {
46
+ let serviceToken = process.env.PRISMA_SERVICE_TOKEN;
47
+ if (!serviceToken) {
48
+ serviceToken = options.serviceToken;
49
+ if (serviceToken) this.warn("If possible, please use the `PRISMA_SERVICE_TOKEN` environment variable instead of using the `serviceToken` option directly. The `serviceToken` option will work; however, this is a less secure method of configuration.");
50
+ else throw new Error("Unable to determine the Prisma service token. Please set the `PRISMA_SERVICE_TOKEN` environment variable.");
51
+ }
52
+ const client$1 = require_api_client_client_gen.createClient(require_api_client_utils_gen.createConfig({
53
+ baseUrl: "https://api.prisma.io",
54
+ throwOnError: true,
55
+ headers: {
56
+ Authorization: `Bearer ${serviceToken}`,
57
+ "User-Agent": "powerlines/1.0"
58
+ }
59
+ }));
60
+ this.prisma.api = new require_api_sdk_gen.PrismaClient({ client: client$1 });
61
+ await this.prisma.api.createDatabase({
62
+ path: { projectId: this.config.prisma.prismaPostgres.projectId },
63
+ body: {
64
+ isDefault: false,
65
+ name: this.config.prisma.prismaPostgres.databaseName || `${this.config.prisma.prismaPostgres.region}.${this.config.mode}.${this.config.name}`,
66
+ region: this.config.prisma.prismaPostgres.region
67
+ }
68
+ }).then((response) => response.data.data);
69
+ }
70
+ if (!this.config.prisma.outputPath) throw new Error(`Prisma generated path is not defined. Please specify a valid path in the plugin configuration.`);
71
+ this.config.prisma.outputPath = require_paths.replacePathTokens(this, this.config.prisma.outputPath);
72
+ this.prisma ??= {};
73
+ if (!(0, __stryke_fs_exists.existsSync)(this.config.prisma.schema)) this.prisma.schema ??= {
74
+ generators: [],
75
+ datasources: [],
76
+ warnings: []
77
+ };
78
+ else this.prisma.schema = await require_helpers_get_schema.getSchema({ datamodel: this.config.prisma.schema });
79
+ const generator = this.prisma.schema.generators.find((gen) => gen.provider.value === "prisma-client-js");
80
+ if (!generator) this.prisma.schema.generators.push({
81
+ name: "prisma-client-js",
82
+ provider: {
83
+ value: "prisma-client-js",
84
+ fromEnvVar: null
85
+ },
86
+ output: {
87
+ value: this.config.prisma.outputPath,
88
+ fromEnvVar: null
89
+ },
90
+ config: {},
91
+ binaryTargets: [],
92
+ previewFeatures: [],
93
+ sourceFilePath: this.config.prisma.schema
94
+ });
95
+ else generator.output ??= {
96
+ value: this.config.prisma.outputPath,
97
+ fromEnvVar: null
98
+ };
99
+ this.prisma.builder = new require_helpers_schema_creator.PrismaSchemaCreator(this);
100
+ },
101
+ async prepare() {
102
+ await this.prisma.builder.write();
103
+ const args = [
104
+ "generate",
105
+ "--schema",
106
+ this.config.prisma.schema
107
+ ];
108
+ if (!this.config.prisma.prismaPath) {
109
+ const isPrismaListed = await (0, __stryke_fs_package_fns.isPackageListed)("prisma", this.config.projectRoot);
110
+ args.unshift(isPrismaListed ? (0, __stryke_path_replace.replacePath)(this.config.sourceRoot, this.config.projectRoot) : this.config.sourceRoot);
111
+ const result = await (0, __stryke_cli_execute.executePackage)("prisma", args, (0, __stryke_path_join_paths.joinPaths)(this.workspaceConfig.workspaceRoot, this.config.projectRoot));
112
+ if (result.failed) throw new Error(`Prisma process exited with code ${result.exitCode}.`);
113
+ } else {
114
+ args.unshift(this.config.prisma.prismaPath);
115
+ const result = await (0, __stryke_cli_execute.execute)(args.join(" "), this.config.projectRoot);
116
+ if (result.failed) throw new Error(`Prisma process exited with code ${result.exitCode}.`);
117
+ }
118
+ }
119
+ };
120
+ };
121
+ var src_default = plugin;
122
+
123
+ //#endregion
124
+ exports.PrismaClient = require_api_sdk_gen.PrismaClient;
125
+ exports.client = require_api_client_gen.client;
126
+ exports.default = src_default;
127
+ exports.plugin = plugin;
package/dist/index.mjs CHANGED
@@ -1 +1,121 @@
1
- import{getConfigPath as e}from"./powerlines/src/plugin-utils/get-config-path.mjs";import{replacePathTokens as t}from"./powerlines/src/plugin-utils/paths.mjs";import{createConfig as n}from"./api/client/utils.gen.mjs";import{createClient as r}from"./api/client/client.gen.mjs";import{client as i}from"./api/client.gen.mjs";import{PrismaClient as a}from"./api/sdk.gen.mjs";import{getSchema as o}from"./helpers/get-schema.mjs";import{PrismaSchemaCreator as s}from"./helpers/schema-creator.mjs";import{execute as c,executePackage as l}from"@stryke/cli/execute";import{existsSync as u}from"@stryke/fs/exists";import{isPackageListed as d}from"@stryke/fs/package-fns";import{joinPaths as f}from"@stryke/path/join-paths";import{replacePath as p}from"@stryke/path/replace";import m from"defu";const h=(i={})=>({name:`prisma`,config(){return{prisma:m(i,{schema:f(this.config.projectRoot,`prisma`,`schema.prisma`),configFile:i.configFile||e(this,`prisma.config`),outputPath:f(`{builtinPath}`,`prisma`),prismaPostgres:i?.prismaPostgres?{projectId:this.config.name,region:`us-east-1`}:void 0})}},async configResolved(){if(this.dependencies[`@prisma/client`]=`latest`,this.config.prisma.configFile=t(this,this.config.prisma.configFile),!this.config.prisma.schema)throw Error(`Prisma schema path is not defined. Please specify a valid path in the plugin configuration.`);if(this.config.prisma.schema=t(this,this.config.prisma.schema),this.config.prisma.prismaPostgres){let e=process.env.PRISMA_SERVICE_TOKEN;if(!e)if(e=i.serviceToken,e)this.warn("If possible, please use the `PRISMA_SERVICE_TOKEN` environment variable instead of using the `serviceToken` option directly. The `serviceToken` option will work; however, this is a less secure method of configuration.");else throw Error("Unable to determine the Prisma service token. Please set the `PRISMA_SERVICE_TOKEN` environment variable.");let t=r(n({baseUrl:`https://api.prisma.io`,throwOnError:!0,headers:{Authorization:`Bearer ${e}`,"User-Agent":`powerlines/1.0`}}));this.prisma.api=new a({client:t}),await this.prisma.api.createDatabase({path:{projectId:this.config.prisma.prismaPostgres.projectId},body:{isDefault:!1,name:this.config.prisma.prismaPostgres.databaseName||`${this.config.prisma.prismaPostgres.region}.${this.config.mode}.${this.config.name}`,region:this.config.prisma.prismaPostgres.region}}).then(e=>e.data.data)}if(!this.config.prisma.outputPath)throw Error(`Prisma generated path is not defined. Please specify a valid path in the plugin configuration.`);this.config.prisma.outputPath=t(this,this.config.prisma.outputPath),this.prisma??={},u(this.config.prisma.schema)?this.prisma.schema=await o({datamodel:this.config.prisma.schema}):this.prisma.schema??={generators:[],datasources:[],warnings:[]};let e=this.prisma.schema.generators.find(e=>e.provider.value===`prisma-client-js`);e?e.output??={value:this.config.prisma.outputPath,fromEnvVar:null}:this.prisma.schema.generators.push({name:`prisma-client-js`,provider:{value:`prisma-client-js`,fromEnvVar:null},output:{value:this.config.prisma.outputPath,fromEnvVar:null},config:{},binaryTargets:[],previewFeatures:[],sourceFilePath:this.config.prisma.schema}),this.prisma.builder=new s(this)},async prepare(){await this.prisma.builder.write();let e=[`generate`,`--schema`,this.config.prisma.schema];if(this.config.prisma.prismaPath){e.unshift(this.config.prisma.prismaPath);let t=await c(e.join(` `),this.config.projectRoot);if(t.failed)throw Error(`Prisma process exited with code ${t.exitCode}.`)}else{let t=await d(`prisma`,this.config.projectRoot);e.unshift(t?p(this.config.sourceRoot,this.config.projectRoot):this.config.sourceRoot);let n=await l(`prisma`,e,f(this.workspaceConfig.workspaceRoot,this.config.projectRoot));if(n.failed)throw Error(`Prisma process exited with code ${n.exitCode}.`)}}});var g=h;export{a as PrismaClient,i as client,g as default,h as plugin};
1
+ import { getConfigPath } from "./powerlines/src/plugin-utils/get-config-path.mjs";
2
+ import { replacePathTokens } from "./powerlines/src/plugin-utils/paths.mjs";
3
+ import { createConfig } from "./api/client/utils.gen.mjs";
4
+ import { createClient } from "./api/client/client.gen.mjs";
5
+ import { client } from "./api/client.gen.mjs";
6
+ import { PrismaClient } from "./api/sdk.gen.mjs";
7
+ import { getSchema } from "./helpers/get-schema.mjs";
8
+ import { PrismaSchemaCreator } from "./helpers/schema-creator.mjs";
9
+ import { execute, executePackage } from "@stryke/cli/execute";
10
+ import { existsSync } from "@stryke/fs/exists";
11
+ import { isPackageListed } from "@stryke/fs/package-fns";
12
+ import { joinPaths } from "@stryke/path/join-paths";
13
+ import { replacePath } from "@stryke/path/replace";
14
+ import defu from "defu";
15
+
16
+ //#region src/index.ts
17
+ /**
18
+ * A Powerlines plugin to integrate Prisma for code generation.
19
+ *
20
+ * @param options - The plugin options.
21
+ * @returns A Powerlines plugin instance.
22
+ */
23
+ const plugin = (options = {}) => {
24
+ return {
25
+ name: "prisma",
26
+ config() {
27
+ return { prisma: defu(options, {
28
+ schema: joinPaths(this.config.projectRoot, "prisma", "schema.prisma"),
29
+ configFile: options.configFile || getConfigPath(this, "prisma.config"),
30
+ outputPath: joinPaths("{builtinPath}", "prisma"),
31
+ prismaPostgres: options?.prismaPostgres ? {
32
+ projectId: this.config.name,
33
+ region: "us-east-1"
34
+ } : void 0
35
+ }) };
36
+ },
37
+ async configResolved() {
38
+ this.dependencies["@prisma/client"] = "latest";
39
+ this.config.prisma.configFile = replacePathTokens(this, this.config.prisma.configFile);
40
+ if (!this.config.prisma.schema) throw new Error(`Prisma schema path is not defined. Please specify a valid path in the plugin configuration.`);
41
+ this.config.prisma.schema = replacePathTokens(this, this.config.prisma.schema);
42
+ if (this.config.prisma.prismaPostgres) {
43
+ let serviceToken = process.env.PRISMA_SERVICE_TOKEN;
44
+ if (!serviceToken) {
45
+ serviceToken = options.serviceToken;
46
+ if (serviceToken) this.warn("If possible, please use the `PRISMA_SERVICE_TOKEN` environment variable instead of using the `serviceToken` option directly. The `serviceToken` option will work; however, this is a less secure method of configuration.");
47
+ else throw new Error("Unable to determine the Prisma service token. Please set the `PRISMA_SERVICE_TOKEN` environment variable.");
48
+ }
49
+ const client$1 = createClient(createConfig({
50
+ baseUrl: "https://api.prisma.io",
51
+ throwOnError: true,
52
+ headers: {
53
+ Authorization: `Bearer ${serviceToken}`,
54
+ "User-Agent": "powerlines/1.0"
55
+ }
56
+ }));
57
+ this.prisma.api = new PrismaClient({ client: client$1 });
58
+ await this.prisma.api.createDatabase({
59
+ path: { projectId: this.config.prisma.prismaPostgres.projectId },
60
+ body: {
61
+ isDefault: false,
62
+ name: this.config.prisma.prismaPostgres.databaseName || `${this.config.prisma.prismaPostgres.region}.${this.config.mode}.${this.config.name}`,
63
+ region: this.config.prisma.prismaPostgres.region
64
+ }
65
+ }).then((response) => response.data.data);
66
+ }
67
+ if (!this.config.prisma.outputPath) throw new Error(`Prisma generated path is not defined. Please specify a valid path in the plugin configuration.`);
68
+ this.config.prisma.outputPath = replacePathTokens(this, this.config.prisma.outputPath);
69
+ this.prisma ??= {};
70
+ if (!existsSync(this.config.prisma.schema)) this.prisma.schema ??= {
71
+ generators: [],
72
+ datasources: [],
73
+ warnings: []
74
+ };
75
+ else this.prisma.schema = await getSchema({ datamodel: this.config.prisma.schema });
76
+ const generator = this.prisma.schema.generators.find((gen) => gen.provider.value === "prisma-client-js");
77
+ if (!generator) this.prisma.schema.generators.push({
78
+ name: "prisma-client-js",
79
+ provider: {
80
+ value: "prisma-client-js",
81
+ fromEnvVar: null
82
+ },
83
+ output: {
84
+ value: this.config.prisma.outputPath,
85
+ fromEnvVar: null
86
+ },
87
+ config: {},
88
+ binaryTargets: [],
89
+ previewFeatures: [],
90
+ sourceFilePath: this.config.prisma.schema
91
+ });
92
+ else generator.output ??= {
93
+ value: this.config.prisma.outputPath,
94
+ fromEnvVar: null
95
+ };
96
+ this.prisma.builder = new PrismaSchemaCreator(this);
97
+ },
98
+ async prepare() {
99
+ await this.prisma.builder.write();
100
+ const args = [
101
+ "generate",
102
+ "--schema",
103
+ this.config.prisma.schema
104
+ ];
105
+ if (!this.config.prisma.prismaPath) {
106
+ const isPrismaListed = await isPackageListed("prisma", this.config.projectRoot);
107
+ args.unshift(isPrismaListed ? replacePath(this.config.sourceRoot, this.config.projectRoot) : this.config.sourceRoot);
108
+ const result = await executePackage("prisma", args, joinPaths(this.workspaceConfig.workspaceRoot, this.config.projectRoot));
109
+ if (result.failed) throw new Error(`Prisma process exited with code ${result.exitCode}.`);
110
+ } else {
111
+ args.unshift(this.config.prisma.prismaPath);
112
+ const result = await execute(args.join(" "), this.config.projectRoot);
113
+ if (result.failed) throw new Error(`Prisma process exited with code ${result.exitCode}.`);
114
+ }
115
+ }
116
+ };
117
+ };
118
+ var src_default = plugin;
119
+
120
+ //#endregion
121
+ export { PrismaClient, client, src_default as default, plugin };
@@ -1 +1,49 @@
1
- const e=require(`../../../_virtual/rolldown_runtime.cjs`);let t=require(`@stryke/path/join`),n=require(`node:fs`);function r(e,r){if((0,n.existsSync)((0,t.joinPaths)(e.workspaceConfig.workspaceRoot,e.config.projectRoot,`${r}.yml`)))return(0,t.joinPaths)(e.workspaceConfig.workspaceRoot,e.config.projectRoot,`${r}.yml`);if((0,n.existsSync)((0,t.joinPaths)(e.workspaceConfig.workspaceRoot,e.config.projectRoot,`${r}.yaml`)))return(0,t.joinPaths)(e.workspaceConfig.workspaceRoot,e.config.projectRoot,`${r}.yaml`);if((0,n.existsSync)((0,t.joinPaths)(e.workspaceConfig.workspaceRoot,e.config.projectRoot,`${r}.json`)))return(0,t.joinPaths)(e.workspaceConfig.workspaceRoot,e.config.projectRoot,`${r}.json`);if((0,n.existsSync)((0,t.joinPaths)(e.workspaceConfig.workspaceRoot,e.config.projectRoot,`${r}.jsonc`)))return(0,t.joinPaths)(e.workspaceConfig.workspaceRoot,e.config.projectRoot,`${r}.jsonc`);if((0,n.existsSync)((0,t.joinPaths)(e.workspaceConfig.workspaceRoot,e.config.projectRoot,`${r}.ts`)))return(0,t.joinPaths)(e.workspaceConfig.workspaceRoot,e.config.projectRoot,`${r}.ts`);if((0,n.existsSync)((0,t.joinPaths)(e.workspaceConfig.workspaceRoot,e.config.projectRoot,`${r}.cts`)))return(0,t.joinPaths)(e.workspaceConfig.workspaceRoot,e.config.projectRoot,`${r}.cts`);if((0,n.existsSync)((0,t.joinPaths)(e.workspaceConfig.workspaceRoot,e.config.projectRoot,`${r}.mts`)))return(0,t.joinPaths)(e.workspaceConfig.workspaceRoot,e.config.projectRoot,`${r}.mts`);if((0,n.existsSync)((0,t.joinPaths)(e.workspaceConfig.workspaceRoot,e.config.projectRoot,`${r}.js`)))return(0,t.joinPaths)(e.workspaceConfig.workspaceRoot,e.config.projectRoot,`${r}.js`);if((0,n.existsSync)((0,t.joinPaths)(e.workspaceConfig.workspaceRoot,e.config.projectRoot,`${r}.cjs`)))return(0,t.joinPaths)(e.workspaceConfig.workspaceRoot,e.config.projectRoot,`${r}.cjs`);if((0,n.existsSync)((0,t.joinPaths)(e.workspaceConfig.workspaceRoot,e.config.projectRoot,`${r}.mjs`)))return(0,t.joinPaths)(e.workspaceConfig.workspaceRoot,e.config.projectRoot,`${r}.mjs`);if((0,n.existsSync)((0,t.joinPaths)(e.workspaceConfig.workspaceRoot,e.config.projectRoot,`${r}.config.ts`)))return(0,t.joinPaths)(e.workspaceConfig.workspaceRoot,e.config.projectRoot,`${r}.config.ts`);if((0,n.existsSync)((0,t.joinPaths)(e.workspaceConfig.workspaceRoot,e.config.projectRoot,`${r}.config.cts`)))return(0,t.joinPaths)(e.workspaceConfig.workspaceRoot,e.config.projectRoot,`${r}.config.cts`);if((0,n.existsSync)((0,t.joinPaths)(e.workspaceConfig.workspaceRoot,e.config.projectRoot,`${r}.config.mts`)))return(0,t.joinPaths)(e.workspaceConfig.workspaceRoot,e.config.projectRoot,`${r}.config.mts`);if((0,n.existsSync)((0,t.joinPaths)(e.workspaceConfig.workspaceRoot,e.config.projectRoot,`${r}.config.js`)))return(0,t.joinPaths)(e.workspaceConfig.workspaceRoot,e.config.projectRoot,`${r}.config.js`);if((0,n.existsSync)((0,t.joinPaths)(e.workspaceConfig.workspaceRoot,e.config.projectRoot,`${r}.config.cjs`)))return(0,t.joinPaths)(e.workspaceConfig.workspaceRoot,e.config.projectRoot,`${r}.config.cjs`);if((0,n.existsSync)((0,t.joinPaths)(e.workspaceConfig.workspaceRoot,e.config.projectRoot,`${r}.config.mjs`)))return(0,t.joinPaths)(e.workspaceConfig.workspaceRoot,e.config.projectRoot,`${r}.config.mjs`);if((0,n.existsSync)((0,t.joinPaths)(e.workspaceConfig.workspaceRoot,`${r}.yml`)))return(0,t.joinPaths)(e.workspaceConfig.workspaceRoot,`${r}.yml`);if((0,n.existsSync)((0,t.joinPaths)(e.workspaceConfig.workspaceRoot,`${r}.yaml`)))return(0,t.joinPaths)(e.workspaceConfig.workspaceRoot,`${r}.yaml`);if((0,n.existsSync)((0,t.joinPaths)(e.workspaceConfig.workspaceRoot,`${r}.json`)))return(0,t.joinPaths)(e.workspaceConfig.workspaceRoot,`${r}.json`);if((0,n.existsSync)((0,t.joinPaths)(e.workspaceConfig.workspaceRoot,`${r}.jsonc`)))return(0,t.joinPaths)(e.workspaceConfig.workspaceRoot,`${r}.jsonc`);if((0,n.existsSync)((0,t.joinPaths)(e.workspaceConfig.workspaceRoot,`${r}.ts`)))return(0,t.joinPaths)(e.workspaceConfig.workspaceRoot,`${r}.ts`);if((0,n.existsSync)((0,t.joinPaths)(e.workspaceConfig.workspaceRoot,`${r}.cts`)))return(0,t.joinPaths)(e.workspaceConfig.workspaceRoot,`${r}.cts`);if((0,n.existsSync)((0,t.joinPaths)(e.workspaceConfig.workspaceRoot,`${r}.mts`)))return(0,t.joinPaths)(e.workspaceConfig.workspaceRoot,`${r}.mts`);if((0,n.existsSync)((0,t.joinPaths)(e.workspaceConfig.workspaceRoot,`${r}.js`)))return(0,t.joinPaths)(e.workspaceConfig.workspaceRoot,`${r}.js`);if((0,n.existsSync)((0,t.joinPaths)(e.workspaceConfig.workspaceRoot,`${r}.cjs`)))return(0,t.joinPaths)(e.workspaceConfig.workspaceRoot,`${r}.cjs`);if((0,n.existsSync)((0,t.joinPaths)(e.workspaceConfig.workspaceRoot,`${r}.mjs`)))return(0,t.joinPaths)(e.workspaceConfig.workspaceRoot,`${r}.mjs`);if((0,n.existsSync)((0,t.joinPaths)(e.workspaceConfig.workspaceRoot,`${r}.config.ts`)))return(0,t.joinPaths)(e.workspaceConfig.workspaceRoot,`${r}.config.ts`);if((0,n.existsSync)((0,t.joinPaths)(e.workspaceConfig.workspaceRoot,`${r}.config.cts`)))return(0,t.joinPaths)(e.workspaceConfig.workspaceRoot,`${r}.config.cts`);if((0,n.existsSync)((0,t.joinPaths)(e.workspaceConfig.workspaceRoot,`${r}.config.mts`)))return(0,t.joinPaths)(e.workspaceConfig.workspaceRoot,`${r}.config.mts`);if((0,n.existsSync)((0,t.joinPaths)(e.workspaceConfig.workspaceRoot,`${r}.config.js`)))return(0,t.joinPaths)(e.workspaceConfig.workspaceRoot,`${r}.config.js`);if((0,n.existsSync)((0,t.joinPaths)(e.workspaceConfig.workspaceRoot,`${r}.config.cjs`)))return(0,t.joinPaths)(e.workspaceConfig.workspaceRoot,`${r}.config.cjs`);if((0,n.existsSync)((0,t.joinPaths)(e.workspaceConfig.workspaceRoot,`${r}.config.mjs`)))return(0,t.joinPaths)(e.workspaceConfig.workspaceRoot,`${r}.config.mjs`)}exports.getConfigPath=r;
1
+ const require_rolldown_runtime = require('../../../_virtual/rolldown_runtime.cjs');
2
+ let __stryke_path_join = require("@stryke/path/join");
3
+ let node_fs = require("node:fs");
4
+
5
+ //#region ../powerlines/src/plugin-utils/get-config-path.ts
6
+ /**
7
+ * Get the configuration file path for a given name.
8
+ *
9
+ * @param context - The Powerlines context.
10
+ * @param name - The name of the configuration file (without extension).
11
+ * @returns The absolute path to the configuration file, or undefined if not found.
12
+ */
13
+ function getConfigPath(context, name) {
14
+ if ((0, node_fs.existsSync)((0, __stryke_path_join.joinPaths)(context.workspaceConfig.workspaceRoot, context.config.projectRoot, `${name}.yml`))) return (0, __stryke_path_join.joinPaths)(context.workspaceConfig.workspaceRoot, context.config.projectRoot, `${name}.yml`);
15
+ else if ((0, node_fs.existsSync)((0, __stryke_path_join.joinPaths)(context.workspaceConfig.workspaceRoot, context.config.projectRoot, `${name}.yaml`))) return (0, __stryke_path_join.joinPaths)(context.workspaceConfig.workspaceRoot, context.config.projectRoot, `${name}.yaml`);
16
+ else if ((0, node_fs.existsSync)((0, __stryke_path_join.joinPaths)(context.workspaceConfig.workspaceRoot, context.config.projectRoot, `${name}.json`))) return (0, __stryke_path_join.joinPaths)(context.workspaceConfig.workspaceRoot, context.config.projectRoot, `${name}.json`);
17
+ else if ((0, node_fs.existsSync)((0, __stryke_path_join.joinPaths)(context.workspaceConfig.workspaceRoot, context.config.projectRoot, `${name}.jsonc`))) return (0, __stryke_path_join.joinPaths)(context.workspaceConfig.workspaceRoot, context.config.projectRoot, `${name}.jsonc`);
18
+ else if ((0, node_fs.existsSync)((0, __stryke_path_join.joinPaths)(context.workspaceConfig.workspaceRoot, context.config.projectRoot, `${name}.ts`))) return (0, __stryke_path_join.joinPaths)(context.workspaceConfig.workspaceRoot, context.config.projectRoot, `${name}.ts`);
19
+ else if ((0, node_fs.existsSync)((0, __stryke_path_join.joinPaths)(context.workspaceConfig.workspaceRoot, context.config.projectRoot, `${name}.cts`))) return (0, __stryke_path_join.joinPaths)(context.workspaceConfig.workspaceRoot, context.config.projectRoot, `${name}.cts`);
20
+ else if ((0, node_fs.existsSync)((0, __stryke_path_join.joinPaths)(context.workspaceConfig.workspaceRoot, context.config.projectRoot, `${name}.mts`))) return (0, __stryke_path_join.joinPaths)(context.workspaceConfig.workspaceRoot, context.config.projectRoot, `${name}.mts`);
21
+ else if ((0, node_fs.existsSync)((0, __stryke_path_join.joinPaths)(context.workspaceConfig.workspaceRoot, context.config.projectRoot, `${name}.js`))) return (0, __stryke_path_join.joinPaths)(context.workspaceConfig.workspaceRoot, context.config.projectRoot, `${name}.js`);
22
+ else if ((0, node_fs.existsSync)((0, __stryke_path_join.joinPaths)(context.workspaceConfig.workspaceRoot, context.config.projectRoot, `${name}.cjs`))) return (0, __stryke_path_join.joinPaths)(context.workspaceConfig.workspaceRoot, context.config.projectRoot, `${name}.cjs`);
23
+ else if ((0, node_fs.existsSync)((0, __stryke_path_join.joinPaths)(context.workspaceConfig.workspaceRoot, context.config.projectRoot, `${name}.mjs`))) return (0, __stryke_path_join.joinPaths)(context.workspaceConfig.workspaceRoot, context.config.projectRoot, `${name}.mjs`);
24
+ else if ((0, node_fs.existsSync)((0, __stryke_path_join.joinPaths)(context.workspaceConfig.workspaceRoot, context.config.projectRoot, `${name}.config.ts`))) return (0, __stryke_path_join.joinPaths)(context.workspaceConfig.workspaceRoot, context.config.projectRoot, `${name}.config.ts`);
25
+ else if ((0, node_fs.existsSync)((0, __stryke_path_join.joinPaths)(context.workspaceConfig.workspaceRoot, context.config.projectRoot, `${name}.config.cts`))) return (0, __stryke_path_join.joinPaths)(context.workspaceConfig.workspaceRoot, context.config.projectRoot, `${name}.config.cts`);
26
+ else if ((0, node_fs.existsSync)((0, __stryke_path_join.joinPaths)(context.workspaceConfig.workspaceRoot, context.config.projectRoot, `${name}.config.mts`))) return (0, __stryke_path_join.joinPaths)(context.workspaceConfig.workspaceRoot, context.config.projectRoot, `${name}.config.mts`);
27
+ else if ((0, node_fs.existsSync)((0, __stryke_path_join.joinPaths)(context.workspaceConfig.workspaceRoot, context.config.projectRoot, `${name}.config.js`))) return (0, __stryke_path_join.joinPaths)(context.workspaceConfig.workspaceRoot, context.config.projectRoot, `${name}.config.js`);
28
+ else if ((0, node_fs.existsSync)((0, __stryke_path_join.joinPaths)(context.workspaceConfig.workspaceRoot, context.config.projectRoot, `${name}.config.cjs`))) return (0, __stryke_path_join.joinPaths)(context.workspaceConfig.workspaceRoot, context.config.projectRoot, `${name}.config.cjs`);
29
+ else if ((0, node_fs.existsSync)((0, __stryke_path_join.joinPaths)(context.workspaceConfig.workspaceRoot, context.config.projectRoot, `${name}.config.mjs`))) return (0, __stryke_path_join.joinPaths)(context.workspaceConfig.workspaceRoot, context.config.projectRoot, `${name}.config.mjs`);
30
+ else if ((0, node_fs.existsSync)((0, __stryke_path_join.joinPaths)(context.workspaceConfig.workspaceRoot, `${name}.yml`))) return (0, __stryke_path_join.joinPaths)(context.workspaceConfig.workspaceRoot, `${name}.yml`);
31
+ else if ((0, node_fs.existsSync)((0, __stryke_path_join.joinPaths)(context.workspaceConfig.workspaceRoot, `${name}.yaml`))) return (0, __stryke_path_join.joinPaths)(context.workspaceConfig.workspaceRoot, `${name}.yaml`);
32
+ else if ((0, node_fs.existsSync)((0, __stryke_path_join.joinPaths)(context.workspaceConfig.workspaceRoot, `${name}.json`))) return (0, __stryke_path_join.joinPaths)(context.workspaceConfig.workspaceRoot, `${name}.json`);
33
+ else if ((0, node_fs.existsSync)((0, __stryke_path_join.joinPaths)(context.workspaceConfig.workspaceRoot, `${name}.jsonc`))) return (0, __stryke_path_join.joinPaths)(context.workspaceConfig.workspaceRoot, `${name}.jsonc`);
34
+ else if ((0, node_fs.existsSync)((0, __stryke_path_join.joinPaths)(context.workspaceConfig.workspaceRoot, `${name}.ts`))) return (0, __stryke_path_join.joinPaths)(context.workspaceConfig.workspaceRoot, `${name}.ts`);
35
+ else if ((0, node_fs.existsSync)((0, __stryke_path_join.joinPaths)(context.workspaceConfig.workspaceRoot, `${name}.cts`))) return (0, __stryke_path_join.joinPaths)(context.workspaceConfig.workspaceRoot, `${name}.cts`);
36
+ else if ((0, node_fs.existsSync)((0, __stryke_path_join.joinPaths)(context.workspaceConfig.workspaceRoot, `${name}.mts`))) return (0, __stryke_path_join.joinPaths)(context.workspaceConfig.workspaceRoot, `${name}.mts`);
37
+ else if ((0, node_fs.existsSync)((0, __stryke_path_join.joinPaths)(context.workspaceConfig.workspaceRoot, `${name}.js`))) return (0, __stryke_path_join.joinPaths)(context.workspaceConfig.workspaceRoot, `${name}.js`);
38
+ else if ((0, node_fs.existsSync)((0, __stryke_path_join.joinPaths)(context.workspaceConfig.workspaceRoot, `${name}.cjs`))) return (0, __stryke_path_join.joinPaths)(context.workspaceConfig.workspaceRoot, `${name}.cjs`);
39
+ else if ((0, node_fs.existsSync)((0, __stryke_path_join.joinPaths)(context.workspaceConfig.workspaceRoot, `${name}.mjs`))) return (0, __stryke_path_join.joinPaths)(context.workspaceConfig.workspaceRoot, `${name}.mjs`);
40
+ else if ((0, node_fs.existsSync)((0, __stryke_path_join.joinPaths)(context.workspaceConfig.workspaceRoot, `${name}.config.ts`))) return (0, __stryke_path_join.joinPaths)(context.workspaceConfig.workspaceRoot, `${name}.config.ts`);
41
+ else if ((0, node_fs.existsSync)((0, __stryke_path_join.joinPaths)(context.workspaceConfig.workspaceRoot, `${name}.config.cts`))) return (0, __stryke_path_join.joinPaths)(context.workspaceConfig.workspaceRoot, `${name}.config.cts`);
42
+ else if ((0, node_fs.existsSync)((0, __stryke_path_join.joinPaths)(context.workspaceConfig.workspaceRoot, `${name}.config.mts`))) return (0, __stryke_path_join.joinPaths)(context.workspaceConfig.workspaceRoot, `${name}.config.mts`);
43
+ else if ((0, node_fs.existsSync)((0, __stryke_path_join.joinPaths)(context.workspaceConfig.workspaceRoot, `${name}.config.js`))) return (0, __stryke_path_join.joinPaths)(context.workspaceConfig.workspaceRoot, `${name}.config.js`);
44
+ else if ((0, node_fs.existsSync)((0, __stryke_path_join.joinPaths)(context.workspaceConfig.workspaceRoot, `${name}.config.cjs`))) return (0, __stryke_path_join.joinPaths)(context.workspaceConfig.workspaceRoot, `${name}.config.cjs`);
45
+ else if ((0, node_fs.existsSync)((0, __stryke_path_join.joinPaths)(context.workspaceConfig.workspaceRoot, `${name}.config.mjs`))) return (0, __stryke_path_join.joinPaths)(context.workspaceConfig.workspaceRoot, `${name}.config.mjs`);
46
+ }
47
+
48
+ //#endregion
49
+ exports.getConfigPath = getConfigPath;
@@ -1 +1,48 @@
1
- import{joinPaths as e}from"@stryke/path/join";import{existsSync as t}from"node:fs";function n(n,r){if(t(e(n.workspaceConfig.workspaceRoot,n.config.projectRoot,`${r}.yml`)))return e(n.workspaceConfig.workspaceRoot,n.config.projectRoot,`${r}.yml`);if(t(e(n.workspaceConfig.workspaceRoot,n.config.projectRoot,`${r}.yaml`)))return e(n.workspaceConfig.workspaceRoot,n.config.projectRoot,`${r}.yaml`);if(t(e(n.workspaceConfig.workspaceRoot,n.config.projectRoot,`${r}.json`)))return e(n.workspaceConfig.workspaceRoot,n.config.projectRoot,`${r}.json`);if(t(e(n.workspaceConfig.workspaceRoot,n.config.projectRoot,`${r}.jsonc`)))return e(n.workspaceConfig.workspaceRoot,n.config.projectRoot,`${r}.jsonc`);if(t(e(n.workspaceConfig.workspaceRoot,n.config.projectRoot,`${r}.ts`)))return e(n.workspaceConfig.workspaceRoot,n.config.projectRoot,`${r}.ts`);if(t(e(n.workspaceConfig.workspaceRoot,n.config.projectRoot,`${r}.cts`)))return e(n.workspaceConfig.workspaceRoot,n.config.projectRoot,`${r}.cts`);if(t(e(n.workspaceConfig.workspaceRoot,n.config.projectRoot,`${r}.mts`)))return e(n.workspaceConfig.workspaceRoot,n.config.projectRoot,`${r}.mts`);if(t(e(n.workspaceConfig.workspaceRoot,n.config.projectRoot,`${r}.js`)))return e(n.workspaceConfig.workspaceRoot,n.config.projectRoot,`${r}.js`);if(t(e(n.workspaceConfig.workspaceRoot,n.config.projectRoot,`${r}.cjs`)))return e(n.workspaceConfig.workspaceRoot,n.config.projectRoot,`${r}.cjs`);if(t(e(n.workspaceConfig.workspaceRoot,n.config.projectRoot,`${r}.mjs`)))return e(n.workspaceConfig.workspaceRoot,n.config.projectRoot,`${r}.mjs`);if(t(e(n.workspaceConfig.workspaceRoot,n.config.projectRoot,`${r}.config.ts`)))return e(n.workspaceConfig.workspaceRoot,n.config.projectRoot,`${r}.config.ts`);if(t(e(n.workspaceConfig.workspaceRoot,n.config.projectRoot,`${r}.config.cts`)))return e(n.workspaceConfig.workspaceRoot,n.config.projectRoot,`${r}.config.cts`);if(t(e(n.workspaceConfig.workspaceRoot,n.config.projectRoot,`${r}.config.mts`)))return e(n.workspaceConfig.workspaceRoot,n.config.projectRoot,`${r}.config.mts`);if(t(e(n.workspaceConfig.workspaceRoot,n.config.projectRoot,`${r}.config.js`)))return e(n.workspaceConfig.workspaceRoot,n.config.projectRoot,`${r}.config.js`);if(t(e(n.workspaceConfig.workspaceRoot,n.config.projectRoot,`${r}.config.cjs`)))return e(n.workspaceConfig.workspaceRoot,n.config.projectRoot,`${r}.config.cjs`);if(t(e(n.workspaceConfig.workspaceRoot,n.config.projectRoot,`${r}.config.mjs`)))return e(n.workspaceConfig.workspaceRoot,n.config.projectRoot,`${r}.config.mjs`);if(t(e(n.workspaceConfig.workspaceRoot,`${r}.yml`)))return e(n.workspaceConfig.workspaceRoot,`${r}.yml`);if(t(e(n.workspaceConfig.workspaceRoot,`${r}.yaml`)))return e(n.workspaceConfig.workspaceRoot,`${r}.yaml`);if(t(e(n.workspaceConfig.workspaceRoot,`${r}.json`)))return e(n.workspaceConfig.workspaceRoot,`${r}.json`);if(t(e(n.workspaceConfig.workspaceRoot,`${r}.jsonc`)))return e(n.workspaceConfig.workspaceRoot,`${r}.jsonc`);if(t(e(n.workspaceConfig.workspaceRoot,`${r}.ts`)))return e(n.workspaceConfig.workspaceRoot,`${r}.ts`);if(t(e(n.workspaceConfig.workspaceRoot,`${r}.cts`)))return e(n.workspaceConfig.workspaceRoot,`${r}.cts`);if(t(e(n.workspaceConfig.workspaceRoot,`${r}.mts`)))return e(n.workspaceConfig.workspaceRoot,`${r}.mts`);if(t(e(n.workspaceConfig.workspaceRoot,`${r}.js`)))return e(n.workspaceConfig.workspaceRoot,`${r}.js`);if(t(e(n.workspaceConfig.workspaceRoot,`${r}.cjs`)))return e(n.workspaceConfig.workspaceRoot,`${r}.cjs`);if(t(e(n.workspaceConfig.workspaceRoot,`${r}.mjs`)))return e(n.workspaceConfig.workspaceRoot,`${r}.mjs`);if(t(e(n.workspaceConfig.workspaceRoot,`${r}.config.ts`)))return e(n.workspaceConfig.workspaceRoot,`${r}.config.ts`);if(t(e(n.workspaceConfig.workspaceRoot,`${r}.config.cts`)))return e(n.workspaceConfig.workspaceRoot,`${r}.config.cts`);if(t(e(n.workspaceConfig.workspaceRoot,`${r}.config.mts`)))return e(n.workspaceConfig.workspaceRoot,`${r}.config.mts`);if(t(e(n.workspaceConfig.workspaceRoot,`${r}.config.js`)))return e(n.workspaceConfig.workspaceRoot,`${r}.config.js`);if(t(e(n.workspaceConfig.workspaceRoot,`${r}.config.cjs`)))return e(n.workspaceConfig.workspaceRoot,`${r}.config.cjs`);if(t(e(n.workspaceConfig.workspaceRoot,`${r}.config.mjs`)))return e(n.workspaceConfig.workspaceRoot,`${r}.config.mjs`)}export{n as getConfigPath};
1
+ import { joinPaths } from "@stryke/path/join";
2
+ import { existsSync } from "node:fs";
3
+
4
+ //#region ../powerlines/src/plugin-utils/get-config-path.ts
5
+ /**
6
+ * Get the configuration file path for a given name.
7
+ *
8
+ * @param context - The Powerlines context.
9
+ * @param name - The name of the configuration file (without extension).
10
+ * @returns The absolute path to the configuration file, or undefined if not found.
11
+ */
12
+ function getConfigPath(context, name) {
13
+ if (existsSync(joinPaths(context.workspaceConfig.workspaceRoot, context.config.projectRoot, `${name}.yml`))) return joinPaths(context.workspaceConfig.workspaceRoot, context.config.projectRoot, `${name}.yml`);
14
+ else if (existsSync(joinPaths(context.workspaceConfig.workspaceRoot, context.config.projectRoot, `${name}.yaml`))) return joinPaths(context.workspaceConfig.workspaceRoot, context.config.projectRoot, `${name}.yaml`);
15
+ else if (existsSync(joinPaths(context.workspaceConfig.workspaceRoot, context.config.projectRoot, `${name}.json`))) return joinPaths(context.workspaceConfig.workspaceRoot, context.config.projectRoot, `${name}.json`);
16
+ else if (existsSync(joinPaths(context.workspaceConfig.workspaceRoot, context.config.projectRoot, `${name}.jsonc`))) return joinPaths(context.workspaceConfig.workspaceRoot, context.config.projectRoot, `${name}.jsonc`);
17
+ else if (existsSync(joinPaths(context.workspaceConfig.workspaceRoot, context.config.projectRoot, `${name}.ts`))) return joinPaths(context.workspaceConfig.workspaceRoot, context.config.projectRoot, `${name}.ts`);
18
+ else if (existsSync(joinPaths(context.workspaceConfig.workspaceRoot, context.config.projectRoot, `${name}.cts`))) return joinPaths(context.workspaceConfig.workspaceRoot, context.config.projectRoot, `${name}.cts`);
19
+ else if (existsSync(joinPaths(context.workspaceConfig.workspaceRoot, context.config.projectRoot, `${name}.mts`))) return joinPaths(context.workspaceConfig.workspaceRoot, context.config.projectRoot, `${name}.mts`);
20
+ else if (existsSync(joinPaths(context.workspaceConfig.workspaceRoot, context.config.projectRoot, `${name}.js`))) return joinPaths(context.workspaceConfig.workspaceRoot, context.config.projectRoot, `${name}.js`);
21
+ else if (existsSync(joinPaths(context.workspaceConfig.workspaceRoot, context.config.projectRoot, `${name}.cjs`))) return joinPaths(context.workspaceConfig.workspaceRoot, context.config.projectRoot, `${name}.cjs`);
22
+ else if (existsSync(joinPaths(context.workspaceConfig.workspaceRoot, context.config.projectRoot, `${name}.mjs`))) return joinPaths(context.workspaceConfig.workspaceRoot, context.config.projectRoot, `${name}.mjs`);
23
+ else if (existsSync(joinPaths(context.workspaceConfig.workspaceRoot, context.config.projectRoot, `${name}.config.ts`))) return joinPaths(context.workspaceConfig.workspaceRoot, context.config.projectRoot, `${name}.config.ts`);
24
+ else if (existsSync(joinPaths(context.workspaceConfig.workspaceRoot, context.config.projectRoot, `${name}.config.cts`))) return joinPaths(context.workspaceConfig.workspaceRoot, context.config.projectRoot, `${name}.config.cts`);
25
+ else if (existsSync(joinPaths(context.workspaceConfig.workspaceRoot, context.config.projectRoot, `${name}.config.mts`))) return joinPaths(context.workspaceConfig.workspaceRoot, context.config.projectRoot, `${name}.config.mts`);
26
+ else if (existsSync(joinPaths(context.workspaceConfig.workspaceRoot, context.config.projectRoot, `${name}.config.js`))) return joinPaths(context.workspaceConfig.workspaceRoot, context.config.projectRoot, `${name}.config.js`);
27
+ else if (existsSync(joinPaths(context.workspaceConfig.workspaceRoot, context.config.projectRoot, `${name}.config.cjs`))) return joinPaths(context.workspaceConfig.workspaceRoot, context.config.projectRoot, `${name}.config.cjs`);
28
+ else if (existsSync(joinPaths(context.workspaceConfig.workspaceRoot, context.config.projectRoot, `${name}.config.mjs`))) return joinPaths(context.workspaceConfig.workspaceRoot, context.config.projectRoot, `${name}.config.mjs`);
29
+ else if (existsSync(joinPaths(context.workspaceConfig.workspaceRoot, `${name}.yml`))) return joinPaths(context.workspaceConfig.workspaceRoot, `${name}.yml`);
30
+ else if (existsSync(joinPaths(context.workspaceConfig.workspaceRoot, `${name}.yaml`))) return joinPaths(context.workspaceConfig.workspaceRoot, `${name}.yaml`);
31
+ else if (existsSync(joinPaths(context.workspaceConfig.workspaceRoot, `${name}.json`))) return joinPaths(context.workspaceConfig.workspaceRoot, `${name}.json`);
32
+ else if (existsSync(joinPaths(context.workspaceConfig.workspaceRoot, `${name}.jsonc`))) return joinPaths(context.workspaceConfig.workspaceRoot, `${name}.jsonc`);
33
+ else if (existsSync(joinPaths(context.workspaceConfig.workspaceRoot, `${name}.ts`))) return joinPaths(context.workspaceConfig.workspaceRoot, `${name}.ts`);
34
+ else if (existsSync(joinPaths(context.workspaceConfig.workspaceRoot, `${name}.cts`))) return joinPaths(context.workspaceConfig.workspaceRoot, `${name}.cts`);
35
+ else if (existsSync(joinPaths(context.workspaceConfig.workspaceRoot, `${name}.mts`))) return joinPaths(context.workspaceConfig.workspaceRoot, `${name}.mts`);
36
+ else if (existsSync(joinPaths(context.workspaceConfig.workspaceRoot, `${name}.js`))) return joinPaths(context.workspaceConfig.workspaceRoot, `${name}.js`);
37
+ else if (existsSync(joinPaths(context.workspaceConfig.workspaceRoot, `${name}.cjs`))) return joinPaths(context.workspaceConfig.workspaceRoot, `${name}.cjs`);
38
+ else if (existsSync(joinPaths(context.workspaceConfig.workspaceRoot, `${name}.mjs`))) return joinPaths(context.workspaceConfig.workspaceRoot, `${name}.mjs`);
39
+ else if (existsSync(joinPaths(context.workspaceConfig.workspaceRoot, `${name}.config.ts`))) return joinPaths(context.workspaceConfig.workspaceRoot, `${name}.config.ts`);
40
+ else if (existsSync(joinPaths(context.workspaceConfig.workspaceRoot, `${name}.config.cts`))) return joinPaths(context.workspaceConfig.workspaceRoot, `${name}.config.cts`);
41
+ else if (existsSync(joinPaths(context.workspaceConfig.workspaceRoot, `${name}.config.mts`))) return joinPaths(context.workspaceConfig.workspaceRoot, `${name}.config.mts`);
42
+ else if (existsSync(joinPaths(context.workspaceConfig.workspaceRoot, `${name}.config.js`))) return joinPaths(context.workspaceConfig.workspaceRoot, `${name}.config.js`);
43
+ else if (existsSync(joinPaths(context.workspaceConfig.workspaceRoot, `${name}.config.cjs`))) return joinPaths(context.workspaceConfig.workspaceRoot, `${name}.config.cjs`);
44
+ else if (existsSync(joinPaths(context.workspaceConfig.workspaceRoot, `${name}.config.mjs`))) return joinPaths(context.workspaceConfig.workspaceRoot, `${name}.config.mjs`);
45
+ }
46
+
47
+ //#endregion
48
+ export { getConfigPath };