Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

fis-auto-packager

Package Overview
Dependencies
Maintainers
2
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fis-auto-packager - npm Package Compare versions

Comparing version 0.0.5 to 0.0.6

6

core/codeAnalyzer.js
var File = require("./file.js"),
util = require("../lib/util.js"),
log = require("../lib/log.js"),
gzip = require('gzip-js'),

@@ -92,2 +93,3 @@ fs = require("fs");

module.exports.getResource = function(dir, hashTable, defaultPackages){
log.debug(" start [getResource] " + dir);
var configDir = dir + "/config",

@@ -152,2 +154,3 @@ autopackDir = dir + "/auto-pack";

}
log.debug(" end [getResource] " + dir);
return files;

@@ -179,4 +182,3 @@ }

}else{
//fis.log.warning('invalid pack config [' + path + ']');
//todo : error 处理
log.error('invalid pack config [' + path + ']');
}

@@ -183,0 +185,0 @@ });

@@ -5,2 +5,3 @@ //todo : 后续升级为每天定时下载分析数据

util = require("../lib/util.js"),
log = require("../lib/log.js"),
request = require("request"),

@@ -98,2 +99,3 @@ fs = require("fs");

module.exports.analyzeLog = function(callback, url, hashTable){
log.debug(" start [analyzeLog] " + url);
var logUrlPrefix = "http://logdata.baidu.com/?m=Data&a=GetData&token=ns_j0vmor9lig2czsfdk78ueqbh3yapw&product=ns&item=Fis_Static_Count&date=",

@@ -110,2 +112,3 @@ logTime = miniteDate(7),

var records = processLogData(body, hashTable);
log.debug(" end [analyzeLog] " + url);
callback(null, records);

@@ -112,0 +115,0 @@ }

@@ -7,2 +7,3 @@

util = require("./lib/util.js"),
log = require("./lib/log.js"),
JsonUtil = require("./lib/jsonUtil.js"),

