-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathmessages.ts
66 lines (60 loc) · 2.19 KB
/
messages.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/* eslint no-console: 'off' */
import * as chalk from 'chalk'
import { getFullName } from './fullname'
function sleep (ms: number): Promise<void> {
return new Promise(resolve => setTimeout(resolve, ms))
}
export async function getUserGreeting (): Promise<string> {
const name = await getFullName()
return name ? `Hi ${name}!` : 'Hi there!'
}
export async function header (version: string, greeting: string): Promise<void> {
console.log(
`${chalk.black.bgCyan.bold(' checkly ')} v${version} ${chalk.bold(
'Build and Run Synthetics That Scale')}\n`,
)
await sleep(1000)
console.log(`${greeting} Let's get you started on your ${chalk.green.bold('monitoring as code')} journey!\n`)
await sleep(500)
}
export async function hint (prefix: string, text: string) {
await sleep(100)
if (process.stdout.columns < 80) {
console.log(`${chalk.cyan('◼')} ${chalk.cyan(prefix)}`)
console.log(`${' '.repeat(3)}${chalk.dim(text)}\n`)
} else {
console.log(`${chalk.cyan('◼')} ${chalk.cyan(prefix)} ${chalk.dim(text)}\n`)
}
}
export async function footer (targetDir?: string): Promise<void> {
const max = process.stdout.columns
const prefix = max < 80 ? ' ' : ' '.repeat(9)
await sleep(200)
console.log(
`\n ${chalk.bgCyan(` ${chalk.black.bold('next')} `)} ${chalk.bold(
'All done. Time to get testing & monitoring with Checkly\n',
)}`,
)
if (targetDir) {
await sleep(200)
console.log(
`${prefix}> Enter your project directory using ${chalk.cyan(`cd ${targetDir}`)}`,
)
}
await sleep(200)
console.log(
`${prefix}> Run ${chalk.cyan('npx checkly login')} to login to your Checkly account or create a free new account`,
)
await sleep(200)
console.log(
`${prefix}> Run ${chalk.cyan('npx checkly test --record')} to dry run your checks`,
)
await sleep(200)
console.log(
`${prefix}> Run ${chalk.cyan('npx checkly deploy')} to deploy your checks to the Checkly cloud`,
)
await sleep(200)
console.log(`\n${prefix}Questions?\n`)
console.log(`${prefix}- Check the docs at ${chalk.cyan('https://checklyhq.com/docs/cli')}`)
console.log(`${prefix}- Join the Checkly Slack community at ${chalk.cyan('https://checklyhq.com/slack')}\n`)
}