MCPcopy
hub / github.com/prisma/prisma / generateClient

Function generateClient

packages/client-generator-js/src/generateClient.ts:303–406  ·  view source on GitHub ↗
(options: GenerateClientOptions)

Source from the content-addressed store, hash-verified

301}
302
303export async function generateClient(options: GenerateClientOptions): Promise<void> {
304 const {
305 datamodel,
306 schemaPath,
307 generator,
308 dmmf,
309 datasources,
310 binaryPaths,
311 testMode,
312 copyRuntime,
313 copyRuntimeSourceMaps = false,
314 runtimeSourcePath,
315 clientVersion,
316 engineVersion,
317 activeProvider,
318 typedSql,
319 compilerBuild,
320 } = options
321
322 const { runtimeBase, outputDir } = await getGenerationDirs(options)
323
324 const { prismaClientDmmf, fileMap } = await buildClient({
325 datamodel,
326 schemaPath,
327 runtimeBase,
328 runtimeSourcePath,
329 outputDir,
330 generator,
331 dmmf,
332 datasources,
333 binaryPaths,
334 clientVersion,
335 engineVersion,
336 activeProvider,
337 testMode,
338 typedSql,
339 compilerBuild,
340 })
341
342 const provider = datasources[0].provider
343
344 const denylistsErrors = validateDmmfAgainstDenylists(prismaClientDmmf)
345
346 if (denylistsErrors) {
347 let message = `${bold(
348 red('Error: '),
349 )}The schema at "${schemaPath}" contains reserved keywords.\n Rename the following items:`
350
351 for (const error of denylistsErrors) {
352 message += '\n - ' + error.message
353 }
354
355 message += `\nTo learn more about how to rename models, check out https://pris.ly/d/naming-models`
356
357 throw new DenylistError(message)
358 }
359
360 await ensureDir(outputDir)

Callers 2

generateInFolderFunction · 0.90
generateMethod · 0.90

Calls 8

copyRuntimeFilesFunction · 0.85
isWasmEngineSupportedFunction · 0.85
fromMethod · 0.80
getGenerationDirsFunction · 0.70
buildClientFunction · 0.70
writeFileMapFunction · 0.70
toStringMethod · 0.45

Tested by

no test coverage detected