(
steps: BootstrapStepStatus,
stepsCompleted: string[],
telemetryCtx: {
distinctId: string
databaseId: string | undefined
linkResult: LinkResult | null
projectState: ReturnType<typeof detectProjectState>
},
config: PrismaConfigInternal,
withModel: boolean,
)
| 604 | } |
| 605 | |
| 606 | private async runInit( |
| 607 | steps: BootstrapStepStatus, |
| 608 | stepsCompleted: string[], |
| 609 | telemetryCtx: { |
| 610 | distinctId: string |
| 611 | databaseId: string | undefined |
| 612 | linkResult: LinkResult | null |
| 613 | projectState: ReturnType<typeof detectProjectState> |
| 614 | }, |
| 615 | config: PrismaConfigInternal, |
| 616 | withModel: boolean, |
| 617 | ): Promise<void> { |
| 618 | const label = withModel ? 'Setting up Prisma with a sample User model...' : 'Setting up Prisma...' |
| 619 | console.log(`\n${bold(label)}`) |
| 620 | const stepStart = performance.now() |
| 621 | |
| 622 | try { |
| 623 | const init = Init.new() |
| 624 | const initArgs = ['--datasource-provider', 'postgresql'] |
| 625 | if (withModel) initArgs.push('--with-model') |
| 626 | const initResult = await init.parse(initArgs, config) |
| 627 | |
| 628 | if (initResult instanceof Error) { |
| 629 | await emitStepFailed(telemetryCtx, 'init', sanitizeErrorMessage(initResult.message)) |
| 630 | throw new Error(`Init failed: ${initResult.message}`) |
| 631 | } |
| 632 | |
| 633 | steps.init = 'completed' |
| 634 | stepsCompleted.push('init') |
| 635 | await emitStepCompleted(telemetryCtx, 'init', performance.now() - stepStart) |
| 636 | } catch (err) { |
| 637 | if (err instanceof Error && err.message.startsWith('Init failed:')) throw err |
| 638 | const msg = err instanceof Error ? err.message : String(err) |
| 639 | await emitStepFailed(telemetryCtx, 'init', sanitizeErrorMessage(msg)) |
| 640 | throw new Error(`Init failed: ${msg}`) |
| 641 | } |
| 642 | } |
| 643 | |
| 644 | public help(error?: string): string | HelpError { |
| 645 | if (error) { |
no test coverage detected