MCPcopy
hub / github.com/prisma/prisma / Generate

Class Generate

packages/cli/src/Generate.ts:41–345  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

39 * $ prisma generate
40 */
41export class Generate implements Command {
42 surveyHandler: () => Promise<void>
43
44 constructor(surveyHandler: () => Promise<void> = handleNpsSurvey) {
45 this.surveyHandler = surveyHandler
46 }
47
48 public static new(): Generate {
49 return new Generate()
50 }
51
52 private static help = format(`
53Generate artifacts (e.g. Prisma Client)
54
55${bold('Usage')}
56
57 ${dim('$')} prisma generate [options]
58
59${bold('Options')}
60 -h, --help Display this help message
61 --config Custom path to your Prisma config file
62 --schema Custom path to your Prisma schema
63 --sql Generate typed sql module
64 --watch Watch the Prisma schema and rerun after a change
65 --generator Generator to use (may be provided multiple times)
66 --no-hints Hides the hint messages but still outputs errors and warnings
67 --require-models Do not allow generating a client without models
68
69${bold('Examples')}
70
71 With an existing Prisma schema
72 ${dim('$')} prisma generate
73
74 Or specify a schema
75 ${dim('$')} prisma generate --schema=./schema.prisma
76
77 Run the command with multiple specific generators
78 ${dim('$')} prisma generate --generator client1 --generator client2
79
80 Watch Prisma schema file and rerun after each change
81 ${dim('$')} prisma generate --watch
82
83`)
84
85 private logText = ''
86 private hasGeneratorErrored = false
87
88 private runGenerate = simpleDebounce(async ({ generators }: { generators: Generator[] }) => {
89 const message: string[] = []
90
91 for (const generator of generators) {
92 const before = Math.round(performance.now())
93 try {
94 await generator.generate()
95 const after = Math.round(performance.now())
96 message.push(getGeneratorSuccessMessage(generator, after - before) + '\n')
97 generator.stop()
98 } catch (err) {

Callers

nothing calls this directly

Calls 6

formatFunction · 0.90
simpleDebounceFunction · 0.90
generateMethod · 0.65
stopMethod · 0.65
pushMethod · 0.45

Tested by

no test coverage detected