@prisma-next/cli 0.16.0-dev.3 → 0.16.0-dev.31
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/README.md +44 -45
- package/dist/cli.mjs +13 -13
- package/dist/{client-KuBQftxz.mjs → client-B1UjQc_x.mjs} +50 -58
- package/dist/client-B1UjQc_x.mjs.map +1 -0
- package/dist/{command-helpers-Cpq44aVa.mjs → command-helpers-D-jBl0Qt.mjs} +16 -8
- package/dist/command-helpers-D-jBl0Qt.mjs.map +1 -0
- package/dist/commands/contract-emit.mjs +1 -1
- package/dist/commands/contract-infer.mjs +1 -1
- package/dist/commands/db-init.d.mts.map +1 -1
- package/dist/commands/db-init.mjs +8 -6
- package/dist/commands/db-init.mjs.map +1 -1
- package/dist/commands/db-schema.mjs +3 -3
- package/dist/commands/db-sign.d.mts.map +1 -1
- package/dist/commands/db-sign.mjs +11 -12
- package/dist/commands/db-sign.mjs.map +1 -1
- package/dist/commands/db-update.d.mts.map +1 -1
- package/dist/commands/db-update.mjs +14 -15
- package/dist/commands/db-update.mjs.map +1 -1
- package/dist/commands/db-verify.mjs +1 -1
- package/dist/commands/migrate.d.mts +1 -1
- package/dist/commands/migrate.d.mts.map +1 -1
- package/dist/commands/migrate.mjs +13 -13
- package/dist/commands/migrate.mjs.map +1 -1
- package/dist/commands/migration-check.d.mts +4 -2
- package/dist/commands/migration-check.d.mts.map +1 -1
- package/dist/commands/migration-check.mjs +1 -1
- package/dist/commands/migration-graph.d.mts +1 -1
- package/dist/commands/migration-graph.mjs +4 -4
- package/dist/commands/migration-list.d.mts +1 -1
- package/dist/commands/migration-list.d.mts.map +1 -1
- package/dist/commands/migration-list.mjs +1 -1
- package/dist/commands/migration-log.d.mts +1 -1
- package/dist/commands/migration-log.mjs +1 -1
- package/dist/commands/migration-new.d.mts.map +1 -1
- package/dist/commands/migration-new.mjs +16 -40
- package/dist/commands/migration-new.mjs.map +1 -1
- package/dist/commands/migration-plan.d.mts +3 -4
- package/dist/commands/migration-plan.d.mts.map +1 -1
- package/dist/commands/migration-plan.mjs +1 -1
- package/dist/commands/migration-show.mjs +5 -5
- package/dist/commands/migration-show.mjs.map +1 -1
- package/dist/commands/migration-status.d.mts +1 -1
- package/dist/commands/migration-status.d.mts.map +1 -1
- package/dist/commands/migration-status.mjs +1 -1
- package/dist/commands/ref.d.mts +1 -1
- package/dist/commands/ref.d.mts.map +1 -1
- package/dist/commands/ref.mjs +13 -18
- package/dist/commands/ref.mjs.map +1 -1
- package/dist/commands/telemetry/index.mjs +1 -1
- package/dist/contract-at-errors-DvZ_DzJK.mjs +36 -0
- package/dist/contract-at-errors-DvZ_DzJK.mjs.map +1 -0
- package/dist/{contract-emit-CgnXSANN.mjs → contract-emit-BT46Mu8Q.mjs} +3 -3
- package/dist/{contract-emit-CgnXSANN.mjs.map → contract-emit-BT46Mu8Q.mjs.map} +1 -1
- package/dist/{contract-emit-cJQBlvGb.mjs → contract-emit-hVdlaF2U.mjs} +6 -7
- package/dist/{contract-emit-cJQBlvGb.mjs.map → contract-emit-hVdlaF2U.mjs.map} +1 -1
- package/dist/{contract-enrichment-gn9sWbPw.mjs → contract-enrichment-JUhLv-BX.mjs} +8 -8
- package/dist/{contract-enrichment-gn9sWbPw.mjs.map → contract-enrichment-JUhLv-BX.mjs.map} +1 -1
- package/dist/{contract-infer-Cg8evbeg.mjs → contract-infer-DpqTQECL.mjs} +3 -3
- package/dist/{contract-infer-Cg8evbeg.mjs.map → contract-infer-DpqTQECL.mjs.map} +1 -1
- package/dist/{contract-space-aggregate-loader-D_3VeHVb.mjs → contract-space-aggregate-loader-CNd-ZB6C.mjs} +14 -14
- package/dist/contract-space-aggregate-loader-CNd-ZB6C.mjs.map +1 -0
- package/dist/{db-verify-BEclUzki.mjs → db-verify-FEN6k1m7.mjs} +10 -8
- package/dist/db-verify-FEN6k1m7.mjs.map +1 -0
- package/dist/exports/control-api.d.mts +4 -4
- package/dist/exports/control-api.d.mts.map +1 -1
- package/dist/exports/control-api.mjs +3 -3
- package/dist/exports/index.d.mts +2 -1
- package/dist/exports/index.d.mts.map +1 -1
- package/dist/exports/index.mjs +61 -21
- package/dist/exports/index.mjs.map +1 -1
- package/dist/exports/init-output.d.mts.map +1 -1
- package/dist/exports/init-output.mjs +1 -1
- package/dist/{format-DAUAZqPt.mjs → format-DI5qVr22.mjs} +8 -7
- package/dist/format-DI5qVr22.mjs.map +1 -0
- package/dist/{framework-components-CnbUbiJw.mjs → framework-components-C4XACYNB.mjs} +3 -3
- package/dist/framework-components-C4XACYNB.mjs.map +1 -0
- package/dist/{init-C3JhkHg-.mjs → init-ClrRkbwd.mjs} +77 -67
- package/dist/init-ClrRkbwd.mjs.map +1 -0
- package/dist/{inspect-live-schema-CX7EA5C3.mjs → inspect-live-schema-C0Rgdtw_.mjs} +4 -4
- package/dist/{inspect-live-schema-CX7EA5C3.mjs.map → inspect-live-schema-C0Rgdtw_.mjs.map} +1 -1
- package/dist/{migration-check-MHT3w7_v.mjs → migration-check-zEkHpPDT.mjs} +58 -30
- package/dist/migration-check-zEkHpPDT.mjs.map +1 -0
- package/dist/{migration-command-scaffold-CRyYrHZ9.mjs → migration-command-scaffold-CkNsp9g1.mjs} +4 -4
- package/dist/{migration-command-scaffold-CRyYrHZ9.mjs.map → migration-command-scaffold-CkNsp9g1.mjs.map} +1 -1
- package/dist/{migration-graph-command-render-B83xrnNy.mjs → migration-graph-command-render-DEwFpx-w.mjs} +5 -4
- package/dist/migration-graph-command-render-DEwFpx-w.mjs.map +1 -0
- package/dist/{migration-list-BAKujUjh.mjs → migration-list-BkafFVXS.mjs} +6 -6
- package/dist/migration-list-BkafFVXS.mjs.map +1 -0
- package/dist/{migration-log-C_xam2HZ.mjs → migration-log-BxhAtbhA.mjs} +5 -5
- package/dist/{migration-log-C_xam2HZ.mjs.map → migration-log-BxhAtbhA.mjs.map} +1 -1
- package/dist/{migration-path-target-DpPTsRCg.mjs → migration-path-target-B5HkjSTO.mjs} +2 -2
- package/dist/{migration-path-target-DpPTsRCg.mjs.map → migration-path-target-B5HkjSTO.mjs.map} +1 -1
- package/dist/{migration-plan-CreSVtWZ.mjs → migration-plan-Bk2pbPQH.mjs} +64 -74
- package/dist/migration-plan-Bk2pbPQH.mjs.map +1 -0
- package/dist/{migration-status-YgEvXf-u.mjs → migration-status-BzlARseq.mjs} +13 -12
- package/dist/migration-status-BzlARseq.mjs.map +1 -0
- package/dist/{output-mEQ74_nd.mjs → output-DWNYqZGc.mjs} +5 -6
- package/dist/output-DWNYqZGc.mjs.map +1 -0
- package/dist/{ref-advancement-BkXlikCA.mjs → ref-advancement-BCz7X7qJ.mjs} +13 -6
- package/dist/ref-advancement-BCz7X7qJ.mjs.map +1 -0
- package/dist/{telemetry-DVr6RFnq.mjs → telemetry-BbniBUbP.mjs} +2 -2
- package/dist/{telemetry-DVr6RFnq.mjs.map → telemetry-BbniBUbP.mjs.map} +1 -1
- package/dist/{types-D4r_HI9-.d.mts → types-DgXprE3w.d.mts} +3 -3
- package/dist/types-DgXprE3w.d.mts.map +1 -0
- package/dist/{verify-CgDVZjhc.mjs → verify-BSaNeaSL.mjs} +2 -2
- package/dist/{verify-CgDVZjhc.mjs.map → verify-BSaNeaSL.mjs.map} +1 -1
- package/package.json +21 -21
- package/src/commands/db-init.ts +5 -3
- package/src/commands/db-sign.ts +9 -7
- package/src/commands/db-update.ts +18 -9
- package/src/commands/db-verify.ts +4 -4
- package/src/commands/format.ts +1 -1
- package/src/commands/init/hygiene-gitattributes.ts +37 -21
- package/src/commands/init/init.ts +6 -6
- package/src/commands/init/output.ts +4 -5
- package/src/commands/init/probe-db.ts +9 -2
- package/src/commands/init/reinit-cleanup.ts +16 -17
- package/src/commands/init/templates/render.ts +2 -1
- package/src/commands/inspect-live-schema.ts +1 -1
- package/src/commands/migrate.ts +6 -5
- package/src/commands/migration-check.ts +72 -34
- package/src/commands/migration-list.ts +1 -5
- package/src/commands/migration-log.ts +1 -1
- package/src/commands/migration-new.ts +17 -41
- package/src/commands/migration-plan.ts +64 -88
- package/src/commands/migration-show.ts +2 -2
- package/src/commands/migration-status.ts +6 -7
- package/src/commands/ref.ts +19 -14
- package/src/control-api/client.ts +43 -25
- package/src/control-api/contract-enrichment.ts +7 -7
- package/src/control-api/operations/contract-emit.ts +2 -3
- package/src/control-api/operations/db-init.ts +3 -3
- package/src/control-api/operations/db-run.ts +8 -7
- package/src/control-api/operations/db-update.ts +2 -2
- package/src/control-api/operations/db-verify.ts +4 -4
- package/src/control-api/operations/format.ts +5 -4
- package/src/control-api/operations/migrate.ts +6 -5
- package/src/control-api/operations/run-migration.ts +2 -1
- package/src/control-api/types.ts +1 -1
- package/src/load-ts-contract.ts +81 -16
- package/src/utils/cli-errors.ts +15 -7
- package/src/utils/combine-verify-results.ts +2 -1
- package/src/utils/command-helpers.ts +15 -5
- package/src/utils/contract-at-errors.ts +13 -22
- package/src/utils/contract-space-aggregate-loader.ts +8 -8
- package/src/utils/contract-space-seed-phase.ts +11 -9
- package/src/utils/extension-pack-inputs.ts +8 -8
- package/src/utils/formatters/migration-graph-grid-layout.ts +2 -1
- package/src/utils/formatters/migration-graph-labels.ts +1 -2
- package/src/utils/formatters/migration-list-data-column.ts +1 -2
- package/src/utils/framework-components.ts +9 -9
- package/src/utils/integrity-violation-to-check-failure.ts +3 -3
- package/src/utils/migration-command-scaffold.ts +1 -1
- package/src/utils/plan-resolution.ts +7 -10
- package/src/utils/ref-advancement.ts +22 -3
- package/dist/client-KuBQftxz.mjs.map +0 -1
- package/dist/command-helpers-Cpq44aVa.mjs.map +0 -1
- package/dist/contract-at-errors-D9gEjYtg.mjs +0 -42
- package/dist/contract-at-errors-D9gEjYtg.mjs.map +0 -1
- package/dist/contract-space-aggregate-loader-D_3VeHVb.mjs.map +0 -1
- package/dist/db-verify-BEclUzki.mjs.map +0 -1
- package/dist/format-DAUAZqPt.mjs.map +0 -1
- package/dist/framework-components-CnbUbiJw.mjs.map +0 -1
- package/dist/init-C3JhkHg-.mjs.map +0 -1
- package/dist/migration-check-MHT3w7_v.mjs.map +0 -1
- package/dist/migration-graph-command-render-B83xrnNy.mjs.map +0 -1
- package/dist/migration-list-BAKujUjh.mjs.map +0 -1
- package/dist/migration-plan-CreSVtWZ.mjs.map +0 -1
- package/dist/migration-status-YgEvXf-u.mjs.map +0 -1
- package/dist/output-mEQ74_nd.mjs.map +0 -1
- package/dist/ref-advancement-BkXlikCA.mjs.map +0 -1
- package/dist/types-D4r_HI9-.d.mts.map +0 -1
- package/src/control-api/errors.ts +0 -9
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
import { F as CliStructuredError, _ as createTerminalUI, b as formatErrorJson, x as formatErrorOutput } from "./command-helpers-
|
|
1
|
+
import { F as CliStructuredError$1, _ as createTerminalUI, b as formatErrorJson, x as formatErrorOutput } from "./command-helpers-D-jBl0Qt.mjs";
|
|
2
2
|
import { a as starterSchema, c as version, i as schemaSample, n as dbFile, o as targetLabel, r as defaultSchemaPath, s as targetPackageName, t as configFile } from "./cli.mjs";
|
|
3
|
-
import { i as renderInitOutro, n as buildNextSteps, r as formatInitJson, t as InitOutputSchema } from "./output-
|
|
3
|
+
import { i as renderInitOutro, n as buildNextSteps, r as formatInitJson, t as InitOutputSchema } from "./output-DWNYqZGc.mjs";
|
|
4
4
|
import { createRequire } from "node:module";
|
|
5
|
+
import { CliStructuredError } from "@prisma-next/errors/control";
|
|
5
6
|
import { basename, dirname, extname, isAbsolute, join, normalize } from "pathe";
|
|
6
7
|
import { blindCast } from "@prisma-next/utils/casts";
|
|
7
8
|
import * as clack from "@clack/prompts";
|
|
8
9
|
import { existsSync, mkdirSync, readFileSync, unlinkSync, writeFileSync } from "node:fs";
|
|
10
|
+
import { InternalError } from "@prisma-next/utils/internal-error";
|
|
9
11
|
import { execFile } from "node:child_process";
|
|
10
12
|
import { promisify } from "node:util";
|
|
11
13
|
import { detect, getUserAgent } from "package-manager-detector/detect";
|
|
@@ -182,7 +184,7 @@ function stripQuotes(value) {
|
|
|
182
184
|
* the user was never given the choice — `--force` is the contract.
|
|
183
185
|
*/
|
|
184
186
|
function errorInitReinitNeedsForce() {
|
|
185
|
-
return new CliStructuredError("CLI.INIT_REINIT_NEEDS_FORCE", "Project is already initialized", {
|
|
187
|
+
return new CliStructuredError$1("CLI.INIT_REINIT_NEEDS_FORCE", "Project is already initialized", {
|
|
186
188
|
why: "A `prisma-next.config.ts` already exists in this directory. Re-running `init` would overwrite the scaffolded files; in non-interactive mode `init` will not do that without `--force`.",
|
|
187
189
|
fix: "Pass `--force` to overwrite the existing scaffold, or run `init` interactively to confirm.",
|
|
188
190
|
docsUrl: "https://prisma-next.dev/docs/cli/init"
|
|
@@ -207,7 +209,7 @@ function errorInitMissingFlags(options) {
|
|
|
207
209
|
default: return `--${flag} <value>`;
|
|
208
210
|
}
|
|
209
211
|
}).join(" ");
|
|
210
|
-
return new CliStructuredError("CLI.INIT_MISSING_FLAGS", "Missing required flags", {
|
|
212
|
+
return new CliStructuredError$1("CLI.INIT_MISSING_FLAGS", "Missing required flags", {
|
|
211
213
|
why: `${options.why} Missing required flag(s): ${flagList}.`,
|
|
212
214
|
fix: `Re-run with the missing flag(s) supplied, e.g. \`prisma-next init --yes ${fixList}\`. Use \`prisma-next init --help\` to see every flag.`,
|
|
213
215
|
docsUrl: "https://prisma-next.dev/docs/cli/init",
|
|
@@ -219,7 +221,7 @@ function errorInitMissingFlags(options) {
|
|
|
219
221
|
* allowed values in `meta` for machine-readable consumption.
|
|
220
222
|
*/
|
|
221
223
|
function errorInitInvalidFlagValue(options) {
|
|
222
|
-
return new CliStructuredError("CLI.INIT_INVALID_FLAG_VALUE", `Invalid value for --${options.flag}`, {
|
|
224
|
+
return new CliStructuredError$1("CLI.INIT_INVALID_FLAG_VALUE", `Invalid value for --${options.flag}`, {
|
|
223
225
|
why: `\`--${options.flag} ${options.value}\` is not one of: ${options.allowed.join(", ")}.`,
|
|
224
226
|
fix: `Use one of: ${options.allowed.map((v) => `--${options.flag} ${v}`).join(", ")}.`,
|
|
225
227
|
docsUrl: "https://prisma-next.dev/docs/cli/init",
|
|
@@ -237,7 +239,7 @@ function errorInitInvalidFlagValue(options) {
|
|
|
237
239
|
*/
|
|
238
240
|
function errorInitAuthoringSchemaPathMismatch(options) {
|
|
239
241
|
const expectedAuthoring = options.expectedExtension === ".ts" ? "typescript" : "psl";
|
|
240
|
-
return new CliStructuredError("CLI.INIT_AUTHORING_SCHEMA_PATH_MISMATCH", "Authoring and schema path do not match", {
|
|
242
|
+
return new CliStructuredError$1("CLI.INIT_AUTHORING_SCHEMA_PATH_MISMATCH", "Authoring and schema path do not match", {
|
|
241
243
|
why: `\`--authoring ${options.authoring}\` requires a schema file ending in ${options.expectedExtension}, but \`--schema-path ${options.schemaPath}\` ends in ${options.actualExtension}.`,
|
|
242
244
|
fix: `Use a matching pair, for example \`--authoring ${expectedAuthoring} --schema-path <path>${options.expectedExtension}\`, or change \`--authoring\` to match the path you supplied. You can also omit \`--schema-path\` to use the default for the chosen authoring.`,
|
|
243
245
|
docsUrl: "https://prisma-next.dev/docs/cli/init",
|
|
@@ -257,7 +259,7 @@ function errorInitAuthoringSchemaPathMismatch(options) {
|
|
|
257
259
|
* 3 (USER_ABORTED).
|
|
258
260
|
*/
|
|
259
261
|
function errorInitUserAborted() {
|
|
260
|
-
return new CliStructuredError("CLI.INIT_USER_ABORTED", "Init cancelled", {
|
|
262
|
+
return new CliStructuredError$1("CLI.INIT_USER_ABORTED", "Init cancelled", {
|
|
261
263
|
why: "The interactive prompt was cancelled before all required inputs were supplied. No files were modified.",
|
|
262
264
|
fix: "Re-run `prisma-next init` and complete the prompts, or pass the required inputs as flags (see `--help`) for a non-interactive run.",
|
|
263
265
|
severity: "info"
|
|
@@ -272,7 +274,7 @@ function errorInitUserAborted() {
|
|
|
272
274
|
* mode is supposed to prevent.
|
|
273
275
|
*/
|
|
274
276
|
function errorInitStrictProbeWithoutProbe() {
|
|
275
|
-
return new CliStructuredError("CLI.INIT_STRICT_PROBE_WITHOUT_PROBE", "`--strict-probe` requires `--probe-db`", {
|
|
277
|
+
return new CliStructuredError$1("CLI.INIT_STRICT_PROBE_WITHOUT_PROBE", "`--strict-probe` requires `--probe-db`", {
|
|
276
278
|
why: "`--strict-probe` only changes how a *failed* probe is reported; without `--probe-db` no probe is attempted in the first place. (`init` is offline-by-default — it never opens a connection to your database without explicit consent.)",
|
|
277
279
|
fix: "Add `--probe-db` to opt in to the probe, or drop `--strict-probe` if you do not need the version check.",
|
|
278
280
|
docsUrl: "https://prisma-next.dev/docs/cli/init"
|
|
@@ -287,7 +289,7 @@ function errorInitStrictProbeWithoutProbe() {
|
|
|
287
289
|
*/
|
|
288
290
|
function errorInitInstallFailed(options) {
|
|
289
291
|
const trimmed = options.stderrLines.map((s) => s.trim()).filter(Boolean);
|
|
290
|
-
return new CliStructuredError("CLI.INIT_INSTALL_FAILED", "Failed to install dependencies", {
|
|
292
|
+
return new CliStructuredError$1("CLI.INIT_INSTALL_FAILED", "Failed to install dependencies", {
|
|
291
293
|
why: trimmed.length === 0 ? "The package manager exited with an error and no recoverable fallback applied." : `The package manager exited with: ${trimmed[0]}`,
|
|
292
294
|
fix: `Install manually:\n ${options.addCommand}\n ${options.addDevCommand}\nThen run \`${options.emitCommand}\` to emit the contract.`,
|
|
293
295
|
docsUrl: "https://prisma-next.dev/docs/cli/init",
|
|
@@ -309,7 +311,7 @@ function errorInitInstallFailed(options) {
|
|
|
309
311
|
* and re-run.
|
|
310
312
|
*/
|
|
311
313
|
function errorInitInvalidManifest(options) {
|
|
312
|
-
return new CliStructuredError("CLI.INIT_INVALID_MANIFEST", `Failed to parse ${options.path}`, {
|
|
314
|
+
return new CliStructuredError$1("CLI.INIT_INVALID_MANIFEST", `Failed to parse ${options.path}`, {
|
|
313
315
|
why: `\`${options.path}\` is not valid JSON: ${options.cause}`,
|
|
314
316
|
fix: `Fix the JSON syntax in \`${options.path}\` (a missing comma or unbalanced brace is the most common cause), then re-run \`prisma-next init\`.`,
|
|
315
317
|
docsUrl: "https://prisma-next.dev/docs/cli/init",
|
|
@@ -334,7 +336,7 @@ function errorInitInvalidManifest(options) {
|
|
|
334
336
|
* re-run.
|
|
335
337
|
*/
|
|
336
338
|
function errorInitInvalidTsconfig(options) {
|
|
337
|
-
return new CliStructuredError("CLI.INIT_INVALID_TSCONFIG", `Failed to parse ${options.path}`, {
|
|
339
|
+
return new CliStructuredError$1("CLI.INIT_INVALID_TSCONFIG", `Failed to parse ${options.path}`, {
|
|
338
340
|
why: `\`${options.path}\` is not valid JSON or JSONC: ${options.cause}`,
|
|
339
341
|
fix: `Fix the syntax in \`${options.path}\` and re-run \`prisma-next init\`. \`init\` accepts JSONC (comments and trailing commas) but cannot recover from unbalanced braces or missing commas.`,
|
|
340
342
|
docsUrl: "https://prisma-next.dev/docs/cli/init",
|
|
@@ -359,7 +361,7 @@ function errorInitInvalidTsconfig(options) {
|
|
|
359
361
|
* carries `filesWritten` so a follow-up agent can resume manually.
|
|
360
362
|
*/
|
|
361
363
|
function errorInitProbeFailed(options) {
|
|
362
|
-
return new CliStructuredError("CLI.INIT_PROBE_FAILED", "Database probe failed", {
|
|
364
|
+
return new CliStructuredError$1("CLI.INIT_PROBE_FAILED", "Database probe failed", {
|
|
363
365
|
why: `\`--probe-db\` could not complete and \`--strict-probe\` was set: ${options.cause}`,
|
|
364
366
|
fix: "Confirm `DATABASE_URL` points at a reachable server, or drop `--strict-probe` to treat probe failures as warnings.",
|
|
365
367
|
docsUrl: "https://prisma-next.dev/docs/cli/init",
|
|
@@ -376,7 +378,7 @@ function errorInitProbeFailed(options) {
|
|
|
376
378
|
* `5 = EMIT_FAILED`.
|
|
377
379
|
*/
|
|
378
380
|
function errorInitEmitFailed(options) {
|
|
379
|
-
return new CliStructuredError("CLI.INIT_EMIT_FAILED", "Failed to emit contract", {
|
|
381
|
+
return new CliStructuredError$1("CLI.INIT_EMIT_FAILED", "Failed to emit contract", {
|
|
380
382
|
why: `\`prisma-next contract emit\` failed: ${options.cause}`,
|
|
381
383
|
fix: `Inspect your contract file, fix the underlying issue, then re-run \`${options.emitCommand}\`. Pass \`-v\` for the full error envelope.`,
|
|
382
384
|
docsUrl: "https://prisma-next.dev/docs/cli/contract-emit",
|
|
@@ -398,7 +400,7 @@ function errorInitEmitFailed(options) {
|
|
|
398
400
|
* semantics. Maps to exit code `6 = SKILL_INSTALL_FAILED`.
|
|
399
401
|
*/
|
|
400
402
|
function errorInitSkillInstallFailed(options) {
|
|
401
|
-
return new CliStructuredError("CLI.INIT_SKILL_INSTALL_FAILED", "Failed to install Prisma Next skills", {
|
|
403
|
+
return new CliStructuredError$1("CLI.INIT_SKILL_INSTALL_FAILED", "Failed to install Prisma Next skills", {
|
|
402
404
|
why: `\`${options.skillInstallCommand}\` exited with an error: ${options.cause}`,
|
|
403
405
|
fix: `Either:
|
|
404
406
|
- Re-run \`prisma-next init --no-skill${options.filesWritten.length > 0 ? " --force" : ""}\` to skip the skill install for this run, or\n - Fix the underlying issue (network, npm registry, \`npx skills\` on PATH) and install manually:\n ${options.skillInstallCommand}`,
|
|
@@ -413,50 +415,59 @@ function errorInitSkillInstallFailed(options) {
|
|
|
413
415
|
//#endregion
|
|
414
416
|
//#region src/commands/init/hygiene-gitattributes.ts
|
|
415
417
|
/**
|
|
416
|
-
* The
|
|
417
|
-
*
|
|
418
|
-
*
|
|
418
|
+
* The `.gitattributes` entries written for a freshly initialised project
|
|
419
|
+
* (FR3.4). Mirrors the relevant subset of the repo-root
|
|
420
|
+
* [`.gitattributes`](../../../../../../../../.gitattributes):
|
|
419
421
|
*
|
|
420
422
|
* - **Today**: `contract.json`, `contract.d.ts` are emitted on every
|
|
421
423
|
* `prisma-next contract emit`. Marking them `linguist-generated`
|
|
422
424
|
* keeps GitHub's diff stats honest and collapses the file in code
|
|
423
425
|
* review by default.
|
|
424
|
-
* - **Forward-looking**: `
|
|
425
|
-
*
|
|
426
|
-
*
|
|
427
|
-
*
|
|
428
|
-
*
|
|
429
|
-
*
|
|
430
|
-
*
|
|
431
|
-
* who runs `init --schema-path db/contract.prisma`
|
|
432
|
-
* `db/contract.json linguist-generated` — not the workspace-glob
|
|
433
|
-
* `<glob>/contract.json` (which would over-match any unrelated
|
|
426
|
+
* - **Forward-looking**: `ops.json`, `migration.json` are not yet emitted
|
|
427
|
+
* by `init` flows but will be produced by adjacent commands (lower /
|
|
428
|
+
* migration tooling). Adding them now matches Decision 5
|
|
429
|
+
* (forward-looking subset) so the file does not need to be amended
|
|
430
|
+
* every time a new artifact lands.
|
|
431
|
+
*
|
|
432
|
+
* `ARTIFACT_FILENAMES` entries are written relative to the schema
|
|
433
|
+
* directory so a user who runs `init --schema-path db/contract.prisma`
|
|
434
|
+
* gets `db/contract.json linguist-generated` — not the workspace-glob
|
|
435
|
+
* form `<glob>/contract.json` (which would over-match any unrelated
|
|
434
436
|
* `contract.json` the user has elsewhere) and not the absolute
|
|
435
|
-
* `DEFAULT_CONTRACT_SOURCE_DIR/contract.json` (which would silently
|
|
436
|
-
* schema path).
|
|
437
|
+
* `DEFAULT_CONTRACT_SOURCE_DIR/contract.json` (which would silently
|
|
438
|
+
* break for a non-default schema path).
|
|
439
|
+
*
|
|
440
|
+
* The migration contract snapshot store (`migrations/snapshots/<hex>/`)
|
|
441
|
+
* is anchored to the migrations root instead, not the schema directory:
|
|
442
|
+
* migration package depth under `migrations/` varies (`app/<pkg>`,
|
|
443
|
+
* `<space>/<pkg>`, or a bare `<pkg>` in extension source repos), so no
|
|
444
|
+
* single schema-dir-relative pattern can reach every snapshot. See
|
|
445
|
+
* `STORE_GITATTRIBUTES_LINES` below.
|
|
437
446
|
*/
|
|
438
|
-
const
|
|
447
|
+
const ARTIFACT_FILENAMES$1 = [
|
|
439
448
|
"contract.json",
|
|
440
449
|
"contract.d.ts",
|
|
441
|
-
"end-contract.json",
|
|
442
|
-
"end-contract.d.ts",
|
|
443
|
-
"start-contract.json",
|
|
444
|
-
"start-contract.d.ts",
|
|
445
450
|
"ops.json",
|
|
446
451
|
"migration.json"
|
|
447
452
|
];
|
|
448
453
|
const ATTRIBUTE = "linguist-generated";
|
|
449
454
|
/**
|
|
455
|
+
* Full `.gitattributes` lines for the migration contract snapshot store,
|
|
456
|
+
* already anchored to the migrations root — unlike `ARTIFACT_FILENAMES`,
|
|
457
|
+
* these are not combined with the schema-relative prefix.
|
|
458
|
+
*/
|
|
459
|
+
const STORE_GITATTRIBUTES_LINES = [`migrations/snapshots/**/contract.json ${ATTRIBUTE}`, `migrations/snapshots/**/contract.d.ts ${ATTRIBUTE}`];
|
|
460
|
+
/**
|
|
450
461
|
* Computes the `.gitattributes` lines this scaffold expects to own. Each
|
|
451
462
|
* line has the shape `<path> linguist-generated`. The `target` parameter
|
|
452
463
|
* is currently unused but accepted for symmetry with the other hygiene
|
|
453
464
|
* helpers and to leave room for target-specific entries (e.g. a future
|
|
454
|
-
*
|
|
465
|
+
* family-specific artifact) without a signature break.
|
|
455
466
|
*/
|
|
456
467
|
function requiredGitattributesLines(schemaDir, _target) {
|
|
457
468
|
const dir = schemaDir === "." ? "" : schemaDir.replace(/\/+$/, "");
|
|
458
469
|
const prefix = dir === "" ? "" : `${dir}/`;
|
|
459
|
-
return
|
|
470
|
+
return [...ARTIFACT_FILENAMES$1.map((file) => `${prefix}${file} ${ATTRIBUTE}`), ...STORE_GITATTRIBUTES_LINES];
|
|
460
471
|
}
|
|
461
472
|
/**
|
|
462
473
|
* Idempotent `.gitattributes` merge (FR3.4 / FR9.3). Returns the new file
|
|
@@ -999,7 +1010,7 @@ async function defaultProbePostgres(databaseUrl, baseDir, overrides) {
|
|
|
999
1010
|
*/
|
|
1000
1011
|
function parsePostgresVersion(versionString) {
|
|
1001
1012
|
const match = versionString.match(/PostgreSQL\s+(\d+(?:\.\d+)?)/i);
|
|
1002
|
-
if (match === null || match[1] === void 0) throw new
|
|
1013
|
+
if (match === null || match[1] === void 0) throw new CliStructuredError("CLI.INIT_PROBE_FAILED", `Could not parse PostgreSQL version from \`${versionString}\``);
|
|
1003
1014
|
return match[1];
|
|
1004
1015
|
}
|
|
1005
1016
|
async function defaultProbeMongo(databaseUrl, baseDir, overrides) {
|
|
@@ -1008,7 +1019,7 @@ async function defaultProbeMongo(databaseUrl, baseDir, overrides) {
|
|
|
1008
1019
|
try {
|
|
1009
1020
|
const buildInfo = await client.db().admin().command({ buildInfo: 1 });
|
|
1010
1021
|
const versionString = String(buildInfo.version ?? "");
|
|
1011
|
-
if (versionString.length === 0) throw new
|
|
1022
|
+
if (versionString.length === 0) throw new CliStructuredError("CLI.INIT_PROBE_FAILED", "buildInfo did not include a `version` field");
|
|
1012
1023
|
return { serverVersion: versionString };
|
|
1013
1024
|
} finally {
|
|
1014
1025
|
await client.close().catch(() => void 0);
|
|
@@ -1037,40 +1048,39 @@ function requirePeer(moduleId, baseDir, overrides) {
|
|
|
1037
1048
|
/**
|
|
1038
1049
|
* Filenames the contract pipeline emits next to the user's schema source
|
|
1039
1050
|
* (`<schemaDir>/contract.json`, `<schemaDir>/contract.d.ts`, …). Mirrors
|
|
1040
|
-
* `
|
|
1041
|
-
*
|
|
1042
|
-
*
|
|
1043
|
-
*
|
|
1044
|
-
*
|
|
1045
|
-
*
|
|
1046
|
-
*
|
|
1047
|
-
*
|
|
1048
|
-
*
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
+
* the schema-dir-relative `ARTIFACT_FILENAMES` in `hygiene-gitattributes.ts`
|
|
1052
|
+
* (not that file's migrations-root-anchored store lines, which are outside
|
|
1053
|
+
* this command's scope — reinit only ever touches `schemaDir`); kept as a
|
|
1054
|
+
* separate constant here because the cleanup contract is target-agnostic
|
|
1055
|
+
* and we deliberately do not want a stale artifact from a previous target
|
|
1056
|
+
* lingering after a re-init.
|
|
1057
|
+
*
|
|
1058
|
+
* If a future emit pipeline produces an additional schema-dir artifact,
|
|
1059
|
+
* add it here **and** to `ARTIFACT_FILENAMES` in `hygiene-gitattributes.ts`
|
|
1060
|
+
* — the two stay in lockstep so the file `init` advertises as
|
|
1061
|
+
* `linguist-generated` is exactly the file `init` is willing to delete on
|
|
1062
|
+
* re-init.
|
|
1063
|
+
*/
|
|
1064
|
+
const ARTIFACT_FILENAMES = [
|
|
1051
1065
|
"contract.json",
|
|
1052
1066
|
"contract.d.ts",
|
|
1053
|
-
"end-contract.json",
|
|
1054
|
-
"end-contract.d.ts",
|
|
1055
|
-
"start-contract.json",
|
|
1056
|
-
"start-contract.d.ts",
|
|
1057
1067
|
"ops.json",
|
|
1058
1068
|
"migration.json"
|
|
1059
1069
|
];
|
|
1060
1070
|
/**
|
|
1061
|
-
* Returns the schema-relative paths of stale contract
|
|
1071
|
+
* Returns the schema-relative paths of stale contract artifacts the
|
|
1062
1072
|
* previous `init` run (or a `contract emit`) left behind in `schemaDir`.
|
|
1063
1073
|
* Paths are returned relative to `baseDir` so the caller can plumb them
|
|
1064
1074
|
* into `filesWritten`-style logging without re-deriving the path.
|
|
1065
1075
|
*
|
|
1066
1076
|
* Pure function: no filesystem mutation. Used by `runInit`'s precondition
|
|
1067
1077
|
* phase (FR6.2 / NFR3 atomicity) so a downstream parse failure leaves
|
|
1068
|
-
* the
|
|
1078
|
+
* the artifacts on disk and the project byte-identical to its pre-init
|
|
1069
1079
|
* state.
|
|
1070
1080
|
*/
|
|
1071
|
-
function
|
|
1081
|
+
function findStaleArtifacts(baseDir, schemaDir) {
|
|
1072
1082
|
const result = [];
|
|
1073
|
-
for (const filename of
|
|
1083
|
+
for (const filename of ARTIFACT_FILENAMES) {
|
|
1074
1084
|
const rel = join(schemaDir, filename);
|
|
1075
1085
|
if (existsSync(join(baseDir, rel))) result.push(rel);
|
|
1076
1086
|
}
|
|
@@ -1370,7 +1380,7 @@ function renderTemplate(templateFile, variableNames, vars) {
|
|
|
1370
1380
|
let result = readFileSync(join(import.meta.dirname, templateFile), "utf-8");
|
|
1371
1381
|
for (const key of variableNames) {
|
|
1372
1382
|
const value = vars[key];
|
|
1373
|
-
if (value === void 0) throw new
|
|
1383
|
+
if (value === void 0) throw new InternalError(`Template variable '${key}' is not defined`);
|
|
1374
1384
|
result = result.replaceAll(`{{${key}}}`, value);
|
|
1375
1385
|
}
|
|
1376
1386
|
return result;
|
|
@@ -1640,7 +1650,7 @@ async function runInit(baseDir, runOptions) {
|
|
|
1640
1650
|
canPrompt
|
|
1641
1651
|
});
|
|
1642
1652
|
} catch (error) {
|
|
1643
|
-
if (CliStructuredError.is(error)) return emitError(ui, flags, error);
|
|
1653
|
+
if (CliStructuredError$1.is(error)) return emitError(ui, flags, error);
|
|
1644
1654
|
throw error;
|
|
1645
1655
|
}
|
|
1646
1656
|
const pm = await detectPackageManager(baseDir);
|
|
@@ -1669,7 +1679,7 @@ async function runInit(baseDir, runOptions) {
|
|
|
1669
1679
|
content: envExampleContent(inputs.target)
|
|
1670
1680
|
}
|
|
1671
1681
|
];
|
|
1672
|
-
const filesToDelete = inputs.reinit ? [...
|
|
1682
|
+
const filesToDelete = inputs.reinit ? [...findStaleArtifacts(baseDir, schemaDir)] : [];
|
|
1673
1683
|
if (existsSync(join(baseDir, ".agents/skills/prisma-next/SKILL.md"))) filesToDelete.push(LEGACY_SKILL_FILE);
|
|
1674
1684
|
if (inputs.writeEnv) if (!existsSync(join(baseDir, ".env"))) filesToWrite.push({
|
|
1675
1685
|
path: ".env",
|
|
@@ -1790,7 +1800,7 @@ async function runInit(baseDir, runOptions) {
|
|
|
1790
1800
|
hasTypesNode: parsedPackageJson !== null ? hasDirectDep(parsedPackageJson, "@types/node") : false
|
|
1791
1801
|
});
|
|
1792
1802
|
} catch (error) {
|
|
1793
|
-
if (CliStructuredError.is(error)) return emitError(ui, flags, error);
|
|
1803
|
+
if (CliStructuredError$1.is(error)) return emitError(ui, flags, error);
|
|
1794
1804
|
throw error;
|
|
1795
1805
|
}
|
|
1796
1806
|
warnings.push(...install.warnings);
|
|
@@ -1804,7 +1814,7 @@ async function runInit(baseDir, runOptions) {
|
|
|
1804
1814
|
});
|
|
1805
1815
|
contractEmitted = true;
|
|
1806
1816
|
} catch (error) {
|
|
1807
|
-
if (CliStructuredError.is(error)) return emitError(ui, flags, error);
|
|
1817
|
+
if (CliStructuredError$1.is(error)) return emitError(ui, flags, error);
|
|
1808
1818
|
throw error;
|
|
1809
1819
|
}
|
|
1810
1820
|
if (inputs.probeDb) {
|
|
@@ -1841,7 +1851,7 @@ async function runInit(baseDir, runOptions) {
|
|
|
1841
1851
|
skillRegistered = true;
|
|
1842
1852
|
} catch (error) {
|
|
1843
1853
|
spinner.stop("Agent-skill install failed");
|
|
1844
|
-
if (CliStructuredError.is(error)) return emitError(ui, flags, error);
|
|
1854
|
+
if (CliStructuredError$1.is(error)) return emitError(ui, flags, error);
|
|
1845
1855
|
throw error;
|
|
1846
1856
|
}
|
|
1847
1857
|
}
|
|
@@ -1868,7 +1878,7 @@ async function runInit(baseDir, runOptions) {
|
|
|
1868
1878
|
warnings
|
|
1869
1879
|
};
|
|
1870
1880
|
const validated = InitOutputSchema(output);
|
|
1871
|
-
if (validated instanceof Error || validated.problems !== void 0) return emitError(ui, flags, new CliStructuredError("CLI.INIT_INVALID_OUTPUT_DOCUMENT", "Init produced an invalid output document", {
|
|
1881
|
+
if (validated instanceof Error || validated.problems !== void 0) return emitError(ui, flags, new CliStructuredError$1("CLI.INIT_INVALID_OUTPUT_DOCUMENT", "Init produced an invalid output document", {
|
|
1872
1882
|
why: `The success document failed schema validation: ${String(validated)}`,
|
|
1873
1883
|
fix: "This is a bug in prisma-next. Please report it with the full `-v` output.",
|
|
1874
1884
|
docsUrl: "https://prisma-next.dev/docs/cli/init"
|
|
@@ -2081,7 +2091,7 @@ function formatCatalogWarning(workspaceFile, entries) {
|
|
|
2081
2091
|
/**
|
|
2082
2092
|
* Recognised pnpm error signatures that justify a fallback to npm.
|
|
2083
2093
|
*
|
|
2084
|
-
* These patterns indicate the published
|
|
2094
|
+
* These patterns indicate the published artifact itself is at fault
|
|
2085
2095
|
* (a leaked `workspace:*` or `catalog:` specifier), not the user's
|
|
2086
2096
|
* environment — pnpm is faithfully reporting "I cannot resolve this
|
|
2087
2097
|
* registry version", and npm is willing to install it because npm
|
|
@@ -2140,7 +2150,7 @@ async function runEmit(ctx) {
|
|
|
2140
2150
|
const spinner = ctx.ui.spinner();
|
|
2141
2151
|
spinner.start("Emitting contract...");
|
|
2142
2152
|
try {
|
|
2143
|
-
const { executeContractEmit } = await import("./contract-emit-
|
|
2153
|
+
const { executeContractEmit } = await import("./contract-emit-hVdlaF2U.mjs").then((n) => n.t);
|
|
2144
2154
|
await executeContractEmit({ configPath: join(ctx.baseDir, "prisma-next.config.ts") });
|
|
2145
2155
|
spinner.stop("Contract emitted");
|
|
2146
2156
|
} catch (err) {
|
|
@@ -2193,4 +2203,4 @@ function sanitisePackageName(raw) {
|
|
|
2193
2203
|
//#endregion
|
|
2194
2204
|
export { runInit };
|
|
2195
2205
|
|
|
2196
|
-
//# sourceMappingURL=init-
|
|
2206
|
+
//# sourceMappingURL=init-ClrRkbwd.mjs.map
|