@@ -78,35 +79,39 @@ fs = require("fs"),

}else{
var urlPvFile = packageReport.printUrlPvs(records, outputDir, projectName);
for(var i=0; i<records.length; i++){
var record = records[i],
syncStatics = record.get("sync"),
asyncStatics = record.get("async");
for(var j=0; j<syncStatics.length; j++){
var resource = resources[syncStatics[j]];
if(resource){
resource.addPage(record.get("hash"), record.get("pv"));
resource.addPv(record.get("pv"));
//todo : 目前策略是优先考虑sync,是否需要改成根据sync和async的pv判断应该为哪一种类型?
resource.setLoadType("sync");
var resultFiles = null;
try{
var urlPvFile = packageReport.printUrlPvs(records, outputDir, projectName);
for(var i=0; i<records.length; i++){
var record = records[i],
syncStatics = record.get("sync"),
asyncStatics = record.get("async");
for(var j=0; j<syncStatics.length; j++){
var resource = resources[syncStatics[j]];
if(resource){
resource.addPage(record.get("hash"), record.get("pv"));
resource.addPv(record.get("pv"));
//todo : 目前策略是优先考虑sync,是否需要改成根据sync和async的pv判断应该为哪一种类型?
resource.setLoadType("sync");
}
}
}
for(var k=0; j<asyncStatics.length; k++){
var resource = resources[asyncStatics[k]];
if(resource){
resource.addPv(record.get("pv"));
resource.setLoadType("async");
for(var k=0; j<asyncStatics.length; k++){
var resource = resources[asyncStatics[k]];
if(resource){
resource.addPv(record.get("pv"));
resource.setLoadType("async");
}
}
}
var staticUrlMapFile = packageReport.createStaticUrlMap(resources, records, outputDir, projectName);
var packageResults = packager.package(resources, defaultPackages);
var predictPackageResultFile = packageReport.predictPackageResult(records, packageResults, outputDir, projectName);
var resultFile = createPackConf(packageResults, outputDir, modules, projectName);
resultFiles = {
"urlPv" : urlPvFile,
"staticUrlMap" : staticUrlMapFile,
"packagePredict" : predictPackageResultFile,
"packageConf" : resultFile
}
}catch(error){
callback(error, null);
}
var staticUrlMapFile = packageReport.createStaticUrlMap(resources, records, outputDir, projectName);
var packageResults = packager.package(resources, defaultPackages);
var predictPackageResultFile = packageReport.predictPackageResult(records, packageResults, outputDir, projectName);
var resultFile = createPackConf(packageResults, outputDir, modules, projectName);
var resultFiles = {
"urlPv" : urlPvFile,
"staticUrlMap" : staticUrlMapFile,
"packagePredict" : predictPackageResultFile,
"packageConf" : resultFile
}
callback(null, resultFiles);

@@ -113,0 +118,0 @@ }

@@ -0,8 +1,36 @@

var util = require("./util.js"),
date = new Date(),
day = date.getYear().toString() + date.getMonth().toString() + date.getDate().toString(),
errorLog = __dirname + "/../log/error." + day + ".log",
noticeLog = __dirname + "/../log/notice." + day + ".log",
debugLog = __dirname + "/../log/debug." + day + ".log";
module.exports.debug = function(str, level){
function now(withoutMilliseconds){
var d = new Date(), str;
str = [
d.getHours(),
d.getMinutes(),
d.getSeconds()
].join(':').replace(/\b\d\b/g, '0$&');
if(!withoutMilliseconds){
str += '.' + ('00' + d.getMilliseconds()).substr(-4);
}
return str;
};
module.exports.error = function(error){
if(!(error instanceof Error)){
error = new Error(error.msg || error);
}
util.write(errorLog, now() + error.stack + "\n", "utf-8", true);
throw error;
}
module.exports.debug = function(msg, level){
var tab = "";
for(var i=1; i<level; i++){
for(var i=0; i<level; i++){
tab += "\t";
}
console.log(tab + str);
console.log(tab + now() + msg + "\n");
util.write(debugLog, tab + now() + msg + "\n", "utf-8", true);
}
{
"name": "fis-auto-packager",
"version": "0.0.5",
"version": "0.0.6",
"description": "fis-auto-packager",

@@ -9,3 +9,4 @@ "main": "fis-auto-packager.js",

"adm-zip" : "*",
"gzip-js" : "*"
"gzip-js" : "*",
"iconv-lite" : "*"
},

@@ -12,0 +13,0 @@ "scripts": {

@@ -9,3 +9,4 @@ /**

File = require("../core/file.js"),
util = require("../lib/util.js");
util = require("../lib/util.js"),
log = require("../lib/log.js");

@@ -17,3 +18,3 @@ var RTT = 2, //round trip time 不能包含建立tcp链接的时间,因为http 1.1都是用了 keep-alive 没有tcp建立的开销

module.exports.package = function(resources, defaultPackages){
log.debug(" start [package]");
var manualResult = mergeDefaultPackage(resources, defaultPackages);

@@ -27,2 +28,3 @@ var newResources = partResources(resources),

util.map(newResources, function(packageKey, partResource){
log.debug(" start package key [" + packageKey + "]", 1);
var packageResult = [];

@@ -34,4 +36,6 @@ if(partResource.length >= 2){

}
log.debug(" end package key [" + packageKey + "]", 1);
});
util.merge(autoResult, manualResult);
log.debug(" end [package]");
return autoResult;

@@ -215,6 +219,5 @@ }

});
//todo : 记录打包的过程
if(staticA.get("module") == "common" && staticA.get("type") == "js" && largestResource != null){
console.log(staticA.get("id") + " and " + largestResource.get("id") + " merged benefit is = " + largestBenefit);
}
if(largestResource != null){
log.debug(" [largestBenefit] " + staticA.get("id") + " and " + largestResource.get("id") + " merged benefit is = " + largestBenefit, 2);
}
return {

@@ -221,0 +224,0 @@ "benefit" : largestBenefit,

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc