@prisma/orm-toolchain 8.0.0-rc.14-dev.4 → 8.0.0-rc.14-dev.5
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/cli-telemetry.mjs +1 -1
- package/dist/cli.mjs +217 -15
- package/dist/cli.mjs.map +1 -1
- package/dist/cli__control-api.mjs +1 -1
- package/dist/cli__migration-cli.mjs +1 -1
- package/dist/config-loader.mjs +1 -1
- package/dist/emitter.mjs +1 -1
- package/dist/{exports-Bx-2JeW0-BHlN6Av7.mjs → exports-BcO9J5Ct-BMk2j8LA.mjs} +24 -18
- package/dist/exports-BcO9J5Ct-BMk2j8LA.mjs.map +1 -0
- package/dist/{exports-CyixGARy.mjs → exports-CbtEF7X6.mjs} +14 -4
- package/dist/exports-CbtEF7X6.mjs.map +1 -0
- package/dist/{exports-Bjl3d71N.mjs → exports-p_LVQQlE.mjs} +2 -2
- package/dist/{exports-Bjl3d71N.mjs.map → exports-p_LVQQlE.mjs.map} +1 -1
- package/dist/{ref-EXO_pTtx-fVrc22ZG.mjs → ref-EXO_pTtx-BcH9AmJ9.mjs} +3 -3
- package/dist/{ref-EXO_pTtx-fVrc22ZG.mjs.map → ref-EXO_pTtx-BcH9AmJ9.mjs.map} +1 -1
- package/dist/vite-plugin-contract-emit.mjs +3 -3
- package/package.json +12 -12
- package/dist/exports-Bx-2JeW0-BHlN6Av7.mjs.map +0 -1
- package/dist/exports-CyixGARy.mjs.map +0 -1
package/dist/cli-telemetry.mjs
CHANGED
|
@@ -42,7 +42,7 @@ async function loadProjectConfig(projectRoot) {
|
|
|
42
42
|
const orm = config["orm"];
|
|
43
43
|
if (orm === null || typeof orm !== "object" || Array.isArray(orm)) return EMPTY_PROJECT_CONFIG;
|
|
44
44
|
config = blindCast(orm);
|
|
45
|
-
const { validateOrmSection } = await import("./exports-
|
|
45
|
+
const { validateOrmSection } = await import("./exports-p_LVQQlE.mjs").then((n) => n.a);
|
|
46
46
|
const validation = validateOrmSection(config, {
|
|
47
47
|
files: [],
|
|
48
48
|
keys: {}
|
package/dist/cli.mjs
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { h as requireConfigSections, i as expandContractInputs, m as ormConfigSection, n as buildLoadedConfig, r as evaluateConfigModule, s as globContractInputMatching, u as loadConfigFiles } from "./exports-
|
|
2
|
-
import { r as getEmittedArtifactPaths } from "./exports-
|
|
1
|
+
import { h as requireConfigSections, i as expandContractInputs, m as ormConfigSection, n as buildLoadedConfig, r as evaluateConfigModule, s as globContractInputMatching, u as loadConfigFiles } from "./exports-p_LVQQlE.mjs";
|
|
2
|
+
import { r as getEmittedArtifactPaths } from "./exports-BcO9J5Ct-BMk2j8LA.mjs";
|
|
3
3
|
import { t as MigrationToolsError } from "./errors-DD6iLGXk-6I9PqjpZ.mjs";
|
|
4
4
|
import { t as contractSnapshotDir } from "./contract-snapshot-store-1S_6vaGt-FrXDiBEd.mjs";
|
|
5
5
|
import { t as EMPTY_CONTRACT_HASH } from "./constants-CM-w38DQ-Cz_EXbOc.mjs";
|
|
6
6
|
import { r as readRef } from "./refs-qwvw4_dV-DNg_7WTD.mjs";
|
|
7
7
|
import { c as spaceMigrationDirectory } from "./verify-contract-spaces-CYjc343k-DHy5xtKR.mjs";
|
|
8
8
|
import { i as createScaffoldSpecifierResolver } from "./import-roots-BB3GzIi-.mjs";
|
|
9
|
-
import { $ as executeRefListCommand, A as errorDriverRequired, At as resolveContractRefToSnapshot, B as errorRuntime, Bt as sourceWarningDiagnostic, C as errorConfigValidation$1, Ct as refuseMarkerOutsideGraph, D as errorContractValidationFailed, Dt as requireLiveDatabase, E as errorContractConfigMissing, Et as refuseUnknownInvariants, F as errorMigrationPackageNotFound, H as errorTargetMismatch, Ht as targetSupportsMigrations, I as errorMigrationPlanningFailed, It as runMigrationCheck, J as executeMigrateShowPlan, L as errorNoMigrations, Lt as runMigrationList, M as errorHashMismatch, Mt as resolveMigrationRef, N as errorLegendHumanOnly, O as errorDatabaseConnectionRequired, Ot as resolveAppTargetPath, P as errorMarkerMissing, Pt as runCommandAction, Q as executeRefDeleteCommand, R as errorPathUnreachable, Rt as sanitizeErrorMessage, S as errorAdvanceRefArgConflict, T as errorContractArgConflict, Tt as refusePackageCorruptionOnAggregate, U as errorUnexpected, Ut as toDeclaredExtensionsFromRaw, V as errorTargetMigrationNotSupported, Vt as statusForMigrationHash, W as executeContractEmit, Wt as validateLoadedContract, X as executeMigrationPlanCommand, Y as executeMigrationNewCommand, _ as createControlClient, _t as preflightRefAdvancement, a as NO_REF_ADVANCEMENT, at as loadAggregateIntegrityViolations, bt as redactUrlCredentials, c as appliedHashesFromLedger, ct as loadContractSourceWithStack, d as buildReadAggregate, dt as mapCaughtMigrationError, et as executeRefSetCommand, f as buildRefAdvancementFields, ft as mapContractAtError, g as computeRefAdvancementName, gt as originHashForStatus, h as closeQuietly, ht as migrationSpaceListEntriesFromAggregate, i as ERROR_CODE_DESTRUCTIVE_CHANGES, it as listRefsByContractHash, j as errorFileNotFound, k as errorDestructiveChanges, kt as resolveContractRef$1, lt as loadContractSpaceAggregateForCli, m as chooseAction, mt as maskConnectionUrl, n as CliStructuredError$1$1, nt as formatSourceDiagnostic, o as advanceRefSafely, ot as loadContractRawSafely, p as checkSingleTarget, r as DB_UPDATE_POLICY, rt as hasMigrationPath, st as loadContractSource, t as ActionableCliError, tt as findPackageByDirPath, u as buildMigrationSpaceGraphEntries, ut as looksLikePath, v as deriveStatusEdgeAnnotations, vt as readContractEnvelope, w as errorConsentPlanMismatch, wt as refuseMissingInvariantPath, x as enumerateCheckSpaces, xt as refuseContractSpaceIntegrity, yt as readMigrationRefs, z as errorRunnerFailed, zt as snapshotVerifierFor } from "./ref-EXO_pTtx-
|
|
9
|
+
import { $ as executeRefListCommand, A as errorDriverRequired, At as resolveContractRefToSnapshot, B as errorRuntime, Bt as sourceWarningDiagnostic, C as errorConfigValidation$1, Ct as refuseMarkerOutsideGraph, D as errorContractValidationFailed, Dt as requireLiveDatabase, E as errorContractConfigMissing, Et as refuseUnknownInvariants, F as errorMigrationPackageNotFound, H as errorTargetMismatch, Ht as targetSupportsMigrations, I as errorMigrationPlanningFailed, It as runMigrationCheck, J as executeMigrateShowPlan, L as errorNoMigrations, Lt as runMigrationList, M as errorHashMismatch, Mt as resolveMigrationRef, N as errorLegendHumanOnly, O as errorDatabaseConnectionRequired, Ot as resolveAppTargetPath, P as errorMarkerMissing, Pt as runCommandAction, Q as executeRefDeleteCommand, R as errorPathUnreachable, Rt as sanitizeErrorMessage, S as errorAdvanceRefArgConflict, T as errorContractArgConflict, Tt as refusePackageCorruptionOnAggregate, U as errorUnexpected, Ut as toDeclaredExtensionsFromRaw, V as errorTargetMigrationNotSupported, Vt as statusForMigrationHash, W as executeContractEmit, Wt as validateLoadedContract, X as executeMigrationPlanCommand, Y as executeMigrationNewCommand, _ as createControlClient, _t as preflightRefAdvancement, a as NO_REF_ADVANCEMENT, at as loadAggregateIntegrityViolations, bt as redactUrlCredentials, c as appliedHashesFromLedger, ct as loadContractSourceWithStack, d as buildReadAggregate, dt as mapCaughtMigrationError, et as executeRefSetCommand, f as buildRefAdvancementFields, ft as mapContractAtError, g as computeRefAdvancementName, gt as originHashForStatus, h as closeQuietly, ht as migrationSpaceListEntriesFromAggregate, i as ERROR_CODE_DESTRUCTIVE_CHANGES, it as listRefsByContractHash, j as errorFileNotFound, k as errorDestructiveChanges, kt as resolveContractRef$1, lt as loadContractSpaceAggregateForCli, m as chooseAction, mt as maskConnectionUrl, n as CliStructuredError$1$1, nt as formatSourceDiagnostic, o as advanceRefSafely, ot as loadContractRawSafely, p as checkSingleTarget, r as DB_UPDATE_POLICY, rt as hasMigrationPath, st as loadContractSource, t as ActionableCliError, tt as findPackageByDirPath, u as buildMigrationSpaceGraphEntries, ut as looksLikePath, v as deriveStatusEdgeAnnotations, vt as readContractEnvelope, w as errorConsentPlanMismatch, wt as refuseMissingInvariantPath, x as enumerateCheckSpaces, xt as refuseContractSpaceIntegrity, yt as readMigrationRefs, z as errorRunnerFailed, zt as snapshotVerifierFor } from "./ref-EXO_pTtx-BcH9AmJ9.mjs";
|
|
10
10
|
import { a as PRISMA7_QUICK_REFERENCE_STEP, i as PRISMA7_LOOP_STEP, n as InitOutputSchema, o as buildNextSteps, r as NEXT_STEPS_BEFORE_SCAFFOLD, t as DB_SIGN_STEP } from "./output-BcC8eB0h-C5bRd-aC.mjs";
|
|
11
11
|
import { createRequire } from "node:module";
|
|
12
12
|
import { existsSync, mkdirSync, readFileSync, readdirSync, rmSync, statSync, unlinkSync, writeFileSync } from "node:fs";
|
|
@@ -35,7 +35,7 @@ import { applyEdits, modify, parse, printParseErrorCode } from "jsonc-parser";
|
|
|
35
35
|
import stringWidth from "string-width";
|
|
36
36
|
import { bold, createColors, cyan, cyanBright, dim, green, yellow } from "colorette";
|
|
37
37
|
import { build } from "esbuild";
|
|
38
|
-
//#region ../../../1-framework/3-tooling/cli/dist/load-config-
|
|
38
|
+
//#region ../../../1-framework/3-tooling/cli/dist/load-config-BIKpzcN0.mjs
|
|
39
39
|
/**
|
|
40
40
|
* `isStructuredError` is the repo's own check, and it is the one that matters here: it holds the
|
|
41
41
|
* regular expression for a dotted `NAMESPACE.SUBCODE`, so only a code the protocol accepts
|
|
@@ -3370,7 +3370,24 @@ function errorInitPrisma7SchemaRefused(options) {
|
|
|
3370
3370
|
}
|
|
3371
3371
|
});
|
|
3372
3372
|
}
|
|
3373
|
-
|
|
3373
|
+
/**
|
|
3374
|
+
* The project's schema is a Prisma 6 MongoDB schema. Init stops before changing anything and gives
|
|
3375
|
+
* the side-by-side setup as its next actions: set up by init, Prisma 8 would take the `prisma`
|
|
3376
|
+
* package name and `prisma.config.ts` from the Prisma 6 CLI the app still runs.
|
|
3377
|
+
*/
|
|
3378
|
+
function errorInitPrisma6SchemaFound(options) {
|
|
3379
|
+
const { database } = options;
|
|
3380
|
+
return new CliStructuredError$1$1("CLI.INIT_PRISMA6_SCHEMA_FOUND", `Prisma 6 ${database} schema found`, {
|
|
3381
|
+
why: `${options.schemaPath} is a Prisma 6 ${database} schema. Prisma 8 can read it as its contract source through prisma6Schema while Prisma 6 keeps running the app, but init does not set that up: both CLIs are published as \`prisma\`, and the Prisma 6 CLI also reads prisma.config.ts. Nothing was changed. Follow the steps below. Passing --target and --authoring instead sets up a Prisma 8 starter in this same project, which breaks the Prisma 6 CLI: it writes prisma.config.ts, so every Prisma 6 command fails until Prisma 6 gets its own config file, and its install step replaces the Prisma 6 CLI with prisma@latest.`,
|
|
3382
|
+
nextActions: options.setup.steps,
|
|
3383
|
+
docsUrl: docsUrlFor("CLI.INIT_PRISMA6_SCHEMA_FOUND"),
|
|
3384
|
+
meta: {
|
|
3385
|
+
schemaPath: options.schemaPath,
|
|
3386
|
+
prismaConfig: options.setup.prismaConfig,
|
|
3387
|
+
prisma6Config: options.setup.prisma6Config
|
|
3388
|
+
}
|
|
3389
|
+
});
|
|
3390
|
+
}
|
|
3374
3391
|
const CONFIG_EXTENSIONS = [
|
|
3375
3392
|
"ts",
|
|
3376
3393
|
"mts",
|
|
@@ -3454,7 +3471,12 @@ function stripLineComments(text) {
|
|
|
3454
3471
|
function findProvider(text) {
|
|
3455
3472
|
const block = /datasource\s+\w+\s*\{([^}]*)\}/.exec(stripLineComments(text));
|
|
3456
3473
|
if (block === null) return;
|
|
3457
|
-
|
|
3474
|
+
const provider = /\bprovider\s*=\s*"([^"]*)"/.exec(block[1] ?? "");
|
|
3475
|
+
const urlEnv = /\burl\s*=\s*env\(\s*"([^"]*)"\s*\)/.exec(block[1] ?? "");
|
|
3476
|
+
return {
|
|
3477
|
+
provider: provider?.[1],
|
|
3478
|
+
urlEnv: urlEnv?.[1]
|
|
3479
|
+
};
|
|
3458
3480
|
}
|
|
3459
3481
|
function prismaFilesUnder(directory) {
|
|
3460
3482
|
return readdirSync(directory, {
|
|
@@ -3474,7 +3496,7 @@ function detectSchema(cwd, path) {
|
|
|
3474
3496
|
if (found !== void 0) return {
|
|
3475
3497
|
kind: "datasource",
|
|
3476
3498
|
path,
|
|
3477
|
-
|
|
3499
|
+
...found
|
|
3478
3500
|
};
|
|
3479
3501
|
}
|
|
3480
3502
|
return {
|
|
@@ -3482,6 +3504,27 @@ function detectSchema(cwd, path) {
|
|
|
3482
3504
|
path
|
|
3483
3505
|
};
|
|
3484
3506
|
}
|
|
3507
|
+
/** The schema locations an earlier Prisma CLI tries, in order, when neither a flag, a config nor package.json names one. */
|
|
3508
|
+
const CONVENTIONAL_SCHEMA_PATHS = [
|
|
3509
|
+
"prisma/schema.prisma",
|
|
3510
|
+
"schema.prisma",
|
|
3511
|
+
"prisma/schema"
|
|
3512
|
+
];
|
|
3513
|
+
/**
|
|
3514
|
+
* The schema an earlier Prisma CLI reads when no flag or config names one: the `prisma.schema` field of package.json, else the first conventional location that exists, else the default path.
|
|
3515
|
+
*/
|
|
3516
|
+
function conventionalSchemaPath(cwd) {
|
|
3517
|
+
const declared = readJsonRecord(join(cwd, "package.json"))?.["prisma"];
|
|
3518
|
+
const schema = isRecord$2(declared) ? declared["schema"] : void 0;
|
|
3519
|
+
if (typeof schema === "string") return {
|
|
3520
|
+
path: schema,
|
|
3521
|
+
source: "package-json"
|
|
3522
|
+
};
|
|
3523
|
+
return {
|
|
3524
|
+
path: CONVENTIONAL_SCHEMA_PATHS.find((candidate) => existsSync(resolve(cwd, candidate))) ?? "prisma/schema.prisma",
|
|
3525
|
+
source: "default"
|
|
3526
|
+
};
|
|
3527
|
+
}
|
|
3485
3528
|
function readJsonRecord(path) {
|
|
3486
3529
|
if (!existsSync(path)) return;
|
|
3487
3530
|
try {
|
|
@@ -3544,7 +3587,8 @@ function warningsFor(config) {
|
|
|
3544
3587
|
async function detectPrisma7Project(ctx) {
|
|
3545
3588
|
const config = await detectConfig(ctx.cwd);
|
|
3546
3589
|
const configSchema = config.kind === "prisma7" || config.kind === "unreadable" ? config.schema : void 0;
|
|
3547
|
-
const
|
|
3590
|
+
const conventional = conventionalSchemaPath(ctx.cwd);
|
|
3591
|
+
const [path, schemaPathSource] = ctx.schemaPath !== void 0 ? [ctx.schemaPath, "flag"] : configSchema !== void 0 ? [configSchema, "config"] : [conventional.path, conventional.source];
|
|
3548
3592
|
return {
|
|
3549
3593
|
config,
|
|
3550
3594
|
schema: detectSchema(ctx.cwd, path),
|
|
@@ -3738,6 +3782,12 @@ function scaffoldSpecifierResolverFor(target) {
|
|
|
3738
3782
|
function targetPackageName(target, resolveImportSpecifier = keepInternalSpecifiers) {
|
|
3739
3783
|
return resolveImportSpecifier(target === "postgres" ? "@internal/postgres" : "@internal/mongo");
|
|
3740
3784
|
}
|
|
3785
|
+
const DRIVER_PEERS = /* @__PURE__ */ new Map([["mongo", "mongodb"]]);
|
|
3786
|
+
/** Packages the target package declares as required peer dependencies; init installs them with it. */
|
|
3787
|
+
function targetPeerPackages(target) {
|
|
3788
|
+
const driver = DRIVER_PEERS.get(target);
|
|
3789
|
+
return driver === void 0 ? [] : [driver];
|
|
3790
|
+
}
|
|
3741
3791
|
/** One entrypoint of the scaffolded project's target package. */
|
|
3742
3792
|
function targetEntrypoint(target, subpath, resolveImportSpecifier = keepInternalSpecifiers) {
|
|
3743
3793
|
return resolveImportSpecifier(`${target === "postgres" ? "@internal/postgres" : "@internal/mongo"}/${subpath}`);
|
|
@@ -4093,6 +4143,7 @@ function envFileContent(target) {
|
|
|
4093
4143
|
}
|
|
4094
4144
|
/** The invocation that finishes what a failed `init` phase started. */
|
|
4095
4145
|
const EMIT_COMMAND = "prisma contract emit";
|
|
4146
|
+
const DB_SIGN_COMMAND = "prisma db sign";
|
|
4096
4147
|
/**
|
|
4097
4148
|
* The command's own record of a phase that failed after the scaffold was
|
|
4098
4149
|
* written. The scaffold is on disk and the run has a result to report, so each
|
|
@@ -4196,7 +4247,7 @@ function buildInitNextActions(inputs) {
|
|
|
4196
4247
|
const actions = [chooseAction("Set DATABASE_URL in your environment (export it or add it to .env)")];
|
|
4197
4248
|
if (!inputs.contractEmitted) actions.push(runCommandAction("Emit the contract", EMIT_COMMAND));
|
|
4198
4249
|
if (inputs.prisma7 !== null) {
|
|
4199
|
-
actions.push(runCommandAction(DB_SIGN_STEP,
|
|
4250
|
+
actions.push(runCommandAction(DB_SIGN_STEP, DB_SIGN_COMMAND));
|
|
4200
4251
|
actions.push({
|
|
4201
4252
|
kind: "edit-file",
|
|
4202
4253
|
label: "Move your routes one at a time to the Prisma 8 client in src/prisma/db.ts"
|
|
@@ -4469,6 +4520,107 @@ function formatRemoveCommand(pm, packages) {
|
|
|
4469
4520
|
...packages
|
|
4470
4521
|
].join(" ");
|
|
4471
4522
|
}
|
|
4523
|
+
function formatAddArgs(pm, packages) {
|
|
4524
|
+
if (pm === "deno") return ["add", ...packages.map((p) => `npm:${p}`)];
|
|
4525
|
+
return ["add", ...packages];
|
|
4526
|
+
}
|
|
4527
|
+
function formatAddDevArgs(pm, packages) {
|
|
4528
|
+
if (pm === "deno") return [
|
|
4529
|
+
"add",
|
|
4530
|
+
"--dev",
|
|
4531
|
+
...packages.map((p) => `npm:${p}`)
|
|
4532
|
+
];
|
|
4533
|
+
return [
|
|
4534
|
+
"add",
|
|
4535
|
+
"-D",
|
|
4536
|
+
...packages
|
|
4537
|
+
];
|
|
4538
|
+
}
|
|
4539
|
+
const PRISMA6_ONLY_PROVIDERS = /* @__PURE__ */ new Map([["mongodb", "mongo"]]);
|
|
4540
|
+
/**
|
|
4541
|
+
* The target of a `datasource` provider that exists only up to Prisma 6, which makes its schema a Prisma 6 schema; `undefined` for any other provider.
|
|
4542
|
+
*/
|
|
4543
|
+
function prisma6OnlyTarget(provider) {
|
|
4544
|
+
return provider === void 0 ? void 0 : PRISMA6_ONLY_PROVIDERS.get(provider);
|
|
4545
|
+
}
|
|
4546
|
+
function runPrisma6(packageManager, args) {
|
|
4547
|
+
switch (packageManager) {
|
|
4548
|
+
case "npm": return `npm run prisma6 -- ${args}`;
|
|
4549
|
+
case "bun": return `bun run prisma6 ${args}`;
|
|
4550
|
+
case "deno": return `deno task prisma6 ${args}`;
|
|
4551
|
+
default: return `${packageManager} prisma6 ${args}`;
|
|
4552
|
+
}
|
|
4553
|
+
}
|
|
4554
|
+
function prisma6SideBySideSetup(inputs) {
|
|
4555
|
+
const { schemaPath, packageManager } = inputs;
|
|
4556
|
+
const prisma6ConfigFile = `prisma6.config.${inputs.ownConfigPath === void 0 ? "ts" : extname(inputs.ownConfigPath).slice(1)}`;
|
|
4557
|
+
const prisma6Config = inputs.ownConfigPath === void 0 ? [
|
|
4558
|
+
"import 'dotenv/config';",
|
|
4559
|
+
"import { defineConfig } from 'prisma6/config';",
|
|
4560
|
+
"",
|
|
4561
|
+
`export default defineConfig({ schema: '${schemaPath}' });`,
|
|
4562
|
+
""
|
|
4563
|
+
].join("\n") : null;
|
|
4564
|
+
const prismaConfig = [
|
|
4565
|
+
"import 'dotenv/config';",
|
|
4566
|
+
"import { definePrismaConfig } from 'prisma/config';",
|
|
4567
|
+
`import { defineConfig as ormConfig, prisma6Schema } from '${inputs.targetConfigEntrypoint}';`,
|
|
4568
|
+
"",
|
|
4569
|
+
"export default definePrismaConfig({",
|
|
4570
|
+
" orm: ormConfig({",
|
|
4571
|
+
` contract: prisma6Schema('${schemaPath}'),`,
|
|
4572
|
+
` db: { connection: process.env['${inputs.urlEnv ?? "DATABASE_URL"}']! },`,
|
|
4573
|
+
" }),",
|
|
4574
|
+
"});",
|
|
4575
|
+
""
|
|
4576
|
+
].join("\n");
|
|
4577
|
+
const add = (args) => [packageManager, ...args].join(" ");
|
|
4578
|
+
return {
|
|
4579
|
+
prismaConfig,
|
|
4580
|
+
prisma6Config,
|
|
4581
|
+
steps: [
|
|
4582
|
+
{
|
|
4583
|
+
kind: "edit-file",
|
|
4584
|
+
label: `In package.json, ${inputs.cliVersion === void 0 ? "install the Prisma 6 CLI under another name: add the dev dependency \"prisma6\": \"npm:prisma@6\"" : `keep the Prisma 6 CLI under another name: replace the "prisma" dev dependency with "prisma6": "npm:prisma@${inputs.cliVersion}"`}, add the script "prisma6": "node node_modules/prisma6/build/index.js --config ${prisma6ConfigFile}", and run every Prisma 6 command through it, as in \`${runPrisma6(packageManager, "db push")}\` and \`${runPrisma6(packageManager, "generate")}\`.`
|
|
4585
|
+
},
|
|
4586
|
+
prisma6Config === null ? {
|
|
4587
|
+
kind: "edit-file",
|
|
4588
|
+
label: `Rename ${inputs.ownConfigPath} to ${prisma6ConfigFile} and import defineConfig from 'prisma6/config' in it, so that only the Prisma 6 CLI reads it.`
|
|
4589
|
+
} : {
|
|
4590
|
+
kind: "edit-file",
|
|
4591
|
+
label: `Write ${prisma6ConfigFile} for the Prisma 6 CLI:\n${prisma6Config.trimEnd()}`
|
|
4592
|
+
},
|
|
4593
|
+
{
|
|
4594
|
+
kind: "run-command",
|
|
4595
|
+
label: "Install the Prisma 8 packages",
|
|
4596
|
+
command: add(formatAddArgs(packageManager, [
|
|
4597
|
+
inputs.targetPackage,
|
|
4598
|
+
"dotenv",
|
|
4599
|
+
...inputs.peerPackages
|
|
4600
|
+
]))
|
|
4601
|
+
},
|
|
4602
|
+
{
|
|
4603
|
+
kind: "run-command",
|
|
4604
|
+
label: "Install the Prisma 8 CLI, which now takes the name prisma",
|
|
4605
|
+
command: add(formatAddDevArgs(packageManager, ["prisma@latest"]))
|
|
4606
|
+
},
|
|
4607
|
+
{
|
|
4608
|
+
kind: "edit-file",
|
|
4609
|
+
label: `Write prisma.config.ts for Prisma 8:\n${prismaConfig.trimEnd()}`
|
|
4610
|
+
},
|
|
4611
|
+
{
|
|
4612
|
+
kind: "run-command",
|
|
4613
|
+
label: "Read the Prisma 6 schema into a contract",
|
|
4614
|
+
command: EMIT_COMMAND
|
|
4615
|
+
},
|
|
4616
|
+
{
|
|
4617
|
+
kind: "run-command",
|
|
4618
|
+
label: "Sign the database the Prisma 6 app uses",
|
|
4619
|
+
command: DB_SIGN_COMMAND
|
|
4620
|
+
}
|
|
4621
|
+
]
|
|
4622
|
+
};
|
|
4623
|
+
}
|
|
4472
4624
|
/**
|
|
4473
4625
|
* Recognised pnpm error signatures that justify a fallback to npm.
|
|
4474
4626
|
*
|
|
@@ -4936,13 +5088,17 @@ function mergePackageScripts(existing, required = REQUIRED_SCRIPTS) {
|
|
|
4936
5088
|
* and surface a structured warning. The user explicitly opted out of
|
|
4937
5089
|
* ESM and we don't silently overwrite that.
|
|
4938
5090
|
*/
|
|
4939
|
-
function ensureEsmModuleType(existing) {
|
|
5091
|
+
function ensureEsmModuleType(existing, options = { existingProject: false }) {
|
|
4940
5092
|
const parsed = blindCast(JSON.parse(existing));
|
|
4941
5093
|
const currentType = parsed["type"];
|
|
4942
5094
|
if (currentType === "module") return {
|
|
4943
5095
|
content: null,
|
|
4944
5096
|
warning: null
|
|
4945
5097
|
};
|
|
5098
|
+
if (options.existingProject && currentType === void 0) return {
|
|
5099
|
+
content: null,
|
|
5100
|
+
warning: "package.json declares no \"type\", so Node loads the project's .js files as CommonJS. init leaves that alone, because setting it would change how the project's own files load. The scaffolded db.ts is an ES module (it imports the contract with `with { type: 'json' }`): Node still loads it, and CommonJS code can require it, but Node prints a MODULE_TYPELESS_PACKAGE_JSON warning and reparses the file as an ES module; a TypeScript runner such as tsx loads it without the warning. Set \"type\": \"module\" in package.json when the project is ready for it, and the warning goes away."
|
|
5101
|
+
};
|
|
4946
5102
|
if (typeof currentType === "string" && currentType !== "module") return {
|
|
4947
5103
|
content: null,
|
|
4948
5104
|
warning: `package.json declares "type": "${currentType}" — keeping yours, but the scaffolded prisma/db.ts uses an ESM-only import attribute (\`with { type: 'json' }\`) and will not load under that module type.\nIf you want the default, set "type": "module" in package.json.`
|
|
@@ -5574,6 +5730,10 @@ async function resolveScaffoldPackageManager(ctx) {
|
|
|
5574
5730
|
* `devDependencies`. Transitive presence is deliberately ignored: detecting it
|
|
5575
5731
|
* needs the lockfile, and the realistic risk is a direct pin being clobbered.
|
|
5576
5732
|
*/
|
|
5733
|
+
function declaresRuntimeDependencies(parsed) {
|
|
5734
|
+
const value = parsed?.["dependencies"];
|
|
5735
|
+
return value !== null && typeof value === "object" && Object.keys(value).length > 0;
|
|
5736
|
+
}
|
|
5577
5737
|
function hasDirectDep(parsed, name) {
|
|
5578
5738
|
for (const field of ["dependencies", "devDependencies"]) {
|
|
5579
5739
|
const value = parsed[field];
|
|
@@ -5733,7 +5893,7 @@ function planScaffold(ctx) {
|
|
|
5733
5893
|
working = withScripts;
|
|
5734
5894
|
changed = true;
|
|
5735
5895
|
}
|
|
5736
|
-
const { content: withType, warning: typeWarning } = ensureEsmModuleType(working);
|
|
5896
|
+
const { content: withType, warning: typeWarning } = ensureEsmModuleType(working, { existingProject: manifestExisted && declaresRuntimeDependencies(parsedManifest) });
|
|
5737
5897
|
if (withType !== null) {
|
|
5738
5898
|
working = withType;
|
|
5739
5899
|
changed = true;
|
|
@@ -6218,6 +6378,44 @@ async function resolveStarterInputs(ctx) {
|
|
|
6218
6378
|
removePreviousFacade
|
|
6219
6379
|
};
|
|
6220
6380
|
}
|
|
6381
|
+
function prisma6Schema(schema) {
|
|
6382
|
+
if (schema.kind !== "datasource") return void 0;
|
|
6383
|
+
const target = prisma6OnlyTarget(schema.provider);
|
|
6384
|
+
return target === void 0 ? void 0 : {
|
|
6385
|
+
schema,
|
|
6386
|
+
target
|
|
6387
|
+
};
|
|
6388
|
+
}
|
|
6389
|
+
/**
|
|
6390
|
+
* The stop for a Prisma 6 project, carrying the side-by-side setup. The provider names the target;
|
|
6391
|
+
* the project's own `prisma.config.*`, when it evaluates to an earlier version's config, is renamed
|
|
6392
|
+
* for the Prisma 6 CLI instead of a new one written.
|
|
6393
|
+
*/
|
|
6394
|
+
function prisma6SchemaFound(detection, { schema, target }, packageManager) {
|
|
6395
|
+
const resolveImportSpecifier = scaffoldSpecifierResolverFor(target);
|
|
6396
|
+
const { config, cli } = detection;
|
|
6397
|
+
const ownConfigPath = (config.kind === "prisma7" || config.kind === "unreadable") && config.path.startsWith(PRISMA7_CONFIG_STEM) ? config.path : void 0;
|
|
6398
|
+
return errorInitPrisma6SchemaFound({
|
|
6399
|
+
schemaPath: schema.path,
|
|
6400
|
+
database: targetLabel(target),
|
|
6401
|
+
setup: prisma6SideBySideSetup({
|
|
6402
|
+
schemaPath: schema.path,
|
|
6403
|
+
urlEnv: schema.urlEnv,
|
|
6404
|
+
packageManager,
|
|
6405
|
+
cliVersion: cli.kind === "earlier" ? cli.version : void 0,
|
|
6406
|
+
ownConfigPath,
|
|
6407
|
+
targetPackage: targetPackageName(target, resolveImportSpecifier),
|
|
6408
|
+
peerPackages: targetPeerPackages(target),
|
|
6409
|
+
targetConfigEntrypoint: targetEntrypoint(target, "config", resolveImportSpecifier)
|
|
6410
|
+
})
|
|
6411
|
+
});
|
|
6412
|
+
}
|
|
6413
|
+
/** Said to a starter run in a Prisma 6 project, which it leaves alone but crowds. */
|
|
6414
|
+
function starterBesidePrisma6Warnings(cwd) {
|
|
6415
|
+
const found = prisma6Schema(detectSchema(cwd, conventionalSchemaPath(cwd).path));
|
|
6416
|
+
if (found === void 0) return [];
|
|
6417
|
+
return [`${found.schema.path} is a Prisma 6 ${targetLabel(found.target)} schema, which this run leaves alone, but this run breaks the Prisma 6 CLI: it writes prisma.config.ts, which the Prisma 6 CLI reads too, so every Prisma 6 command fails until Prisma 6 gets its own config file, and its install step replaces the Prisma 6 CLI with prisma@latest. Run \`prisma orm init\` without --target and --authoring to see how to keep Prisma 6 working and read this schema instead.`];
|
|
6418
|
+
}
|
|
6221
6419
|
/**
|
|
6222
6420
|
* Resolves every input from the flags and, where a flag is absent, from the
|
|
6223
6421
|
* engine's prompt surface.
|
|
@@ -6241,6 +6439,8 @@ async function resolveInitInputs(ctx) {
|
|
|
6241
6439
|
cwd,
|
|
6242
6440
|
schemaPath: flags.fromPrisma7Schema
|
|
6243
6441
|
});
|
|
6442
|
+
const prisma6 = prisma6Schema(detection.schema);
|
|
6443
|
+
if (prisma6 !== void 0) throw prisma6SchemaFound(detection, prisma6, ctx.packageManager);
|
|
6244
6444
|
if (await choosePrisma7Path({
|
|
6245
6445
|
flags,
|
|
6246
6446
|
prompt,
|
|
@@ -6264,7 +6464,7 @@ async function resolveInitInputs(ctx) {
|
|
|
6264
6464
|
target: flagTarget,
|
|
6265
6465
|
flagAuthoring,
|
|
6266
6466
|
prisma7SchemaPath,
|
|
6267
|
-
warnings: [],
|
|
6467
|
+
warnings: mayAdoptPrisma7 ? [] : starterBesidePrisma6Warnings(cwd),
|
|
6268
6468
|
installed: []
|
|
6269
6469
|
});
|
|
6270
6470
|
}
|
|
@@ -6303,7 +6503,7 @@ function causeMessage(error) {
|
|
|
6303
6503
|
const createInitCommand = (injected) => defineOrmCommand({
|
|
6304
6504
|
help: {
|
|
6305
6505
|
summary: "Initialize a new Prisma ORM project",
|
|
6306
|
-
description: "Scaffolds config, schema, and runtime files, installs dependencies,\nand emits the contract. Gets you from zero to typed queries in one step.\n\nRun it interactively for a guided setup, or supply --target and --authoring\nfor a fully scriptable run (CI, AI coding agents, automation).\n\nIn a Prisma 7 project, pass --from-prisma7-schema (or answer yes when asked)\nto use the existing schema.prisma as the contract source.",
|
|
6506
|
+
description: "Scaffolds config, schema, and runtime files, installs dependencies,\nand emits the contract. Gets you from zero to typed queries in one step.\n\nRun it interactively for a guided setup, or supply --target and --authoring\nfor a fully scriptable run (CI, AI coding agents, automation).\n\nIn a Prisma 7 project, pass --from-prisma7-schema (or answer yes when asked)\nto use the existing schema.prisma as the contract source.\n\nIn a Prisma 6 MongoDB project, init changes nothing: it prints how to install\nPrisma 8 beside Prisma 6 and read schema.prisma through prisma6Schema in\nprisma.config.ts, keeping the Prisma 6 CLI as an alias with its own config.\nPassing --target and --authoring sets up a starter in the same project instead,\nwhich breaks the Prisma 6 CLI.",
|
|
6307
6507
|
examples: [
|
|
6308
6508
|
"orm init",
|
|
6309
6509
|
"orm init --target postgres --authoring psl",
|
|
@@ -6365,7 +6565,8 @@ const createInitCommand = (injected) => defineOrmCommand({
|
|
|
6365
6565
|
install: !args.flags.skipInstall,
|
|
6366
6566
|
importFromProject: injected.importFromProject
|
|
6367
6567
|
}),
|
|
6368
|
-
warn
|
|
6568
|
+
warn,
|
|
6569
|
+
packageManager
|
|
6369
6570
|
});
|
|
6370
6571
|
} catch (error) {
|
|
6371
6572
|
if (!(error instanceof Prisma7CheckInstallFailed)) throw error;
|
|
@@ -6421,6 +6622,7 @@ const createInitCommand = (injected) => defineOrmCommand({
|
|
|
6421
6622
|
const deps = [
|
|
6422
6623
|
targetPackageName(inputs.target, scaffold.resolveImportSpecifier),
|
|
6423
6624
|
"dotenv",
|
|
6625
|
+
...targetPeerPackages(inputs.target),
|
|
6424
6626
|
...moveClient ? ["@prisma/client@7"] : []
|
|
6425
6627
|
];
|
|
6426
6628
|
const depsToInstall = deps.filter((dep) => !inputs.preinstalled.includes(dep));
|
|
@@ -6586,7 +6788,7 @@ const lspCommand = defineServerCommand({
|
|
|
6586
6788
|
} },
|
|
6587
6789
|
handler: async (args, io) => {
|
|
6588
6790
|
const exitCode = await withoutClientProcessIdInArgv(async () => {
|
|
6589
|
-
const { startServer } = await import("./exports-
|
|
6791
|
+
const { startServer } = await import("./exports-CbtEF7X6.mjs");
|
|
6590
6792
|
return startServer({
|
|
6591
6793
|
stdin: io.stdin,
|
|
6592
6794
|
stdout: io.stdout,
|