Skip to content

Commit

Permalink
feat(cli, generate command): Added promo array to rotate and make cli…
Browse files Browse the repository at this point in the history
… 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
  • Loading branch information
apolanc authored Jul 16, 2024
1 parent 4f0f85f commit a15d3b9
Show file tree
Hide file tree
Showing 5 changed files with 137 additions and 266 deletions.
18 changes: 4 additions & 14 deletions packages/cli/src/Generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { enginesVersion } from '@prisma/engines'
import {
arg,
Command,
drawBox,
format,
Generator,
getCommandWithExecutor,
Expand All @@ -29,6 +28,7 @@ import resolvePkg from 'resolve-pkg'

import { getHardcodedUrlWarning } from './generate/getHardcodedUrlWarning'
import { breakingChangesMessage } from './utils/breakingChanges'
import { getRandomPromotion } from './utils/handlePromotions'
import { simpleDebounce } from './utils/simpleDebounce'

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

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

if (!schemaResult) return ''

Expand Down Expand Up @@ -255,21 +256,10 @@ Please make sure they have the same version.`
if (hideHints) {
hint = `${getHardcodedUrlWarning(config)}${breakingChangesStr}${versionsWarning}`
} else {
const tryAccelerateMessage = `Deploying your app to serverless or edge functions?
Try Prisma Accelerate for connection pooling and caching.
${link('https://pris.ly/cli/--accelerate')}`

const boxedTryAccelerateMessage = drawBox({
height: tryAccelerateMessage.split('\n').length,
width: 0, // calculated automatically
str: tryAccelerateMessage,
horizontalPadding: 2,
})

hint = `
Start by importing your prisma client (See: http://pris.ly/d/importing-client)
Start by importing your Prisma Client (See: http://pris.ly/d/importing-client)
${boxedTryAccelerateMessage}
${promotion.text} ${promotion.link}
${getHardcodedUrlWarning(config)}${breakingChangesStr}${versionsWarning}`
}
}
Expand Down
21 changes: 6 additions & 15 deletions packages/cli/src/Init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import {
canConnectToDatabase,
checkUnsupportedDataProxy,
Command,
drawBox,
format,
getCommandWithExecutor,
HelpError,
Expand Down Expand Up @@ -210,7 +209,6 @@ export class Init implements Command {
${dim('$')} prisma init --with-model
`)

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

steps.push(
`Tip: Explore how you can extend the ${green(
'ORM',
)} with scalable connection pooling, global caching, and real-time database events. Read: https://pris.ly/beyond-the-orm`,
)

if (!url || args['--datasource-provider']) {
if (!args['--datasource-provider']) {
steps.unshift(
Expand All @@ -419,17 +423,6 @@ export class Init implements Command {
)
}

const promoMessage = `Developing real-time features?
Prisma Pulse lets you respond instantly to database changes.
${link('https://pris.ly/cli/pulse')}`

const boxedPromoMessage = drawBox({
height: promoMessage.split('\n').length,
width: 0, // calculated automatically
str: promoMessage,
horizontalPadding: 2,
})

return `
✔ Your Prisma schema was created at ${green('prisma/schema.prisma')}
You can now open it in your favorite editor.
Expand All @@ -439,8 +432,6 @@ ${steps.map((s, i) => `${i + 1}. ${s}`).join('\n')}
More information in our documentation:
${link('https://pris.ly/d/getting-started')}
${boxedPromoMessage}
`
}

Expand Down
Loading

0 comments on commit a15d3b9

Please sign in to comment.