Skip to content

Commit

Permalink
feat: update messaging to take project isMonitored state into account
Browse files Browse the repository at this point in the history
  • Loading branch information
joshje authored and Danny Grander committed Aug 4, 2016
1 parent 1731104 commit 7874202
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
13 changes: 11 additions & 2 deletions cli/commands/monitor.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ var apiTokenExists = require('../../lib/api-token').exists;
var snyk = require('../../lib/');
var config = require('../../lib/config');
var url = require('url');
var chalk = require('chalk');

function monitor(path, options) {
if (!path) {
Expand Down Expand Up @@ -34,11 +35,19 @@ function monitor(path, options) {
if (res.org) {
leader = '/org/' + res.org;
}
endpoint.pathname = leader + '/monitor/' + res.id;
var monitorUrl = url.format(endpoint);
endpoint.pathname = leader + '/manage';
var manageUrl = url.format(endpoint);

endpoint.pathname = leader + '/monitor/' + res.id;
return 'Captured a snapshot of this project\'s dependencies.\n' +
'Explore this snapshot at ' + url.format(endpoint) + '\n' +
'Explore this snapshot at ' + monitorUrl + '\n' +
(res.isMonitored ?
'Notifications about newly disclosed vulnerabilities\n' +
'related to these dependencies will be emailed to you.\n';
'related to these dependencies will be emailed to you.\n' :
chalk.bold.red('Project is inactive, so notifications are turned ' +
'off.\nActivate this project here: ' + manageUrl + '\n'));
});

});
Expand Down
12 changes: 9 additions & 3 deletions cli/commands/protect/wizard.js
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,9 @@ function processAnswers(answers, policy, options) {
leader = '/org/' + monitorRes.org;
}
endpoint.pathname = leader + '/monitor/' + monitorRes.id;
var monitorUrl = url.format(endpoint);
endpoint.pathname = leader + '/manage';
var manageUrl = url.format(endpoint);

return (options.newPolicy ?
// if it's a newly created file
Expand All @@ -400,9 +403,12 @@ function processAnswers(answers, policy, options) {
'\nYour .snyk policy file has been successfully updated.') +
'\nTo review your policy, run `snyk policy`.\n\n' +
'You can see a snapshot of your dependencies here:\n' +
url.format(endpoint) +
'\n\nWe\'ll notify you when relevant new vulnerabilities are ' +
'disclosed.';
monitorUrl + '\n\n' +
(monitorRes.isMonitored ?
'We\'ll notify you when relevant new vulnerabilities are ' +
'disclosed.\n' :
chalk.bold.red('Project is inactive, so notifications are turned off.\n' +
'Activate this project here: ' + manageUrl + '\n'));
})
.catch(function (error) {
// if it's a dry run - exit with 0 status
Expand Down

0 comments on commit 7874202

Please sign in to comment.