import { prompt } from 'prompts' ; import { isCi } from '@prisma/sdk' ; import slugify from '@sindresorhus/slugify' ; type getMigratioNameOutput = { name ? : string ; userCancelled ? : string ; } ; export async function getMigrationName ( name ? ) { const maxMigrationNameLength = 200 ; if ( name ) { return { name : slugify ( name , { separator : '_' } ) . substring ( 0 , maxMigrationNameLength ) , } ; } else if ( isCi ( ) && Boolean ( prompt . _injected ?. length ) === false ) { return { name : '' , } ; } const response = await prompt ( { type : 'text' , name : 'name' , message : `Enter a name for the new migration:` , } ) ; if ( ! ( 'name' in response ) ) { return { userCancelled : 'Canceled by user.' , } ; } return { name : slugify ( response . name , { separator : '_' } ) . substring ( 0 , maxMigrationNameLength ) || '' , } ; }