MCPcopy
hub / github.com/prisma/prisma / printUpdateMessage

Function printUpdateMessage

packages/cli/src/utils/printUpdateMessage.ts:7–49  ·  view source on GitHub ↗
(checkResult: Check.Result | 0 | void)

Source from the content-addressed store, hash-verified

5const isPrismaInstalledGlobally = isCurrentBinInstalledGlobally()
6
7export function printUpdateMessage(checkResult: Check.Result | 0 | void): void {
8 const shouldHide = process.env.PRISMA_HIDE_UPDATE_MESSAGE
9 if (!checkResult || checkResult.status !== 'ok' || shouldHide || !checkResult.data.outdated) {
10 return
11 }
12
13 let boxHeight = 4
14 let majorText = ''
15
16 const currentVersionInstalled = checkResult.data.previous_version
17 const latestVersionAvailable = checkResult.data.current_version
18
19 const prismaCLICommand = makeInstallCommand(checkResult.data.package, checkResult.data.release_tag)
20 const prismaClientCommand = makeInstallCommand('@prisma/client', checkResult.data.release_tag, {
21 canBeGlobal: false,
22 canBeDev: false,
23 })
24
25 try {
26 const [majorInstalled] = currentVersionInstalled.split('.')
27 const [majorLatest] = latestVersionAvailable.split('.')
28
29 if (majorInstalled < majorLatest) {
30 majorText = `\nThis is a major update - please follow the guide at\nhttps://pris.ly/d/major-version-upgrade\n\n`
31 boxHeight = boxHeight + 4
32 }
33 } catch (e) {}
34
35 const boxText = `\n${blue(
36 'Update available',
37 )} ${currentVersionInstalled} -> ${latestVersionAvailable}\n${majorText}Run the following to update
38 ${bold(prismaCLICommand)}
39 ${bold(prismaClientCommand)}`
40
41 const boxedMessage = drawBox({
42 height: boxHeight,
43 width: 59,
44 str: boxText,
45 horizontalPadding: 2,
46 })
47
48 console.error(boxedMessage)
49}
50
51function makeInstallCommand(
52 packageName: string,

Callers 3

parseMethod · 0.90
printUpdateMessageFromToFunction · 0.90

Calls 3

drawBoxFunction · 0.90
makeInstallCommandFunction · 0.85
errorMethod · 0.80

Tested by 1

printUpdateMessageFromToFunction · 0.72