@powerlines/plugin-prisma 0.2.75 → 0.2.77
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/client/client.gen.cjs +8 -175
- package/dist/api/client/client.gen.mjs +7 -174
- package/dist/api/client/index.cjs +18 -13
- package/dist/api/client/index.mjs +10 -5
- package/dist/api/client/utils.gen.cjs +13 -186
- package/dist/api/client/utils.gen.mjs +5 -178
- package/dist/api/client.gen.cjs +12 -8
- package/dist/api/client.gen.mjs +11 -7
- package/dist/api/core/auth.gen.cjs +2 -11
- package/dist/api/core/auth.gen.mjs +1 -9
- package/dist/api/core/bodySerializer.gen.cjs +4 -34
- package/dist/api/core/bodySerializer.gen.mjs +1 -30
- package/dist/api/core/params.gen.cjs +2 -64
- package/dist/api/core/params.gen.mjs +1 -62
- package/dist/api/core/pathSerializer.gen.cjs +7 -86
- package/dist/api/core/pathSerializer.gen.mjs +1 -79
- package/dist/api/core/queryKeySerializer.gen.cjs +4 -65
- package/dist/api/core/queryKeySerializer.gen.mjs +1 -61
- package/dist/api/core/serverSentEvents.gen.cjs +2 -94
- package/dist/api/core/serverSentEvents.gen.mjs +1 -92
- package/dist/api/core/utils.gen.cjs +6 -80
- package/dist/api/core/utils.gen.mjs +2 -76
- package/dist/api/sdk.gen.cjs +13 -255
- package/dist/api/sdk.gen.mjs +12 -254
- package/dist/api/types.gen.cjs +1 -0
- package/dist/api/types.gen.mjs +2 -0
- package/dist/auth.gen-BFteuMTV.cjs +17 -0
- package/dist/auth.gen-C4FxE4_3.mjs +11 -0
- package/dist/bodySerializer.gen-BLtxkFoA.cjs +50 -0
- package/dist/bodySerializer.gen-DBXNewIA.mjs +32 -0
- package/dist/client-BlRUW8mL.mjs +1 -0
- package/dist/client-DBAc9HV1.cjs +0 -0
- package/dist/client.gen-COMS1glH.mjs +8 -0
- package/dist/client.gen-CPQm4WCv.mjs +176 -0
- package/dist/client.gen-DPSMNZNm.cjs +181 -0
- package/dist/client.gen-JhYC1fDf.cjs +13 -0
- package/dist/get-schema-CKw6MiKb.mjs +78 -0
- package/dist/get-schema-CqMBOHOd.cjs +118 -0
- package/dist/helpers/get-schema.cjs +2 -80
- package/dist/helpers/get-schema.mjs +1 -76
- package/dist/helpers/index.cjs +6 -6
- package/dist/helpers/index.mjs +3 -3
- package/dist/helpers/prisma-postgres.cjs +2 -15
- package/dist/helpers/prisma-postgres.mjs +1 -13
- package/dist/helpers/schema-creator.cjs +2 -60
- package/dist/helpers/schema-creator.mjs +1 -58
- package/dist/index.cjs +107 -20
- package/dist/index.mjs +96 -8
- package/dist/params.gen-BM1l95BD.mjs +64 -0
- package/dist/params.gen-BtCSnwiV.cjs +70 -0
- package/dist/pathSerializer.gen-BEbuI0Vn.cjs +117 -0
- package/dist/pathSerializer.gen-m7BRzH23.mjs +81 -0
- package/dist/plugin-DE9fKOLA.cjs +0 -0
- package/dist/plugin-EFmNQLKA.mjs +1 -0
- package/dist/prisma-BzQJneyW.cjs +0 -0
- package/dist/prisma-CB-m5c-j.mjs +1 -0
- package/dist/prisma-postgres-CAOpTtWq.mjs +15 -0
- package/dist/prisma-postgres-dGaLzxF3.cjs +21 -0
- package/dist/queryKeySerializer.gen-4TWHHXn3.cjs +81 -0
- package/dist/queryKeySerializer.gen-BMMZAjVN.mjs +63 -0
- package/dist/schema-creator-Cfian3ih.mjs +60 -0
- package/dist/schema-creator-zmlwh4-l.cjs +66 -0
- package/dist/sdk.gen-B2his2jD.mjs +256 -0
- package/dist/sdk.gen-CAWIQ8BM.cjs +261 -0
- package/dist/serverSentEvents.gen-C4apQvDl.mjs +94 -0
- package/dist/serverSentEvents.gen-CiMMmhyQ.cjs +100 -0
- package/dist/types/index.cjs +3 -0
- package/dist/types/index.mjs +4 -0
- package/dist/types/plugin.cjs +1 -0
- package/dist/types/plugin.mjs +2 -0
- package/dist/types/prisma.cjs +1 -0
- package/dist/types/prisma.mjs +2 -0
- package/dist/types-CmY9-4ff.cjs +0 -0
- package/dist/types-Dbwx-Khg.mjs +1 -0
- package/dist/types.gen-BN-p9nVT.cjs +0 -0
- package/dist/types.gen-CS2KiRfG.mjs +1 -0
- package/dist/utils.gen-Bk2pTkV1.cjs +101 -0
- package/dist/utils.gen-C-7sZa7Z.mjs +180 -0
- package/dist/utils.gen-DATakax-.cjs +227 -0
- package/dist/utils.gen-RO8GxC4i.mjs +78 -0
- package/package.json +6 -6
- package/dist/_virtual/rolldown_runtime.cjs +0 -29
- package/dist/powerlines/src/plugin-utils/get-config-path.cjs +0 -49
- package/dist/powerlines/src/plugin-utils/get-config-path.mjs +0 -48
- package/dist/powerlines/src/plugin-utils/paths.cjs +0 -36
- package/dist/powerlines/src/plugin-utils/paths.mjs +0 -35
|
@@ -1,78 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import prismaSchemaWasm from "@prisma/prisma-schema-wasm";
|
|
3
|
-
import * as E from "fp-ts/Either";
|
|
4
|
-
import { pipe } from "fp-ts/lib/function";
|
|
5
|
-
import { match } from "ts-pattern";
|
|
1
|
+
import { t as getSchema } from "../get-schema-CKw6MiKb.mjs";
|
|
6
2
|
|
|
7
|
-
//#region src/helpers/get-schema.ts
|
|
8
|
-
async function resolveBinaryTargets(generator) {
|
|
9
|
-
for (const binaryTarget of generator.binaryTargets) {
|
|
10
|
-
if (binaryTarget.fromEnvVar && process.env[binaryTarget.fromEnvVar]) {
|
|
11
|
-
const value = JSON.parse(process.env[binaryTarget.fromEnvVar]);
|
|
12
|
-
if (Array.isArray(value)) {
|
|
13
|
-
generator.binaryTargets = value.map((v) => ({
|
|
14
|
-
fromEnvVar: null,
|
|
15
|
-
value: v
|
|
16
|
-
}));
|
|
17
|
-
await resolveBinaryTargets(generator);
|
|
18
|
-
} else binaryTarget.value = value;
|
|
19
|
-
}
|
|
20
|
-
if (binaryTarget.value === "native") {
|
|
21
|
-
binaryTarget.value = await getBinaryTargetForCurrentPlatform();
|
|
22
|
-
binaryTarget.native = true;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
if (generator.binaryTargets.length === 0) generator.binaryTargets = [{
|
|
26
|
-
fromEnvVar: null,
|
|
27
|
-
value: await getBinaryTargetForCurrentPlatform(),
|
|
28
|
-
native: true
|
|
29
|
-
}];
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* Retrieves the Prisma schema using the provided options.
|
|
33
|
-
*
|
|
34
|
-
* @param options - The options to customize the schema retrieval.
|
|
35
|
-
* @returns The Prisma schema.
|
|
36
|
-
*/
|
|
37
|
-
async function getSchema(options) {
|
|
38
|
-
const configEither = pipe(E.tryCatch(() => {
|
|
39
|
-
if (process.env.FORCE_PANIC_QUERY_ENGINE_GET_CONFIG) prismaSchemaWasm.debug_panic();
|
|
40
|
-
const params = JSON.stringify({
|
|
41
|
-
prismaSchema: options.datamodel,
|
|
42
|
-
datasourceOverrides: {},
|
|
43
|
-
ignoreEnvVarErrors: options.ignoreEnvVarErrors ?? false,
|
|
44
|
-
env: process.env
|
|
45
|
-
});
|
|
46
|
-
return prismaSchemaWasm.get_config(params);
|
|
47
|
-
}, (e) => ({
|
|
48
|
-
type: "wasm-error",
|
|
49
|
-
reason: "(get-config wasm)",
|
|
50
|
-
error: e
|
|
51
|
-
})), E.map((result) => ({ result })), E.chainW(({ result }) => E.tryCatch(() => JSON.parse(result), (e) => ({
|
|
52
|
-
type: "parse-json",
|
|
53
|
-
reason: "Unable to parse JSON",
|
|
54
|
-
error: e
|
|
55
|
-
}))), E.chainW((response) => {
|
|
56
|
-
if (response.errors.length > 0) return E.left({
|
|
57
|
-
type: "validation-error",
|
|
58
|
-
reason: "(get-config wasm)",
|
|
59
|
-
error: response.errors
|
|
60
|
-
});
|
|
61
|
-
return E.right(response.config);
|
|
62
|
-
}));
|
|
63
|
-
if (E.isRight(configEither)) {
|
|
64
|
-
const { right: data } = configEither;
|
|
65
|
-
for (const generator of data.generators) await resolveBinaryTargets(generator);
|
|
66
|
-
return Promise.resolve(data);
|
|
67
|
-
}
|
|
68
|
-
throw match(configEither.left).with({ type: "wasm-error" }, (e) => {
|
|
69
|
-
return /* @__PURE__ */ new Error(`Prisma get-config Wasm runtime error: ${e.error.message}`);
|
|
70
|
-
}).with({ type: "validation-error" }, (e) => {
|
|
71
|
-
return /* @__PURE__ */ new Error(`Prisma get-config validation error: ${e.error.map((err) => err.message).join(", ")}`);
|
|
72
|
-
}).otherwise((e) => {
|
|
73
|
-
return /* @__PURE__ */ new Error(`Prisma get-config unknown error: ${e.reason} - ${e.error.message}`);
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
//#endregion
|
|
78
3
|
export { getSchema };
|
package/dist/helpers/index.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
const
|
|
2
|
-
const
|
|
3
|
-
const
|
|
1
|
+
const require_get_schema = require('../get-schema-CqMBOHOd.cjs');
|
|
2
|
+
const require_schema_creator = require('../schema-creator-zmlwh4-l.cjs');
|
|
3
|
+
const require_prisma_postgres = require('../prisma-postgres-dGaLzxF3.cjs');
|
|
4
4
|
|
|
5
|
-
exports.PrismaSchemaCreator =
|
|
6
|
-
exports.findDatabaseByName =
|
|
7
|
-
exports.getSchema =
|
|
5
|
+
exports.PrismaSchemaCreator = require_schema_creator.PrismaSchemaCreator;
|
|
6
|
+
exports.findDatabaseByName = require_prisma_postgres.findDatabaseByName;
|
|
7
|
+
exports.getSchema = require_get_schema.getSchema;
|
package/dist/helpers/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { getSchema } from "
|
|
2
|
-
import { PrismaSchemaCreator } from "
|
|
3
|
-
import { findDatabaseByName } from "
|
|
1
|
+
import { t as getSchema } from "../get-schema-CKw6MiKb.mjs";
|
|
2
|
+
import { t as PrismaSchemaCreator } from "../schema-creator-Cfian3ih.mjs";
|
|
3
|
+
import { t as findDatabaseByName } from "../prisma-postgres-CAOpTtWq.mjs";
|
|
4
4
|
|
|
5
5
|
export { PrismaSchemaCreator, findDatabaseByName, getSchema };
|
|
@@ -1,16 +1,3 @@
|
|
|
1
|
+
const require_prisma_postgres = require('../prisma-postgres-dGaLzxF3.cjs');
|
|
1
2
|
|
|
2
|
-
|
|
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;
|
|
3
|
+
exports.findDatabaseByName = require_prisma_postgres.findDatabaseByName;
|
|
@@ -1,15 +1,3 @@
|
|
|
1
|
-
|
|
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
|
-
}
|
|
1
|
+
import { t as findDatabaseByName } from "../prisma-postgres-CAOpTtWq.mjs";
|
|
13
2
|
|
|
14
|
-
//#endregion
|
|
15
3
|
export { findDatabaseByName };
|
|
@@ -1,61 +1,3 @@
|
|
|
1
|
-
const
|
|
2
|
-
let prisma_util_schema_creator = require("prisma-util/schema-creator");
|
|
1
|
+
const require_schema_creator = require('../schema-creator-zmlwh4-l.cjs');
|
|
3
2
|
|
|
4
|
-
|
|
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
|
-
}` : ""}
|
|
50
|
-
}
|
|
51
|
-
|
|
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;
|
|
3
|
+
exports.PrismaSchemaCreator = require_schema_creator.PrismaSchemaCreator;
|
|
@@ -1,60 +1,3 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { t as PrismaSchemaCreator } from "../schema-creator-Cfian3ih.mjs";
|
|
2
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
|
-
}` : ""}
|
|
49
|
-
}
|
|
50
|
-
|
|
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
3
|
export { PrismaSchemaCreator };
|
package/dist/index.cjs
CHANGED
|
@@ -1,21 +1,108 @@
|
|
|
1
1
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
2
|
-
const
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
|
|
2
|
+
const require_get_schema = require('./get-schema-CqMBOHOd.cjs');
|
|
3
|
+
require('./serverSentEvents.gen-CiMMmhyQ.cjs');
|
|
4
|
+
require('./pathSerializer.gen-BEbuI0Vn.cjs');
|
|
5
|
+
require('./utils.gen-Bk2pTkV1.cjs');
|
|
6
|
+
require('./auth.gen-BFteuMTV.cjs');
|
|
7
|
+
require('./bodySerializer.gen-BLtxkFoA.cjs');
|
|
8
|
+
const require_utils_gen$1 = require('./utils.gen-DATakax-.cjs');
|
|
9
|
+
const require_client_gen = require('./client.gen-DPSMNZNm.cjs');
|
|
10
|
+
require('./params.gen-BtCSnwiV.cjs');
|
|
11
|
+
require('./queryKeySerializer.gen-4TWHHXn3.cjs');
|
|
12
|
+
require('./client-DBAc9HV1.cjs');
|
|
13
|
+
const require_client_gen$1 = require('./client.gen-JhYC1fDf.cjs');
|
|
14
|
+
const require_sdk_gen = require('./sdk.gen-CAWIQ8BM.cjs');
|
|
15
|
+
const require_schema_creator = require('./schema-creator-zmlwh4-l.cjs');
|
|
16
|
+
require('./types.gen-BN-p9nVT.cjs');
|
|
17
|
+
require('./plugin-DE9fKOLA.cjs');
|
|
18
|
+
require('./prisma-BzQJneyW.cjs');
|
|
19
|
+
require('./types-CmY9-4ff.cjs');
|
|
11
20
|
let __stryke_cli_execute = require("@stryke/cli/execute");
|
|
12
21
|
let __stryke_fs_exists = require("@stryke/fs/exists");
|
|
13
22
|
let __stryke_fs_package_fns = require("@stryke/fs/package-fns");
|
|
14
23
|
let __stryke_path_join_paths = require("@stryke/path/join-paths");
|
|
15
24
|
let __stryke_path_replace = require("@stryke/path/replace");
|
|
16
25
|
let defu = require("defu");
|
|
17
|
-
defu =
|
|
26
|
+
defu = require_get_schema.__toESM(defu);
|
|
27
|
+
let __stryke_path_join = require("@stryke/path/join");
|
|
28
|
+
let node_fs = require("node:fs");
|
|
18
29
|
|
|
30
|
+
//#region ../powerlines/src/plugin-utils/get-config-path.ts
|
|
31
|
+
/**
|
|
32
|
+
* Get the configuration file path for a given name.
|
|
33
|
+
*
|
|
34
|
+
* @param context - The Powerlines context.
|
|
35
|
+
* @param name - The name of the configuration file (without extension).
|
|
36
|
+
* @returns The absolute path to the configuration file, or undefined if not found.
|
|
37
|
+
*/
|
|
38
|
+
function getConfigPath(context, name) {
|
|
39
|
+
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`);
|
|
40
|
+
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`);
|
|
41
|
+
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`);
|
|
42
|
+
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`);
|
|
43
|
+
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`);
|
|
44
|
+
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`);
|
|
45
|
+
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`);
|
|
46
|
+
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`);
|
|
47
|
+
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`);
|
|
48
|
+
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`);
|
|
49
|
+
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`);
|
|
50
|
+
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`);
|
|
51
|
+
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`);
|
|
52
|
+
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`);
|
|
53
|
+
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`);
|
|
54
|
+
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`);
|
|
55
|
+
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`);
|
|
56
|
+
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`);
|
|
57
|
+
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`);
|
|
58
|
+
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`);
|
|
59
|
+
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`);
|
|
60
|
+
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`);
|
|
61
|
+
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`);
|
|
62
|
+
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`);
|
|
63
|
+
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`);
|
|
64
|
+
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`);
|
|
65
|
+
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`);
|
|
66
|
+
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`);
|
|
67
|
+
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`);
|
|
68
|
+
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`);
|
|
69
|
+
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`);
|
|
70
|
+
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`);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
//#endregion
|
|
74
|
+
//#region ../powerlines/src/plugin-utils/paths.ts
|
|
75
|
+
/**
|
|
76
|
+
* Replaces tokens in the given path string with their corresponding values from the context.
|
|
77
|
+
*
|
|
78
|
+
* @remarks
|
|
79
|
+
* The following tokens are supported:
|
|
80
|
+
* - `{workspaceRoot}` - The root directory of the workspace.
|
|
81
|
+
* - `{root}` - The root directory of the project (same as `{projectRoot}`).
|
|
82
|
+
* - `{projectRoot}` - The root directory of the project (same as `{root}`).
|
|
83
|
+
* - `{sourceRoot}` - The source root directory of the project (usually `./src`).
|
|
84
|
+
* - `{powerlinesPath}` - The directory where Powerlines is installed.
|
|
85
|
+
* - `{cachePath}` - The environment's directory for cached files.
|
|
86
|
+
* - `{dataPath}` - The environment's directory for data files.
|
|
87
|
+
* - `{logPath}` - The environment's directory for log files.
|
|
88
|
+
* - `{tempPath}` - The environment's directory for temporary files.
|
|
89
|
+
* - `{configPath}` - The environment's directory for configuration files.
|
|
90
|
+
* - `{outputPath}` - The configured output directory for the project.
|
|
91
|
+
* - `{buildPath}` - The configured distribution directory for the project.
|
|
92
|
+
* - `{artifactsPath}` - The configured directory for build artifacts.
|
|
93
|
+
* - `{builtinPath}` - The configured directory for generated built-in plugins.
|
|
94
|
+
* - `{entryPath}` - The configured directory for generated entry files.
|
|
95
|
+
*
|
|
96
|
+
* @param context - The context containing the values for the path tokens.
|
|
97
|
+
* @param path - The path string with tokens to replace.
|
|
98
|
+
* @returns The path string with tokens replaced by their corresponding values from the context.
|
|
99
|
+
*/
|
|
100
|
+
function replacePathTokens(context, path) {
|
|
101
|
+
if (!path) return path;
|
|
102
|
+
return path.replaceAll("{workspaceRoot}", context.workspaceConfig.workspaceRoot).replaceAll("{root}", context.config.projectRoot).replaceAll("{projectRoot}", context.config.projectRoot).replaceAll("{sourceRoot}", context.config.sourceRoot).replaceAll("{powerlinesPath}", context.powerlinesPath).replaceAll("{cachePath}", context.cachePath).replaceAll("{dataPath}", context.dataPath).replaceAll("{logPath}", context.envPaths.log).replaceAll("{tempPath}", context.envPaths.temp).replaceAll("{configPath}", context.envPaths.config).replaceAll("{outputPath}", context.config.output.outputPath).replaceAll("{buildPath}", context.config.output.buildPath).replaceAll("{artifactsPath}", (0, __stryke_path_replace.replacePath)(context.artifactsPath, context.workspaceConfig.workspaceRoot)).replaceAll("{builtinPath}", (0, __stryke_path_replace.replacePath)(context.builtinsPath, context.workspaceConfig.workspaceRoot)).replaceAll("{entryPath}", (0, __stryke_path_replace.replacePath)(context.entryPath, context.workspaceConfig.workspaceRoot));
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
//#endregion
|
|
19
106
|
//#region src/index.ts
|
|
20
107
|
/**
|
|
21
108
|
* A Powerlines plugin to integrate Prisma for code generation.
|
|
@@ -29,7 +116,7 @@ const plugin = (options = {}) => {
|
|
|
29
116
|
config() {
|
|
30
117
|
return { prisma: (0, defu.default)(options, {
|
|
31
118
|
schema: (0, __stryke_path_join_paths.joinPaths)(this.config.projectRoot, "prisma", "schema.prisma"),
|
|
32
|
-
configFile: options.configFile ||
|
|
119
|
+
configFile: options.configFile || getConfigPath(this, "prisma.config"),
|
|
33
120
|
outputPath: (0, __stryke_path_join_paths.joinPaths)("{builtinPath}", "prisma"),
|
|
34
121
|
prismaPostgres: options?.prismaPostgres ? {
|
|
35
122
|
projectId: this.config.name,
|
|
@@ -39,9 +126,9 @@ const plugin = (options = {}) => {
|
|
|
39
126
|
},
|
|
40
127
|
async configResolved() {
|
|
41
128
|
this.dependencies["@prisma/client"] = "latest";
|
|
42
|
-
this.config.prisma.configFile =
|
|
129
|
+
this.config.prisma.configFile = replacePathTokens(this, this.config.prisma.configFile);
|
|
43
130
|
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 =
|
|
131
|
+
this.config.prisma.schema = replacePathTokens(this, this.config.prisma.schema);
|
|
45
132
|
if (this.config.prisma.prismaPostgres) {
|
|
46
133
|
let serviceToken = process.env.PRISMA_SERVICE_TOKEN;
|
|
47
134
|
if (!serviceToken) {
|
|
@@ -49,7 +136,7 @@ const plugin = (options = {}) => {
|
|
|
49
136
|
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
137
|
else throw new Error("Unable to determine the Prisma service token. Please set the `PRISMA_SERVICE_TOKEN` environment variable.");
|
|
51
138
|
}
|
|
52
|
-
const client$1 =
|
|
139
|
+
const client$1 = require_client_gen.createClient(require_utils_gen$1.createConfig({
|
|
53
140
|
baseUrl: "https://api.prisma.io",
|
|
54
141
|
throwOnError: true,
|
|
55
142
|
headers: {
|
|
@@ -57,7 +144,7 @@ const plugin = (options = {}) => {
|
|
|
57
144
|
"User-Agent": "powerlines/1.0"
|
|
58
145
|
}
|
|
59
146
|
}));
|
|
60
|
-
this.prisma.api = new
|
|
147
|
+
this.prisma.api = new require_sdk_gen.PrismaClient({ client: client$1 });
|
|
61
148
|
await this.prisma.api.createDatabase({
|
|
62
149
|
path: { projectId: this.config.prisma.prismaPostgres.projectId },
|
|
63
150
|
body: {
|
|
@@ -68,14 +155,14 @@ const plugin = (options = {}) => {
|
|
|
68
155
|
}).then((response) => response.data.data);
|
|
69
156
|
}
|
|
70
157
|
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 =
|
|
158
|
+
this.config.prisma.outputPath = replacePathTokens(this, this.config.prisma.outputPath);
|
|
72
159
|
this.prisma ??= {};
|
|
73
160
|
if (!(0, __stryke_fs_exists.existsSync)(this.config.prisma.schema)) this.prisma.schema ??= {
|
|
74
161
|
generators: [],
|
|
75
162
|
datasources: [],
|
|
76
163
|
warnings: []
|
|
77
164
|
};
|
|
78
|
-
else this.prisma.schema = await
|
|
165
|
+
else this.prisma.schema = await require_get_schema.getSchema({ datamodel: this.config.prisma.schema });
|
|
79
166
|
const generator = this.prisma.schema.generators.find((gen) => gen.provider.value === "prisma-client-js");
|
|
80
167
|
if (!generator) this.prisma.schema.generators.push({
|
|
81
168
|
name: "prisma-client-js",
|
|
@@ -96,7 +183,7 @@ const plugin = (options = {}) => {
|
|
|
96
183
|
value: this.config.prisma.outputPath,
|
|
97
184
|
fromEnvVar: null
|
|
98
185
|
};
|
|
99
|
-
this.prisma.builder = new
|
|
186
|
+
this.prisma.builder = new require_schema_creator.PrismaSchemaCreator(this);
|
|
100
187
|
},
|
|
101
188
|
async prepare() {
|
|
102
189
|
await this.prisma.builder.write();
|
|
@@ -121,7 +208,7 @@ const plugin = (options = {}) => {
|
|
|
121
208
|
var src_default = plugin;
|
|
122
209
|
|
|
123
210
|
//#endregion
|
|
124
|
-
exports.PrismaClient =
|
|
125
|
-
exports.client =
|
|
211
|
+
exports.PrismaClient = require_sdk_gen.PrismaClient;
|
|
212
|
+
exports.client = require_client_gen$1.client;
|
|
126
213
|
exports.default = src_default;
|
|
127
214
|
exports.plugin = plugin;
|
package/dist/index.mjs
CHANGED
|
@@ -1,18 +1,106 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import
|
|
1
|
+
import "./serverSentEvents.gen-C4apQvDl.mjs";
|
|
2
|
+
import "./pathSerializer.gen-m7BRzH23.mjs";
|
|
3
|
+
import "./utils.gen-RO8GxC4i.mjs";
|
|
4
|
+
import "./auth.gen-C4FxE4_3.mjs";
|
|
5
|
+
import "./bodySerializer.gen-DBXNewIA.mjs";
|
|
6
|
+
import { n as createConfig } from "./utils.gen-C-7sZa7Z.mjs";
|
|
7
|
+
import { t as createClient } from "./client.gen-CPQm4WCv.mjs";
|
|
8
|
+
import "./params.gen-BM1l95BD.mjs";
|
|
9
|
+
import "./queryKeySerializer.gen-BMMZAjVN.mjs";
|
|
10
|
+
import "./client-BlRUW8mL.mjs";
|
|
11
|
+
import { t as client } from "./client.gen-COMS1glH.mjs";
|
|
12
|
+
import { t as PrismaClient } from "./sdk.gen-B2his2jD.mjs";
|
|
13
|
+
import { t as getSchema } from "./get-schema-CKw6MiKb.mjs";
|
|
14
|
+
import { t as PrismaSchemaCreator } from "./schema-creator-Cfian3ih.mjs";
|
|
15
|
+
import "./types.gen-CS2KiRfG.mjs";
|
|
16
|
+
import "./plugin-EFmNQLKA.mjs";
|
|
17
|
+
import "./prisma-CB-m5c-j.mjs";
|
|
18
|
+
import "./types-Dbwx-Khg.mjs";
|
|
9
19
|
import { execute, executePackage } from "@stryke/cli/execute";
|
|
10
20
|
import { existsSync } from "@stryke/fs/exists";
|
|
11
21
|
import { isPackageListed } from "@stryke/fs/package-fns";
|
|
12
22
|
import { joinPaths } from "@stryke/path/join-paths";
|
|
13
23
|
import { replacePath } from "@stryke/path/replace";
|
|
14
24
|
import defu from "defu";
|
|
25
|
+
import { joinPaths as joinPaths$1 } from "@stryke/path/join";
|
|
26
|
+
import { existsSync as existsSync$1 } from "node:fs";
|
|
15
27
|
|
|
28
|
+
//#region ../powerlines/src/plugin-utils/get-config-path.ts
|
|
29
|
+
/**
|
|
30
|
+
* Get the configuration file path for a given name.
|
|
31
|
+
*
|
|
32
|
+
* @param context - The Powerlines context.
|
|
33
|
+
* @param name - The name of the configuration file (without extension).
|
|
34
|
+
* @returns The absolute path to the configuration file, or undefined if not found.
|
|
35
|
+
*/
|
|
36
|
+
function getConfigPath(context, name) {
|
|
37
|
+
if (existsSync$1(joinPaths$1(context.workspaceConfig.workspaceRoot, context.config.projectRoot, `${name}.yml`))) return joinPaths$1(context.workspaceConfig.workspaceRoot, context.config.projectRoot, `${name}.yml`);
|
|
38
|
+
else if (existsSync$1(joinPaths$1(context.workspaceConfig.workspaceRoot, context.config.projectRoot, `${name}.yaml`))) return joinPaths$1(context.workspaceConfig.workspaceRoot, context.config.projectRoot, `${name}.yaml`);
|
|
39
|
+
else if (existsSync$1(joinPaths$1(context.workspaceConfig.workspaceRoot, context.config.projectRoot, `${name}.json`))) return joinPaths$1(context.workspaceConfig.workspaceRoot, context.config.projectRoot, `${name}.json`);
|
|
40
|
+
else if (existsSync$1(joinPaths$1(context.workspaceConfig.workspaceRoot, context.config.projectRoot, `${name}.jsonc`))) return joinPaths$1(context.workspaceConfig.workspaceRoot, context.config.projectRoot, `${name}.jsonc`);
|
|
41
|
+
else if (existsSync$1(joinPaths$1(context.workspaceConfig.workspaceRoot, context.config.projectRoot, `${name}.ts`))) return joinPaths$1(context.workspaceConfig.workspaceRoot, context.config.projectRoot, `${name}.ts`);
|
|
42
|
+
else if (existsSync$1(joinPaths$1(context.workspaceConfig.workspaceRoot, context.config.projectRoot, `${name}.cts`))) return joinPaths$1(context.workspaceConfig.workspaceRoot, context.config.projectRoot, `${name}.cts`);
|
|
43
|
+
else if (existsSync$1(joinPaths$1(context.workspaceConfig.workspaceRoot, context.config.projectRoot, `${name}.mts`))) return joinPaths$1(context.workspaceConfig.workspaceRoot, context.config.projectRoot, `${name}.mts`);
|
|
44
|
+
else if (existsSync$1(joinPaths$1(context.workspaceConfig.workspaceRoot, context.config.projectRoot, `${name}.js`))) return joinPaths$1(context.workspaceConfig.workspaceRoot, context.config.projectRoot, `${name}.js`);
|
|
45
|
+
else if (existsSync$1(joinPaths$1(context.workspaceConfig.workspaceRoot, context.config.projectRoot, `${name}.cjs`))) return joinPaths$1(context.workspaceConfig.workspaceRoot, context.config.projectRoot, `${name}.cjs`);
|
|
46
|
+
else if (existsSync$1(joinPaths$1(context.workspaceConfig.workspaceRoot, context.config.projectRoot, `${name}.mjs`))) return joinPaths$1(context.workspaceConfig.workspaceRoot, context.config.projectRoot, `${name}.mjs`);
|
|
47
|
+
else if (existsSync$1(joinPaths$1(context.workspaceConfig.workspaceRoot, context.config.projectRoot, `${name}.config.ts`))) return joinPaths$1(context.workspaceConfig.workspaceRoot, context.config.projectRoot, `${name}.config.ts`);
|
|
48
|
+
else if (existsSync$1(joinPaths$1(context.workspaceConfig.workspaceRoot, context.config.projectRoot, `${name}.config.cts`))) return joinPaths$1(context.workspaceConfig.workspaceRoot, context.config.projectRoot, `${name}.config.cts`);
|
|
49
|
+
else if (existsSync$1(joinPaths$1(context.workspaceConfig.workspaceRoot, context.config.projectRoot, `${name}.config.mts`))) return joinPaths$1(context.workspaceConfig.workspaceRoot, context.config.projectRoot, `${name}.config.mts`);
|
|
50
|
+
else if (existsSync$1(joinPaths$1(context.workspaceConfig.workspaceRoot, context.config.projectRoot, `${name}.config.js`))) return joinPaths$1(context.workspaceConfig.workspaceRoot, context.config.projectRoot, `${name}.config.js`);
|
|
51
|
+
else if (existsSync$1(joinPaths$1(context.workspaceConfig.workspaceRoot, context.config.projectRoot, `${name}.config.cjs`))) return joinPaths$1(context.workspaceConfig.workspaceRoot, context.config.projectRoot, `${name}.config.cjs`);
|
|
52
|
+
else if (existsSync$1(joinPaths$1(context.workspaceConfig.workspaceRoot, context.config.projectRoot, `${name}.config.mjs`))) return joinPaths$1(context.workspaceConfig.workspaceRoot, context.config.projectRoot, `${name}.config.mjs`);
|
|
53
|
+
else if (existsSync$1(joinPaths$1(context.workspaceConfig.workspaceRoot, `${name}.yml`))) return joinPaths$1(context.workspaceConfig.workspaceRoot, `${name}.yml`);
|
|
54
|
+
else if (existsSync$1(joinPaths$1(context.workspaceConfig.workspaceRoot, `${name}.yaml`))) return joinPaths$1(context.workspaceConfig.workspaceRoot, `${name}.yaml`);
|
|
55
|
+
else if (existsSync$1(joinPaths$1(context.workspaceConfig.workspaceRoot, `${name}.json`))) return joinPaths$1(context.workspaceConfig.workspaceRoot, `${name}.json`);
|
|
56
|
+
else if (existsSync$1(joinPaths$1(context.workspaceConfig.workspaceRoot, `${name}.jsonc`))) return joinPaths$1(context.workspaceConfig.workspaceRoot, `${name}.jsonc`);
|
|
57
|
+
else if (existsSync$1(joinPaths$1(context.workspaceConfig.workspaceRoot, `${name}.ts`))) return joinPaths$1(context.workspaceConfig.workspaceRoot, `${name}.ts`);
|
|
58
|
+
else if (existsSync$1(joinPaths$1(context.workspaceConfig.workspaceRoot, `${name}.cts`))) return joinPaths$1(context.workspaceConfig.workspaceRoot, `${name}.cts`);
|
|
59
|
+
else if (existsSync$1(joinPaths$1(context.workspaceConfig.workspaceRoot, `${name}.mts`))) return joinPaths$1(context.workspaceConfig.workspaceRoot, `${name}.mts`);
|
|
60
|
+
else if (existsSync$1(joinPaths$1(context.workspaceConfig.workspaceRoot, `${name}.js`))) return joinPaths$1(context.workspaceConfig.workspaceRoot, `${name}.js`);
|
|
61
|
+
else if (existsSync$1(joinPaths$1(context.workspaceConfig.workspaceRoot, `${name}.cjs`))) return joinPaths$1(context.workspaceConfig.workspaceRoot, `${name}.cjs`);
|
|
62
|
+
else if (existsSync$1(joinPaths$1(context.workspaceConfig.workspaceRoot, `${name}.mjs`))) return joinPaths$1(context.workspaceConfig.workspaceRoot, `${name}.mjs`);
|
|
63
|
+
else if (existsSync$1(joinPaths$1(context.workspaceConfig.workspaceRoot, `${name}.config.ts`))) return joinPaths$1(context.workspaceConfig.workspaceRoot, `${name}.config.ts`);
|
|
64
|
+
else if (existsSync$1(joinPaths$1(context.workspaceConfig.workspaceRoot, `${name}.config.cts`))) return joinPaths$1(context.workspaceConfig.workspaceRoot, `${name}.config.cts`);
|
|
65
|
+
else if (existsSync$1(joinPaths$1(context.workspaceConfig.workspaceRoot, `${name}.config.mts`))) return joinPaths$1(context.workspaceConfig.workspaceRoot, `${name}.config.mts`);
|
|
66
|
+
else if (existsSync$1(joinPaths$1(context.workspaceConfig.workspaceRoot, `${name}.config.js`))) return joinPaths$1(context.workspaceConfig.workspaceRoot, `${name}.config.js`);
|
|
67
|
+
else if (existsSync$1(joinPaths$1(context.workspaceConfig.workspaceRoot, `${name}.config.cjs`))) return joinPaths$1(context.workspaceConfig.workspaceRoot, `${name}.config.cjs`);
|
|
68
|
+
else if (existsSync$1(joinPaths$1(context.workspaceConfig.workspaceRoot, `${name}.config.mjs`))) return joinPaths$1(context.workspaceConfig.workspaceRoot, `${name}.config.mjs`);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
//#endregion
|
|
72
|
+
//#region ../powerlines/src/plugin-utils/paths.ts
|
|
73
|
+
/**
|
|
74
|
+
* Replaces tokens in the given path string with their corresponding values from the context.
|
|
75
|
+
*
|
|
76
|
+
* @remarks
|
|
77
|
+
* The following tokens are supported:
|
|
78
|
+
* - `{workspaceRoot}` - The root directory of the workspace.
|
|
79
|
+
* - `{root}` - The root directory of the project (same as `{projectRoot}`).
|
|
80
|
+
* - `{projectRoot}` - The root directory of the project (same as `{root}`).
|
|
81
|
+
* - `{sourceRoot}` - The source root directory of the project (usually `./src`).
|
|
82
|
+
* - `{powerlinesPath}` - The directory where Powerlines is installed.
|
|
83
|
+
* - `{cachePath}` - The environment's directory for cached files.
|
|
84
|
+
* - `{dataPath}` - The environment's directory for data files.
|
|
85
|
+
* - `{logPath}` - The environment's directory for log files.
|
|
86
|
+
* - `{tempPath}` - The environment's directory for temporary files.
|
|
87
|
+
* - `{configPath}` - The environment's directory for configuration files.
|
|
88
|
+
* - `{outputPath}` - The configured output directory for the project.
|
|
89
|
+
* - `{buildPath}` - The configured distribution directory for the project.
|
|
90
|
+
* - `{artifactsPath}` - The configured directory for build artifacts.
|
|
91
|
+
* - `{builtinPath}` - The configured directory for generated built-in plugins.
|
|
92
|
+
* - `{entryPath}` - The configured directory for generated entry files.
|
|
93
|
+
*
|
|
94
|
+
* @param context - The context containing the values for the path tokens.
|
|
95
|
+
* @param path - The path string with tokens to replace.
|
|
96
|
+
* @returns The path string with tokens replaced by their corresponding values from the context.
|
|
97
|
+
*/
|
|
98
|
+
function replacePathTokens(context, path) {
|
|
99
|
+
if (!path) return path;
|
|
100
|
+
return path.replaceAll("{workspaceRoot}", context.workspaceConfig.workspaceRoot).replaceAll("{root}", context.config.projectRoot).replaceAll("{projectRoot}", context.config.projectRoot).replaceAll("{sourceRoot}", context.config.sourceRoot).replaceAll("{powerlinesPath}", context.powerlinesPath).replaceAll("{cachePath}", context.cachePath).replaceAll("{dataPath}", context.dataPath).replaceAll("{logPath}", context.envPaths.log).replaceAll("{tempPath}", context.envPaths.temp).replaceAll("{configPath}", context.envPaths.config).replaceAll("{outputPath}", context.config.output.outputPath).replaceAll("{buildPath}", context.config.output.buildPath).replaceAll("{artifactsPath}", replacePath(context.artifactsPath, context.workspaceConfig.workspaceRoot)).replaceAll("{builtinPath}", replacePath(context.builtinsPath, context.workspaceConfig.workspaceRoot)).replaceAll("{entryPath}", replacePath(context.entryPath, context.workspaceConfig.workspaceRoot));
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
//#endregion
|
|
16
104
|
//#region src/index.ts
|
|
17
105
|
/**
|
|
18
106
|
* A Powerlines plugin to integrate Prisma for code generation.
|