Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

heroku-cli-addons

Package Overview
Dependencies
Maintainers
7
Versions
51
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

heroku-cli-addons - npm Package Compare versions

Comparing version 0.2.1 to 0.3.0

17

commands/addons/open.js

@@ -93,2 +93,7 @@ 'use strict';

function* getAppAddonAttachment (addon, app) {
const attachments = yield api.get(`/addons/${encodeURIComponent(addon.id)}/addon-attachments`);
return attachments.find(att => att.app.name === app);
}
let id = ctx.args.addon;

@@ -105,3 +110,13 @@

let addon = yield getAppAddon(ctx.app, id);
yield open(addon.web_url);
// If we were passed an add-on slug, there still could be an attachment
// to the context app. Try to find and use it so `context_app` is set
// correctly in the SSO payload.
let attachment = yield getAppAddonAttachment(addon, ctx.app);
if (attachment) {
yield open(attachment.web_url);
} else {
yield open(addon.web_url);
}
}

@@ -108,0 +123,0 @@ }

2

package.json
{
"name": "heroku-cli-addons",
"version": "0.2.1",
"version": "0.3.0",
"description": "`heroku addons:*` commands",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -14,10 +14,38 @@ 'use strict';

it('opens the addon dashboard', function() {
let api = nock('https://api.heroku.com:443')
.get('/apps/myapp/addons/slowdb')
.reply(200, {web_url: 'http://slowdb'});
let api = nock('https://api.heroku.com:443');
api.get('/apps/myapp/addons/slowdb')
.reply(200, {id: 'slowdb', web_url: 'http://slowdb'});
api.get('/addons/slowdb/addon-attachments')
.reply(200, []);
return cmd.run({app: 'myapp', args: {addon: 'slowdb'}})
.then(() => expect(opnMock.url).to.equal('http://slowdb'))
.then(() => expect(cli.stdout).to.equal('Opening http://slowdb...\n'))
.then(() => api.done());
.then(() => expect(opnMock.url).to.equal('http://slowdb'))
.then(() => expect(cli.stdout).to.equal('Opening http://slowdb...\n'))
.then(() => api.done());
});
it('opens an attached addon, by slug, with the correct `context_app`', function() {
let api = nock('https://api.heroku.com:443');
api.get('/apps/myapp-2/addon-attachments/slowdb')
.reply(404);
api.get('/apps/myapp-2/addons/slowdb')
.reply(404);
api.get('/addons/slowdb')
.reply(200, {id: 'c7c9cf20-ec87-11e5-aea4-0002a5d5c51b', web_url: 'http://myapp-slowdb'});
api.get('/addons/c7c9cf20-ec87-11e5-aea4-0002a5d5c51b/addon-attachments')
.reply(200, [
{app: {name: 'myapp'}, web_url: 'http://myapp-slowdb'},
{app: {name: 'myapp-2'}, web_url: 'http://myapp-2-slowdb'}]);
return cmd.run({app: 'myapp-2', args: {addon: 'slowdb'}})
.then(() => expect(opnMock.url).to.equal('http://myapp-2-slowdb'))
.then(() => expect(cli.stdout).to.equal('Opening http://myapp-2-slowdb...\n'))
.then(() => api.done());
});
});
SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc