Skip to content

Commit a15d3b9

Browse files
authored
feat(cli, generate command): Added promo array to rotate and make cli messaging more engaging (#24792)
* Added promo array and modified the existing promo text in the generate file * removed the boxed message and promo from init command and added an adittional step * updated tests and snapshot with mocked sample tip * Added Tip: keyword at the beginning of the 5th step in prisma init command * updated iinit command snapshots * update snapshots for generate command * snapshots * Added missing links and updated snapshots * remove whitespace * updated snapshots
1 parent 4f0f85f commit a15d3b9

File tree

5 files changed

+137
-266
lines changed

5 files changed

+137
-266
lines changed

packages/cli/src/Generate.ts

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { enginesVersion } from '@prisma/engines'
22
import {
33
arg,
44
Command,
5-
drawBox,
65
format,
76
Generator,
87
getCommandWithExecutor,
@@ -29,6 +28,7 @@ import resolvePkg from 'resolve-pkg'
2928

3029
import { getHardcodedUrlWarning } from './generate/getHardcodedUrlWarning'
3130
import { breakingChangesMessage } from './utils/breakingChanges'
31+
import { getRandomPromotion } from './utils/handlePromotions'
3232
import { simpleDebounce } from './utils/simpleDebounce'
3333

3434
const pkg = eval(`require('../package.json')`)
@@ -131,6 +131,7 @@ ${bold('Examples')}
131131
await loadEnvFile({ schemaPath: args['--schema'], printMessage: true })
132132

133133
const schemaResult = await getSchemaForGenerate(args['--schema'], cwd, Boolean(postinstallCwd))
134+
const promotion = getRandomPromotion()
134135

135136
if (!schemaResult) return ''
136137

@@ -255,21 +256,10 @@ Please make sure they have the same version.`
255256
if (hideHints) {
256257
hint = `${getHardcodedUrlWarning(config)}${breakingChangesStr}${versionsWarning}`
257258
} else {
258-
const tryAccelerateMessage = `Deploying your app to serverless or edge functions?
259-
Try Prisma Accelerate for connection pooling and caching.
260-
${link('https://pris.ly/cli/--accelerate')}`
261-
262-
const boxedTryAccelerateMessage = drawBox({
263-
height: tryAccelerateMessage.split('\n').length,
264-
width: 0, // calculated automatically
265-
str: tryAccelerateMessage,
266-
horizontalPadding: 2,
267-
})
268-
269259
hint = `
270-
Start by importing your prisma client (See: http://pris.ly/d/importing-client)
260+
Start by importing your Prisma Client (See: http://pris.ly/d/importing-client)
271261
272-
${boxedTryAccelerateMessage}
262+
${promotion.text} ${promotion.link}
273263
${getHardcodedUrlWarning(config)}${breakingChangesStr}${versionsWarning}`
274264
}
275265
}

packages/cli/src/Init.ts

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import {
44
canConnectToDatabase,
55
checkUnsupportedDataProxy,
66
Command,
7-
drawBox,
87
format,
98
getCommandWithExecutor,
109
HelpError,
@@ -210,7 +209,6 @@ export class Init implements Command {
210209
${dim('$')} prisma init --with-model
211210
`)
212211

213-
// eslint-disable-next-line @typescript-eslint/require-await
214212
async parse(argv: string[]): Promise<any> {
215213
const args = arg(argv, {
216214
'--help': Boolean,
@@ -401,6 +399,12 @@ export class Init implements Command {
401399
)} to generate the Prisma Client. You can then start querying your database.`,
402400
)
403401

402+
steps.push(
403+
`Tip: Explore how you can extend the ${green(
404+
'ORM',
405+
)} with scalable connection pooling, global caching, and real-time database events. Read: https://pris.ly/beyond-the-orm`,
406+
)
407+
404408
if (!url || args['--datasource-provider']) {
405409
if (!args['--datasource-provider']) {
406410
steps.unshift(
@@ -419,17 +423,6 @@ export class Init implements Command {
419423
)
420424
}
421425

422-
const promoMessage = `Developing real-time features?
423-
Prisma Pulse lets you respond instantly to database changes.
424-
${link('https://pris.ly/cli/pulse')}`
425-
426-
const boxedPromoMessage = drawBox({
427-
height: promoMessage.split('\n').length,
428-
width: 0, // calculated automatically
429-
str: promoMessage,
430-
horizontalPadding: 2,
431-
})
432-
433426
return `
434427
✔ Your Prisma schema was created at ${green('prisma/schema.prisma')}
435428
You can now open it in your favorite editor.
@@ -439,8 +432,6 @@ ${steps.map((s, i) => `${i + 1}. ${s}`).join('\n')}
439432
440433
More information in our documentation:
441434
${link('https://pris.ly/d/getting-started')}
442-
443-
${boxedPromoMessage}
444435
`
445436
}
446437

0 commit comments

Comments
 (0)