@prisma/orm-toolchain 8.0.0-rc.3-dev.7 → 8.0.0-rc.3-dev.8
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/{aggregate-CPZB020V.mjs → aggregate-BOlLu7k7.mjs} +8 -8
- package/dist/{aggregate-CPZB020V.mjs.map → aggregate-BOlLu7k7.mjs.map} +1 -1
- package/dist/cli-telemetry.d.mts +2 -2
- package/dist/cli-telemetry.mjs +9 -12
- package/dist/cli-telemetry.mjs.map +1 -1
- package/dist/cli.d.mts +1 -5
- package/dist/cli.d.mts.map +1 -1
- package/dist/cli.mjs +117 -58
- package/dist/cli.mjs.map +1 -1
- package/dist/cli__control-api.d.mts +3 -3
- package/dist/cli__control-api.d.mts.map +1 -1
- package/dist/cli__control-api.mjs +1 -1
- package/dist/cli__control-api__testing.d.mts +1 -1
- package/dist/cli__migration-cli.mjs +5 -5
- package/dist/cli__migration-cli.mjs.map +1 -1
- package/dist/config-loader.d.mts +1 -1
- package/dist/config-loader.mjs +1 -1
- package/dist/{contract-snapshot-store-B0G1Fw_F-CHc4QfKb.mjs → contract-snapshot-store-BAmQkHe5-BJFpuIQQ.mjs} +3 -3
- package/dist/{contract-snapshot-store-B0G1Fw_F-CHc4QfKb.mjs.map → contract-snapshot-store-BAmQkHe5-BJFpuIQQ.mjs.map} +1 -1
- package/dist/{db-verify-BwgNK50T-DGvKgFCK.d.mts → db-verify-BRDzImLV-3eI346zy.d.mts} +3 -3
- package/dist/{db-verify-BwgNK50T-DGvKgFCK.d.mts.map → db-verify-BRDzImLV-3eI346zy.d.mts.map} +1 -1
- package/dist/emitter.mjs +1 -1
- package/dist/{errors-CXbGUWGu-CstQHPh6.mjs → errors-CcEpbfnE-CsSXrttT.mjs} +6 -6
- package/dist/errors-CcEpbfnE-CsSXrttT.mjs.map +1 -0
- package/dist/{exports-DLDFkjNv.mjs → exports-CN1Qe98l.mjs} +3 -3
- package/dist/{exports-DLDFkjNv.mjs.map → exports-CN1Qe98l.mjs.map} +1 -1
- package/dist/{exports-UjssmDwy.mjs → exports-Cv8nMmBT.mjs} +15 -51
- package/dist/exports-Cv8nMmBT.mjs.map +1 -0
- package/dist/{exports-BCLg4CiV-05kuwcb0.mjs → exports-Dw2WIX63-CQgI2e_L.mjs} +6 -6
- package/dist/exports-Dw2WIX63-CQgI2e_L.mjs.map +1 -0
- package/dist/{graph-membership-BViWUMpP-C4lYYJdU.mjs → graph-membership-BoITerZB-C2-x1Qp6.mjs} +3 -3
- package/dist/{graph-membership-BViWUMpP-C4lYYJdU.mjs.map → graph-membership-BoITerZB-C2-x1Qp6.mjs.map} +1 -1
- package/dist/{import-roots-CfoYgejL.d.mts → import-roots-ARK1wjzc.d.mts} +3 -3
- package/dist/{import-roots-CfoYgejL.d.mts.map → import-roots-ARK1wjzc.d.mts.map} +1 -1
- package/dist/{import-roots-CNFBPAT1.mjs → import-roots-D0H8HuRw.mjs} +3 -3
- package/dist/import-roots-D0H8HuRw.mjs.map +1 -0
- package/dist/{index-BRjNSwL-.d.mts → index-u5RdrumF.d.mts} +2 -10
- package/dist/index-u5RdrumF.d.mts.map +1 -0
- package/dist/{invariants-CTHy88OP-CYI2a8IO.mjs → invariants-DcFfhJMZ-BHDWZP9k.mjs} +3 -3
- package/dist/{invariants-CTHy88OP-CYI2a8IO.mjs.map → invariants-DcFfhJMZ-BHDWZP9k.mjs.map} +1 -1
- package/dist/{io-635GlNx1-D3zrw2qu.mjs → io-DsViRB_O-Ci1kJGBg.mjs} +5 -5
- package/dist/{io-635GlNx1-D3zrw2qu.mjs.map → io-DsViRB_O-Ci1kJGBg.mjs.map} +1 -1
- package/dist/{migration-BB4LDjuS.mjs → migration-CWSj4pMr.mjs} +3 -3
- package/dist/{migration-BB4LDjuS.mjs.map → migration-CWSj4pMr.mjs.map} +1 -1
- package/dist/{migration-graph-_SJImD5V-BURyY1KM.mjs → migration-graph-DwXAHP6T-NgmP2DNz.mjs} +3 -3
- package/dist/{migration-graph-_SJImD5V-BURyY1KM.mjs.map → migration-graph-DwXAHP6T-NgmP2DNz.mjs.map} +1 -1
- package/dist/migration-tools.d.mts +1 -1
- package/dist/migration-tools.mjs +12 -12
- package/dist/migration-tools__aggregate.mjs +1 -1
- package/dist/migration-tools__contract-snapshot-store.mjs +1 -1
- package/dist/migration-tools__errors.mjs +1 -1
- package/dist/migration-tools__invariants.mjs +1 -1
- package/dist/migration-tools__io.mjs +1 -1
- package/dist/migration-tools__migration-graph.mjs +2 -2
- package/dist/migration-tools__migration.mjs +1 -1
- package/dist/migration-tools__ref-resolution.mjs +1 -1
- package/dist/migration-tools__refs.mjs +1 -1
- package/dist/migration-tools__spaces.d.mts +1 -1
- package/dist/migration-tools__spaces.mjs +2 -2
- package/dist/publish-surface.d.mts +1 -1
- package/dist/publish-surface.mjs +1 -1
- package/dist/publish-surface__import-roots.d.mts +1 -1
- package/dist/publish-surface__import-roots.mjs +1 -1
- package/dist/quick-reference-postgres.md +1 -1
- package/dist/{ref-BSRf-7Uh-JmET-ptm.mjs → ref-dWFulULw-TMeX1ZM1.mjs} +16 -16
- package/dist/ref-dWFulULw-TMeX1ZM1.mjs.map +1 -0
- package/dist/{ref-resolution-HeNBXW53.mjs → ref-resolution-Cbdejrwt.mjs} +2 -2
- package/dist/{ref-resolution-HeNBXW53.mjs.map → ref-resolution-Cbdejrwt.mjs.map} +1 -1
- package/dist/{refs-WK86uYYp-gM8tvWQP.mjs → refs-KVVlm3lE-BcqdpdYD.mjs} +6 -6
- package/dist/refs-KVVlm3lE-BcqdpdYD.mjs.map +1 -0
- package/dist/{spaces-Dj65JrwZ.d.mts → spaces-B20bgxF9.d.mts} +2 -2
- package/dist/{spaces-Dj65JrwZ.d.mts.map → spaces-B20bgxF9.d.mts.map} +1 -1
- package/dist/{spaces-4qMOAYE9.mjs → spaces-CHrjWRoZ.mjs} +7 -7
- package/dist/spaces-CHrjWRoZ.mjs.map +1 -0
- package/dist/{verify-contract-spaces-DhJTb0zM-B62maCfE.mjs → verify-contract-spaces-DomK5uP5-CyI3hD3Q.mjs} +7 -7
- package/dist/{verify-contract-spaces-DhJTb0zM-B62maCfE.mjs.map → verify-contract-spaces-DomK5uP5-CyI3hD3Q.mjs.map} +1 -1
- package/dist/vite-plugin-contract-emit.mjs +3 -3
- package/package.json +12 -12
- package/dist/errors-CXbGUWGu-CstQHPh6.mjs.map +0 -1
- package/dist/exports-BCLg4CiV-05kuwcb0.mjs.map +0 -1
- package/dist/exports-UjssmDwy.mjs.map +0 -1
- package/dist/import-roots-CNFBPAT1.mjs.map +0 -1
- package/dist/index-BRjNSwL-.d.mts.map +0 -1
- package/dist/ref-BSRf-7Uh-JmET-ptm.mjs.map +0 -1
- package/dist/refs-WK86uYYp-gM8tvWQP.mjs.map +0 -1
- package/dist/spaces-4qMOAYE9.mjs.map +0 -1
package/dist/cli.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { r as getEmittedArtifactPaths } from "./exports-
|
|
1
|
+
import { r as getEmittedArtifactPaths } from "./exports-Dw2WIX63-CQgI2e_L.mjs";
|
|
2
2
|
import { t as EMPTY_CONTRACT_HASH } from "./constants-CM-w38DQ-Cz_EXbOc.mjs";
|
|
3
|
-
import { c as spaceMigrationDirectory } from "./verify-contract-spaces-
|
|
4
|
-
import { i as createScaffoldSpecifierResolver } from "./import-roots-
|
|
5
|
-
import { $ as loadContractRawSafely, A as errorMigrationPlanningFailed, At as statusForMigrationHash, C as errorDestructiveChanges, Ct as resolveRefAdvancementFields, D as errorLegendHumanOnly, Dt as runMigrationCheck, E as errorHashMismatch, F as errorTargetMigrationNotSupported, H as executeMigrateShowPlan, I as errorTargetMismatch, J as executeRefSetCommand, K as executeRefDeleteCommand, L as errorUnexpected, M as errorPathUnreachable, Mt as toDeclaredExtensionsFromRaw, N as errorRunnerFailed, O as errorMarkerMissing, Ot as runMigrationList, P as errorRuntime, Q as loadAggregateIntegrityViolations, R as executeContractEmit, S as errorDatabaseConnectionRequired, St as resolveMigrationRef, T as errorFileNotFound, Tt as runCommandAction, U as executeMigrationNewCommand, W as executeMigrationPlanCommand, X as hasMigrationPath, Y as findPackageByDirPath, Z as listRefsByContractHash, _ as enumerateCheckSpaces, _t as requireLiveDatabase, at as maskConnectionUrl, b as errorContractArgConflict, bt as resolveContractRefToSnapshot, ct as readContractEnvelope, d as closeQuietly, dt as refuseContractSpaceIntegrity, et as loadContractSpaceAggregateForCli, gt as refuseUnknownInvariants, ht as refusePackageCorruptionOnAggregate, i as appliedHashesFromLedger, j as errorNoMigrations, jt as targetSupportsMigrations, k as errorMigrationPackageNotFound, kt as sanitizeErrorMessage, l as checkSingleTarget, lt as readContractIR, m as deriveStatusEdgeAnnotations, mt as refuseMissingInvariantPath, n as advanceRefSafely, nt as mapCaughtMigrationError, o as buildMigrationSpaceGraphEntries, ot as migrationSpaceListEntriesFromAggregate, p as createControlClient, pt as refuseMarkerOutsideGraph, q as executeRefListCommand, rt as mapContractAtError, s as buildReadAggregate, st as originHashForStatus, t as CliStructuredError$1$1, tt as looksLikePath, u as chooseAction, ut as readMigrationRefs, v as errorConfigValidation$1, vt as resolveAppTargetPath, w as errorDriverRequired, x as errorContractValidationFailed, y as errorConsentPlanMismatch, yt as resolveContractRef$1 } from "./ref-
|
|
3
|
+
import { c as spaceMigrationDirectory } from "./verify-contract-spaces-DomK5uP5-CyI3hD3Q.mjs";
|
|
4
|
+
import { i as createScaffoldSpecifierResolver } from "./import-roots-D0H8HuRw.mjs";
|
|
5
|
+
import { $ as loadContractRawSafely, A as errorMigrationPlanningFailed, At as statusForMigrationHash, C as errorDestructiveChanges, Ct as resolveRefAdvancementFields, D as errorLegendHumanOnly, Dt as runMigrationCheck, E as errorHashMismatch, F as errorTargetMigrationNotSupported, H as executeMigrateShowPlan, I as errorTargetMismatch, J as executeRefSetCommand, K as executeRefDeleteCommand, L as errorUnexpected, M as errorPathUnreachable, Mt as toDeclaredExtensionsFromRaw, N as errorRunnerFailed, O as errorMarkerMissing, Ot as runMigrationList, P as errorRuntime, Q as loadAggregateIntegrityViolations, R as executeContractEmit, S as errorDatabaseConnectionRequired, St as resolveMigrationRef, T as errorFileNotFound, Tt as runCommandAction, U as executeMigrationNewCommand, W as executeMigrationPlanCommand, X as hasMigrationPath, Y as findPackageByDirPath, Z as listRefsByContractHash, _ as enumerateCheckSpaces, _t as requireLiveDatabase, at as maskConnectionUrl, b as errorContractArgConflict, bt as resolveContractRefToSnapshot, ct as readContractEnvelope, d as closeQuietly, dt as refuseContractSpaceIntegrity, et as loadContractSpaceAggregateForCli, gt as refuseUnknownInvariants, ht as refusePackageCorruptionOnAggregate, i as appliedHashesFromLedger, j as errorNoMigrations, jt as targetSupportsMigrations, k as errorMigrationPackageNotFound, kt as sanitizeErrorMessage, l as checkSingleTarget, lt as readContractIR, m as deriveStatusEdgeAnnotations, mt as refuseMissingInvariantPath, n as advanceRefSafely, nt as mapCaughtMigrationError, o as buildMigrationSpaceGraphEntries, ot as migrationSpaceListEntriesFromAggregate, p as createControlClient, pt as refuseMarkerOutsideGraph, q as executeRefListCommand, rt as mapContractAtError, s as buildReadAggregate, st as originHashForStatus, t as CliStructuredError$1$1, tt as looksLikePath, u as chooseAction, ut as readMigrationRefs, v as errorConfigValidation$1, vt as resolveAppTargetPath, w as errorDriverRequired, x as errorContractValidationFailed, y as errorConsentPlanMismatch, yt as resolveContractRef$1 } from "./ref-dWFulULw-TMeX1ZM1.mjs";
|
|
6
6
|
import { n as buildNextSteps, t as InitOutputSchema } from "./output-CovTDY14-CUoAqLML.mjs";
|
|
7
|
-
import { r as loadConfig } from "./exports-
|
|
7
|
+
import { r as loadConfig, t as finalizeConfig } from "./exports-Cv8nMmBT.mjs";
|
|
8
8
|
import { createRequire } from "node:module";
|
|
9
9
|
import { existsSync, mkdirSync, readFileSync, rmSync, unlinkSync, writeFileSync } from "node:fs";
|
|
10
10
|
import { ifDefined } from "@prisma/orm-framework/utils/defined";
|
|
@@ -21,19 +21,19 @@ import { type } from "arktype";
|
|
|
21
21
|
import { defineCommand, defineCommandFamily, defineConfigSection, defineServerCommand, flag, positional } from "@prisma/cli-engine";
|
|
22
22
|
import { CliStructuredError as CliStructuredError$1, notOk as notOk$1, ok as ok$1 } from "@prisma/cli-engine/protocol";
|
|
23
23
|
import { collectConfigIssues } from "@prisma/orm-framework/config/config-validation";
|
|
24
|
+
import { DEFAULT_CONTRACT_SOURCE_DIR } from "@prisma/orm-framework/config/config-types";
|
|
25
|
+
import { pathToFileURL } from "node:url";
|
|
24
26
|
import { printPsl } from "@prisma/orm-framework/psl-printer";
|
|
25
27
|
import { EOL, tmpdir } from "node:os";
|
|
26
28
|
import { format } from "@prisma/orm-framework/psl-parser/format";
|
|
27
|
-
import { DEFAULT_CONTRACT_SOURCE_DIR } from "@prisma/orm-framework/config/config-types";
|
|
28
29
|
import { spawn } from "node:child_process";
|
|
29
30
|
import { detect } from "package-manager-detector/detect";
|
|
30
31
|
import { applyEdits, modify, parse, printParseErrorCode } from "jsonc-parser";
|
|
31
32
|
import stringWidth from "string-width";
|
|
32
33
|
import { bold, createColors, cyan, cyanBright, dim, green, yellow } from "colorette";
|
|
33
|
-
import { pathToFileURL } from "node:url";
|
|
34
34
|
import { build } from "esbuild";
|
|
35
|
-
//#region ../../../1-framework/3-tooling/cli/dist/load-config-
|
|
36
|
-
var version = "8.0.0-rc.3-dev.
|
|
35
|
+
//#region ../../../1-framework/3-tooling/cli/dist/load-config-CJf_3AeJ.mjs
|
|
36
|
+
var version = "8.0.0-rc.3-dev.8";
|
|
37
37
|
const MISSING_CONFIG_ACTION = {
|
|
38
38
|
kind: "run-command",
|
|
39
39
|
label: "Create a config file",
|
|
@@ -91,7 +91,7 @@ function unreadableDiagnostic(error) {
|
|
|
91
91
|
}]
|
|
92
92
|
};
|
|
93
93
|
}
|
|
94
|
-
function isRecord(value) {
|
|
94
|
+
function isRecord$1(value) {
|
|
95
95
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
96
96
|
}
|
|
97
97
|
/**
|
|
@@ -101,10 +101,10 @@ function isRecord(value) {
|
|
|
101
101
|
*/
|
|
102
102
|
function collectArtifactCollisionIssues(raw) {
|
|
103
103
|
const contract = raw["contract"];
|
|
104
|
-
if (!isRecord(contract)) return [];
|
|
104
|
+
if (!isRecord$1(contract)) return [];
|
|
105
105
|
const source = contract["source"];
|
|
106
106
|
const output = contract["output"];
|
|
107
|
-
if (!isRecord(source) || typeof output !== "string") return [];
|
|
107
|
+
if (!isRecord$1(source) || typeof output !== "string") return [];
|
|
108
108
|
const inputs = source["inputs"];
|
|
109
109
|
if (!Array.isArray(inputs)) return [];
|
|
110
110
|
let emitted;
|
|
@@ -130,7 +130,7 @@ function validate(raw) {
|
|
|
130
130
|
ok: false,
|
|
131
131
|
diagnostics: [sectionAbsentDiagnostic()]
|
|
132
132
|
};
|
|
133
|
-
if (!isRecord(raw)) return {
|
|
133
|
+
if (!isRecord$1(raw)) return {
|
|
134
134
|
ok: false,
|
|
135
135
|
diagnostics: [notAnObjectDiagnostic()]
|
|
136
136
|
};
|
|
@@ -249,12 +249,39 @@ function normalizeError(error) {
|
|
|
249
249
|
* Prisma Next rather than something the user did. Re-throwing lets the engine settle it as a bug
|
|
250
250
|
* at exit 1, where converting it would report the same number as a bad connection string.
|
|
251
251
|
*/
|
|
252
|
+
function isRecord(value) {
|
|
253
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
* Hands the handler a config whose paths are absolute. The engine's own
|
|
257
|
+
* loader evaluates `prisma.config.ts` without touching the paths inside it, so
|
|
258
|
+
* a command mounted in the unified host receives `contract.output` and
|
|
259
|
+
* `migrations.dir` exactly as authored — usually relative — while this repo's
|
|
260
|
+
* bin finalizes them in its loader. Anchoring here, on the section every ORM
|
|
261
|
+
* command reads, makes both hosts hand handlers the same absolute paths.
|
|
262
|
+
*
|
|
263
|
+
* The anchor is the working directory: the engine discovers the config in the
|
|
264
|
+
* working directory only, so that is the file's own directory. (A `--config`
|
|
265
|
+
* pointing into another directory is not visible from a command context; a
|
|
266
|
+
* relative path inside such a file resolves against the invocation directory,
|
|
267
|
+
* which is also what the file's author sees the command run from.)
|
|
268
|
+
* Finalization is idempotent — an already-absolute path resolves to itself —
|
|
269
|
+
* so a config that arrived finalized passes through unchanged.
|
|
270
|
+
*/
|
|
271
|
+
function finalizedConfigContext(ctx) {
|
|
272
|
+
if (!isRecord(ctx.config)) return ctx;
|
|
273
|
+
const config = blindCast(ctx.config);
|
|
274
|
+
return {
|
|
275
|
+
...ctx,
|
|
276
|
+
config: finalizeConfig(config, ctx.cwd)
|
|
277
|
+
};
|
|
278
|
+
}
|
|
252
279
|
function defineOrmCommand(def) {
|
|
253
280
|
return defineCommand({
|
|
254
281
|
...def,
|
|
255
282
|
handler: async (args, ctx) => {
|
|
256
283
|
try {
|
|
257
|
-
return await def.handler(args, ctx);
|
|
284
|
+
return await def.handler(args, finalizedConfigContext(ctx));
|
|
258
285
|
} catch (error) {
|
|
259
286
|
if (isInternalError(error)) throw error;
|
|
260
287
|
return notOk$1(normalizeError(error));
|
|
@@ -3283,40 +3310,40 @@ model Post {
|
|
|
3283
3310
|
function starterSchemaTsPostgres(builder) {
|
|
3284
3311
|
return `import { defineContract } from '${builder}';
|
|
3285
3312
|
|
|
3286
|
-
export const contract = defineContract(
|
|
3287
|
-
{
|
|
3288
|
-
|
|
3313
|
+
export const contract = defineContract({}, ({ field, model, rel }) => {
|
|
3314
|
+
const User = model('User', {
|
|
3315
|
+
fields: {
|
|
3316
|
+
id: field.id.uuidv7String(),
|
|
3317
|
+
email: field.text().unique(),
|
|
3318
|
+
username: field.text().optional(),
|
|
3319
|
+
name: field.text().optional(),
|
|
3320
|
+
createdAt: field.temporal.createdAt(),
|
|
3321
|
+
updatedAt: field.temporal.updatedAt(),
|
|
3322
|
+
},
|
|
3323
|
+
});
|
|
3324
|
+
|
|
3325
|
+
const Post = model('Post', {
|
|
3326
|
+
fields: {
|
|
3327
|
+
id: field.id.uuidv7String(),
|
|
3328
|
+
title: field.text(),
|
|
3329
|
+
content: field.text().optional(),
|
|
3330
|
+
authorId: field.uuidString(),
|
|
3331
|
+
createdAt: field.temporal.createdAt(),
|
|
3332
|
+
updatedAt: field.temporal.updatedAt(),
|
|
3333
|
+
},
|
|
3334
|
+
});
|
|
3335
|
+
|
|
3336
|
+
return {
|
|
3289
3337
|
models: {
|
|
3290
|
-
User:
|
|
3291
|
-
|
|
3292
|
-
id: field.id.uuidv7String(),
|
|
3293
|
-
email: field.text().unique(),
|
|
3294
|
-
username: field.text().optional(),
|
|
3295
|
-
name: field.text().optional(),
|
|
3296
|
-
createdAt: field.temporal.createdAt(),
|
|
3297
|
-
updatedAt: field.temporal.updatedAt(),
|
|
3298
|
-
},
|
|
3299
|
-
relations: {
|
|
3300
|
-
posts: rel.hasMany('Post', { by: 'authorId' }),
|
|
3301
|
-
},
|
|
3338
|
+
User: User.relations({
|
|
3339
|
+
posts: rel.hasMany(Post, { by: 'authorId' }),
|
|
3302
3340
|
}),
|
|
3303
|
-
|
|
3304
|
-
|
|
3305
|
-
fields: {
|
|
3306
|
-
id: field.id.uuidv7String(),
|
|
3307
|
-
title: field.text(),
|
|
3308
|
-
content: field.text().optional(),
|
|
3309
|
-
authorId: field.uuidString(),
|
|
3310
|
-
createdAt: field.temporal.createdAt(),
|
|
3311
|
-
updatedAt: field.temporal.updatedAt(),
|
|
3312
|
-
},
|
|
3313
|
-
relations: {
|
|
3314
|
-
author: rel.belongsTo('User', { from: 'authorId', to: 'id' }),
|
|
3315
|
-
},
|
|
3341
|
+
Post: Post.relations({
|
|
3342
|
+
author: rel.belongsTo(User, { from: 'authorId', to: 'id' }),
|
|
3316
3343
|
}),
|
|
3317
3344
|
},
|
|
3318
|
-
}
|
|
3319
|
-
);
|
|
3345
|
+
};
|
|
3346
|
+
});
|
|
3320
3347
|
`;
|
|
3321
3348
|
}
|
|
3322
3349
|
function starterSchemaTsMongo(builder) {
|
|
@@ -3373,7 +3400,8 @@ export default definePrismaConfig({
|
|
|
3373
3400
|
}
|
|
3374
3401
|
function dbFile(target, resolveImportSpecifier = keepInternalSpecifiers) {
|
|
3375
3402
|
const runtime = targetEntrypoint(target, "runtime", resolveImportSpecifier);
|
|
3376
|
-
if (target === "postgres") return `import
|
|
3403
|
+
if (target === "postgres") return `import 'dotenv/config';
|
|
3404
|
+
import postgres from '${runtime}';
|
|
3377
3405
|
import type { Contract } from './contract.d';
|
|
3378
3406
|
import contractJson from './contract.json' with { type: 'json' };
|
|
3379
3407
|
|
|
@@ -3382,7 +3410,8 @@ export const db = postgres<Contract>({
|
|
|
3382
3410
|
url: process.env['DATABASE_URL']!,
|
|
3383
3411
|
});
|
|
3384
3412
|
`;
|
|
3385
|
-
return `import
|
|
3413
|
+
return `import 'dotenv/config';
|
|
3414
|
+
import mongo from '${runtime}';
|
|
3386
3415
|
import type { Contract } from './contract.d';
|
|
3387
3416
|
import contractJson from './contract.json' with { type: 'json' };
|
|
3388
3417
|
|
|
@@ -4788,6 +4817,28 @@ function retriedWarning(failure) {
|
|
|
4788
4817
|
* command, and this decides — from the stderr it returned — that another
|
|
4789
4818
|
* manager is worth a try.
|
|
4790
4819
|
*/
|
|
4820
|
+
/**
|
|
4821
|
+
* The engine dependency spec a fresh scaffold installs. The scaffolded
|
|
4822
|
+
* `prisma.config.ts` imports `defineConfig` from `@prisma/cli-engine`, and the
|
|
4823
|
+
* installed `@prisma/cli` names the exact engine version it runs against — so
|
|
4824
|
+
* the spec is read from the manifest the install just placed, never guessed
|
|
4825
|
+
* from a dist-tag (whose `latest` has lagged that version before and broken
|
|
4826
|
+
* the very next command). A CLI without a readable engine entry falls back to
|
|
4827
|
+
* the `next` tag, the release train the CLI itself publishes under.
|
|
4828
|
+
*/
|
|
4829
|
+
function engineDevDependencySpec(cwd) {
|
|
4830
|
+
try {
|
|
4831
|
+
const manifest = JSON.parse(readFileSync(join(cwd, "node_modules", "@prisma", "cli", "package.json"), "utf-8"));
|
|
4832
|
+
if (typeof manifest === "object" && manifest !== null) for (const field of ["dependencies", "peerDependencies"]) {
|
|
4833
|
+
const block = Reflect.get(manifest, field);
|
|
4834
|
+
if (typeof block === "object" && block !== null) {
|
|
4835
|
+
const engine = Reflect.get(block, "@prisma/cli-engine");
|
|
4836
|
+
if (typeof engine === "string" && engine.length > 0) return `@prisma/cli-engine@${engine}`;
|
|
4837
|
+
}
|
|
4838
|
+
}
|
|
4839
|
+
} catch {}
|
|
4840
|
+
return "@prisma/cli-engine@next";
|
|
4841
|
+
}
|
|
4791
4842
|
async function installProjectDependencies(ctx) {
|
|
4792
4843
|
const pair = async (manager) => {
|
|
4793
4844
|
const runtimeDeps = await ctx.packages.install({
|
|
@@ -4950,7 +5001,7 @@ const createInitCommand = (injected) => defineOrmCommand({
|
|
|
4950
5001
|
text: note
|
|
4951
5002
|
});
|
|
4952
5003
|
const deps = [targetPackageName(inputs.target, scaffold.resolveImportSpecifier), "dotenv"];
|
|
4953
|
-
const cliDevDeps = ["@prisma/cli@next"
|
|
5004
|
+
const cliDevDeps = ["@prisma/cli@next"];
|
|
4954
5005
|
const devDeps = scaffold.hasTypesNode ? cliDevDeps : [...cliDevDeps, "@types/node"];
|
|
4955
5006
|
const findings = [];
|
|
4956
5007
|
const extraActions = [];
|
|
@@ -5017,6 +5068,19 @@ const createInitCommand = (injected) => defineOrmCommand({
|
|
|
5017
5068
|
findings.push(installFailedFinding(outcome.failure, scaffold.filesWritten));
|
|
5018
5069
|
return settle(4);
|
|
5019
5070
|
}
|
|
5071
|
+
const engineSpec = engineDevDependencySpec(ctx.cwd);
|
|
5072
|
+
const engineInstall = await ctx.packages.install({
|
|
5073
|
+
packages: [engineSpec],
|
|
5074
|
+
dev: true,
|
|
5075
|
+
cwd: ctx.cwd,
|
|
5076
|
+
...ifDefined("manager", outcome.manager)
|
|
5077
|
+
});
|
|
5078
|
+
if (!engineInstall.ok) {
|
|
5079
|
+
packagesInstalled = "failed";
|
|
5080
|
+
findings.push(installFailedFinding(engineInstall.failure, scaffold.filesWritten));
|
|
5081
|
+
return settle(4);
|
|
5082
|
+
}
|
|
5083
|
+
devDeps.push(engineSpec);
|
|
5020
5084
|
packagesInstalled = "installed";
|
|
5021
5085
|
installedManager = outcome.manager;
|
|
5022
5086
|
const emitStep = "Emit the contract";
|
|
@@ -5041,7 +5105,7 @@ const createInitCommand = (injected) => defineOrmCommand({
|
|
|
5041
5105
|
findings.push(emitFailedFinding(causeMessage(error), scaffold.filesWritten));
|
|
5042
5106
|
return settle(5);
|
|
5043
5107
|
}
|
|
5044
|
-
} else extraActions.push(chooseAction(`Install the project dependencies with your package manager: ${deps.join(", ")} (and ${devDeps.join(", ")} as development dependencies)`));
|
|
5108
|
+
} else extraActions.push(chooseAction(`Install the project dependencies with your package manager: ${deps.join(", ")} (and ${devDeps.join(", ")} plus @prisma/cli-engine at the version @prisma/cli declares as its peer, as development dependencies)`));
|
|
5045
5109
|
if (inputs.probeDb) {
|
|
5046
5110
|
const probe = probeWarning(await probeServerVersion({
|
|
5047
5111
|
baseDir: ctx.cwd,
|
|
@@ -5100,7 +5164,7 @@ const lspCommand = defineServerCommand({
|
|
|
5100
5164
|
} },
|
|
5101
5165
|
handler: async (args, io) => {
|
|
5102
5166
|
const exitCode = await withoutClientProcessIdInArgv(async () => {
|
|
5103
|
-
const { startServer } = await import("./exports-
|
|
5167
|
+
const { startServer } = await import("./exports-CN1Qe98l.mjs");
|
|
5104
5168
|
return startServer({
|
|
5105
5169
|
stdin: io.stdin,
|
|
5106
5170
|
stdout: io.stdout,
|
|
@@ -9534,8 +9598,6 @@ const ormCommandFamily = defineCommandFamily({
|
|
|
9534
9598
|
});
|
|
9535
9599
|
/** The file the ORM's loader reads when `--config` names none. */
|
|
9536
9600
|
const ORM_CONFIG_FILENAME = "prisma.config.ts";
|
|
9537
|
-
/** The pre-consolidation filename, still read as a deprecated fallback. */
|
|
9538
|
-
const DEPRECATED_ORM_CONFIG_FILENAME = "prisma-next.config.ts";
|
|
9539
9601
|
/**
|
|
9540
9602
|
* Builds the engine's `Runtime.config` from `prisma.config.ts`.
|
|
9541
9603
|
*
|
|
@@ -9543,28 +9605,25 @@ const DEPRECATED_ORM_CONFIG_FILENAME = "prisma-next.config.ts";
|
|
|
9543
9605
|
* ORM's c12 loader evaluates the module asynchronously and finalizes paths
|
|
9544
9606
|
* against the config file's own directory. It reads the same shape the engine
|
|
9545
9607
|
* does — defineConfig from `@prisma/cli-engine` with the whole Prisma Next
|
|
9546
|
-
* configuration nested as the single `orm` section
|
|
9547
|
-
* deprecated `prisma-next.config.ts` filename and flat shape, surfacing each
|
|
9548
|
-
* through `warn`.
|
|
9608
|
+
* configuration nested as the single `orm` section.
|
|
9549
9609
|
*
|
|
9550
9610
|
* Only failures that prevent evaluation entirely are diagnostics here, and
|
|
9551
9611
|
* they carry `section: null` so they fail exactly the commands that read
|
|
9552
9612
|
* config. Structural verdicts belong to the section validator.
|
|
9553
9613
|
*/
|
|
9554
9614
|
async function loadOrmConfig(options) {
|
|
9615
|
+
const path = resolve(options.cwd, options.configPath ?? ORM_CONFIG_FILENAME);
|
|
9555
9616
|
const loaded = await loadConfig(options.configPath, { cwd: options.cwd });
|
|
9556
9617
|
if (!loaded.ok) return {
|
|
9557
|
-
path
|
|
9618
|
+
path,
|
|
9558
9619
|
sections: {},
|
|
9559
9620
|
diagnostics: [{
|
|
9560
9621
|
section: null,
|
|
9561
9622
|
diagnostic: toEngineDiagnostic(loaded.failure)
|
|
9562
9623
|
}]
|
|
9563
9624
|
};
|
|
9564
|
-
for (const deprecation of loaded.value.deprecations) options.warn?.(deprecation.message);
|
|
9565
|
-
const filename = loaded.value.deprecations.some((deprecation) => deprecation.code === "CONFIG.DEPRECATED_FILENAME") ? DEPRECATED_ORM_CONFIG_FILENAME : ORM_CONFIG_FILENAME;
|
|
9566
9625
|
return {
|
|
9567
|
-
path
|
|
9626
|
+
path,
|
|
9568
9627
|
sections: { ["orm"]: loaded.value.config },
|
|
9569
9628
|
diagnostics: []
|
|
9570
9629
|
};
|