cli-engine-heroku
Advanced tools
Comparing version 1.1.12 to 2.0.0
@@ -8,5 +8,5 @@ 'use strict'; | ||
var _http = require('cli-engine-command/lib/http'); | ||
var _httpCall = require('http-call'); | ||
var _http2 = _interopRequireDefault(_http); | ||
var _httpCall2 = _interopRequireDefault(_httpCall); | ||
@@ -45,27 +45,36 @@ var _yubikey = require('./yubikey'); | ||
exports.HerokuAPIError = HerokuAPIError; | ||
class Heroku extends _http2.default { | ||
class Heroku { | ||
constructor({ out }, options = {}) { | ||
super(out); | ||
this.out = out; | ||
if (options.required === undefined) options.required = true; | ||
options.preauth = options.preauth !== false; | ||
this.options = options; | ||
this.config = out.config; | ||
let apiUrl = new _url.URL(_vars2.default.apiUrl); | ||
this.requestOptions.host = this.host = apiUrl.host; | ||
this.requestOptions.protocol = 'https:'; | ||
let headers = this.requestOptions.headers; | ||
if (this.auth) headers['authorization'] = `Bearer ${this.auth}`; | ||
headers['user-agent'] = `heroku-cli/${this.out.config.version} ${this.out.config.platform}`; | ||
headers['accept'] = headers['accept'] || 'application/vnd.heroku+json; version=3'; | ||
let envHeaders = JSON.parse(process.env.HEROKU_HEADERS || '{}'); | ||
for (let [k, v] of Object.entries(envHeaders)) { | ||
if (!headers[k]) headers[k] = v; | ||
} | ||
this.twoFactorMutex = new _mutex2.default(); | ||
this.preauthPromises = {}; | ||
let auth = this.auth; | ||
let self = this; | ||
this.http = class extends this.http { | ||
this.http = class extends _httpCall2.default { | ||
static get defaultOptions() { | ||
let opts = { | ||
...super.defaultOptions, | ||
host: apiUrl.host, | ||
headers: { | ||
...super.defaultOptions.headers, | ||
'user-agent': `heroku-cli/${self.config.version} ${self.config.platform}`, | ||
accept: 'application/vnd.heroku+json; version=3', | ||
...envHeaders | ||
} | ||
}; | ||
if (auth) opts.headers.authorization = `Bearer ${auth}`; | ||
return opts; | ||
} | ||
static async twoFactorRetry(err, url, opts = {}, retries = 3) { | ||
const app = err.body.app ? err.body.app.name : null; | ||
if (!app || !options.preauth) { | ||
// flow$ignore | ||
opts.headers['Heroku-Two-Factor-Code'] = await self.twoFactorPrompt(); | ||
@@ -133,3 +142,27 @@ return this.request(url, opts, retries); | ||
} | ||
get(url, options = {}) { | ||
return this.http.get(url, options); | ||
} | ||
post(url, options = {}) { | ||
return this.http.post(url, options); | ||
} | ||
put(url, options = {}) { | ||
return this.http.put(url, options); | ||
} | ||
patch(url, options = {}) { | ||
return this.http.patch(url, options); | ||
} | ||
delete(url, options = {}) { | ||
return this.http.delete(url, options); | ||
} | ||
stream(url, options = {}) { | ||
return this.http.stream(url, options); | ||
} | ||
request(url, options = {}) { | ||
return this.http.request(url, options); | ||
} | ||
get defaultOptions() { | ||
return this.http.defaultOptions; | ||
} | ||
} | ||
exports.default = Heroku; |
@@ -33,6 +33,7 @@ 'use strict'; | ||
let options = { | ||
userAgent: this.heroku.requestOptions.headers['user-agent'], | ||
// flow$ignore | ||
userAgent: this.heroku.defaultOptions.headers['user-agent'], | ||
debug: this.config.debug, | ||
token: this.heroku.auth, | ||
host: `${this.heroku.requestOptions.protocol || 'https:'}//${this.heroku.requestOptions.host || 'api.heroku.com'}` | ||
host: `${this.heroku.defaultOptions.protocol || 'https:'}//${this.heroku.defaultOptions.host || 'api.heroku.com'}` | ||
}; | ||
@@ -39,0 +40,0 @@ |
@@ -13,3 +13,3 @@ 'use strict'; | ||
var _ = require('.'); | ||
require('cli-engine-command/lib/flags'); | ||
@@ -41,9 +41,8 @@ var _git = require('../git'); | ||
function app(options = {}, env = process.env) { | ||
const envApp = env.HEROKU_APP; | ||
const defaultOptions = { | ||
function app(options = {}) { | ||
return { | ||
char: 'a', | ||
description: 'app to run command against', | ||
default: () => envApp, | ||
parse: (input, cmd) => { | ||
const envApp = process.env.HEROKU_APP; | ||
if (cmd && cmd.flags.app) return cmd.flags.app; | ||
@@ -68,17 +67,17 @@ if (input) return input; | ||
const heroku = new _api_client2.default({ out: ctx.out }); | ||
let apps = await heroku.get('/apps'); | ||
let { body: apps } = await heroku.get('/apps'); | ||
return apps.map(a => a.name).sort(); | ||
} | ||
} | ||
}, | ||
...options | ||
}; | ||
return (0, _.merge)(defaultOptions, options); | ||
} | ||
function remote(options = {}) { | ||
const defaultOptions = { | ||
return { | ||
char: 'r', | ||
description: 'git remote of app to use', | ||
parse: input => input | ||
parse: v => v, | ||
...options | ||
}; | ||
return (0, _.merge)(defaultOptions, options); | ||
} | ||
@@ -85,0 +84,0 @@ |
@@ -6,13 +6,3 @@ 'use strict'; | ||
}); | ||
exports.merge = undefined; | ||
var _flags = require('cli-engine-command/lib/flags'); | ||
Object.defineProperty(exports, 'merge', { | ||
enumerable: true, | ||
get: function () { | ||
return _flags.merge; | ||
} | ||
}); | ||
var _cliEngineCommand = require('cli-engine-command'); | ||
@@ -19,0 +9,0 @@ |
@@ -8,15 +8,14 @@ 'use strict'; | ||
var _flags = require('cli-engine-command/lib/flags'); | ||
require('cli-engine-command/lib/flags'); | ||
function OrgFlag(options = {}, env = process.env) { | ||
const defaultOptions = { | ||
function OrgFlag(options = {}) { | ||
return { | ||
char: 'o', | ||
hidden: true, | ||
parse: (input, cmd) => { | ||
parse: input => { | ||
if (input) return input; | ||
if (env.HEROKU_ORGANIZATION) return env.HEROKU_ORGANIZATION; | ||
if (options.required) throw new Error('No org specified'); | ||
} | ||
if (process.env.HEROKU_ORGANIZATION) return process.env.HEROKU_ORGANIZATION; | ||
}, | ||
...options | ||
}; | ||
return (0, _flags.merge)(defaultOptions, options); | ||
} |
@@ -8,14 +8,11 @@ 'use strict'; | ||
var _flags = require('cli-engine-command/lib/flags'); | ||
require('cli-engine-command/lib/flags'); | ||
function PipelineFlag(options = {}, env = process.env) { | ||
const defaultOptions = { | ||
function PipelineFlag(options = {}) { | ||
return { | ||
char: 'p', | ||
description: 'name of pipeline', | ||
parse: (input, cmd) => { | ||
if (input) return input; | ||
if (options.required) throw new Error('No pipeline specified'); | ||
} | ||
parse: v => v, | ||
...options | ||
}; | ||
return (0, _flags.merge)(defaultOptions, options); | ||
} |
@@ -8,17 +8,17 @@ 'use strict'; | ||
var _flags = require('cli-engine-command/lib/flags'); | ||
require('cli-engine-command/lib/flags'); | ||
function TeamFlag(options = {}, env = process.env) { | ||
const defaultOptions = { | ||
function TeamFlag(options = {}) { | ||
return { | ||
char: 't', | ||
description: 'team to use', | ||
parse: (input, cmd) => { | ||
parse: (input, cmd, name) => { | ||
if (input) return input; | ||
if (env.HEROKU_TEAM) return env.HEROKU_TEAM; | ||
if (process.env.HEROKU_TEAM) return process.env.HEROKU_TEAM; | ||
if (cmd && cmd.flags.org) return cmd.flags.org; | ||
if (env.HEROKU_ORGANIZATION) return env.HEROKU_ORGANIZATION; | ||
if (process.env.HEROKU_ORGANIZATION) return process.env.HEROKU_ORGANIZATION; | ||
if (options.required) throw new Error('No team specified'); | ||
} | ||
}, | ||
...options | ||
}; | ||
return (0, _flags.merge)(defaultOptions, options); | ||
} |
{ | ||
"name": "cli-engine-heroku", | ||
"description": "heroku specific functionality for the cli-engine", | ||
"version": "1.1.12", | ||
"version": "2.0.0", | ||
"author": "Jeff Dickey @dickeyxxx", | ||
@@ -9,2 +9,3 @@ "bugs": "https://github.com/heroku/cli-engine-heroku/issues", | ||
"heroku-client": "^3.0.3", | ||
"http-call": "^3.0.1", | ||
"netrc-parser": "^2.0.3" | ||
@@ -16,10 +17,11 @@ }, | ||
"babel-jest": "20.0.3", | ||
"babel-plugin-syntax-object-rest-spread": "^6.13.0", | ||
"babel-plugin-transform-class-properties": "6.24.1", | ||
"babel-plugin-transform-es2015-modules-commonjs": "^6.26.0", | ||
"babel-plugin-transform-flow-strip-types": "6.22.0", | ||
"cli-engine-command": "^6.0.1", | ||
"cli-engine-config": "^1.6.1", | ||
"eslint": "^4.5.0", | ||
"cli-engine-command": "^7.0.2", | ||
"cli-engine-config": "^1.6.4", | ||
"eslint": "^4.6.0", | ||
"eslint-config-standard": "10.2.1", | ||
"eslint-plugin-flowtype": "^2.34.1", | ||
"eslint-plugin-flowtype": "^2.35.1", | ||
"eslint-plugin-import": "^2.7.0", | ||
@@ -30,3 +32,3 @@ "eslint-plugin-jest": "20.0.3", | ||
"eslint-plugin-standard": "3.0.1", | ||
"flow-bin": "^0.53.1", | ||
"flow-bin": "^0.54.0", | ||
"flow-copy-source": "^1.2.1", | ||
@@ -60,3 +62,3 @@ "flow-typed": "^2.1.5", | ||
"peerDependencies": { | ||
"cli-engine-command": "^6.0.0" | ||
"cli-engine-command": "^7.0.0" | ||
}, | ||
@@ -63,0 +65,0 @@ "repository": "heroku/cli-engine-heroku", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 3 instances in 1 package
31309
474
4
24
11
4
+ Addedhttp-call@^3.0.1
+ Addedcli-engine-command@7.0.6(transitive)
+ Addedcli-engine-config@2.0.2(transitive)
+ Addedhttp-call@3.0.2(transitive)
- Removedcli-engine-command@6.0.2(transitive)
- Removedcli-engine-config@1.7.0(transitive)
- Removedhttp-call@2.1.6(transitive)