prisma-next 0.5.0-dev.8 → 0.5.0-dev.81
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-errors-B9OBbled.d.mts +3 -0
- package/dist/cli-errors-D3_sMh2K.mjs +33 -0
- package/dist/cli-errors-D3_sMh2K.mjs.map +1 -0
- package/dist/cli.mjs +16 -78
- package/dist/cli.mjs.map +1 -1
- package/dist/client-qVH-rEgd.mjs +1595 -0
- package/dist/client-qVH-rEgd.mjs.map +1 -0
- package/dist/{result-handler-Ba3zWQsI.mjs → command-helpers-BeZHkxV8.mjs} +70 -47
- package/dist/command-helpers-BeZHkxV8.mjs.map +1 -0
- package/dist/commands/contract-emit.d.mts.map +1 -1
- package/dist/commands/contract-emit.mjs +2 -4
- package/dist/commands/contract-infer.d.mts.map +1 -1
- package/dist/commands/contract-infer.mjs +2 -4
- package/dist/commands/db-init.d.mts.map +1 -1
- package/dist/commands/db-init.mjs +16 -13
- package/dist/commands/db-init.mjs.map +1 -1
- package/dist/commands/db-schema.d.mts.map +1 -1
- package/dist/commands/db-schema.mjs +6 -7
- package/dist/commands/db-schema.mjs.map +1 -1
- package/dist/commands/db-sign.d.mts.map +1 -1
- package/dist/commands/db-sign.mjs +9 -9
- 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 +15 -13
- package/dist/commands/db-update.mjs.map +1 -1
- package/dist/commands/db-verify.d.mts.map +1 -1
- package/dist/commands/db-verify.mjs +1 -321
- package/dist/commands/migration-apply.d.mts +28 -13
- package/dist/commands/migration-apply.d.mts.map +1 -1
- package/dist/commands/migration-apply.mjs +55 -151
- package/dist/commands/migration-apply.mjs.map +1 -1
- package/dist/commands/migration-new.d.mts +0 -1
- package/dist/commands/migration-new.d.mts.map +1 -1
- package/dist/commands/migration-new.mjs +34 -40
- package/dist/commands/migration-new.mjs.map +1 -1
- package/dist/commands/migration-plan.d.mts +33 -6
- package/dist/commands/migration-plan.d.mts.map +1 -1
- package/dist/commands/migration-plan.mjs +2 -348
- package/dist/commands/migration-ref.d.mts +1 -1
- package/dist/commands/migration-ref.d.mts.map +1 -1
- package/dist/commands/migration-ref.mjs +8 -12
- package/dist/commands/migration-ref.mjs.map +1 -1
- package/dist/commands/migration-show.d.mts +13 -7
- package/dist/commands/migration-show.d.mts.map +1 -1
- package/dist/commands/migration-show.mjs +35 -36
- package/dist/commands/migration-show.mjs.map +1 -1
- package/dist/commands/migration-status.d.mts +126 -5
- package/dist/commands/migration-status.d.mts.map +1 -1
- package/dist/commands/migration-status.mjs +2 -4
- package/dist/{config-loader-C25b63rJ.mjs → config-loader-B6sJjXTv.mjs} +3 -5
- package/dist/config-loader-B6sJjXTv.mjs.map +1 -0
- package/dist/config-loader.d.mts +0 -1
- package/dist/config-loader.d.mts.map +1 -1
- package/dist/config-loader.mjs +2 -3
- package/dist/contract-emit-9DBda5Ou.mjs +150 -0
- package/dist/contract-emit-9DBda5Ou.mjs.map +1 -0
- package/dist/contract-emit-B77TsJqf.mjs +327 -0
- package/dist/contract-emit-B77TsJqf.mjs.map +1 -0
- package/dist/{contract-enrichment-CAOELa-H.mjs → contract-enrichment-Dani0mMW.mjs} +4 -6
- package/dist/contract-enrichment-Dani0mMW.mjs.map +1 -0
- package/dist/{contract-infer-D9cC3rJm.mjs → contract-infer-BK9YFGEG.mjs} +13 -22
- package/dist/contract-infer-BK9YFGEG.mjs.map +1 -0
- package/dist/db-verify-C0y1PCO2.mjs +404 -0
- package/dist/db-verify-C0y1PCO2.mjs.map +1 -0
- package/dist/exports/config-types.mjs +1 -2
- package/dist/exports/control-api.d.mts +101 -586
- package/dist/exports/control-api.d.mts.map +1 -1
- package/dist/exports/control-api.mjs +4 -6
- package/dist/exports/index.d.mts.map +1 -1
- package/dist/exports/index.mjs +28 -30
- package/dist/exports/index.mjs.map +1 -1
- package/dist/exports/init-output.d.mts +2 -4
- package/dist/exports/init-output.d.mts.map +1 -1
- package/dist/exports/init-output.mjs +2 -3
- package/dist/extension-pack-inputs-C7xgE-vv.mjs +74 -0
- package/dist/extension-pack-inputs-C7xgE-vv.mjs.map +1 -0
- package/dist/{framework-components-Cr--XBKy.mjs → framework-components-ChqVUxR-.mjs} +3 -4
- package/dist/{framework-components-Cr--XBKy.mjs.map → framework-components-ChqVUxR-.mjs.map} +1 -1
- package/dist/global-flags-Icqpxk23.d.mts +12 -0
- package/dist/global-flags-Icqpxk23.d.mts.map +1 -0
- package/dist/helpers-eqdN8tH6.mjs +25 -0
- package/dist/helpers-eqdN8tH6.mjs.map +1 -0
- package/dist/{init-C5220SY9.mjs → init-CoDVPvQ4.mjs} +26 -35
- package/dist/init-CoDVPvQ4.mjs.map +1 -0
- package/dist/{inspect-live-schema-yrHAvG71.mjs → inspect-live-schema-CWYxGKlb.mjs} +10 -11
- package/dist/inspect-live-schema-CWYxGKlb.mjs.map +1 -0
- package/dist/migration-cli.d.mts +41 -12
- package/dist/migration-cli.d.mts.map +1 -1
- package/dist/migration-cli.mjs +309 -86
- package/dist/migration-cli.mjs.map +1 -1
- package/dist/{migration-command-scaffold-B3B09et6.mjs → migration-command-scaffold-B5dORFEv.mjs} +8 -9
- package/dist/migration-command-scaffold-B5dORFEv.mjs.map +1 -0
- package/dist/migration-plan-C6lVaHsO.mjs +554 -0
- package/dist/migration-plan-C6lVaHsO.mjs.map +1 -0
- package/dist/{migration-status-DUMiH8_G.mjs → migration-status-CZ-D5k7k.mjs} +272 -65
- package/dist/migration-status-CZ-D5k7k.mjs.map +1 -0
- package/dist/migrations-D_UJnpuW.mjs +216 -0
- package/dist/migrations-D_UJnpuW.mjs.map +1 -0
- package/dist/{output-BpcQrnnq.mjs → output-B16Kefzx.mjs} +9 -3
- package/dist/output-B16Kefzx.mjs.map +1 -0
- package/dist/{progress-adapter-DvQWB1nK.mjs → progress-adapter-DFfvZcYL.mjs} +2 -2
- package/dist/{progress-adapter-DvQWB1nK.mjs.map → progress-adapter-DFfvZcYL.mjs.map} +1 -1
- package/dist/result-handler-rmPVKIP2.mjs +25 -0
- package/dist/result-handler-rmPVKIP2.mjs.map +1 -0
- package/dist/rolldown-runtime-twds-ZHy.mjs +14 -0
- package/dist/{terminal-ui-C3ZLwQxK.mjs → terminal-ui-C_hFNbAn.mjs} +4 -28
- package/dist/terminal-ui-C_hFNbAn.mjs.map +1 -0
- package/dist/types-D7x-IFLO.d.mts +858 -0
- package/dist/types-D7x-IFLO.d.mts.map +1 -0
- package/dist/{verify-Bkycc-Tf.mjs → verify-CiwNWM9N.mjs} +3 -4
- package/dist/verify-CiwNWM9N.mjs.map +1 -0
- package/package.json +19 -17
- package/dist/cli-errors-BFYgBH3L.d.mts +0 -4
- package/dist/cli-errors-Cd79vmTH.mjs +0 -5
- package/dist/client-CrsnY58k.mjs +0 -997
- package/dist/client-CrsnY58k.mjs.map +0 -1
- package/dist/commands/db-verify.mjs.map +0 -1
- package/dist/commands/migration-plan.mjs.map +0 -1
- package/dist/config-loader-C25b63rJ.mjs.map +0 -1
- package/dist/contract-emit--feXyNd7.mjs +0 -4
- package/dist/contract-emit-NJ01hiiv.mjs +0 -195
- package/dist/contract-emit-NJ01hiiv.mjs.map +0 -1
- package/dist/contract-emit-V5SSitUT.mjs +0 -122
- package/dist/contract-emit-V5SSitUT.mjs.map +0 -1
- package/dist/contract-enrichment-CAOELa-H.mjs.map +0 -1
- package/dist/contract-infer-D9cC3rJm.mjs.map +0 -1
- package/dist/extract-operation-statements-DsFfxXVZ.mjs +0 -13
- package/dist/extract-operation-statements-DsFfxXVZ.mjs.map +0 -1
- package/dist/extract-sql-ddl-D9UbZDyz.mjs +0 -26
- package/dist/extract-sql-ddl-D9UbZDyz.mjs.map +0 -1
- package/dist/init-C5220SY9.mjs.map +0 -1
- package/dist/inspect-live-schema-yrHAvG71.mjs.map +0 -1
- package/dist/migration-command-scaffold-B3B09et6.mjs.map +0 -1
- package/dist/migration-status-DUMiH8_G.mjs.map +0 -1
- package/dist/migrations-Bo5WtTla.mjs +0 -153
- package/dist/migrations-Bo5WtTla.mjs.map +0 -1
- package/dist/output-BpcQrnnq.mjs.map +0 -1
- package/dist/result-handler-Ba3zWQsI.mjs.map +0 -1
- package/dist/terminal-ui-C3ZLwQxK.mjs.map +0 -1
- package/dist/validate-contract-deps-B_Cs29TL.mjs +0 -37
- package/dist/validate-contract-deps-B_Cs29TL.mjs.map +0 -1
- package/dist/verify-Bkycc-Tf.mjs.map +0 -1
|
@@ -1,19 +1,42 @@
|
|
|
1
|
+
import { t as GlobalFlags } from "../global-flags-Icqpxk23.mjs";
|
|
1
2
|
import { Command } from "commander";
|
|
2
3
|
import { Result } from "@prisma-next/utils/result";
|
|
4
|
+
import { OperationPreview } from "@prisma-next/framework-components/control";
|
|
3
5
|
|
|
4
6
|
//#region src/commands/migration-plan.d.ts
|
|
5
7
|
interface MigrationPlanResult {
|
|
6
8
|
readonly ok: boolean;
|
|
7
9
|
readonly noOp: boolean;
|
|
8
|
-
readonly from: string;
|
|
10
|
+
readonly from: string | null;
|
|
9
11
|
readonly to: string;
|
|
10
12
|
readonly dir?: string;
|
|
13
|
+
/**
|
|
14
|
+
* Extension-space migration packages materialised onto disk during this
|
|
15
|
+
* `plan` run. Each entry names a `migrations/<spaceId>/<dirName>/`
|
|
16
|
+
* tree the framework wrote alongside the app-space migration directory.
|
|
17
|
+
* Empty when the project has no extension packs declaring a contract
|
|
18
|
+
* space, or when every extension-space package is already on disk.
|
|
19
|
+
*
|
|
20
|
+
* Surfacing these in the result (rather than only via `ui.step` log
|
|
21
|
+
* lines) makes the cross-space side effect explicit to JSON consumers
|
|
22
|
+
* and the success-summary renderer — the same multi-space side effect
|
|
23
|
+
* that `migration apply` will replay.
|
|
24
|
+
*/
|
|
25
|
+
readonly emittedExtensionDirs: readonly {
|
|
26
|
+
readonly spaceId: string;
|
|
27
|
+
readonly dirName: string;
|
|
28
|
+
}[];
|
|
11
29
|
readonly operations: readonly {
|
|
12
30
|
readonly id: string;
|
|
13
31
|
readonly label: string;
|
|
14
32
|
readonly operationClass: string;
|
|
15
33
|
}[];
|
|
16
|
-
|
|
34
|
+
/**
|
|
35
|
+
* Family-agnostic textual preview of the migration plan operations.
|
|
36
|
+
* Replaces the previous `sql?: readonly string[]` field; consumers should
|
|
37
|
+
* read `result.preview?.statements`.
|
|
38
|
+
*/
|
|
39
|
+
readonly preview?: OperationPreview;
|
|
17
40
|
readonly summary: string;
|
|
18
41
|
/**
|
|
19
42
|
* When true, `migration.ts` was written but contains unfilled
|
|
@@ -26,6 +49,7 @@ interface MigrationPlanResult {
|
|
|
26
49
|
};
|
|
27
50
|
}
|
|
28
51
|
declare function createMigrationPlanCommand(): Command;
|
|
52
|
+
declare function formatMigrationPlanOutput(result: MigrationPlanResult, flags: GlobalFlags): string;
|
|
29
53
|
type PrefixResolutionFailure = {
|
|
30
54
|
reason: 'ambiguous';
|
|
31
55
|
count: number;
|
|
@@ -33,20 +57,23 @@ type PrefixResolutionFailure = {
|
|
|
33
57
|
reason: 'not-found';
|
|
34
58
|
};
|
|
35
59
|
/**
|
|
36
|
-
* Resolve a migration
|
|
60
|
+
* Resolve a migration package by **target contract hash** (`metadata.to`)
|
|
61
|
+
* using exact match or prefix match.
|
|
37
62
|
*
|
|
63
|
+
* Note: matches `metadata.to` (the contract hash this migration produces),
|
|
64
|
+
* not `metadata.migrationHash` (the package's content-addressed identity).
|
|
38
65
|
* Tries exact match first, then prefix match (auto-prepending `sha256:` when
|
|
39
|
-
* the needle omits the scheme). Returns the matched
|
|
66
|
+
* the needle omits the scheme). Returns the matched package on success, or a
|
|
40
67
|
* discriminated failure indicating whether the prefix was ambiguous or simply
|
|
41
68
|
* not found.
|
|
42
69
|
*
|
|
43
70
|
* @internal Exported for testing only.
|
|
44
71
|
*/
|
|
45
72
|
declare function resolveBundleByPrefix<T extends {
|
|
46
|
-
|
|
73
|
+
metadata: {
|
|
47
74
|
to: string;
|
|
48
75
|
};
|
|
49
76
|
}>(bundles: readonly T[], needle: string): Result<T, PrefixResolutionFailure>;
|
|
50
77
|
//#endregion
|
|
51
|
-
export { MigrationPlanResult, PrefixResolutionFailure, createMigrationPlanCommand, resolveBundleByPrefix };
|
|
78
|
+
export { MigrationPlanResult, PrefixResolutionFailure, createMigrationPlanCommand, formatMigrationPlanOutput, resolveBundleByPrefix };
|
|
52
79
|
//# sourceMappingURL=migration-plan.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migration-plan.d.mts","names":[],"sources":["../../src/commands/migration-plan.ts"],"
|
|
1
|
+
{"version":3,"file":"migration-plan.d.mts","names":[],"sources":["../../src/commands/migration-plan.ts"],"mappings":";;;;;;UAoEiB,mBAAA;EAAA,SACN,EAAA;EAAA,SACA,IAAA;EAAA,SACA,IAAA;EAAA,SACA,EAAA;EAAA,SACA,GAAA;EAJA;;;;;;;;;;;;EAAA,SAiBA,oBAAA;IAAA,SAA0C,OAAA;IAAA,SAA0B,OAAA;EAAA;EAAA,SACpE,UAAA;IAAA,SACE,EAAA;IAAA,SACA,KAAA;IAAA,SACA,cAAA;EAAA;EA0X6B;;;;AA4D1C;EA5D0C,SAnX/B,OAAA,GAAU,gBAAA;EAAA,SACV,OAAA;EA8a8E;;;;;EAAA,SAxa9E,mBAAA;EAAA,SACA,OAAA;IAAA,SACE,KAAA;EAAA;AAAA;AAAA,iBA0WG,0BAAA,CAAA,GAA8B,OAAA;AAAA,iBA4D9B,yBAAA,CAA0B,MAAA,EAAQ,mBAAA,EAAqB,KAAA,EAAO,WAAA;AAAA,KA2HlE,uBAAA;EACN,MAAA;EAAqB,KAAA;AAAA;EACrB,MAAA;AAAA;;;;;;;;;;;;;;iBAeU,qBAAA;EAAkC,QAAA;IAAY,EAAA;EAAA;AAAA,EAAA,CAC5D,OAAA,WAAkB,CAAA,IAClB,MAAA,WACC,MAAA,CAAO,CAAA,EAAG,uBAAA"}
|
|
@@ -1,348 +1,2 @@
|
|
|
1
|
-
import { t as
|
|
2
|
-
|
|
3
|
-
import { t as assertFrameworkComponentsCompatible } from "../framework-components-Cr--XBKy.mjs";
|
|
4
|
-
import { t as extractSqlDdl } from "../extract-sql-ddl-D9UbZDyz.mjs";
|
|
5
|
-
import { t as TerminalUI } from "../terminal-ui-C3ZLwQxK.mjs";
|
|
6
|
-
import { _ as formatStyledHeader, c as resolveMigrationPaths, d as setCommandExamples, i as loadAllBundles, m as parseGlobalFlags, n as addGlobalOptions, r as getTargetMigrations, s as resolveContractPath, t as handleResult, u as setCommandDescriptions } from "../result-handler-Ba3zWQsI.mjs";
|
|
7
|
-
import { Command } from "commander";
|
|
8
|
-
import { getEmittedArtifactPaths } from "@prisma-next/emitter";
|
|
9
|
-
import { notOk, ok } from "@prisma-next/utils/result";
|
|
10
|
-
import { join, relative } from "pathe";
|
|
11
|
-
import { createControlStack } from "@prisma-next/framework-components/control";
|
|
12
|
-
import { EMPTY_CONTRACT_HASH } from "@prisma-next/migration-tools/constants";
|
|
13
|
-
import { readFile } from "node:fs/promises";
|
|
14
|
-
import { findLatestMigration } from "@prisma-next/migration-tools/dag";
|
|
15
|
-
import { copyFilesWithRename, formatMigrationDirName, writeMigrationPackage } from "@prisma-next/migration-tools/io";
|
|
16
|
-
import { computeMigrationId } from "@prisma-next/migration-tools/attestation";
|
|
17
|
-
import { MigrationToolsError } from "@prisma-next/migration-tools/types";
|
|
18
|
-
import { writeMigrationTs } from "@prisma-next/migration-tools/migration-ts";
|
|
19
|
-
|
|
20
|
-
//#region src/commands/migration-plan.ts
|
|
21
|
-
function mapMigrationToolsError(error) {
|
|
22
|
-
if (CliStructuredError.is(error)) return error;
|
|
23
|
-
if (MigrationToolsError.is(error)) return errorRuntime(error.message, {
|
|
24
|
-
why: error.why,
|
|
25
|
-
fix: error.fix,
|
|
26
|
-
meta: {
|
|
27
|
-
code: error.code,
|
|
28
|
-
...error.details ?? {}
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
return errorUnexpected(error instanceof Error ? error.message : String(error), { why: `Unexpected error during migration plan: ${error instanceof Error ? error.message : String(error)}` });
|
|
32
|
-
}
|
|
33
|
-
async function executeMigrationPlanCommand(options, flags, ui, startTime) {
|
|
34
|
-
const config = await loadConfig(options.config);
|
|
35
|
-
const { configPath, migrationsDir, migrationsRelative } = resolveMigrationPaths(options.config, config);
|
|
36
|
-
const contractPathAbsolute = resolveContractPath(config);
|
|
37
|
-
const contractPath = relative(process.cwd(), contractPathAbsolute);
|
|
38
|
-
if (!flags.json && !flags.quiet) {
|
|
39
|
-
const details = [
|
|
40
|
-
{
|
|
41
|
-
label: "config",
|
|
42
|
-
value: configPath
|
|
43
|
-
},
|
|
44
|
-
{
|
|
45
|
-
label: "contract",
|
|
46
|
-
value: contractPath
|
|
47
|
-
},
|
|
48
|
-
{
|
|
49
|
-
label: "migrations",
|
|
50
|
-
value: migrationsRelative
|
|
51
|
-
}
|
|
52
|
-
];
|
|
53
|
-
if (options.from) details.push({
|
|
54
|
-
label: "from",
|
|
55
|
-
value: options.from
|
|
56
|
-
});
|
|
57
|
-
if (options.name) details.push({
|
|
58
|
-
label: "name",
|
|
59
|
-
value: options.name
|
|
60
|
-
});
|
|
61
|
-
const header = formatStyledHeader({
|
|
62
|
-
command: "migration plan",
|
|
63
|
-
description: "Plan a migration from contract changes",
|
|
64
|
-
url: "https://pris.ly/migration-plan",
|
|
65
|
-
details,
|
|
66
|
-
flags
|
|
67
|
-
});
|
|
68
|
-
ui.stderr(header);
|
|
69
|
-
}
|
|
70
|
-
let contractJsonContent;
|
|
71
|
-
try {
|
|
72
|
-
contractJsonContent = await readFile(contractPathAbsolute, "utf-8");
|
|
73
|
-
} catch (error) {
|
|
74
|
-
if (error instanceof Error && error.code === "ENOENT") return notOk(errorFileNotFound(contractPathAbsolute, {
|
|
75
|
-
why: `Contract file not found at ${contractPathAbsolute}`,
|
|
76
|
-
fix: `Run \`prisma-next contract emit\` to generate ${contractPath}, or update \`config.contract.output\` in ${configPath}`
|
|
77
|
-
}));
|
|
78
|
-
return notOk(errorUnexpected(error instanceof Error ? error.message : String(error), { why: `Failed to read contract file: ${error instanceof Error ? error.message : String(error)}` }));
|
|
79
|
-
}
|
|
80
|
-
let toContractJson;
|
|
81
|
-
try {
|
|
82
|
-
toContractJson = JSON.parse(contractJsonContent);
|
|
83
|
-
} catch (error) {
|
|
84
|
-
return notOk(errorContractValidationFailed(`Contract JSON is invalid: ${error instanceof Error ? error.message : String(error)}`, { where: { path: contractPathAbsolute } }));
|
|
85
|
-
}
|
|
86
|
-
const rawStorageHash = toContractJson.storage?.storageHash;
|
|
87
|
-
if (typeof rawStorageHash !== "string") return notOk(errorContractValidationFailed("Contract is missing storageHash", { where: { path: contractPathAbsolute } }));
|
|
88
|
-
const toStorageHash = rawStorageHash;
|
|
89
|
-
let fromContract = null;
|
|
90
|
-
let fromHash = EMPTY_CONTRACT_HASH;
|
|
91
|
-
let fromContractSourceDir = null;
|
|
92
|
-
try {
|
|
93
|
-
const { bundles, graph } = await loadAllBundles(migrationsDir);
|
|
94
|
-
if (options.from) {
|
|
95
|
-
const resolved = resolveBundleByPrefix(bundles, options.from);
|
|
96
|
-
if (!resolved.ok) {
|
|
97
|
-
const f = resolved.failure;
|
|
98
|
-
return notOk(f.reason === "ambiguous" ? errorRuntime("Multiple matching migrations found", {
|
|
99
|
-
why: `Prefix "${options.from}" matches ${f.count} migrations in ${migrationsRelative}`,
|
|
100
|
-
fix: "Provide a longer prefix to disambiguate, or omit --from to use the latest migration target."
|
|
101
|
-
}) : errorRuntime("Starting contract not found", {
|
|
102
|
-
why: `No migration with to hash matching "${options.from}" exists in ${migrationsRelative}`,
|
|
103
|
-
fix: "Check that the --from hash matches a known migration target hash, or omit --from to use the latest migration target."
|
|
104
|
-
}));
|
|
105
|
-
}
|
|
106
|
-
fromHash = resolved.value.manifest.to;
|
|
107
|
-
fromContract = resolved.value.manifest.toContract;
|
|
108
|
-
fromContractSourceDir = resolved.value.dirPath;
|
|
109
|
-
} else {
|
|
110
|
-
const latestMigration = findLatestMigration(graph);
|
|
111
|
-
if (latestMigration) {
|
|
112
|
-
fromHash = latestMigration.to;
|
|
113
|
-
const leafPkg = bundles.find((p) => p.manifest.migrationId === latestMigration.migrationId);
|
|
114
|
-
if (leafPkg) {
|
|
115
|
-
fromContract = leafPkg.manifest.toContract;
|
|
116
|
-
fromContractSourceDir = leafPkg.dirPath;
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
} catch (error) {
|
|
121
|
-
if (MigrationToolsError.is(error)) return notOk(mapMigrationToolsError(error));
|
|
122
|
-
throw error;
|
|
123
|
-
}
|
|
124
|
-
if (fromHash === toStorageHash) return ok({
|
|
125
|
-
ok: true,
|
|
126
|
-
noOp: true,
|
|
127
|
-
from: fromHash,
|
|
128
|
-
to: toStorageHash,
|
|
129
|
-
operations: [],
|
|
130
|
-
summary: "No changes detected between contracts",
|
|
131
|
-
timings: { total: Date.now() - startTime }
|
|
132
|
-
});
|
|
133
|
-
const migrations = getTargetMigrations(config.target);
|
|
134
|
-
if (!migrations) return notOk(errorTargetMigrationNotSupported({ why: `Target "${config.target.id}" does not support migrations` }));
|
|
135
|
-
const frameworkComponents = assertFrameworkComponentsCompatible(config.family.familyId, config.target.targetId, [
|
|
136
|
-
config.target,
|
|
137
|
-
config.adapter,
|
|
138
|
-
...config.extensionPacks ?? []
|
|
139
|
-
]);
|
|
140
|
-
const timestamp = /* @__PURE__ */ new Date();
|
|
141
|
-
const packageDir = join(migrationsDir, formatMigrationDirName(timestamp, options.name ?? "migration"));
|
|
142
|
-
const baseManifest = {
|
|
143
|
-
from: fromHash,
|
|
144
|
-
to: toStorageHash,
|
|
145
|
-
kind: "regular",
|
|
146
|
-
fromContract,
|
|
147
|
-
toContract: toContractJson,
|
|
148
|
-
hints: {
|
|
149
|
-
used: [],
|
|
150
|
-
applied: [],
|
|
151
|
-
plannerVersion: "2.0.0"
|
|
152
|
-
},
|
|
153
|
-
labels: [],
|
|
154
|
-
createdAt: timestamp.toISOString()
|
|
155
|
-
};
|
|
156
|
-
try {
|
|
157
|
-
const stack = createControlStack(config);
|
|
158
|
-
const familyInstance = config.family.create(stack);
|
|
159
|
-
const planner = migrations.createPlanner(familyInstance);
|
|
160
|
-
const fromSchema = migrations.contractToSchema(fromContract, frameworkComponents);
|
|
161
|
-
const plannerResult = planner.plan({
|
|
162
|
-
contract: toContractJson,
|
|
163
|
-
schema: fromSchema,
|
|
164
|
-
policy: { allowedOperationClasses: [
|
|
165
|
-
"additive",
|
|
166
|
-
"widening",
|
|
167
|
-
"destructive",
|
|
168
|
-
"data"
|
|
169
|
-
] },
|
|
170
|
-
fromHash,
|
|
171
|
-
fromContract,
|
|
172
|
-
frameworkComponents
|
|
173
|
-
});
|
|
174
|
-
if (plannerResult.kind === "failure") return notOk(errorMigrationPlanningFailed({ conflicts: plannerResult.conflicts }));
|
|
175
|
-
let plannedOps = [];
|
|
176
|
-
let hasPlaceholders = false;
|
|
177
|
-
try {
|
|
178
|
-
plannedOps = plannerResult.plan.operations;
|
|
179
|
-
if (plannedOps.length === 0) return notOk(errorMigrationPlanningFailed({ conflicts: [{
|
|
180
|
-
kind: "unsupportedChange",
|
|
181
|
-
summary: "Contract changed but planner produced no operations. This indicates unsupported or ignored changes."
|
|
182
|
-
}] }));
|
|
183
|
-
} catch (e) {
|
|
184
|
-
if (CliStructuredError.is(e) && e.domain === "MIG" && e.code === "2001") hasPlaceholders = true;
|
|
185
|
-
else throw e;
|
|
186
|
-
}
|
|
187
|
-
const migrationTsContent = plannerResult.plan.renderTypeScript();
|
|
188
|
-
const opsForWrite = hasPlaceholders ? [] : plannedOps;
|
|
189
|
-
await writeMigrationPackage(packageDir, {
|
|
190
|
-
...baseManifest,
|
|
191
|
-
migrationId: computeMigrationId(baseManifest, opsForWrite)
|
|
192
|
-
}, opsForWrite);
|
|
193
|
-
const destinationArtifacts = getEmittedArtifactPaths(contractPathAbsolute);
|
|
194
|
-
await copyFilesWithRename(packageDir, [{
|
|
195
|
-
sourcePath: destinationArtifacts.jsonPath,
|
|
196
|
-
destName: "end-contract.json"
|
|
197
|
-
}, {
|
|
198
|
-
sourcePath: destinationArtifacts.dtsPath,
|
|
199
|
-
destName: "end-contract.d.ts"
|
|
200
|
-
}]);
|
|
201
|
-
if (fromContractSourceDir !== null) {
|
|
202
|
-
const sourceArtifacts = getEmittedArtifactPaths(join(fromContractSourceDir, "end-contract.json"));
|
|
203
|
-
await copyFilesWithRename(packageDir, [{
|
|
204
|
-
sourcePath: sourceArtifacts.jsonPath,
|
|
205
|
-
destName: "start-contract.json"
|
|
206
|
-
}, {
|
|
207
|
-
sourcePath: sourceArtifacts.dtsPath,
|
|
208
|
-
destName: "start-contract.d.ts"
|
|
209
|
-
}]);
|
|
210
|
-
}
|
|
211
|
-
await writeMigrationTs(packageDir, migrationTsContent);
|
|
212
|
-
if (hasPlaceholders) return ok({
|
|
213
|
-
ok: true,
|
|
214
|
-
noOp: false,
|
|
215
|
-
from: fromHash,
|
|
216
|
-
to: toStorageHash,
|
|
217
|
-
dir: relative(process.cwd(), packageDir),
|
|
218
|
-
operations: [],
|
|
219
|
-
pendingPlaceholders: true,
|
|
220
|
-
summary: "Planned migration with placeholder(s) — edit migration.ts then run `node migration.ts` to self-emit",
|
|
221
|
-
timings: { total: Date.now() - startTime }
|
|
222
|
-
});
|
|
223
|
-
const sql = extractSqlDdl(plannedOps);
|
|
224
|
-
return ok({
|
|
225
|
-
ok: true,
|
|
226
|
-
noOp: false,
|
|
227
|
-
from: fromHash,
|
|
228
|
-
to: toStorageHash,
|
|
229
|
-
dir: relative(process.cwd(), packageDir),
|
|
230
|
-
operations: plannedOps.map((op) => ({
|
|
231
|
-
id: op.id,
|
|
232
|
-
label: op.label,
|
|
233
|
-
operationClass: op.operationClass
|
|
234
|
-
})),
|
|
235
|
-
sql,
|
|
236
|
-
summary: `Planned ${plannedOps.length} operation(s)`,
|
|
237
|
-
timings: { total: Date.now() - startTime }
|
|
238
|
-
});
|
|
239
|
-
} catch (error) {
|
|
240
|
-
return notOk(mapMigrationToolsError(error));
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
function createMigrationPlanCommand() {
|
|
244
|
-
const command = new Command("plan");
|
|
245
|
-
setCommandDescriptions(command, "Plan a migration from contract changes", "Compares the emitted contract against the latest on-disk migration state and\nproduces a new migration package with the required operations. No database\nconnection is needed — this is a fully offline operation.");
|
|
246
|
-
setCommandExamples(command, ["prisma-next migration plan", "prisma-next migration plan --name add-users-table"]);
|
|
247
|
-
addGlobalOptions(command).option("--config <path>", "Path to prisma-next.config.ts").option("--name <slug>", "Name slug for the migration directory", "migration").option("--from <hash>", "Explicit starting contract hash (overrides latest migration target)").action(async (options) => {
|
|
248
|
-
const flags = parseGlobalFlags(options);
|
|
249
|
-
const startTime = Date.now();
|
|
250
|
-
const ui = new TerminalUI({
|
|
251
|
-
color: flags.color,
|
|
252
|
-
interactive: flags.interactive
|
|
253
|
-
});
|
|
254
|
-
const exitCode = handleResult(await executeMigrationPlanCommand(options, flags, ui, startTime), flags, ui, (planResult) => {
|
|
255
|
-
if (flags.json) ui.output(JSON.stringify(planResult, null, 2));
|
|
256
|
-
else if (!flags.quiet) ui.log(formatMigrationPlanOutput(planResult, flags));
|
|
257
|
-
});
|
|
258
|
-
process.exit(exitCode);
|
|
259
|
-
});
|
|
260
|
-
return command;
|
|
261
|
-
}
|
|
262
|
-
function formatMigrationPlanOutput(result, flags) {
|
|
263
|
-
const lines = [];
|
|
264
|
-
const useColor = flags.color !== false;
|
|
265
|
-
const green_ = useColor ? (s) => `\x1b[32m${s}\x1b[0m` : (s) => s;
|
|
266
|
-
const yellow_ = useColor ? (s) => `\x1b[33m${s}\x1b[0m` : (s) => s;
|
|
267
|
-
const dim_ = useColor ? (s) => `\x1b[2m${s}\x1b[0m` : (s) => s;
|
|
268
|
-
if (result.noOp) {
|
|
269
|
-
lines.push(`${green_("✔")} No changes detected`);
|
|
270
|
-
lines.push(dim_(` from: ${result.from}`));
|
|
271
|
-
lines.push(dim_(` to: ${result.to}`));
|
|
272
|
-
return lines.join("\n");
|
|
273
|
-
}
|
|
274
|
-
if (result.pendingPlaceholders) {
|
|
275
|
-
lines.push(`${yellow_("⚠")} ${result.summary}`);
|
|
276
|
-
lines.push("");
|
|
277
|
-
lines.push(dim_(`from: ${result.from}`));
|
|
278
|
-
lines.push(dim_(`to: ${result.to}`));
|
|
279
|
-
if (result.dir) lines.push(dim_(`dir: ${result.dir}`));
|
|
280
|
-
lines.push("");
|
|
281
|
-
lines.push("Open migration.ts and replace each `placeholder(...)` call with your actual query.");
|
|
282
|
-
lines.push(`Then run: ${green_(`node ${result.dir ?? "<dir>"}/migration.ts`)}`);
|
|
283
|
-
return lines.join("\n");
|
|
284
|
-
}
|
|
285
|
-
lines.push(`${green_("✔")} ${result.summary}`);
|
|
286
|
-
lines.push("");
|
|
287
|
-
if (result.operations.length > 0) {
|
|
288
|
-
lines.push(dim_("│"));
|
|
289
|
-
for (let i = 0; i < result.operations.length; i++) {
|
|
290
|
-
const op = result.operations[i];
|
|
291
|
-
const treeChar = i === result.operations.length - 1 ? "└" : "├";
|
|
292
|
-
const opClassLabel = op.operationClass === "destructive" ? yellow_(`[${op.operationClass}]`) : dim_(`[${op.operationClass}]`);
|
|
293
|
-
lines.push(`${dim_(treeChar)}─ ${op.label} ${opClassLabel}`);
|
|
294
|
-
}
|
|
295
|
-
if (result.operations.some((op) => op.operationClass === "destructive")) {
|
|
296
|
-
lines.push("");
|
|
297
|
-
lines.push(`${yellow_("⚠")} This migration contains destructive operations that may cause data loss.`);
|
|
298
|
-
}
|
|
299
|
-
lines.push("");
|
|
300
|
-
}
|
|
301
|
-
lines.push(dim_(`from: ${result.from}`));
|
|
302
|
-
lines.push(dim_(`to: ${result.to}`));
|
|
303
|
-
if (result.dir) lines.push(dim_(`dir: ${result.dir}`));
|
|
304
|
-
lines.push("");
|
|
305
|
-
lines.push(`Next: ${green_(`node ${result.dir ?? "<dir>"}/migration.ts`)} to emit ops.json and attest migrationId before running ${green_("prisma-next migration apply")}.`);
|
|
306
|
-
if (result.sql && result.sql.length > 0) {
|
|
307
|
-
lines.push("");
|
|
308
|
-
lines.push(dim_("DDL preview"));
|
|
309
|
-
lines.push("");
|
|
310
|
-
for (const statement of result.sql) {
|
|
311
|
-
const trimmed = statement.trim();
|
|
312
|
-
if (!trimmed) continue;
|
|
313
|
-
const line = trimmed.endsWith(";") ? trimmed : `${trimmed};`;
|
|
314
|
-
lines.push(line);
|
|
315
|
-
}
|
|
316
|
-
}
|
|
317
|
-
if (flags.verbose && result.timings) {
|
|
318
|
-
lines.push("");
|
|
319
|
-
lines.push(dim_(`Total time: ${result.timings.total}ms`));
|
|
320
|
-
}
|
|
321
|
-
return lines.join("\n");
|
|
322
|
-
}
|
|
323
|
-
/**
|
|
324
|
-
* Resolve a migration bundle by exact hash or prefix match.
|
|
325
|
-
*
|
|
326
|
-
* Tries exact match first, then prefix match (auto-prepending `sha256:` when
|
|
327
|
-
* the needle omits the scheme). Returns the matched bundle on success, or a
|
|
328
|
-
* discriminated failure indicating whether the prefix was ambiguous or simply
|
|
329
|
-
* not found.
|
|
330
|
-
*
|
|
331
|
-
* @internal Exported for testing only.
|
|
332
|
-
*/
|
|
333
|
-
function resolveBundleByPrefix(bundles, needle) {
|
|
334
|
-
const exact = bundles.find((p) => p.manifest.to === needle);
|
|
335
|
-
if (exact) return ok(exact);
|
|
336
|
-
const prefixWithScheme = needle.startsWith("sha256:") ? needle : `sha256:${needle}`;
|
|
337
|
-
const candidates = bundles.filter((p) => p.manifest.to.startsWith(prefixWithScheme));
|
|
338
|
-
if (candidates.length === 1) return ok(candidates[0]);
|
|
339
|
-
if (candidates.length > 1) return notOk({
|
|
340
|
-
reason: "ambiguous",
|
|
341
|
-
count: candidates.length
|
|
342
|
-
});
|
|
343
|
-
return notOk({ reason: "not-found" });
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
//#endregion
|
|
347
|
-
export { createMigrationPlanCommand, resolveBundleByPrefix };
|
|
348
|
-
//# sourceMappingURL=migration-plan.mjs.map
|
|
1
|
+
import { n as formatMigrationPlanOutput, r as resolveBundleByPrefix, t as createMigrationPlanCommand } from "../migration-plan-C6lVaHsO.mjs";
|
|
2
|
+
export { createMigrationPlanCommand, formatMigrationPlanOutput, resolveBundleByPrefix };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as CliStructuredError } from "../cli-errors-
|
|
1
|
+
import { t as CliStructuredError } from "../cli-errors-B9OBbled.mjs";
|
|
2
2
|
import { Command } from "commander";
|
|
3
3
|
import { Result } from "@prisma-next/utils/result";
|
|
4
4
|
import { RefEntry } from "@prisma-next/migration-tools/refs";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migration-ref.d.mts","names":[],"sources":["../../src/commands/migration-ref.ts"],"
|
|
1
|
+
{"version":3,"file":"migration-ref.d.mts","names":[],"sources":["../../src/commands/migration-ref.ts"],"mappings":";;;;;;UA6BU,YAAA;EAAA,SACC,EAAA;EAAA,SACA,GAAA;EAAA,SACA,IAAA;EAAA,SACA,UAAA;AAAA;AAAA,UAGD,YAAA;EAAA,SACC,EAAA;EAAA,SACA,GAAA;EAAA,SACA,IAAA;EAAA,SACA,UAAA;AAAA;AAAA,UAGD,eAAA;EAAA,SACC,EAAA;EAAA,SACA,GAAA;EAAA,SACA,OAAA;AAAA;AAAA,UAGD,aAAA;EAAA,SACC,EAAA;EAAA,SACA,IAAA,EAAM,MAAA,SAAe,QAAA;AAAA;AAAA,iBAUvB,sBAAA,CAAuB,IAAA,WAAe,kBAAA;AAAA,iBAOtC,uBAAA,CAAwB,IAAA,WAAe,kBAAA;AAAA,iBAOjC,oBAAA,CACb,IAAA,UACA,IAAA,UACA,OAAA;EAAW,MAAA;AAAA,IACV,OAAA,CAAQ,MAAA,CAAO,YAAA,EAAc,kBAAA;AAAA,iBAoBjB,oBAAA,CACb,IAAA,UACA,OAAA;EAAW,MAAA;AAAA,IACV,OAAA,CAAQ,MAAA,CAAO,YAAA,EAAc,kBAAA;AAAA,iBAYjB,uBAAA,CACb,IAAA,UACA,OAAA;EAAW,MAAA;AAAA,IACV,OAAA,CAAQ,MAAA,CAAO,eAAA,EAAiB,kBAAA;AAAA,iBAYpB,qBAAA,CAAsB,OAAA;EACnC,MAAA;AAAA,IACE,OAAA,CAAQ,MAAA,CAAO,aAAA,EAAe,kBAAA;AAAA,iBA8IlB,yBAAA,CAAA,GAA6B,OAAA"}
|
|
@@ -1,19 +1,15 @@
|
|
|
1
|
-
import { t as loadConfig } from "../config-loader-
|
|
2
|
-
import { _ as errorUnexpected, m as errorRuntime, t as CliStructuredError } from "../cli-errors-
|
|
3
|
-
import { t as
|
|
4
|
-
import {
|
|
1
|
+
import { t as loadConfig } from "../config-loader-B6sJjXTv.mjs";
|
|
2
|
+
import { _ as errorUnexpected, m as errorRuntime, t as CliStructuredError, v as mapMigrationToolsError } from "../cli-errors-D3_sMh2K.mjs";
|
|
3
|
+
import { _ as formatCommandHelp, d as setCommandDescriptions, g as parseGlobalFlags, l as resolveMigrationPaths, t as addGlobalOptions } from "../command-helpers-BeZHkxV8.mjs";
|
|
4
|
+
import { t as TerminalUI } from "../terminal-ui-C_hFNbAn.mjs";
|
|
5
|
+
import { t as handleResult } from "../result-handler-rmPVKIP2.mjs";
|
|
5
6
|
import { Command } from "commander";
|
|
6
7
|
import { notOk, ok } from "@prisma-next/utils/result";
|
|
8
|
+
import { MigrationToolsError } from "@prisma-next/migration-tools/errors";
|
|
7
9
|
import { deleteRef, readRef, readRefs, validateRefName, validateRefValue, writeRef } from "@prisma-next/migration-tools/refs";
|
|
8
|
-
import { MigrationToolsError } from "@prisma-next/migration-tools/types";
|
|
9
|
-
|
|
10
10
|
//#region src/commands/migration-ref.ts
|
|
11
11
|
function mapError(error) {
|
|
12
|
-
if (MigrationToolsError.is(error)) return
|
|
13
|
-
why: error.why,
|
|
14
|
-
fix: error.fix,
|
|
15
|
-
meta: { code: error.code }
|
|
16
|
-
});
|
|
12
|
+
if (MigrationToolsError.is(error)) return mapMigrationToolsError(error);
|
|
17
13
|
return errorUnexpected(error instanceof Error ? error.message : String(error));
|
|
18
14
|
}
|
|
19
15
|
function cliErrorInvalidRefName(name) {
|
|
@@ -184,7 +180,7 @@ function createMigrationRefCommand() {
|
|
|
184
180
|
command.addCommand(createRefListCommand());
|
|
185
181
|
return command;
|
|
186
182
|
}
|
|
187
|
-
|
|
188
183
|
//#endregion
|
|
189
184
|
export { cliErrorInvalidRefName, cliErrorInvalidRefValue, createMigrationRefCommand, executeRefDeleteCommand, executeRefGetCommand, executeRefListCommand, executeRefSetCommand };
|
|
185
|
+
|
|
190
186
|
//# sourceMappingURL=migration-ref.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migration-ref.mjs","names":[],"sources":["../../src/commands/migration-ref.ts"],"sourcesContent":["import type { RefEntry } from '@prisma-next/migration-tools/refs';\nimport {\n deleteRef,\n readRef,\n readRefs,\n validateRefName,\n validateRefValue,\n writeRef,\n} from '@prisma-next/migration-tools/refs';\nimport { MigrationToolsError } from '@prisma-next/migration-tools/types';\nimport { notOk, ok, type Result } from '@prisma-next/utils/result';\nimport { Command } from 'commander';\nimport { loadConfig } from '../config-loader';\nimport { CliStructuredError, errorRuntime, errorUnexpected } from '../utils/cli-errors';\nimport {\n addGlobalOptions,\n resolveMigrationPaths,\n setCommandDescriptions,\n} from '../utils/command-helpers';\nimport { formatCommandHelp } from '../utils/formatters/help';\nimport { parseGlobalFlags } from '../utils/global-flags';\nimport { handleResult } from '../utils/result-handler';\nimport { TerminalUI } from '../utils/terminal-ui';\n\ninterface RefSetResult {\n readonly ok: true;\n readonly ref: string;\n readonly hash: string;\n readonly invariants: readonly string[];\n}\n\ninterface RefGetResult {\n readonly ok: true;\n readonly ref: string;\n readonly hash: string;\n readonly invariants: readonly string[];\n}\n\ninterface RefDeleteResult {\n readonly ok: true;\n readonly ref: string;\n readonly deleted: true;\n}\n\ninterface RefListResult {\n readonly ok: true;\n readonly refs: Record<string, RefEntry>;\n}\n\nfunction mapError(error: unknown): CliStructuredError {\n if (MigrationToolsError.is(error)) {\n return errorRuntime(error.message, {\n why: error.why,\n fix: error.fix,\n meta: { code: error.code },\n });\n }\n return errorUnexpected(error instanceof Error ? error.message : String(error));\n}\n\nfunction cliErrorInvalidRefName(name: string): CliStructuredError {\n return errorRuntime(`Invalid ref name \"${name}\"`, {\n why: `Ref name \"${name}\" does not match the required format`,\n fix: 'Ref names must be lowercase alphanumeric with hyphens or forward slashes, no `.` or `..` segments',\n });\n}\n\nfunction cliErrorInvalidRefValue(hash: string): CliStructuredError {\n return errorRuntime(`Invalid contract hash \"${hash}\"`, {\n why: `\"${hash}\" is not a valid contract hash`,\n fix: 'Contract hashes must match the format \"sha256:<64 hex chars>\". Copy the hash from `prisma-next contract emit` or `migration status --json`.',\n });\n}\n\nasync function executeRefSetCommand(\n name: string,\n hash: string,\n options: { config?: string },\n): Promise<Result<RefSetResult, CliStructuredError>> {\n if (!validateRefName(name)) {\n return notOk(cliErrorInvalidRefName(name));\n }\n if (!validateRefValue(hash)) {\n return notOk(cliErrorInvalidRefValue(hash));\n }\n\n try {\n const config = await loadConfig(options.config);\n const { refsDir } = resolveMigrationPaths(options.config, config);\n const entry: RefEntry = { hash, invariants: [] };\n await writeRef(refsDir, name, entry);\n return ok({ ok: true as const, ref: name, hash, invariants: [] });\n } catch (error) {\n if (error instanceof CliStructuredError) return notOk(error);\n return notOk(mapError(error));\n }\n}\n\nasync function executeRefGetCommand(\n name: string,\n options: { config?: string },\n): Promise<Result<RefGetResult, CliStructuredError>> {\n try {\n const config = await loadConfig(options.config);\n const { refsDir } = resolveMigrationPaths(options.config, config);\n const entry = await readRef(refsDir, name);\n return ok({ ok: true as const, ref: name, hash: entry.hash, invariants: entry.invariants });\n } catch (error) {\n if (error instanceof CliStructuredError) return notOk(error);\n return notOk(mapError(error));\n }\n}\n\nasync function executeRefDeleteCommand(\n name: string,\n options: { config?: string },\n): Promise<Result<RefDeleteResult, CliStructuredError>> {\n try {\n const config = await loadConfig(options.config);\n const { refsDir } = resolveMigrationPaths(options.config, config);\n await deleteRef(refsDir, name);\n return ok({ ok: true as const, ref: name, deleted: true as const });\n } catch (error) {\n if (error instanceof CliStructuredError) return notOk(error);\n return notOk(mapError(error));\n }\n}\n\nasync function executeRefListCommand(options: {\n config?: string;\n}): Promise<Result<RefListResult, CliStructuredError>> {\n try {\n const config = await loadConfig(options.config);\n const { refsDir } = resolveMigrationPaths(options.config, config);\n const refs = await readRefs(refsDir);\n return ok({ ok: true as const, refs });\n } catch (error) {\n if (error instanceof CliStructuredError) return notOk(error);\n return notOk(mapError(error));\n }\n}\n\nfunction createRefSetCommand(): Command {\n const command = new Command('set');\n setCommandDescriptions(\n command,\n 'Set a ref to a contract hash',\n 'Sets a named ref to point to a contract hash in migrations/refs/.',\n );\n addGlobalOptions(command)\n .argument('<name>', 'Ref name (e.g., staging, production)')\n .argument('<hash>', 'Contract hash to point to')\n .option('--config <path>', 'Path to prisma-next.config.ts')\n .action(\n async (\n name: string,\n hash: string,\n options: { config?: string; json?: string | boolean; quiet?: boolean },\n ) => {\n const flags = parseGlobalFlags(options);\n const ui = new TerminalUI({ color: flags.color, interactive: flags.interactive });\n const result = await executeRefSetCommand(name, hash, options);\n const exitCode = handleResult(result, flags, ui, (value) => {\n if (flags.json) {\n ui.output(JSON.stringify(value));\n } else if (!flags.quiet) {\n ui.output(`Set ref \"${value.ref}\" → ${value.hash}`);\n }\n });\n process.exit(exitCode);\n },\n );\n return command;\n}\n\nfunction createRefGetCommand(): Command {\n const command = new Command('get');\n setCommandDescriptions(\n command,\n 'Get the hash for a ref',\n 'Reads a named ref from migrations/refs/ and prints its contract hash.',\n );\n addGlobalOptions(command)\n .argument('<name>', 'Ref name to look up')\n .option('--config <path>', 'Path to prisma-next.config.ts')\n .action(\n async (\n name: string,\n options: { config?: string; json?: string | boolean; quiet?: boolean },\n ) => {\n const flags = parseGlobalFlags(options);\n const ui = new TerminalUI({ color: flags.color, interactive: flags.interactive });\n const result = await executeRefGetCommand(name, options);\n const exitCode = handleResult(result, flags, ui, (value) => {\n if (flags.json) {\n ui.output(JSON.stringify(value));\n } else {\n ui.output(value.hash);\n }\n });\n process.exit(exitCode);\n },\n );\n return command;\n}\n\nfunction createRefDeleteCommand(): Command {\n const command = new Command('delete');\n setCommandDescriptions(command, 'Delete a ref', 'Removes a named ref from migrations/refs/.');\n addGlobalOptions(command)\n .argument('<name>', 'Ref name to delete')\n .option('--config <path>', 'Path to prisma-next.config.ts')\n .action(\n async (\n name: string,\n options: { config?: string; json?: string | boolean; quiet?: boolean },\n ) => {\n const flags = parseGlobalFlags(options);\n const ui = new TerminalUI({ color: flags.color, interactive: flags.interactive });\n const result = await executeRefDeleteCommand(name, options);\n const exitCode = handleResult(result, flags, ui, (value) => {\n if (flags.json) {\n ui.output(JSON.stringify(value));\n } else if (!flags.quiet) {\n ui.output(`Deleted ref \"${value.ref}\"`);\n }\n });\n process.exit(exitCode);\n },\n );\n return command;\n}\n\nfunction createRefListCommand(): Command {\n const command = new Command('list');\n setCommandDescriptions(command, 'List all refs', 'Lists all named refs from migrations/refs/.');\n addGlobalOptions(command)\n .option('--config <path>', 'Path to prisma-next.config.ts')\n .action(async (options: { config?: string; json?: string | boolean; quiet?: boolean }) => {\n const flags = parseGlobalFlags(options);\n const ui = new TerminalUI({ color: flags.color, interactive: flags.interactive });\n const result = await executeRefListCommand(options);\n const exitCode = handleResult(result, flags, ui, (value) => {\n if (flags.json) {\n ui.output(JSON.stringify(value));\n } else if (!flags.quiet) {\n const entries = Object.entries(value.refs);\n if (entries.length === 0) {\n ui.output('No refs defined');\n } else {\n for (const [refName, entry] of entries) {\n const invariantsSuffix =\n entry.invariants.length > 0 ? ` [invariants: ${entry.invariants.join(', ')}]` : '';\n ui.output(`${refName} → ${entry.hash}${invariantsSuffix}`);\n }\n }\n }\n });\n process.exit(exitCode);\n });\n return command;\n}\n\nexport {\n executeRefSetCommand,\n executeRefGetCommand,\n executeRefDeleteCommand,\n executeRefListCommand,\n cliErrorInvalidRefName,\n cliErrorInvalidRefValue,\n};\n\nexport function createMigrationRefCommand(): Command {\n const command = new Command('ref');\n setCommandDescriptions(\n command,\n 'Manage migration refs',\n 'Manage named refs in migrations/refs/. Refs map logical environment\\n' +\n 'names (e.g., staging, production) to contract hashes.',\n );\n addGlobalOptions(command).configureHelp({\n formatHelp: (cmd) => formatCommandHelp({ command: cmd, flags: parseGlobalFlags({}) }),\n subcommandDescription: () => '',\n });\n command.addCommand(createRefSetCommand());\n command.addCommand(createRefGetCommand());\n command.addCommand(createRefDeleteCommand());\n command.addCommand(createRefListCommand());\n return command;\n}\n"],"mappings":";;;;;;;;;;AAiDA,SAAS,SAAS,OAAoC;AACpD,KAAI,oBAAoB,GAAG,MAAM,CAC/B,QAAO,aAAa,MAAM,SAAS;EACjC,KAAK,MAAM;EACX,KAAK,MAAM;EACX,MAAM,EAAE,MAAM,MAAM,MAAM;EAC3B,CAAC;AAEJ,QAAO,gBAAgB,iBAAiB,QAAQ,MAAM,UAAU,OAAO,MAAM,CAAC;;AAGhF,SAAS,uBAAuB,MAAkC;AAChE,QAAO,aAAa,qBAAqB,KAAK,IAAI;EAChD,KAAK,aAAa,KAAK;EACvB,KAAK;EACN,CAAC;;AAGJ,SAAS,wBAAwB,MAAkC;AACjE,QAAO,aAAa,0BAA0B,KAAK,IAAI;EACrD,KAAK,IAAI,KAAK;EACd,KAAK;EACN,CAAC;;AAGJ,eAAe,qBACb,MACA,MACA,SACmD;AACnD,KAAI,CAAC,gBAAgB,KAAK,CACxB,QAAO,MAAM,uBAAuB,KAAK,CAAC;AAE5C,KAAI,CAAC,iBAAiB,KAAK,CACzB,QAAO,MAAM,wBAAwB,KAAK,CAAC;AAG7C,KAAI;EACF,MAAM,SAAS,MAAM,WAAW,QAAQ,OAAO;EAC/C,MAAM,EAAE,YAAY,sBAAsB,QAAQ,QAAQ,OAAO;AAEjE,QAAM,SAAS,SAAS,MADA;GAAE;GAAM,YAAY,EA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,UAAU,IAAI,QAAQ,MAAM;AAClC,wBACE,SACA,yBACA,6HAED;AACD,kBAAiB,QAAQ,CAAC,cAAc;EACtC,aAAa,QAAQ,kBAAkB;GAAE,SAAS;GAAK,OAAO,iBAAiB,EAAE,CAAC;GAAE,CAAC;EACrF,6BAA6B;EAC9B,CAAC;AACF,SAAQ,WAAW,qBAAqB,CAAC;AACzC,SAAQ,WAAW,qBAAqB,CAAC;AACzC,SAAQ,WAAW,wBAAwB,CAAC;AAC5C,SAAQ,WAAW,sBAAsB,CAAC;AAC1C,QAAO"}
|
|
1
|
+
{"version":3,"file":"migration-ref.mjs","names":[],"sources":["../../src/commands/migration-ref.ts"],"sourcesContent":["import { MigrationToolsError } from '@prisma-next/migration-tools/errors';\nimport type { RefEntry } from '@prisma-next/migration-tools/refs';\nimport {\n deleteRef,\n readRef,\n readRefs,\n validateRefName,\n validateRefValue,\n writeRef,\n} from '@prisma-next/migration-tools/refs';\nimport { notOk, ok, type Result } from '@prisma-next/utils/result';\nimport { Command } from 'commander';\nimport { loadConfig } from '../config-loader';\nimport {\n CliStructuredError,\n errorRuntime,\n errorUnexpected,\n mapMigrationToolsError,\n} from '../utils/cli-errors';\nimport {\n addGlobalOptions,\n resolveMigrationPaths,\n setCommandDescriptions,\n} from '../utils/command-helpers';\nimport { formatCommandHelp } from '../utils/formatters/help';\nimport { parseGlobalFlags } from '../utils/global-flags';\nimport { handleResult } from '../utils/result-handler';\nimport { TerminalUI } from '../utils/terminal-ui';\n\ninterface RefSetResult {\n readonly ok: true;\n readonly ref: string;\n readonly hash: string;\n readonly invariants: readonly string[];\n}\n\ninterface RefGetResult {\n readonly ok: true;\n readonly ref: string;\n readonly hash: string;\n readonly invariants: readonly string[];\n}\n\ninterface RefDeleteResult {\n readonly ok: true;\n readonly ref: string;\n readonly deleted: true;\n}\n\ninterface RefListResult {\n readonly ok: true;\n readonly refs: Record<string, RefEntry>;\n}\n\nfunction mapError(error: unknown): CliStructuredError {\n if (MigrationToolsError.is(error)) {\n return mapMigrationToolsError(error);\n }\n return errorUnexpected(error instanceof Error ? error.message : String(error));\n}\n\nfunction cliErrorInvalidRefName(name: string): CliStructuredError {\n return errorRuntime(`Invalid ref name \"${name}\"`, {\n why: `Ref name \"${name}\" does not match the required format`,\n fix: 'Ref names must be lowercase alphanumeric with hyphens or forward slashes, no `.` or `..` segments',\n });\n}\n\nfunction cliErrorInvalidRefValue(hash: string): CliStructuredError {\n return errorRuntime(`Invalid contract hash \"${hash}\"`, {\n why: `\"${hash}\" is not a valid contract hash`,\n fix: 'Contract hashes must match the format \"sha256:<64 hex chars>\". Copy the hash from `prisma-next contract emit` or `migration status --json`.',\n });\n}\n\nasync function executeRefSetCommand(\n name: string,\n hash: string,\n options: { config?: string },\n): Promise<Result<RefSetResult, CliStructuredError>> {\n if (!validateRefName(name)) {\n return notOk(cliErrorInvalidRefName(name));\n }\n if (!validateRefValue(hash)) {\n return notOk(cliErrorInvalidRefValue(hash));\n }\n\n try {\n const config = await loadConfig(options.config);\n const { refsDir } = resolveMigrationPaths(options.config, config);\n const entry: RefEntry = { hash, invariants: [] };\n await writeRef(refsDir, name, entry);\n return ok({ ok: true as const, ref: name, hash, invariants: [] });\n } catch (error) {\n if (error instanceof CliStructuredError) return notOk(error);\n return notOk(mapError(error));\n }\n}\n\nasync function executeRefGetCommand(\n name: string,\n options: { config?: string },\n): Promise<Result<RefGetResult, CliStructuredError>> {\n try {\n const config = await loadConfig(options.config);\n const { refsDir } = resolveMigrationPaths(options.config, config);\n const entry = await readRef(refsDir, name);\n return ok({ ok: true as const, ref: name, hash: entry.hash, invariants: entry.invariants });\n } catch (error) {\n if (error instanceof CliStructuredError) return notOk(error);\n return notOk(mapError(error));\n }\n}\n\nasync function executeRefDeleteCommand(\n name: string,\n options: { config?: string },\n): Promise<Result<RefDeleteResult, CliStructuredError>> {\n try {\n const config = await loadConfig(options.config);\n const { refsDir } = resolveMigrationPaths(options.config, config);\n await deleteRef(refsDir, name);\n return ok({ ok: true as const, ref: name, deleted: true as const });\n } catch (error) {\n if (error instanceof CliStructuredError) return notOk(error);\n return notOk(mapError(error));\n }\n}\n\nasync function executeRefListCommand(options: {\n config?: string;\n}): Promise<Result<RefListResult, CliStructuredError>> {\n try {\n const config = await loadConfig(options.config);\n const { refsDir } = resolveMigrationPaths(options.config, config);\n const refs = await readRefs(refsDir);\n return ok({ ok: true as const, refs });\n } catch (error) {\n if (error instanceof CliStructuredError) return notOk(error);\n return notOk(mapError(error));\n }\n}\n\nfunction createRefSetCommand(): Command {\n const command = new Command('set');\n setCommandDescriptions(\n command,\n 'Set a ref to a contract hash',\n 'Sets a named ref to point to a contract hash in migrations/refs/.',\n );\n addGlobalOptions(command)\n .argument('<name>', 'Ref name (e.g., staging, production)')\n .argument('<hash>', 'Contract hash to point to')\n .option('--config <path>', 'Path to prisma-next.config.ts')\n .action(\n async (\n name: string,\n hash: string,\n options: { config?: string; json?: string | boolean; quiet?: boolean },\n ) => {\n const flags = parseGlobalFlags(options);\n const ui = new TerminalUI({ color: flags.color, interactive: flags.interactive });\n const result = await executeRefSetCommand(name, hash, options);\n const exitCode = handleResult(result, flags, ui, (value) => {\n if (flags.json) {\n ui.output(JSON.stringify(value));\n } else if (!flags.quiet) {\n ui.output(`Set ref \"${value.ref}\" → ${value.hash}`);\n }\n });\n process.exit(exitCode);\n },\n );\n return command;\n}\n\nfunction createRefGetCommand(): Command {\n const command = new Command('get');\n setCommandDescriptions(\n command,\n 'Get the hash for a ref',\n 'Reads a named ref from migrations/refs/ and prints its contract hash.',\n );\n addGlobalOptions(command)\n .argument('<name>', 'Ref name to look up')\n .option('--config <path>', 'Path to prisma-next.config.ts')\n .action(\n async (\n name: string,\n options: { config?: string; json?: string | boolean; quiet?: boolean },\n ) => {\n const flags = parseGlobalFlags(options);\n const ui = new TerminalUI({ color: flags.color, interactive: flags.interactive });\n const result = await executeRefGetCommand(name, options);\n const exitCode = handleResult(result, flags, ui, (value) => {\n if (flags.json) {\n ui.output(JSON.stringify(value));\n } else {\n ui.output(value.hash);\n }\n });\n process.exit(exitCode);\n },\n );\n return command;\n}\n\nfunction createRefDeleteCommand(): Command {\n const command = new Command('delete');\n setCommandDescriptions(command, 'Delete a ref', 'Removes a named ref from migrations/refs/.');\n addGlobalOptions(command)\n .argument('<name>', 'Ref name to delete')\n .option('--config <path>', 'Path to prisma-next.config.ts')\n .action(\n async (\n name: string,\n options: { config?: string; json?: string | boolean; quiet?: boolean },\n ) => {\n const flags = parseGlobalFlags(options);\n const ui = new TerminalUI({ color: flags.color, interactive: flags.interactive });\n const result = await executeRefDeleteCommand(name, options);\n const exitCode = handleResult(result, flags, ui, (value) => {\n if (flags.json) {\n ui.output(JSON.stringify(value));\n } else if (!flags.quiet) {\n ui.output(`Deleted ref \"${value.ref}\"`);\n }\n });\n process.exit(exitCode);\n },\n );\n return command;\n}\n\nfunction createRefListCommand(): Command {\n const command = new Command('list');\n setCommandDescriptions(command, 'List all refs', 'Lists all named refs from migrations/refs/.');\n addGlobalOptions(command)\n .option('--config <path>', 'Path to prisma-next.config.ts')\n .action(async (options: { config?: string; json?: string | boolean; quiet?: boolean }) => {\n const flags = parseGlobalFlags(options);\n const ui = new TerminalUI({ color: flags.color, interactive: flags.interactive });\n const result = await executeRefListCommand(options);\n const exitCode = handleResult(result, flags, ui, (value) => {\n if (flags.json) {\n ui.output(JSON.stringify(value));\n } else if (!flags.quiet) {\n const entries = Object.entries(value.refs);\n if (entries.length === 0) {\n ui.output('No refs defined');\n } else {\n for (const [refName, entry] of entries) {\n const invariantsSuffix =\n entry.invariants.length > 0 ? ` [invariants: ${entry.invariants.join(', ')}]` : '';\n ui.output(`${refName} → ${entry.hash}${invariantsSuffix}`);\n }\n }\n }\n });\n process.exit(exitCode);\n });\n return command;\n}\n\nexport {\n executeRefSetCommand,\n executeRefGetCommand,\n executeRefDeleteCommand,\n executeRefListCommand,\n cliErrorInvalidRefName,\n cliErrorInvalidRefValue,\n};\n\nexport function createMigrationRefCommand(): Command {\n const command = new Command('ref');\n setCommandDescriptions(\n command,\n 'Manage migration refs',\n 'Manage named refs in migrations/refs/. Refs map logical environment\\n' +\n 'names (e.g., staging, production) to contract hashes.',\n );\n addGlobalOptions(command).configureHelp({\n formatHelp: (cmd) => formatCommandHelp({ command: cmd, flags: parseGlobalFlags({}) }),\n subcommandDescription: () => '',\n });\n command.addCommand(createRefSetCommand());\n command.addCommand(createRefGetCommand());\n command.addCommand(createRefDeleteCommand());\n command.addCommand(createRefListCommand());\n return command;\n}\n"],"mappings":";;;;;;;;;;AAsDA,SAAS,SAAS,OAAoC;CACpD,IAAI,oBAAoB,GAAG,MAAM,EAC/B,OAAO,uBAAuB,MAAM;CAEtC,OAAO,gBAAgB,iBAAiB,QAAQ,MAAM,UAAU,OAAO,MAAM,CAAC;;AAGhF,SAAS,uBAAuB,MAAkC;CAChE,OAAO,aAAa,qBAAqB,KAAK,IAAI;EAChD,KAAK,aAAa,KAAK;EACvB,KAAK;EACN,CAAC;;AAGJ,SAAS,wBAAwB,MAAkC;CACjE,OAAO,aAAa,0BAA0B,KAAK,IAAI;EACrD,KAAK,IAAI,KAAK;EACd,KAAK;EACN,CAAC;;AAGJ,eAAe,qBACb,MACA,MACA,SACmD;CACnD,IAAI,CAAC,gBAAgB,KAAK,EACxB,OAAO,MAAM,uBAAuB,KAAK,CAAC;CAE5C,IAAI,CAAC,iBAAiB,KAAK,EACzB,OAAO,MAAM,wBAAwB,KAAK,CAAC;CAG7C,IAAI;EACF,MAAM,SAAS,MAAM,WAAW,QAAQ,OAAO;EAC/C,MAAM,EAAE,YAAY,sBAAsB,QAAQ,QAAQ,OAAO;EAEjE,MAAM,SAAS,SAAS,MAAM;GADJ;GAAM,YAAY,EAAE;GACX,CAAC;EACpC,OAAO,GAAG;GAAE,IAAI;GAAe,KAAK;GAAM;GAAM,YAAY,EAAE;GAAE,CAAC;UAC1D,OAAO;EACd,IAAI,iBAAiB,oBAAoB,OAAO,MAAM,MAAM;EAC5D,OAAO,MAAM,SAAS,MA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;GAAE,CAAC;EACrF,6BAA6B;EAC9B,CAAC;CACF,QAAQ,WAAW,qBAAqB,CAAC;CACzC,QAAQ,WAAW,qBAAqB,CAAC;CACzC,QAAQ,WAAW,wBAAwB,CAAC;CAC5C,QAAQ,WAAW,sBAAsB,CAAC;CAC1C,OAAO"}
|
|
@@ -1,27 +1,33 @@
|
|
|
1
|
-
import { t as CliStructuredError } from "../cli-errors-
|
|
1
|
+
import { t as CliStructuredError } from "../cli-errors-B9OBbled.mjs";
|
|
2
2
|
import { Command } from "commander";
|
|
3
3
|
import { Result } from "@prisma-next/utils/result";
|
|
4
|
-
import {
|
|
4
|
+
import { OperationPreview } from "@prisma-next/framework-components/control";
|
|
5
|
+
import { OnDiskMigrationPackage } from "@prisma-next/migration-tools/package";
|
|
5
6
|
|
|
6
7
|
//#region src/commands/migration-show.d.ts
|
|
7
8
|
interface MigrationShowResult {
|
|
8
9
|
readonly ok: true;
|
|
9
10
|
readonly dirName: string;
|
|
10
11
|
readonly dirPath: string;
|
|
11
|
-
readonly from: string;
|
|
12
|
+
readonly from: string | null;
|
|
12
13
|
readonly to: string;
|
|
13
|
-
readonly
|
|
14
|
-
readonly kind: string;
|
|
14
|
+
readonly migrationHash: string;
|
|
15
15
|
readonly createdAt: string;
|
|
16
16
|
readonly operations: readonly {
|
|
17
17
|
readonly id: string;
|
|
18
18
|
readonly label: string;
|
|
19
19
|
readonly operationClass: string;
|
|
20
20
|
}[];
|
|
21
|
-
|
|
21
|
+
/**
|
|
22
|
+
* Family-agnostic textual preview of the migration's operations. Replaces
|
|
23
|
+
* the previous string-array DDL field. Always defined; statements is empty
|
|
24
|
+
* for a no-op migration or a family that does not implement the
|
|
25
|
+
* `OperationPreviewCapable` capability.
|
|
26
|
+
*/
|
|
27
|
+
readonly preview: OperationPreview;
|
|
22
28
|
readonly summary: string;
|
|
23
29
|
}
|
|
24
|
-
declare function resolveByHashPrefix(packages: readonly
|
|
30
|
+
declare function resolveByHashPrefix(packages: readonly OnDiskMigrationPackage[], prefix: string): Result<OnDiskMigrationPackage, CliStructuredError>;
|
|
25
31
|
declare function createMigrationShowCommand(): Command;
|
|
26
32
|
//#endregion
|
|
27
33
|
export { MigrationShowResult, createMigrationShowCommand, resolveByHashPrefix };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migration-show.d.mts","names":[],"sources":["../../src/commands/migration-show.ts"],"
|
|
1
|
+
{"version":3,"file":"migration-show.d.mts","names":[],"sources":["../../src/commands/migration-show.ts"],"mappings":";;;;;;;UAuCiB,mBAAA;EAAA,SACN,EAAA;EAAA,SACA,OAAA;EAAA,SACA,OAAA;EAAA,SACA,IAAA;EAAA,SACA,EAAA;EAAA,SACA,aAAA;EAAA,SACA,SAAA;EAAA,SACA,UAAA;IAAA,SACE,EAAA;IAAA,SACA,KAAA;IAAA,SACA,cAAA;EAAA;EAHF;;;;;;EAAA,SAWA,OAAA,EAAS,gBAAA;EAAA,SACT,OAAA;AAAA;AAAA,iBAOK,mBAAA,CACd,QAAA,WAAmB,sBAAA,IACnB,MAAA,WACC,MAAA,CAAO,sBAAA,EAAwB,kBAAA;AAAA,iBAsJlB,0BAAA,CAAA,GAA8B,OAAA"}
|