@prisma/orm-toolchain 8.0.0-rc.5 → 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 -259
- 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";
|
|
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,171 +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
|
-
{
|
|
2978
|
-
subpath: "skills",
|
|
2979
|
-
skill: "prisma-8",
|
|
2980
|
-
ref: "cli",
|
|
2981
|
-
description: "usage skill (version-locked to installed Prisma Next)"
|
|
2982
|
-
},
|
|
2983
|
-
{
|
|
2984
|
-
subpath: "skills",
|
|
2985
|
-
skill: "prisma-next-upgrade",
|
|
2986
|
-
ref: null,
|
|
2987
|
-
description: "upgrade skill (always tracks `main`)"
|
|
2988
|
-
},
|
|
2989
|
-
{
|
|
2990
|
-
subpath: "skills",
|
|
2991
|
-
skill: "prisma-8-extension-upgrade",
|
|
2992
|
-
ref: null,
|
|
2993
|
-
description: "extension-author upgrade skill (always tracks `main`)"
|
|
2994
|
-
}
|
|
2995
|
-
];
|
|
2996
|
-
/**
|
|
2997
|
-
* Test-only escape hatch for pinning the install base to a local
|
|
2998
|
-
* checkout. Production runs leave this unset, so installs always use
|
|
2999
|
-
* `DEFAULT_SKILL_BASE`.
|
|
3000
|
-
*
|
|
3001
|
-
* When set to an absolute filesystem path (typical for tests), the
|
|
3002
|
-
* `#ref` fragment is dropped — local-path mode in upstream's CLI does
|
|
3003
|
-
* not accept refs, and the local clone has whatever content the test
|
|
3004
|
-
* checked into it anyway. When set to anything else (e.g. a fork name
|
|
3005
|
-
* `myuser/prisma`), the ref policy is preserved.
|
|
3006
|
-
*/
|
|
3007
|
-
function resolveAgentSkillBase(env) {
|
|
3008
|
-
const override = env["PRISMA_NEXT_SKILLS_BASE"]?.trim();
|
|
3009
|
-
return override && override.length > 0 ? override : DEFAULT_SKILL_BASE;
|
|
3010
|
-
}
|
|
3011
|
-
function isLocalPath(base) {
|
|
3012
|
-
return base.startsWith("/") || /^[a-zA-Z]:[\\/]/.test(base);
|
|
3013
|
-
}
|
|
3014
|
-
/**
|
|
3015
|
-
* Agents passed to every project-level init install. Upstream `skills add`
|
|
3016
|
-
* is the source of truth for per-agent install behaviour; the CLI lists
|
|
3017
|
-
* every supported runtime on one invocation and delegates the rest.
|
|
3018
|
-
*/
|
|
3019
|
-
const DEFAULT_SKILL_AGENTS = [
|
|
3020
|
-
"cursor",
|
|
3021
|
-
"claude-code",
|
|
3022
|
-
"codex",
|
|
3023
|
-
"windsurf"
|
|
3024
|
-
];
|
|
3025
|
-
/**
|
|
3026
|
-
* Build the `<base>/<subpath>[#ref]` URL the `skills` CLI will
|
|
3027
|
-
* resolve. Exported for unit tests so the per-source format can be
|
|
3028
|
-
* asserted without going through the full install loop.
|
|
3029
|
-
*/
|
|
3030
|
-
function formatSkillSourceUrl(source, env = process.env) {
|
|
3031
|
-
const base = resolveAgentSkillBase(env);
|
|
3032
|
-
const url = `${base}/${source.subpath}`;
|
|
3033
|
-
if (source.ref === null) return url;
|
|
3034
|
-
if (isLocalPath(base)) return url;
|
|
3035
|
-
if (source.ref === "cli") return `${url}#v${version}`;
|
|
3036
|
-
return url;
|
|
3037
|
-
}
|
|
3038
|
-
/**
|
|
3039
|
-
* The skill-install command for one source, formatted for the
|
|
3040
|
-
* project's detected package manager. `npx`/`pnpm dlx`/`bunx` are
|
|
3041
|
-
* interchangeable to the user; we pick the variant that matches the
|
|
3042
|
-
* rest of the install step so a single project consistently uses one
|
|
3043
|
-
* runner.
|
|
3044
|
-
*
|
|
3045
|
-
* `--agent` takes space-separated slugs on one flag; the explicit
|
|
3046
|
-
* `--skill <name>` and `-y` skip the multi-select prompts a
|
|
3047
|
-
* non-interactive scaffold step cannot show.
|
|
3048
|
-
*
|
|
3049
|
-
* Exported for unit tests so the per-PM dispatch can be asserted
|
|
3050
|
-
* without a live subprocess.
|
|
3051
|
-
*/
|
|
3052
|
-
function formatSkillInstallCommand(args) {
|
|
3053
|
-
const agents = args.agents ?? DEFAULT_SKILL_AGENTS;
|
|
3054
|
-
const cliArgs = [
|
|
3055
|
-
"skills@latest",
|
|
3056
|
-
"add",
|
|
3057
|
-
formatSkillSourceUrl(args.source, args.env),
|
|
3058
|
-
"--agent",
|
|
3059
|
-
...agents,
|
|
3060
|
-
"--skill",
|
|
3061
|
-
args.source.skill,
|
|
3062
|
-
"-y"
|
|
3063
|
-
];
|
|
3064
|
-
return formatPackageManagerCommand(args.pm, cliArgs);
|
|
3065
|
-
}
|
|
3066
|
-
/**
|
|
3067
|
-
* Ordered skill-install commands for one init run. This is both what the
|
|
3068
|
-
* commander shell runs and what either shell tells the user to run when the
|
|
3069
|
-
* install is skipped or fails — the commands need no scaffold and no `init`.
|
|
3070
|
-
*/
|
|
3071
|
-
function resolveProjectSkillInstallCommands(pm, env) {
|
|
3072
|
-
return DEFAULT_SKILL_SOURCES.map((source) => formatSkillInstallCommand({
|
|
3073
|
-
pm,
|
|
3074
|
-
source,
|
|
3075
|
-
...ifDefined("env", env)
|
|
3076
|
-
}));
|
|
3077
|
-
}
|
|
3078
|
-
function formatPackageManagerCommand(pm, args) {
|
|
3079
|
-
switch (pm) {
|
|
3080
|
-
case "pnpm": return `pnpm dlx ${args.join(" ")}`;
|
|
3081
|
-
case "yarn": return `yarn dlx ${args.join(" ")}`;
|
|
3082
|
-
case "bun": return `bunx ${args.join(" ")}`;
|
|
3083
|
-
case "deno": return `deno run -A npm:${args.join(" ")}`;
|
|
3084
|
-
case "npm": return `npx ${args.join(" ")}`;
|
|
3085
|
-
}
|
|
3086
|
-
}
|
|
3087
|
-
/**
|
|
3088
|
-
* Skill directories that predate the consolidated `prisma-8` skill:
|
|
3089
|
-
* the per-workflow usage cluster (including the renamed
|
|
3090
|
-
* `prisma-8-migration-review` spelling it briefly shipped under), the
|
|
3091
|
-
* pre-rename spellings of the consolidated skill and the
|
|
3092
|
-
* extension-author upgrade skill, and any hand-rolled `prisma-next`
|
|
3093
|
-
* stub. Projects initialised before the consolidation carry these as
|
|
3094
|
-
* sibling directories in each agent's install root; left in place
|
|
3095
|
-
* they compete with the current skills for activation, so init
|
|
3096
|
-
* removes them on every run.
|
|
3097
|
-
*/
|
|
3098
|
-
const RETIRED_SKILL_NAMES = [
|
|
3099
|
-
"prisma-next",
|
|
3100
|
-
"prisma-next-quickstart",
|
|
3101
|
-
"prisma-next-contract",
|
|
3102
|
-
"prisma-next-migrations",
|
|
3103
|
-
"prisma-next-migration-review",
|
|
3104
|
-
"prisma-8-migration-review",
|
|
3105
|
-
"prisma-next-queries",
|
|
3106
|
-
"prisma-next-runtime",
|
|
3107
|
-
"prisma-next-build",
|
|
3108
|
-
"prisma-next-supabase",
|
|
3109
|
-
"prisma-next-debug",
|
|
3110
|
-
"prisma-next-feedback",
|
|
3111
|
-
"prisma-next-extension-upgrade"
|
|
3112
|
-
];
|
|
3113
|
-
/**
|
|
3114
|
-
* Project-level install roots the upstream `skills` CLI uses for the
|
|
3115
|
-
* agents in `DEFAULT_SKILL_AGENTS`: cursor and codex install into
|
|
3116
|
-
* `.agents/skills`, claude-code into `.claude/skills`, windsurf into
|
|
3117
|
-
* `.windsurf/skills`.
|
|
3118
|
-
*/
|
|
3119
|
-
const AGENT_SKILL_ROOTS = [
|
|
3120
|
-
".agents/skills",
|
|
3121
|
-
".claude/skills",
|
|
3122
|
-
".windsurf/skills"
|
|
3123
|
-
];
|
|
3124
|
-
/**
|
|
3125
|
-
* Every directory a retired per-workflow skill may occupy in a
|
|
3126
|
-
* consumer project. Init deletes each (recursively) before running the
|
|
3127
|
-
* skill install. Names that are also in `DEFAULT_SKILL_SOURCES` are
|
|
3128
|
-
* excluded so a list mistake can never delete a skill init installs
|
|
3129
|
-
* (or one `--skip-skills` preserves) — see TML-2637.
|
|
3130
|
-
*/
|
|
3131
|
-
function legacySkillDirs(retired = RETIRED_SKILL_NAMES, sources = DEFAULT_SKILL_SOURCES) {
|
|
3132
|
-
const installed = new Set(sources.map((source) => source.skill));
|
|
3133
|
-
return AGENT_SKILL_ROOTS.flatMap((root) => retired.filter((name) => !installed.has(name)).map((name) => `${root}/${name}`));
|
|
3134
|
-
}
|
|
3135
|
-
/**
|
|
3136
2970
|
* The resolver a scaffold for `target` is written against.
|
|
3137
2971
|
*
|
|
3138
2972
|
* A scaffold is always on the facade root: `init` writes an application around
|
|
@@ -3497,7 +3331,7 @@ function envFileContent(target) {
|
|
|
3497
3331
|
return envPlaceholderBody(target);
|
|
3498
3332
|
}
|
|
3499
3333
|
/** The invocation that finishes what a failed `init` phase started. */
|
|
3500
|
-
const EMIT_COMMAND = "prisma
|
|
3334
|
+
const EMIT_COMMAND = "prisma contract emit";
|
|
3501
3335
|
/**
|
|
3502
3336
|
* The command's own record of a phase that failed after the scaffold was
|
|
3503
3337
|
* written. The scaffold is on disk and the run has a result to report, so each
|
|
@@ -3541,22 +3375,6 @@ function emitFailedFinding(cause, filesWritten) {
|
|
|
3541
3375
|
}
|
|
3542
3376
|
});
|
|
3543
3377
|
}
|
|
3544
|
-
/**
|
|
3545
|
-
* An agent-skill install failed; the project itself is complete without it.
|
|
3546
|
-
* The remedy is the skill-install commands themselves, which run against any
|
|
3547
|
-
* directory — advising a re-run of `init` would put the user's schema at risk
|
|
3548
|
-
* to fix something `init` no longer needs to be involved in.
|
|
3549
|
-
*/
|
|
3550
|
-
function skillInstallFailedFinding(failure, filesWritten, skillCommands) {
|
|
3551
|
-
return initFinding("CLI.INIT_SKILL_INSTALL_FAILED", "Failed to install Prisma Next skills", {
|
|
3552
|
-
why: failure.why ?? failure.message,
|
|
3553
|
-
nextActions: [...failure.nextActions, ...skillCommands.map((command) => runCommandAction("Install the Prisma Next skills", command))],
|
|
3554
|
-
meta: {
|
|
3555
|
-
filesWritten,
|
|
3556
|
-
skillInstall: failure.meta ?? {}
|
|
3557
|
-
}
|
|
3558
|
-
});
|
|
3559
|
-
}
|
|
3560
3378
|
function fileNodes(paths) {
|
|
3561
3379
|
return paths.map((path) => ({
|
|
3562
3380
|
label: path,
|
|
@@ -3601,7 +3419,7 @@ function buildInitNextActions(inputs) {
|
|
|
3601
3419
|
label: `Edit your schema at ${inputs.schemaPath}, then emit again`
|
|
3602
3420
|
});
|
|
3603
3421
|
actions.push(chooseAction("Open prisma-next.md for a quick reference on writing your first typed query"));
|
|
3604
|
-
|
|
3422
|
+
actions.push(runCommandAction("Set up the Prisma agent skills for your coding agent", "prisma init"));
|
|
3605
3423
|
return actions;
|
|
3606
3424
|
}
|
|
3607
3425
|
const DONE_TEXT = "Done. Open prisma-next.md to get started.";
|
|
@@ -3665,7 +3483,7 @@ function redactSecrets(stderr) {
|
|
|
3665
3483
|
}
|
|
3666
3484
|
/**
|
|
3667
3485
|
* Emits the contract for the project `init` has just scaffolded, by spawning
|
|
3668
|
-
* the project-local `prisma
|
|
3486
|
+
* the project-local `prisma` binary the install step put into
|
|
3669
3487
|
* `node_modules`. That binary and the installed `defineConfig` come from the
|
|
3670
3488
|
* same registry release, so the config loader that evaluates
|
|
3671
3489
|
* `prisma.config.ts` always matches the config format it was written
|
|
@@ -3683,26 +3501,26 @@ async function emitScaffoldedContract(ctx, overrides = {}) {
|
|
|
3683
3501
|
if (result.exitCode !== 0) {
|
|
3684
3502
|
const output = result.stderr.trim().length > 0 ? result.stderr : result.stdout;
|
|
3685
3503
|
const cause = result.exitCode === null ? `was killed by signal ${result.signal ?? "unknown"}` : `exited with code ${result.exitCode}`;
|
|
3686
|
-
throw new Error(`\`prisma
|
|
3504
|
+
throw new Error(`\`prisma contract emit\` ${cause}: ${redactSecrets(tail(output))}`);
|
|
3687
3505
|
}
|
|
3688
3506
|
}
|
|
3689
3507
|
function resolveProjectBin(cwd, overrides) {
|
|
3690
3508
|
const resolveFromBaseDir = overrides.resolveFromBaseDir ?? ((baseDir, specifier) => createRequire(join(baseDir, "package.json")).resolve(specifier));
|
|
3691
3509
|
let manifestPath;
|
|
3692
3510
|
try {
|
|
3693
|
-
manifestPath = resolveFromBaseDir(cwd, "
|
|
3511
|
+
manifestPath = resolveFromBaseDir(cwd, "prisma/package.json");
|
|
3694
3512
|
} catch (error) {
|
|
3695
|
-
throw new Error(
|
|
3513
|
+
throw new Error(`\`prisma\` is not installed in this project (resolved from ${cwd}; cause: ${causeMessage$1(error)})`);
|
|
3696
3514
|
}
|
|
3697
3515
|
let manifest;
|
|
3698
3516
|
try {
|
|
3699
3517
|
manifest = JSON.parse(readFileSync(manifestPath, "utf-8"));
|
|
3700
3518
|
} catch (error) {
|
|
3701
|
-
throw new Error(`the installed
|
|
3519
|
+
throw new Error(`the installed prisma manifest at ${manifestPath} is not valid JSON: ${causeMessage$1(error)}`);
|
|
3702
3520
|
}
|
|
3703
3521
|
const bin = manifest !== null && typeof manifest === "object" ? Reflect.get(manifest, "bin") : void 0;
|
|
3704
|
-
const binEntry = typeof bin === "string" ? bin : bin !== null && typeof bin === "object" ? Reflect.get(bin, "prisma
|
|
3705
|
-
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`);
|
|
3706
3524
|
return join(dirname(manifestPath), binEntry);
|
|
3707
3525
|
}
|
|
3708
3526
|
function runCaptured(file, args, cwd) {
|
|
@@ -3724,7 +3542,7 @@ function runCaptured(file, args, cwd) {
|
|
|
3724
3542
|
stderr += chunk.toString("utf-8");
|
|
3725
3543
|
});
|
|
3726
3544
|
child.on("error", (error) => {
|
|
3727
|
-
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}`));
|
|
3728
3546
|
});
|
|
3729
3547
|
child.on("close", (code, signal) => {
|
|
3730
3548
|
resolve({
|
|
@@ -3822,7 +3640,7 @@ function formatRunScriptCommand(pm, scriptName) {
|
|
|
3822
3640
|
* [`.gitattributes`](../../../../../../../../.gitattributes):
|
|
3823
3641
|
*
|
|
3824
3642
|
* - **Today**: `contract.json`, `contract.d.ts` are emitted on every
|
|
3825
|
-
* `prisma
|
|
3643
|
+
* `prisma contract emit`. Marking them `linguist-generated`
|
|
3826
3644
|
* keeps GitHub's diff stats honest and collapses the file in code
|
|
3827
3645
|
* review by default.
|
|
3828
3646
|
* - **Forward-looking**: `ops.json`, `migration.json` are not yet emitted
|
|
@@ -3933,7 +3751,7 @@ function mergeGitignore(existing) {
|
|
|
3933
3751
|
}
|
|
3934
3752
|
const REQUIRED_SCRIPTS = [{
|
|
3935
3753
|
name: "contract:emit",
|
|
3936
|
-
command: "prisma
|
|
3754
|
+
command: "prisma contract emit"
|
|
3937
3755
|
}];
|
|
3938
3756
|
/**
|
|
3939
3757
|
* Idempotent `package.json#scripts` merge with collision detection
|
|
@@ -4104,6 +3922,51 @@ function removeDependency(existing, depName) {
|
|
|
4104
3922
|
const trailingNewline = existing.endsWith("\n") ? "\n" : "";
|
|
4105
3923
|
return `${JSON.stringify(parsed, null, 2)}${trailingNewline}`;
|
|
4106
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
|
+
}
|
|
4107
3970
|
function renderTemplate(templateFile, variableNames, vars) {
|
|
4108
3971
|
let result = readFileSync(join(import.meta.dirname, templateFile), "utf-8");
|
|
4109
3972
|
for (const key of variableNames) {
|
|
@@ -4134,7 +3997,7 @@ function quickReferenceMd(target, authoring, schemaPath, pkgRun, resolveImportSp
|
|
|
4134
3997
|
pkg,
|
|
4135
3998
|
configEntrypoint: targetEntrypoint(target, "config", resolveImportSpecifier),
|
|
4136
3999
|
schemaSample: schemaSample(target, authoring, resolveImportSpecifier),
|
|
4137
|
-
requirements: requirementsBlock(target)
|
|
4000
|
+
requirements: requirementsBlock(target, pkgRun)
|
|
4138
4001
|
};
|
|
4139
4002
|
return renderTemplate(`quick-reference-${target}.md`, variables, vars);
|
|
4140
4003
|
}
|
|
@@ -4149,12 +4012,12 @@ function quickReferenceMd(target, authoring, schemaPath, pkgRun, resolveImportSp
|
|
|
4149
4012
|
* shouldn't ship Mongo's `db.runCommand` (and vice versa) just because
|
|
4150
4013
|
* we couldn't be bothered to branch.
|
|
4151
4014
|
*/
|
|
4152
|
-
function requirementsBlock(target) {
|
|
4015
|
+
function requirementsBlock(target, pkgRun) {
|
|
4153
4016
|
return [
|
|
4154
4017
|
"## Requirements",
|
|
4155
4018
|
"",
|
|
4156
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.`,
|
|
4157
|
-
|
|
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.`
|
|
4158
4021
|
].join("\n");
|
|
4159
4022
|
}
|
|
4160
4023
|
const sharedVariables = [
|
|
@@ -4439,7 +4302,7 @@ function planScaffold(ctx) {
|
|
|
4439
4302
|
const warnings = [];
|
|
4440
4303
|
const schemaDir = dirname(inputs.schemaPath);
|
|
4441
4304
|
const configContractPath = isAbsolute(inputs.schemaPath) ? inputs.schemaPath : `./${inputs.schemaPath}`;
|
|
4442
|
-
const runPrefix = formatRunCommand(packageManager, "prisma
|
|
4305
|
+
const runPrefix = formatRunCommand(packageManager, "prisma", "").trimEnd();
|
|
4443
4306
|
const files = [
|
|
4444
4307
|
{
|
|
4445
4308
|
path: inputs.schemaPath,
|
|
@@ -4528,7 +4391,7 @@ function planScaffold(ctx) {
|
|
|
4528
4391
|
changed = true;
|
|
4529
4392
|
}
|
|
4530
4393
|
}
|
|
4531
|
-
const { content: withScripts, warnings: scriptWarnings } = mergePackageScripts(working
|
|
4394
|
+
const { content: withScripts, warnings: scriptWarnings } = mergePackageScripts(working);
|
|
4532
4395
|
if (withScripts !== null) {
|
|
4533
4396
|
working = withScripts;
|
|
4534
4397
|
changed = true;
|
|
@@ -4759,8 +4622,7 @@ async function resolveInitInputs(ctx) {
|
|
|
4759
4622
|
probeDb: flags.probeDb,
|
|
4760
4623
|
strictProbe: flags.strictProbe,
|
|
4761
4624
|
reinit,
|
|
4762
|
-
removePreviousFacade
|
|
4763
|
-
installProjectSkill: !flags.skipSkills
|
|
4625
|
+
removePreviousFacade
|
|
4764
4626
|
};
|
|
4765
4627
|
}
|
|
4766
4628
|
/**
|
|
@@ -4822,7 +4684,7 @@ function retriedWarning(failure) {
|
|
|
4822
4684
|
/**
|
|
4823
4685
|
* The engine dependency spec a fresh scaffold installs. The scaffolded
|
|
4824
4686
|
* `prisma.config.ts` imports `defineConfig` from `@prisma/cli-engine`, and the
|
|
4825
|
-
* installed
|
|
4687
|
+
* installed `prisma` names the exact engine version it runs against — so
|
|
4826
4688
|
* the spec is read from the manifest the install just placed, never guessed
|
|
4827
4689
|
* from a dist-tag (whose `latest` has lagged that version before and broken
|
|
4828
4690
|
* the very next command). A CLI without a readable engine entry falls back to
|
|
@@ -4830,7 +4692,7 @@ function retriedWarning(failure) {
|
|
|
4830
4692
|
*/
|
|
4831
4693
|
function engineDevDependencySpec(cwd) {
|
|
4832
4694
|
try {
|
|
4833
|
-
const manifest = JSON.parse(readFileSync(join(cwd, "node_modules", "
|
|
4695
|
+
const manifest = JSON.parse(readFileSync(join(cwd, "node_modules", "prisma", "package.json"), "utf-8"));
|
|
4834
4696
|
if (typeof manifest === "object" && manifest !== null) for (const field of ["dependencies", "peerDependencies"]) {
|
|
4835
4697
|
const block = Reflect.get(manifest, field);
|
|
4836
4698
|
if (typeof block === "object" && block !== null) {
|
|
@@ -4880,38 +4742,10 @@ async function installProjectDependencies(ctx) {
|
|
|
4880
4742
|
warnings: [fallbackWarning(failure)]
|
|
4881
4743
|
};
|
|
4882
4744
|
}
|
|
4883
|
-
function skillArgs(url, skill) {
|
|
4884
|
-
return [
|
|
4885
|
-
"add",
|
|
4886
|
-
url,
|
|
4887
|
-
"--agent",
|
|
4888
|
-
...DEFAULT_SKILL_AGENTS,
|
|
4889
|
-
"--skill",
|
|
4890
|
-
skill,
|
|
4891
|
-
"-y"
|
|
4892
|
-
];
|
|
4893
|
-
}
|
|
4894
|
-
/**
|
|
4895
|
-
* Registers every Prisma Next skill with the agent runtimes, in order. The
|
|
4896
|
-
* first failure stops the loop: the user opted into Prisma Next by running
|
|
4897
|
-
* `init`, and a half-installed skill set leaves the project ambiguous.
|
|
4898
|
-
*/
|
|
4899
|
-
async function installAgentSkills(ctx) {
|
|
4900
|
-
for (const source of DEFAULT_SKILL_SOURCES) {
|
|
4901
|
-
const result = await ctx.packages.run({
|
|
4902
|
-
package: "skills@latest",
|
|
4903
|
-
args: skillArgs(formatSkillSourceUrl(source, ctx.env), source.skill),
|
|
4904
|
-
cwd: ctx.cwd,
|
|
4905
|
-
...ifDefined("manager", ctx.manager)
|
|
4906
|
-
});
|
|
4907
|
-
if (!result.ok) return result.failure;
|
|
4908
|
-
}
|
|
4909
|
-
}
|
|
4910
4745
|
/** The scaffold is on disk from here on, so each of these is a finding. */
|
|
4911
4746
|
const INIT_EXIT_CODES = {
|
|
4912
4747
|
4: "scaffold written; dependency install failed",
|
|
4913
|
-
5: "scaffold written and installed; contract emit failed"
|
|
4914
|
-
6: "scaffold complete; agent-skill install failed"
|
|
4748
|
+
5: "scaffold written and installed; contract emit failed"
|
|
4915
4749
|
};
|
|
4916
4750
|
function probeWarning(outcome, strictProbe) {
|
|
4917
4751
|
switch (outcome.kind) {
|
|
@@ -4946,7 +4780,6 @@ const createInitCommand = (injected) => defineOrmCommand({
|
|
|
4946
4780
|
"orm init --target postgres --authoring psl",
|
|
4947
4781
|
"orm init --target mongodb --authoring typescript --json",
|
|
4948
4782
|
"orm init --skip-install",
|
|
4949
|
-
"orm init --skip-skills",
|
|
4950
4783
|
"orm init --target postgres --keep-previous-facade"
|
|
4951
4784
|
]
|
|
4952
4785
|
},
|
|
@@ -4967,7 +4800,6 @@ const createInitCommand = (injected) => defineOrmCommand({
|
|
|
4967
4800
|
probeDb: flag.boolean({ brief: "Connect to DATABASE_URL once and check the server version" }),
|
|
4968
4801
|
strictProbe: flag.boolean({ brief: "Treat a failed --probe-db as fatal" }),
|
|
4969
4802
|
skipInstall: flag.boolean({ brief: "Skip dependency installation and contract emission" }),
|
|
4970
|
-
skipSkills: flag.boolean({ brief: "Skip the Prisma Next agent-skill install" }),
|
|
4971
4803
|
keepPreviousFacade: flag.boolean({ brief: "Keep the previous target package in package.json when switching targets" })
|
|
4972
4804
|
} },
|
|
4973
4805
|
exitCodes: INIT_EXIT_CODES,
|
|
@@ -5003,14 +4835,12 @@ const createInitCommand = (injected) => defineOrmCommand({
|
|
|
5003
4835
|
text: note
|
|
5004
4836
|
});
|
|
5005
4837
|
const deps = [targetPackageName(inputs.target, scaffold.resolveImportSpecifier), "dotenv"];
|
|
5006
|
-
const cliDevDeps = ["
|
|
4838
|
+
const cliDevDeps = ["prisma@next"];
|
|
5007
4839
|
const devDeps = scaffold.hasTypesNode ? cliDevDeps : [...cliDevDeps, "@types/node"];
|
|
5008
4840
|
const findings = [];
|
|
5009
4841
|
const extraActions = [];
|
|
5010
|
-
let installedManager;
|
|
5011
4842
|
let packagesInstalled = "skipped";
|
|
5012
4843
|
let contractEmitted = false;
|
|
5013
|
-
let skillRegistered = false;
|
|
5014
4844
|
const settle = (exitCode) => {
|
|
5015
4845
|
const installed = packagesInstalled === "installed";
|
|
5016
4846
|
const document = {
|
|
@@ -5031,8 +4861,7 @@ const createInitCommand = (injected) => defineOrmCommand({
|
|
|
5031
4861
|
packagesInstalled,
|
|
5032
4862
|
contractEmitted,
|
|
5033
4863
|
emitCommand: EMIT_COMMAND,
|
|
5034
|
-
schemaPath: inputs.schemaPath
|
|
5035
|
-
skillRegistered
|
|
4864
|
+
schemaPath: inputs.schemaPath
|
|
5036
4865
|
}),
|
|
5037
4866
|
warnings
|
|
5038
4867
|
};
|
|
@@ -5051,8 +4880,7 @@ const createInitCommand = (injected) => defineOrmCommand({
|
|
|
5051
4880
|
complete: exitCode === 0,
|
|
5052
4881
|
nextActions: [...extraActions, ...buildInitNextActions({
|
|
5053
4882
|
contractEmitted,
|
|
5054
|
-
schemaPath: inputs.schemaPath
|
|
5055
|
-
skillRegistered
|
|
4883
|
+
schemaPath: inputs.schemaPath
|
|
5056
4884
|
})]
|
|
5057
4885
|
})));
|
|
5058
4886
|
};
|
|
@@ -5084,7 +4912,6 @@ const createInitCommand = (injected) => defineOrmCommand({
|
|
|
5084
4912
|
}
|
|
5085
4913
|
devDeps.push(engineSpec);
|
|
5086
4914
|
packagesInstalled = "installed";
|
|
5087
|
-
installedManager = outcome.manager;
|
|
5088
4915
|
const emitStep = "Emit the contract";
|
|
5089
4916
|
ctx.report({
|
|
5090
4917
|
kind: "step-started",
|
|
@@ -5107,7 +4934,7 @@ const createInitCommand = (injected) => defineOrmCommand({
|
|
|
5107
4934
|
findings.push(emitFailedFinding(causeMessage(error), scaffold.filesWritten));
|
|
5108
4935
|
return settle(5);
|
|
5109
4936
|
}
|
|
5110
|
-
} 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)`));
|
|
5111
4938
|
if (inputs.probeDb) {
|
|
5112
4939
|
const probe = probeWarning(await probeServerVersion({
|
|
5113
4940
|
baseDir: ctx.cwd,
|
|
@@ -5121,20 +4948,6 @@ const createInitCommand = (injected) => defineOrmCommand({
|
|
|
5121
4948
|
filesWritten: scaffold.filesWritten
|
|
5122
4949
|
})));
|
|
5123
4950
|
}
|
|
5124
|
-
const skillCommands = resolveProjectSkillInstallCommands(installedManager ?? packageManager, ctx.env);
|
|
5125
|
-
if (inputs.installProjectSkill) {
|
|
5126
|
-
const failure = await installAgentSkills({
|
|
5127
|
-
packages: ctx.packages,
|
|
5128
|
-
cwd: ctx.cwd,
|
|
5129
|
-
env: ctx.env,
|
|
5130
|
-
manager: installedManager
|
|
5131
|
-
});
|
|
5132
|
-
if (failure !== void 0) {
|
|
5133
|
-
findings.push(skillInstallFailedFinding(failure, scaffold.filesWritten, skillCommands));
|
|
5134
|
-
return settle(6);
|
|
5135
|
-
}
|
|
5136
|
-
skillRegistered = true;
|
|
5137
|
-
} else warn(`Skipped the Prisma Next agent-skill install (--skip-skills). To install them later, run: ${skillCommands.map((command) => `\`${command}\``).join(" && ")}`);
|
|
5138
4951
|
return settle(0);
|
|
5139
4952
|
}
|
|
5140
4953
|
});
|