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

Function generateClient

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

Source from the content-addressed store, hash-verified

169}
170
171export async function generateClient(options: GenerateClientOptions): Promise<void> {
172 const {
173 datamodel,
174 schemaPath,
175 generator,
176 dmmf,
177 datasources,
178 binaryPaths,
179 clientVersion,
180 engineVersion,
181 activeProvider,
182 typedSql,
183 target,
184 generatedFileExtension,
185 importFileExtension,
186 moduleFormat,
187 tsNoCheckPreamble,
188 compilerBuild,
189 } = options
190
191 const { runtimeBase, outputDir } = await getGenerationDirs(options)
192
193 const { prismaClientDmmf, fileMap } = buildClient({
194 datamodel,
195 schemaPath,
196 runtimeBase,
197 outputDir,
198 generator,
199 dmmf,
200 datasources,
201 binaryPaths,
202 clientVersion,
203 engineVersion,
204 activeProvider,
205 typedSql,
206 target,
207 generatedFileExtension,
208 importFileExtension,
209 moduleFormat,
210 tsNoCheckPreamble,
211 compilerBuild,
212 })
213
214 const denylistsErrors = validateDmmfAgainstDenylists(prismaClientDmmf)
215
216 if (denylistsErrors) {
217 let message = `${bold(
218 red('Error: '),
219 )}The schema at "${schemaPath}" contains reserved keywords.\n Rename the following items:`
220
221 for (const error of denylistsErrors) {
222 message += '\n - ' + error.message
223 }
224
225 message += `\nTo learn more about how to rename models, check out https://pris.ly/d/naming-models`
226
227 throw new DenylistError(message)
228 }

Callers 1

generateMethod · 0.90

Calls 5

deleteOutputDirFunction · 0.85
getGenerationDirsFunction · 0.70
buildClientFunction · 0.70
writeFileMapFunction · 0.70

Tested by

no test coverage detected