Skip to content
This repository has been archived by the owner on Feb 12, 2022. It is now read-only.

Commit

Permalink
fix: move to @heroku-cli/command
Browse files Browse the repository at this point in the history
  • Loading branch information
jdx committed Apr 6, 2018
1 parent 6a5664f commit c8a1db5
Show file tree
Hide file tree
Showing 11 changed files with 45 additions and 114 deletions.
2 changes: 1 addition & 1 deletion commands/detached.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ let cli = require('heroku-cli-util')
let helpers = require('../lib/helpers')
let logDisplayer = require('../lib/log_displayer')
let Dyno = require('../lib/dyno')
const {DynoSizeCompletion, ProcessTypeCompletion} = require('cli-engine-heroku/lib/completions')
const {DynoSizeCompletion, ProcessTypeCompletion} = require('@heroku-cli/command/lib/completions')

function * run (context, heroku) {
let opts = {
Expand Down
2 changes: 1 addition & 1 deletion commands/logs.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
let co = require('co')
let cli = require('heroku-cli-util')
let logDisplayer = require('../lib/log_displayer')
const {DynoCompletion, ProcessTypeCompletion} = require('cli-engine-heroku/lib/completions')
const {DynoCompletion, ProcessTypeCompletion} = require('@heroku-cli/command/lib/completions')

function * run (context, heroku) {
cli.color.enabled = context.flags['force-colors'] || cli.color.enabled
Expand Down
2 changes: 1 addition & 1 deletion commands/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ let co = require('co')
let cli = require('heroku-cli-util')
let helpers = require('../lib/helpers')
let Dyno = require('../lib/dyno')
const {DynoSizeCompletion, ProcessTypeCompletion} = require('cli-engine-heroku/lib/completions')
const {DynoSizeCompletion, ProcessTypeCompletion} = require('@heroku-cli/command/lib/completions')

function * run (context, heroku) {
let opts = {
Expand Down
50 changes: 25 additions & 25 deletions lib/dyno.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,28 +59,28 @@ class Dyno extends Duplex {
force_no_tty: this.opts['no-tty']
}
})
.then(dyno => {
this.dyno = dyno
if (this.opts.attach || this.opts.dyno) {
if (this.dyno.name && this.opts.dyno === undefined) this.opts.dyno = this.dyno.name
return this.attach()
} else if (this.opts.showStatus) {
cli.action.done(this._status('done'))
}
})
.catch(err => {
.then(dyno => {
this.dyno = dyno
if (this.opts.attach || this.opts.dyno) {
if (this.dyno.name && this.opts.dyno === undefined) this.opts.dyno = this.dyno.name
return this.attach()
} else if (this.opts.showStatus) {
cli.action.done(this._status('done'))
}
})
.catch(err => {
// Currently the runtime API sends back a 409 in the event the
// release isn't found yet. API just forwards this response back to
// the client, so we'll need to retry these. This usually
// happens when you create an app and immediately try to run a
// one-off dyno. No pause between attempts since this is
// typically a very short-lived condition.
if (err.statusCode === 409 && retries > 0) {
return this._doStart(retries - 1)
} else {
throw err
}
})
if (err.statusCode === 409 && retries > 0) {
return this._doStart(retries - 1)
} else {
throw err
}
})
}

/**
Expand Down Expand Up @@ -137,16 +137,16 @@ class Dyno extends Duplex {
const wait = (ms) => new Promise((resolve) => setTimeout(resolve, ms))

return this.heroku.get(`/apps/${this.opts.app}/dynos/${this.opts.dyno}`)
.then(dyno => {
this.dyno = dyno
cli.action.done(this._status(this.dyno.state))
.then(dyno => {
this.dyno = dyno
cli.action.done(this._status(this.dyno.state))

if (this.dyno.state === 'starting' || this.dyno.state === 'up') return this._connect()
else return wait(interval).then(this._ssh.bind(this))
})
.catch(() => {
return wait(interval).then(this._ssh.bind(this))
})
if (this.dyno.state === 'starting' || this.dyno.state === 'up') return this._connect()
else return wait(interval).then(this._ssh.bind(this))
})
.catch(() => {
return wait(interval).then(this._ssh.bind(this))
})
}

_connect () {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
}
},
"dependencies": {
"cli-engine-heroku": "^5.0.4",
"@heroku-cli/command": "^8.0.4",
"co": "4.6.0",
"eventsource": "^1.0.5",
"fs-extra": "^5.0.0",
Expand Down
2 changes: 1 addition & 1 deletion test/commands/console.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ describe('console', () => {

it('runs console', () => {
return cmd.run({app: 'heroku-run-test-app', flags: {}})
.then(() => expect(dynoOpts.command, 'to equal', 'console'))
.then(() => expect(dynoOpts.command, 'to equal', 'console'))
})

afterEach(() => {
Expand Down
2 changes: 1 addition & 1 deletion test/commands/detached.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ describe('run:detached', () => {

it('runs a command', () => {
return cmd.run({app: 'heroku-run-test-app', flags: {}, auth: {password: apikey}, args: ['echo', '1', '2', '3']})
.then(() => expect(cli.stdout, 'to begin with', 'Run heroku logs --app heroku-run-test-app --dyno'))
.then(() => expect(cli.stdout, 'to begin with', 'Run heroku logs --app heroku-run-test-app --dyno'))
})
})
2 changes: 1 addition & 1 deletion test/commands/logs.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ describe('logs', () => {

it('shows the logs', () => {
return cmd.run({app: 'heroku-run-test-app', flags: {}, auth: {password: apikey}})
.then(() => expect(cli.stdout, 'to begin with', '20')) // starts with the year
.then(() => expect(cli.stdout, 'to begin with', '20')) // starts with the year
})
})
2 changes: 1 addition & 1 deletion test/commands/rake.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ describe('rake', () => {

it('runs rake', () => {
return cmd.run({app: 'heroku-run-test-app', flags: {}, args: ['test']})
.then(() => expect(dynoOpts.command, 'to equal', 'rake test'))
.then(() => expect(dynoOpts.command, 'to equal', 'rake test'))
})

afterEach(() => {
Expand Down
16 changes: 8 additions & 8 deletions test/commands/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,35 +15,35 @@ describe('run', () => {
let fixture = new StdOutFixture()
fixture.capture(s => { stdout += s })
return cmd.run({app: 'heroku-run-test-app', flags: {}, auth: {password: apikey}, args: ['echo', '1', '2', '3']})
.then(() => fixture.release())
.then(() => expect(stdout, 'to equal', '1 2 3\n'))
.then(() => fixture.release())
.then(() => expect(stdout, 'to equal', '1 2 3\n'))
})

it('runs a command with spaces', () => {
let stdout = ''
let fixture = new StdOutFixture()
fixture.capture(s => { stdout += s })
return cmd.run({app: 'heroku-run-test-app', flags: {}, auth: {password: apikey}, args: ['ruby', '-e', 'puts ARGV[0]', '{"foo": "bar"} ']})
.then(() => fixture.release())
.then(() => expect(stdout, 'to equal', '{"foo": "bar"} \n'))
.then(() => fixture.release())
.then(() => expect(stdout, 'to equal', '{"foo": "bar"} \n'))
})

it('runs a command with quotes', () => {
let stdout = ''
let fixture = new StdOutFixture()
fixture.capture(s => { stdout += s })
return cmd.run({app: 'heroku-run-test-app', flags: {}, auth: {password: apikey}, args: ['ruby', '-e', 'puts ARGV[0]', '{"foo":"bar"}']})
.then(() => fixture.release())
.then(() => expect(stdout, 'to equal', '{"foo":"bar"}\n'))
.then(() => fixture.release())
.then(() => expect(stdout, 'to equal', '{"foo":"bar"}\n'))
})

it('runs a command with env vars', () => {
let stdout = ''
let fixture = new StdOutFixture()
fixture.capture(s => { stdout += s })
return cmd.run({app: 'heroku-run-test-app', flags: {env: 'FOO=bar'}, auth: {password: apikey}, args: ['env']})
.then(() => fixture.release())
.then(() => expect(stdout, 'to contain', 'FOO=bar'))
.then(() => fixture.release())
.then(() => expect(stdout, 'to contain', 'FOO=bar'))
})

it('gets 127 status for invalid command', () => {
Expand Down
77 changes: 4 additions & 73 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@
# yarn lockfile v1


"@cli-engine/screen@^0.0.0":
version "0.0.0"
resolved "https://registry.yarnpkg.com/@cli-engine/screen/-/screen-0.0.0.tgz#c2e847c7d4d998490c9097282bf21637d5162116"

"@heroku-cli/color@^1.0.4", "@heroku-cli/color@^1.1.3":
"@heroku-cli/color@^1.1.3":
version "1.1.3"
resolved "https://registry.yarnpkg.com/@heroku-cli/color/-/color-1.1.3.tgz#f5f3bb043c3c5c78888135a89633227cfca04b2b"
dependencies:
Expand All @@ -15,7 +11,7 @@
strip-ansi "^4.0.0"
supports-color "^5.1.0"

"@heroku-cli/command@^8.0.1":
"@heroku-cli/command@^8.0.1", "@heroku-cli/command@^8.0.4":
version "8.0.4"
resolved "https://registry.yarnpkg.com/@heroku-cli/command/-/command-8.0.4.tgz#008cc5efacb34943408d92ae693e05449755a627"
dependencies:
Expand Down Expand Up @@ -562,33 +558,6 @@ cli-cursor@^2.1.0:
dependencies:
restore-cursor "^2.0.0"

cli-engine-heroku@^5.0.4:
version "5.0.4"
resolved "https://registry.yarnpkg.com/cli-engine-heroku/-/cli-engine-heroku-5.0.4.tgz#937fb488b4c41a0eff842d3386a3581d3b0111c2"
dependencies:
cli-ux "^2.0.17"
heroku-client "^3.0.5"
http-call "^4.0.6"
netrc-parser "^2.0.5"

cli-ux@^2.0.17:
version "2.1.1"
resolved "https://registry.yarnpkg.com/cli-ux/-/cli-ux-2.1.1.tgz#07021d2b084d739af5d3c0f9d3d07673cb203947"
dependencies:
"@cli-engine/screen" "^0.0.0"
"@heroku-cli/color" "^1.0.4"
"@heroku/linewrap" "^1.0.0"
ansi-escapes "^3.0.0"
ansi-styles "^3.2.0"
cardinal "^1.0.0"
chalk "^2.3.0"
lodash "^4.17.4"
moment "^2.20.1"
password-prompt "^1.0.3"
strip-ansi "^4.0.0"
supports-color "^5.1.0"
ts-lodash "^4.0.8"

cli-ux@^3.3.26:
version "3.3.26"
resolved "https://registry.yarnpkg.com/cli-ux/-/cli-ux-3.3.26.tgz#998be26eb4bcd2a29a740a9bea2a497071461a7a"
Expand Down Expand Up @@ -1536,7 +1505,7 @@ heroku-cli-util@^8.0.4:
tslib "^1.9.0"
tunnel-agent "^0.6.0"

heroku-client@3.0.6, heroku-client@^3.0.5, heroku-client@^3.0.6:
heroku-client@3.0.6, heroku-client@^3.0.6:
version "3.0.6"
resolved "https://registry.yarnpkg.com/heroku-client/-/heroku-client-3.0.6.tgz#bf603716a9d469682d4f7f80489276d82b896305"
dependencies:
Expand All @@ -1551,17 +1520,6 @@ http-cache-semantics@3.8.1:
version "3.8.1"
resolved "https://registry.yarnpkg.com/http-cache-semantics/-/http-cache-semantics-3.8.1.tgz#39b0e16add9b605bf0a9ef3d9daaf4843b4cacd2"

http-call@^4.0.6:
version "4.0.8"
resolved "https://registry.yarnpkg.com/http-call/-/http-call-4.0.8.tgz#fd0207764958a3f1238bb3344ff912b32ddfa64a"
dependencies:
content-type "^1.0.4"
debug "^3.1.0"
is-retry-allowed "^1.1.0"
is-stream "^1.1.0"
tslib "^1.8.1"
tunnel-agent "^0.6.0"

http-call@^5.1.0:
version "5.1.0"
resolved "https://registry.yarnpkg.com/http-call/-/http-call-5.1.0.tgz#699847d9bcd635eb4e3fdfe3084456a9c89d716d"
Expand Down Expand Up @@ -2021,10 +1979,6 @@ levn@^0.3.0, levn@~0.3.0:
prelude-ls "~1.1.2"
type-check "~0.3.2"

lex@^1.7.9:
version "1.7.9"
resolved "https://registry.yarnpkg.com/lex/-/lex-1.7.9.tgz#5d5636ccef574348362938b79a47f0eed8ed0d43"

load-json-file@^1.0.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/load-json-file/-/load-json-file-1.1.0.tgz#956905708d58b4bab4c2261b04f59f31c99374c0"
Expand Down Expand Up @@ -2297,10 +2251,6 @@ mocha@^5.0.5:
mkdirp "0.5.1"
supports-color "4.4.0"

moment@^2.20.1:
version "2.20.1"
resolved "https://registry.yarnpkg.com/moment/-/moment-2.20.1.tgz#d6eb1a46cbcc14a2b2f9434112c1ff8907f313fd"

ms@2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/ms/-/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8"
Expand Down Expand Up @@ -2330,12 +2280,6 @@ natural-compare@^1.4.0:
version "1.4.0"
resolved "https://registry.yarnpkg.com/natural-compare/-/natural-compare-1.4.0.tgz#4abebfeed7541f2c27acfb29bdbbd15c8d5ba4f7"

netrc-parser@^2.0.5:
version "2.0.6"
resolved "https://registry.yarnpkg.com/netrc-parser/-/netrc-parser-2.0.6.tgz#0a21b96810dbb2c3ac42fac0a260bf838d20ef2f"
dependencies:
lex "^1.7.9"

netrc-parser@^3.1.2, netrc-parser@^3.1.3:
version "3.1.3"
resolved "https://registry.yarnpkg.com/netrc-parser/-/netrc-parser-3.1.3.tgz#b4d70487e1a849dc2294c0362a5f21812115891a"
Expand Down Expand Up @@ -2587,13 +2531,6 @@ pascalcase@^0.1.1:
version "0.1.1"
resolved "https://registry.yarnpkg.com/pascalcase/-/pascalcase-0.1.1.tgz#b363e55e8006ca6fe21784d2db22bd15d7917f14"

password-prompt@^1.0.3:
version "1.0.3"
resolved "https://registry.yarnpkg.com/password-prompt/-/password-prompt-1.0.3.tgz#1478aad647c5afb65158e901bf4df0a3c367039a"
dependencies:
ansi-escapes "^3.0.0"
cross-spawn "^5.1.0"

password-prompt@^1.0.4:
version "1.0.4"
resolved "https://registry.yarnpkg.com/password-prompt/-/password-prompt-1.0.4.tgz#933bac8db3528fcb27e9fdbc0a6592adcbdb5ed9"
Expand Down Expand Up @@ -3328,13 +3265,7 @@ tryit@^1.0.1:
version "1.0.3"
resolved "https://registry.yarnpkg.com/tryit/-/tryit-1.0.3.tgz#393be730a9446fd1ead6da59a014308f36c289cb"

ts-lodash@^4.0.8:
version "4.0.11"
resolved "https://registry.yarnpkg.com/ts-lodash/-/ts-lodash-4.0.11.tgz#f668e2ad4b6cb3bcbeceb894cf0a8cde48b3cd85"
dependencies:
lodash "^4.17.4"

tslib@^1.8.1, tslib@^1.9.0:
tslib@^1.9.0:
version "1.9.0"
resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.9.0.tgz#e37a86fda8cbbaf23a057f473c9f4dc64e5fc2e8"

Expand Down

0 comments on commit c8a1db5

Please sign in to comment.