Skip to content

Commit

Permalink
chore: update oclif
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
sorccu committed Feb 20, 2025
1 parent 18857dc commit ca596cd
Show file tree
Hide file tree
Showing 9 changed files with 2,546 additions and 996 deletions.
3,486 changes: 2,510 additions & 976 deletions package-lock.json

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions packages/cli/bin/run
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/env node
/* eslint-disable @typescript-eslint/no-var-requires */

const oclif = require('@oclif/core')
const { run, handle, flush } = require('@oclif/core')

oclif.run().then(require('@oclif/core/flush')).catch(require('@oclif/core/handle'))
run().catch(handle).finally(flush)
10 changes: 5 additions & 5 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,11 @@
},
"homepage": "https://github.com/checkly/checkly-cli#readme",
"dependencies": {
"@oclif/core": "2.8.11",
"@oclif/plugin-help": "5.1.20",
"@oclif/plugin-not-found": "2.3.23",
"@oclif/plugin-plugins": "5.4.4",
"@oclif/plugin-warn-if-update-available": "2.0.24",
"@oclif/core": "4.2.7",
"@oclif/plugin-help": "6.2.25",
"@oclif/plugin-not-found": "3.2.42",
"@oclif/plugin-plugins": "5.4.33",
"@oclif/plugin-warn-if-update-available": "3.1.33",
"@typescript-eslint/typescript-estree": "6.19.0",
"acorn": "8.8.1",
"acorn-walk": "8.2.0",
Expand Down
3 changes: 2 additions & 1 deletion packages/cli/src/commands/deploy.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { setTimeout } from 'node:timers/promises'
import * as fs from 'fs/promises'
import * as api from '../rest/api'
import config from '../services/config'
Expand Down Expand Up @@ -163,7 +164,7 @@ export default class Deploy extends AuthCommand {
this.log(this.formatPreview(data, project))
}
if (!preview) {
await ux.wait(500)
await setTimeout(500)
this.log(`Successfully deployed project "${project.name}" to account "${account.name}".`)

// Print the ping URL for heartbeat checks.
Expand Down
9 changes: 8 additions & 1 deletion packages/cli/src/commands/env/add.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import prompts from 'prompts'
import * as api from '../../rest/api'
import { Flags, Args, ux } from '@oclif/core'
import { AuthCommand } from '../authCommand'
Expand Down Expand Up @@ -43,7 +44,13 @@ export default class EnvAdd extends AuthCommand {
if (args.value) {
envValue = args.value
} else {
envValue = await ux.prompt(`What is the value of ${envVariableName}?`, { type: 'mask' })
const response = await prompts({
type: 'password',
name: 'value',
message: `What is the value of ${envVariableName}?`,
})

envValue = response.value
}
try {
await api.environmentVariables.add(envVariableName, envValue, locked, secret)
Expand Down
9 changes: 8 additions & 1 deletion packages/cli/src/commands/env/update.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import prompts from 'prompts'
import * as api from '../../rest/api'
import { Flags, Args, ux } from '@oclif/core'
import { AuthCommand } from '../authCommand'
Expand Down Expand Up @@ -43,7 +44,13 @@ export default class EnvUpdate extends AuthCommand {
if (args.value) {
envValue = args.value
} else {
envValue = await ux.prompt(`What is the value of ${envVariableName}?`, { type: 'mask' })
const response = await prompts({
type: 'password',
name: 'value',
message: `What is the value of ${envVariableName}?`,
})

envValue = response.value
}
try {
await api.environmentVariables.update(envVariableName, envValue, locked, secret)
Expand Down
7 changes: 3 additions & 4 deletions packages/cli/src/help/help-extension.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
import { Command, Help } from '@oclif/core'
import examples from './examples'
import { BaseCommandClass } from '../commands/baseCommand'
import { Topic } from '@oclif/core/lib/interfaces'

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

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

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

const formatCommandsWithTopics = (commands: Array<BaseCommandClass | Command.Loadable | Command.Cached>) =>
const formatCommandsWithTopics = (commands: Array<Command.Loadable>) =>
commands
// discard commands with ':' indicating they are under a topic
.filter(c => !c.id.includes(':'))
Expand Down
7 changes: 4 additions & 3 deletions packages/create-cli/bin/run
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
#!/usr/bin/env node
/* eslint-disable @typescript-eslint/no-var-requires */
/* eslint-disable no-console */

const currentVersion = process.versions.node
const requiredVersion = parseInt(currentVersion.split('.')[0], 10)
const minimumVersion = 16
const minimumVersion = 18

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

const oclif = require('@oclif/core')
const { run, handle, flush } = require('@oclif/core')

oclif.run().then(require('@oclif/core/flush')).catch(require('@oclif/core/handle'))
run().catch(handle).finally(flush)
6 changes: 3 additions & 3 deletions packages/create-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@
},
"homepage": "https://github.com/checkly/checkly-cli#readme",
"dependencies": {
"@oclif/core": "2.8.11",
"@oclif/plugin-help": "5.1.20",
"@oclif/plugin-plugins": "5.4.4",
"@oclif/core": "4.2.7",
"@oclif/plugin-help": "6.2.25",
"@oclif/plugin-plugins": "5.4.33",
"axios": "1.7.4",
"chalk": "4.1.2",
"debug": "4.3.4",
Expand Down

0 comments on commit ca596cd

Please sign in to comment.