@prisma-next/cli 0.5.0-dev.3 → 0.5.0-dev.4
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 +4 -4
- package/dist/commands/contract-emit.mjs +1 -1
- package/dist/commands/contract-infer.mjs +1 -1
- package/dist/commands/db-init.mjs +3 -3
- package/dist/commands/db-schema.mjs +3 -3
- package/dist/commands/db-sign.mjs +2 -2
- package/dist/commands/db-update.mjs +3 -3
- package/dist/commands/db-verify.mjs +2 -2
- package/dist/commands/migration-apply.mjs +4 -4
- package/dist/commands/migration-apply.mjs.map +1 -1
- package/dist/commands/migration-new.mjs +1 -1
- package/dist/commands/migration-plan.mjs +1 -1
- package/dist/commands/migration-ref.d.mts +5 -3
- package/dist/commands/migration-ref.d.mts.map +1 -1
- package/dist/commands/migration-ref.mjs +26 -31
- package/dist/commands/migration-ref.mjs.map +1 -1
- package/dist/commands/migration-show.mjs +2 -2
- package/dist/commands/migration-status.d.mts.map +1 -1
- package/dist/commands/migration-status.mjs +1 -1
- package/dist/{contract-emit-CNYyzJwF.mjs → contract-emit-DpPjuFy-.mjs} +2 -2
- package/dist/{contract-emit-CNYyzJwF.mjs.map → contract-emit-DpPjuFy-.mjs.map} +1 -1
- package/dist/{contract-infer-BP3DrGgz.mjs → contract-infer-BS4kIX9c.mjs} +3 -3
- package/dist/{contract-infer-BP3DrGgz.mjs.map → contract-infer-BS4kIX9c.mjs.map} +1 -1
- package/dist/exports/index.mjs +1 -1
- package/dist/{inspect-live-schema-DWzf4Q_m.mjs → inspect-live-schema-BsoFVoS1.mjs} +2 -2
- package/dist/{inspect-live-schema-DWzf4Q_m.mjs.map → inspect-live-schema-BsoFVoS1.mjs.map} +1 -1
- package/dist/{migration-command-scaffold-CLMD302g.mjs → migration-command-scaffold-DOXnheFa.mjs} +2 -2
- package/dist/{migration-command-scaffold-CLMD302g.mjs.map → migration-command-scaffold-DOXnheFa.mjs.map} +1 -1
- package/dist/{migration-status-B0HLF7So.mjs → migration-status-Ry3TnEya.mjs} +8 -10
- package/dist/{migration-status-B0HLF7So.mjs.map → migration-status-Ry3TnEya.mjs.map} +1 -1
- package/dist/{migrations-B0dOQlk0.mjs → migrations-fU0xoKjS.mjs} +2 -2
- package/dist/{migrations-B0dOQlk0.mjs.map → migrations-fU0xoKjS.mjs.map} +1 -1
- package/dist/{result-handler-CIyu0Pdt.mjs → result-handler-BJwA7ufw.mjs} +2 -2
- package/dist/{result-handler-CIyu0Pdt.mjs.map → result-handler-BJwA7ufw.mjs.map} +1 -1
- package/dist/{verify-BxiVp50b.mjs → verify-bl__PkXk.mjs} +2 -2
- package/dist/{verify-BxiVp50b.mjs.map → verify-bl__PkXk.mjs.map} +1 -1
- package/package.json +15 -15
- package/src/commands/migration-apply.ts +3 -3
- package/src/commands/migration-ref.ts +32 -47
- package/src/commands/migration-status.ts +16 -21
- package/src/utils/command-helpers.ts +3 -3
package/dist/cli.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
import "./config-loader-_W4T21X1.mjs";
|
|
4
|
-
import { d as setCommandExamples, g as formatRootHelp, h as formatCommandHelp, m as parseGlobalFlags, u as setCommandDescriptions } from "./result-handler-
|
|
5
|
-
import { t as createContractEmitCommand } from "./contract-emit-
|
|
4
|
+
import { d as setCommandExamples, g as formatRootHelp, h as formatCommandHelp, m as parseGlobalFlags, u as setCommandDescriptions } from "./result-handler-BJwA7ufw.mjs";
|
|
5
|
+
import { t as createContractEmitCommand } from "./contract-emit-DpPjuFy-.mjs";
|
|
6
6
|
import { n as installShutdownHandlers } from "./terminal-ui-C5k88MmW.mjs";
|
|
7
|
-
import { t as createContractInferCommand } from "./contract-infer-
|
|
7
|
+
import { t as createContractInferCommand } from "./contract-infer-BS4kIX9c.mjs";
|
|
8
8
|
import { createDbInitCommand } from "./commands/db-init.mjs";
|
|
9
9
|
import { createDbSchemaCommand } from "./commands/db-schema.mjs";
|
|
10
10
|
import { createDbSignCommand } from "./commands/db-sign.mjs";
|
|
@@ -15,7 +15,7 @@ import { createMigrationNewCommand } from "./commands/migration-new.mjs";
|
|
|
15
15
|
import { createMigrationPlanCommand } from "./commands/migration-plan.mjs";
|
|
16
16
|
import { createMigrationRefCommand } from "./commands/migration-ref.mjs";
|
|
17
17
|
import { createMigrationShowCommand } from "./commands/migration-show.mjs";
|
|
18
|
-
import { t as createMigrationStatusCommand } from "./migration-status-
|
|
18
|
+
import { t as createMigrationStatusCommand } from "./migration-status-Ry3TnEya.mjs";
|
|
19
19
|
import { Command } from "commander";
|
|
20
20
|
import { distance } from "closest-match";
|
|
21
21
|
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import "../config-loader-_W4T21X1.mjs";
|
|
2
2
|
import { _ as errorUnexpected, a as errorContractValidationFailed, f as errorMigrationPlanningFailed, m as errorRuntime, p as errorRunnerFailed, t as CliStructuredError } from "../cli-errors-DHq6GQGu.mjs";
|
|
3
3
|
import { n as ContractValidationError } from "../client-TG7rbCWT.mjs";
|
|
4
|
-
import { d as setCommandExamples, l as sanitizeErrorMessage, m as parseGlobalFlags, t as handleResult, u as setCommandDescriptions } from "../result-handler-
|
|
4
|
+
import { d as setCommandExamples, l as sanitizeErrorMessage, m as parseGlobalFlags, t as handleResult, u as setCommandDescriptions } from "../result-handler-BJwA7ufw.mjs";
|
|
5
5
|
import { t as TerminalUI } from "../terminal-ui-C5k88MmW.mjs";
|
|
6
|
-
import { i as formatMigrationPlanOutput, n as formatMigrationApplyOutput, r as formatMigrationJson } from "../migrations-
|
|
7
|
-
import { n as prepareMigrationContext, t as addMigrationCommandOptions } from "../migration-command-scaffold-
|
|
6
|
+
import { i as formatMigrationPlanOutput, n as formatMigrationApplyOutput, r as formatMigrationJson } from "../migrations-fU0xoKjS.mjs";
|
|
7
|
+
import { n as prepareMigrationContext, t as addMigrationCommandOptions } from "../migration-command-scaffold-DOXnheFa.mjs";
|
|
8
8
|
import { Command } from "commander";
|
|
9
9
|
import { notOk, ok } from "@prisma-next/utils/result";
|
|
10
10
|
import { ifDefined } from "@prisma-next/utils/defined";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import "../config-loader-_W4T21X1.mjs";
|
|
2
|
-
import { d as setCommandExamples, m as parseGlobalFlags, n as addGlobalOptions, t as handleResult, u as setCommandDescriptions } from "../result-handler-
|
|
2
|
+
import { d as setCommandExamples, m as parseGlobalFlags, n as addGlobalOptions, t as handleResult, u as setCommandDescriptions } from "../result-handler-BJwA7ufw.mjs";
|
|
3
3
|
import { t as TerminalUI } from "../terminal-ui-C5k88MmW.mjs";
|
|
4
|
-
import { t as inspectLiveSchema } from "../inspect-live-schema-
|
|
5
|
-
import { n as formatIntrospectOutput, t as formatIntrospectJson } from "../verify-
|
|
4
|
+
import { t as inspectLiveSchema } from "../inspect-live-schema-BsoFVoS1.mjs";
|
|
5
|
+
import { n as formatIntrospectOutput, t as formatIntrospectJson } from "../verify-bl__PkXk.mjs";
|
|
6
6
|
import { Command } from "commander";
|
|
7
7
|
|
|
8
8
|
//#region src/commands/db-schema.ts
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { t as loadConfig } from "../config-loader-_W4T21X1.mjs";
|
|
2
2
|
import { _ as errorUnexpected, a as errorContractValidationFailed, c as errorDriverRequired, l as errorFileNotFound, o as errorDatabaseConnectionRequired, t as CliStructuredError } from "../cli-errors-DHq6GQGu.mjs";
|
|
3
3
|
import { n as ContractValidationError, t as createControlClient } from "../client-TG7rbCWT.mjs";
|
|
4
|
-
import { _ as formatStyledHeader, a as maskConnectionUrl, d as setCommandExamples, m as parseGlobalFlags, n as addGlobalOptions, s as resolveContractPath, t as handleResult, u as setCommandDescriptions } from "../result-handler-
|
|
4
|
+
import { _ as formatStyledHeader, a as maskConnectionUrl, d as setCommandExamples, m as parseGlobalFlags, n as addGlobalOptions, s as resolveContractPath, t as handleResult, u as setCommandDescriptions } from "../result-handler-BJwA7ufw.mjs";
|
|
5
5
|
import { t as createProgressAdapter } from "../progress-adapter-B-YvmcDu.mjs";
|
|
6
6
|
import { t as TerminalUI } from "../terminal-ui-C5k88MmW.mjs";
|
|
7
|
-
import { a as formatSignJson, i as formatSchemaVerifyOutput, o as formatSignOutput, r as formatSchemaVerifyJson } from "../verify-
|
|
7
|
+
import { a as formatSignJson, i as formatSchemaVerifyOutput, o as formatSignOutput, r as formatSchemaVerifyJson } from "../verify-bl__PkXk.mjs";
|
|
8
8
|
import { Command } from "commander";
|
|
9
9
|
import { notOk, ok } from "@prisma-next/utils/result";
|
|
10
10
|
import { relative, resolve } from "pathe";
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import "../config-loader-_W4T21X1.mjs";
|
|
2
2
|
import { _ as errorUnexpected, a as errorContractValidationFailed, f as errorMigrationPlanningFailed, n as ERROR_CODE_DESTRUCTIVE_CHANGES, p as errorRunnerFailed, s as errorDestructiveChanges, t as CliStructuredError } from "../cli-errors-DHq6GQGu.mjs";
|
|
3
3
|
import { n as ContractValidationError } from "../client-TG7rbCWT.mjs";
|
|
4
|
-
import { d as setCommandExamples, l as sanitizeErrorMessage, m as parseGlobalFlags, t as handleResult, u as setCommandDescriptions } from "../result-handler-
|
|
4
|
+
import { d as setCommandExamples, l as sanitizeErrorMessage, m as parseGlobalFlags, t as handleResult, u as setCommandDescriptions } from "../result-handler-BJwA7ufw.mjs";
|
|
5
5
|
import { t as TerminalUI } from "../terminal-ui-C5k88MmW.mjs";
|
|
6
|
-
import { i as formatMigrationPlanOutput, n as formatMigrationApplyOutput, r as formatMigrationJson } from "../migrations-
|
|
7
|
-
import { n as prepareMigrationContext, t as addMigrationCommandOptions } from "../migration-command-scaffold-
|
|
6
|
+
import { i as formatMigrationPlanOutput, n as formatMigrationApplyOutput, r as formatMigrationJson } from "../migrations-fU0xoKjS.mjs";
|
|
7
|
+
import { n as prepareMigrationContext, t as addMigrationCommandOptions } from "../migration-command-scaffold-DOXnheFa.mjs";
|
|
8
8
|
import { Command } from "commander";
|
|
9
9
|
import { notOk, ok } from "@prisma-next/utils/result";
|
|
10
10
|
import { ifDefined } from "@prisma-next/utils/defined";
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { t as loadConfig } from "../config-loader-_W4T21X1.mjs";
|
|
2
2
|
import { _ as errorUnexpected, a as errorContractValidationFailed, c as errorDriverRequired, d as errorMarkerMissing, g as errorTargetMismatch, l as errorFileNotFound, m as errorRuntime, o as errorDatabaseConnectionRequired, t as CliStructuredError, u as errorHashMismatch } from "../cli-errors-DHq6GQGu.mjs";
|
|
3
3
|
import { n as ContractValidationError, t as createControlClient } from "../client-TG7rbCWT.mjs";
|
|
4
|
-
import { _ as formatStyledHeader, a as maskConnectionUrl, d as setCommandExamples, m as parseGlobalFlags, n as addGlobalOptions, s as resolveContractPath, t as handleResult, u as setCommandDescriptions } from "../result-handler-
|
|
4
|
+
import { _ as formatStyledHeader, a as maskConnectionUrl, d as setCommandExamples, m as parseGlobalFlags, n as addGlobalOptions, s as resolveContractPath, t as handleResult, u as setCommandDescriptions } from "../result-handler-BJwA7ufw.mjs";
|
|
5
5
|
import { t as createProgressAdapter } from "../progress-adapter-B-YvmcDu.mjs";
|
|
6
6
|
import { t as TerminalUI } from "../terminal-ui-C5k88MmW.mjs";
|
|
7
|
-
import { c as formatVerifyOutput, i as formatSchemaVerifyOutput, r as formatSchemaVerifyJson, s as formatVerifyJson } from "../verify-
|
|
7
|
+
import { c as formatVerifyOutput, i as formatSchemaVerifyOutput, r as formatSchemaVerifyJson, s as formatVerifyJson } from "../verify-bl__PkXk.mjs";
|
|
8
8
|
import { Command } from "commander";
|
|
9
9
|
import { notOk, ok } from "@prisma-next/utils/result";
|
|
10
10
|
import { relative, resolve } from "pathe";
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { t as loadConfig } from "../config-loader-_W4T21X1.mjs";
|
|
2
2
|
import { _ as errorUnexpected, c as errorDriverRequired, h as errorTargetMigrationNotSupported, m as errorRuntime, o as errorDatabaseConnectionRequired, t as CliStructuredError } from "../cli-errors-DHq6GQGu.mjs";
|
|
3
3
|
import { t as createControlClient } from "../client-TG7rbCWT.mjs";
|
|
4
|
-
import { _ as formatStyledHeader, a as maskConnectionUrl, c as resolveMigrationPaths, d as setCommandExamples, f as targetSupportsMigrations, i as loadAllBundles, m as parseGlobalFlags, n as addGlobalOptions, o as readContractEnvelope, p as toPathDecisionResult, t as handleResult, u as setCommandDescriptions } from "../result-handler-
|
|
4
|
+
import { _ as formatStyledHeader, a as maskConnectionUrl, c as resolveMigrationPaths, d as setCommandExamples, f as targetSupportsMigrations, i as loadAllBundles, m as parseGlobalFlags, n as addGlobalOptions, o as readContractEnvelope, p as toPathDecisionResult, t as handleResult, u as setCommandDescriptions } from "../result-handler-BJwA7ufw.mjs";
|
|
5
5
|
import { t as TerminalUI } from "../terminal-ui-C5k88MmW.mjs";
|
|
6
|
-
import { t as formatMigrationApplyCommandOutput } from "../migrations-
|
|
6
|
+
import { t as formatMigrationApplyCommandOutput } from "../migrations-fU0xoKjS.mjs";
|
|
7
7
|
import { Command } from "commander";
|
|
8
8
|
import { notOk, ok } from "@prisma-next/utils/result";
|
|
9
9
|
import { EMPTY_CONTRACT_HASH } from "@prisma-next/migration-tools/constants";
|
|
@@ -42,7 +42,7 @@ function packageToStep(pkg) {
|
|
|
42
42
|
}
|
|
43
43
|
async function executeMigrationApplyCommand(options, flags, ui, startTime) {
|
|
44
44
|
const config = await loadConfig(options.config);
|
|
45
|
-
const { configPath, migrationsDir, migrationsRelative,
|
|
45
|
+
const { configPath, migrationsDir, migrationsRelative, refsDir } = resolveMigrationPaths(options.config, config);
|
|
46
46
|
const dbConnection = options.db ?? config.db?.connection;
|
|
47
47
|
if (!dbConnection) return notOk(errorDatabaseConnectionRequired({
|
|
48
48
|
why: `Database connection is required for migration apply (set db.connection in ${configPath}, or pass --db <url>)`,
|
|
@@ -55,7 +55,7 @@ async function executeMigrationApplyCommand(options, flags, ui, startTime) {
|
|
|
55
55
|
if (options.ref) {
|
|
56
56
|
refName = options.ref;
|
|
57
57
|
try {
|
|
58
|
-
destinationHash = resolveRef(await readRefs(
|
|
58
|
+
destinationHash = resolveRef(await readRefs(refsDir), refName).hash;
|
|
59
59
|
} catch (error) {
|
|
60
60
|
if (MigrationToolsError.is(error)) return notOk(mapMigrationToolsError(error));
|
|
61
61
|
throw error;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migration-apply.mjs","names":["destinationHash: string","refName: string | undefined","details: Array<{ label: string; value: string }>","migrations: MigrationBundleSet","pendingMigrations: MigrationApplyStep[]"],"sources":["../../src/commands/migration-apply.ts"],"sourcesContent":["import { verifyMigrationBundle } from '@prisma-next/migration-tools/attestation';\nimport { EMPTY_CONTRACT_HASH } from '@prisma-next/migration-tools/constants';\nimport { findPathWithDecision } from '@prisma-next/migration-tools/dag';\nimport { readRefs, resolveRef } from '@prisma-next/migration-tools/refs';\nimport type { MigrationBundle } from '@prisma-next/migration-tools/types';\nimport { MigrationToolsError } from '@prisma-next/migration-tools/types';\nimport { notOk, ok, type Result } from '@prisma-next/utils/result';\nimport { Command } from 'commander';\n\nimport { loadConfig } from '../config-loader';\nimport { createControlClient } from '../control-api/client';\nimport type { MigrationApplyFailure, MigrationApplyStep } from '../control-api/types';\nimport {\n CliStructuredError,\n type CliStructuredError as CliStructuredErrorType,\n errorDatabaseConnectionRequired,\n errorDriverRequired,\n errorRuntime,\n errorTargetMigrationNotSupported,\n errorUnexpected,\n} from '../utils/cli-errors';\nimport {\n addGlobalOptions,\n loadAllBundles,\n type MigrationBundleSet,\n maskConnectionUrl,\n readContractEnvelope,\n resolveMigrationPaths,\n setCommandDescriptions,\n setCommandExamples,\n targetSupportsMigrations,\n toPathDecisionResult,\n} from '../utils/command-helpers';\nimport { formatMigrationApplyCommandOutput } from '../utils/formatters/migrations';\nimport { formatStyledHeader } from '../utils/formatters/styled';\nimport type { CommonCommandOptions } from '../utils/global-flags';\nimport { type GlobalFlags, parseGlobalFlags } from '../utils/global-flags';\nimport { handleResult } from '../utils/result-handler';\nimport { TerminalUI } from '../utils/terminal-ui';\n\ninterface MigrationApplyCommandOptions extends CommonCommandOptions {\n readonly db?: string;\n readonly config?: string;\n readonly ref?: string;\n}\n\nexport interface MigrationApplyResult {\n readonly ok: boolean;\n readonly migrationsApplied: number;\n readonly migrationsTotal: number;\n readonly markerHash: string;\n readonly applied: readonly {\n readonly dirName: string;\n readonly from: string;\n readonly to: string;\n readonly operationsExecuted: number;\n }[];\n readonly summary: string;\n readonly pathDecision?: {\n readonly fromHash: string;\n readonly toHash: string;\n readonly alternativeCount: number;\n readonly tieBreakReasons: readonly string[];\n readonly refName?: string;\n readonly selectedPath: readonly {\n readonly dirName: string;\n readonly migrationId: string;\n readonly from: string;\n readonly to: string;\n }[];\n };\n readonly timings: {\n readonly total: number;\n };\n}\n\nfunction mapMigrationToolsError(error: unknown): CliStructuredErrorType {\n if (MigrationToolsError.is(error)) {\n return errorRuntime(error.message, {\n why: error.why,\n fix: error.fix,\n meta: { code: error.code, ...(error.details ?? {}) },\n });\n }\n return errorUnexpected(error instanceof Error ? error.message : String(error), {\n why: `Unexpected error during migration apply: ${error instanceof Error ? error.message : String(error)}`,\n });\n}\n\nfunction mapApplyFailure(failure: MigrationApplyFailure): CliStructuredErrorType {\n return errorRuntime(failure.summary, {\n why: failure.why ?? 'Migration runner failed',\n fix: 'Fix the issue and re-run `prisma-next migration apply` — previously applied migrations are preserved.',\n meta: failure.meta ?? {},\n });\n}\n\nfunction packageToStep(pkg: MigrationBundle): MigrationApplyStep {\n return {\n dirName: pkg.dirName,\n from: pkg.manifest.from,\n to: pkg.manifest.to,\n toContract: pkg.manifest.toContract,\n operations: pkg.ops,\n };\n}\n\nasync function executeMigrationApplyCommand(\n options: MigrationApplyCommandOptions,\n flags: GlobalFlags,\n ui: TerminalUI,\n startTime: number,\n): Promise<Result<MigrationApplyResult, CliStructuredErrorType>> {\n const config = await loadConfig(options.config);\n const { configPath, migrationsDir, migrationsRelative, refsPath } = resolveMigrationPaths(\n options.config,\n config,\n );\n\n const dbConnection = options.db ?? config.db?.connection;\n if (!dbConnection) {\n return notOk(\n errorDatabaseConnectionRequired({\n why: `Database connection is required for migration apply (set db.connection in ${configPath}, or pass --db <url>)`,\n commandName: 'migration apply',\n }),\n );\n }\n\n if (!config.driver) {\n return notOk(\n errorDriverRequired({\n why: 'Config.driver is required for migration apply',\n }),\n );\n }\n\n if (!targetSupportsMigrations(config.target)) {\n return notOk(\n errorTargetMigrationNotSupported({\n why: `Target \"${config.target.id}\" does not support migrations`,\n }),\n );\n }\n\n let destinationHash: string;\n let refName: string | undefined;\n\n if (options.ref) {\n refName = options.ref;\n try {\n const refs = await readRefs(refsPath);\n destinationHash = resolveRef(refs, refName);\n } catch (error) {\n if (MigrationToolsError.is(error)) {\n return notOk(mapMigrationToolsError(error));\n }\n throw error;\n }\n } else {\n try {\n const envelope = await readContractEnvelope(config);\n destinationHash = envelope.storageHash;\n } catch (error) {\n return notOk(\n errorRuntime('Current contract is unavailable', {\n why: `Failed to read contract: ${error instanceof Error ? error.message : String(error)}`,\n fix: 'Run `prisma-next contract emit` to generate a valid contract.json, then retry apply.',\n }),\n );\n }\n }\n\n if (!flags.json && !flags.quiet) {\n const details: Array<{ label: string; value: string }> = [\n { label: 'config', value: configPath },\n { label: 'migrations', value: migrationsRelative },\n ];\n if (typeof dbConnection === 'string') {\n details.push({\n label: 'database',\n value: maskConnectionUrl(dbConnection),\n });\n }\n if (refName) {\n details.push({ label: 'ref', value: refName });\n }\n const header = formatStyledHeader({\n command: 'migration apply',\n description: 'Apply planned migrations to the database',\n url: 'https://pris.ly/migration-apply',\n details,\n flags,\n });\n ui.stderr(header);\n }\n\n // Read migrations and build migration chain model (offline — no DB needed)\n let migrations: MigrationBundleSet;\n try {\n migrations = await loadAllBundles(migrationsDir);\n } catch (error) {\n if (MigrationToolsError.is(error)) {\n return notOk(mapMigrationToolsError(error));\n }\n throw error;\n }\n\n // Defense in depth: re-hash every bundle and confirm the recorded\n // `migrationId` matches the on-disk `(manifest, ops)`. Catches FS\n // corruption, partial writes, and post-emit hand edits before we\n // start touching the database.\n for (const bundle of migrations.bundles) {\n const verified = verifyMigrationBundle(bundle);\n if (!verified.ok) {\n return notOk(\n errorRuntime(`Migration package is corrupt: ${bundle.dirName}`, {\n why: `Stored migrationId \"${verified.storedMigrationId}\" does not match the recomputed hash \"${verified.computedMigrationId}\" for ${migrationsRelative}/${bundle.dirName}. The migration.json or ops.json has been edited or partially written since emit.`,\n fix: `Re-emit the package by running \\`node \"${migrationsRelative}/${bundle.dirName}/migration.ts\"\\`, or restore the directory from version control.`,\n meta: {\n dirName: bundle.dirName,\n storedMigrationId: verified.storedMigrationId,\n computedMigrationId: verified.computedMigrationId,\n },\n }),\n );\n }\n }\n\n const client = createControlClient({\n family: config.family,\n target: config.target,\n adapter: config.adapter,\n driver: config.driver,\n extensionPacks: config.extensionPacks ?? [],\n });\n\n try {\n await client.connect(dbConnection);\n const marker = await client.readMarker();\n\n // --- No migrations on disk ---\n if (migrations.bundles.length === 0) {\n if (marker?.storageHash) {\n return notOk(\n errorRuntime('Database has state but no migrations exist', {\n why: `The database marker hash \"${marker.storageHash}\" exists but no migrations were found in ${migrationsRelative}`,\n fix: 'Ensure the migrations directory is correct. If the database was managed with `db init` or `db update`, run `prisma-next db sign` to update the marker.',\n meta: { markerHash: marker.storageHash, migrationsDir: migrationsRelative },\n }),\n );\n }\n // Non-empty contract + no migrations = user needs to plan first.\n if (destinationHash !== EMPTY_CONTRACT_HASH) {\n return notOk(\n errorRuntime('Current contract has no planned migrations', {\n why: `No migrations were found in ${migrationsRelative}, but current contract hash is \"${destinationHash}\"`,\n fix: 'Run `prisma-next migration plan` to create a migration for the current contract.',\n meta: { destinationHash, migrationsDir: migrationsRelative },\n }),\n );\n }\n // Empty contract + no migrations = nothing to do.\n return ok({\n ok: true,\n migrationsApplied: 0,\n migrationsTotal: 0,\n markerHash: EMPTY_CONTRACT_HASH,\n applied: [],\n summary: 'No migrations found',\n timings: { total: Date.now() - startTime },\n });\n }\n\n // --- Validate marker state ---\n\n // The empty sentinel should never appear in a real marker row — if it does,\n // the marker was corrupted and replaying all migrations would be dangerous.\n if (marker?.storageHash === EMPTY_CONTRACT_HASH) {\n return notOk(\n errorRuntime('Database marker contains the empty sentinel hash', {\n why: `The marker row exists but contains the empty sentinel value \"${EMPTY_CONTRACT_HASH}\". This should never happen — the marker should contain the hash of the last applied contract.`,\n fix: 'The marker is corrupted. Run `prisma-next db sign` to overwrite it with the correct contract hash, or drop and recreate the database.',\n meta: { markerHash: EMPTY_CONTRACT_HASH },\n }),\n );\n }\n\n const markerHash = marker?.storageHash;\n\n if (markerHash !== undefined && !migrations.graph.nodes.has(markerHash)) {\n return notOk(\n errorRuntime('Database marker does not match any known migration', {\n why: `The database marker hash \"${markerHash}\" is not found in the migration history at ${migrationsRelative}`,\n fix: 'Ensure the migrations directory matches this database. If the database was managed with `db init` or `db update`, run `prisma-next db sign` to update the marker.',\n meta: { markerHash, knownNodes: [...migrations.graph.nodes] },\n }),\n );\n }\n\n if (!migrations.graph.nodes.has(destinationHash)) {\n return notOk(\n errorRuntime('Current contract has no planned migration path', {\n why: `Current contract hash \"${destinationHash}\" is not present in the migration history at ${migrationsRelative}`,\n fix: 'Run `prisma-next migration plan` to create a migration for the current contract, then re-run apply.',\n meta: { destinationHash, knownNodes: [...migrations.graph.nodes] },\n }),\n );\n }\n\n // --- Resolve path and apply ---\n\n // \"No marker\" means the database is fresh — start from the empty contract hash.\n const originHash = markerHash ?? EMPTY_CONTRACT_HASH;\n\n const decision = findPathWithDecision(migrations.graph, originHash, destinationHash, refName);\n if (!decision) {\n return notOk(\n errorRuntime('No migration path from current state to target', {\n why: `Cannot find a path from \"${originHash}\" to target \"${destinationHash}\"`,\n fix: 'Check the migration history for gaps or inconsistencies.',\n meta: { markerHash: originHash, destinationHash },\n }),\n );\n }\n\n const pendingPath = decision.selectedPath;\n const pathDecision = toPathDecisionResult(decision);\n\n if (pendingPath.length === 0) {\n return ok({\n ok: true,\n migrationsApplied: 0,\n migrationsTotal: 0,\n markerHash: originHash,\n applied: [],\n summary: 'Already up to date',\n pathDecision,\n timings: { total: Date.now() - startTime },\n });\n }\n\n const bundleByDir = new Map(migrations.bundles.map((b) => [b.dirName, b]));\n const pendingMigrations: MigrationApplyStep[] = [];\n for (const migration of pendingPath) {\n const pkg = bundleByDir.get(migration.dirName);\n if (!pkg) {\n return notOk(\n errorRuntime(`Migration package not found: ${migration.dirName}`, {\n why: `The migration directory for path segment ${migration.from} → ${migration.to} was not found`,\n fix: 'Ensure all migration directories are present and intact.',\n }),\n );\n }\n pendingMigrations.push(packageToStep(pkg));\n }\n\n if (!flags.quiet && !flags.json) {\n for (const migration of pendingMigrations) {\n ui.step(`Pending ${migration.dirName}`);\n }\n }\n\n const applyResult = await client.migrationApply({\n originHash,\n destinationHash,\n pendingMigrations,\n });\n\n if (!applyResult.ok) {\n return notOk(mapApplyFailure(applyResult.failure));\n }\n\n const { value } = applyResult;\n\n return ok({\n ok: true,\n migrationsApplied: value.migrationsApplied,\n migrationsTotal: pendingPath.length,\n markerHash: value.markerHash,\n applied: value.applied,\n summary: value.summary,\n pathDecision,\n timings: { total: Date.now() - startTime },\n });\n } catch (error) {\n if (CliStructuredError.is(error)) {\n return notOk(error);\n }\n return notOk(\n errorUnexpected(error instanceof Error ? error.message : String(error), {\n why: `Unexpected error during migration apply: ${error instanceof Error ? error.message : String(error)}`,\n }),\n );\n } finally {\n await client.close();\n }\n}\n\nexport function createMigrationApplyCommand(): Command {\n const command = new Command('apply');\n setCommandDescriptions(\n command,\n 'Apply planned migrations to the database',\n 'Applies previously planned migrations (created by `migration plan`) to a live database.\\n' +\n 'Compares the database marker against the migration history to determine which\\n' +\n 'migrations are pending, then executes them sequentially. Each migration runs\\n' +\n 'in its own transaction. Does not plan new migrations — run `migration plan` first.',\n );\n setCommandExamples(command, ['prisma-next migration apply --db $DATABASE_URL']);\n addGlobalOptions(command)\n .option('--db <url>', 'Database connection string')\n .option('--config <path>', 'Path to prisma-next.config.ts')\n .option('--ref <name>', 'Target ref name from migrations/refs/')\n .action(async (options: MigrationApplyCommandOptions) => {\n const flags = parseGlobalFlags(options);\n const startTime = Date.now();\n\n const ui = new TerminalUI({\n color: flags.color,\n interactive: flags.interactive,\n });\n\n const result = await executeMigrationApplyCommand(options, flags, ui, startTime);\n\n const exitCode = handleResult(result, flags, ui, (applyResult) => {\n if (flags.json) {\n ui.output(JSON.stringify(applyResult, null, 2));\n } else if (!flags.quiet) {\n ui.log(formatMigrationApplyCommandOutput(applyResult, flags));\n }\n });\n\n process.exit(exitCode);\n });\n\n return command;\n}\n"],"mappings":";;;;;;;;;;;;;;;AA4EA,SAAS,uBAAuB,OAAwC;AACtE,KAAI,oBAAoB,GAAG,MAAM,CAC/B,QAAO,aAAa,MAAM,SAAS;EACjC,KAAK,MAAM;EACX,KAAK,MAAM;EACX,MAAM;GAAE,MAAM,MAAM;GAAM,GAAI,MAAM,WAAW,EAAE;GAAG;EACrD,CAAC;AAEJ,QAAO,gBAAgB,iBAAiB,QAAQ,MAAM,UAAU,OAAO,MAAM,EAAE,EAC7E,KAAK,4CAA4C,iBAAiB,QAAQ,MAAM,UAAU,OAAO,MAAM,IACxG,CAAC;;AAGJ,SAAS,gBAAgB,SAAwD;AAC/E,QAAO,aAAa,QAAQ,SAAS;EACnC,KAAK,QAAQ,OAAO;EACpB,KAAK;EACL,MAAM,QAAQ,QAAQ,EAAE;EACzB,CAAC;;AAGJ,SAAS,cAAc,KAA0C;AAC/D,QAAO;EACL,SAAS,IAAI;EACb,MAAM,IAAI,SAAS;EACnB,IAAI,IAAI,SAAS;EACjB,YAAY,IAAI,SAAS;EACzB,YAAY,IAAI;EACjB;;AAGH,eAAe,6BACb,SACA,OACA,IACA,WAC+D;CAC/D,MAAM,SAAS,MAAM,WAAW,QAAQ,OAAO;CAC/C,MAAM,EAAE,YAAY,eAAe,oBAAoB,a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0C;EACvD,MAAM,QAAQ,iBAAiB,QAAQ;EACvC,MAAM,YAAY,KAAK,KAAK;EAE5B,MAAM,KAAK,IAAI,WAAW;GACxB,OAAO,MAAM;GACb,aAAa,MAAM;GACpB,CAAC;EAIF,MAAM,WAAW,aAFF,MAAM,6BAA6B,SAAS,OAAO,IAAI,UAAU,EAE1C,OAAO,KAAK,gBAAgB;AAChE,OAAI,MAAM,KACR,IAAG,OAAO,KAAK,UAAU,aAAa,MAAM,EAAE,CAAC;YACtC,CAAC,MAAM,MAChB,IAAG,IAAI,kCAAkC,aAAa,MAAM,CAAC;IAE/D;AAEF,UAAQ,KAAK,SAAS;GACtB;AAEJ,QAAO"}
|
|
1
|
+
{"version":3,"file":"migration-apply.mjs","names":["destinationHash: string","refName: string | undefined","details: Array<{ label: string; value: string }>","migrations: MigrationBundleSet","pendingMigrations: MigrationApplyStep[]"],"sources":["../../src/commands/migration-apply.ts"],"sourcesContent":["import { verifyMigrationBundle } from '@prisma-next/migration-tools/attestation';\nimport { EMPTY_CONTRACT_HASH } from '@prisma-next/migration-tools/constants';\nimport { findPathWithDecision } from '@prisma-next/migration-tools/dag';\nimport { readRefs, resolveRef } from '@prisma-next/migration-tools/refs';\nimport type { MigrationBundle } from '@prisma-next/migration-tools/types';\nimport { MigrationToolsError } from '@prisma-next/migration-tools/types';\nimport { notOk, ok, type Result } from '@prisma-next/utils/result';\nimport { Command } from 'commander';\n\nimport { loadConfig } from '../config-loader';\nimport { createControlClient } from '../control-api/client';\nimport type { MigrationApplyFailure, MigrationApplyStep } from '../control-api/types';\nimport {\n CliStructuredError,\n type CliStructuredError as CliStructuredErrorType,\n errorDatabaseConnectionRequired,\n errorDriverRequired,\n errorRuntime,\n errorTargetMigrationNotSupported,\n errorUnexpected,\n} from '../utils/cli-errors';\nimport {\n addGlobalOptions,\n loadAllBundles,\n type MigrationBundleSet,\n maskConnectionUrl,\n readContractEnvelope,\n resolveMigrationPaths,\n setCommandDescriptions,\n setCommandExamples,\n targetSupportsMigrations,\n toPathDecisionResult,\n} from '../utils/command-helpers';\nimport { formatMigrationApplyCommandOutput } from '../utils/formatters/migrations';\nimport { formatStyledHeader } from '../utils/formatters/styled';\nimport type { CommonCommandOptions } from '../utils/global-flags';\nimport { type GlobalFlags, parseGlobalFlags } from '../utils/global-flags';\nimport { handleResult } from '../utils/result-handler';\nimport { TerminalUI } from '../utils/terminal-ui';\n\ninterface MigrationApplyCommandOptions extends CommonCommandOptions {\n readonly db?: string;\n readonly config?: string;\n readonly ref?: string;\n}\n\nexport interface MigrationApplyResult {\n readonly ok: boolean;\n readonly migrationsApplied: number;\n readonly migrationsTotal: number;\n readonly markerHash: string;\n readonly applied: readonly {\n readonly dirName: string;\n readonly from: string;\n readonly to: string;\n readonly operationsExecuted: number;\n }[];\n readonly summary: string;\n readonly pathDecision?: {\n readonly fromHash: string;\n readonly toHash: string;\n readonly alternativeCount: number;\n readonly tieBreakReasons: readonly string[];\n readonly refName?: string;\n readonly selectedPath: readonly {\n readonly dirName: string;\n readonly migrationId: string;\n readonly from: string;\n readonly to: string;\n }[];\n };\n readonly timings: {\n readonly total: number;\n };\n}\n\nfunction mapMigrationToolsError(error: unknown): CliStructuredErrorType {\n if (MigrationToolsError.is(error)) {\n return errorRuntime(error.message, {\n why: error.why,\n fix: error.fix,\n meta: { code: error.code, ...(error.details ?? {}) },\n });\n }\n return errorUnexpected(error instanceof Error ? error.message : String(error), {\n why: `Unexpected error during migration apply: ${error instanceof Error ? error.message : String(error)}`,\n });\n}\n\nfunction mapApplyFailure(failure: MigrationApplyFailure): CliStructuredErrorType {\n return errorRuntime(failure.summary, {\n why: failure.why ?? 'Migration runner failed',\n fix: 'Fix the issue and re-run `prisma-next migration apply` — previously applied migrations are preserved.',\n meta: failure.meta ?? {},\n });\n}\n\nfunction packageToStep(pkg: MigrationBundle): MigrationApplyStep {\n return {\n dirName: pkg.dirName,\n from: pkg.manifest.from,\n to: pkg.manifest.to,\n toContract: pkg.manifest.toContract,\n operations: pkg.ops,\n };\n}\n\nasync function executeMigrationApplyCommand(\n options: MigrationApplyCommandOptions,\n flags: GlobalFlags,\n ui: TerminalUI,\n startTime: number,\n): Promise<Result<MigrationApplyResult, CliStructuredErrorType>> {\n const config = await loadConfig(options.config);\n const { configPath, migrationsDir, migrationsRelative, refsDir } = resolveMigrationPaths(\n options.config,\n config,\n );\n\n const dbConnection = options.db ?? config.db?.connection;\n if (!dbConnection) {\n return notOk(\n errorDatabaseConnectionRequired({\n why: `Database connection is required for migration apply (set db.connection in ${configPath}, or pass --db <url>)`,\n commandName: 'migration apply',\n }),\n );\n }\n\n if (!config.driver) {\n return notOk(\n errorDriverRequired({\n why: 'Config.driver is required for migration apply',\n }),\n );\n }\n\n if (!targetSupportsMigrations(config.target)) {\n return notOk(\n errorTargetMigrationNotSupported({\n why: `Target \"${config.target.id}\" does not support migrations`,\n }),\n );\n }\n\n let destinationHash: string;\n let refName: string | undefined;\n\n if (options.ref) {\n refName = options.ref;\n try {\n const refs = await readRefs(refsDir);\n destinationHash = resolveRef(refs, refName).hash;\n } catch (error) {\n if (MigrationToolsError.is(error)) {\n return notOk(mapMigrationToolsError(error));\n }\n throw error;\n }\n } else {\n try {\n const envelope = await readContractEnvelope(config);\n destinationHash = envelope.storageHash;\n } catch (error) {\n return notOk(\n errorRuntime('Current contract is unavailable', {\n why: `Failed to read contract: ${error instanceof Error ? error.message : String(error)}`,\n fix: 'Run `prisma-next contract emit` to generate a valid contract.json, then retry apply.',\n }),\n );\n }\n }\n\n if (!flags.json && !flags.quiet) {\n const details: Array<{ label: string; value: string }> = [\n { label: 'config', value: configPath },\n { label: 'migrations', value: migrationsRelative },\n ];\n if (typeof dbConnection === 'string') {\n details.push({\n label: 'database',\n value: maskConnectionUrl(dbConnection),\n });\n }\n if (refName) {\n details.push({ label: 'ref', value: refName });\n }\n const header = formatStyledHeader({\n command: 'migration apply',\n description: 'Apply planned migrations to the database',\n url: 'https://pris.ly/migration-apply',\n details,\n flags,\n });\n ui.stderr(header);\n }\n\n // Read migrations and build migration chain model (offline — no DB needed)\n let migrations: MigrationBundleSet;\n try {\n migrations = await loadAllBundles(migrationsDir);\n } catch (error) {\n if (MigrationToolsError.is(error)) {\n return notOk(mapMigrationToolsError(error));\n }\n throw error;\n }\n\n // Defense in depth: re-hash every bundle and confirm the recorded\n // `migrationId` matches the on-disk `(manifest, ops)`. Catches FS\n // corruption, partial writes, and post-emit hand edits before we\n // start touching the database.\n for (const bundle of migrations.bundles) {\n const verified = verifyMigrationBundle(bundle);\n if (!verified.ok) {\n return notOk(\n errorRuntime(`Migration package is corrupt: ${bundle.dirName}`, {\n why: `Stored migrationId \"${verified.storedMigrationId}\" does not match the recomputed hash \"${verified.computedMigrationId}\" for ${migrationsRelative}/${bundle.dirName}. The migration.json or ops.json has been edited or partially written since emit.`,\n fix: `Re-emit the package by running \\`node \"${migrationsRelative}/${bundle.dirName}/migration.ts\"\\`, or restore the directory from version control.`,\n meta: {\n dirName: bundle.dirName,\n storedMigrationId: verified.storedMigrationId,\n computedMigrationId: verified.computedMigrationId,\n },\n }),\n );\n }\n }\n\n const client = createControlClient({\n family: config.family,\n target: config.target,\n adapter: config.adapter,\n driver: config.driver,\n extensionPacks: config.extensionPacks ?? [],\n });\n\n try {\n await client.connect(dbConnection);\n const marker = await client.readMarker();\n\n // --- No migrations on disk ---\n if (migrations.bundles.length === 0) {\n if (marker?.storageHash) {\n return notOk(\n errorRuntime('Database has state but no migrations exist', {\n why: `The database marker hash \"${marker.storageHash}\" exists but no migrations were found in ${migrationsRelative}`,\n fix: 'Ensure the migrations directory is correct. If the database was managed with `db init` or `db update`, run `prisma-next db sign` to update the marker.',\n meta: { markerHash: marker.storageHash, migrationsDir: migrationsRelative },\n }),\n );\n }\n // Non-empty contract + no migrations = user needs to plan first.\n if (destinationHash !== EMPTY_CONTRACT_HASH) {\n return notOk(\n errorRuntime('Current contract has no planned migrations', {\n why: `No migrations were found in ${migrationsRelative}, but current contract hash is \"${destinationHash}\"`,\n fix: 'Run `prisma-next migration plan` to create a migration for the current contract.',\n meta: { destinationHash, migrationsDir: migrationsRelative },\n }),\n );\n }\n // Empty contract + no migrations = nothing to do.\n return ok({\n ok: true,\n migrationsApplied: 0,\n migrationsTotal: 0,\n markerHash: EMPTY_CONTRACT_HASH,\n applied: [],\n summary: 'No migrations found',\n timings: { total: Date.now() - startTime },\n });\n }\n\n // --- Validate marker state ---\n\n // The empty sentinel should never appear in a real marker row — if it does,\n // the marker was corrupted and replaying all migrations would be dangerous.\n if (marker?.storageHash === EMPTY_CONTRACT_HASH) {\n return notOk(\n errorRuntime('Database marker contains the empty sentinel hash', {\n why: `The marker row exists but contains the empty sentinel value \"${EMPTY_CONTRACT_HASH}\". This should never happen — the marker should contain the hash of the last applied contract.`,\n fix: 'The marker is corrupted. Run `prisma-next db sign` to overwrite it with the correct contract hash, or drop and recreate the database.',\n meta: { markerHash: EMPTY_CONTRACT_HASH },\n }),\n );\n }\n\n const markerHash = marker?.storageHash;\n\n if (markerHash !== undefined && !migrations.graph.nodes.has(markerHash)) {\n return notOk(\n errorRuntime('Database marker does not match any known migration', {\n why: `The database marker hash \"${markerHash}\" is not found in the migration history at ${migrationsRelative}`,\n fix: 'Ensure the migrations directory matches this database. If the database was managed with `db init` or `db update`, run `prisma-next db sign` to update the marker.',\n meta: { markerHash, knownNodes: [...migrations.graph.nodes] },\n }),\n );\n }\n\n if (!migrations.graph.nodes.has(destinationHash)) {\n return notOk(\n errorRuntime('Current contract has no planned migration path', {\n why: `Current contract hash \"${destinationHash}\" is not present in the migration history at ${migrationsRelative}`,\n fix: 'Run `prisma-next migration plan` to create a migration for the current contract, then re-run apply.',\n meta: { destinationHash, knownNodes: [...migrations.graph.nodes] },\n }),\n );\n }\n\n // --- Resolve path and apply ---\n\n // \"No marker\" means the database is fresh — start from the empty contract hash.\n const originHash = markerHash ?? EMPTY_CONTRACT_HASH;\n\n const decision = findPathWithDecision(migrations.graph, originHash, destinationHash, refName);\n if (!decision) {\n return notOk(\n errorRuntime('No migration path from current state to target', {\n why: `Cannot find a path from \"${originHash}\" to target \"${destinationHash}\"`,\n fix: 'Check the migration history for gaps or inconsistencies.',\n meta: { markerHash: originHash, destinationHash },\n }),\n );\n }\n\n const pendingPath = decision.selectedPath;\n const pathDecision = toPathDecisionResult(decision);\n\n if (pendingPath.length === 0) {\n return ok({\n ok: true,\n migrationsApplied: 0,\n migrationsTotal: 0,\n markerHash: originHash,\n applied: [],\n summary: 'Already up to date',\n pathDecision,\n timings: { total: Date.now() - startTime },\n });\n }\n\n const bundleByDir = new Map(migrations.bundles.map((b) => [b.dirName, b]));\n const pendingMigrations: MigrationApplyStep[] = [];\n for (const migration of pendingPath) {\n const pkg = bundleByDir.get(migration.dirName);\n if (!pkg) {\n return notOk(\n errorRuntime(`Migration package not found: ${migration.dirName}`, {\n why: `The migration directory for path segment ${migration.from} → ${migration.to} was not found`,\n fix: 'Ensure all migration directories are present and intact.',\n }),\n );\n }\n pendingMigrations.push(packageToStep(pkg));\n }\n\n if (!flags.quiet && !flags.json) {\n for (const migration of pendingMigrations) {\n ui.step(`Pending ${migration.dirName}`);\n }\n }\n\n const applyResult = await client.migrationApply({\n originHash,\n destinationHash,\n pendingMigrations,\n });\n\n if (!applyResult.ok) {\n return notOk(mapApplyFailure(applyResult.failure));\n }\n\n const { value } = applyResult;\n\n return ok({\n ok: true,\n migrationsApplied: value.migrationsApplied,\n migrationsTotal: pendingPath.length,\n markerHash: value.markerHash,\n applied: value.applied,\n summary: value.summary,\n pathDecision,\n timings: { total: Date.now() - startTime },\n });\n } catch (error) {\n if (CliStructuredError.is(error)) {\n return notOk(error);\n }\n return notOk(\n errorUnexpected(error instanceof Error ? error.message : String(error), {\n why: `Unexpected error during migration apply: ${error instanceof Error ? error.message : String(error)}`,\n }),\n );\n } finally {\n await client.close();\n }\n}\n\nexport function createMigrationApplyCommand(): Command {\n const command = new Command('apply');\n setCommandDescriptions(\n command,\n 'Apply planned migrations to the database',\n 'Applies previously planned migrations (created by `migration plan`) to a live database.\\n' +\n 'Compares the database marker against the migration history to determine which\\n' +\n 'migrations are pending, then executes them sequentially. Each migration runs\\n' +\n 'in its own transaction. Does not plan new migrations — run `migration plan` first.',\n );\n setCommandExamples(command, ['prisma-next migration apply --db $DATABASE_URL']);\n addGlobalOptions(command)\n .option('--db <url>', 'Database connection string')\n .option('--config <path>', 'Path to prisma-next.config.ts')\n .option('--ref <name>', 'Target ref name from migrations/refs/')\n .action(async (options: MigrationApplyCommandOptions) => {\n const flags = parseGlobalFlags(options);\n const startTime = Date.now();\n\n const ui = new TerminalUI({\n color: flags.color,\n interactive: flags.interactive,\n });\n\n const result = await executeMigrationApplyCommand(options, flags, ui, startTime);\n\n const exitCode = handleResult(result, flags, ui, (applyResult) => {\n if (flags.json) {\n ui.output(JSON.stringify(applyResult, null, 2));\n } else if (!flags.quiet) {\n ui.log(formatMigrationApplyCommandOutput(applyResult, flags));\n }\n });\n\n process.exit(exitCode);\n });\n\n return command;\n}\n"],"mappings":";;;;;;;;;;;;;;;AA4EA,SAAS,uBAAuB,OAAwC;AACtE,KAAI,oBAAoB,GAAG,MAAM,CAC/B,QAAO,aAAa,MAAM,SAAS;EACjC,KAAK,MAAM;EACX,KAAK,MAAM;EACX,MAAM;GAAE,MAAM,MAAM;GAAM,GAAI,MAAM,WAAW,EAAE;GAAG;EACrD,CAAC;AAEJ,QAAO,gBAAgB,iBAAiB,QAAQ,MAAM,UAAU,OAAO,MAAM,EAAE,EAC7E,KAAK,4CAA4C,iBAAiB,QAAQ,MAAM,UAAU,OAAO,MAAM,IACxG,CAAC;;AAGJ,SAAS,gBAAgB,SAAwD;AAC/E,QAAO,aAAa,QAAQ,SAAS;EACnC,KAAK,QAAQ,OAAO;EACpB,KAAK;EACL,MAAM,QAAQ,QAAQ,EAAE;EACzB,CAAC;;AAGJ,SAAS,cAAc,KAA0C;AAC/D,QAAO;EACL,SAAS,IAAI;EACb,MAAM,IAAI,SAAS;EACnB,IAAI,IAAI,SAAS;EACjB,Y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AID;AACD,oBAAmB,SAAS,CAAC,iDAAiD,CAAC;AAC/E,kBAAiB,QAAQ,CACtB,OAAO,cAAc,6BAA6B,CAClD,OAAO,mBAAmB,gCAAgC,CAC1D,OAAO,gBAAgB,wCAAwC,CAC/D,OAAO,OAAO,YAA0C;EACvD,MAAM,QAAQ,iBAAiB,QAAQ;EACvC,MAAM,YAAY,KAAK,KAAK;EAE5B,MAAM,KAAK,IAAI,WAAW;GACxB,OAAO,MAAM;GACb,aAAa,MAAM;GACpB,CAAC;EAIF,MAAM,WAAW,aAFF,MAAM,6BAA6B,SAAS,OAAO,IAAI,UAAU,EAE1C,OAAO,KAAK,gBAAgB;AAChE,OAAI,MAAM,KACR,IAAG,OAAO,KAAK,UAAU,aAAa,MAAM,EAAE,CAAC;YACtC,CAAC,MAAM,MAChB,IAAG,IAAI,kCAAkC,aAAa,MAAM,CAAC;IAE/D;AAEF,UAAQ,KAAK,SAAS;GACtB;AAEJ,QAAO"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { t as loadConfig } from "../config-loader-_W4T21X1.mjs";
|
|
2
2
|
import { _ as errorUnexpected, h as errorTargetMigrationNotSupported, m as errorRuntime, t as CliStructuredError } from "../cli-errors-DHq6GQGu.mjs";
|
|
3
3
|
import { t as assertFrameworkComponentsCompatible } from "../framework-components-DfZKQBQ2.mjs";
|
|
4
|
-
import { _ as formatStyledHeader, c as resolveMigrationPaths, d as setCommandExamples, m as parseGlobalFlags, n as addGlobalOptions, r as getTargetMigrations, t as handleResult, u as setCommandDescriptions } from "../result-handler-
|
|
4
|
+
import { _ as formatStyledHeader, c as resolveMigrationPaths, d as setCommandExamples, m as parseGlobalFlags, n as addGlobalOptions, r as getTargetMigrations, t as handleResult, u as setCommandDescriptions } from "../result-handler-BJwA7ufw.mjs";
|
|
5
5
|
import { t as TerminalUI } from "../terminal-ui-C5k88MmW.mjs";
|
|
6
6
|
import { Command } from "commander";
|
|
7
7
|
import { readFileSync } from "node:fs";
|
|
@@ -2,7 +2,7 @@ import { t as loadConfig } from "../config-loader-_W4T21X1.mjs";
|
|
|
2
2
|
import { _ as errorUnexpected, a as errorContractValidationFailed, f as errorMigrationPlanningFailed, h as errorTargetMigrationNotSupported, l as errorFileNotFound, m as errorRuntime, t as CliStructuredError } from "../cli-errors-DHq6GQGu.mjs";
|
|
3
3
|
import { t as assertFrameworkComponentsCompatible } from "../framework-components-DfZKQBQ2.mjs";
|
|
4
4
|
import { t as extractSqlDdl } from "../extract-sql-ddl-DDMX-9mz.mjs";
|
|
5
|
-
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-
|
|
5
|
+
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-BJwA7ufw.mjs";
|
|
6
6
|
import { t as TerminalUI } from "../terminal-ui-C5k88MmW.mjs";
|
|
7
7
|
import { Command } from "commander";
|
|
8
8
|
import { getEmittedArtifactPaths } from "@prisma-next/emitter";
|
|
@@ -1,17 +1,20 @@
|
|
|
1
1
|
import { t as CliStructuredError } from "../cli-errors-C0JhVj0c.mjs";
|
|
2
2
|
import { Command } from "commander";
|
|
3
3
|
import { Result } from "@prisma-next/utils/result";
|
|
4
|
+
import { RefEntry } from "@prisma-next/migration-tools/refs";
|
|
4
5
|
|
|
5
6
|
//#region src/commands/migration-ref.d.ts
|
|
6
7
|
interface RefSetResult {
|
|
7
8
|
readonly ok: true;
|
|
8
9
|
readonly ref: string;
|
|
9
10
|
readonly hash: string;
|
|
11
|
+
readonly invariants: readonly string[];
|
|
10
12
|
}
|
|
11
13
|
interface RefGetResult {
|
|
12
14
|
readonly ok: true;
|
|
13
15
|
readonly ref: string;
|
|
14
16
|
readonly hash: string;
|
|
17
|
+
readonly invariants: readonly string[];
|
|
15
18
|
}
|
|
16
19
|
interface RefDeleteResult {
|
|
17
20
|
readonly ok: true;
|
|
@@ -20,11 +23,10 @@ interface RefDeleteResult {
|
|
|
20
23
|
}
|
|
21
24
|
interface RefListResult {
|
|
22
25
|
readonly ok: true;
|
|
23
|
-
readonly refs: Record<string,
|
|
26
|
+
readonly refs: Record<string, RefEntry>;
|
|
24
27
|
}
|
|
25
28
|
declare function cliErrorInvalidRefName(name: string): CliStructuredError;
|
|
26
29
|
declare function cliErrorInvalidRefValue(hash: string): CliStructuredError;
|
|
27
|
-
declare function errorRefNotFound(name: string): CliStructuredError;
|
|
28
30
|
declare function executeRefSetCommand(name: string, hash: string, options: {
|
|
29
31
|
config?: string;
|
|
30
32
|
}): Promise<Result<RefSetResult, CliStructuredError>>;
|
|
@@ -39,5 +41,5 @@ declare function executeRefListCommand(options: {
|
|
|
39
41
|
}): Promise<Result<RefListResult, CliStructuredError>>;
|
|
40
42
|
declare function createMigrationRefCommand(): Command;
|
|
41
43
|
//#endregion
|
|
42
|
-
export { cliErrorInvalidRefName, cliErrorInvalidRefValue, createMigrationRefCommand,
|
|
44
|
+
export { cliErrorInvalidRefName, cliErrorInvalidRefValue, createMigrationRefCommand, executeRefDeleteCommand, executeRefGetCommand, executeRefListCommand, executeRefSetCommand };
|
|
43
45
|
//# sourceMappingURL=migration-ref.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migration-ref.d.mts","names":[],"sources":["../../src/commands/migration-ref.ts"],"sourcesContent":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"migration-ref.d.mts","names":[],"sources":["../../src/commands/migration-ref.ts"],"sourcesContent":[],"mappings":";;;;;;UAwBU,YAAA;;EAAA,SAAA,GAAA,EAAA,MAAY;EAOZ,SAAA,IAAA,EAAY,MAAA;EAOZ,SAAA,UAAe,EAAA,SAAA,MAAA,EAAA;AAAA;AAQF,UAfb,YAAA,CA6B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X1.mjs";
|
|
2
2
|
import { _ as errorUnexpected, m as errorRuntime, t as CliStructuredError } from "../cli-errors-DHq6GQGu.mjs";
|
|
3
|
-
import { h as formatCommandHelp, m as parseGlobalFlags, n as addGlobalOptions, t as handleResult, u as setCommandDescriptions } from "../result-handler-
|
|
3
|
+
import { c as resolveMigrationPaths, h as formatCommandHelp, m as parseGlobalFlags, n as addGlobalOptions, t as handleResult, u as setCommandDescriptions } from "../result-handler-BJwA7ufw.mjs";
|
|
4
4
|
import { t as TerminalUI } from "../terminal-ui-C5k88MmW.mjs";
|
|
5
5
|
import { Command } from "commander";
|
|
6
6
|
import { notOk, ok } from "@prisma-next/utils/result";
|
|
7
|
-
import {
|
|
8
|
-
import { readRefs, resolveRef, validateRefName, validateRefValue, writeRefs } from "@prisma-next/migration-tools/refs";
|
|
7
|
+
import { deleteRef, readRef, readRefs, validateRefName, validateRefValue, writeRef } from "@prisma-next/migration-tools/refs";
|
|
9
8
|
import { MigrationToolsError } from "@prisma-next/migration-tools/types";
|
|
10
9
|
|
|
11
10
|
//#region src/commands/migration-ref.ts
|
|
12
|
-
function resolveRefsPath(configPath, config) {
|
|
13
|
-
return resolve(configPath ? resolve(configPath, "..") : process.cwd(), config?.migrations?.dir ?? "migrations", "refs.json");
|
|
14
|
-
}
|
|
15
11
|
function mapError(error) {
|
|
16
12
|
if (MigrationToolsError.is(error)) return errorRuntime(error.message, {
|
|
17
13
|
why: error.why,
|
|
@@ -32,26 +28,21 @@ function cliErrorInvalidRefValue(hash) {
|
|
|
32
28
|
fix: "Contract hashes must match the format \"sha256:<64 hex chars>\". Copy the hash from `prisma-next contract emit` or `migration status --json`."
|
|
33
29
|
});
|
|
34
30
|
}
|
|
35
|
-
function errorRefNotFound(name) {
|
|
36
|
-
return errorRuntime(`Ref "${name}" does not exist`, {
|
|
37
|
-
why: `No ref named "${name}" found in refs.json`,
|
|
38
|
-
fix: `Run \`prisma-next migration ref list\` to see available refs, or \`prisma-next migration ref set ${name} <hash>\` to create it`
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
31
|
async function executeRefSetCommand(name, hash, options) {
|
|
42
32
|
if (!validateRefName(name)) return notOk(cliErrorInvalidRefName(name));
|
|
43
33
|
if (!validateRefValue(hash)) return notOk(cliErrorInvalidRefValue(hash));
|
|
44
34
|
try {
|
|
45
35
|
const config = await loadConfig(options.config);
|
|
46
|
-
const
|
|
47
|
-
await
|
|
48
|
-
|
|
49
|
-
[
|
|
36
|
+
const { refsDir } = resolveMigrationPaths(options.config, config);
|
|
37
|
+
await writeRef(refsDir, name, {
|
|
38
|
+
hash,
|
|
39
|
+
invariants: []
|
|
50
40
|
});
|
|
51
41
|
return ok({
|
|
52
42
|
ok: true,
|
|
53
43
|
ref: name,
|
|
54
|
-
hash
|
|
44
|
+
hash,
|
|
45
|
+
invariants: []
|
|
55
46
|
});
|
|
56
47
|
} catch (error) {
|
|
57
48
|
if (error instanceof CliStructuredError) return notOk(error);
|
|
@@ -61,10 +52,13 @@ async function executeRefSetCommand(name, hash, options) {
|
|
|
61
52
|
async function executeRefGetCommand(name, options) {
|
|
62
53
|
try {
|
|
63
54
|
const config = await loadConfig(options.config);
|
|
55
|
+
const { refsDir } = resolveMigrationPaths(options.config, config);
|
|
56
|
+
const entry = await readRef(refsDir, name);
|
|
64
57
|
return ok({
|
|
65
58
|
ok: true,
|
|
66
59
|
ref: name,
|
|
67
|
-
hash:
|
|
60
|
+
hash: entry.hash,
|
|
61
|
+
invariants: entry.invariants
|
|
68
62
|
});
|
|
69
63
|
} catch (error) {
|
|
70
64
|
if (error instanceof CliStructuredError) return notOk(error);
|
|
@@ -74,11 +68,8 @@ async function executeRefGetCommand(name, options) {
|
|
|
74
68
|
async function executeRefDeleteCommand(name, options) {
|
|
75
69
|
try {
|
|
76
70
|
const config = await loadConfig(options.config);
|
|
77
|
-
const
|
|
78
|
-
|
|
79
|
-
if (!Object.hasOwn(refs, name)) return notOk(errorRefNotFound(name));
|
|
80
|
-
const { [name]: _, ...remaining } = refs;
|
|
81
|
-
await writeRefs(refsPath, remaining);
|
|
71
|
+
const { refsDir } = resolveMigrationPaths(options.config, config);
|
|
72
|
+
await deleteRef(refsDir, name);
|
|
82
73
|
return ok({
|
|
83
74
|
ok: true,
|
|
84
75
|
ref: name,
|
|
@@ -92,9 +83,10 @@ async function executeRefDeleteCommand(name, options) {
|
|
|
92
83
|
async function executeRefListCommand(options) {
|
|
93
84
|
try {
|
|
94
85
|
const config = await loadConfig(options.config);
|
|
86
|
+
const { refsDir } = resolveMigrationPaths(options.config, config);
|
|
95
87
|
return ok({
|
|
96
88
|
ok: true,
|
|
97
|
-
refs: await readRefs(
|
|
89
|
+
refs: await readRefs(refsDir)
|
|
98
90
|
});
|
|
99
91
|
} catch (error) {
|
|
100
92
|
if (error instanceof CliStructuredError) return notOk(error);
|
|
@@ -103,7 +95,7 @@ async function executeRefListCommand(options) {
|
|
|
103
95
|
}
|
|
104
96
|
function createRefSetCommand() {
|
|
105
97
|
const command = new Command("set");
|
|
106
|
-
setCommandDescriptions(command, "Set a ref to a contract hash", "Sets a named ref to point to a contract hash in migrations/refs
|
|
98
|
+
setCommandDescriptions(command, "Set a ref to a contract hash", "Sets a named ref to point to a contract hash in migrations/refs/.");
|
|
107
99
|
addGlobalOptions(command).argument("<name>", "Ref name (e.g., staging, production)").argument("<hash>", "Contract hash to point to").option("--config <path>", "Path to prisma-next.config.ts").action(async (name, hash, options) => {
|
|
108
100
|
const flags = parseGlobalFlags(options);
|
|
109
101
|
const ui = new TerminalUI({
|
|
@@ -120,7 +112,7 @@ function createRefSetCommand() {
|
|
|
120
112
|
}
|
|
121
113
|
function createRefGetCommand() {
|
|
122
114
|
const command = new Command("get");
|
|
123
|
-
setCommandDescriptions(command, "Get the hash for a ref", "Reads a named ref from migrations/refs
|
|
115
|
+
setCommandDescriptions(command, "Get the hash for a ref", "Reads a named ref from migrations/refs/ and prints its contract hash.");
|
|
124
116
|
addGlobalOptions(command).argument("<name>", "Ref name to look up").option("--config <path>", "Path to prisma-next.config.ts").action(async (name, options) => {
|
|
125
117
|
const flags = parseGlobalFlags(options);
|
|
126
118
|
const ui = new TerminalUI({
|
|
@@ -137,7 +129,7 @@ function createRefGetCommand() {
|
|
|
137
129
|
}
|
|
138
130
|
function createRefDeleteCommand() {
|
|
139
131
|
const command = new Command("delete");
|
|
140
|
-
setCommandDescriptions(command, "Delete a ref", "Removes a named ref from migrations/refs
|
|
132
|
+
setCommandDescriptions(command, "Delete a ref", "Removes a named ref from migrations/refs/.");
|
|
141
133
|
addGlobalOptions(command).argument("<name>", "Ref name to delete").option("--config <path>", "Path to prisma-next.config.ts").action(async (name, options) => {
|
|
142
134
|
const flags = parseGlobalFlags(options);
|
|
143
135
|
const ui = new TerminalUI({
|
|
@@ -154,7 +146,7 @@ function createRefDeleteCommand() {
|
|
|
154
146
|
}
|
|
155
147
|
function createRefListCommand() {
|
|
156
148
|
const command = new Command("list");
|
|
157
|
-
setCommandDescriptions(command, "List all refs", "Lists all named refs from migrations/refs
|
|
149
|
+
setCommandDescriptions(command, "List all refs", "Lists all named refs from migrations/refs/.");
|
|
158
150
|
addGlobalOptions(command).option("--config <path>", "Path to prisma-next.config.ts").action(async (options) => {
|
|
159
151
|
const flags = parseGlobalFlags(options);
|
|
160
152
|
const ui = new TerminalUI({
|
|
@@ -166,7 +158,10 @@ function createRefListCommand() {
|
|
|
166
158
|
else if (!flags.quiet) {
|
|
167
159
|
const entries = Object.entries(value.refs);
|
|
168
160
|
if (entries.length === 0) ui.output("No refs defined");
|
|
169
|
-
else for (const [refName,
|
|
161
|
+
else for (const [refName, entry] of entries) {
|
|
162
|
+
const invariantsSuffix = entry.invariants.length > 0 ? ` [invariants: ${entry.invariants.join(", ")}]` : "";
|
|
163
|
+
ui.output(`${refName} → ${entry.hash}${invariantsSuffix}`);
|
|
164
|
+
}
|
|
170
165
|
}
|
|
171
166
|
});
|
|
172
167
|
process.exit(exitCode);
|
|
@@ -175,7 +170,7 @@ function createRefListCommand() {
|
|
|
175
170
|
}
|
|
176
171
|
function createMigrationRefCommand() {
|
|
177
172
|
const command = new Command("ref");
|
|
178
|
-
setCommandDescriptions(command, "Manage migration refs", "Manage named refs in migrations/refs
|
|
173
|
+
setCommandDescriptions(command, "Manage migration refs", "Manage named refs in migrations/refs/. Refs map logical environment\nnames (e.g., staging, production) to contract hashes.");
|
|
179
174
|
addGlobalOptions(command).configureHelp({
|
|
180
175
|
formatHelp: (cmd) => formatCommandHelp({
|
|
181
176
|
command: cmd,
|
|
@@ -191,5 +186,5 @@ function createMigrationRefCommand() {
|
|
|
191
186
|
}
|
|
192
187
|
|
|
193
188
|
//#endregion
|
|
194
|
-
export { cliErrorInvalidRefName, cliErrorInvalidRefValue, createMigrationRefCommand,
|
|
189
|
+
export { cliErrorInvalidRefName, cliErrorInvalidRefValue, createMigrationRefCommand, executeRefDeleteCommand, executeRefGetCommand, executeRefListCommand, executeRefSetCommand };
|
|
195
190
|
//# sourceMappingURL=migration-ref.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migration-ref.mjs","names":[],"sources":["../../src/commands/migration-ref.ts"],"sourcesContent":["import {\n readRefs,\n resolveRef,\n validateRefName,\n validateRefValue,\n writeRefs,\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 { resolve } from 'pathe';\nimport { loadConfig } from '../config-loader';\nimport { CliStructuredError, errorRuntime, errorUnexpected } from '../utils/cli-errors';\nimport { addGlobalOptions, setCommandDescriptions } 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}\n\ninterface RefGetResult {\n readonly ok: true;\n readonly ref: string;\n readonly hash: 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, string>;\n}\n\nfunction resolveRefsPath(configPath?: string, config?: { migrations?: { dir?: string } }): string {\n const base = configPath ? resolve(configPath, '..') : process.cwd();\n return resolve(base, config?.migrations?.dir ?? 'migrations', 'refs.json');\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\nfunction errorRefNotFound(name: string): CliStructuredError {\n return errorRuntime(`Ref \"${name}\" does not exist`, {\n why: `No ref named \"${name}\" found in refs.json`,\n fix: `Run \\`prisma-next migration ref list\\` to see available refs, or \\`prisma-next migration ref set ${name} <hash>\\` to create it`,\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 refsPath = resolveRefsPath(options.config, config);\n const refs = await readRefs(refsPath);\n const updated = { ...refs, [name]: hash };\n await writeRefs(refsPath, updated);\n return ok({ ok: true as const, ref: name, hash });\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 refsPath = resolveRefsPath(options.config, config);\n const refs = await readRefs(refsPath);\n const hash = resolveRef(refs, name);\n return ok({ ok: true as const, ref: name, hash });\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 refsPath = resolveRefsPath(options.config, config);\n const refs = await readRefs(refsPath);\n if (!Object.hasOwn(refs, name)) {\n return notOk(errorRefNotFound(name));\n }\n const { [name]: _, ...remaining } = refs;\n await writeRefs(refsPath, remaining);\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 refsPath = resolveRefsPath(options.config, config);\n const refs = await readRefs(refsPath);\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.json.',\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.json 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.json.');\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(\n command,\n 'List all refs',\n 'Lists all named refs from migrations/refs.json.',\n );\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, hash] of entries) {\n ui.output(`${refName} → ${hash}`);\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 errorRefNotFound,\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.json. 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":";;;;;;;;;;;AA0CA,SAAS,gBAAgB,YAAqB,QAAoD;AAEhG,QAAO,QADM,aAAa,QAAQ,YAAY,KAAK,GAAG,QAAQ,KAAK,EAC9C,QAAQ,YAAY,OAAO,cAAc,YAAY;;AAG5E,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,OA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,IAAI,QAAQ,OAAO;AACnC,wBACE,SACA,iBACA,kDACD;AACD,kBAAiB,QAAQ,CACtB,OAAO,mBAAmB,gCAAgC,CAC1D,OAAO,OAAO,YAA2E;EACxF,MAAM,QAAQ,iBAAiB,QAAQ;EACvC,MAAM,KAAK,IAAI,WAAW;GAAE,OAAO,MAAM;GAAO,aAAa,MAAM;GAAa,CAAC;EAEjF,MAAM,WAAW,aADF,MAAM,sBAAsB,QAAQ,EACb,OAAO,KAAK,UAAU;AAC1D,OAAI,MAAM,KACR,IAAG,OAAO,KAAK,UAAU,MAAM,CAAC;YACvB,CAAC,MAAM,OAAO;IACvB,MAAM,UAAU,OAAO,QAAQ,MAAM,KAAK;AAC1C,QAAI,QAAQ,WAAW,EACrB,IAAG,OAAO,kBAAkB;QAE5B,MAAK,MAAM,CAAC,SAAS,SAAS,QAC5B,IAAG,OAAO,GAAG,QAAQ,KAAK,OAAO;;IAIvC;AACF,UAAQ,KAAK,SAAS;GACtB;AACJ,QAAO;;AAaT,SAAgB,4BAAqC;CACnD,MAAM,UAAU,IAAI,QAAQ,MAAM;AAClC,wBACE,SACA,yBACA,iIAED;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 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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AAE,OAAO,MAAM;GAAO,aAAa,MAAM;GAAa,CAAC;EAEjF,MAAM,WAAW,aADF,MAAM,sBAAsB,QAAQ,EACb,OAAO,KAAK,UAAU;AAC1D,OAAI,MAAM,KACR,IAAG,OAAO,KAAK,UAAU,MAAM,CAAC;YACvB,CAAC,MAAM,OAAO;IACvB,MAAM,UAAU,OAAO,QAAQ,MAAM,KAAK;AAC1C,QAAI,QAAQ,WAAW,EACrB,IAAG,OAAO,kBAAkB;QAE5B,MAAK,MAAM,CAAC,SAAS,UAAU,SAAS;KACtC,MAAM,mBACJ,MAAM,WAAW,SAAS,IAAI,iBAAiB,MAAM,WAAW,KAAK,KAAK,CAAC,KAAK;AAClF,QAAG,OAAO,GAAG,QAAQ,KAAK,MAAM,OAAO,mBAAmB;;;IAIhE;AACF,UAAQ,KAAK,SAAS;GACtB;AACJ,QAAO;;AAYT,SAAgB,4BAAqC;CACnD,MAAM,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,9 +1,9 @@
|
|
|
1
1
|
import { t as loadConfig } from "../config-loader-_W4T21X1.mjs";
|
|
2
2
|
import { _ as errorUnexpected, m as errorRuntime } from "../cli-errors-DHq6GQGu.mjs";
|
|
3
3
|
import { t as extractOperationStatements } from "../extract-operation-statements-DZUJNmL3.mjs";
|
|
4
|
-
import { _ as formatStyledHeader, d as setCommandExamples, m as parseGlobalFlags, n as addGlobalOptions, t as handleResult, u as setCommandDescriptions } from "../result-handler-
|
|
4
|
+
import { _ as formatStyledHeader, d as setCommandExamples, m as parseGlobalFlags, n as addGlobalOptions, t as handleResult, u as setCommandDescriptions } from "../result-handler-BJwA7ufw.mjs";
|
|
5
5
|
import { t as TerminalUI } from "../terminal-ui-C5k88MmW.mjs";
|
|
6
|
-
import { a as formatMigrationShowOutput } from "../migrations-
|
|
6
|
+
import { a as formatMigrationShowOutput } from "../migrations-fU0xoKjS.mjs";
|
|
7
7
|
import { Command } from "commander";
|
|
8
8
|
import { notOk, ok } from "@prisma-next/utils/result";
|
|
9
9
|
import { relative, resolve } from "pathe";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migration-status.d.mts","names":[],"sources":["../../src/utils/migration-types.ts","../../src/utils/formatters/graph-migration-mapper.ts","../../src/commands/migration-status.ts"],"sourcesContent":[],"mappings":";;;;UAAiB,SAAA;;;;AAAjB;AAMiB,UAAA,gBAAA,CAAgB;;;;ECWrB,SAAA,KAAA,EAAA,SAAc,MAAA,EAAA;AAmB1B;;;KAnBY,cAAA;ADjBZ;AAMiB,UC8BA,UAAA,CD9BgB;;mBCgCd;;;;ADtCF,UE2DA,oBAAA,CF3DS;EAMT,SAAA,OAAA,EAAA,MAAgB;;;;ECWrB,SAAA,cAAc,EAAA,MAAA;EAmBT,SAAA,gBAEE,EAAA,MAAA;;mBC6BA;;AAKF,UAAA,qBAAA,CAAqB;EAGN,SAAA,EAAA,EAAA,IAAA;EAIL,SAAA,IAAA,EAAA,QAAA,GAAA,SAAA;EAeM,SAAA,UAAA,EAAA,SAnBD,oBAmBC,EAAA;EACd,SAAA,UAAA,CAAA,EAAA,MAAA;EACW,SAAA,UAAA,EAAA,MAAA;EACK,SAAA,YAAA,EAAA,MAAA;EAAU,SAAA,IAAA,CAAA,EAAA,SAlBlB,SAkBkB,EAAA;EAkD7B,SAAA,YAAkB,CAAA,EAAA;
|
|
1
|
+
{"version":3,"file":"migration-status.d.mts","names":[],"sources":["../../src/utils/migration-types.ts","../../src/utils/formatters/graph-migration-mapper.ts","../../src/commands/migration-status.ts"],"sourcesContent":[],"mappings":";;;;UAAiB,SAAA;;;;AAAjB;AAMiB,UAAA,gBAAA,CAAgB;;;;ECWrB,SAAA,KAAA,EAAA,SAAc,MAAA,EAAA;AAmB1B;;;KAnBY,cAAA;ADjBZ;AAMiB,UC8BA,UAAA,CD9BgB;;mBCgCd;;;;ADtCF,UE2DA,oBAAA,CF3DS;EAMT,SAAA,OAAA,EAAA,MAAgB;;;;ECWrB,SAAA,cAAc,EAAA,MAAA;EAmBT,SAAA,gBAEE,EAAA,MAAA;;mBC6BA;;AAKF,UAAA,qBAAA,CAAqB;EAGN,SAAA,EAAA,EAAA,IAAA;EAIL,SAAA,IAAA,EAAA,QAAA,GAAA,SAAA;EAeM,SAAA,UAAA,EAAA,SAnBD,oBAmBC,EAAA;EACd,SAAA,UAAA,CAAA,EAAA,MAAA;EACW,SAAA,UAAA,EAAA,MAAA;EACK,SAAA,YAAA,EAAA,MAAA;EAAU,SAAA,IAAA,CAAA,EAAA,SAlBlB,SAkBkB,EAAA;EAkD7B,SAAA,YAAkB,CAAA,EAAA;IAsiBlB,SAAA,QAAA,EAAA,MAAA;;;;;;;;;;;;;iCA3lBiB;mBACd;8BACW;mCACK;;;;;;;;;;;;;;;;;;;;iBAkDnB,kBAAA,QACP,uHAKN;iBAgiBa,4BAAA,CAAA,GAAgC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import "../config-loader-_W4T21X1.mjs";
|
|
2
|
-
import { n as deriveEdgeStatuses, t as createMigrationStatusCommand } from "../migration-status-
|
|
2
|
+
import { n as deriveEdgeStatuses, t as createMigrationStatusCommand } from "../migration-status-Ry3TnEya.mjs";
|
|
3
3
|
|
|
4
4
|
export { createMigrationStatusCommand, deriveEdgeStatuses };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { t as loadConfig } from "./config-loader-_W4T21X1.mjs";
|
|
2
2
|
import { _ as errorUnexpected$1, a as errorContractValidationFailed, m as errorRuntime, t as CliStructuredError$1 } from "./cli-errors-DHq6GQGu.mjs";
|
|
3
3
|
import { t as createControlClient } from "./client-TG7rbCWT.mjs";
|
|
4
|
-
import { _ as formatStyledHeader, d as setCommandExamples, m as parseGlobalFlags, n as addGlobalOptions, t as handleResult, u as setCommandDescriptions, v as formatSuccessMessage, x as isVerbose } from "./result-handler-
|
|
4
|
+
import { _ as formatStyledHeader, d as setCommandExamples, m as parseGlobalFlags, n as addGlobalOptions, t as handleResult, u as setCommandDescriptions, v as formatSuccessMessage, x as isVerbose } from "./result-handler-BJwA7ufw.mjs";
|
|
5
5
|
import { t as createProgressAdapter } from "./progress-adapter-B-YvmcDu.mjs";
|
|
6
6
|
import { t as TerminalUI } from "./terminal-ui-C5k88MmW.mjs";
|
|
7
7
|
import { Command } from "commander";
|
|
@@ -192,4 +192,4 @@ function createContractEmitCommand() {
|
|
|
192
192
|
|
|
193
193
|
//#endregion
|
|
194
194
|
export { createContractEmitCommand as t };
|
|
195
|
-
//# sourceMappingURL=contract-emit-
|
|
195
|
+
//# sourceMappingURL=contract-emit-DpPjuFy-.mjs.map
|