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

Method parse

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

Source from the content-addressed store, hash-verified

46 }
47
48 async parse(argv: string[], config: PrismaConfigInternal, baseDir: string = process.cwd()): Promise<string | Error> {
49 const args = arg(argv, {
50 '--help': Boolean,
51 '-h': '--help',
52 '--schema': String,
53 '--config': String,
54 '--telemetry-information': String,
55 })
56
57 if (isError(args)) {
58 return this.help(args.message)
59 }
60
61 if (args['--help']) {
62 return this.help()
63 }
64
65 const formatEnvValue = (name: string, text?: string) => {
66 const value = process.env[name]
67 const line = `- ${name}${text ? ` ${text}` : ''}`
68
69 if (value === undefined) {
70 return dim(line + ':')
71 }
72 return bold(line + `: \`${value}\``)
73 }
74
75 let schemaPath
76 try {
77 const schemaResult = await getSchemaWithPath({
78 schemaPath: createSchemaPathInput({
79 schemaPathFromArgs: args['--schema'],
80 schemaPathFromConfig: config.schema,
81 baseDir,
82 }),
83 })
84 schemaPath = link(schemaResult.schemaPath)
85 } catch (e) {
86 schemaPath = e.message
87 }
88 const rootCacheDir = link(await getRootCacheDir())
89
90 return `${underline('-- Prisma schema --')}
91Path: ${schemaPath}
92
93${underline('-- Local cache directory for engines files --')}
94Path: ${rootCacheDir}
95
96${underline('-- Environment variables --')}
97When not set, the line is dimmed and no value is displayed.
98When set, the line is bold and the value is inside the \`\` backticks.
99
100For general debugging
101${formatEnvValue('CI')}
102${formatEnvValue('DEBUG')}
103${formatEnvValue('NODE_ENV')}
104${formatEnvValue('RUST_LOG')}
105${formatEnvValue('RUST_BACKTRACE')}

Callers

nothing calls this directly

Calls 9

helpMethod · 0.95
argFunction · 0.90
isErrorFunction · 0.90
getSchemaWithPathFunction · 0.90
createSchemaPathInputFunction · 0.90
linkFunction · 0.90
getRootCacheDirFunction · 0.90
isInteractiveFunction · 0.90
isCiFunction · 0.90

Tested by

no test coverage detected