prisma-next 0.12.0-dev.3 → 0.12.0-dev.30
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 +180 -163
- package/dist/cli.mjs.map +1 -1
- package/dist/{client-KgJorIvG.mjs → client-xeWpMlq1.mjs} +39 -15
- package/dist/client-xeWpMlq1.mjs.map +1 -0
- package/dist/{command-helpers-Bbw1GbwL.mjs → command-helpers-DK_5ItoJ.mjs} +284 -24
- package/dist/command-helpers-DK_5ItoJ.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.mjs +4 -5
- package/dist/commands/db-init.mjs.map +1 -1
- package/dist/commands/db-schema.mjs +3 -3
- package/dist/commands/db-sign.mjs +4 -4
- package/dist/commands/db-update.d.mts.map +1 -1
- package/dist/commands/db-update.mjs +10 -7
- 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.mjs +5 -6
- package/dist/commands/migrate.mjs.map +1 -1
- package/dist/commands/migration-check.mjs +1 -1
- package/dist/commands/migration-graph.d.mts +13 -7
- package/dist/commands/migration-graph.d.mts.map +1 -1
- package/dist/commands/migration-graph.mjs +171 -2
- package/dist/commands/migration-graph.mjs.map +1 -0
- package/dist/commands/migration-list.d.mts +24 -26
- package/dist/commands/migration-list.d.mts.map +1 -1
- package/dist/commands/migration-list.mjs +2 -190
- package/dist/commands/migration-log.d.mts +6 -18
- package/dist/commands/migration-log.d.mts.map +1 -1
- package/dist/commands/migration-log.mjs +1 -137
- package/dist/commands/migration-new.mjs +3 -3
- package/dist/commands/migration-plan.d.mts +1 -1
- package/dist/commands/migration-plan.mjs +1 -1
- package/dist/commands/migration-show.d.mts +1 -1
- package/dist/commands/migration-show.mjs +3 -4
- package/dist/commands/migration-show.mjs.map +1 -1
- package/dist/commands/migration-status.d.mts +41 -141
- package/dist/commands/migration-status.d.mts.map +1 -1
- package/dist/commands/migration-status.mjs +2 -759
- package/dist/commands/ref.d.mts +1 -1
- package/dist/commands/ref.mjs +3 -3
- package/dist/commands/telemetry/index.d.mts +7 -0
- package/dist/commands/telemetry/index.d.mts.map +1 -0
- package/dist/commands/telemetry/index.mjs +2 -0
- package/dist/{contract-at-errors-BxP-TOMl.mjs → contract-at-errors-DG3kjgoz.mjs} +2 -2
- package/dist/{contract-at-errors-BxP-TOMl.mjs.map → contract-at-errors-DG3kjgoz.mjs.map} +1 -1
- package/dist/{contract-emit-D-4jrNve.mjs → contract-emit-BO0l6fnT.mjs} +3 -3
- package/dist/{contract-emit-D-4jrNve.mjs.map → contract-emit-BO0l6fnT.mjs.map} +1 -1
- package/dist/{contract-emit-DxcGl4Uq.mjs → contract-emit-C0Bs0VRj.mjs} +3 -3
- package/dist/{contract-emit-DxcGl4Uq.mjs.map → contract-emit-C0Bs0VRj.mjs.map} +1 -1
- package/dist/{contract-infer-D8uEbJuu.mjs → contract-infer-2wtPflGH.mjs} +3 -3
- package/dist/{contract-infer-D8uEbJuu.mjs.map → contract-infer-2wtPflGH.mjs.map} +1 -1
- package/dist/{contract-space-aggregate-loader-DvZwdkrr.mjs → contract-space-aggregate-loader-Dbr3-jHF.mjs} +4 -4
- package/dist/{contract-space-aggregate-loader-DvZwdkrr.mjs.map → contract-space-aggregate-loader-Dbr3-jHF.mjs.map} +1 -1
- package/dist/{db-verify-v_vUKXTU.mjs → db-verify-CxHiSiTG.mjs} +4 -4
- package/dist/{db-verify-v_vUKXTU.mjs.map → db-verify-CxHiSiTG.mjs.map} +1 -1
- package/dist/exports/control-api.d.mts +1 -1
- package/dist/exports/control-api.d.mts.map +1 -1
- package/dist/exports/control-api.mjs +2 -2
- package/dist/exports/index.mjs +1 -1
- package/dist/exports/init-output.mjs +1 -1
- package/dist/{framework-components-fYXjz_in.mjs → framework-components-CxOVKAAh.mjs} +2 -2
- package/dist/{framework-components-fYXjz_in.mjs.map → framework-components-CxOVKAAh.mjs.map} +1 -1
- package/dist/{global-flags-DEHjV8_s.d.mts → global-flags-DG4uY5tV.d.mts} +1 -1
- package/dist/{global-flags-DEHjV8_s.d.mts.map → global-flags-DG4uY5tV.d.mts.map} +1 -1
- package/dist/{init-Cv9UzWL5.mjs → init-R272pxux.mjs} +5 -58
- package/dist/init-R272pxux.mjs.map +1 -0
- package/dist/{inspect-live-schema-C6ohV_oQ.mjs → inspect-live-schema-RekOwfi5.mjs} +3 -3
- package/dist/{inspect-live-schema-C6ohV_oQ.mjs.map → inspect-live-schema-RekOwfi5.mjs.map} +1 -1
- package/dist/{migration-check-BiBJoYYW.mjs → migration-check-Dc0cOhKH.mjs} +2 -2
- package/dist/{migration-check-BiBJoYYW.mjs.map → migration-check-Dc0cOhKH.mjs.map} +1 -1
- package/dist/{migration-command-scaffold-CjvwO6at.mjs → migration-command-scaffold-ApB3NxWY.mjs} +3 -3
- package/dist/{migration-command-scaffold-CjvwO6at.mjs.map → migration-command-scaffold-ApB3NxWY.mjs.map} +1 -1
- package/dist/migration-graph-space-render-dmLLWift.mjs +1966 -0
- package/dist/migration-graph-space-render-dmLLWift.mjs.map +1 -0
- package/dist/migration-list-C5sXrl0U.mjs +228 -0
- package/dist/migration-list-C5sXrl0U.mjs.map +1 -0
- package/dist/migration-list-types-DS63IdFd.d.mts +23 -0
- package/dist/migration-list-types-DS63IdFd.d.mts.map +1 -0
- package/dist/migration-log-DD_vCbYW.mjs +203 -0
- package/dist/migration-log-DD_vCbYW.mjs.map +1 -0
- package/dist/{migration-plan-9DJ7q7_z.mjs → migration-plan-CeTjQOIG.mjs} +5 -5
- package/dist/{migration-plan-9DJ7q7_z.mjs.map → migration-plan-CeTjQOIG.mjs.map} +1 -1
- package/dist/migration-status-qV8ctwPy.mjs +432 -0
- package/dist/migration-status-qV8ctwPy.mjs.map +1 -0
- package/dist/{output-B60Gw5fu.mjs → output-CF_hqzI-.mjs} +1 -1
- package/dist/{output-B60Gw5fu.mjs.map → output-CF_hqzI-.mjs.map} +1 -1
- package/dist/{ref-advancement-DUZqsue6.mjs → ref-advancement-V1o-9LVK.mjs} +1 -1
- package/dist/{ref-advancement-DUZqsue6.mjs.map → ref-advancement-V1o-9LVK.mjs.map} +1 -1
- package/dist/telemetry-S-NGi9U6.mjs +122 -0
- package/dist/telemetry-S-NGi9U6.mjs.map +1 -0
- package/dist/{types-Dt_SfqFm.d.mts → types-Mh7mdPHM.d.mts} +13 -2
- package/dist/types-Mh7mdPHM.d.mts.map +1 -0
- package/dist/{verify-DCA9Sldu.mjs → verify-BdI-BgYi.mjs} +2 -2
- package/dist/{verify-DCA9Sldu.mjs.map → verify-BdI-BgYi.mjs.map} +1 -1
- package/package.json +11 -12
- package/dist/client-KgJorIvG.mjs.map +0 -1
- package/dist/command-helpers-Bbw1GbwL.mjs.map +0 -1
- package/dist/commands/migration-list.mjs.map +0 -1
- package/dist/commands/migration-log.mjs.map +0 -1
- package/dist/commands/migration-status.mjs.map +0 -1
- package/dist/graph-render-rFAqZujX.mjs +0 -1081
- package/dist/graph-render-rFAqZujX.mjs.map +0 -1
- package/dist/init-Cv9UzWL5.mjs.map +0 -1
- package/dist/migration-graph-D7DVUElV.mjs +0 -1232
- package/dist/migration-graph-D7DVUElV.mjs.map +0 -1
- package/dist/migration-list-styler-BRwF4-gy.mjs +0 -399
- package/dist/migration-list-styler-BRwF4-gy.mjs.map +0 -1
- package/dist/migration-types-D2FW63pr.d.mts +0 -15
- package/dist/migration-types-D2FW63pr.d.mts.map +0 -1
- package/dist/migrations-Cv2jxNNK.mjs +0 -228
- package/dist/migrations-Cv2jxNNK.mjs.map +0 -1
- package/dist/types-Dt_SfqFm.d.mts.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CliStructuredError as CliStructuredError$1, errorConfigValidation as errorConfigValidation$1, errorContractConfigMissing as errorContractConfigMissing$1, errorContractValidationFailed, errorDatabaseConnectionRequired, errorDriverRequired, errorFileNotFound, errorInvalidOutputFormat, errorMigrationPlanningFailed, errorOutputFormatMutex, errorTargetMigrationNotSupported, errorUnexpected as errorUnexpected$1 } from "@prisma-next/errors/control";
|
|
2
|
-
import
|
|
2
|
+
import "@prisma-next/utils/defined";
|
|
3
3
|
import { notOk } from "@prisma-next/utils/result";
|
|
4
4
|
import { relative, resolve } from "pathe";
|
|
5
5
|
import { readFile } from "node:fs/promises";
|
|
@@ -12,6 +12,7 @@ import wrapAnsi from "wrap-ansi";
|
|
|
12
12
|
import stringWidth from "string-width";
|
|
13
13
|
import stripAnsi from "strip-ansi";
|
|
14
14
|
import { isCI } from "ci-info";
|
|
15
|
+
import { blindCast } from "@prisma-next/utils/casts";
|
|
15
16
|
import * as clack from "@clack/prompts";
|
|
16
17
|
//#region src/utils/cli-errors.ts
|
|
17
18
|
function errorRefSetHashNotInGraph(resolvedHash, reachableHashes, graphTipHash) {
|
|
@@ -39,6 +40,20 @@ function errorRefSetEmptySentinel(hash) {
|
|
|
39
40
|
});
|
|
40
41
|
}
|
|
41
42
|
/**
|
|
43
|
+
* `--legend` was combined with a machine-readable or silent output flag.
|
|
44
|
+
* The legend is human-only decoration on stderr.
|
|
45
|
+
*/
|
|
46
|
+
function errorLegendHumanOnly(conflictingFlag) {
|
|
47
|
+
return errorRuntime("`--legend` is only available for human-readable output", {
|
|
48
|
+
why: `\`--legend\` prints a glyph key to stderr and cannot be combined with ${conflictingFlag}.`,
|
|
49
|
+
fix: `Omit ${conflictingFlag} to print the legend alongside the tree, or omit --legend when using ${conflictingFlag}.`,
|
|
50
|
+
meta: {
|
|
51
|
+
code: "MIGRATION.LEGEND_HUMAN_ONLY",
|
|
52
|
+
conflictingFlag
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
42
57
|
* `--space <id>` was given a value that doesn't satisfy the contract-space
|
|
43
58
|
* naming rule (`[a-z][a-z0-9_-]{0,63}` per `isValidSpaceId`). Fires before
|
|
44
59
|
* any fs work — the input is syntactically rejected the same way an on-disk
|
|
@@ -670,6 +685,237 @@ function isCI$1() {
|
|
|
670
685
|
return isCI;
|
|
671
686
|
}
|
|
672
687
|
//#endregion
|
|
688
|
+
//#region src/utils/formatters/migrations.ts
|
|
689
|
+
/**
|
|
690
|
+
* Render a single statement of an `OperationPreview` for the human-readable
|
|
691
|
+
* preview block. SQL statements get a trailing `;` if missing so the rendered
|
|
692
|
+
* preview is byte-identical to the legacy `string[]`-based renderer for SQL
|
|
693
|
+
* targets. Other languages (`'mongodb-shell'`) render verbatim.
|
|
694
|
+
*/
|
|
695
|
+
function renderPreviewStatement(text, language) {
|
|
696
|
+
const trimmed = text.trim();
|
|
697
|
+
if (!trimmed) return void 0;
|
|
698
|
+
if (language === "sql") return trimmed.endsWith(";") ? trimmed : `${trimmed};`;
|
|
699
|
+
return trimmed;
|
|
700
|
+
}
|
|
701
|
+
/**
|
|
702
|
+
* Choose the header label for a preview block. SQL-only previews keep the
|
|
703
|
+
* legacy `DDL preview` label so the rendered output is byte-identical to the
|
|
704
|
+
* pre-aggregate SQL CLI; previews from any other family — or a mix that
|
|
705
|
+
* includes any non-SQL language — use the family-agnostic `Operation preview`
|
|
706
|
+
* label.
|
|
707
|
+
*
|
|
708
|
+
* An empty `statements` array deliberately renders as `Operation preview`
|
|
709
|
+
* rather than `DDL preview`: `Array.prototype.every` is vacuously true for
|
|
710
|
+
* empty arrays, but we have no evidence the preview is SQL-only when no
|
|
711
|
+
* statements are present, so the family-agnostic label is the safer default.
|
|
712
|
+
*/
|
|
713
|
+
function previewBlockHeader(preview) {
|
|
714
|
+
return preview.statements.length > 0 && preview.statements.every((s) => s.language === "sql") ? "DDL preview" : "Operation preview";
|
|
715
|
+
}
|
|
716
|
+
function formatPlannerWarningsBlock(warnings, useColor) {
|
|
717
|
+
const formatDimText = (text) => formatDim(useColor, text);
|
|
718
|
+
const lines = ["", "Warnings:"];
|
|
719
|
+
for (const warning of warnings) lines.push(` ${formatDimText(`- ${warning.summary}`)}`);
|
|
720
|
+
return lines;
|
|
721
|
+
}
|
|
722
|
+
/**
|
|
723
|
+
* Render the shared per-space execution block consumed by the `db init`
|
|
724
|
+
* / `db update` / `migrate` summaries. Always shows: space
|
|
725
|
+
* label (`Extension space: <id>` or `App space`) → per-op lines under
|
|
726
|
+
* each space → per-space marker hash (when known).
|
|
727
|
+
*
|
|
728
|
+
* `mode` controls the marker label phrasing — `'apply'` shows
|
|
729
|
+
* `marker → <hash>` (post-apply), `'plan'` omits the marker line
|
|
730
|
+
* entirely (no marker has been written yet).
|
|
731
|
+
*/
|
|
732
|
+
function formatPerSpaceBlock(perSpace, mode, useColor) {
|
|
733
|
+
const formatYellow = createColorFormatter(useColor, yellow);
|
|
734
|
+
const formatCyan = createColorFormatter(useColor, cyan);
|
|
735
|
+
const formatDimText = (text) => formatDim(useColor, text);
|
|
736
|
+
const lines = [];
|
|
737
|
+
for (let s = 0; s < perSpace.length; s++) {
|
|
738
|
+
const space = perSpace[s];
|
|
739
|
+
if (s > 0) lines.push("");
|
|
740
|
+
const header = space.kind === "app" ? formatCyan("App space") : formatCyan(`Extension space: ${space.spaceId}`);
|
|
741
|
+
lines.push(header);
|
|
742
|
+
if (space.operations.length === 0) lines.push(` ${formatDimText("(no operations)")}`);
|
|
743
|
+
else for (let i = 0; i < space.operations.length; i++) {
|
|
744
|
+
const op = space.operations[i];
|
|
745
|
+
const treeChar = i === space.operations.length - 1 ? "└" : "├";
|
|
746
|
+
const destructiveMarker = op.operationClass === "destructive" ? ` ${formatYellow("(destructive)")}` : "";
|
|
747
|
+
lines.push(` ${formatDimText(treeChar)}─ ${op.label}${destructiveMarker}`);
|
|
748
|
+
}
|
|
749
|
+
if (mode === "apply" && space.marker) lines.push(` ${formatDimText(`marker: ${space.marker.storageHash}`)}`);
|
|
750
|
+
}
|
|
751
|
+
return lines;
|
|
752
|
+
}
|
|
753
|
+
/**
|
|
754
|
+
* Formats human-readable output for migration commands (db init, db update) in plan mode.
|
|
755
|
+
*/
|
|
756
|
+
function formatMigrationPlanOutput(result, flags) {
|
|
757
|
+
if (flags.quiet) return "";
|
|
758
|
+
const lines = [];
|
|
759
|
+
const useColor = flags.color !== false;
|
|
760
|
+
const formatGreen = createColorFormatter(useColor, green);
|
|
761
|
+
const formatDimText = (text) => formatDim(useColor, text);
|
|
762
|
+
const operationCount = result.plan?.operations.length ?? 0;
|
|
763
|
+
const spaceCount = result.perSpace?.length ?? 0;
|
|
764
|
+
if (spaceCount > 0) lines.push(`${formatGreen("✔")} Planned ${operationCount} operation(s) across ${spaceCount} contract space${spaceCount === 1 ? "" : "s"}`);
|
|
765
|
+
else lines.push(`${formatGreen("✔")} Planned ${operationCount} operation(s)`);
|
|
766
|
+
if (result.warnings && result.warnings.length > 0) lines.push(...formatPlannerWarningsBlock(result.warnings, useColor));
|
|
767
|
+
const formatYellow = createColorFormatter(useColor, yellow);
|
|
768
|
+
if (result.perSpace && result.perSpace.length > 0) {
|
|
769
|
+
lines.push("");
|
|
770
|
+
lines.push(...formatPerSpaceBlock(result.perSpace, "plan", useColor));
|
|
771
|
+
if (result.perSpace.some((s) => s.operations.some((op) => op.operationClass === "destructive"))) {
|
|
772
|
+
lines.push("");
|
|
773
|
+
lines.push(`${formatYellow("⚠")} This migration contains destructive operations that may cause data loss.`);
|
|
774
|
+
}
|
|
775
|
+
} else if (result.plan?.operations && result.plan.operations.length > 0) {
|
|
776
|
+
lines.push(`${formatDimText("│")}`);
|
|
777
|
+
for (let i = 0; i < result.plan.operations.length; i++) {
|
|
778
|
+
const op = result.plan.operations[i];
|
|
779
|
+
if (!op) continue;
|
|
780
|
+
const treeChar = i === result.plan.operations.length - 1 ? "└" : "├";
|
|
781
|
+
const destructiveMarker = op.operationClass === "destructive" ? ` ${formatYellow("(destructive)")}` : "";
|
|
782
|
+
lines.push(`${formatDimText(treeChar)}─ ${op.label}${destructiveMarker}`);
|
|
783
|
+
}
|
|
784
|
+
if (result.plan.operations.some((op) => op.operationClass === "destructive")) {
|
|
785
|
+
lines.push("");
|
|
786
|
+
lines.push(`${formatYellow("⚠")} This migration contains destructive operations that may cause data loss.`);
|
|
787
|
+
}
|
|
788
|
+
}
|
|
789
|
+
if (result.plan?.destination) {
|
|
790
|
+
lines.push("");
|
|
791
|
+
lines.push(`${formatDimText(`Destination hash: ${result.plan.destination.storageHash}`)}`);
|
|
792
|
+
}
|
|
793
|
+
if (result.plannedAdvanceRef) {
|
|
794
|
+
lines.push("");
|
|
795
|
+
lines.push(formatDimText(`Would advance ref "${result.plannedAdvanceRef.name}" → ${result.plannedAdvanceRef.hash}`));
|
|
796
|
+
}
|
|
797
|
+
const preview = result.plan?.preview;
|
|
798
|
+
if (preview) {
|
|
799
|
+
lines.push("");
|
|
800
|
+
lines.push(`${formatDimText(previewBlockHeader(preview))}`);
|
|
801
|
+
if (preview.statements.length === 0) lines.push(`${formatDimText("No operations.")}`);
|
|
802
|
+
else {
|
|
803
|
+
lines.push("");
|
|
804
|
+
for (const statement of preview.statements) {
|
|
805
|
+
const rendered = renderPreviewStatement(statement.text, statement.language);
|
|
806
|
+
if (rendered) lines.push(rendered);
|
|
807
|
+
}
|
|
808
|
+
}
|
|
809
|
+
}
|
|
810
|
+
if (isVerbose(flags, 1)) lines.push(`${formatDimText(`Total time: ${result.timings.total}ms`)}`);
|
|
811
|
+
lines.push("");
|
|
812
|
+
lines.push(`${formatDimText("This is a dry run. No changes were applied.")}`);
|
|
813
|
+
lines.push(`${formatDimText("Run without --dry-run to apply changes.")}`);
|
|
814
|
+
return lines.join("\n");
|
|
815
|
+
}
|
|
816
|
+
function formatMigrationApplyCommandOutput(result, flags) {
|
|
817
|
+
if (flags.quiet) return "";
|
|
818
|
+
const lines = [];
|
|
819
|
+
const useColor = flags.color !== false;
|
|
820
|
+
const formatGreen = createColorFormatter(useColor, green);
|
|
821
|
+
const formatDimText = (text) => formatDim(useColor, text);
|
|
822
|
+
lines.push(`${formatGreen("✔")} ${result.summary}`);
|
|
823
|
+
if (result.perSpace.length > 0) {
|
|
824
|
+
lines.push("");
|
|
825
|
+
for (const line of formatPerSpaceBlock(result.perSpace, "apply", useColor)) lines.push(line);
|
|
826
|
+
}
|
|
827
|
+
if (result.advancedRef) {
|
|
828
|
+
lines.push("");
|
|
829
|
+
lines.push(formatDimText(`Advanced ref "${result.advancedRef.name}" → ${result.advancedRef.hash}`));
|
|
830
|
+
}
|
|
831
|
+
lines.push("");
|
|
832
|
+
lines.push(formatDimText("Next: prisma-next migration status"));
|
|
833
|
+
if (isVerbose(flags, 1) && result.timings) {
|
|
834
|
+
lines.push("");
|
|
835
|
+
lines.push(formatDimText(`Total time: ${result.timings.total}ms`));
|
|
836
|
+
}
|
|
837
|
+
return lines.join("\n");
|
|
838
|
+
}
|
|
839
|
+
function formatSpaceShowBlock(space, useColor) {
|
|
840
|
+
const formatGreen = createColorFormatter(useColor, green);
|
|
841
|
+
const formatYellow = createColorFormatter(useColor, yellow);
|
|
842
|
+
const formatDimText = (text) => formatDim(useColor, text);
|
|
843
|
+
const lines = [];
|
|
844
|
+
lines.push(`${formatGreen("✔")} ${space.dirName}`);
|
|
845
|
+
lines.push(`${formatDimText(` from: ${space.from ?? "(baseline)"}`)}`);
|
|
846
|
+
lines.push(`${formatDimText(` to: ${space.to}`)}`);
|
|
847
|
+
lines.push(`${formatDimText(` migrationHash: ${space.migrationHash}`)}`);
|
|
848
|
+
lines.push(`${formatDimText(` created: ${space.createdAt}`)}`);
|
|
849
|
+
lines.push("");
|
|
850
|
+
lines.push(`${space.operations.length} operation(s)`);
|
|
851
|
+
if (space.operations.length > 0) {
|
|
852
|
+
lines.push(`${formatDimText("│")}`);
|
|
853
|
+
for (let i = 0; i < space.operations.length; i++) {
|
|
854
|
+
const op = space.operations[i];
|
|
855
|
+
const treeChar = i === space.operations.length - 1 ? "└" : "├";
|
|
856
|
+
const destructiveMarker = op.operationClass === "destructive" ? ` ${formatYellow("(destructive)")}` : "";
|
|
857
|
+
lines.push(`${formatDimText(treeChar)}─ ${op.label}${destructiveMarker}`);
|
|
858
|
+
}
|
|
859
|
+
if (space.operations.some((op) => op.operationClass === "destructive")) {
|
|
860
|
+
lines.push("");
|
|
861
|
+
lines.push(`${formatYellow("⚠")} This migration contains destructive operations that may cause data loss.`);
|
|
862
|
+
}
|
|
863
|
+
}
|
|
864
|
+
if (space.preview.statements.length > 0) {
|
|
865
|
+
lines.push("");
|
|
866
|
+
lines.push(`${formatDimText(previewBlockHeader(space.preview))}`);
|
|
867
|
+
lines.push("");
|
|
868
|
+
for (const statement of space.preview.statements) {
|
|
869
|
+
const rendered = renderPreviewStatement(statement.text, statement.language);
|
|
870
|
+
if (rendered) lines.push(rendered);
|
|
871
|
+
}
|
|
872
|
+
}
|
|
873
|
+
return lines;
|
|
874
|
+
}
|
|
875
|
+
function formatMigrationShowOutput(result, flags) {
|
|
876
|
+
if (flags.quiet) return "";
|
|
877
|
+
const useColor = flags.color !== false;
|
|
878
|
+
return formatSpaceShowBlock(result.migration, useColor).join("\n");
|
|
879
|
+
}
|
|
880
|
+
/**
|
|
881
|
+
* Formats human-readable output for migration commands (db init, db update) in apply mode.
|
|
882
|
+
*/
|
|
883
|
+
function formatMigrationApplyOutput(result, flags) {
|
|
884
|
+
if (flags.quiet) return "";
|
|
885
|
+
const lines = [];
|
|
886
|
+
const useColor = flags.color !== false;
|
|
887
|
+
const formatGreen = createColorFormatter(useColor, green);
|
|
888
|
+
const formatDimText = (text) => formatDim(useColor, text);
|
|
889
|
+
if (result.ok) {
|
|
890
|
+
const executed = result.execution?.operationsExecuted ?? 0;
|
|
891
|
+
const spaceCount = result.perSpace?.length ?? 0;
|
|
892
|
+
if (executed === 0) {
|
|
893
|
+
const acrossClause = spaceCount > 0 ? ` across ${spaceCount} contract space${spaceCount === 1 ? "" : "s"}` : "";
|
|
894
|
+
lines.push(`${formatGreen("✔")} Database already matches contract${acrossClause}`);
|
|
895
|
+
} else if (spaceCount > 0) lines.push(`${formatGreen("✔")} Applied ${executed} operation(s) across ${spaceCount} contract space${spaceCount === 1 ? "" : "s"}`);
|
|
896
|
+
else lines.push(`${formatGreen("✔")} Applied ${executed} operation(s)`);
|
|
897
|
+
if (result.warnings && result.warnings.length > 0) lines.push(...formatPlannerWarningsBlock(result.warnings, useColor));
|
|
898
|
+
if (result.perSpace && result.perSpace.length > 0) {
|
|
899
|
+
lines.push("");
|
|
900
|
+
lines.push(...formatPerSpaceBlock(result.perSpace, "apply", useColor));
|
|
901
|
+
lines.push("");
|
|
902
|
+
lines.push(formatDimText(`Run 'prisma-next migration status' to confirm ${spaceCount === 1 ? "the space is" : "all spaces are"} up to date.`));
|
|
903
|
+
} else if (result.marker) {
|
|
904
|
+
lines.push(`${formatDimText(` App-space marker: ${result.marker.storageHash}`)}`);
|
|
905
|
+
if (result.marker.profileHash) lines.push(`${formatDimText(` Profile hash: ${result.marker.profileHash}`)}`);
|
|
906
|
+
}
|
|
907
|
+
if (isVerbose(flags, 1)) lines.push(`${formatDimText(` Total time: ${result.timings.total}ms`)}`);
|
|
908
|
+
if (result.advancedRef) lines.push(formatDimText(`Advanced ref "${result.advancedRef.name}" → ${result.advancedRef.hash}`));
|
|
909
|
+
}
|
|
910
|
+
return lines.join("\n");
|
|
911
|
+
}
|
|
912
|
+
/**
|
|
913
|
+
* Formats JSON output for migration commands (db init, db update).
|
|
914
|
+
*/
|
|
915
|
+
function formatMigrationJson(result) {
|
|
916
|
+
return JSON.stringify(result, null, 2);
|
|
917
|
+
}
|
|
918
|
+
//#endregion
|
|
673
919
|
//#region src/utils/formatters/errors.ts
|
|
674
920
|
/**
|
|
675
921
|
* Formats error output for human-readable display.
|
|
@@ -711,6 +957,11 @@ function formatErrorOutput(error, flags) {
|
|
|
711
957
|
}
|
|
712
958
|
}
|
|
713
959
|
if (error.docsUrl && isVerbose(flags, 1)) lines.push(formatDimText(error.docsUrl));
|
|
960
|
+
const plannerWarnings = error.meta?.["plannerWarnings"];
|
|
961
|
+
if (Array.isArray(plannerWarnings) && plannerWarnings.length > 0) {
|
|
962
|
+
const typedWarnings = blindCast(plannerWarnings);
|
|
963
|
+
lines.push(...formatPlannerWarningsBlock(typedWarnings, useColor));
|
|
964
|
+
}
|
|
714
965
|
if (isVerbose(flags, 2) && error.meta) lines.push(`${formatDimText(` Meta: ${JSON.stringify(error.meta, null, 2)}`)}`);
|
|
715
966
|
return lines.join("\n");
|
|
716
967
|
}
|
|
@@ -1163,6 +1414,36 @@ function parseGlobalFlags(options) {
|
|
|
1163
1414
|
if (options.yes || options.y) flags.yes = true;
|
|
1164
1415
|
return flags;
|
|
1165
1416
|
}
|
|
1417
|
+
/**
|
|
1418
|
+
* Bridges the two TTY checks (stdout via `flags`, stdin via
|
|
1419
|
+
* `process.stdin.isTTY`) into the `canPrompt` boolean the interactive
|
|
1420
|
+
* `init` flow consumes.
|
|
1421
|
+
*
|
|
1422
|
+
* Per the [Style Guide § Interactivity](../../../../../../../docs/CLI%20Style%20Guide.md#interactivity):
|
|
1423
|
+
*
|
|
1424
|
+
* - `flags.interactive` governs *decoration* (TerminalUI, intro/outro,
|
|
1425
|
+
* spinners) and is derived from stdout-TTY by `parseGlobalFlags`,
|
|
1426
|
+
* honouring `--interactive` / `--no-interactive`.
|
|
1427
|
+
* - Prompting additionally requires a stdin TTY — closing stdin is a
|
|
1428
|
+
* common signal in CI / agent environments even when stdout stays
|
|
1429
|
+
* attached.
|
|
1430
|
+
* - `--interactive` is the explicit override: when the user passes it,
|
|
1431
|
+
* we honour it (e.g. testing flows where stdin is stubbed).
|
|
1432
|
+
*
|
|
1433
|
+
* Single source of truth for the interactive-prompt decision: both the
|
|
1434
|
+
* `init` action handler and the preAction telemetry bridge derive
|
|
1435
|
+
* prompt-eligibility from this helper so they cannot drift. Lives in
|
|
1436
|
+
* `global-flags` (alongside `parseGlobalFlags`) to keep
|
|
1437
|
+
* `utils/telemetry` and `commands/init/index` free of an import cycle.
|
|
1438
|
+
*
|
|
1439
|
+
* Exported so callers and tests can derive the same value without
|
|
1440
|
+
* touching `process` globals.
|
|
1441
|
+
*/
|
|
1442
|
+
function deriveCanPrompt(opts) {
|
|
1443
|
+
if (opts.optionInteractive === true) return true;
|
|
1444
|
+
if (opts.flagsInteractive === false) return false;
|
|
1445
|
+
return opts.stdinIsTTY;
|
|
1446
|
+
}
|
|
1166
1447
|
//#endregion
|
|
1167
1448
|
//#region src/utils/command-helpers.ts
|
|
1168
1449
|
const longDescriptions = /* @__PURE__ */ new WeakMap();
|
|
@@ -1269,27 +1550,6 @@ function toStructuralEdge(edge) {
|
|
|
1269
1550
|
invariants: edge.invariants
|
|
1270
1551
|
};
|
|
1271
1552
|
}
|
|
1272
|
-
/**
|
|
1273
|
-
* Maps a PathDecision to the slim CLI output representation.
|
|
1274
|
-
*/
|
|
1275
|
-
function toPathDecisionResult(decision) {
|
|
1276
|
-
return {
|
|
1277
|
-
fromHash: decision.fromHash,
|
|
1278
|
-
toHash: decision.toHash,
|
|
1279
|
-
alternativeCount: decision.alternativeCount,
|
|
1280
|
-
tieBreakReasons: decision.tieBreakReasons,
|
|
1281
|
-
requiredInvariants: decision.requiredInvariants ?? [],
|
|
1282
|
-
satisfiedInvariants: decision.satisfiedInvariants ?? [],
|
|
1283
|
-
...ifDefined("refName", decision.refName),
|
|
1284
|
-
selectedPath: decision.selectedPath.map((entry) => ({
|
|
1285
|
-
dirName: entry.dirName,
|
|
1286
|
-
migrationHash: entry.migrationHash,
|
|
1287
|
-
from: entry.from,
|
|
1288
|
-
to: entry.to,
|
|
1289
|
-
invariants: entry.invariants
|
|
1290
|
-
}))
|
|
1291
|
-
};
|
|
1292
|
-
}
|
|
1293
1553
|
function targetSupportsMigrations(target) {
|
|
1294
1554
|
return hasMigrations(target);
|
|
1295
1555
|
}
|
|
@@ -1370,6 +1630,6 @@ function addGlobalOptions(command) {
|
|
|
1370
1630
|
} }).option("--format <pretty|json>", "Output format (default: pretty, or json when stdout is not a TTY)").option("--json", "Output as JSON (alias for --format json)").option("-q, --quiet", "Quiet mode: errors only").option("-v, --verbose", "Verbose output: debug info, timings").option("--trace", "Trace output: deep internals, stack traces").option("--color", "Force color output").option("--no-color", "Disable color output").option("--interactive", "Force interactive mode").option("--no-interactive", "Disable interactive prompts").option("-y, --yes", "Auto-accept prompts");
|
|
1371
1631
|
}
|
|
1372
1632
|
//#endregion
|
|
1373
|
-
export {
|
|
1633
|
+
export { errorRefSetEmptySentinel as $, formatStyledHeader as A, errorDatabaseConnectionRequired as B, formatMigrationApplyOutput as C, isCI$1 as D, formatMigrationShowOutput as E, CliStructuredError$1 as F, errorInvalidSpaceId as G, errorDriverRequired as H, ERROR_CODE_DESTRUCTIVE_CHANGES as I, errorMarkerMissing as J, errorLegendHumanOnly as K, errorConfigValidation$1 as L, createColorFormatter as M, formatDim as N, formatCommandHelp as O, isVerbose as P, errorRefSetBundleNotFound as Q, errorContractConfigMissing$1 as R, formatMigrationApplyCommandOutput as S, formatMigrationPlanOutput as T, errorFileNotFound as U, errorDestructiveChanges as V, errorHashMismatch as W, errorPathUnreachable as X, errorMigrationPlanningFailed as Y, errorPlanForgotTheFlag as Z, createTerminalUI as _, readContractEnvelope as a, errorTargetMigrationNotSupported as at, formatErrorJson as b, sanitizeErrorMessage as c, mapMigrationToolsError as ct, setCommandSeeAlso as d, errorRefSetHashNotInGraph as et, targetSupportsMigrations as f, parseGlobalFlagsOrExit as g, parseGlobalFlags as h, maskConnectionUrl as i, errorSpaceNotFound as it, formatSuccessMessage as j, formatRootHelp as k, setCommandDescriptions as l, mapRefResolutionError as lt, deriveCanPrompt as m, collectDeclaredInvariants as n, errorRuntime$1 as nt, resolveContractPath as o, errorTargetMismatch as ot, toStructuralEdge as p, errorMarkerMismatch as q, getTargetMigrations as r, errorSnapshotMissing as rt, resolveMigrationPaths as s, errorUnexpected$1 as st, addGlobalOptions as t, errorRunnerFailed as tt, setCommandExamples as u, installShutdownHandlers as v, formatMigrationJson as w, formatErrorOutput as x, handleResult as y, errorContractValidationFailed as z };
|
|
1374
1634
|
|
|
1375
|
-
//# sourceMappingURL=command-helpers-
|
|
1635
|
+
//# sourceMappingURL=command-helpers-DK_5ItoJ.mjs.map
|