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

Method parse

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

Source from the content-addressed store, hash-verified

53 }
54
55 async parse(argv: string[], config: PrismaConfigInternal, baseDir: string = process.cwd()): Promise<string | Error> {
56 const args = arg(argv, {
57 '--help': Boolean,
58 '-h': '--help',
59 '--version': Boolean,
60 '-v': '--version',
61 '--config': String,
62 '--json': Boolean,
63 '--telemetry-information': String,
64 })
65
66 if (isError(args)) {
67 return this.help(args.message)
68 }
69
70 if (args['--help']) {
71 return this.help()
72 }
73
74 const engineResult = await resolveEngine(BinaryType.SchemaEngineBinary)
75 const [enginesInfo, schemaEngineRetrievalErrors] = getEnginesInfo(engineResult)
76
77 const schemaEngineRows = [['Schema Engine', enginesInfo] as const]
78
79 const prismaClientVersion = await getInstalledPrismaClientVersion()
80 const typescriptVersion = await getTypescriptVersion()
81
82 const rows = [
83 [packageJson.name, packageJson.version],
84 ['@prisma/client', prismaClientVersion ?? 'Not found'],
85 ['Operating System', os.platform()],
86 ['Architecture', os.arch()],
87 ['Node.js', process.version],
88 ['TypeScript', typescriptVersion],
89 ['Query Compiler', 'enabled'],
90 ['PSL', `@prisma/prisma-schema-wasm ${wasm.prismaSchemaWasmVersion}`],
91 ...schemaEngineRows,
92
93 ['Default Engines Hash', enginesVersion],
94 ['Studio', packageJson.dependencies['@prisma/studio-core']],
95 ]
96
97 /**
98 * If reading Rust engines metainfo (like their git hash) failed, display the errors to stderr,
99 * and let Node.js exit naturally, but with error code 1.
100 */
101
102 if (schemaEngineRetrievalErrors.length > 0) {
103 process.exitCode = 1
104 schemaEngineRetrievalErrors.forEach((e) => console.error(e))
105 }
106
107 const featureFlags = await this.getFeatureFlags(config.schema, baseDir)
108 if (featureFlags && featureFlags.length > 0) {
109 rows.push(['Preview Features', featureFlags.join(', ')])
110 }
111
112 // @ts-ignore TODO @jkomyno, as affects the type of rows

Callers

nothing calls this directly

Calls 11

helpMethod · 0.95
getFeatureFlagsMethod · 0.95
argFunction · 0.90
isErrorFunction · 0.90
resolveEngineFunction · 0.90
getEnginesInfoFunction · 0.90
getTypescriptVersionFunction · 0.90
formatTableFunction · 0.90
errorMethod · 0.80
pushMethod · 0.45

Tested by

no test coverage detected