Skip to content

Commit

Permalink
refactor: migrate run commands to use oclif/core v2 (#2880)
Browse files Browse the repository at this point in the history
* refactor: migrate run command to oclif/core v2

* refactor: migrate run:detached command to oclif/core v2

* refactor: migrate run:inside command to oclif/core v2

* refactor: remove unneeded packages

* refactor: delete run-v5 package

* update yarn.lock
  • Loading branch information
k80bowman committed May 14, 2024
1 parent f1d4690 commit 2074b60
Show file tree
Hide file tree
Showing 32 changed files with 44 additions and 2,398 deletions.
3 changes: 0 additions & 3 deletions packages/cli/package.json
Expand Up @@ -8,18 +8,15 @@
"dependencies": {
"@heroku-cli/color": "2.0.1",
"@heroku-cli/command": "^10.0.0",
"@heroku-cli/command-v9": "npm:@heroku-cli/command@^9.0.2",
"@heroku-cli/notifications": "^1.2.4",
"@heroku-cli/plugin-certs-v5": "^9.0.0-alpha.0",
"@heroku-cli/plugin-ps": "^8.1.7",
"@heroku-cli/plugin-ps-exec": "^2.4.0",
"@heroku-cli/plugin-run": "8.1.4",
"@heroku-cli/schema": "^1.0.25",
"@heroku/buildpack-registry": "^1.0.1",
"@heroku/eventsource": "^1.0.7",
"@heroku/heroku-cli-util": "^8.0.13",
"@oclif/core": "^2.8.11",
"@oclif/core-v1": "npm:@oclif/core@^1.26.2",
"@oclif/plugin-commands": "2.2.2",
"@oclif/plugin-help": "^5",
"@oclif/plugin-legacy": "^1.3.0",
Expand Down
23 changes: 9 additions & 14 deletions packages/cli/src/commands/run/detached.ts
@@ -1,13 +1,10 @@
/* eslint-disable @typescript-eslint/ban-ts-comment */
// tslint:disable:file-name-casing
import color from '@heroku-cli/color'
import {Command, flags} from '@heroku-cli/command-v9'
import {DynoSizeCompletion, ProcessTypeCompletion} from '@heroku-cli/command-v9/lib/completions'
import {CliUx} from '@oclif/core-v1'
import '@oclif/core-v1/lib/parser'
import Dyno from '@heroku-cli/plugin-run/lib/lib/dyno'
import {buildCommand} from '@heroku-cli/plugin-run/lib/lib/helpers'
import logDisplayer from '@heroku-cli/plugin-run/lib/lib/log-displayer'
import {Command, flags} from '@heroku-cli/command'
import {DynoSizeCompletion, ProcessTypeCompletion} from '@heroku-cli/command/lib/completions'
import {ux} from '@oclif/core'
import Dyno from '../../lib/run/dyno'
import {buildCommand} from '../../lib/run/helpers'
import logDisplayer from '../../lib/run/log-displayer'

export default class RunDetached extends Command {
static description = 'run a detached dyno, where output is sent to your logs'
Expand All @@ -33,7 +30,7 @@ export default class RunDetached extends Command {
const opts = {
heroku: this.heroku,
app: flags.app,
command: buildCommand(argv),
command: buildCommand(argv as string[]),
size: flags.size,
type: flags.type,
env: flags.env,
Expand All @@ -51,13 +48,11 @@ export default class RunDetached extends Command {
if (flags.tail) {
await logDisplayer(this.heroku, {
app: flags.app,
// @ts-ignore
dyno: dyno.dyno.name,
dyno: dyno.dyno?.name,
tail: true,
})
} else {
// @ts-ignore
CliUx.ux.log(`Run ${color.cmd('heroku logs --app ' + dyno.opts.app + ' --dyno ' + dyno.dyno.name)} to view the output.`)
ux.log(`Run ${color.cmd(`heroku logs --app ${dyno.opts.app} --dyno ${dyno.dyno?.name || ''}`)} to view the output.`)
}
}
}
15 changes: 7 additions & 8 deletions packages/cli/src/commands/run/index.ts
@@ -1,11 +1,10 @@
import {Command, flags} from '@heroku-cli/command-v9'
import {DynoSizeCompletion, ProcessTypeCompletion} from '@heroku-cli/command-v9/lib/completions'
import {CliUx} from '@oclif/core-v1'
import '@oclif/core-v1/lib/parser'
import {Command, flags} from '@heroku-cli/command'
import {DynoSizeCompletion, ProcessTypeCompletion} from '@heroku-cli/command/lib/completions'
import {ux} from '@oclif/core'
import debugFactory from 'debug'
import * as Heroku from '@heroku-cli/schema'
import Dyno from '@heroku-cli/plugin-run/lib/lib/dyno'
import {buildCommand} from '@heroku-cli/plugin-run/lib/lib/helpers'
import Dyno from '../../lib/run/dyno'
import {buildCommand} from '../../lib/run/helpers'

const debug = debugFactory('heroku:run')

Expand Down Expand Up @@ -40,7 +39,7 @@ export default class Run extends Command {
'no-tty': flags['no-tty'],
app: flags.app,
attach: true,
command: buildCommand(argv),
command: buildCommand(argv as string[]),
env: flags.env,
heroku: this.heroku,
listen: flags.listen,
Expand All @@ -61,7 +60,7 @@ export default class Run extends Command {
} catch (error: any) {
debug(error)
if (error.exitCode) {
CliUx.ux.error(error.message, {code: error.exitCode, exit: error.exitCode})
ux.error(error.message, {code: error.exitCode, exit: error.exitCode})
} else {
throw error
}
Expand Down
16 changes: 7 additions & 9 deletions packages/cli/src/commands/run/inside.ts
@@ -1,10 +1,8 @@
// tslint:disable:file-name-casing
import {Command, flags} from '@heroku-cli/command-v9'
import {CliUx} from '@oclif/core-v1'
import '@oclif/core-v1/lib/parser'
import {Command, flags} from '@heroku-cli/command'
import {ux} from '@oclif/core'
import debugFactory from 'debug'
import Dyno from '@heroku-cli/plugin-run/lib/lib/dyno'
import {buildCommand} from '@heroku-cli/plugin-run/lib/lib/helpers'
import Dyno from '../../lib/run/dyno'
import {buildCommand} from '../../lib/run/helpers'

const debug = debugFactory('heroku:run:inside')

Expand Down Expand Up @@ -37,8 +35,8 @@ export default class RunInside extends Command {
const opts = {
'exit-code': flags['exit-code'],
app: flags.app,
command: buildCommand(argv.slice(1)),
dyno: argv[0],
command: buildCommand(argv.slice(1) as string[]),
dyno: argv[0] as string,
env: flags.env,
heroku: this.heroku,
listen: flags.listen,
Expand All @@ -51,7 +49,7 @@ export default class RunInside extends Command {
} catch (error: any) {
debug(error)
if (error.exitCode) {
CliUx.ux.exit(error.exitCode)
ux.exit(error.exitCode)
} else {
throw error
}
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/lib/run/log-displayer.ts
Expand Up @@ -10,7 +10,7 @@ const EventSource = require('@heroku/eventsource')

interface LogDisplayerOptions {
app: string;
dyno: string;
dyno?: string;
lines?: number;
tail: boolean;
source?: string;
Expand Down
2 changes: 0 additions & 2 deletions packages/run-v5/.gitignore

This file was deleted.

0 comments on commit 2074b60

Please sign in to comment.