fh-dev-tools
Advanced tools
Comparing version 1.0.1 to 1.1.1
@@ -10,3 +10,6 @@ var index = require('../../index.js'); | ||
.alias('p', 'product') | ||
.default('t', 'mobile-internal@redhat.com') | ||
.alias('t', 'to') | ||
.describe('to', 'Specify email recipients') | ||
.describe('print', 'Print out email content only') | ||
.argv; | ||
@@ -18,3 +21,3 @@ return argv; | ||
var email = index.email; | ||
email.sendReleaseNote(args.product, args.version, null, function(err){ | ||
email.sendReleaseNote(args.product, args.version, null, function(err, sent){ | ||
if(err) { | ||
@@ -24,5 +27,9 @@ logger.error(err); | ||
} | ||
logger.info('Email sent'); | ||
if(sent === false){ | ||
logger.info('No email is sent'); | ||
} else { | ||
logger.info('Email sent'); | ||
} | ||
}); | ||
} | ||
}; |
@@ -96,7 +96,7 @@ module.exports = { | ||
'smtp_auth_user': { | ||
description: 'Email User (SendGrid Username). Optional.', | ||
description: 'Email User (Gmail). Optional.', | ||
default: nconf.get('smtp_auth_user') | ||
}, | ||
'smtp_auth_pass': { | ||
description: 'Email Password (SendGrid Password). Optional.', | ||
description: 'Email Password (Gmail App Password). Optional.', | ||
hidden: true, | ||
@@ -103,0 +103,0 @@ default: nconf.get('smtp_auth_pass') |
@@ -0,3 +1,11 @@ | ||
# 1.1.1 | ||
## Fix repo check if already on correct branch of fhcap | ||
# 1.1.0 | ||
## Use Gmail for sending emails | ||
# 1.0.1 | ||
## Update tag prefix for core_map | ||
## Update tag prefix for core_map |
@@ -38,2 +38,4 @@ var Git = require('./tools/git.js'); | ||
}); | ||
} else { | ||
return cb(); | ||
} | ||
@@ -47,2 +49,3 @@ }); | ||
var branchName = products.releaseTag(product_name, version); | ||
// TODO: if already on correct branch, skip | ||
confirm('Checkout (new) branch for release ' + branchName + ' in ' + repoPath + '?', function(err, yesno){ | ||
@@ -49,0 +52,0 @@ if(err){ |
@@ -9,5 +9,30 @@ var nodemailer = require('nodemailer'); | ||
var logger = require('./logger.js')(); | ||
var _ = require('underscore'); | ||
function addPadding(message, many){ | ||
var paddings = []; | ||
for(var i=0;i<many;i++){ | ||
paddings.push(' '); | ||
} | ||
return paddings.join('') + message; | ||
} | ||
var consoleTransport = { | ||
name: 'console', | ||
version: '0.1.0', | ||
send: function(mail, callback){ | ||
var envelope = mail.data.envelope || mail.message.getEnvelope(); | ||
console.log('\n'); | ||
console.log(addPadding('To: ' + envelope.to, 0)); | ||
console.log(addPadding('Subject: ' + mail.data.subject, 0)); | ||
console.log(addPadding('Content: ', 0)); | ||
_.forEach(mail.data.text.split('\n'), function(line){ | ||
console.log(addPadding(line, 0)); | ||
}); | ||
callback(null, false); | ||
} | ||
}; | ||
var transporter = null; | ||
var printOnly = false; | ||
@@ -17,18 +42,22 @@ function getTransporter(){ | ||
var pass = nconf.get('smtp_auth_pass'); | ||
if(!user || !pass){ | ||
logger.warn('No user or password set for sending email'); | ||
if(nconf.get('print')){ | ||
logger.info('Print out email content'); | ||
printOnly = true; | ||
transporter = consoleTransport; | ||
} else { | ||
if(!user || !pass){ | ||
logger.warn('No user or password set for sending email'); | ||
logger.warn('Print out email content'); | ||
printOnly = true; | ||
transporter = consoleTransport; | ||
} else { | ||
transporter = { | ||
service: 'Gmail', | ||
auth: { | ||
user: user, | ||
pass: pass | ||
} | ||
}; | ||
} | ||
} | ||
var host = nconf.get('smtp_host') || 'smtp.sendgrid.net'; | ||
var port = nconf.get('smtp_port') || 587; | ||
logger.debug('Sending email conf', {host: host, port: port}); | ||
if(null === transporter){ | ||
transporter = nodemailer.createTransport({ | ||
host:host, | ||
port:port, | ||
auth: { | ||
user: user, | ||
pass: pass | ||
} | ||
}); | ||
} | ||
return transporter; | ||
@@ -39,3 +68,3 @@ } | ||
sendMarkdown: function(from, to, subject, markdown, cb){ | ||
var t = getTransporter(); | ||
var t = nodemailer.createTransport(transporter); | ||
t.use('compile', markdownPlugin()); | ||
@@ -59,2 +88,3 @@ var opts = { | ||
sendReleaseNote: function(prod, version, content, cb){ | ||
getTransporter(); | ||
var from = nconf.get('user_email'); | ||
@@ -64,12 +94,16 @@ var to = nconf.get('to') || 'mobile-internal@redhat.com'; | ||
function doSend(md, cb){ | ||
confirm('Send release note to ' + to + '?', function(err, yesno){ | ||
if(err){ | ||
return cb(err); | ||
} | ||
if(yesno){ | ||
module.exports.sendMarkdown(from, to, subject, md, cb); | ||
} else { | ||
return cb(); | ||
} | ||
}); | ||
if(!printOnly){ | ||
confirm('Send release note to ' + to + '?', function(err, yesno){ | ||
if(err){ | ||
return cb(err); | ||
} | ||
if(yesno){ | ||
module.exports.sendMarkdown(from, to, subject, md, cb); | ||
} else { | ||
return cb(null, false); | ||
} | ||
}); | ||
} else { | ||
module.exports.sendMarkdown(from, to, subject, md, cb); | ||
} | ||
} | ||
@@ -76,0 +110,0 @@ if(content){ |
{ | ||
"name": "fh-dev-tools", | ||
"version": "1.0.1", | ||
"version": "1.1.1", | ||
"description": "FeedHenry Development Tools", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
# fh-dev-tools | ||
FeedHenry Development Tools | ||
## Install | ||
`npm install fh-dev-tools -g` | ||
## Usage | ||
@@ -36,2 +40,8 @@ | ||
#### About Email Setup | ||
During setup, this tool will ask for your Gmail user name and [App Password](https://security.google.com/settings/security/apppasswords) for sending out emails. You should not use your Gmail account's user password here. | ||
If you choose not to set the password, the tool will print out the email content to the console so you can compose the email using other tools. However, the email content will be in Markdown and you may need other tools to support editing emails in Markdown (e.g. You can try [Markdown Here](http://markdown-here.com/)). But there is no way to support Mail.app at the moment. | ||
### Release | ||
@@ -38,0 +48,0 @@ |
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
42887
1270
57