Skip to content

Commit

Permalink
chore(introspection) "Better Introspect Output"
Browse files Browse the repository at this point in the history
Closes #1554
  • Loading branch information
Jolg42 committed May 14, 2020
1 parent b709695 commit 5e5c05e
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/packages/introspection/src/commands/Introspect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,12 @@ Then you can run ${chalk.green('prisma introspect')} again.
schemaPath = schemaPath || 'schema.prisma'
fs.writeFileSync(schemaPath, introspectionSchema)

log(`\n✔ Wrote Prisma data model into ${chalk.underline(
const modelsCount = (introspectionSchema.match(/^\s*model\s+/gm) || [])

This comment has been minimized.

Copy link
@janpio

janpio May 14, 2020

Member

hrhr, that's one way to do it.

cc @do4gr

This comment has been minimized.

Copy link
@Jolg42

Jolg42 May 15, 2020

Author Member

That should just work though, it ignores commented models 😄

This comment has been minimized.

Copy link
@janpio

janpio May 15, 2020

Member

Well...

C:\Users\Jan\Documents\throwaway                                                                   
λ npx -p @prisma/cli@alpha prisma introspect --url="mysql://root:root@localhost:3306/model"        
                                                                                                   
Introspecting …                                                                                    
                                                                                                   
✔ Introspected 4 models and wrote them into prisma\schema.prisma in 60ms                           
                                                                                                   
Run prisma generate to generate Prisma Client. 

C:\Users\Jan\Documents\throwaway                                                                   
λ npx -p @prisma/cli@alpha prisma introspect --url="mysql://root:root@localhost:3306/model" --print
datasource db {                                                                                    
  provider = "mysql"                                                                               
  url      = "mysql://root:root@localhost:3306/model"                                              
}                                                                                                  
                                                                                                   
model model {                                                                                      
  model  Int    @default(autoincrement()) @id                                                      
  second second @relation(fields: [model], references: [second])                                   
                                                                                                   
  @@index([model], name: "model")                                                                  
}                                                                                                  
                                                                                                   
model second {                                                                                     
  second Int    @default(autoincrement()) @id                                                      
  model  model?                                                                                    
}                                                                                                                                                        

This comment has been minimized.

Copy link
@Jolg42

Jolg42 May 15, 2020

Author Member

Haha good one 😅 I can fix that I think

This comment has been minimized.

Copy link
@Jolg42

Jolg42 May 15, 2020

Author Member

Will be fixed in next alpha :)

.length

log(`\n✔ Introspected ${modelsCount} ${
modelsCount > 1 ? 'models and wrote them' : 'model and wrote it'
} into ${chalk.underline(
path.relative(process.cwd(), schemaPath),
)} in ${chalk.bold(formatms(Date.now() - before))} ${chalk.dim(
introspectionSchemaVersion || '',
Expand Down

0 comments on commit 5e5c05e

Please sign in to comment.