@prisma-next/cli 0.4.1 → 0.5.0-dev.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -6
- package/dist/cli-errors-C0JhVj0c.d.mts +4 -0
- package/dist/{cli-errors-CznZA5-d.mjs → cli-errors-DHq6GQGu.mjs} +2 -2
- package/dist/cli.mjs +7 -7
- package/dist/{client-DGKrciLM.mjs → client-TG7rbCWT.mjs} +4 -4
- package/dist/{client-DGKrciLM.mjs.map → client-TG7rbCWT.mjs.map} +1 -1
- package/dist/commands/contract-emit.mjs +2 -2
- package/dist/commands/contract-infer.mjs +2 -2
- package/dist/commands/db-init.mjs +7 -7
- package/dist/commands/db-schema.mjs +5 -5
- package/dist/commands/db-sign.mjs +7 -7
- package/dist/commands/db-update.mjs +7 -7
- package/dist/commands/db-verify.mjs +7 -7
- package/dist/commands/migration-apply.mjs +6 -6
- package/dist/commands/migration-new.mjs +5 -5
- package/dist/commands/migration-plan.mjs +6 -6
- package/dist/commands/migration-ref.d.mts +1 -1
- package/dist/commands/migration-ref.mjs +4 -4
- package/dist/commands/migration-show.d.mts +1 -1
- package/dist/commands/migration-show.mjs +6 -6
- package/dist/commands/migration-status.mjs +2 -2
- package/dist/{config-loader-_xQZsw0i.mjs → config-loader-_W4T21X1.mjs} +1 -1
- package/dist/{config-loader-_xQZsw0i.mjs.map → config-loader-_W4T21X1.mjs.map} +1 -1
- package/dist/config-loader.mjs +1 -1
- package/dist/{contract-emit-mU1_B_m9.mjs → contract-emit-CNYyzJwF.mjs} +10 -10
- package/dist/contract-emit-CNYyzJwF.mjs.map +1 -0
- package/dist/{contract-emit-DgeWdonT.mjs → contract-emit-CQfj7xJn.mjs} +6 -6
- package/dist/{contract-emit-DgeWdonT.mjs.map → contract-emit-CQfj7xJn.mjs.map} +1 -1
- package/dist/contract-emit-fhNwwhkQ.mjs +4 -0
- package/dist/{contract-enrichment-BV4KpbNW.mjs → contract-enrichment-CGW6mm-E.mjs} +1 -1
- package/dist/{contract-enrichment-BV4KpbNW.mjs.map → contract-enrichment-CGW6mm-E.mjs.map} +1 -1
- package/dist/{contract-infer-CUbiWGX0.mjs → contract-infer-BP3DrGgz.mjs} +4 -4
- package/dist/{contract-infer-CUbiWGX0.mjs.map → contract-infer-BP3DrGgz.mjs.map} +1 -1
- package/dist/exports/control-api.mjs +4 -4
- package/dist/exports/index.mjs +2 -2
- package/dist/{extract-operation-statements-DWWFz1PK.mjs → extract-operation-statements-DZUJNmL3.mjs} +2 -2
- package/dist/{extract-operation-statements-DWWFz1PK.mjs.map → extract-operation-statements-DZUJNmL3.mjs.map} +1 -1
- package/dist/{extract-sql-ddl-7zn_AFS8.mjs → extract-sql-ddl-DDMX-9mz.mjs} +1 -1
- package/dist/{extract-sql-ddl-7zn_AFS8.mjs.map → extract-sql-ddl-DDMX-9mz.mjs.map} +1 -1
- package/dist/{framework-components-B__p--vT.mjs → framework-components-DfZKQBQ2.mjs} +2 -2
- package/dist/{framework-components-B__p--vT.mjs.map → framework-components-DfZKQBQ2.mjs.map} +1 -1
- package/dist/{init-DRquYpPa.mjs → init-CQfo_4Ro.mjs} +3 -3
- package/dist/{init-DRquYpPa.mjs.map → init-CQfo_4Ro.mjs.map} +1 -1
- package/dist/{inspect-live-schema-wIYBTdL3.mjs → inspect-live-schema-DWzf4Q_m.mjs} +6 -6
- package/dist/{inspect-live-schema-wIYBTdL3.mjs.map → inspect-live-schema-DWzf4Q_m.mjs.map} +1 -1
- package/dist/migration-cli.d.mts +50 -0
- package/dist/migration-cli.d.mts.map +1 -0
- package/dist/migration-cli.mjs +184 -0
- package/dist/migration-cli.mjs.map +1 -0
- package/dist/{migration-command-scaffold-BC73xQSo.mjs → migration-command-scaffold-CLMD302g.mjs} +6 -6
- package/dist/{migration-command-scaffold-BC73xQSo.mjs.map → migration-command-scaffold-CLMD302g.mjs.map} +1 -1
- package/dist/{migration-status-CXBbScH5.mjs → migration-status-B0HLF7So.mjs} +6 -6
- package/dist/{migration-status-CXBbScH5.mjs.map → migration-status-B0HLF7So.mjs.map} +1 -1
- package/dist/{migrations-DYRAjiVh.mjs → migrations-B0dOQlk0.mjs} +2 -2
- package/dist/{migrations-DYRAjiVh.mjs.map → migrations-B0dOQlk0.mjs.map} +1 -1
- package/dist/{progress-adapter-Bwouy73-.mjs → progress-adapter-B-YvmcDu.mjs} +1 -1
- package/dist/{progress-adapter-Bwouy73-.mjs.map → progress-adapter-B-YvmcDu.mjs.map} +1 -1
- package/dist/{result-handler-CGohaH1o.mjs → result-handler-CIyu0Pdt.mjs} +1 -1
- package/dist/{result-handler-CGohaH1o.mjs.map → result-handler-CIyu0Pdt.mjs.map} +1 -1
- package/dist/{terminal-ui-BuPXVRFY.mjs → terminal-ui-C5k88MmW.mjs} +1 -1
- package/dist/{terminal-ui-BuPXVRFY.mjs.map → terminal-ui-C5k88MmW.mjs.map} +1 -1
- package/dist/{validate-contract-deps-DZqv9m7H.mjs → validate-contract-deps-esa-VQ0h.mjs} +1 -1
- package/dist/{validate-contract-deps-DZqv9m7H.mjs.map → validate-contract-deps-esa-VQ0h.mjs.map} +1 -1
- package/dist/{verify-Cm2UFuZA.mjs → verify-BxiVp50b.mjs} +2 -2
- package/dist/{verify-Cm2UFuZA.mjs.map → verify-BxiVp50b.mjs.map} +1 -1
- package/package.json +20 -16
- package/src/migration-cli.ts +254 -0
- package/src/utils/cli-errors.ts +1 -0
- package/dist/cli-errors-z37sV3eR.d.mts +0 -4
- package/dist/contract-emit-304WZtZJ.mjs +0 -4
- package/dist/contract-emit-mU1_B_m9.mjs.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init-DRquYpPa.mjs","names":["KNOWN: ReadonlySet<string>","variables","vars: TemplateVars","vars: TemplateVars","REQUIRED_COMPILER_OPTIONS: Record<string, string | boolean>","files: FileEntry[]"],"sources":["../src/commands/init/detect-package-manager.ts","../src/commands/init/templates/render.ts","../src/commands/init/templates/agent-skill.ts","../src/commands/init/templates/code-templates.ts","../src/commands/init/templates/quick-reference.ts","../src/commands/init/templates/tsconfig.ts","../src/commands/init/init.ts"],"sourcesContent":["import { existsSync } from 'node:fs';\nimport { detect } from 'package-manager-detector/detect';\nimport { join } from 'pathe';\n\nexport type PackageManager = 'pnpm' | 'npm' | 'yarn' | 'bun' | 'deno';\n\nconst KNOWN: ReadonlySet<string> = new Set<PackageManager>(['pnpm', 'npm', 'yarn', 'bun', 'deno']);\n\nexport async function detectPackageManager(cwd: string): Promise<PackageManager> {\n const result = await detect({ cwd });\n if (result && KNOWN.has(result.name)) {\n return result.name as PackageManager;\n }\n return 'npm';\n}\n\nexport function hasProjectManifest(cwd: string): boolean {\n return (\n existsSync(join(cwd, 'package.json')) ||\n existsSync(join(cwd, 'deno.json')) ||\n existsSync(join(cwd, 'deno.jsonc'))\n );\n}\n\nexport function formatRunCommand(pm: PackageManager, bin: string, args: string): string {\n if (pm === 'npm') {\n return `npx ${bin} ${args}`;\n }\n if (pm === 'deno') {\n return `deno run npm:${bin} ${args}`;\n }\n return `${pm} ${bin} ${args}`;\n}\n\nexport function formatAddArgs(pm: PackageManager, packages: string[]): string[] {\n if (pm === 'deno') {\n return ['add', ...packages.map((p) => `npm:${p}`)];\n }\n return ['add', ...packages];\n}\n\nexport function formatAddDevArgs(pm: PackageManager, packages: string[]): string[] {\n if (pm === 'deno') {\n return ['add', '--dev', ...packages.map((p) => `npm:${p}`)];\n }\n return ['add', '-D', ...packages];\n}\n","import { readFileSync } from 'node:fs';\nimport { join } from 'pathe';\n\nexport function renderTemplate(\n templateFile: string,\n variableNames: readonly string[],\n vars: Record<string, string>,\n): string {\n const templatePath = join(import.meta.dirname, templateFile);\n const raw = readFileSync(templatePath, 'utf-8');\n let result = raw;\n for (const key of variableNames) {\n const value = vars[key];\n if (value === undefined) {\n throw new Error(`Template variable '${key}' is not defined`);\n }\n result = result.replaceAll(`{{${key}}}`, value);\n }\n return result;\n}\n","import { dirname } from 'pathe';\nimport type { TargetId } from './code-templates';\nimport { renderTemplate } from './render';\n\nexport const variables = ['schemaPath', 'schemaDir', 'dbImportPath', 'pkgRun'] as const;\n\ntype TemplateVars = Record<(typeof variables)[number], string>;\n\nexport function agentSkillMd(target: TargetId, schemaPath: string, pkgRun: string): string {\n const schemaDir = dirname(schemaPath);\n const vars: TemplateVars = {\n schemaPath,\n schemaDir,\n dbImportPath: `./${schemaDir}/db`,\n pkgRun,\n };\n const templateFile = `agent-skill-${target}.md`;\n return renderTemplate(templateFile, variables, vars);\n}\n","export type TargetId = 'postgres' | 'mongo';\nexport type AuthoringId = 'psl' | 'typescript';\n\nexport function targetPackageName(target: TargetId): string {\n return target === 'postgres' ? '@prisma-next/postgres' : '@prisma-next/mongo';\n}\n\nexport function targetLabel(target: TargetId): string {\n return target === 'postgres' ? 'PostgreSQL' : 'MongoDB';\n}\n\nexport function defaultSchemaPath(authoring: AuthoringId): string {\n if (authoring === 'typescript') {\n return 'prisma/contract.ts';\n }\n return 'prisma/contract.prisma';\n}\n\nexport function starterSchema(target: TargetId, authoring: AuthoringId): string {\n if (authoring === 'typescript') {\n return target === 'mongo' ? starterSchemaTsMongo() : starterSchemaTsPostgres();\n }\n return target === 'mongo' ? starterSchemaPslMongo() : starterSchemaPslPostgres();\n}\n\nfunction starterSchemaPslPostgres(): string {\n return `model User {\n id Int @id @default(autoincrement())\n email String @unique\n name String?\n posts Post[]\n createdAt DateTime @default(now())\n}\n\nmodel Post {\n id Int @id @default(autoincrement())\n title String\n content String?\n author User @relation(fields: [authorId], references: [id])\n authorId Int\n createdAt DateTime @default(now())\n}\n`;\n}\n\nfunction starterSchemaPslMongo(): string {\n return `model User {\n id ObjectId @id @map(\"_id\")\n email String @unique\n name String?\n posts Post[]\n @@map(\"users\")\n}\n\nmodel Post {\n id ObjectId @id @map(\"_id\")\n title String\n content String?\n author User @relation(fields: [authorId], references: [id])\n authorId ObjectId\n @@map(\"posts\")\n}\n`;\n}\n\nfunction starterSchemaTsPostgres(): string {\n return `import sqlFamily from '@prisma-next/family-sql/pack';\nimport { defineContract } from '@prisma-next/sql-contract-ts/contract-builder';\nimport postgresPack from '@prisma-next/target-postgres/pack';\n\nexport const contract = defineContract(\n { family: sqlFamily, target: postgresPack },\n ({ field, model, rel }) => ({\n models: {\n User: model('User', {\n fields: {\n id: field.id.uuidv7(),\n email: field.text().unique(),\n name: field.text().optional(),\n createdAt: field.createdAt(),\n },\n }).relations({\n posts: rel.hasMany('Post', { by: 'authorId' }),\n }),\n\n Post: model('Post', {\n fields: {\n id: field.id.uuidv7(),\n title: field.text(),\n content: field.text().optional(),\n authorId: field.uuid(),\n createdAt: field.createdAt(),\n },\n }).relations({\n author: rel.belongsTo('User', { from: 'authorId', to: 'id' }),\n }),\n },\n }),\n);\n`;\n}\n\nfunction starterSchemaTsMongo(): string {\n return `import mongoFamily from '@prisma-next/family-mongo/pack';\nimport { defineContract, field, model, rel } from '@prisma-next/mongo-contract-ts/contract-builder';\nimport mongoTarget from '@prisma-next/target-mongo/pack';\n\nconst User = model('User', {\n collection: 'users',\n fields: {\n _id: field.objectId(),\n email: field.string(),\n name: field.string().optional(),\n },\n});\n\nconst Post = model('Post', {\n collection: 'posts',\n fields: {\n _id: field.objectId(),\n title: field.string(),\n content: field.string().optional(),\n authorId: field.objectId(),\n },\n relations: {\n author: rel.belongsTo(User, { from: 'authorId', to: User.ref('_id') }),\n },\n});\n\nexport const contract = defineContract({\n family: mongoFamily,\n target: mongoTarget,\n models: { User, Post },\n});\n`;\n}\n\nexport function configFile(target: TargetId, contractPath: string): string {\n const pkg = targetPackageName(target);\n return `import 'dotenv/config';\nimport { defineConfig } from '${pkg}/config';\n\nexport default defineConfig({\n contract: ${JSON.stringify(contractPath)},\n db: {\n connection: process.env['DATABASE_URL']!,\n },\n});\n`;\n}\n\nexport function dbFile(target: TargetId): string {\n if (target === 'postgres') {\n return `import postgres from '@prisma-next/postgres/runtime';\nimport type { Contract } from './contract.d';\nimport contractJson from './contract.json' with { type: 'json' };\n\nexport const db = postgres<Contract>({ contractJson });\n`;\n }\n\n return `import mongo from '@prisma-next/mongo/runtime';\nimport type { Contract } from './contract.d';\nimport contractJson from './contract.json' with { type: 'json' };\n\nexport const db = mongo<Contract>({ contractJson });\n`;\n}\n","import { dirname } from 'pathe';\nimport type { TargetId } from './code-templates';\nimport { renderTemplate } from './render';\n\nexport const variables = ['schemaPath', 'schemaDir', 'dbImportPath', 'pkgRun'] as const;\n\ntype TemplateVars = Record<(typeof variables)[number], string>;\n\nexport function quickReferenceMd(target: TargetId, schemaPath: string, pkgRun: string): string {\n const schemaDir = dirname(schemaPath);\n const vars: TemplateVars = {\n schemaPath,\n schemaDir,\n dbImportPath: `./${schemaDir}/db`,\n pkgRun,\n };\n const templateFile = `quick-reference-${target}.md`;\n return renderTemplate(templateFile, variables, vars);\n}\n","export const REQUIRED_COMPILER_OPTIONS: Record<string, string | boolean> = {\n module: 'preserve',\n moduleResolution: 'bundler',\n resolveJsonModule: true,\n};\n\nexport function defaultTsConfig(): string {\n return JSON.stringify(\n {\n compilerOptions: {\n target: 'ES2022',\n ...REQUIRED_COMPILER_OPTIONS,\n strict: true,\n skipLibCheck: true,\n esModuleInterop: true,\n outDir: 'dist',\n },\n include: ['**/*.ts'],\n },\n null,\n 2,\n );\n}\n\nexport function mergeTsConfig(existing: string): string {\n const config = JSON.parse(existing) as Record<string, unknown>;\n const compilerOptions = (config['compilerOptions'] ?? {}) as Record<string, unknown>;\n\n for (const [key, value] of Object.entries(REQUIRED_COMPILER_OPTIONS)) {\n compilerOptions[key] = value;\n }\n\n config['compilerOptions'] = compilerOptions;\n return JSON.stringify(config, null, 2);\n}\n","import { execFile } from 'node:child_process';\nimport { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';\nimport { promisify } from 'node:util';\nimport * as clack from '@clack/prompts';\nimport { dirname, extname, isAbsolute, join, normalize } from 'pathe';\nimport { TerminalUI } from '../../utils/terminal-ui';\nimport {\n detectPackageManager,\n formatAddArgs,\n formatAddDevArgs,\n formatRunCommand,\n hasProjectManifest,\n} from './detect-package-manager';\nimport { agentSkillMd } from './templates/agent-skill';\nimport {\n type AuthoringId,\n configFile,\n dbFile,\n defaultSchemaPath,\n starterSchema,\n type TargetId,\n targetPackageName,\n} from './templates/code-templates';\nimport { quickReferenceMd } from './templates/quick-reference';\nimport { defaultTsConfig, mergeTsConfig } from './templates/tsconfig';\n\nexport interface InitOptions {\n readonly noInstall?: boolean;\n}\n\ninterface FileEntry {\n readonly path: string;\n readonly content: string;\n}\n\nexport async function runInit(baseDir: string, options: InitOptions): Promise<void> {\n const ui = new TerminalUI();\n\n clack.intro('prisma-next init', { output: process.stderr });\n\n if (!hasProjectManifest(baseDir)) {\n ui.error(\n 'No package.json or deno.json found. Initialize your project first (e.g. npm init or deno init), then re-run prisma-next init.',\n );\n process.exit(1);\n }\n\n const pm = await detectPackageManager(baseDir);\n const pkgRun = formatRunCommand(pm, 'prisma-next', '').trimEnd();\n\n if (existsSync(join(baseDir, 'prisma-next.config.ts'))) {\n const reinit = await clack.confirm({\n message:\n 'This project is already initialized. Re-initialize? This will overwrite all generated files.',\n initialValue: false,\n output: process.stderr,\n });\n if (clack.isCancel(reinit) || !reinit) {\n clack.cancel('Init cancelled.', { output: process.stderr });\n process.exit(0);\n }\n }\n\n const targetResult = await clack.select({\n message: 'What database are you using?',\n options: [\n { value: 'postgres' as TargetId, label: 'PostgreSQL' },\n { value: 'mongo' as TargetId, label: 'MongoDB' },\n ],\n output: process.stderr,\n });\n if (clack.isCancel(targetResult)) {\n clack.cancel('Init cancelled.', { output: process.stderr });\n process.exit(0);\n }\n const target = targetResult as TargetId;\n\n const authoringResult = await clack.select({\n message: 'How do you want to write your schema?',\n options: [\n { value: 'psl' as AuthoringId, label: 'Prisma Schema Language (.prisma)' },\n { value: 'typescript' as AuthoringId, label: 'TypeScript (.ts)' },\n ],\n output: process.stderr,\n });\n if (clack.isCancel(authoringResult)) {\n clack.cancel('Init cancelled.', { output: process.stderr });\n process.exit(0);\n }\n const authoring = authoringResult as AuthoringId;\n\n const schemaPathResult = await clack.text({\n message: 'Where should the schema file go?',\n initialValue: defaultSchemaPath(authoring),\n validate(value = '') {\n const trimmed = value.trim();\n if (trimmed.length === 0) return 'Path cannot be empty';\n if (trimmed.endsWith('/') || trimmed.endsWith('\\\\'))\n return 'Path must be a file, not a directory';\n if (!extname(trimmed)) return 'Path must include a file extension (e.g. .prisma or .ts)';\n return undefined;\n },\n output: process.stderr,\n });\n if (clack.isCancel(schemaPathResult)) {\n clack.cancel('Init cancelled.', { output: process.stderr });\n process.exit(0);\n }\n const schemaPath = normalize((schemaPathResult as string).trim());\n\n const schemaDir = dirname(schemaPath);\n const configPath = isAbsolute(schemaPath) ? schemaPath : `./${schemaPath}`;\n\n const files: FileEntry[] = [\n { path: schemaPath, content: starterSchema(target, authoring) },\n { path: 'prisma-next.config.ts', content: configFile(target, configPath) },\n { path: join(schemaDir, 'db.ts'), content: dbFile(target) },\n { path: 'prisma-next.md', content: quickReferenceMd(target, schemaPath, pkgRun) },\n {\n path: '.agents/skills/prisma-next/SKILL.md',\n content: agentSkillMd(target, schemaPath, pkgRun),\n },\n ];\n\n for (const file of files) {\n const fullPath = join(baseDir, file.path);\n mkdirSync(dirname(fullPath), { recursive: true });\n writeFileSync(fullPath, file.content, 'utf-8');\n }\n\n const tsconfigPath = join(baseDir, 'tsconfig.json');\n if (existsSync(tsconfigPath)) {\n const existing = readFileSync(tsconfigPath, 'utf-8');\n writeFileSync(tsconfigPath, mergeTsConfig(existing), 'utf-8');\n ui.log('Updated tsconfig.json with required compiler options.');\n } else {\n writeFileSync(tsconfigPath, defaultTsConfig(), 'utf-8');\n }\n\n const emitCommand = formatRunCommand(pm, 'prisma-next', 'contract emit');\n\n if (options.noInstall) {\n const pkg = targetPackageName(target);\n ui.note(\n [\n 'Run the following commands to complete setup:',\n '',\n ' 1. Install dependencies:',\n ` ${pm} ${formatAddArgs(pm, [pkg, 'dotenv']).join(' ')}`,\n ` ${pm} ${formatAddDevArgs(pm, ['prisma-next']).join(' ')}`,\n '',\n ' 2. Emit the contract:',\n ` ${emitCommand}`,\n ].join('\\n'),\n 'Manual steps',\n );\n } else {\n const pkg = targetPackageName(target);\n const spinner = ui.spinner();\n let installSucceeded = false;\n\n const exec = promisify(execFile);\n\n spinner.start(`Installing ${pkg}, dotenv, and prisma-next...`);\n try {\n await exec(pm, formatAddArgs(pm, [pkg, 'dotenv']), { cwd: baseDir });\n await exec(pm, formatAddDevArgs(pm, ['prisma-next']), { cwd: baseDir });\n spinner.stop(`Installed ${pkg}, dotenv, and prisma-next`);\n installSucceeded = true;\n } catch (err) {\n spinner.stop('Installation failed');\n const stderr =\n err instanceof Error && 'stderr' in err ? (err as { stderr: string }).stderr : '';\n ui.warn(\n [\n 'Could not install dependencies automatically.',\n ...(stderr ? [` ${stderr.trim()}`] : []),\n '',\n 'Run manually:',\n ` ${pm} ${formatAddArgs(pm, [pkg, 'dotenv']).join(' ')}`,\n ` ${pm} ${formatAddDevArgs(pm, ['prisma-next']).join(' ')}`,\n ].join('\\n'),\n );\n }\n\n if (installSucceeded) {\n spinner.start('Emitting contract...');\n try {\n const { executeContractEmit } = await import('../../control-api/operations/contract-emit');\n const configFilePath = join(baseDir, 'prisma-next.config.ts');\n await executeContractEmit({ configPath: configFilePath });\n spinner.stop('Contract emitted');\n } catch {\n spinner.stop('Contract emission failed');\n ui.warn(\n ['Could not emit contract automatically. Run manually:', ` ${emitCommand}`].join('\\n'),\n );\n }\n }\n }\n\n clack.outro('Done! Open prisma-next.md to get started.', { output: process.stderr });\n}\n"],"mappings":";;;;;;;;;AAMA,MAAMA,QAA6B,IAAI,IAAoB;CAAC;CAAQ;CAAO;CAAQ;CAAO;CAAO,CAAC;AAElG,eAAsB,qBAAqB,KAAsC;CAC/E,MAAM,SAAS,MAAM,OAAO,EAAE,KAAK,CAAC;AACpC,KAAI,UAAU,MAAM,IAAI,OAAO,KAAK,CAClC,QAAO,OAAO;AAEhB,QAAO;;AAGT,S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,SAAS,CAAC,CAAC,KAAK,IAAI;IACvD,KAAK,GAAG,GAAG,iBAAiB,IAAI,CAAC,cAAc,CAAC,CAAC,KAAK,IAAI;IAC3D,CAAC,KAAK,KAAK,CACb;;AAGH,MAAI,kBAAkB;AACpB,WAAQ,MAAM,uBAAuB;AACrC,OAAI;IACF,MAAM,EAAE,wBAAwB,MAAM,OAAO;AAE7C,UAAM,oBAAoB,EAAE,YADL,KAAK,SAAS,wBAAwB,EACL,CAAC;AACzD,YAAQ,KAAK,mBAAmB;WAC1B;AACN,YAAQ,KAAK,2BAA2B;AACxC,OAAG,KACD,CAAC,wDAAwD,KAAK,cAAc,CAAC,KAAK,KAAK,CACxF;;;;AAKP,OAAM,MAAM,6CAA6C,EAAE,QAAQ,QAAQ,QAAQ,CAAC"}
|
|
1
|
+
{"version":3,"file":"init-CQfo_4Ro.mjs","names":["KNOWN: ReadonlySet<string>","variables","vars: TemplateVars","vars: TemplateVars","REQUIRED_COMPILER_OPTIONS: Record<string, string | boolean>","files: FileEntry[]"],"sources":["../src/commands/init/detect-package-manager.ts","../src/commands/init/templates/render.ts","../src/commands/init/templates/agent-skill.ts","../src/commands/init/templates/code-templates.ts","../src/commands/init/templates/quick-reference.ts","../src/commands/init/templates/tsconfig.ts","../src/commands/init/init.ts"],"sourcesContent":["import { existsSync } from 'node:fs';\nimport { detect } from 'package-manager-detector/detect';\nimport { join } from 'pathe';\n\nexport type PackageManager = 'pnpm' | 'npm' | 'yarn' | 'bun' | 'deno';\n\nconst KNOWN: ReadonlySet<string> = new Set<PackageManager>(['pnpm', 'npm', 'yarn', 'bun', 'deno']);\n\nexport async function detectPackageManager(cwd: string): Promise<PackageManager> {\n const result = await detect({ cwd });\n if (result && KNOWN.has(result.name)) {\n return result.name as PackageManager;\n }\n return 'npm';\n}\n\nexport function hasProjectManifest(cwd: string): boolean {\n return (\n existsSync(join(cwd, 'package.json')) ||\n existsSync(join(cwd, 'deno.json')) ||\n existsSync(join(cwd, 'deno.jsonc'))\n );\n}\n\nexport function formatRunCommand(pm: PackageManager, bin: string, args: string): string {\n if (pm === 'npm') {\n return `npx ${bin} ${args}`;\n }\n if (pm === 'deno') {\n return `deno run npm:${bin} ${args}`;\n }\n return `${pm} ${bin} ${args}`;\n}\n\nexport function formatAddArgs(pm: PackageManager, packages: string[]): string[] {\n if (pm === 'deno') {\n return ['add', ...packages.map((p) => `npm:${p}`)];\n }\n return ['add', ...packages];\n}\n\nexport function formatAddDevArgs(pm: PackageManager, packages: string[]): string[] {\n if (pm === 'deno') {\n return ['add', '--dev', ...packages.map((p) => `npm:${p}`)];\n }\n return ['add', '-D', ...packages];\n}\n","import { readFileSync } from 'node:fs';\nimport { join } from 'pathe';\n\nexport function renderTemplate(\n templateFile: string,\n variableNames: readonly string[],\n vars: Record<string, string>,\n): string {\n const templatePath = join(import.meta.dirname, templateFile);\n const raw = readFileSync(templatePath, 'utf-8');\n let result = raw;\n for (const key of variableNames) {\n const value = vars[key];\n if (value === undefined) {\n throw new Error(`Template variable '${key}' is not defined`);\n }\n result = result.replaceAll(`{{${key}}}`, value);\n }\n return result;\n}\n","import { dirname } from 'pathe';\nimport type { TargetId } from './code-templates';\nimport { renderTemplate } from './render';\n\nexport const variables = ['schemaPath', 'schemaDir', 'dbImportPath', 'pkgRun'] as const;\n\ntype TemplateVars = Record<(typeof variables)[number], string>;\n\nexport function agentSkillMd(target: TargetId, schemaPath: string, pkgRun: string): string {\n const schemaDir = dirname(schemaPath);\n const vars: TemplateVars = {\n schemaPath,\n schemaDir,\n dbImportPath: `./${schemaDir}/db`,\n pkgRun,\n };\n const templateFile = `agent-skill-${target}.md`;\n return renderTemplate(templateFile, variables, vars);\n}\n","export type TargetId = 'postgres' | 'mongo';\nexport type AuthoringId = 'psl' | 'typescript';\n\nexport function targetPackageName(target: TargetId): string {\n return target === 'postgres' ? '@prisma-next/postgres' : '@prisma-next/mongo';\n}\n\nexport function targetLabel(target: TargetId): string {\n return target === 'postgres' ? 'PostgreSQL' : 'MongoDB';\n}\n\nexport function defaultSchemaPath(authoring: AuthoringId): string {\n if (authoring === 'typescript') {\n return 'prisma/contract.ts';\n }\n return 'prisma/contract.prisma';\n}\n\nexport function starterSchema(target: TargetId, authoring: AuthoringId): string {\n if (authoring === 'typescript') {\n return target === 'mongo' ? starterSchemaTsMongo() : starterSchemaTsPostgres();\n }\n return target === 'mongo' ? starterSchemaPslMongo() : starterSchemaPslPostgres();\n}\n\nfunction starterSchemaPslPostgres(): string {\n return `model User {\n id Int @id @default(autoincrement())\n email String @unique\n name String?\n posts Post[]\n createdAt DateTime @default(now())\n}\n\nmodel Post {\n id Int @id @default(autoincrement())\n title String\n content String?\n author User @relation(fields: [authorId], references: [id])\n authorId Int\n createdAt DateTime @default(now())\n}\n`;\n}\n\nfunction starterSchemaPslMongo(): string {\n return `model User {\n id ObjectId @id @map(\"_id\")\n email String @unique\n name String?\n posts Post[]\n @@map(\"users\")\n}\n\nmodel Post {\n id ObjectId @id @map(\"_id\")\n title String\n content String?\n author User @relation(fields: [authorId], references: [id])\n authorId ObjectId\n @@map(\"posts\")\n}\n`;\n}\n\nfunction starterSchemaTsPostgres(): string {\n return `import sqlFamily from '@prisma-next/family-sql/pack';\nimport { defineContract } from '@prisma-next/sql-contract-ts/contract-builder';\nimport postgresPack from '@prisma-next/target-postgres/pack';\n\nexport const contract = defineContract(\n { family: sqlFamily, target: postgresPack },\n ({ field, model, rel }) => ({\n models: {\n User: model('User', {\n fields: {\n id: field.id.uuidv7(),\n email: field.text().unique(),\n name: field.text().optional(),\n createdAt: field.createdAt(),\n },\n }).relations({\n posts: rel.hasMany('Post', { by: 'authorId' }),\n }),\n\n Post: model('Post', {\n fields: {\n id: field.id.uuidv7(),\n title: field.text(),\n content: field.text().optional(),\n authorId: field.uuid(),\n createdAt: field.createdAt(),\n },\n }).relations({\n author: rel.belongsTo('User', { from: 'authorId', to: 'id' }),\n }),\n },\n }),\n);\n`;\n}\n\nfunction starterSchemaTsMongo(): string {\n return `import mongoFamily from '@prisma-next/family-mongo/pack';\nimport { defineContract, field, model, rel } from '@prisma-next/mongo-contract-ts/contract-builder';\nimport mongoTarget from '@prisma-next/target-mongo/pack';\n\nconst User = model('User', {\n collection: 'users',\n fields: {\n _id: field.objectId(),\n email: field.string(),\n name: field.string().optional(),\n },\n});\n\nconst Post = model('Post', {\n collection: 'posts',\n fields: {\n _id: field.objectId(),\n title: field.string(),\n content: field.string().optional(),\n authorId: field.objectId(),\n },\n relations: {\n author: rel.belongsTo(User, { from: 'authorId', to: User.ref('_id') }),\n },\n});\n\nexport const contract = defineContract({\n family: mongoFamily,\n target: mongoTarget,\n models: { User, Post },\n});\n`;\n}\n\nexport function configFile(target: TargetId, contractPath: string): string {\n const pkg = targetPackageName(target);\n return `import 'dotenv/config';\nimport { defineConfig } from '${pkg}/config';\n\nexport default defineConfig({\n contract: ${JSON.stringify(contractPath)},\n db: {\n connection: process.env['DATABASE_URL']!,\n },\n});\n`;\n}\n\nexport function dbFile(target: TargetId): string {\n if (target === 'postgres') {\n return `import postgres from '@prisma-next/postgres/runtime';\nimport type { Contract } from './contract.d';\nimport contractJson from './contract.json' with { type: 'json' };\n\nexport const db = postgres<Contract>({ contractJson });\n`;\n }\n\n return `import mongo from '@prisma-next/mongo/runtime';\nimport type { Contract } from './contract.d';\nimport contractJson from './contract.json' with { type: 'json' };\n\nexport const db = mongo<Contract>({ contractJson });\n`;\n}\n","import { dirname } from 'pathe';\nimport type { TargetId } from './code-templates';\nimport { renderTemplate } from './render';\n\nexport const variables = ['schemaPath', 'schemaDir', 'dbImportPath', 'pkgRun'] as const;\n\ntype TemplateVars = Record<(typeof variables)[number], string>;\n\nexport function quickReferenceMd(target: TargetId, schemaPath: string, pkgRun: string): string {\n const schemaDir = dirname(schemaPath);\n const vars: TemplateVars = {\n schemaPath,\n schemaDir,\n dbImportPath: `./${schemaDir}/db`,\n pkgRun,\n };\n const templateFile = `quick-reference-${target}.md`;\n return renderTemplate(templateFile, variables, vars);\n}\n","export const REQUIRED_COMPILER_OPTIONS: Record<string, string | boolean> = {\n module: 'preserve',\n moduleResolution: 'bundler',\n resolveJsonModule: true,\n};\n\nexport function defaultTsConfig(): string {\n return JSON.stringify(\n {\n compilerOptions: {\n target: 'ES2022',\n ...REQUIRED_COMPILER_OPTIONS,\n strict: true,\n skipLibCheck: true,\n esModuleInterop: true,\n outDir: 'dist',\n },\n include: ['**/*.ts'],\n },\n null,\n 2,\n );\n}\n\nexport function mergeTsConfig(existing: string): string {\n const config = JSON.parse(existing) as Record<string, unknown>;\n const compilerOptions = (config['compilerOptions'] ?? {}) as Record<string, unknown>;\n\n for (const [key, value] of Object.entries(REQUIRED_COMPILER_OPTIONS)) {\n compilerOptions[key] = value;\n }\n\n config['compilerOptions'] = compilerOptions;\n return JSON.stringify(config, null, 2);\n}\n","import { execFile } from 'node:child_process';\nimport { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';\nimport { promisify } from 'node:util';\nimport * as clack from '@clack/prompts';\nimport { dirname, extname, isAbsolute, join, normalize } from 'pathe';\nimport { TerminalUI } from '../../utils/terminal-ui';\nimport {\n detectPackageManager,\n formatAddArgs,\n formatAddDevArgs,\n formatRunCommand,\n hasProjectManifest,\n} from './detect-package-manager';\nimport { agentSkillMd } from './templates/agent-skill';\nimport {\n type AuthoringId,\n configFile,\n dbFile,\n defaultSchemaPath,\n starterSchema,\n type TargetId,\n targetPackageName,\n} from './templates/code-templates';\nimport { quickReferenceMd } from './templates/quick-reference';\nimport { defaultTsConfig, mergeTsConfig } from './templates/tsconfig';\n\nexport interface InitOptions {\n readonly noInstall?: boolean;\n}\n\ninterface FileEntry {\n readonly path: string;\n readonly content: string;\n}\n\nexport async function runInit(baseDir: string, options: InitOptions): Promise<void> {\n const ui = new TerminalUI();\n\n clack.intro('prisma-next init', { output: process.stderr });\n\n if (!hasProjectManifest(baseDir)) {\n ui.error(\n 'No package.json or deno.json found. Initialize your project first (e.g. npm init or deno init), then re-run prisma-next init.',\n );\n process.exit(1);\n }\n\n const pm = await detectPackageManager(baseDir);\n const pkgRun = formatRunCommand(pm, 'prisma-next', '').trimEnd();\n\n if (existsSync(join(baseDir, 'prisma-next.config.ts'))) {\n const reinit = await clack.confirm({\n message:\n 'This project is already initialized. Re-initialize? This will overwrite all generated files.',\n initialValue: false,\n output: process.stderr,\n });\n if (clack.isCancel(reinit) || !reinit) {\n clack.cancel('Init cancelled.', { output: process.stderr });\n process.exit(0);\n }\n }\n\n const targetResult = await clack.select({\n message: 'What database are you using?',\n options: [\n { value: 'postgres' as TargetId, label: 'PostgreSQL' },\n { value: 'mongo' as TargetId, label: 'MongoDB' },\n ],\n output: process.stderr,\n });\n if (clack.isCancel(targetResult)) {\n clack.cancel('Init cancelled.', { output: process.stderr });\n process.exit(0);\n }\n const target = targetResult as TargetId;\n\n const authoringResult = await clack.select({\n message: 'How do you want to write your schema?',\n options: [\n { value: 'psl' as AuthoringId, label: 'Prisma Schema Language (.prisma)' },\n { value: 'typescript' as AuthoringId, label: 'TypeScript (.ts)' },\n ],\n output: process.stderr,\n });\n if (clack.isCancel(authoringResult)) {\n clack.cancel('Init cancelled.', { output: process.stderr });\n process.exit(0);\n }\n const authoring = authoringResult as AuthoringId;\n\n const schemaPathResult = await clack.text({\n message: 'Where should the schema file go?',\n initialValue: defaultSchemaPath(authoring),\n validate(value = '') {\n const trimmed = value.trim();\n if (trimmed.length === 0) return 'Path cannot be empty';\n if (trimmed.endsWith('/') || trimmed.endsWith('\\\\'))\n return 'Path must be a file, not a directory';\n if (!extname(trimmed)) return 'Path must include a file extension (e.g. .prisma or .ts)';\n return undefined;\n },\n output: process.stderr,\n });\n if (clack.isCancel(schemaPathResult)) {\n clack.cancel('Init cancelled.', { output: process.stderr });\n process.exit(0);\n }\n const schemaPath = normalize((schemaPathResult as string).trim());\n\n const schemaDir = dirname(schemaPath);\n const configPath = isAbsolute(schemaPath) ? schemaPath : `./${schemaPath}`;\n\n const files: FileEntry[] = [\n { path: schemaPath, content: starterSchema(target, authoring) },\n { path: 'prisma-next.config.ts', content: configFile(target, configPath) },\n { path: join(schemaDir, 'db.ts'), content: dbFile(target) },\n { path: 'prisma-next.md', content: quickReferenceMd(target, schemaPath, pkgRun) },\n {\n path: '.agents/skills/prisma-next/SKILL.md',\n content: agentSkillMd(target, schemaPath, pkgRun),\n },\n ];\n\n for (const file of files) {\n const fullPath = join(baseDir, file.path);\n mkdirSync(dirname(fullPath), { recursive: true });\n writeFileSync(fullPath, file.content, 'utf-8');\n }\n\n const tsconfigPath = join(baseDir, 'tsconfig.json');\n if (existsSync(tsconfigPath)) {\n const existing = readFileSync(tsconfigPath, 'utf-8');\n writeFileSync(tsconfigPath, mergeTsConfig(existing), 'utf-8');\n ui.log('Updated tsconfig.json with required compiler options.');\n } else {\n writeFileSync(tsconfigPath, defaultTsConfig(), 'utf-8');\n }\n\n const emitCommand = formatRunCommand(pm, 'prisma-next', 'contract emit');\n\n if (options.noInstall) {\n const pkg = targetPackageName(target);\n ui.note(\n [\n 'Run the following commands to complete setup:',\n '',\n ' 1. Install dependencies:',\n ` ${pm} ${formatAddArgs(pm, [pkg, 'dotenv']).join(' ')}`,\n ` ${pm} ${formatAddDevArgs(pm, ['prisma-next']).join(' ')}`,\n '',\n ' 2. Emit the contract:',\n ` ${emitCommand}`,\n ].join('\\n'),\n 'Manual steps',\n );\n } else {\n const pkg = targetPackageName(target);\n const spinner = ui.spinner();\n let installSucceeded = false;\n\n const exec = promisify(execFile);\n\n spinner.start(`Installing ${pkg}, dotenv, and prisma-next...`);\n try {\n await exec(pm, formatAddArgs(pm, [pkg, 'dotenv']), { cwd: baseDir });\n await exec(pm, formatAddDevArgs(pm, ['prisma-next']), { cwd: baseDir });\n spinner.stop(`Installed ${pkg}, dotenv, and prisma-next`);\n installSucceeded = true;\n } catch (err) {\n spinner.stop('Installation failed');\n const stderr =\n err instanceof Error && 'stderr' in err ? (err as { stderr: string }).stderr : '';\n ui.warn(\n [\n 'Could not install dependencies automatically.',\n ...(stderr ? [` ${stderr.trim()}`] : []),\n '',\n 'Run manually:',\n ` ${pm} ${formatAddArgs(pm, [pkg, 'dotenv']).join(' ')}`,\n ` ${pm} ${formatAddDevArgs(pm, ['prisma-next']).join(' ')}`,\n ].join('\\n'),\n );\n }\n\n if (installSucceeded) {\n spinner.start('Emitting contract...');\n try {\n const { executeContractEmit } = await import('../../control-api/operations/contract-emit');\n const configFilePath = join(baseDir, 'prisma-next.config.ts');\n await executeContractEmit({ configPath: configFilePath });\n spinner.stop('Contract emitted');\n } catch {\n spinner.stop('Contract emission failed');\n ui.warn(\n ['Could not emit contract automatically. Run manually:', ` ${emitCommand}`].join('\\n'),\n );\n }\n }\n }\n\n clack.outro('Done! Open prisma-next.md to get started.', { output: process.stderr });\n}\n"],"mappings":";;;;;;;;;AAMA,MAAMA,QAA6B,IAAI,IAAoB;CAAC;CAAQ;CAAO;CAAQ;CAAO;CAAO,CAAC;AAElG,eAAsB,qBAAqB,KAAsC;CAC/E,MAAM,SAAS,MAAM,OAAO,EAAE,KAAK,CAAC;AACpC,KAAI,UAAU,MAAM,IAAI,OAAO,KAAK,CAClC,QAAO,OAAO;AAEhB,QAAO;;AAGT,SAAgB,mBAAmB,KAAsB;AACvD,QACE,WAAW,KAAK,KAAK,eAAe,CAAC,IACrC,WAAW,KAAK,KAAK,YAAY,CAAC,IAClC,WAAW,KAAK,KAAK,aAAa,CAAC;;AAIvC,SAAgB,iBAAiB,IAAoB,KAAa,MAAsB;AACtF,KAAI,OAAO,MACT,QAAO,OAAO,IAAI,GAAG;AAEvB,KAAI,OAAO,OACT,QAAO,gBAAgB,IAAI,GAAG;AAEhC,QAAO,GAAG,GAAG,GAAG,IAAI,GAAG;;AAGzB,SAAgB,cAAc,IAAoB,UAA8B;AAC9E,KAAI,OAAO,OACT,QAAO,CAAC,OAAO,GAAG,SAAS,KAAK,MAAM,OAAO,IAAI,CAAC;AAEpD,QAAO,CAAC,OAAO,GAAG,SAAS;;AAG7B,SAAgB,iBAAiB,IAAoB,UAA8B;A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|
|
|
1
|
-
import { t as loadConfig } from "./config-loader-
|
|
2
|
-
import { _ as errorUnexpected, c as errorDriverRequired, o as errorDatabaseConnectionRequired, t as CliStructuredError } from "./cli-errors-
|
|
3
|
-
import { t as createControlClient } from "./client-
|
|
4
|
-
import { _ as formatStyledHeader, a as maskConnectionUrl, l as sanitizeErrorMessage } from "./result-handler-
|
|
5
|
-
import { t as createProgressAdapter } from "./progress-adapter-
|
|
1
|
+
import { t as loadConfig } from "./config-loader-_W4T21X1.mjs";
|
|
2
|
+
import { _ as errorUnexpected, c as errorDriverRequired, o as errorDatabaseConnectionRequired, t as CliStructuredError } from "./cli-errors-DHq6GQGu.mjs";
|
|
3
|
+
import { t as createControlClient } from "./client-TG7rbCWT.mjs";
|
|
4
|
+
import { _ as formatStyledHeader, a as maskConnectionUrl, l as sanitizeErrorMessage } from "./result-handler-CIyu0Pdt.mjs";
|
|
5
|
+
import { t as createProgressAdapter } from "./progress-adapter-B-YvmcDu.mjs";
|
|
6
6
|
import { notOk, ok } from "@prisma-next/utils/result";
|
|
7
7
|
import { relative, resolve } from "pathe";
|
|
8
8
|
import { validatePrintableSqlSchemaIR } from "@prisma-next/psl-printer";
|
|
@@ -88,4 +88,4 @@ async function inspectLiveSchema(options, flags, ui, startTime, context) {
|
|
|
88
88
|
|
|
89
89
|
//#endregion
|
|
90
90
|
export { inspectLiveSchema as t };
|
|
91
|
-
//# sourceMappingURL=inspect-live-schema-
|
|
91
|
+
//# sourceMappingURL=inspect-live-schema-DWzf4Q_m.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inspect-live-schema-
|
|
1
|
+
{"version":3,"file":"inspect-live-schema-DWzf4Q_m.mjs","names":["config: LoadedCliConfig","details: Array<{ label: string; value: string }>"],"sources":["../src/commands/inspect-live-schema.ts"],"sourcesContent":["import type { CoreSchemaView } from '@prisma-next/framework-components/control';\nimport { validatePrintableSqlSchemaIR } from '@prisma-next/psl-printer';\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 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 schemaIR = await client.introspect({\n connection: dbConnection,\n onProgress,\n });\n // TODO(TML-2251): Remove SQL-specific branching — SQL should use the same family-agnostic path as Mongo.\n const schema =\n config.family.familyId === 'sql' ? validatePrintableSqlSchemaIR(schemaIR) : schemaIR;\n const schemaView = client.toSchemaView(schema);\n\n const dbUrl = typeof dbConnection === 'string' ? maskConnectionUrl(dbConnection) : undefined;\n\n return ok({\n config,\n schema,\n schemaView,\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":";;;;;;;;;;AAgDA,eAAsB,kBACpB,SACA,OACA,IACA,WACA,SAC8D;CAC9D,IAAIA;AACJ,KA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M,WAAW,MAAM,OAAO,WAAW;GACvC,YAAY;GACZ;GACD,CAAC;EAEF,MAAM,SACJ,OAAO,OAAO,aAAa,QAAQ,6BAA6B,SAAS,GAAG;EAC9E,MAAM,aAAa,OAAO,aAAa,OAAO;EAE9C,MAAM,QAAQ,OAAO,iBAAiB,WAAW,kBAAkB,aAAa,GAAG;AAEnF,SAAO,GAAG;GACR;GACA;GACA;GACA,QAAQ;IACN,UAAU,OAAO,OAAO;IACxB,IAAI,OAAO,OAAO;IACnB;GACD,MAAM;IACJ;IACA,GAAI,QAAQ,EAAE,OAAO,GAAG,EAAE;IAC3B;GACD,SAAS,EACP,OAAO,KAAK,KAAK,GAAG,WACrB;GACF,CAAC;UACK,OAAO;AACd,MAAI,mBAAmB,GAAG,MAAM,CAC9B,QAAO,MAAM,MAAM;EAIrB,MAAM,cAAc,qBADD,iBAAiB,QAAQ,MAAM,UAAU,OAAO,MAAM,EAGvE,OAAO,iBAAiB,WAAW,eAAe,OACnD;AACD,SAAO,MACL,gBAAgB,aAAa,EAC3B,KAAK,2BAA2B,QAAQ,YAAY,IAAI,eACzD,CAAC,CACH;WACO;AACR,QAAM,OAAO,OAAO"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { Migration } from "@prisma-next/migration-tools/migration";
|
|
2
|
+
|
|
3
|
+
//#region src/migration-cli.d.ts
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Constructor shape accepted by `MigrationCLI.run`. `Migration` subclasses
|
|
7
|
+
* accept an optional `ControlStack` in their constructor (each subclass
|
|
8
|
+
* narrows the stack to its own family/target generics); the CLI always
|
|
9
|
+
* passes one assembled from the loaded config. We use a rest-args `any[]`
|
|
10
|
+
* constructor signature so that subclass constructors with narrower
|
|
11
|
+
* parameter types remain assignable - constructor type compatibility in
|
|
12
|
+
* TS is contravariant in the parameter, and a wider `unknown` parameter
|
|
13
|
+
* on the alias side would reject any narrower subclass signature.
|
|
14
|
+
*
|
|
15
|
+
* The CLI only ever passes one argument (`new MigrationClass(stack)`);
|
|
16
|
+
* the rest-arity is purely a type-compatibility concession for subclass
|
|
17
|
+
* constructors that declare narrower parameter types, not an extension
|
|
18
|
+
* point for additional construction arguments.
|
|
19
|
+
*/
|
|
20
|
+
type MigrationConstructor = new (...args: any[]) => Migration;
|
|
21
|
+
/**
|
|
22
|
+
* The CLI surface invoked by an authored `migration.ts` file. Exposed as
|
|
23
|
+
* a class with a static `run` method (rather than a free function) to
|
|
24
|
+
* give the concept a stable identity in the ubiquitous language: this is
|
|
25
|
+
* the "migration-file CLI", distinct from the apply-time runner that
|
|
26
|
+
* executes migration JSON ops.
|
|
27
|
+
*
|
|
28
|
+
* Currently a single static method. Future surface (e.g. a programmatic
|
|
29
|
+
* `MigrationCLI.serializeOnly(...)` for tests, or extra subcommands) can
|
|
30
|
+
* land here without changing the import shape used by every authored
|
|
31
|
+
* migration.
|
|
32
|
+
*/
|
|
33
|
+
declare class MigrationCLI {
|
|
34
|
+
/**
|
|
35
|
+
* Orchestrates a class-flow `migration.ts` script run. Awaitable:
|
|
36
|
+
* callers may `await MigrationCLI.run(...)` to surface async failures
|
|
37
|
+
* from config loading, but the typical usage pattern (top-level call
|
|
38
|
+
* after the class definition) does not require awaiting because
|
|
39
|
+
* node's module evaluation keeps the promise alive until completion.
|
|
40
|
+
*
|
|
41
|
+
* Any throwable inside this function must surface through the internal
|
|
42
|
+
* try/catch — script callers do not await, so an unhandled rejection
|
|
43
|
+
* would silently exit 0. Treat the try/catch as load-bearing for the
|
|
44
|
+
* no-await usage pattern.
|
|
45
|
+
*/
|
|
46
|
+
static run(importMetaUrl: string, MigrationClass: MigrationConstructor): Promise<void>;
|
|
47
|
+
}
|
|
48
|
+
//#endregion
|
|
49
|
+
export { MigrationCLI, MigrationConstructor };
|
|
50
|
+
//# sourceMappingURL=migration-cli.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migration-cli.d.mts","names":[],"sources":["../src/migration-cli.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;;;;;;;KAqEY,oBAAA,2BAA+C;;;;;;;;;;;;;cAiE9C,YAAA;;;;;;;;;;;;;oDAa6C,uBAAuB"}
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import { t as loadConfig } from "./config-loader-_W4T21X1.mjs";
|
|
2
|
+
import { readFileSync, writeFileSync } from "node:fs";
|
|
3
|
+
import { CliStructuredError, errorMigrationCliInvalidConfigArg } from "@prisma-next/errors/control";
|
|
4
|
+
import { dirname, join } from "pathe";
|
|
5
|
+
import { createControlStack } from "@prisma-next/framework-components/control";
|
|
6
|
+
import { errorMigrationTargetMismatch } from "@prisma-next/errors/migration";
|
|
7
|
+
import { fileURLToPath } from "node:url";
|
|
8
|
+
import { buildMigrationArtifacts, isDirectEntrypoint, printMigrationHelp } from "@prisma-next/migration-tools/migration";
|
|
9
|
+
|
|
10
|
+
//#region src/migration-cli.ts
|
|
11
|
+
/**
|
|
12
|
+
* The migration-file CLI interface: the actor invoked when the author runs
|
|
13
|
+
* `node migration.ts` directly.
|
|
14
|
+
*
|
|
15
|
+
* Naming: this is *not* a "migration runner" in the apply-time sense. The
|
|
16
|
+
* apply-time runner is the thing `prisma-next migration apply` uses to
|
|
17
|
+
* execute migration JSON ops against a database. `MigrationCLI` is the
|
|
18
|
+
* tiny CLI surface owned by an authored `migration.ts` file: parse the
|
|
19
|
+
* file's argv, load the project's `prisma-next.config.ts`, assemble a
|
|
20
|
+
* `ControlStack`, instantiate the migration class, and serialize.
|
|
21
|
+
*
|
|
22
|
+
* The user authors a migration class, then calls
|
|
23
|
+
* `MigrationCLI.run(import.meta.url, MigrationClass)` at module scope
|
|
24
|
+
* after the class definition. When the file is invoked as a node
|
|
25
|
+
* entrypoint (`node migration.ts`), the CLI:
|
|
26
|
+
*
|
|
27
|
+
* 1. Detects whether the file is the direct entrypoint (no-op when imported).
|
|
28
|
+
* 2. Parses CLI args (`--help`, `--dry-run`, `--config <path>`).
|
|
29
|
+
* 3. Loads the project's `prisma-next.config.ts` via the same `loadConfig`
|
|
30
|
+
* the CLI commands use, walking up from the migration file's directory.
|
|
31
|
+
* 4. Probe-instantiates the migration class without a stack so it can read
|
|
32
|
+
* `targetId` and verify it matches `config.target.targetId`
|
|
33
|
+
* (`PN-MIG-2006` on mismatch) before any stack-driven adapter
|
|
34
|
+
* construction runs.
|
|
35
|
+
* 5. Assembles a `ControlStack` from the loaded config descriptors and
|
|
36
|
+
* constructs the migration with that stack.
|
|
37
|
+
* 6. Reads any previously-scaffolded `migration.json`, then calls
|
|
38
|
+
* `buildMigrationArtifacts` from `@prisma-next/migration-tools` to
|
|
39
|
+
* produce in-memory `ops.json` + `migration.json` content. Persists
|
|
40
|
+
* the result to disk (or prints in dry-run mode).
|
|
41
|
+
*
|
|
42
|
+
* File I/O lives here, in `@prisma-next/cli`: this is the only place
|
|
43
|
+
* that legitimately combines config loading, stack assembly, and
|
|
44
|
+
* on-disk persistence. `@prisma-next/migration-tools` owns the pure
|
|
45
|
+
* conversion from a `Migration` instance to artifact strings; `Migration`
|
|
46
|
+
* stays a pure abstract class.
|
|
47
|
+
*/
|
|
48
|
+
/**
|
|
49
|
+
* Parse the subset of `process.argv` that `MigrationCLI.run` cares about.
|
|
50
|
+
* Recognised flags: `--help`, `--dry-run`, `--config <path>` /
|
|
51
|
+
* `--config=<path>`. Unknown flags are ignored to keep the surface
|
|
52
|
+
* forgiving for ad-hoc tooling that wraps a migration file.
|
|
53
|
+
*
|
|
54
|
+
* Throws `errorMigrationCliInvalidConfigArg` (`PN-CLI-4012`) when
|
|
55
|
+
* `--config` is missing its path argument or is followed by another flag
|
|
56
|
+
* (e.g. `--config --dry-run`); silently consuming the next flag would
|
|
57
|
+
* either drop dry-run handling or serialize against the wrong project.
|
|
58
|
+
*
|
|
59
|
+
* NOTE: this hand-rolled parser is a known wart, tracked separately by
|
|
60
|
+
* TML-2318 ("Migration CLI: replace handrolled arg parser with shared
|
|
61
|
+
* CLI library"). Until that lands the surface is intentionally tiny.
|
|
62
|
+
*/
|
|
63
|
+
function parseArgs(argv) {
|
|
64
|
+
let help = false;
|
|
65
|
+
let dryRun = false;
|
|
66
|
+
let configPath;
|
|
67
|
+
for (let i = 0; i < argv.length; i++) {
|
|
68
|
+
const arg = argv[i];
|
|
69
|
+
if (arg === "--help" || arg === "-h") help = true;
|
|
70
|
+
else if (arg === "--dry-run") dryRun = true;
|
|
71
|
+
else if (arg === "--config") {
|
|
72
|
+
const next = argv[i + 1];
|
|
73
|
+
if (next === void 0) throw errorMigrationCliInvalidConfigArg();
|
|
74
|
+
if (next.startsWith("-")) throw errorMigrationCliInvalidConfigArg({ nextToken: next });
|
|
75
|
+
configPath = next;
|
|
76
|
+
i++;
|
|
77
|
+
} else if (arg.startsWith("--config=")) configPath = arg.slice(9);
|
|
78
|
+
}
|
|
79
|
+
return {
|
|
80
|
+
help,
|
|
81
|
+
dryRun,
|
|
82
|
+
configPath
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* The CLI surface invoked by an authored `migration.ts` file. Exposed as
|
|
87
|
+
* a class with a static `run` method (rather than a free function) to
|
|
88
|
+
* give the concept a stable identity in the ubiquitous language: this is
|
|
89
|
+
* the "migration-file CLI", distinct from the apply-time runner that
|
|
90
|
+
* executes migration JSON ops.
|
|
91
|
+
*
|
|
92
|
+
* Currently a single static method. Future surface (e.g. a programmatic
|
|
93
|
+
* `MigrationCLI.serializeOnly(...)` for tests, or extra subcommands) can
|
|
94
|
+
* land here without changing the import shape used by every authored
|
|
95
|
+
* migration.
|
|
96
|
+
*/
|
|
97
|
+
var MigrationCLI = class {
|
|
98
|
+
/**
|
|
99
|
+
* Orchestrates a class-flow `migration.ts` script run. Awaitable:
|
|
100
|
+
* callers may `await MigrationCLI.run(...)` to surface async failures
|
|
101
|
+
* from config loading, but the typical usage pattern (top-level call
|
|
102
|
+
* after the class definition) does not require awaiting because
|
|
103
|
+
* node's module evaluation keeps the promise alive until completion.
|
|
104
|
+
*
|
|
105
|
+
* Any throwable inside this function must surface through the internal
|
|
106
|
+
* try/catch — script callers do not await, so an unhandled rejection
|
|
107
|
+
* would silently exit 0. Treat the try/catch as load-bearing for the
|
|
108
|
+
* no-await usage pattern.
|
|
109
|
+
*/
|
|
110
|
+
static async run(importMetaUrl, MigrationClass) {
|
|
111
|
+
if (!importMetaUrl) return;
|
|
112
|
+
if (!isDirectEntrypoint(importMetaUrl)) return;
|
|
113
|
+
try {
|
|
114
|
+
const args = parseArgs(process.argv.slice(2));
|
|
115
|
+
if (args.help) {
|
|
116
|
+
printMigrationHelp();
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
const migrationDir = dirname(fileURLToPath(importMetaUrl));
|
|
120
|
+
const config = await loadConfig(args.configPath);
|
|
121
|
+
const probe = new MigrationClass();
|
|
122
|
+
if (probe.targetId !== config.target.targetId) throw errorMigrationTargetMismatch({
|
|
123
|
+
migrationTargetId: probe.targetId,
|
|
124
|
+
configTargetId: config.target.targetId
|
|
125
|
+
});
|
|
126
|
+
serializeMigrationToDisk(new MigrationClass(createControlStack(config)), migrationDir, args.dryRun);
|
|
127
|
+
} catch (err) {
|
|
128
|
+
if (CliStructuredError.is(err)) process.stderr.write(`${err.message}: ${err.why}\n`);
|
|
129
|
+
else process.stderr.write(`${err instanceof Error ? err.message : String(err)}\n`);
|
|
130
|
+
process.exitCode = 1;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
/**
|
|
135
|
+
* Read a previously-scaffolded `migration.json` from disk, returning
|
|
136
|
+
* `null` when the file is missing or unparseable. The CLI feeds this into
|
|
137
|
+
* `buildMigrationArtifacts` so the pure builder can preserve fields owned
|
|
138
|
+
* by `migration plan` (contract bookends, hints, labels, `createdAt`)
|
|
139
|
+
* across re-emits.
|
|
140
|
+
*/
|
|
141
|
+
function readExistingManifest(manifestPath) {
|
|
142
|
+
let raw;
|
|
143
|
+
try {
|
|
144
|
+
raw = readFileSync(manifestPath, "utf-8");
|
|
145
|
+
} catch {
|
|
146
|
+
return null;
|
|
147
|
+
}
|
|
148
|
+
try {
|
|
149
|
+
return JSON.parse(raw);
|
|
150
|
+
} catch {
|
|
151
|
+
return null;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Persist a migration instance's artifacts to `migrationDir`. In
|
|
156
|
+
* `dryRun` mode the artifacts are printed to stdout (with the same
|
|
157
|
+
* `--- migration.json --- / --- ops.json ---` framing the legacy
|
|
158
|
+
* `serializeMigration` helper used) and no files are written. Otherwise
|
|
159
|
+
* `ops.json` and `migration.json` are written next to `migration.ts` and
|
|
160
|
+
* a confirmation line is printed.
|
|
161
|
+
*
|
|
162
|
+
* File I/O lives in the CLI rather than `@prisma-next/migration-tools`
|
|
163
|
+
* so the migration-tools package stays focused on the pure
|
|
164
|
+
* `Migration` → in-memory artifact conversion. The CLI is the only
|
|
165
|
+
* legitimate site for combining config loading, stack assembly, and
|
|
166
|
+
* filesystem persistence.
|
|
167
|
+
*/
|
|
168
|
+
function serializeMigrationToDisk(instance, migrationDir, dryRun) {
|
|
169
|
+
const manifestPath = join(migrationDir, "migration.json");
|
|
170
|
+
const { opsJson, manifestJson } = buildMigrationArtifacts(instance, readExistingManifest(manifestPath));
|
|
171
|
+
if (dryRun) {
|
|
172
|
+
process.stdout.write(`--- migration.json ---\n${manifestJson}\n`);
|
|
173
|
+
process.stdout.write("--- ops.json ---\n");
|
|
174
|
+
process.stdout.write(`${opsJson}\n`);
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
writeFileSync(join(migrationDir, "ops.json"), opsJson);
|
|
178
|
+
writeFileSync(manifestPath, manifestJson);
|
|
179
|
+
process.stdout.write(`Wrote ops.json + migration.json to ${migrationDir}\n`);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
//#endregion
|
|
183
|
+
export { MigrationCLI };
|
|
184
|
+
//# sourceMappingURL=migration-cli.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migration-cli.mjs","names":["configPath: string | undefined","raw: string"],"sources":["../src/migration-cli.ts"],"sourcesContent":["/**\n * The migration-file CLI interface: the actor invoked when the author runs\n * `node migration.ts` directly.\n *\n * Naming: this is *not* a \"migration runner\" in the apply-time sense. The\n * apply-time runner is the thing `prisma-next migration apply` uses to\n * execute migration JSON ops against a database. `MigrationCLI` is the\n * tiny CLI surface owned by an authored `migration.ts` file: parse the\n * file's argv, load the project's `prisma-next.config.ts`, assemble a\n * `ControlStack`, instantiate the migration class, and serialize.\n *\n * The user authors a migration class, then calls\n * `MigrationCLI.run(import.meta.url, MigrationClass)` at module scope\n * after the class definition. When the file is invoked as a node\n * entrypoint (`node migration.ts`), the CLI:\n *\n * 1. Detects whether the file is the direct entrypoint (no-op when imported).\n * 2. Parses CLI args (`--help`, `--dry-run`, `--config <path>`).\n * 3. Loads the project's `prisma-next.config.ts` via the same `loadConfig`\n * the CLI commands use, walking up from the migration file's directory.\n * 4. Probe-instantiates the migration class without a stack so it can read\n * `targetId` and verify it matches `config.target.targetId`\n * (`PN-MIG-2006` on mismatch) before any stack-driven adapter\n * construction runs.\n * 5. Assembles a `ControlStack` from the loaded config descriptors and\n * constructs the migration with that stack.\n * 6. Reads any previously-scaffolded `migration.json`, then calls\n * `buildMigrationArtifacts` from `@prisma-next/migration-tools` to\n * produce in-memory `ops.json` + `migration.json` content. Persists\n * the result to disk (or prints in dry-run mode).\n *\n * File I/O lives here, in `@prisma-next/cli`: this is the only place\n * that legitimately combines config loading, stack assembly, and\n * on-disk persistence. `@prisma-next/migration-tools` owns the pure\n * conversion from a `Migration` instance to artifact strings; `Migration`\n * stays a pure abstract class.\n */\n\nimport { readFileSync, writeFileSync } from 'node:fs';\nimport { fileURLToPath } from 'node:url';\nimport { CliStructuredError, errorMigrationCliInvalidConfigArg } from '@prisma-next/errors/control';\nimport { errorMigrationTargetMismatch } from '@prisma-next/errors/migration';\nimport { createControlStack } from '@prisma-next/framework-components/control';\nimport {\n buildMigrationArtifacts,\n isDirectEntrypoint,\n type Migration,\n printMigrationHelp,\n} from '@prisma-next/migration-tools/migration';\nimport type { MigrationManifest } from '@prisma-next/migration-tools/types';\nimport { dirname, join } from 'pathe';\nimport { loadConfig } from './config-loader';\n\n/**\n * Constructor shape accepted by `MigrationCLI.run`. `Migration` subclasses\n * accept an optional `ControlStack` in their constructor (each subclass\n * narrows the stack to its own family/target generics); the CLI always\n * passes one assembled from the loaded config. We use a rest-args `any[]`\n * constructor signature so that subclass constructors with narrower\n * parameter types remain assignable - constructor type compatibility in\n * TS is contravariant in the parameter, and a wider `unknown` parameter\n * on the alias side would reject any narrower subclass signature.\n *\n * The CLI only ever passes one argument (`new MigrationClass(stack)`);\n * the rest-arity is purely a type-compatibility concession for subclass\n * constructors that declare narrower parameter types, not an extension\n * point for additional construction arguments.\n */\n// biome-ignore lint/suspicious/noExplicitAny: see JSDoc - rest args with any are the idiomatic TS pattern for accepting arbitrary subclass constructor signatures\nexport type MigrationConstructor = new (...args: any[]) => Migration;\n\ninterface ParsedArgs {\n readonly help: boolean;\n readonly dryRun: boolean;\n readonly configPath: string | undefined;\n}\n\n/**\n * Parse the subset of `process.argv` that `MigrationCLI.run` cares about.\n * Recognised flags: `--help`, `--dry-run`, `--config <path>` /\n * `--config=<path>`. Unknown flags are ignored to keep the surface\n * forgiving for ad-hoc tooling that wraps a migration file.\n *\n * Throws `errorMigrationCliInvalidConfigArg` (`PN-CLI-4012`) when\n * `--config` is missing its path argument or is followed by another flag\n * (e.g. `--config --dry-run`); silently consuming the next flag would\n * either drop dry-run handling or serialize against the wrong project.\n *\n * NOTE: this hand-rolled parser is a known wart, tracked separately by\n * TML-2318 (\"Migration CLI: replace handrolled arg parser with shared\n * CLI library\"). Until that lands the surface is intentionally tiny.\n */\nfunction parseArgs(argv: readonly string[]): ParsedArgs {\n let help = false;\n let dryRun = false;\n let configPath: string | undefined;\n\n for (let i = 0; i < argv.length; i++) {\n const arg = argv[i]!;\n if (arg === '--help' || arg === '-h') {\n help = true;\n } else if (arg === '--dry-run') {\n dryRun = true;\n } else if (arg === '--config') {\n const next = argv[i + 1];\n if (next === undefined) {\n throw errorMigrationCliInvalidConfigArg();\n }\n if (next.startsWith('-')) {\n throw errorMigrationCliInvalidConfigArg({ nextToken: next });\n }\n configPath = next;\n i++;\n } else if (arg.startsWith('--config=')) {\n configPath = arg.slice('--config='.length);\n }\n }\n\n return { help, dryRun, configPath };\n}\n\n/**\n * The CLI surface invoked by an authored `migration.ts` file. Exposed as\n * a class with a static `run` method (rather than a free function) to\n * give the concept a stable identity in the ubiquitous language: this is\n * the \"migration-file CLI\", distinct from the apply-time runner that\n * executes migration JSON ops.\n *\n * Currently a single static method. Future surface (e.g. a programmatic\n * `MigrationCLI.serializeOnly(...)` for tests, or extra subcommands) can\n * land here without changing the import shape used by every authored\n * migration.\n */\n// biome-ignore lint/complexity/noStaticOnlyClass: see JSDoc - intentional class facade for the migration-file CLI surface; future methods will share state derived from argv/config.\nexport class MigrationCLI {\n /**\n * Orchestrates a class-flow `migration.ts` script run. Awaitable:\n * callers may `await MigrationCLI.run(...)` to surface async failures\n * from config loading, but the typical usage pattern (top-level call\n * after the class definition) does not require awaiting because\n * node's module evaluation keeps the promise alive until completion.\n *\n * Any throwable inside this function must surface through the internal\n * try/catch — script callers do not await, so an unhandled rejection\n * would silently exit 0. Treat the try/catch as load-bearing for the\n * no-await usage pattern.\n */\n static async run(importMetaUrl: string, MigrationClass: MigrationConstructor): Promise<void> {\n if (!importMetaUrl) return;\n if (!isDirectEntrypoint(importMetaUrl)) return;\n\n try {\n const args = parseArgs(process.argv.slice(2));\n\n if (args.help) {\n printMigrationHelp();\n return;\n }\n\n const migrationFile = fileURLToPath(importMetaUrl);\n const migrationDir = dirname(migrationFile);\n\n const config = await loadConfig(args.configPath);\n\n // Probe-instantiate without a stack so we can read `targetId` before\n // any target-specific constructor side effects (e.g.\n // `PostgresMigration`'s `stack.adapter.create(stack)`) run. Concrete\n // subclasses are required to accept the no-arg form; the abstract\n // `Migration` constructor declares `stack?` and target subclasses\n // (Postgres, Mongo) propagate that optionality. This makes the\n // target-mismatch guard fail fast with `PN-MIG-2006` before any\n // stack-driven adapter construction begins, even if the wrong-target\n // adapter's `create` would otherwise succeed and silently misshapen\n // the stored adapter cast.\n const probe = new MigrationClass();\n\n if (probe.targetId !== config.target.targetId) {\n throw errorMigrationTargetMismatch({\n migrationTargetId: probe.targetId,\n configTargetId: config.target.targetId,\n });\n }\n\n const stack = createControlStack(config);\n const instance = new MigrationClass(stack);\n\n serializeMigrationToDisk(instance, migrationDir, args.dryRun);\n } catch (err) {\n if (CliStructuredError.is(err)) {\n process.stderr.write(`${err.message}: ${err.why}\\n`);\n } else {\n process.stderr.write(`${err instanceof Error ? err.message : String(err)}\\n`);\n }\n process.exitCode = 1;\n }\n }\n}\n\n/**\n * Read a previously-scaffolded `migration.json` from disk, returning\n * `null` when the file is missing or unparseable. The CLI feeds this into\n * `buildMigrationArtifacts` so the pure builder can preserve fields owned\n * by `migration plan` (contract bookends, hints, labels, `createdAt`)\n * across re-emits.\n */\nfunction readExistingManifest(manifestPath: string): Partial<MigrationManifest> | null {\n let raw: string;\n try {\n raw = readFileSync(manifestPath, 'utf-8');\n } catch {\n return null;\n }\n try {\n return JSON.parse(raw) as Partial<MigrationManifest>;\n } catch {\n return null;\n }\n}\n\n/**\n * Persist a migration instance's artifacts to `migrationDir`. In\n * `dryRun` mode the artifacts are printed to stdout (with the same\n * `--- migration.json --- / --- ops.json ---` framing the legacy\n * `serializeMigration` helper used) and no files are written. Otherwise\n * `ops.json` and `migration.json` are written next to `migration.ts` and\n * a confirmation line is printed.\n *\n * File I/O lives in the CLI rather than `@prisma-next/migration-tools`\n * so the migration-tools package stays focused on the pure\n * `Migration` → in-memory artifact conversion. The CLI is the only\n * legitimate site for combining config loading, stack assembly, and\n * filesystem persistence.\n */\nfunction serializeMigrationToDisk(\n instance: Migration,\n migrationDir: string,\n dryRun: boolean,\n): void {\n const manifestPath = join(migrationDir, 'migration.json');\n const existing = readExistingManifest(manifestPath);\n const { opsJson, manifestJson } = buildMigrationArtifacts(instance, existing);\n\n if (dryRun) {\n process.stdout.write(`--- migration.json ---\\n${manifestJson}\\n`);\n process.stdout.write('--- ops.json ---\\n');\n process.stdout.write(`${opsJson}\\n`);\n return;\n }\n\n writeFileSync(join(migrationDir, 'ops.json'), opsJson);\n writeFileSync(manifestPath, manifestJson);\n\n process.stdout.write(`Wrote ops.json + migration.json to ${migrationDir}\\n`);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4FA,SAAS,UAAU,MAAqC;CACtD,IAAI,OAAO;CACX,IAAI,SAAS;CACb,IAAIA;AAEJ,MAAK,IAAI,IAAI,GAAG,IAAI,KAAK,QAAQ,KAAK;EACpC,MAAM,MAAM,KAAK;AACjB,MAAI,QAAQ,YAAY,QAAQ,KAC9B,QAAO;WACE,QAAQ,YACjB,UAAS;WACA,QAAQ,YAAY;GAC7B,MAAM,OAAO,KAAK,IAAI;AACtB,OAAI,SAAS,OACX,OAAM,mCAAmC;AAE3C,OAAI,KAAK,WAAW,IAAI,CACtB,OAAM,kCAAkC,EAAE,WAAW,MAAM,CAAC;AAE9D,gBAAa;AACb;aACS,IAAI,WAAW,YAAY,CACpC,cAAa,IAAI,MAAM,EAAmB;;AAI9C,QAAO;EAAE;EAAM;EAAQ;EAAY;;;;;;;;;;;;;;AAgBrC,IAAa,eAAb,MAA0B;;;;;;;;;;;;;CAaxB,aAAa,IAAI,eAAuB,gBAAqD;AAC3F,MAAI,CAAC,cAAe;AACpB,MAAI,CAAC,mBAAmB,cAAc,CAAE;AAExC,MAAI;GACF,MAAM,OAAO,UAAU,QAAQ,KAAK,MAAM,EAAE,CAAC;AAE7C,OAAI,KAAK,MAAM;AACb,wBAAoB;AACpB;;GAIF,MAAM,eAAe,QADC,cAAc,cAAc,CACP;GAE3C,MAAM,SAAS,MAAM,WAAW,KAAK,WAAW;GAYhD,MAAM,QAAQ,IAAI,gBAAgB;AAElC,OAAI,MAAM,aAAa,OAAO,OAAO,SACnC,OAAM,6BAA6B;IACjC,mBAAmB,MAAM;IACzB,gBAAgB,OAAO,OAAO;IAC/B,CAAC;AAMJ,4BAFiB,IAAI,eADP,mBAAmB,OAAO,CACE,EAEP,cAAc,KAAK,OAAO;WACtD,KAAK;AACZ,OAAI,mBAAmB,GAAG,IAAI,CAC5B,SAAQ,OAAO,MAAM,GAAG,IAAI,QAAQ,IAAI,IAAI,IAAI,IAAI;OAEpD,SAAQ,OAAO,MAAM,GAAG,eAAe,QAAQ,IAAI,UAAU,OAAO,IAAI,CAAC,IAAI;AAE/E,WAAQ,WAAW;;;;;;;;;;;AAYzB,SAAS,qBAAqB,cAAyD;CACrF,IAAIC;AACJ,KAAI;AACF,QAAM,aAAa,cAAc,QAAQ;SACnC;AACN,SAAO;;AAET,KAAI;AACF,SAAO,KAAK,MAAM,IAAI;SAChB;AACN,SAAO;;;;;;;;;;;;;;;;;AAkBX,SAAS,yBACP,UACA,cACA,QACM;CACN,MAAM,eAAe,KAAK,cAAc,iBAAiB;CAEzD,MAAM,EAAE,SAAS,iBAAiB,wBAAwB,UADzC,qBAAqB,aAAa,CAC0B;AAE7E,KAAI,QAAQ;AACV,UAAQ,OAAO,MAAM,2BAA2B,aAAa,IAAI;AACjE,UAAQ,OAAO,MAAM,qBAAqB;AAC1C,UAAQ,OAAO,MAAM,GAAG,QAAQ,IAAI;AACpC;;AAGF,eAAc,KAAK,cAAc,WAAW,EAAE,QAAQ;AACtD,eAAc,cAAc,aAAa;AAEzC,SAAQ,OAAO,MAAM,sCAAsC,aAAa,IAAI"}
|
package/dist/{migration-command-scaffold-BC73xQSo.mjs → migration-command-scaffold-CLMD302g.mjs}
RENAMED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { t as loadConfig } from "./config-loader-
|
|
2
|
-
import { _ as errorUnexpected, a as errorContractValidationFailed, c as errorDriverRequired, h as errorTargetMigrationNotSupported, l as errorFileNotFound, o as errorDatabaseConnectionRequired } from "./cli-errors-
|
|
3
|
-
import { t as createControlClient } from "./client-
|
|
4
|
-
import { _ as formatStyledHeader, a as maskConnectionUrl, n as addGlobalOptions, s as resolveContractPath } from "./result-handler-
|
|
5
|
-
import { t as createProgressAdapter } from "./progress-adapter-
|
|
1
|
+
import { t as loadConfig } from "./config-loader-_W4T21X1.mjs";
|
|
2
|
+
import { _ as errorUnexpected, a as errorContractValidationFailed, c as errorDriverRequired, h as errorTargetMigrationNotSupported, l as errorFileNotFound, o as errorDatabaseConnectionRequired } from "./cli-errors-DHq6GQGu.mjs";
|
|
3
|
+
import { t as createControlClient } from "./client-TG7rbCWT.mjs";
|
|
4
|
+
import { _ as formatStyledHeader, a as maskConnectionUrl, n as addGlobalOptions, s as resolveContractPath } from "./result-handler-CIyu0Pdt.mjs";
|
|
5
|
+
import { t as createProgressAdapter } from "./progress-adapter-B-YvmcDu.mjs";
|
|
6
6
|
import { notOk, ok } from "@prisma-next/utils/result";
|
|
7
7
|
import { hasMigrations } from "@prisma-next/framework-components/control";
|
|
8
8
|
import { readFile } from "node:fs/promises";
|
|
@@ -102,4 +102,4 @@ function addMigrationCommandOptions(command) {
|
|
|
102
102
|
|
|
103
103
|
//#endregion
|
|
104
104
|
export { prepareMigrationContext as n, addMigrationCommandOptions as t };
|
|
105
|
-
//# sourceMappingURL=migration-command-scaffold-
|
|
105
|
+
//# sourceMappingURL=migration-command-scaffold-CLMD302g.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migration-command-scaffold-
|
|
1
|
+
{"version":3,"file":"migration-command-scaffold-CLMD302g.mjs","names":["details: Array<{ label: string; value: string }>","contractJsonContent: string","contractJson: Record<string, unknown>"],"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,OAAO;CAC/C,MAAM,aAAa,QAAQ,SACvB,SAAS,QAAQ,KAAK,EAAE,QAAQ,QAAQ,OAAO,CAAC,GAChD;CACJ,MAAM,uBAAuB,oBAAoB,OAAO;CACxD,MAAM,eAAe,SAAS,QAAQ,KAAK,EAAE,qBAAqB;AAGlE,KAAI,CAAC,MAAM,QAAQ,CAAC,MAAM,OAAO;EAC/B,MAAMA,UAAmD,CACvD;GAAE,OAAO;GAAU,OAAO;GAAY,EACtC;GAAE,OAAO;GAAY,OAAO;GAAc,CAC3C;AACD,MAAI,QAAQ,GACV,SAAQ,KAAK;GAAE,OAAO;GAAY,OAAO,kBAAkB,QAAQ,GAAG;GAAE,CAAC;AAE3E,MAAI,QAAQ,OACV,SAAQ,KAAK;GAAE,OAAO;GAAQ,OAAO;GAAW,CAAC;EAEnD,MAAM,SAAS,mBAAmB;GAChC,SAAS,WAAW;GACpB,aAAa,WAAW;GACxB,KAAK,WAAW;GAChB;GACA;GACD,CAAC;AACF,KAAG,OAAO,OAAO;;CAInB,IAAIC;AACJ,KAAI;AACF,wBAAsB,MAAM,SAAS,sBAAsB,QAAQ;UAC5D,OAAO;AACd,MAAI,iBAAiB,SAAU,MAA4B,SAAS,S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AO,aAAa,+CAA+C,MAAM"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { t as loadConfig } from "./config-loader-
|
|
2
|
-
import { _ as errorUnexpected, m as errorRuntime } from "./cli-errors-
|
|
3
|
-
import { t as createControlClient } from "./client-
|
|
4
|
-
import { _ as formatStyledHeader, a as maskConnectionUrl, c as resolveMigrationPaths, d as setCommandExamples, i as loadAllBundles, m as parseGlobalFlags, n as addGlobalOptions, o as readContractEnvelope, p as toPathDecisionResult, t as handleResult, u as setCommandDescriptions } from "./result-handler-
|
|
5
|
-
import { t as TerminalUI } from "./terminal-ui-
|
|
1
|
+
import { t as loadConfig } from "./config-loader-_W4T21X1.mjs";
|
|
2
|
+
import { _ as errorUnexpected, m as errorRuntime } from "./cli-errors-DHq6GQGu.mjs";
|
|
3
|
+
import { t as createControlClient } from "./client-TG7rbCWT.mjs";
|
|
4
|
+
import { _ as formatStyledHeader, a as maskConnectionUrl, c as resolveMigrationPaths, d as setCommandExamples, i as loadAllBundles, m as parseGlobalFlags, n as addGlobalOptions, o as readContractEnvelope, p as toPathDecisionResult, t as handleResult, u as setCommandDescriptions } from "./result-handler-CIyu0Pdt.mjs";
|
|
5
|
+
import { t as TerminalUI } from "./terminal-ui-C5k88MmW.mjs";
|
|
6
6
|
import { Command } from "commander";
|
|
7
7
|
import { notOk, ok } from "@prisma-next/utils/result";
|
|
8
8
|
import { ifDefined } from "@prisma-next/utils/defined";
|
|
@@ -1564,4 +1564,4 @@ function summarizeRefDistance(graph, markerHash, refHash, refName) {
|
|
|
1564
1564
|
|
|
1565
1565
|
//#endregion
|
|
1566
1566
|
export { deriveEdgeStatuses as n, createMigrationStatusCommand as t };
|
|
1567
|
-
//# sourceMappingURL=migration-status-
|
|
1567
|
+
//# sourceMappingURL=migration-status-B0HLF7So.mjs.map
|