Comparing version 0.0.14 to 0.0.16
var fs = require('fs') | ||
, request = require('request') | ||
, Step = require('./git/step') | ||
, log = require('./logger').getInstance(); | ||
@@ -17,3 +19,16 @@ | ||
} | ||
exports.readJsonCfg = readJsonCfg; | ||
exports.readJsonCfg = readJsonCfg; | ||
function readJsonCfgFromUrl(url, opts, fn){ | ||
opts.url = url; | ||
var result = null; | ||
var start = new Date().getTime() | ||
, ts = 0; | ||
request(opts, function(e,r,d){ | ||
result = d; | ||
ts = new Date().getTime() - start; | ||
return fn(result); | ||
}); | ||
} | ||
exports.readJsonCfgFromUrl = readJsonCfgFromUrl; |
@@ -10,2 +10,6 @@ var exports = module.exports; | ||
exports.sqlutil = require('./sqlutil'); | ||
exports.xml2json = require('./git/xml2json'); | ||
//From: https://github.com/buglabs/node-xml2json | ||
//Modify the trim function for break line parse | ||
exports.json2table = require('./git/json-to-table'); | ||
@@ -12,0 +16,0 @@ String.prototype.endsWith = function (s) { |
@@ -1,9 +0,25 @@ | ||
var nodemailer = require("nodemailer"); | ||
var os = require('os'); | ||
var fs = require('fs'); | ||
var util = require('util'); | ||
var cfg = null; | ||
var nodemailer = require("nodemailer") | ||
, log = require('./logger').getInstance() | ||
, os = require('os') | ||
, fs = require('fs') | ||
, cfg = null | ||
, smtpOption = {} | ||
, smtpTransport = null | ||
, cfg_path = process.env.HOME + '/.nmail'; | ||
var mailutil = exports; | ||
exports.init = function(json){ | ||
if(json) { | ||
log.debug('Setting the cfg using json...' ); | ||
log.debug(json); | ||
cfg = json; | ||
log.debug('Confirm cfg:'); | ||
log.debug(cfg); | ||
smtpOption = json.smtpOptions; | ||
} | ||
initial(); | ||
} | ||
/* node.js v0.6.x still no fs.existsSync() */ | ||
@@ -17,33 +33,34 @@ function isCfgExists() { | ||
} | ||
//node 0.8.x | ||
//return fs.existsSync(cfg_path); | ||
} | ||
var cfg_path = process.env.HOME + '/.nmail'; | ||
if(isCfgExists()) { | ||
cfg = require('../lib/cfgutil').readJsonCfg(process.env.HOME + '/.nmail'); | ||
} else { | ||
cfg = {smtpOptions:{host : "localhost"}}; | ||
} | ||
var smtpOption = cfg.smtpOptions; | ||
mailutil.smtpOption = smtpOption; | ||
function initial(){ | ||
if(!cfg || cfg == null) | ||
if(isCfgExists()) { | ||
cfg = require('../lib/cfgutil').readJsonCfg(process.env.HOME + '/.nmail'); | ||
} else { | ||
cfg = {smtpOptions:{host : "localhost"}}; | ||
} | ||
smtpOption = cfg.smtpOptions; | ||
smtpTransport = nodemailer.createTransport("SMTP", smtpOption); | ||
mailutil.smtpOption = smtpOption; | ||
/** | ||
* SMTP transport object | ||
*/ | ||
var smtpTransport = nodemailer.createTransport("SMTP", smtpOption); | ||
/** | ||
* SMTP transport object | ||
*/ | ||
smtpTransport = nodemailer.createTransport("SMTP", smtpOption); | ||
/** | ||
* To set the SMTP transport using option | ||
*/ | ||
mailutil.setSmtpTransUsingOption = function(opt){ | ||
smtpTransport = nodemailer.createTransport("SMTP", opt); | ||
}; | ||
/** | ||
* To set the SMTP transport using option | ||
*/ | ||
mailutil.setSmtpTransUsingOption = function(opt){ | ||
smtpTransport = nodemailer.createTransport("SMTP", opt); | ||
}; | ||
/** | ||
* To reset the SMTP transport using the last smtpOption | ||
*/ | ||
mailutil.resetSmtpTrans = function() { | ||
smtpTransport = nodemailer.createTransport("SMTP", this.smtpOption); | ||
}; | ||
/** | ||
* To reset the SMTP transport using the last smtpOption | ||
*/ | ||
mailutil.resetSmtpTrans = function() { | ||
smtpTransport = nodemailer.createTransport("SMTP", this.smtpOption); | ||
}; | ||
} | ||
@@ -73,9 +90,9 @@ /** | ||
mailOptions.html = msg; | ||
util.log(util.format('[INFO]Using smtpOption:%s', JSON.stringify(smtpOption))); | ||
util.log(util.format('[INFO]Using mailOptions:%s', JSON.stringify(mailOptions))); | ||
log.debug('[INFO]Using smtpOption:%s', JSON.stringify(smtpOption)); | ||
log.debug('[INFO]Using mailOptions:%s', JSON.stringify(mailOptions)); | ||
smtpTransport.sendMail(mailOptions, function(error, response){ | ||
if(error){ | ||
console.log('[ERROR]%s',JSON.stringify(error)); | ||
log.error('[ERROR]%s',JSON.stringify(error)); | ||
} else { | ||
util.log(util.format("Message sent: " + response.message)); | ||
log.debug("Message sent: " + response.message); | ||
} | ||
@@ -82,0 +99,0 @@ if(isClose) |
{ | ||
"name": "nodeutil", | ||
"description": "Node.js Utility", | ||
"version": "0.0.14", | ||
"version": "0.0.16", | ||
"author": { | ||
@@ -17,2 +17,4 @@ "name": "Simon Su", | ||
"nodemailer": "*", | ||
"node-expat": "*", | ||
"request": "*", | ||
"log4js": "*" | ||
@@ -37,3 +39,3 @@ }, | ||
}, | ||
"_id": "nodeutil@0.0.1", | ||
"_id": "nodeutil@0.0.16", | ||
"optionalDependencies": {}, | ||
@@ -40,0 +42,0 @@ "_engineSupported": true, |
NodeUtil | ||
==================== | ||
<h2>Usage</h2> | ||
This is just a tool collect for easy use of some tool library. I will pack some operation for more easy to use. | ||
## Install | ||
<pre> | ||
npm install nodeutil | ||
</pre> | ||
## Usage | ||
<pre> | ||
var nu = require('nodeutil'); | ||
</pre> | ||
//Using logger | ||
## Using logger | ||
<pre> | ||
var log = nu.logger.getInstance(); | ||
log.info('Test logger...'); | ||
</pre> | ||
//Using dateutil | ||
## Using dateutil | ||
<pre> | ||
var dateutil = no.dateutil; | ||
@@ -18,4 +32,7 @@ var pattern = 'yyyymmdd hh24:mi:ss'; | ||
dateutil.getDateString(new Date(), pattern) | ||
</pre> | ||
//Using step | ||
## Using step | ||
<pre> | ||
var Step = nu.step; | ||
@@ -33,4 +50,10 @@ Step( | ||
) | ||
</pre> | ||
## Using cfgutil | ||
<pre> | ||
var cfgutil = nu.cfgutil; | ||
//read from json file | ||
var cfg = cfgutil.readJsonCfg('path to json config file'); | ||
</pre> | ||
Wildcard dependency
QualityPackage has a dependency with a floating version range. This can cause issues if the dependency publishes a new major version.
Found 2 instances in 1 package
33355
16
892
58
4
5
15
+ Addednode-expat@*
+ Addedrequest@*
+ Addedajv@6.12.6(transitive)
+ Addedasn1@0.2.6(transitive)
+ Addedassert-plus@1.0.0(transitive)
+ Addedasynckit@0.4.0(transitive)
+ Addedaws-sign2@0.7.0(transitive)
+ Addedaws4@1.13.2(transitive)
+ Addedbcrypt-pbkdf@1.0.2(transitive)
+ Addedbindings@1.5.0(transitive)
+ Addedcaseless@0.12.0(transitive)
+ Addedcombined-stream@1.0.8(transitive)
+ Addedcore-util-is@1.0.2(transitive)
+ Addeddashdash@1.14.1(transitive)
+ Addeddelayed-stream@1.0.0(transitive)
+ Addedecc-jsbn@0.1.2(transitive)
+ Addedextend@3.0.2(transitive)
+ Addedextsprintf@1.3.0(transitive)
+ Addedfast-deep-equal@3.1.3(transitive)
+ Addedfast-json-stable-stringify@2.1.0(transitive)
+ Addedfile-uri-to-path@1.0.0(transitive)
+ Addedforever-agent@0.6.1(transitive)
+ Addedform-data@2.3.3(transitive)
+ Addedgetpass@0.1.7(transitive)
+ Addedhar-schema@2.0.0(transitive)
+ Addedhar-validator@5.1.5(transitive)
+ Addedhttp-signature@1.2.0(transitive)
+ Addedis-typedarray@1.0.0(transitive)
+ Addedisstream@0.1.2(transitive)
+ Addedjsbn@0.1.1(transitive)
+ Addedjson-schema@0.4.0(transitive)
+ Addedjson-schema-traverse@0.4.1(transitive)
+ Addedjson-stringify-safe@5.0.1(transitive)
+ Addedjsprim@1.4.2(transitive)
+ Addedmime-db@1.52.0(transitive)
+ Addedmime-types@2.1.35(transitive)
+ Addednan@2.22.0(transitive)
+ Addednode-expat@2.4.1(transitive)
+ Addedoauth-sign@0.9.0(transitive)
+ Addedperformance-now@2.1.0(transitive)
+ Addedpsl@1.10.0(transitive)
+ Addedpunycode@2.3.1(transitive)
+ Addedqs@6.5.3(transitive)
+ Addedrequest@2.88.2(transitive)
+ Addedsafe-buffer@5.2.1(transitive)
+ Addedsafer-buffer@2.1.2(transitive)
+ Addedsshpk@1.18.0(transitive)
+ Addedtough-cookie@2.5.0(transitive)
+ Addedtunnel-agent@0.6.0(transitive)
+ Addedtweetnacl@0.14.5(transitive)
+ Addeduri-js@4.4.1(transitive)
+ Addeduuid@3.4.0(transitive)
+ Addedverror@1.10.0(transitive)