heroku-cli-addons
Advanced tools
Comparing version 0.2.1 to 0.3.0
@@ -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 @@ } |
{ | ||
"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()); | ||
}); | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
49837
1130
0