MCPcopy
hub / github.com/prisma/prisma / parse

Method parse

packages/cli/src/Validate.ts:55–112  ·  view source on GitHub ↗
(
    argv: string[],
    config: PrismaConfigInternal,
    baseDir: string = process.cwd(),
  )

Source from the content-addressed store, hash-verified

53`)
54
55 public async parse(
56 argv: string[],
57 config: PrismaConfigInternal,
58 baseDir: string = process.cwd(),
59 ): Promise<string | Error> {
60 const args = arg(argv, {
61 '--help': Boolean,
62 '-h': '--help',
63 '--schema': String,
64 '--config': String,
65 '--telemetry-information': String,
66 })
67
68 if (args instanceof Error) {
69 return this.help(args.message)
70 }
71
72 if (args['--help']) {
73 return this.help()
74 }
75
76 const { schemaPath, schemas } = await getSchemaWithPath({
77 schemaPath: createSchemaPathInput({
78 schemaPathFromArgs: args['--schema'],
79 schemaPathFromConfig: config.schema,
80 baseDir,
81 }),
82 })
83 printSchemaLoadedMessage(schemaPath)
84
85 const { lintDiagnostics } = handleLintPanic(() => {
86 // the only possible error here is a Rust panic
87 const lintDiagnostics = lintSchema({ schemas })
88 return { lintDiagnostics }
89 })
90
91 const lintWarnings = getLintWarningsAsText(lintDiagnostics)
92 if (lintWarnings && logger.should.warn()) {
93 // Output warnings to stderr
94 console.warn(lintWarnings)
95 }
96
97 validate({
98 schemas,
99 })
100
101 await getConfig({
102 datamodel: schemas,
103 })
104
105 const schemaRelativePath = path.relative(process.cwd(), schemaPath)
106
107 if (schemas.length > 1) {
108 return `The schemas at ${underline(schemaRelativePath)} are valid 🚀`
109 }
110
111 return `The schema at ${underline(schemaRelativePath)} is valid 🚀`
112 }

Callers

nothing calls this directly

Calls 11

helpMethod · 0.95
argFunction · 0.90
getSchemaWithPathFunction · 0.90
createSchemaPathInputFunction · 0.90
printSchemaLoadedMessageFunction · 0.90
handleLintPanicFunction · 0.90
lintSchemaFunction · 0.90
getLintWarningsAsTextFunction · 0.90
validateFunction · 0.90
getConfigFunction · 0.90
warnMethod · 0.80

Tested by

no test coverage detected