flex-combo
Advanced tools
Comparing version 0.10.8 to 0.11.0
35
api.js
@@ -6,7 +6,8 @@ var urlLib = require("url"); | ||
var async = require("async"); | ||
var mkdirp = require("mkdirp"); | ||
var merge = require("merge"); | ||
var Helper = require("./lib/util"); | ||
var DAC = require("dac"); | ||
var isUtf8 = DAC.isUtf8; | ||
var iconv = DAC.iconv; | ||
var Helper = require("./lib/util"); | ||
var ALProtocol = { | ||
@@ -17,2 +18,4 @@ "http:": require("http"), | ||
var ENGINES = []; | ||
function FlexCombo(param, confFile) { | ||
@@ -24,6 +27,6 @@ this.HOST = null; | ||
this.res = null; | ||
this.engines = FlexCombo.prototype.engines.map(function(i) { | ||
this.engines = ENGINES.map(function(i) { | ||
return i; | ||
}); | ||
this.param = Helper.clone(require("./lib/param")); | ||
this.param = merge(true, require("./lib/param")); | ||
this.query = {}; | ||
@@ -42,10 +45,10 @@ this.cacheDir = pathLib.join(process.cwd(), ".cache"); | ||
} | ||
this.param = Helper.merge(true, this.param, confJSON, param || {}); | ||
this.param = merge.recursive(true, this.param, confJSON, param || {}); | ||
if (confJSON.filter || param.filter) { | ||
this.param.filter = Helper.merge(confJSON.filter || {}, param.filter || {}); | ||
this.param.filter = merge(confJSON.filter || {}, param.filter || {}); | ||
} | ||
} | ||
else { | ||
this.param = Helper.merge(true, this.param, param || {}); | ||
this.param = merge.recursive(true, this.param, param || {}); | ||
} | ||
@@ -58,3 +61,3 @@ | ||
if (this.param.cache && !fsLib.existsSync(this.cacheDir)) { | ||
Helper.mkdirPSync(this.cacheDir); | ||
mkdirp.sync(this.cacheDir); | ||
fsLib.chmod(this.cacheDir, 0777); | ||
@@ -88,6 +91,5 @@ } | ||
}, | ||
engines: [], | ||
addEngine: function (rule, func, p, inner) { | ||
if (rule && typeof func == "function") { | ||
(inner ? this.engines : FlexCombo.prototype.engines).push({ | ||
(inner ? this.engines : ENGINES).push({ | ||
rule: rule, | ||
@@ -103,3 +105,3 @@ func: func, | ||
this.query = Helper.merge(true, this.query, req.query || {}); | ||
this.query = merge.recursive(true, this.query, req.query || {}); | ||
@@ -182,3 +184,3 @@ this.HOST = (req.protocol || "http") + "://" + (req.hostname || req.host || req.headers.host); | ||
var protocol = (this.req.protocol || "https") + ':'; | ||
var protocol = (this.req.protocol || "http") + ':'; | ||
var H = this.req.headers.host.split(':'); | ||
@@ -204,6 +206,7 @@ var reqPort = H[1] || (protocol == "https:" ? 443 : 80); | ||
"x-broker": "flex-combo", | ||
host: reqHostName | ||
host: reqHostName, | ||
cookie: this.req.headers.cookie | ||
} | ||
}; | ||
requestOption.headers = Helper.merge(true, this.param.headers, requestOption.headers); | ||
requestOption.headers = merge.recursive(true, this.param.headers || {}, requestOption.headers); | ||
@@ -227,5 +230,5 @@ return requestOption; | ||
var engine = this.engines[matchedIndex]; | ||
this.query = Helper.merge(true, this.query, this.param[engine.path] || {}); | ||
this.query = merge.recursive(true, this.query, this.param[engine.path] || {}); | ||
engine.func(absPath, filteredURL, this.query, function (e, result, realPath, MIME) { | ||
engine.func(absPath, this.buildRequestOption(filteredURL), this.query, function (e, result, realPath, MIME) { | ||
if (!e) { | ||
@@ -232,0 +235,0 @@ this.MIME = MIME; |
20
index.js
@@ -9,8 +9,16 @@ /** | ||
var fsLib = require("fs"); | ||
var Helper = require("./lib/util"); | ||
var mkdirp = require("mkdirp"); | ||
try { | ||
var updateNotifier = require("update-notifier"); | ||
var pkg = require(__dirname + "/package.json"); | ||
updateNotifier({pkg: pkg}).notify(); | ||
require("check-update")({ | ||
packageName: pkg.name, | ||
packageVersion: pkg.version, | ||
isCLI: process.title == "node" | ||
}, function (err, latestVersion, defaultMessage) { | ||
if (!err && pkg.version < latestVersion) { | ||
console.log(defaultMessage); | ||
} | ||
}); | ||
} | ||
@@ -23,4 +31,4 @@ catch (e) { | ||
fcInst.addEngine("\\.tpl\\.js$", DAC.tpl, "dac/tpl"); | ||
fcInst.addEngine("\\.html\\.js$", function (htmlfile, _url, param, cb) { | ||
DAC.tpl(htmlfile, _url, param, function (err, result, filepath, MIME) { | ||
fcInst.addEngine("\\.html\\.js$", function (htmlfile, reqOpt, param, cb) { | ||
DAC.tpl(htmlfile, reqOpt, param, function (err, result, filepath, MIME) { | ||
if (typeof result != "undefined") { | ||
@@ -48,3 +56,3 @@ var fs = require("fs"); | ||
if (!fsLib.existsSync(confDir)) { | ||
Helper.mkdirPSync(confDir); | ||
mkdirp.sync(confDir); | ||
fsLib.chmod(confDir, 0777); | ||
@@ -51,0 +59,0 @@ } |
var fsLib = require("fs"); | ||
var pathLib = require("path"); | ||
var crypto = require("crypto"); | ||
var utilLib = require("mace")(module); | ||
var DAC = require("dac"); | ||
@@ -9,2 +8,5 @@ var isUtf8 = DAC.isUtf8; | ||
var utilLib = require("mace")(module); | ||
var merge = require("merge"); | ||
/* 读取文件并返回Unicode编码的字符串,以便在Node.js环境下进行文本处理 */ | ||
@@ -73,7 +75,4 @@ exports.getUnicode = function (filePath) { | ||
exports.merge = utilLib.merge; | ||
exports.mkdirPSync = utilLib.mkdirPSync; | ||
exports.clone = utilLib.clone; | ||
exports.MD5 = function (str) { | ||
return crypto.createHash("md5").update(str).digest('hex'); | ||
return crypto.createHash("md5").update(str).digest("hex"); | ||
}; | ||
@@ -154,3 +153,3 @@ | ||
remote: function (url, opt) { | ||
opt = utilLib.merge(true, { | ||
opt = merge.recursive(true, { | ||
protocol: "http:", | ||
@@ -157,0 +156,0 @@ host: "127.0.0.1", |
{ | ||
"name": "flex-combo", | ||
"version": "0.10.8", | ||
"version": "0.11.0", | ||
"description": "A combo tool designed for web front-end developer, which support various kinds of combo format by modify configuration(eg. yahoo combo).", | ||
@@ -11,8 +11,10 @@ "main": "index.js", | ||
"async": "~0.9.0", | ||
"check-update": "~0.0.7", | ||
"commander": "~2.5.0", | ||
"dac": "~0.4.1", | ||
"dac": "~0.5.1", | ||
"mace": "~2.0.0", | ||
"merge": "~1.2.0", | ||
"mime": "~1.3.4", | ||
"through2": "~0.6.3", | ||
"update-notifier": "~0.3.1" | ||
"mkdirp": "~0.5.0", | ||
"through2": "~0.6.5" | ||
}, | ||
@@ -19,0 +21,0 @@ "repository": { |
Sorry, the diff of this file is not supported yet
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
51570
700
9
+ Addedcheck-update@~0.0.7
+ Addedmerge@~1.2.0
+ Addedmkdirp@~0.5.0
+ Addedcheck-update@0.0.8(transitive)
+ Addedcolors@1.4.0(transitive)
+ Addeddac@0.5.10(transitive)
+ Addeddeep-extend@0.2.11(transitive)
+ Addedgot@2.9.2(transitive)
+ Addedless@2.5.3(transitive)
+ Addedmerge@1.2.1(transitive)
+ Addedminimist@0.0.10(transitive)
+ Addedrc@0.5.5(transitive)
+ Addedread-all-stream@2.2.0(transitive)
+ Addedsource-map@0.4.4(transitive)
+ Addedstatuses@1.5.0(transitive)
+ Addedstrip-json-comments@0.1.3(transitive)
- Removedupdate-notifier@~0.3.1
- Removedansi-regex@2.1.1(transitive)
- Removedansi-styles@2.2.1(transitive)
- Removedargparse@1.0.10(transitive)
- Removedchalk@1.1.3(transitive)
- Removedconfigstore@0.3.2(transitive)
- Removeddac@0.4.1(transitive)
- Removeddeep-extend@0.6.0(transitive)
- Removedescape-string-regexp@1.0.5(transitive)
- Removedesprima@4.0.1(transitive)
- Removedgot@3.3.1(transitive)
- Removedhas-ansi@2.0.0(transitive)
- Removedis-npm@1.0.0(transitive)
- Removedis-redirect@1.0.0(transitive)
- Removedjs-yaml@3.14.1(transitive)
- Removedlatest-version@1.0.1(transitive)
- Removedless@2.4.0(transitive)
- Removedobject-assign@3.0.0(transitive)
- Removedos-homedir@1.0.2(transitive)
- Removedos-tmpdir@1.0.2(transitive)
- Removedosenv@0.1.5(transitive)
- Removedpackage-json@1.2.0(transitive)
- Removedpinkie@2.0.4(transitive)
- Removedpinkie-promise@2.0.1(transitive)
- Removedrc@1.2.8(transitive)
- Removedread-all-stream@3.1.0(transitive)
- Removedregistry-url@3.1.0(transitive)
- Removedsafe-buffer@5.2.1(transitive)
- Removedsemver@5.7.2(transitive)
- Removedsemver-diff@2.1.0(transitive)
- Removedsource-map@0.2.0(transitive)
- Removedsprintf-js@1.0.3(transitive)
- Removedstring-length@1.0.1(transitive)
- Removedstrip-ansi@3.0.1(transitive)
- Removedstrip-json-comments@2.0.1(transitive)
- Removedsupports-color@2.0.0(transitive)
- Removedupdate-notifier@0.3.2(transitive)
- Removeduser-home@1.1.1(transitive)
- Removeduuid@2.0.3(transitive)
- Removedxdg-basedir@1.0.1(transitive)
Updateddac@~0.5.1
Updatedthrough2@~0.6.5