MCPcopy
hub / github.com/prisma/prisma / runInit

Method runInit

packages/cli/src/bootstrap/Bootstrap.ts:606–642  ·  view source on GitHub ↗
(
    steps: BootstrapStepStatus,
    stepsCompleted: string[],
    telemetryCtx: {
      distinctId: string
      databaseId: string | undefined
      linkResult: LinkResult | null
      projectState: ReturnType<typeof detectProjectState>
    },
    config: PrismaConfigInternal,
    withModel: boolean,
  )

Source from the content-addressed store, hash-verified

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) {

Callers 1

runMethod · 0.95

Calls 7

emitStepFailedFunction · 0.90
sanitizeErrorMessageFunction · 0.90
emitStepCompletedFunction · 0.90
logMethod · 0.80
parseMethod · 0.65
newMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected