@prisma/orm-toolchain 8.0.0-rc.5-dev.1 → 8.0.0-rc.5-dev.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.mjs +72 -248
- package/dist/cli.mjs.map +1 -1
- package/dist/cli__init-output.mjs +1 -1
- package/dist/{output-CovTDY14-CUoAqLML.mjs → output-D87bBeOF-DWlKHmk9.mjs} +3 -3
- package/dist/{output-CovTDY14-CUoAqLML.mjs.map → output-D87bBeOF-DWlKHmk9.mjs.map} +1 -1
- package/dist/quick-reference-mongo.md +2 -2
- package/dist/quick-reference-postgres.md +2 -2
- package/package.json +12 -12
package/dist/cli.mjs
CHANGED
|
@@ -3,7 +3,7 @@ import { t as EMPTY_CONTRACT_HASH } from "./constants-CM-w38DQ-Cz_EXbOc.mjs";
|
|
|
3
3
|
import { c as spaceMigrationDirectory } from "./verify-contract-spaces-CrxvgpwD-D5LLXGci.mjs";
|
|
4
4
|
import { i as createScaffoldSpecifierResolver } from "./import-roots-kw_vAdpJ.mjs";
|
|
5
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-XdaDN3GF-Io-mSVS6.mjs";
|
|
6
|
-
import { n as buildNextSteps, t as InitOutputSchema } from "./output-
|
|
6
|
+
import { n as buildNextSteps, t as InitOutputSchema } from "./output-D87bBeOF-DWlKHmk9.mjs";
|
|
7
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";
|
|
@@ -33,8 +33,7 @@ import { applyEdits, modify, parse, printParseErrorCode } from "jsonc-parser";
|
|
|
33
33
|
import stringWidth from "string-width";
|
|
34
34
|
import { bold, createColors, cyan, cyanBright, dim, green, yellow } from "colorette";
|
|
35
35
|
import { build } from "esbuild";
|
|
36
|
-
//#region ../../../1-framework/3-tooling/cli/dist/load-config-
|
|
37
|
-
var version = "8.0.0-rc.5-dev.1";
|
|
36
|
+
//#region ../../../1-framework/3-tooling/cli/dist/load-config-Cx3hKchL.mjs
|
|
38
37
|
const MISSING_CONFIG_ACTION = {
|
|
39
38
|
kind: "run-command",
|
|
40
39
|
label: "Create a config file",
|
|
@@ -2968,160 +2967,6 @@ function requirePeer(moduleId, baseDir, overrides) {
|
|
|
2968
2967
|
}
|
|
2969
2968
|
}
|
|
2970
2969
|
/**
|
|
2971
|
-
* Default base for the GitHub-URL form `<owner>/<repo>` consumed by
|
|
2972
|
-
* upstream `skills add`. Each `SkillSource` joins this base with its
|
|
2973
|
-
* own subpath (and optional `#ref` for version-pinned clusters).
|
|
2974
|
-
*/
|
|
2975
|
-
const DEFAULT_SKILL_BASE = "prisma/prisma";
|
|
2976
|
-
const DEFAULT_SKILL_SOURCES = [{
|
|
2977
|
-
subpath: "skills",
|
|
2978
|
-
skill: "prisma-8",
|
|
2979
|
-
ref: "cli",
|
|
2980
|
-
description: "usage skill (version-locked to installed Prisma Next)"
|
|
2981
|
-
}];
|
|
2982
|
-
/**
|
|
2983
|
-
* Test-only escape hatch for pinning the install base to a local
|
|
2984
|
-
* checkout. Production runs leave this unset, so installs always use
|
|
2985
|
-
* `DEFAULT_SKILL_BASE`.
|
|
2986
|
-
*
|
|
2987
|
-
* When set to an absolute filesystem path (typical for tests), the
|
|
2988
|
-
* `#ref` fragment is dropped — local-path mode in upstream's CLI does
|
|
2989
|
-
* not accept refs, and the local clone has whatever content the test
|
|
2990
|
-
* checked into it anyway. When set to anything else (e.g. a fork name
|
|
2991
|
-
* `myuser/prisma`), the ref policy is preserved.
|
|
2992
|
-
*/
|
|
2993
|
-
function resolveAgentSkillBase(env) {
|
|
2994
|
-
const override = env["PRISMA_NEXT_SKILLS_BASE"]?.trim();
|
|
2995
|
-
return override && override.length > 0 ? override : DEFAULT_SKILL_BASE;
|
|
2996
|
-
}
|
|
2997
|
-
function isLocalPath(base) {
|
|
2998
|
-
return base.startsWith("/") || /^[a-zA-Z]:[\\/]/.test(base);
|
|
2999
|
-
}
|
|
3000
|
-
/**
|
|
3001
|
-
* Agents passed to every project-level init install. Upstream `skills add`
|
|
3002
|
-
* is the source of truth for per-agent install behaviour; the CLI lists
|
|
3003
|
-
* every supported runtime on one invocation and delegates the rest.
|
|
3004
|
-
*/
|
|
3005
|
-
const DEFAULT_SKILL_AGENTS = [
|
|
3006
|
-
"cursor",
|
|
3007
|
-
"claude-code",
|
|
3008
|
-
"codex",
|
|
3009
|
-
"windsurf"
|
|
3010
|
-
];
|
|
3011
|
-
/**
|
|
3012
|
-
* Build the `<base>/<subpath>[#ref]` URL the `skills` CLI will
|
|
3013
|
-
* resolve. Exported for unit tests so the per-source format can be
|
|
3014
|
-
* asserted without going through the full install loop.
|
|
3015
|
-
*/
|
|
3016
|
-
function formatSkillSourceUrl(source, env = process.env) {
|
|
3017
|
-
const base = resolveAgentSkillBase(env);
|
|
3018
|
-
const url = `${base}/${source.subpath}`;
|
|
3019
|
-
if (source.ref === null) return url;
|
|
3020
|
-
if (isLocalPath(base)) return url;
|
|
3021
|
-
if (source.ref === "cli") return `${url}#v${version}`;
|
|
3022
|
-
return url;
|
|
3023
|
-
}
|
|
3024
|
-
/**
|
|
3025
|
-
* The skill-install command for one source, formatted for the
|
|
3026
|
-
* project's detected package manager. `npx`/`pnpm dlx`/`bunx` are
|
|
3027
|
-
* interchangeable to the user; we pick the variant that matches the
|
|
3028
|
-
* rest of the install step so a single project consistently uses one
|
|
3029
|
-
* runner.
|
|
3030
|
-
*
|
|
3031
|
-
* `--agent` takes space-separated slugs on one flag; the explicit
|
|
3032
|
-
* `--skill <name>` and `-y` skip the multi-select prompts a
|
|
3033
|
-
* non-interactive scaffold step cannot show.
|
|
3034
|
-
*
|
|
3035
|
-
* Exported for unit tests so the per-PM dispatch can be asserted
|
|
3036
|
-
* without a live subprocess.
|
|
3037
|
-
*/
|
|
3038
|
-
function formatSkillInstallCommand(args) {
|
|
3039
|
-
const agents = args.agents ?? DEFAULT_SKILL_AGENTS;
|
|
3040
|
-
const cliArgs = [
|
|
3041
|
-
"skills@latest",
|
|
3042
|
-
"add",
|
|
3043
|
-
formatSkillSourceUrl(args.source, args.env),
|
|
3044
|
-
"--agent",
|
|
3045
|
-
...agents,
|
|
3046
|
-
"--skill",
|
|
3047
|
-
args.source.skill,
|
|
3048
|
-
"-y"
|
|
3049
|
-
];
|
|
3050
|
-
return formatPackageManagerCommand(args.pm, cliArgs);
|
|
3051
|
-
}
|
|
3052
|
-
/**
|
|
3053
|
-
* Ordered skill-install commands for one init run. This is both what the
|
|
3054
|
-
* commander shell runs and what either shell tells the user to run when the
|
|
3055
|
-
* install is skipped or fails — the commands need no scaffold and no `init`.
|
|
3056
|
-
*/
|
|
3057
|
-
function resolveProjectSkillInstallCommands(pm, env) {
|
|
3058
|
-
return DEFAULT_SKILL_SOURCES.map((source) => formatSkillInstallCommand({
|
|
3059
|
-
pm,
|
|
3060
|
-
source,
|
|
3061
|
-
...ifDefined("env", env)
|
|
3062
|
-
}));
|
|
3063
|
-
}
|
|
3064
|
-
function formatPackageManagerCommand(pm, args) {
|
|
3065
|
-
switch (pm) {
|
|
3066
|
-
case "pnpm": return `pnpm dlx ${args.join(" ")}`;
|
|
3067
|
-
case "yarn": return `yarn dlx ${args.join(" ")}`;
|
|
3068
|
-
case "bun": return `bunx ${args.join(" ")}`;
|
|
3069
|
-
case "deno": return `deno run -A npm:${args.join(" ")}`;
|
|
3070
|
-
case "npm": return `npx ${args.join(" ")}`;
|
|
3071
|
-
}
|
|
3072
|
-
}
|
|
3073
|
-
/**
|
|
3074
|
-
* Skill directories that predate the consolidated `prisma-8` skill:
|
|
3075
|
-
* the per-workflow usage cluster (including the renamed
|
|
3076
|
-
* `prisma-8-migration-review` spelling it briefly shipped under), the
|
|
3077
|
-
* pre-rename spellings of the consolidated skill and the
|
|
3078
|
-
* extension-author upgrade skill, any hand-rolled `prisma-next` stub,
|
|
3079
|
-
* and the two standalone upgrade skills that folded into the
|
|
3080
|
-
* `prisma-8` router. Projects initialised before the consolidation carry these as
|
|
3081
|
-
* sibling directories in each agent's install root; left in place
|
|
3082
|
-
* they compete with the current skills for activation, so init
|
|
3083
|
-
* removes them on every run.
|
|
3084
|
-
*/
|
|
3085
|
-
const RETIRED_SKILL_NAMES = [
|
|
3086
|
-
"prisma-next",
|
|
3087
|
-
"prisma-next-quickstart",
|
|
3088
|
-
"prisma-next-contract",
|
|
3089
|
-
"prisma-next-migrations",
|
|
3090
|
-
"prisma-next-migration-review",
|
|
3091
|
-
"prisma-8-migration-review",
|
|
3092
|
-
"prisma-next-queries",
|
|
3093
|
-
"prisma-next-runtime",
|
|
3094
|
-
"prisma-next-build",
|
|
3095
|
-
"prisma-next-supabase",
|
|
3096
|
-
"prisma-next-debug",
|
|
3097
|
-
"prisma-next-feedback",
|
|
3098
|
-
"prisma-next-extension-upgrade",
|
|
3099
|
-
"prisma-next-upgrade",
|
|
3100
|
-
"prisma-8-extension-upgrade"
|
|
3101
|
-
];
|
|
3102
|
-
/**
|
|
3103
|
-
* Project-level install roots the upstream `skills` CLI uses for the
|
|
3104
|
-
* agents in `DEFAULT_SKILL_AGENTS`: cursor and codex install into
|
|
3105
|
-
* `.agents/skills`, claude-code into `.claude/skills`, windsurf into
|
|
3106
|
-
* `.windsurf/skills`.
|
|
3107
|
-
*/
|
|
3108
|
-
const AGENT_SKILL_ROOTS = [
|
|
3109
|
-
".agents/skills",
|
|
3110
|
-
".claude/skills",
|
|
3111
|
-
".windsurf/skills"
|
|
3112
|
-
];
|
|
3113
|
-
/**
|
|
3114
|
-
* Every directory a retired per-workflow skill may occupy in a
|
|
3115
|
-
* consumer project. Init deletes each (recursively) before running the
|
|
3116
|
-
* skill install. Names that are also in `DEFAULT_SKILL_SOURCES` are
|
|
3117
|
-
* excluded so a list mistake can never delete a skill init installs
|
|
3118
|
-
* (or one `--skip-skills` preserves) — see TML-2637.
|
|
3119
|
-
*/
|
|
3120
|
-
function legacySkillDirs(retired = RETIRED_SKILL_NAMES, sources = DEFAULT_SKILL_SOURCES) {
|
|
3121
|
-
const installed = new Set(sources.map((source) => source.skill));
|
|
3122
|
-
return AGENT_SKILL_ROOTS.flatMap((root) => retired.filter((name) => !installed.has(name)).map((name) => `${root}/${name}`));
|
|
3123
|
-
}
|
|
3124
|
-
/**
|
|
3125
2970
|
* The resolver a scaffold for `target` is written against.
|
|
3126
2971
|
*
|
|
3127
2972
|
* A scaffold is always on the facade root: `init` writes an application around
|
|
@@ -3486,7 +3331,7 @@ function envFileContent(target) {
|
|
|
3486
3331
|
return envPlaceholderBody(target);
|
|
3487
3332
|
}
|
|
3488
3333
|
/** The invocation that finishes what a failed `init` phase started. */
|
|
3489
|
-
const EMIT_COMMAND = "prisma
|
|
3334
|
+
const EMIT_COMMAND = "prisma contract emit";
|
|
3490
3335
|
/**
|
|
3491
3336
|
* The command's own record of a phase that failed after the scaffold was
|
|
3492
3337
|
* written. The scaffold is on disk and the run has a result to report, so each
|
|
@@ -3530,22 +3375,6 @@ function emitFailedFinding(cause, filesWritten) {
|
|
|
3530
3375
|
}
|
|
3531
3376
|
});
|
|
3532
3377
|
}
|
|
3533
|
-
/**
|
|
3534
|
-
* An agent-skill install failed; the project itself is complete without it.
|
|
3535
|
-
* The remedy is the skill-install commands themselves, which run against any
|
|
3536
|
-
* directory — advising a re-run of `init` would put the user's schema at risk
|
|
3537
|
-
* to fix something `init` no longer needs to be involved in.
|
|
3538
|
-
*/
|
|
3539
|
-
function skillInstallFailedFinding(failure, filesWritten, skillCommands) {
|
|
3540
|
-
return initFinding("CLI.INIT_SKILL_INSTALL_FAILED", "Failed to install Prisma Next skills", {
|
|
3541
|
-
why: failure.why ?? failure.message,
|
|
3542
|
-
nextActions: [...failure.nextActions, ...skillCommands.map((command) => runCommandAction("Install the Prisma Next skills", command))],
|
|
3543
|
-
meta: {
|
|
3544
|
-
filesWritten,
|
|
3545
|
-
skillInstall: failure.meta ?? {}
|
|
3546
|
-
}
|
|
3547
|
-
});
|
|
3548
|
-
}
|
|
3549
3378
|
function fileNodes(paths) {
|
|
3550
3379
|
return paths.map((path) => ({
|
|
3551
3380
|
label: path,
|
|
@@ -3590,7 +3419,7 @@ function buildInitNextActions(inputs) {
|
|
|
3590
3419
|
label: `Edit your schema at ${inputs.schemaPath}, then emit again`
|
|
3591
3420
|
});
|
|
3592
3421
|
actions.push(chooseAction("Open prisma-next.md for a quick reference on writing your first typed query"));
|
|
3593
|
-
|
|
3422
|
+
actions.push(runCommandAction("Set up the Prisma agent skills for your coding agent", "prisma init"));
|
|
3594
3423
|
return actions;
|
|
3595
3424
|
}
|
|
3596
3425
|
const DONE_TEXT = "Done. Open prisma-next.md to get started.";
|
|
@@ -3654,7 +3483,7 @@ function redactSecrets(stderr) {
|
|
|
3654
3483
|
}
|
|
3655
3484
|
/**
|
|
3656
3485
|
* Emits the contract for the project `init` has just scaffolded, by spawning
|
|
3657
|
-
* the project-local `prisma
|
|
3486
|
+
* the project-local `prisma` binary the install step put into
|
|
3658
3487
|
* `node_modules`. That binary and the installed `defineConfig` come from the
|
|
3659
3488
|
* same registry release, so the config loader that evaluates
|
|
3660
3489
|
* `prisma.config.ts` always matches the config format it was written
|
|
@@ -3672,26 +3501,26 @@ async function emitScaffoldedContract(ctx, overrides = {}) {
|
|
|
3672
3501
|
if (result.exitCode !== 0) {
|
|
3673
3502
|
const output = result.stderr.trim().length > 0 ? result.stderr : result.stdout;
|
|
3674
3503
|
const cause = result.exitCode === null ? `was killed by signal ${result.signal ?? "unknown"}` : `exited with code ${result.exitCode}`;
|
|
3675
|
-
throw new Error(`\`prisma
|
|
3504
|
+
throw new Error(`\`prisma contract emit\` ${cause}: ${redactSecrets(tail(output))}`);
|
|
3676
3505
|
}
|
|
3677
3506
|
}
|
|
3678
3507
|
function resolveProjectBin(cwd, overrides) {
|
|
3679
3508
|
const resolveFromBaseDir = overrides.resolveFromBaseDir ?? ((baseDir, specifier) => createRequire(join(baseDir, "package.json")).resolve(specifier));
|
|
3680
3509
|
let manifestPath;
|
|
3681
3510
|
try {
|
|
3682
|
-
manifestPath = resolveFromBaseDir(cwd, "
|
|
3511
|
+
manifestPath = resolveFromBaseDir(cwd, "prisma/package.json");
|
|
3683
3512
|
} catch (error) {
|
|
3684
|
-
throw new Error(
|
|
3513
|
+
throw new Error(`\`prisma\` is not installed in this project (resolved from ${cwd}; cause: ${causeMessage$1(error)})`);
|
|
3685
3514
|
}
|
|
3686
3515
|
let manifest;
|
|
3687
3516
|
try {
|
|
3688
3517
|
manifest = JSON.parse(readFileSync(manifestPath, "utf-8"));
|
|
3689
3518
|
} catch (error) {
|
|
3690
|
-
throw new Error(`the installed
|
|
3519
|
+
throw new Error(`the installed prisma manifest at ${manifestPath} is not valid JSON: ${causeMessage$1(error)}`);
|
|
3691
3520
|
}
|
|
3692
3521
|
const bin = manifest !== null && typeof manifest === "object" ? Reflect.get(manifest, "bin") : void 0;
|
|
3693
|
-
const binEntry = typeof bin === "string" ? bin : bin !== null && typeof bin === "object" ? Reflect.get(bin, "prisma
|
|
3694
|
-
if (typeof binEntry !== "string") throw new Error(`the installed
|
|
3522
|
+
const binEntry = typeof bin === "string" ? bin : bin !== null && typeof bin === "object" ? Reflect.get(bin, "prisma") : void 0;
|
|
3523
|
+
if (typeof binEntry !== "string") throw new Error(`the installed prisma package at ${dirname(manifestPath)} declares no \`prisma\` bin`);
|
|
3695
3524
|
return join(dirname(manifestPath), binEntry);
|
|
3696
3525
|
}
|
|
3697
3526
|
function runCaptured(file, args, cwd) {
|
|
@@ -3713,7 +3542,7 @@ function runCaptured(file, args, cwd) {
|
|
|
3713
3542
|
stderr += chunk.toString("utf-8");
|
|
3714
3543
|
});
|
|
3715
3544
|
child.on("error", (error) => {
|
|
3716
|
-
reject(/* @__PURE__ */ new Error(`could not run the project-local prisma
|
|
3545
|
+
reject(/* @__PURE__ */ new Error(`could not run the project-local prisma binary: ${error.message}`));
|
|
3717
3546
|
});
|
|
3718
3547
|
child.on("close", (code, signal) => {
|
|
3719
3548
|
resolve({
|
|
@@ -3811,7 +3640,7 @@ function formatRunScriptCommand(pm, scriptName) {
|
|
|
3811
3640
|
* [`.gitattributes`](../../../../../../../../.gitattributes):
|
|
3812
3641
|
*
|
|
3813
3642
|
* - **Today**: `contract.json`, `contract.d.ts` are emitted on every
|
|
3814
|
-
* `prisma
|
|
3643
|
+
* `prisma contract emit`. Marking them `linguist-generated`
|
|
3815
3644
|
* keeps GitHub's diff stats honest and collapses the file in code
|
|
3816
3645
|
* review by default.
|
|
3817
3646
|
* - **Forward-looking**: `ops.json`, `migration.json` are not yet emitted
|
|
@@ -3922,7 +3751,7 @@ function mergeGitignore(existing) {
|
|
|
3922
3751
|
}
|
|
3923
3752
|
const REQUIRED_SCRIPTS = [{
|
|
3924
3753
|
name: "contract:emit",
|
|
3925
|
-
command: "prisma
|
|
3754
|
+
command: "prisma contract emit"
|
|
3926
3755
|
}];
|
|
3927
3756
|
/**
|
|
3928
3757
|
* Idempotent `package.json#scripts` merge with collision detection
|
|
@@ -4093,6 +3922,51 @@ function removeDependency(existing, depName) {
|
|
|
4093
3922
|
const trailingNewline = existing.endsWith("\n") ? "\n" : "";
|
|
4094
3923
|
return `${JSON.stringify(parsed, null, 2)}${trailingNewline}`;
|
|
4095
3924
|
}
|
|
3925
|
+
/**
|
|
3926
|
+
* Skill directories that predate the consolidated `prisma-8` skill: the
|
|
3927
|
+
* per-workflow usage cluster (including the renamed
|
|
3928
|
+
* `prisma-8-migration-review` spelling it briefly shipped under), the
|
|
3929
|
+
* pre-rename spellings of the consolidated skill and the extension-author
|
|
3930
|
+
* upgrade skill, any hand-rolled `prisma-next` stub, and the two standalone
|
|
3931
|
+
* upgrade skills that folded into the `prisma-8` router. Projects initialised
|
|
3932
|
+
* before those changes carry these as sibling directories in each agent's
|
|
3933
|
+
* install root; left in place they compete with the current skill for
|
|
3934
|
+
* activation, so init removes them on every run.
|
|
3935
|
+
*/
|
|
3936
|
+
const RETIRED_SKILL_NAMES = [
|
|
3937
|
+
"prisma-next",
|
|
3938
|
+
"prisma-next-quickstart",
|
|
3939
|
+
"prisma-next-contract",
|
|
3940
|
+
"prisma-next-migrations",
|
|
3941
|
+
"prisma-next-migration-review",
|
|
3942
|
+
"prisma-8-migration-review",
|
|
3943
|
+
"prisma-next-queries",
|
|
3944
|
+
"prisma-next-runtime",
|
|
3945
|
+
"prisma-next-build",
|
|
3946
|
+
"prisma-next-supabase",
|
|
3947
|
+
"prisma-next-debug",
|
|
3948
|
+
"prisma-next-feedback",
|
|
3949
|
+
"prisma-next-extension-upgrade",
|
|
3950
|
+
"prisma-next-upgrade",
|
|
3951
|
+
"prisma-8-extension-upgrade"
|
|
3952
|
+
];
|
|
3953
|
+
/**
|
|
3954
|
+
* The project-level skill directories the agent harnesses read: Claude Code,
|
|
3955
|
+
* Cursor, Codex (`.agents`), and Windsurf.
|
|
3956
|
+
*/
|
|
3957
|
+
const AGENT_SKILL_ROOTS = [
|
|
3958
|
+
".claude/skills",
|
|
3959
|
+
".cursor/skills",
|
|
3960
|
+
".agents/skills",
|
|
3961
|
+
".windsurf/skills"
|
|
3962
|
+
];
|
|
3963
|
+
/**
|
|
3964
|
+
* Every directory a retired skill may occupy in a consumer project. Init
|
|
3965
|
+
* deletes each (recursively) on every run.
|
|
3966
|
+
*/
|
|
3967
|
+
function legacySkillDirs() {
|
|
3968
|
+
return AGENT_SKILL_ROOTS.flatMap((root) => RETIRED_SKILL_NAMES.map((name) => `${root}/${name}`));
|
|
3969
|
+
}
|
|
4096
3970
|
function renderTemplate(templateFile, variableNames, vars) {
|
|
4097
3971
|
let result = readFileSync(join(import.meta.dirname, templateFile), "utf-8");
|
|
4098
3972
|
for (const key of variableNames) {
|
|
@@ -4123,7 +3997,7 @@ function quickReferenceMd(target, authoring, schemaPath, pkgRun, resolveImportSp
|
|
|
4123
3997
|
pkg,
|
|
4124
3998
|
configEntrypoint: targetEntrypoint(target, "config", resolveImportSpecifier),
|
|
4125
3999
|
schemaSample: schemaSample(target, authoring, resolveImportSpecifier),
|
|
4126
|
-
requirements: requirementsBlock(target)
|
|
4000
|
+
requirements: requirementsBlock(target, pkgRun)
|
|
4127
4001
|
};
|
|
4128
4002
|
return renderTemplate(`quick-reference-${target}.md`, variables, vars);
|
|
4129
4003
|
}
|
|
@@ -4138,12 +4012,12 @@ function quickReferenceMd(target, authoring, schemaPath, pkgRun, resolveImportSp
|
|
|
4138
4012
|
* shouldn't ship Mongo's `db.runCommand` (and vice versa) just because
|
|
4139
4013
|
* we couldn't be bothered to branch.
|
|
4140
4014
|
*/
|
|
4141
|
-
function requirementsBlock(target) {
|
|
4015
|
+
function requirementsBlock(target, pkgRun) {
|
|
4142
4016
|
return [
|
|
4143
4017
|
"## Requirements",
|
|
4144
4018
|
"",
|
|
4145
4019
|
`- **${TARGET_LABEL[target]} ${MIN_SERVER_VERSION[target]} or newer.** Older servers are not supported. Run ${target === "postgres" ? "`SELECT version()`" : "`db.runCommand({ buildInfo: 1 })`"} against your server to verify.`,
|
|
4146
|
-
|
|
4020
|
+
`- The CLI never connects to your database without explicit consent. Pass \`--probe-db\` to \`${pkgRun} orm init\` if you want \`init\` to verify the server version itself.`
|
|
4147
4021
|
].join("\n");
|
|
4148
4022
|
}
|
|
4149
4023
|
const sharedVariables = [
|
|
@@ -4428,7 +4302,7 @@ function planScaffold(ctx) {
|
|
|
4428
4302
|
const warnings = [];
|
|
4429
4303
|
const schemaDir = dirname(inputs.schemaPath);
|
|
4430
4304
|
const configContractPath = isAbsolute(inputs.schemaPath) ? inputs.schemaPath : `./${inputs.schemaPath}`;
|
|
4431
|
-
const runPrefix = formatRunCommand(packageManager, "prisma
|
|
4305
|
+
const runPrefix = formatRunCommand(packageManager, "prisma", "").trimEnd();
|
|
4432
4306
|
const files = [
|
|
4433
4307
|
{
|
|
4434
4308
|
path: inputs.schemaPath,
|
|
@@ -4517,7 +4391,7 @@ function planScaffold(ctx) {
|
|
|
4517
4391
|
changed = true;
|
|
4518
4392
|
}
|
|
4519
4393
|
}
|
|
4520
|
-
const { content: withScripts, warnings: scriptWarnings } = mergePackageScripts(working
|
|
4394
|
+
const { content: withScripts, warnings: scriptWarnings } = mergePackageScripts(working);
|
|
4521
4395
|
if (withScripts !== null) {
|
|
4522
4396
|
working = withScripts;
|
|
4523
4397
|
changed = true;
|
|
@@ -4748,8 +4622,7 @@ async function resolveInitInputs(ctx) {
|
|
|
4748
4622
|
probeDb: flags.probeDb,
|
|
4749
4623
|
strictProbe: flags.strictProbe,
|
|
4750
4624
|
reinit,
|
|
4751
|
-
removePreviousFacade
|
|
4752
|
-
installProjectSkill: !flags.skipSkills
|
|
4625
|
+
removePreviousFacade
|
|
4753
4626
|
};
|
|
4754
4627
|
}
|
|
4755
4628
|
/**
|
|
@@ -4811,7 +4684,7 @@ function retriedWarning(failure) {
|
|
|
4811
4684
|
/**
|
|
4812
4685
|
* The engine dependency spec a fresh scaffold installs. The scaffolded
|
|
4813
4686
|
* `prisma.config.ts` imports `defineConfig` from `@prisma/cli-engine`, and the
|
|
4814
|
-
* installed
|
|
4687
|
+
* installed `prisma` names the exact engine version it runs against — so
|
|
4815
4688
|
* the spec is read from the manifest the install just placed, never guessed
|
|
4816
4689
|
* from a dist-tag (whose `latest` has lagged that version before and broken
|
|
4817
4690
|
* the very next command). A CLI without a readable engine entry falls back to
|
|
@@ -4819,7 +4692,7 @@ function retriedWarning(failure) {
|
|
|
4819
4692
|
*/
|
|
4820
4693
|
function engineDevDependencySpec(cwd) {
|
|
4821
4694
|
try {
|
|
4822
|
-
const manifest = JSON.parse(readFileSync(join(cwd, "node_modules", "
|
|
4695
|
+
const manifest = JSON.parse(readFileSync(join(cwd, "node_modules", "prisma", "package.json"), "utf-8"));
|
|
4823
4696
|
if (typeof manifest === "object" && manifest !== null) for (const field of ["dependencies", "peerDependencies"]) {
|
|
4824
4697
|
const block = Reflect.get(manifest, field);
|
|
4825
4698
|
if (typeof block === "object" && block !== null) {
|
|
@@ -4869,38 +4742,10 @@ async function installProjectDependencies(ctx) {
|
|
|
4869
4742
|
warnings: [fallbackWarning(failure)]
|
|
4870
4743
|
};
|
|
4871
4744
|
}
|
|
4872
|
-
function skillArgs(url, skill) {
|
|
4873
|
-
return [
|
|
4874
|
-
"add",
|
|
4875
|
-
url,
|
|
4876
|
-
"--agent",
|
|
4877
|
-
...DEFAULT_SKILL_AGENTS,
|
|
4878
|
-
"--skill",
|
|
4879
|
-
skill,
|
|
4880
|
-
"-y"
|
|
4881
|
-
];
|
|
4882
|
-
}
|
|
4883
|
-
/**
|
|
4884
|
-
* Registers every Prisma Next skill with the agent runtimes, in order. The
|
|
4885
|
-
* first failure stops the loop: the user opted into Prisma Next by running
|
|
4886
|
-
* `init`, and a half-installed skill set leaves the project ambiguous.
|
|
4887
|
-
*/
|
|
4888
|
-
async function installAgentSkills(ctx) {
|
|
4889
|
-
for (const source of DEFAULT_SKILL_SOURCES) {
|
|
4890
|
-
const result = await ctx.packages.run({
|
|
4891
|
-
package: "skills@latest",
|
|
4892
|
-
args: skillArgs(formatSkillSourceUrl(source, ctx.env), source.skill),
|
|
4893
|
-
cwd: ctx.cwd,
|
|
4894
|
-
...ifDefined("manager", ctx.manager)
|
|
4895
|
-
});
|
|
4896
|
-
if (!result.ok) return result.failure;
|
|
4897
|
-
}
|
|
4898
|
-
}
|
|
4899
4745
|
/** The scaffold is on disk from here on, so each of these is a finding. */
|
|
4900
4746
|
const INIT_EXIT_CODES = {
|
|
4901
4747
|
4: "scaffold written; dependency install failed",
|
|
4902
|
-
5: "scaffold written and installed; contract emit failed"
|
|
4903
|
-
6: "scaffold complete; agent-skill install failed"
|
|
4748
|
+
5: "scaffold written and installed; contract emit failed"
|
|
4904
4749
|
};
|
|
4905
4750
|
function probeWarning(outcome, strictProbe) {
|
|
4906
4751
|
switch (outcome.kind) {
|
|
@@ -4935,7 +4780,6 @@ const createInitCommand = (injected) => defineOrmCommand({
|
|
|
4935
4780
|
"orm init --target postgres --authoring psl",
|
|
4936
4781
|
"orm init --target mongodb --authoring typescript --json",
|
|
4937
4782
|
"orm init --skip-install",
|
|
4938
|
-
"orm init --skip-skills",
|
|
4939
4783
|
"orm init --target postgres --keep-previous-facade"
|
|
4940
4784
|
]
|
|
4941
4785
|
},
|
|
@@ -4956,7 +4800,6 @@ const createInitCommand = (injected) => defineOrmCommand({
|
|
|
4956
4800
|
probeDb: flag.boolean({ brief: "Connect to DATABASE_URL once and check the server version" }),
|
|
4957
4801
|
strictProbe: flag.boolean({ brief: "Treat a failed --probe-db as fatal" }),
|
|
4958
4802
|
skipInstall: flag.boolean({ brief: "Skip dependency installation and contract emission" }),
|
|
4959
|
-
skipSkills: flag.boolean({ brief: "Skip the Prisma Next agent-skill install" }),
|
|
4960
4803
|
keepPreviousFacade: flag.boolean({ brief: "Keep the previous target package in package.json when switching targets" })
|
|
4961
4804
|
} },
|
|
4962
4805
|
exitCodes: INIT_EXIT_CODES,
|
|
@@ -4992,14 +4835,12 @@ const createInitCommand = (injected) => defineOrmCommand({
|
|
|
4992
4835
|
text: note
|
|
4993
4836
|
});
|
|
4994
4837
|
const deps = [targetPackageName(inputs.target, scaffold.resolveImportSpecifier), "dotenv"];
|
|
4995
|
-
const cliDevDeps = ["
|
|
4838
|
+
const cliDevDeps = ["prisma@next"];
|
|
4996
4839
|
const devDeps = scaffold.hasTypesNode ? cliDevDeps : [...cliDevDeps, "@types/node"];
|
|
4997
4840
|
const findings = [];
|
|
4998
4841
|
const extraActions = [];
|
|
4999
|
-
let installedManager;
|
|
5000
4842
|
let packagesInstalled = "skipped";
|
|
5001
4843
|
let contractEmitted = false;
|
|
5002
|
-
let skillRegistered = false;
|
|
5003
4844
|
const settle = (exitCode) => {
|
|
5004
4845
|
const installed = packagesInstalled === "installed";
|
|
5005
4846
|
const document = {
|
|
@@ -5020,8 +4861,7 @@ const createInitCommand = (injected) => defineOrmCommand({
|
|
|
5020
4861
|
packagesInstalled,
|
|
5021
4862
|
contractEmitted,
|
|
5022
4863
|
emitCommand: EMIT_COMMAND,
|
|
5023
|
-
schemaPath: inputs.schemaPath
|
|
5024
|
-
skillRegistered
|
|
4864
|
+
schemaPath: inputs.schemaPath
|
|
5025
4865
|
}),
|
|
5026
4866
|
warnings
|
|
5027
4867
|
};
|
|
@@ -5040,8 +4880,7 @@ const createInitCommand = (injected) => defineOrmCommand({
|
|
|
5040
4880
|
complete: exitCode === 0,
|
|
5041
4881
|
nextActions: [...extraActions, ...buildInitNextActions({
|
|
5042
4882
|
contractEmitted,
|
|
5043
|
-
schemaPath: inputs.schemaPath
|
|
5044
|
-
skillRegistered
|
|
4883
|
+
schemaPath: inputs.schemaPath
|
|
5045
4884
|
})]
|
|
5046
4885
|
})));
|
|
5047
4886
|
};
|
|
@@ -5073,7 +4912,6 @@ const createInitCommand = (injected) => defineOrmCommand({
|
|
|
5073
4912
|
}
|
|
5074
4913
|
devDeps.push(engineSpec);
|
|
5075
4914
|
packagesInstalled = "installed";
|
|
5076
|
-
installedManager = outcome.manager;
|
|
5077
4915
|
const emitStep = "Emit the contract";
|
|
5078
4916
|
ctx.report({
|
|
5079
4917
|
kind: "step-started",
|
|
@@ -5096,7 +4934,7 @@ const createInitCommand = (injected) => defineOrmCommand({
|
|
|
5096
4934
|
findings.push(emitFailedFinding(causeMessage(error), scaffold.filesWritten));
|
|
5097
4935
|
return settle(5);
|
|
5098
4936
|
}
|
|
5099
|
-
} else extraActions.push(chooseAction(`Install the project dependencies with your package manager: ${deps.join(", ")} (and ${devDeps.join(", ")} plus @prisma/cli-engine at the version
|
|
4937
|
+
} 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 declares as its dependency, as development dependencies)`));
|
|
5100
4938
|
if (inputs.probeDb) {
|
|
5101
4939
|
const probe = probeWarning(await probeServerVersion({
|
|
5102
4940
|
baseDir: ctx.cwd,
|
|
@@ -5110,20 +4948,6 @@ const createInitCommand = (injected) => defineOrmCommand({
|
|
|
5110
4948
|
filesWritten: scaffold.filesWritten
|
|
5111
4949
|
})));
|
|
5112
4950
|
}
|
|
5113
|
-
const skillCommands = resolveProjectSkillInstallCommands(installedManager ?? packageManager, ctx.env);
|
|
5114
|
-
if (inputs.installProjectSkill) {
|
|
5115
|
-
const failure = await installAgentSkills({
|
|
5116
|
-
packages: ctx.packages,
|
|
5117
|
-
cwd: ctx.cwd,
|
|
5118
|
-
env: ctx.env,
|
|
5119
|
-
manager: installedManager
|
|
5120
|
-
});
|
|
5121
|
-
if (failure !== void 0) {
|
|
5122
|
-
findings.push(skillInstallFailedFinding(failure, scaffold.filesWritten, skillCommands));
|
|
5123
|
-
return settle(6);
|
|
5124
|
-
}
|
|
5125
|
-
skillRegistered = true;
|
|
5126
|
-
} else warn(`Skipped the Prisma Next agent-skill install (--skip-skills). To install them later, run: ${skillCommands.map((command) => `\`${command}\``).join(" && ")}`);
|
|
5127
4951
|
return settle(0);
|
|
5128
4952
|
}
|
|
5129
4953
|
});
|