Socket
Socket
Sign inDemoInstall

heroku-api-plugin

Package Overview
Dependencies
54
Maintainers
5
Versions
19
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.1.2 to 1.2.2

yarn.lock

62

commands/api.js

@@ -1,5 +0,6 @@

'use strict';
'use strict'
let cli = require('heroku-cli-util');
let fs = require("co-fs");
const cli = require('heroku-cli-util')
const fs = require('co-fs')
const {inspect} = require('util')

@@ -38,4 +39,4 @@ module.exports = {

args: [
{name: 'method', description: 'GET, POST, PUT, PATCH, or DELETE', optional: false},
{name: 'path', description: 'endpoint to call', optional: false}
{name: 'method', description: 'GET, POST, PUT, PATCH, or DELETE'},
{name: 'path', description: 'endpoint to call', optional: true}
],

@@ -46,29 +47,36 @@ flags: [

],
run: cli.command(function* (context, heroku) {
let request = {};
request.method = context.args.method.toUpperCase();
request.path = context.args.path;
let version = context.flags.version || "3";
let headers = { 'Accept': `application/vnd.heroku+json; version=${version}` };
if (context.flags['accept-inclusion'] !== undefined) {
headers['Accept-Inclusion'] = context.flags['accept-inclusion'];
run: cli.command(async function (context, heroku) {
let request = {}
request.path = context.args.path
request.method = context.args.method
if (!request.path) {
request.path = request.method
request.method = 'GET'
}
request.headers = headers;
if (request.method === "PATCH" || request.method === "PUT" || request.method === "POST") {
let body = yield fs.readFile('/dev/stdin', 'utf8');
let parsedBody;
request.method = request.method.toUpperCase()
let version = context.flags.version || '3'
request.headers = { 'Accept': `application/vnd.heroku+json; version=${version}` }
if (context.flags['accept-inclusion']) {
request.headers['Accept-Inclusion'] = context.flags['accept-inclusion']
}
if (request.method === 'PATCH' || request.method === 'PUT' || request.method === 'POST') {
let body = await fs.readFile('/dev/stdin', 'utf8')
let parsedBody
try {
parsedBody = JSON.parse(body);
} catch(e) {
throw new Error("Request body must be valid JSON");
parsedBody = JSON.parse(body)
} catch (e) {
throw new Error('Request body must be valid JSON')
}
request.body = parsedBody;
request.body = parsedBody
}
let response = yield heroku.request(request);
let response
try {
response = await heroku.request(request)
} catch (err) {
if (!err.statusCode) throw err
throw new Error(`HTTP: ${err.statusCode} ${request.path}\n${inspect(err.body)}`)
}
if (typeof response === "object")
cli.styledJSON(response);
else
cli.log(response);
if (typeof response === 'object') { cli.styledJSON(response) } else { cli.log(response) }
})
};
}
exports.topic = {
name: 'api',
description: 'call the Heroku API directly'
};
}
exports.commands = [
require('./commands/api')
];
]
{
"name": "heroku-api-plugin",
"description": "access the Heroku API directly",
"version": "1.1.2",
"author": "Mark Pundsack @markpundsack",
"repository": "heroku/heroku-api-plugin",
"version": "1.2.2",
"author": "Jeff Dickey @dickeyxxx",
"bugs": {
"url": "https://github.com/heroku/heroku-api-plugin/issues"
},
"dependencies": {
"co": "^4.5.4",
"co-fs": "^1.2.0",
"heroku-cli-util": "^6.2.0"
},
"devDependencies": {
"chai": "^4.0.2",
"mocha": "^3.4.2",
"nock": "^9.0.13",
"sinon": "^2.3.5",
"sinon-chai": "^2.8.0",
"standard": "^10.0.2"
},
"keywords": [

@@ -15,20 +27,9 @@ "heroku-plugin"

"main": "index.js",
"repository": "heroku/heroku-api-plugin",
"scripts": {
"test": "mocha && jshint .",
"preversion": "npm test",
"postversion": "npm publish && git push && git push --tags"
"test": "mocha && standard"
},
"dependencies": {
"co": "^4.5.4",
"co-fs": "^1.2.0",
"heroku-cli-util": "5.8.4"
},
"devDependencies": {
"chai": "^3.0.0",
"jshint": "*",
"mocha": "^2.2.5",
"nock": "^2.5.0",
"sinon": "^1.15.3",
"sinon-chai": "^2.8.0"
"standard": {
"env": "jest"
}
}

@@ -1,32 +0,32 @@

'use strict';
'use strict'
let cli = require('heroku-cli-util');
let nock = require('nock');
let sinon = require('sinon');
let cmd = require('../../commands/api');
let cli = require('heroku-cli-util')
let nock = require('nock')
let sinon = require('sinon')
let cmd = require('../../commands/api')
describe('api', function () {
beforeEach(function () {
this.cliDebug = sinon.stub(cli, 'debug');
});
this.cliDebug = sinon.stub(cli, 'debug')
})
afterEach(function () {
this.cliDebug.restore();
});
this.cliDebug.restore()
})
it.skip('displays the app info', function () {
let self = this;
let method = "get";
let path = "/app/myapp";
let app = {name: 'myapp', web_url: 'https://myapp.herokuapp.com/'};
let self = this
let method = 'get'
let path = '/app/myapp'
let app = {name: 'myapp', web_url: 'https://myapp.herokuapp.com/'}
nock('https://api.heroku.com')
.get('/apps/myapp')
.reply(200, app);
.reply(200, app)
return cmd.run({args: {method, path}, flags: {}})
.then(function () {
self.cliDebug.should.have.been.calledWith(app);
});
});
});
self.cliDebug.should.have.been.calledWith(app)
})
})
})

@@ -1,8 +0,8 @@

'use strict';
'use strict'
let cli = require('heroku-cli-util');
cli.raiseErrors = true;
let cli = require('heroku-cli-util')
cli.raiseErrors = true
let chai = require('chai');
chai.use(require('sinon-chai'));
chai.should();
let chai = require('chai')
chai.use(require('sinon-chai'))
chai.should()
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc