prisma-next 0.11.0-dev.43 → 0.11.0-dev.45
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 +8 -8
- package/dist/{command-helpers-BnqwTptC.mjs → command-helpers-yLuA78TP.mjs} +226 -4
- package/dist/command-helpers-yLuA78TP.mjs.map +1 -0
- package/dist/commands/contract-emit.mjs +1 -1
- package/dist/commands/contract-infer.mjs +1 -1
- package/dist/commands/db-init.mjs +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 +1 -1
- package/dist/commands/migrate.mjs +2 -2
- package/dist/commands/migration-check.mjs +1 -1
- package/dist/commands/migration-graph.mjs +1 -1
- package/dist/commands/migration-list.d.mts +8 -1
- package/dist/commands/migration-list.d.mts.map +1 -1
- package/dist/commands/migration-list.mjs +2 -2
- package/dist/commands/migration-log.mjs +1 -1
- package/dist/commands/migration-new.mjs +1 -1
- package/dist/commands/migration-plan.d.mts +1 -1
- package/dist/commands/migration-plan.mjs +1 -1
- package/dist/commands/migration-show.mjs +2 -2
- package/dist/commands/migration-status.mjs +2 -2
- package/dist/commands/ref.mjs +1 -1
- package/dist/{contract-emit-aFcOi3aw.mjs → contract-emit-FtDVFs2Q.mjs} +2 -2
- package/dist/{contract-emit-aFcOi3aw.mjs.map → contract-emit-FtDVFs2Q.mjs.map} +1 -1
- package/dist/{contract-infer-BpJeg-Eu.mjs → contract-infer-CVMuoJKk.mjs} +3 -3
- package/dist/{contract-infer-BpJeg-Eu.mjs.map → contract-infer-CVMuoJKk.mjs.map} +1 -1
- package/dist/{db-verify-CxtdGiL3.mjs → db-verify-B00o3LuC.mjs} +3 -3
- package/dist/{db-verify-CxtdGiL3.mjs.map → db-verify-B00o3LuC.mjs.map} +1 -1
- package/dist/exports/index.mjs +1 -1
- package/dist/exports/init-output.d.mts.map +1 -1
- package/dist/{global-flags-CdE7M0d9.d.mts → global-flags-Dvibm2yu.d.mts} +1 -1
- package/dist/{global-flags-CdE7M0d9.d.mts.map → global-flags-Dvibm2yu.d.mts.map} +1 -1
- package/dist/{init-eGkSo7hi.mjs → init-BKgB6EKw.mjs} +2 -2
- package/dist/{init-eGkSo7hi.mjs.map → init-BKgB6EKw.mjs.map} +1 -1
- package/dist/{inspect-live-schema-B1GCyjAJ.mjs → inspect-live-schema-BXUd6RfS.mjs} +2 -2
- package/dist/{inspect-live-schema-B1GCyjAJ.mjs.map → inspect-live-schema-BXUd6RfS.mjs.map} +1 -1
- package/dist/{migration-command-scaffold-CNdZl60X.mjs → migration-command-scaffold-3l3EdmSD.mjs} +2 -2
- package/dist/{migration-command-scaffold-CNdZl60X.mjs.map → migration-command-scaffold-3l3EdmSD.mjs.map} +1 -1
- package/dist/{migration-list-CnYiHrNV.mjs → migration-list-DopkAG7L.mjs} +40 -49
- package/dist/migration-list-DopkAG7L.mjs.map +1 -0
- package/dist/migration-list-graph-render-C-daUZLU.d.mts +7 -0
- package/dist/migration-list-graph-render-C-daUZLU.d.mts.map +1 -0
- package/dist/{migration-plan-ulpJu26J.mjs → migration-plan-BHoeET4O.mjs} +2 -2
- package/dist/{migration-plan-ulpJu26J.mjs.map → migration-plan-BHoeET4O.mjs.map} +1 -1
- package/dist/{migrations-C7YTBnLy.mjs → migrations-D-UCOGtk.mjs} +2 -2
- package/dist/{migrations-C7YTBnLy.mjs.map → migrations-D-UCOGtk.mjs.map} +1 -1
- package/dist/{verify-DX4RQwq4.mjs → verify-9gDJz6cm.mjs} +2 -2
- package/dist/{verify-DX4RQwq4.mjs.map → verify-9gDJz6cm.mjs.map} +1 -1
- package/package.json +11 -11
- package/dist/command-helpers-BnqwTptC.mjs.map +0 -1
- package/dist/migration-list-CnYiHrNV.mjs.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { t as loadConfig } from "./config-loader-B6sJjXTv.mjs";
|
|
2
2
|
import { O as errorUnexpected, c as errorDriverRequired, o as errorDatabaseConnectionRequired, t as CliStructuredError } from "./cli-errors-DFF1LlfU.mjs";
|
|
3
|
-
import {
|
|
3
|
+
import { A as formatStyledHeader, o as maskConnectionUrl, u as sanitizeErrorMessage } from "./command-helpers-yLuA78TP.mjs";
|
|
4
4
|
import { t as createProgressAdapter } from "./progress-adapter-xASh41wr.mjs";
|
|
5
5
|
import { t as createControlClient } from "./client-a5NJce0-.mjs";
|
|
6
6
|
import { notOk, ok } from "@prisma-next/utils/result";
|
|
@@ -87,4 +87,4 @@ async function inspectLiveSchema(options, flags, ui, startTime, context) {
|
|
|
87
87
|
//#endregion
|
|
88
88
|
export { inspectLiveSchema as t };
|
|
89
89
|
|
|
90
|
-
//# sourceMappingURL=inspect-live-schema-
|
|
90
|
+
//# sourceMappingURL=inspect-live-schema-BXUd6RfS.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inspect-live-schema-
|
|
1
|
+
{"version":3,"file":"inspect-live-schema-BXUd6RfS.mjs","names":[],"sources":["../src/commands/inspect-live-schema.ts"],"sourcesContent":["import type { CoreSchemaView } from '@prisma-next/framework-components/control';\nimport type { PslDocumentAst } from '@prisma-next/framework-components/psl-ast';\nimport { notOk, ok, type Result } from '@prisma-next/utils/result';\nimport { relative, resolve } from 'pathe';\nimport { loadConfig } from '../config-loader';\nimport { createControlClient } from '../control-api/client';\nimport {\n CliStructuredError,\n errorDatabaseConnectionRequired,\n errorDriverRequired,\n errorUnexpected,\n} from '../utils/cli-errors';\nimport { maskConnectionUrl, sanitizeErrorMessage } from '../utils/command-helpers';\nimport { formatStyledHeader } from '../utils/formatters/styled';\nimport type { CommonCommandOptions, GlobalFlags } from '../utils/global-flags';\nimport { createProgressAdapter } from '../utils/progress-adapter';\nimport type { TerminalUI } from '../utils/terminal-ui';\n\nexport interface InspectLiveSchemaOptions extends CommonCommandOptions {\n readonly db?: string;\n readonly config?: string;\n}\n\ninterface InspectLiveSchemaContext {\n readonly commandName: string;\n readonly description: string;\n readonly url: string;\n}\n\ntype LoadedCliConfig = Awaited<ReturnType<typeof loadConfig>>;\n\nexport interface InspectLiveSchemaResult {\n readonly config: LoadedCliConfig;\n readonly schema: unknown;\n readonly schemaView: CoreSchemaView | undefined;\n /**\n * PSL AST inferred from the introspected schema, when the configured family\n * implements `PslContractInferCapable`. `undefined` for families that do not\n * support inference (e.g. Mongo today).\n */\n readonly pslContractAst: PslDocumentAst | undefined;\n readonly target: {\n readonly familyId: string;\n readonly id: string;\n };\n readonly meta: {\n readonly configPath?: string;\n readonly dbUrl?: string;\n };\n readonly timings: {\n readonly total: number;\n };\n}\n\nexport async function inspectLiveSchema(\n options: InspectLiveSchemaOptions,\n flags: GlobalFlags,\n ui: TerminalUI,\n startTime: number,\n context: InspectLiveSchemaContext,\n): Promise<Result<InspectLiveSchemaResult, CliStructuredError>> {\n let config: LoadedCliConfig;\n try {\n config = await loadConfig(options.config);\n } catch (error) {\n if (CliStructuredError.is(error)) {\n return notOk(error);\n }\n\n return notOk(\n errorUnexpected(error instanceof Error ? error.message : String(error), {\n why: 'Failed to load config',\n }),\n );\n }\n\n const configPath = options.config\n ? relative(process.cwd(), resolve(options.config))\n : 'prisma-next.config.ts';\n\n if (!flags.json && !flags.quiet) {\n const details: Array<{ label: string; value: string }> = [\n { label: 'config', value: configPath },\n ];\n\n if (options.db) {\n details.push({ label: 'database', value: maskConnectionUrl(options.db) });\n } else if (config.db?.connection && typeof config.db.connection === 'string') {\n details.push({ label: 'database', value: maskConnectionUrl(config.db.connection) });\n }\n\n ui.stderr(\n formatStyledHeader({\n command: context.commandName,\n description: context.description,\n url: context.url,\n details,\n flags,\n }),\n );\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 ${context.commandName} (set db.connection in ${configPath}, or pass --db <url>)`,\n commandName: context.commandName,\n }),\n );\n }\n\n if (!config.driver) {\n return notOk(\n errorDriverRequired({\n why: `Config.driver is required for ${context.commandName}`,\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 const onProgress = createProgressAdapter({ ui, flags });\n\n try {\n const schema = await client.introspect({\n connection: dbConnection,\n onProgress,\n });\n const schemaView = client.toSchemaView(schema);\n const pslContractAst = client.inferPslContract(schema);\n\n const dbUrl = typeof dbConnection === 'string' ? maskConnectionUrl(dbConnection) : undefined;\n\n return ok({\n config,\n schema,\n schemaView,\n pslContractAst,\n target: {\n familyId: config.family.familyId,\n id: config.target.targetId,\n },\n meta: {\n configPath,\n ...(dbUrl ? { dbUrl } : {}),\n },\n timings: {\n total: Date.now() - startTime,\n },\n });\n } catch (error) {\n if (CliStructuredError.is(error)) {\n return notOk(error);\n }\n\n const rawMessage = error instanceof Error ? error.message : String(error);\n const safeMessage = sanitizeErrorMessage(\n rawMessage,\n typeof dbConnection === 'string' ? dbConnection : undefined,\n );\n return notOk(\n errorUnexpected(safeMessage, {\n why: `Unexpected error during ${context.commandName}: ${safeMessage}`,\n }),\n );\n } finally {\n await client.close();\n }\n}\n"],"mappings":";;;;;;;;AAsDA,eAAsB,kBACpB,SACA,OACA,IACA,WACA,SAC8D;CAC9D,IAAI;CACJ,IAAI;EACF,SAAS,MAAM,WAAW,QAAQ,MAAM;CAC1C,SAAS,OAAO;EACd,IAAI,mBAAmB,GAAG,KAAK,GAC7B,OAAO,MAAM,KAAK;EAGpB,OAAO,MACL,gBAAgB,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,GAAG,EACtE,KAAK,wBACP,CAAC,CACH;CACF;CAEA,MAAM,aAAa,QAAQ,SACvB,SAAS,QAAQ,IAAI,GAAG,QAAQ,QAAQ,MAAM,CAAC,IAC/C;CAEJ,IAAI,CAAC,MAAM,QAAQ,CAAC,MAAM,OAAO;EAC/B,MAAM,UAAmD,CACvD;GAAE,OAAO;GAAU,OA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,KAAK,IAAI,IAAI,UACtB;EACF,CAAC;CACH,SAAS,OAAO;EACd,IAAI,mBAAmB,GAAG,KAAK,GAC7B,OAAO,MAAM,KAAK;EAIpB,MAAM,cAAc,qBADD,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,GAGtE,OAAO,iBAAiB,WAAW,eAAe,KAAA,CACpD;EACA,OAAO,MACL,gBAAgB,aAAa,EAC3B,KAAK,2BAA2B,QAAQ,YAAY,IAAI,cAC1D,CAAC,CACH;CACF,UAAU;EACR,MAAM,OAAO,MAAM;CACrB;AACF"}
|
package/dist/{migration-command-scaffold-CNdZl60X.mjs → migration-command-scaffold-3l3EdmSD.mjs}
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { t as loadConfig } from "./config-loader-B6sJjXTv.mjs";
|
|
2
2
|
import { E as errorTargetMigrationNotSupported, O as errorUnexpected, a as errorContractValidationFailed, c as errorDriverRequired, l as errorFileNotFound, o as errorDatabaseConnectionRequired } from "./cli-errors-DFF1LlfU.mjs";
|
|
3
|
-
import {
|
|
3
|
+
import { A as formatStyledHeader, c as resolveContractPath, o as maskConnectionUrl, t as addGlobalOptions } from "./command-helpers-yLuA78TP.mjs";
|
|
4
4
|
import { t as createProgressAdapter } from "./progress-adapter-xASh41wr.mjs";
|
|
5
5
|
import { t as createControlClient } from "./client-a5NJce0-.mjs";
|
|
6
6
|
import { notOk, ok } from "@prisma-next/utils/result";
|
|
@@ -101,4 +101,4 @@ function addMigrationCommandOptions(command) {
|
|
|
101
101
|
//#endregion
|
|
102
102
|
export { prepareMigrationContext as n, addMigrationCommandOptions as t };
|
|
103
103
|
|
|
104
|
-
//# sourceMappingURL=migration-command-scaffold-
|
|
104
|
+
//# sourceMappingURL=migration-command-scaffold-3l3EdmSD.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migration-command-scaffold-
|
|
1
|
+
{"version":3,"file":"migration-command-scaffold-3l3EdmSD.mjs","names":[],"sources":["../src/utils/migration-command-scaffold.ts"],"sourcesContent":["import { readFile } from 'node:fs/promises';\nimport { relative, resolve } from 'node:path';\nimport { hasMigrations } from '@prisma-next/framework-components/control';\nimport { notOk, ok, type Result } from '@prisma-next/utils/result';\nimport type { Command } from 'commander';\nimport { loadConfig } from '../config-loader';\nimport { createControlClient } from '../control-api/client';\nimport type { ControlClient } from '../control-api/types';\nimport {\n type CliStructuredError,\n errorContractValidationFailed,\n errorDatabaseConnectionRequired,\n errorDriverRequired,\n errorFileNotFound,\n errorTargetMigrationNotSupported,\n errorUnexpected,\n} from './cli-errors';\nimport { addGlobalOptions, maskConnectionUrl, resolveContractPath } from './command-helpers';\nimport { formatStyledHeader } from './formatters/styled';\nimport type { GlobalFlags } from './global-flags';\nimport { createProgressAdapter } from './progress-adapter';\nimport type { TerminalUI } from './terminal-ui';\n\n/**\n * Resolved context for a migration command.\n * Contains everything needed to invoke a control-api operation.\n */\nexport interface MigrationContext {\n readonly client: ControlClient;\n readonly contractJson: Record<string, unknown>;\n readonly dbConnection: unknown;\n readonly onProgress: ReturnType<typeof createProgressAdapter>;\n readonly configPath: string;\n readonly contractPath: string;\n readonly contractPathAbsolute: string;\n readonly config: Awaited<ReturnType<typeof loadConfig>>;\n}\n\n/**\n * Command-specific configuration for the shared scaffold.\n */\nexport interface MigrationCommandDescriptor {\n readonly commandName: string;\n readonly description: string;\n readonly url: string;\n}\n\n/**\n * Prepares the shared context for migration commands (db init, db update).\n *\n * Handles: config loading, contract file reading, JSON parsing, connection resolution,\n * driver/migration-support validation, client creation, and header output.\n *\n * Returns a Result with either the resolved context or a structured error.\n */\nexport async function prepareMigrationContext(\n options: { readonly db?: string; readonly config?: string; readonly dryRun?: boolean },\n flags: GlobalFlags,\n ui: TerminalUI,\n descriptor: MigrationCommandDescriptor,\n): Promise<Result<MigrationContext, CliStructuredError>> {\n // Load config\n const config = await loadConfig(options.config);\n const configPath = options.config\n ? relative(process.cwd(), resolve(options.config))\n : 'prisma-next.config.ts';\n const contractPathAbsolute = resolveContractPath(config);\n const contractPath = relative(process.cwd(), contractPathAbsolute);\n\n // Output header to stderr (decoration)\n if (!flags.json && !flags.quiet) {\n const details: Array<{ label: string; value: string }> = [\n { label: 'config', value: configPath },\n { label: 'contract', value: contractPath },\n ];\n if (options.db) {\n details.push({ label: 'database', value: maskConnectionUrl(options.db) });\n }\n if (options.dryRun) {\n details.push({ label: 'mode', value: 'dry run' });\n }\n const header = formatStyledHeader({\n command: descriptor.commandName,\n description: descriptor.description,\n url: descriptor.url,\n details,\n flags,\n });\n ui.stderr(header);\n }\n\n // Load contract file\n let contractJsonContent: string;\n try {\n contractJsonContent = await readFile(contractPathAbsolute, 'utf-8');\n } catch (error) {\n if (error instanceof Error && (error as { code?: string }).code === 'ENOENT') {\n return notOk(\n errorFileNotFound(contractPathAbsolute, {\n why: `Contract file not found at ${contractPathAbsolute}`,\n fix: `Run \\`prisma-next contract emit\\` to generate ${contractPath}, or update \\`config.contract.output\\` in ${configPath}`,\n }),\n );\n }\n return notOk(\n errorUnexpected(error instanceof Error ? error.message : String(error), {\n why: `Failed to read contract file: ${error instanceof Error ? error.message : String(error)}`,\n }),\n );\n }\n\n // Parse contract JSON\n let contractJson: Record<string, unknown>;\n try {\n contractJson = JSON.parse(contractJsonContent) as Record<string, unknown>;\n } catch (error) {\n return notOk(\n errorContractValidationFailed(\n `Contract JSON is invalid: ${error instanceof Error ? error.message : String(error)}`,\n { where: { path: contractPathAbsolute } },\n ),\n );\n }\n\n // Resolve database connection (--db flag or config.db.connection)\n const dbConnection = options.db ?? config.db?.connection;\n if (!dbConnection) {\n return notOk(\n errorDatabaseConnectionRequired({\n why: `Database connection is required for ${descriptor.commandName} (set db.connection in ${configPath}, or pass --db <url>)`,\n commandName: descriptor.commandName,\n }),\n );\n }\n\n // Check for driver\n if (!config.driver) {\n return notOk(\n errorDriverRequired({ why: `Config.driver is required for ${descriptor.commandName}` }),\n );\n }\n\n if (!hasMigrations(config.target)) {\n return notOk(\n errorTargetMigrationNotSupported({\n why: `Target \"${config.target.id}\" does not support migrations`,\n }),\n );\n }\n\n // Create control client\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 // Create progress adapter\n const onProgress = createProgressAdapter({ ui, flags });\n\n return ok({\n client,\n contractJson,\n dbConnection,\n onProgress,\n configPath,\n contractPath,\n contractPathAbsolute,\n config,\n });\n}\n\n/**\n * Registers the shared CLI options for migration commands (db init, db update).\n */\nexport function addMigrationCommandOptions(command: Command): Command {\n addGlobalOptions(command);\n return command\n .option('--db <url>', 'Database connection string')\n .option('--config <path>', 'Path to prisma-next.config.ts')\n .option('--dry-run', 'Preview planned operations without applying', false);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAuDA,eAAsB,wBACpB,SACA,OACA,IACA,YACuD;CAEvD,MAAM,SAAS,MAAM,WAAW,QAAQ,MAAM;CAC9C,MAAM,aAAa,QAAQ,SACvB,SAAS,QAAQ,IAAI,GAAG,QAAQ,QAAQ,MAAM,CAAC,IAC/C;CACJ,MAAM,uBAAuB,oBAAoB,MAAM;CACvD,MAAM,eAAe,SAAS,QAAQ,IAAI,GAAG,oBAAoB;CAGjE,IAAI,CAAC,MAAM,QAAQ,CAAC,MAAM,OAAO;EAC/B,MAAM,UAAmD,CACvD;GAAE,OAAO;GAAU,OAAO;EAAW,GACrC;GAAE,OAAO;GAAY,OAAO;EAAa,CAC3C;EACA,IAAI,QAAQ,IACV,QAAQ,KAAK;GAAE,OAAO;GAAY,OAAO,kBAAkB,QAAQ,EAAE;EAAE,CAAC;EAE1E,IAAI,QAAQ,QACV,QAAQ,KAAK;GAAE,OAAO;GAAQ,OAAO;EAAU,CAAC;EAElD,MAAM,SAAS,mBAAmB;GAChC,SAAS,WAAW;GACpB,aAAa,WAAW;GACxB,KAAK,WAAW;GAChB;GACA;EACF,CAAC;EACD,GAAG,OAAO,MAAM;CAClB;CAGA,IAAI;CACJ,IA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B,2BAA2B,SAA2B;CACpE,iBAAiB,OAAO;CACxB,OAAO,QACJ,OAAO,cAAc,4BAA4B,EACjD,OAAO,mBAAmB,+BAA+B,EACzD,OAAO,aAAa,+CAA+C,KAAK;AAC7E"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { t as loadConfig } from "./config-loader-B6sJjXTv.mjs";
|
|
2
2
|
import { O as errorUnexpected, T as errorSpaceNotFound, f as errorInvalidSpaceId, k as mapMigrationToolsError } from "./cli-errors-DFF1LlfU.mjs";
|
|
3
|
-
import {
|
|
3
|
+
import { A as formatStyledHeader, C as formatMigrationDataColumn, S as computeMigrationDirNameWidth, d as setCommandDescriptions, f as setCommandExamples, l as resolveMigrationPaths, p as setCommandSeeAlso, t as addGlobalOptions, v as parseGlobalFlagsOrExit, w as handleResult, x as renderMigrationListGraphResult, y as createTerminalUI } from "./command-helpers-yLuA78TP.mjs";
|
|
4
4
|
import { Command } from "commander";
|
|
5
5
|
import { ifDefined } from "@prisma-next/utils/defined";
|
|
6
6
|
import { notOk, ok } from "@prisma-next/utils/result";
|
|
@@ -8,47 +8,36 @@ import { APP_SPACE_ID, isValidSpaceId } from "@prisma-next/migration-tools/space
|
|
|
8
8
|
import { bold, cyan, cyanBright, dim, green, greenBright, yellow } from "colorette";
|
|
9
9
|
import { MigrationToolsError } from "@prisma-next/migration-tools/errors";
|
|
10
10
|
import { enumerateMigrationSpaces } from "@prisma-next/migration-tools/enumerate-migration-spaces";
|
|
11
|
+
import { classifyMigrationListGraphTopology } from "@prisma-next/migration-tools/migration-list-graph-topology";
|
|
11
12
|
//#region src/utils/formatters/migration-list-render.ts
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
const KIND_GLYPH = {
|
|
14
|
+
forward: "*",
|
|
15
|
+
rollback: "↩",
|
|
16
|
+
self: "⟲"
|
|
17
|
+
};
|
|
17
18
|
const IDENTITY_MIGRATION_LIST_STYLER = {
|
|
19
|
+
kind: (text) => text,
|
|
18
20
|
dirName: (text) => text,
|
|
19
21
|
sourceHash: (text) => text,
|
|
20
22
|
destHash: (text) => text,
|
|
21
23
|
glyph: (text) => text,
|
|
24
|
+
lane: (text) => text,
|
|
22
25
|
invariants: (ids) => `{${ids.join(", ")}}`,
|
|
23
26
|
refs: (names) => `(${names.join(", ")})`,
|
|
24
27
|
spaceHeading: (text) => text,
|
|
25
28
|
summary: (text) => text,
|
|
26
29
|
emptyState: (text) => text
|
|
27
30
|
};
|
|
28
|
-
function
|
|
29
|
-
return
|
|
30
|
-
}
|
|
31
|
-
function formatSourceColumn(from, style) {
|
|
32
|
-
if (from === null) return style.glyph(EMPTY_SOURCE) + " ".repeat(HASH_WIDTH - 1);
|
|
33
|
-
return style.sourceHash(abbreviateContractHash(from));
|
|
34
|
-
}
|
|
35
|
-
function formatDestColumn(from, to, style) {
|
|
36
|
-
if (from !== null && from === to) return " ".repeat(HASH_WIDTH);
|
|
37
|
-
return style.destHash(abbreviateContractHash(to));
|
|
38
|
-
}
|
|
39
|
-
function formatArrowGlyph(from, to, style) {
|
|
40
|
-
return style.glyph(from !== null && from === to ? SELF_EDGE_GLYPH : FORWARD_EDGE_GLYPH);
|
|
41
|
-
}
|
|
42
|
-
function formatDecorations(providedInvariants, refs, style) {
|
|
43
|
-
const blocks = [];
|
|
44
|
-
if (providedInvariants.length > 0) blocks.push(style.invariants(providedInvariants));
|
|
45
|
-
if (refs.length > 0) blocks.push(style.refs(refs));
|
|
46
|
-
if (blocks.length === 0) return "";
|
|
47
|
-
return `${DECORATION_PREFIX}${blocks.join(" ")}`;
|
|
31
|
+
function resolveEdgeKind(migrationHash, kindByMigrationHash) {
|
|
32
|
+
return kindByMigrationHash.get(migrationHash) ?? "forward";
|
|
48
33
|
}
|
|
49
|
-
function formatMigrationRow(migration, dirNameWidth, style) {
|
|
50
|
-
|
|
51
|
-
|
|
34
|
+
function formatMigrationRow(migration, dirNameWidth, edgeKind, style) {
|
|
35
|
+
return `${`${style.kind(KIND_GLYPH[edgeKind])} `}${formatMigrationDataColumn(migration, {
|
|
36
|
+
dirNameWidth,
|
|
37
|
+
edgeKind,
|
|
38
|
+
style,
|
|
39
|
+
forwardArrow: "→"
|
|
40
|
+
})}`;
|
|
52
41
|
}
|
|
53
42
|
function formatEmptyStateLine(spaceId, style) {
|
|
54
43
|
return style.emptyState(`There are no migrations in migrations/${spaceId}/ yet`);
|
|
@@ -59,8 +48,9 @@ function renderSpaceBlock(spaceId, migrations, multiSpace, style) {
|
|
|
59
48
|
if (!multiSpace) return [emptyLine];
|
|
60
49
|
return [style.spaceHeading(`${spaceId}:`), ` ${emptyLine}`];
|
|
61
50
|
}
|
|
62
|
-
const
|
|
63
|
-
const
|
|
51
|
+
const kindByMigrationHash = classifyMigrationListGraphTopology(migrations).kindByMigrationHash;
|
|
52
|
+
const dirNameWidth = computeMigrationDirNameWidth(migrations);
|
|
53
|
+
const rows = migrations.map((entry) => formatMigrationRow(entry, dirNameWidth, resolveEdgeKind(entry.migrationHash, kindByMigrationHash), style));
|
|
64
54
|
if (!multiSpace) return rows;
|
|
65
55
|
return [style.spaceHeading(`${spaceId}:`), ...rows.map((row) => ` ${row}`)];
|
|
66
56
|
}
|
|
@@ -110,6 +100,7 @@ function styleRefName(name) {
|
|
|
110
100
|
* - `sourceHash`: dim cyan
|
|
111
101
|
* - `destHash`: bright cyan
|
|
112
102
|
* - `glyph` (`→` / `⟲` / `∅`): dim
|
|
103
|
+
* - `lane` (graph gutter lines `│` and fan/join connectors `├─┐` / `├─┘`): dim
|
|
113
104
|
* - `invariants` (`{...}`): yellow
|
|
114
105
|
* - `refs` (`(...)`): green; the live-DB `db` marker inside is green-bold
|
|
115
106
|
* - `spaceHeading` (`<spaceId>:`): bold
|
|
@@ -119,10 +110,12 @@ function styleRefName(name) {
|
|
|
119
110
|
function createAnsiMigrationListStyler(opts) {
|
|
120
111
|
if (!opts.useColor) return IDENTITY_MIGRATION_LIST_STYLER;
|
|
121
112
|
return {
|
|
113
|
+
kind: (text) => dim(text),
|
|
122
114
|
dirName: (text) => bold(text),
|
|
123
115
|
sourceHash: (text) => dim(cyan(text)),
|
|
124
116
|
destHash: (text) => cyanBright(text),
|
|
125
117
|
glyph: (text) => dim(text),
|
|
118
|
+
lane: (text) => dim(text),
|
|
126
119
|
invariants: (ids) => yellow(`{${ids.join(", ")}}`),
|
|
127
120
|
refs: (names) => {
|
|
128
121
|
const open = green("(");
|
|
@@ -137,16 +130,11 @@ function createAnsiMigrationListStyler(opts) {
|
|
|
137
130
|
}
|
|
138
131
|
//#endregion
|
|
139
132
|
//#region src/commands/migration-list.ts
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
*
|
|
146
|
-
* The renderer suppresses the summary line when `totalMigrations === 0`
|
|
147
|
-
* — the empty-state line carries enough information on its own — so
|
|
148
|
-
* this function always returns a string even for the empty-state.
|
|
149
|
-
*/
|
|
133
|
+
function renderMigrationListHumanOutput(result, options) {
|
|
134
|
+
const styler = createAnsiMigrationListStyler({ useColor: options.useColor });
|
|
135
|
+
if (options.graph) return renderMigrationListGraphResult(result, styler, options.glyphMode);
|
|
136
|
+
return renderMigrationListWithStyle(result, styler);
|
|
137
|
+
}
|
|
150
138
|
function computeSummary(spaces) {
|
|
151
139
|
const totalMigrations = spaces.reduce((count, space) => count + space.migrations.length, 0);
|
|
152
140
|
if (spaces.length <= 1) return `${totalMigrations} migration(s) on disk`;
|
|
@@ -244,10 +232,12 @@ async function executeMigrationListCommand(options, flags, ui) {
|
|
|
244
232
|
}
|
|
245
233
|
function createMigrationListCommand() {
|
|
246
234
|
const command = new Command("list");
|
|
247
|
-
setCommandDescriptions(command, "List on-disk migrations, latest first, per contract space", "Enumerates every on-disk migration under migrations/<space>/ for every\ncontract space found on disk, latest first. Offline — does not consult\nthe database. Each row
|
|
235
|
+
setCommandDescriptions(command, "List on-disk migrations, latest first, per contract space", "Enumerates every on-disk migration under migrations/<space>/ for every\ncontract space found on disk, latest first. Offline — does not consult\nthe database. Each row leads with a kind glyph (* forward, ↩ rollback,\n⟲ self), then dirName, then source → destination contract hashes\n(7-char git-style). Self-edges show a single hash. Invariants render as\n{...}; refs on the destination as (production, db). Pass --space <id>\nto narrow to one contract space. --graph draws the forward spine with\nlane gutters; --ascii forces ASCII glyphs (orthogonal to --no-color).");
|
|
248
236
|
setCommandExamples(command, [
|
|
249
237
|
"prisma-next migration list",
|
|
238
|
+
"prisma-next migration list --graph",
|
|
250
239
|
"prisma-next migration list --space app",
|
|
240
|
+
"prisma-next migration list --graph --ascii",
|
|
251
241
|
"prisma-next migration list --json"
|
|
252
242
|
]);
|
|
253
243
|
setCommandSeeAlso(command, [
|
|
@@ -268,21 +258,22 @@ function createMigrationListCommand() {
|
|
|
268
258
|
oneLiner: "Display migration package contents"
|
|
269
259
|
}
|
|
270
260
|
]);
|
|
271
|
-
addGlobalOptions(command).option("--config <path>", "Path to prisma-next.config.ts").option("--space <id>", "Narrow output to a single contract space").action(async (options) => {
|
|
261
|
+
addGlobalOptions(command).option("--config <path>", "Path to prisma-next.config.ts").option("--space <id>", "Narrow output to a single contract space").option("--graph", "Draw migration relationships as an annotated tree").option("--ascii", "Use ASCII glyphs for --graph (pipe-friendly)").action(async (options) => {
|
|
272
262
|
const flags = parseGlobalFlagsOrExit(options);
|
|
273
263
|
const ui = createTerminalUI(flags);
|
|
274
264
|
const exitCode = handleResult(await executeMigrationListCommand(options, flags, ui), flags, ui, (listResult) => {
|
|
275
265
|
if (flags.json) ui.output(JSON.stringify(listResult, null, 2));
|
|
276
|
-
else if (!flags.quiet) {
|
|
277
|
-
|
|
278
|
-
ui.
|
|
279
|
-
|
|
266
|
+
else if (!flags.quiet) ui.output(renderMigrationListHumanOutput(listResult, {
|
|
267
|
+
graph: options.graph === true,
|
|
268
|
+
glyphMode: ui.resolveGlyphMode(options.ascii === true),
|
|
269
|
+
useColor: ui.useColor
|
|
270
|
+
}));
|
|
280
271
|
});
|
|
281
272
|
process.exit(exitCode);
|
|
282
273
|
});
|
|
283
274
|
return command;
|
|
284
275
|
}
|
|
285
276
|
//#endregion
|
|
286
|
-
export {
|
|
277
|
+
export { renderMigrationListHumanOutput as n, runMigrationList as r, createMigrationListCommand as t };
|
|
287
278
|
|
|
288
|
-
//# sourceMappingURL=migration-list-
|
|
279
|
+
//# sourceMappingURL=migration-list-DopkAG7L.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migration-list-DopkAG7L.mjs","names":[],"sources":["../src/utils/formatters/migration-list-render.ts","../src/utils/formatters/migration-list-styler.ts","../src/commands/migration-list.ts"],"sourcesContent":["import {\n classifyMigrationListGraphTopology,\n type EdgeKind,\n} from '@prisma-next/migration-tools/migration-list-graph-topology';\nimport type {\n MigrationListEntry,\n MigrationListResult,\n} from '@prisma-next/migration-tools/migration-list-types';\nimport {\n computeMigrationDirNameWidth,\n formatMigrationDataColumn,\n MIGRATION_LIST_FORWARD_EDGE_GLYPH,\n} from './migration-list-data-column';\n\nexport type { EdgeKind } from '@prisma-next/migration-tools/migration-list-graph-topology';\n\nexport type {\n MigrationListEntry,\n MigrationListResult,\n MigrationSpaceListEntry,\n} from '@prisma-next/migration-tools/migration-list-types';\n\nconst KIND_GLYPH: Record<EdgeKind, string> = {\n forward: '*',\n rollback: '↩',\n self: '⟲',\n};\n\n/**\n * Semantic styler for `migration list` output tokens. Token-typed so\n * the renderer composes presentation-neutral fragments and the styler\n * decides how each token kind is decorated (ANSI codes, plain text,\n * etc.). The renderer pads with raw spaces *outside* styled tokens so\n * visible column widths stay stable regardless of what the styler\n * emits — adding ANSI escape sequences never disturbs alignment.\n *\n * `invariants` and `refs` receive the underlying string arrays rather\n * than a pre-joined string so per-element styling (e.g. distinguishing\n * the live-DB `db` marker from user-named refs) is possible without\n * having to re-parse a joined block.\n */\nexport interface MigrationListStyler {\n kind(text: string): string;\n dirName(text: string): string;\n sourceHash(text: string): string;\n destHash(text: string): string;\n glyph(text: string): string;\n lane(text: string): string;\n invariants(ids: readonly string[]): string;\n refs(names: readonly string[]): string;\n spaceHeading(text: string): string;\n summary(text: string): string;\n emptyState(text: string): string;\n}\n\nexport const IDENTITY_MIGRATION_LIST_STYLER: MigrationListStyler = {\n kind: (text) => text,\n dirName: (text) => text,\n sourceHash: (text) => text,\n destHash: (text) => text,\n glyph: (text) => text,\n lane: (text) => text,\n invariants: (ids) => `{${ids.join(', ')}}`,\n refs: (names) => `(${names.join(', ')})`,\n spaceHeading: (text) => text,\n summary: (text) => text,\n emptyState: (text) => text,\n};\n\nfunction resolveEdgeKind(\n migrationHash: string,\n kindByMigrationHash: ReadonlyMap<string, EdgeKind>,\n): EdgeKind {\n return kindByMigrationHash.get(migrationHash) ?? 'forward';\n}\n\nfunction formatMigrationRow(\n migration: MigrationListEntry,\n dirNameWidth: number,\n edgeKind: EdgeKind,\n style: MigrationListStyler,\n): string {\n const kindColumn = `${style.kind(KIND_GLYPH[edgeKind])} `;\n const data = formatMigrationDataColumn(migration, {\n dirNameWidth,\n edgeKind,\n style,\n forwardArrow: MIGRATION_LIST_FORWARD_EDGE_GLYPH,\n });\n return `${kindColumn}${data}`;\n}\n\nfunction formatEmptyStateLine(spaceId: string, style: MigrationListStyler): string {\n return style.emptyState(`There are no migrations in migrations/${spaceId}/ yet`);\n}\n\nfunction renderSpaceBlock(\n spaceId: string,\n migrations: readonly MigrationListEntry[],\n multiSpace: boolean,\n style: MigrationListStyler,\n): readonly string[] {\n if (migrations.length === 0) {\n const emptyLine = formatEmptyStateLine(spaceId, style);\n if (!multiSpace) {\n return [emptyLine];\n }\n return [style.spaceHeading(`${spaceId}:`), ` ${emptyLine}`];\n }\n\n const kindByMigrationHash = classifyMigrationListGraphTopology(migrations).kindByMigrationHash;\n const dirNameWidth = computeMigrationDirNameWidth(migrations);\n const rows = migrations.map((entry) =>\n formatMigrationRow(\n entry,\n dirNameWidth,\n resolveEdgeKind(entry.migrationHash, kindByMigrationHash),\n style,\n ),\n );\n if (!multiSpace) {\n return rows;\n }\n return [style.spaceHeading(`${spaceId}:`), ...rows.map((row) => ` ${row}`)];\n}\n\n/**\n * Compose the styled `migration list` output. The renderer is\n * presentation-neutral — every token passes through `style` before\n * landing in the output, so the same composition serves the pure-text\n * path ({@link renderMigrationList} via\n * {@link IDENTITY_MIGRATION_LIST_STYLER}) and the ANSI-styled CLI path\n * (via the ANSI styler the CLI shell wires up).\n */\nexport function renderMigrationListWithStyle(\n result: MigrationListResult,\n style: MigrationListStyler,\n): string {\n const multiSpace = result.spaces.length > 1;\n const lines: string[] = [];\n\n for (let index = 0; index < result.spaces.length; index++) {\n const space = result.spaces[index]!;\n if (index > 0) {\n lines.push('');\n }\n lines.push(...renderSpaceBlock(space.spaceId, space.migrations, multiSpace, style));\n }\n\n const totalMigrations = result.spaces.reduce(\n (count, space) => count + space.migrations.length,\n 0,\n );\n if (totalMigrations > 0) {\n lines.push('');\n lines.push(style.summary(result.summary));\n }\n\n return lines.join('\\n');\n}\n\nexport function renderMigrationList(result: MigrationListResult): string {\n return renderMigrationListWithStyle(result, IDENTITY_MIGRATION_LIST_STYLER);\n}\n","import { bold, cyan, cyanBright, dim, green, greenBright, yellow } from 'colorette';\nimport { IDENTITY_MIGRATION_LIST_STYLER, type MigrationListStyler } from './migration-list-render';\n\n/**\n * The reserved ref name for the live-database marker. Treated as a\n * structurally distinct token from user-named refs so the styler can\n * make it visually pop in `(refs)` decorations.\n */\nconst DB_REF_NAME = 'db';\n\nfunction styleRefName(name: string): string {\n return name === DB_REF_NAME ? bold(greenBright(name)) : green(name);\n}\n\n/**\n * Build a {@link MigrationListStyler} that decorates `migration list`\n * tokens with ANSI SGR codes. When `useColor` is `false` (non-TTY,\n * `--no-color`, `NO_COLOR=1`, piped output) the function returns the\n * shared identity styler so callers get plain text with zero ANSI\n * bytes — pipe-friendly by construction.\n *\n * Palette:\n *\n * - `dirName`: bold\n * - `sourceHash`: dim cyan\n * - `destHash`: bright cyan\n * - `glyph` (`→` / `⟲` / `∅`): dim\n * - `lane` (graph gutter lines `│` and fan/join connectors `├─┐` / `├─┘`): dim\n * - `invariants` (`{...}`): yellow\n * - `refs` (`(...)`): green; the live-DB `db` marker inside is green-bold\n * - `spaceHeading` (`<spaceId>:`): bold\n * - `summary`: dim\n * - `emptyState`: dim\n */\nexport function createAnsiMigrationListStyler(opts: {\n readonly useColor: boolean;\n}): MigrationListStyler {\n if (!opts.useColor) {\n return IDENTITY_MIGRATION_LIST_STYLER;\n }\n return {\n kind: (text) => dim(text),\n dirName: (text) => bold(text),\n sourceHash: (text) => dim(cyan(text)),\n destHash: (text) => cyanBright(text),\n glyph: (text) => dim(text),\n lane: (text) => dim(text),\n invariants: (ids) => yellow(`{${ids.join(', ')}}`),\n refs: (names) => {\n const open = green('(');\n const close = green(')');\n const separator = green(', ');\n return open + names.map(styleRefName).join(separator) + close;\n },\n spaceHeading: (text) => bold(text),\n summary: (text) => dim(text),\n emptyState: (text) => dim(text),\n };\n}\n","import { enumerateMigrationSpaces } from '@prisma-next/migration-tools/enumerate-migration-spaces';\nimport { MigrationToolsError } from '@prisma-next/migration-tools/errors';\nimport type {\n MigrationListResult,\n MigrationSpaceListEntry,\n} from '@prisma-next/migration-tools/migration-list-types';\nimport { APP_SPACE_ID, isValidSpaceId } from '@prisma-next/migration-tools/spaces';\nimport { ifDefined } from '@prisma-next/utils/defined';\nimport { notOk, ok, type Result } from '@prisma-next/utils/result';\nimport { Command } from 'commander';\nimport { loadConfig } from '../config-loader';\nimport {\n type CliStructuredError,\n errorInvalidSpaceId,\n errorSpaceNotFound,\n errorUnexpected,\n mapMigrationToolsError,\n} from '../utils/cli-errors';\nimport {\n addGlobalOptions,\n resolveMigrationPaths,\n setCommandDescriptions,\n setCommandExamples,\n setCommandSeeAlso,\n} from '../utils/command-helpers';\nimport {\n type GlyphMode,\n renderMigrationListGraphResult,\n} from '../utils/formatters/migration-list-graph-render';\nimport { renderMigrationListWithStyle } from '../utils/formatters/migration-list-render';\nimport { createAnsiMigrationListStyler } from '../utils/formatters/migration-list-styler';\nimport { formatStyledHeader } from '../utils/formatters/styled';\nimport type { CommonCommandOptions } from '../utils/global-flags';\nimport { type GlobalFlags, parseGlobalFlagsOrExit } from '../utils/global-flags';\nimport { handleResult } from '../utils/result-handler';\nimport { createTerminalUI, type TerminalUI } from '../utils/terminal-ui';\n\ninterface MigrationListOptions extends CommonCommandOptions {\n readonly config?: string;\n readonly space?: string;\n readonly graph?: boolean;\n readonly ascii?: boolean;\n}\n\nexport interface MigrationListHumanRenderOptions {\n readonly graph: boolean;\n readonly glyphMode: GlyphMode;\n readonly useColor: boolean;\n}\n\nexport function renderMigrationListHumanOutput(\n result: MigrationListResult,\n options: MigrationListHumanRenderOptions,\n): string {\n const styler = createAnsiMigrationListStyler({ useColor: options.useColor });\n if (options.graph) {\n return renderMigrationListGraphResult(result, styler, options.glyphMode);\n }\n return renderMigrationListWithStyle(result, styler);\n}\n\n/**\n * Inputs for {@link runMigrationList} — the pure-ish data-and-policy core\n * of `migration list` that tests exercise directly.\n *\n * The core depends only on the filesystem rooted at `migrationsDir`. It\n * does NOT call `loadConfig`, parse CLI flags, render a styled header,\n * or write to any stream. Output rendering is the caller's concern (the\n * CLI shell renders via {@link renderMigrationList}; JSON callers\n * serialize the {@link MigrationListResult} directly).\n */\nexport interface RunMigrationListInputs {\n /** Absolute path to the project's `migrations/` directory. */\n readonly migrationsDir: string;\n /**\n * Optional contract-space id to narrow the result to a single space.\n * Same validation rules as {@link isValidSpaceId}. When absent, every\n * on-disk space contributes.\n */\n readonly spaceFilter?: string;\n}\n\nfunction computeSummary(spaces: readonly MigrationSpaceListEntry[]): string {\n const totalMigrations = spaces.reduce((count, space) => count + space.migrations.length, 0);\n if (spaces.length <= 1) {\n return `${totalMigrations} migration(s) on disk`;\n }\n return `${totalMigrations} migration(s) across ${spaces.length} contract space(s)`;\n}\n\n/**\n * The unit-testable core of `migration list`. Given an absolute\n * `migrationsDir` and an optional `spaceFilter`, enumerates every\n * on-disk migration (via {@link enumerateMigrationSpaces}), narrows to\n * the requested space if any, and assembles a {@link MigrationListResult}\n * ready for the renderer or JSON serializer.\n *\n * The enumerator is the single source of truth for \"what is a contract\n * space\": existence, the `--space` candidate-suggestion list, and\n * scoping are all derived from one {@link enumerateMigrationSpaces}\n * traversal. This means the reserved-name exclusion the enumerator\n * applies (e.g. the per-space `refs/` subdirectory) is honoured here for\n * free — a `--space refs` request resolves to `SPACE_NOT_FOUND`, not a\n * synthesized empty-state.\n *\n * Distinct empty-state paths:\n *\n * - `migrations/` missing or contains no valid space directories →\n * synthesizes `[{ spaceId: APP_SPACE_ID, migrations: [] }]` so the\n * renderer's empty-state path can name a directory (spec § Empty-state +\n * the `migrations/` missing edge case).\n * - `--space <id>` on an existing-but-empty space dir → the enumerator\n * surfaces `{ spaceId, migrations: [] }`; `<id>` is in the set, so it\n * scopes to that entry and renders the empty-state the same way.\n * - `--space <id>` on a non-existent (or reserved) space → structured\n * `MIGRATION.SPACE_NOT_FOUND` error (NOT empty-state).\n *\n * Errors caught here:\n *\n * - {@link MigrationToolsError} from the enumerator → mapped through\n * {@link mapMigrationToolsError} so callers see the catalogue code.\n * - Anything else (filesystem etc.) → wrapped via {@link errorUnexpected}.\n */\nexport async function runMigrationList(\n inputs: RunMigrationListInputs,\n): Promise<Result<MigrationListResult, CliStructuredError>> {\n const { migrationsDir, spaceFilter } = inputs;\n\n if (spaceFilter !== undefined && !isValidSpaceId(spaceFilter)) {\n return notOk(errorInvalidSpaceId(spaceFilter));\n }\n\n let spaces: readonly MigrationSpaceListEntry[];\n try {\n spaces = await enumerateMigrationSpaces({ projectMigrationsDir: migrationsDir });\n } catch (error) {\n if (MigrationToolsError.is(error)) return notOk(mapMigrationToolsError(error));\n return notOk(\n errorUnexpected(error instanceof Error ? error.message : String(error), {\n why: `Failed to enumerate migrations: ${error instanceof Error ? error.message : String(error)}`,\n }),\n );\n }\n\n if (spaceFilter !== undefined && !spaces.some((s) => s.spaceId === spaceFilter)) {\n return notOk(errorSpaceNotFound(spaceFilter, spaces.map((s) => s.spaceId).sort()));\n }\n\n const scopedSpaces =\n spaceFilter !== undefined ? spaces.filter((s) => s.spaceId === spaceFilter) : spaces;\n\n const resultSpaces: readonly MigrationSpaceListEntry[] =\n scopedSpaces.length === 0 ? [{ spaceId: APP_SPACE_ID, migrations: [] }] : scopedSpaces;\n\n return ok({\n ok: true,\n spaces: resultSpaces,\n summary: computeSummary(resultSpaces),\n });\n}\n\n/**\n * CLI shell: loads config, resolves paths, prints the styled header on\n * stderr (interactive mode only), and delegates to {@link runMigrationList}.\n * Kept intentionally thin so the unit-testable surface lives in the core.\n */\nasync function executeMigrationListCommand(\n options: MigrationListOptions,\n flags: GlobalFlags,\n ui: TerminalUI,\n): Promise<Result<MigrationListResult, CliStructuredError>> {\n const config = await loadConfig(options.config);\n const { configPath, migrationsDir, migrationsRelative } = resolveMigrationPaths(\n options.config,\n config,\n );\n\n if (!flags.json && !flags.quiet) {\n const header = formatStyledHeader({\n command: 'migration list',\n description: 'List on-disk migrations, latest first, per contract space',\n details: [\n { label: 'config', value: configPath },\n { label: 'migrations', value: migrationsRelative },\n ...(options.space !== undefined ? [{ label: 'space', value: options.space }] : []),\n ],\n flags,\n });\n ui.stderr(header);\n }\n\n return runMigrationList({\n migrationsDir,\n ...ifDefined('spaceFilter', options.space),\n });\n}\n\nexport function createMigrationListCommand(): Command {\n const command = new Command('list');\n setCommandDescriptions(\n command,\n 'List on-disk migrations, latest first, per contract space',\n 'Enumerates every on-disk migration under migrations/<space>/ for every\\n' +\n 'contract space found on disk, latest first. Offline — does not consult\\n' +\n 'the database. Each row leads with a kind glyph (* forward, ↩ rollback,\\n' +\n '⟲ self), then dirName, then source → destination contract hashes\\n' +\n '(7-char git-style). Self-edges show a single hash. Invariants render as\\n' +\n '{...}; refs on the destination as (production, db). Pass --space <id>\\n' +\n 'to narrow to one contract space. --graph draws the forward spine with\\n' +\n 'lane gutters; --ascii forces ASCII glyphs (orthogonal to --no-color).',\n );\n setCommandExamples(command, [\n 'prisma-next migration list',\n 'prisma-next migration list --graph',\n 'prisma-next migration list --space app',\n 'prisma-next migration list --graph --ascii',\n 'prisma-next migration list --json',\n ]);\n setCommandSeeAlso(command, [\n { verb: 'migration status', oneLiner: 'Show migration path and pending status' },\n { verb: 'migration log', oneLiner: 'Show executed migration history' },\n { verb: 'migration graph', oneLiner: 'Show the migration graph topology' },\n { verb: 'migration show', oneLiner: 'Display migration package contents' },\n ]);\n addGlobalOptions(command)\n .option('--config <path>', 'Path to prisma-next.config.ts')\n .option('--space <id>', 'Narrow output to a single contract space')\n .option('--graph', 'Draw migration relationships as an annotated tree')\n .option('--ascii', 'Use ASCII glyphs for --graph (pipe-friendly)')\n .action(async (options: MigrationListOptions) => {\n const flags = parseGlobalFlagsOrExit(options);\n const ui = createTerminalUI(flags);\n const result = await executeMigrationListCommand(options, flags, ui);\n const exitCode = handleResult(result, flags, ui, (listResult) => {\n if (flags.json) {\n ui.output(JSON.stringify(listResult, null, 2));\n } else if (!flags.quiet) {\n ui.output(\n renderMigrationListHumanOutput(listResult, {\n graph: options.graph === true,\n glyphMode: ui.resolveGlyphMode(options.ascii === true),\n useColor: ui.useColor,\n }),\n );\n }\n });\n process.exit(exitCode);\n });\n return command;\n}\n"],"mappings":";;;;;;;;;;;;AAsBA,MAAM,aAAuC;CAC3C,SAAS;CACT,UAAU;CACV,MAAM;AACR;AA6BA,MAAa,iCAAsD;CACjE,OAAO,SAAS;CAChB,UAAU,SAAS;CACnB,aAAa,SAAS;CACtB,WAAW,SAAS;CACpB,QAAQ,SAAS;CACjB,OAAO,SAAS;CAChB,aAAa,QAAQ,IAAI,IAAI,KAAK,IAAI,EAAE;CACxC,OAAO,UAAU,IAAI,MAAM,KAAK,IAAI,EAAE;CACtC,eAAe,SAAS;CACxB,UAAU,SAAS;CACnB,aAAa,SAAS;AACxB;AAEA,SAAS,gBACP,eACA,qBACU;CACV,OAAO,oBAAoB,IAAI,aAAa,KAAK;AACn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,7 @@
|
|
|
1
|
+
import { MigrationListResult } from "@prisma-next/migration-tools/migration-list-types";
|
|
2
|
+
|
|
3
|
+
//#region src/utils/formatters/migration-list-graph-render.d.ts
|
|
4
|
+
type GlyphMode = 'unicode' | 'ascii';
|
|
5
|
+
//#endregion
|
|
6
|
+
export { GlyphMode as t };
|
|
7
|
+
//# sourceMappingURL=migration-list-graph-render-C-daUZLU.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migration-list-graph-render-C-daUZLU.d.mts","names":[],"sources":["../src/utils/formatters/migration-list-graph-render.ts"],"mappings":";;;KAuBY,SAAA"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { t as loadConfig } from "./config-loader-B6sJjXTv.mjs";
|
|
2
2
|
import { A as mapRefResolutionError, E as errorTargetMigrationNotSupported, O as errorUnexpected, a as errorContractValidationFailed, h as errorMigrationPlanningFailed, k as mapMigrationToolsError, l as errorFileNotFound, t as CliStructuredError, v as errorPlanForgotTheFlag, w as errorSnapshotMissing } from "./cli-errors-DFF1LlfU.mjs";
|
|
3
3
|
import { t as assertFrameworkComponentsCompatible } from "./framework-components-DTcjouhS.mjs";
|
|
4
|
-
import {
|
|
4
|
+
import { A as formatStyledHeader, a as loadMigrationPackages, c as resolveContractPath, d as setCommandDescriptions, f as setCommandExamples, i as getTargetMigrations, l as resolveMigrationPaths, t as addGlobalOptions, v as parseGlobalFlagsOrExit, w as handleResult, y as createTerminalUI } from "./command-helpers-yLuA78TP.mjs";
|
|
5
5
|
import { n as toExtensionInputs, t as buildContractSpaceAggregate } from "./contract-space-aggregate-loader-EVU3n9YE.mjs";
|
|
6
6
|
import { Command } from "commander";
|
|
7
7
|
import { getEmittedArtifactPaths } from "@prisma-next/emitter";
|
|
@@ -778,4 +778,4 @@ function resolveBundleByPrefix(bundles, needle) {
|
|
|
778
778
|
//#endregion
|
|
779
779
|
export { formatMigrationPlanOutput as n, resolveBundleByPrefix as r, createMigrationPlanCommand as t };
|
|
780
780
|
|
|
781
|
-
//# sourceMappingURL=migration-plan-
|
|
781
|
+
//# sourceMappingURL=migration-plan-BHoeET4O.mjs.map
|