Skip to content

Commit 45ca172

Browse files
authored
chore: update oclif [sc-23314] (#1024)
* chore: update oclif Replaces removed ux.wait() with stdlib, ux.prompt() with prompts. Minor changes to bin files were also required as otherwise errors were printed with stack traces. I had not realized that the create-cli bin was checking Node version - it has now been updated to Node 18 too. The new oclif also requires Node 18. Custom help output had some type changes but is basically the same. * feat: add update warning to create-cli and make it single command like before * chore: bump all oclif deps to latest again * fix: must set topicSeparator or oclif fails to handle CLI errors properly This makes no sense but if topicSeparator is not present or is set to `":"`, CLI errors such as attempting to run `bin/run foo` in the packages/create-cli folder will error with a stack trace, with the error being thrown and handled (incorrectly) by oclif itself.
1 parent d8706e5 commit 45ca172

File tree

9 files changed

+2581
-959
lines changed

9 files changed

+2581
-959
lines changed

package-lock.json

Lines changed: 2529 additions & 936 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/cli/bin/run

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#!/usr/bin/env node
2+
/* eslint-disable @typescript-eslint/no-var-requires */
23

3-
const oclif = require('@oclif/core')
4+
const { run, handle, flush } = require('@oclif/core')
45

5-
oclif.run().then(require('@oclif/core/flush')).catch(require('@oclif/core/handle'))
6+
run().catch(handle).finally(flush)

packages/cli/package.json

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,18 +61,19 @@
6161
"description": "Manage Checkly environment variables."
6262
}
6363
},
64-
"helpClass": "./dist/help/help-extension"
64+
"helpClass": "./dist/help/help-extension",
65+
"topicSeparator": " "
6566
},
6667
"bin": {
6768
"checkly": "./bin/run"
6869
},
6970
"homepage": "https://github.com/checkly/checkly-cli#readme",
7071
"dependencies": {
71-
"@oclif/core": "2.8.11",
72-
"@oclif/plugin-help": "5.1.20",
73-
"@oclif/plugin-not-found": "2.3.23",
74-
"@oclif/plugin-plugins": "5.4.4",
75-
"@oclif/plugin-warn-if-update-available": "2.0.24",
72+
"@oclif/core": "4.2.8",
73+
"@oclif/plugin-help": "6.2.26",
74+
"@oclif/plugin-not-found": "3.2.44",
75+
"@oclif/plugin-plugins": "5.4.34",
76+
"@oclif/plugin-warn-if-update-available": "3.1.35",
7677
"@typescript-eslint/typescript-estree": "8.24.1",
7778
"acorn": "8.14.0",
7879
"acorn-walk": "8.3.4",

packages/cli/src/commands/deploy.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { setTimeout } from 'node:timers/promises'
12
import * as fs from 'fs/promises'
23
import * as api from '../rest/api'
34
import config from '../services/config'
@@ -163,7 +164,7 @@ export default class Deploy extends AuthCommand {
163164
this.log(this.formatPreview(data, project))
164165
}
165166
if (!preview) {
166-
await ux.wait(500)
167+
await setTimeout(500)
167168
this.log(`Successfully deployed project "${project.name}" to account "${account.name}".`)
168169

169170
// Print the ping URL for heartbeat checks.

packages/cli/src/commands/env/add.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import prompts from 'prompts'
12
import * as api from '../../rest/api'
23
import { Flags, Args, ux } from '@oclif/core'
34
import { AuthCommand } from '../authCommand'
@@ -43,7 +44,13 @@ export default class EnvAdd extends AuthCommand {
4344
if (args.value) {
4445
envValue = args.value
4546
} else {
46-
envValue = await ux.prompt(`What is the value of ${envVariableName}?`, { type: 'mask' })
47+
const response = await prompts({
48+
type: 'password',
49+
name: 'value',
50+
message: `What is the value of ${envVariableName}?`,
51+
})
52+
53+
envValue = response.value
4754
}
4855
try {
4956
await api.environmentVariables.add(envVariableName, envValue, locked, secret)

packages/cli/src/commands/env/update.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import prompts from 'prompts'
12
import * as api from '../../rest/api'
23
import { Flags, Args, ux } from '@oclif/core'
34
import { AuthCommand } from '../authCommand'
@@ -43,7 +44,13 @@ export default class EnvUpdate extends AuthCommand {
4344
if (args.value) {
4445
envValue = args.value
4546
} else {
46-
envValue = await ux.prompt(`What is the value of ${envVariableName}?`, { type: 'mask' })
47+
const response = await prompts({
48+
type: 'password',
49+
name: 'value',
50+
message: `What is the value of ${envVariableName}?`,
51+
})
52+
53+
envValue = response.value
4754
}
4855
try {
4956
await api.environmentVariables.update(envVariableName, envValue, locked, secret)

packages/cli/src/help/help-extension.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,22 @@
11
import { Command, Help } from '@oclif/core'
22
import examples from './examples'
3-
import { BaseCommandClass } from '../commands/baseCommand'
43
import { Topic } from '@oclif/core/lib/interfaces'
54

65
export default class ChecklyHelpClass extends Help {
7-
protected formatAllCommands (commands: Array<BaseCommandClass | Command.Loadable | Command.Cached>,
6+
protected formatAllCommands (commands: Array<Command.Loadable>,
87
topics: Array<Topic>): string {
98
if (commands.length === 0) return ''
109

1110
const coreCommands = commands.filter(c => c.coreCommand)
1211
const additionalCommands = commands.filter(c => !c.coreCommand)
1312

14-
const formatCommandsWithoutTopics = (commands: Array<BaseCommandClass | Command.Loadable | Command.Cached>) =>
13+
const formatCommandsWithoutTopics = (commands: Array<Command.Loadable>) =>
1514
commands
1615
// discard commands with ':' indicating they are under a topic
1716
.filter(c => !c.id.includes(':') || c.coreCommand)
1817
.map(c => [c.id.replace(/:/g, ' '), this.summary(c)])
1918

20-
const formatCommandsWithTopics = (commands: Array<BaseCommandClass | Command.Loadable | Command.Cached>) =>
19+
const formatCommandsWithTopics = (commands: Array<Command.Loadable>) =>
2120
commands
2221
// discard commands with ':' indicating they are under a topic
2322
.filter(c => !c.id.includes(':'))

packages/create-cli/bin/run

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
#!/usr/bin/env node
2+
/* eslint-disable @typescript-eslint/no-var-requires */
23
/* eslint-disable no-console */
34

45
const currentVersion = process.versions.node
56
const requiredVersion = parseInt(currentVersion.split('.')[0], 10)
6-
const minimumVersion = 16
7+
const minimumVersion = 18
78

89
if (requiredVersion < minimumVersion) {
910
console.error(`You are running Node.js v${currentVersion}. The Checkly CLI requires Node.js v${minimumVersion} or higher.`)
1011
process.exit(1)
1112
}
1213

13-
const oclif = require('@oclif/core')
14+
const { run, handle, flush } = require('@oclif/core')
1415

15-
oclif.run().then(require('@oclif/core/flush')).catch(require('@oclif/core/handle'))
16+
run().catch(handle).finally(flush)

packages/create-cli/package.json

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,26 @@
3737
],
3838
"oclif": {
3939
"bin": "create-cli",
40-
"commands": "./dist/commands",
41-
"default": "bootstrap"
40+
"commands": {
41+
"strategy": "single",
42+
"target": "./dist/commands/bootstrap"
43+
},
44+
"plugins": [
45+
"@oclif/plugin-help",
46+
"@oclif/plugin-warn-if-update-available"
47+
],
48+
"warn-if-update-available": {
49+
"timeoutInDays": 30,
50+
"message": "<%= config.name %> update available from <%= chalk.greenBright(config.version) %> to <%= chalk.greenBright(latest) %>. To update, run `npm install -D checkly@latest`"
51+
},
52+
"topicSeparator": " "
4253
},
4354
"homepage": "https://github.com/checkly/checkly-cli#readme",
4455
"dependencies": {
45-
"@oclif/core": "2.8.11",
46-
"@oclif/plugin-help": "5.1.20",
47-
"@oclif/plugin-plugins": "5.4.4",
56+
"@oclif/core": "4.2.8",
57+
"@oclif/plugin-help": "6.2.26",
58+
"@oclif/plugin-plugins": "5.4.34",
59+
"@oclif/plugin-warn-if-update-available": "3.1.35",
4860
"axios": "1.7.4",
4961
"chalk": "4.1.2",
5062
"debug": "4.3.4",

0 commit comments

Comments
 (0)