New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.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

to
0.0.9

2

core/logAnalyzer.js

@@ -1,2 +0,2 @@

//todo : 后续升级为每天定时下载分析数据
//todo : 添加脚本定期从log平台抓取数据、按照fisid切分开发,存贮到app目录中

@@ -3,0 +3,0 @@ var Record = require("./record.js"),

@@ -26,3 +26,3 @@

*/
function createPackConf(resources, outputDir, moduels, projectName){
function createPackConf(resources, sourceDir, outputDir, moduels, projectName){
var packResults = {};

@@ -41,11 +41,13 @@

util.map(packages, function(index, pkgFile){
var files = pkgFile.get("mergedStatic"),
packageKey = "pkg/" + packageKeyPrefix + "_" + index + "." + type;
//对于自定义包 : 使用用户原生配置不再自动生成,可以保证自定义包的顺序
if(pkgFile.get("packageType") != "manual"){
var files = pkgFile.get("mergedStatic"),
packageKey = "pkg/" + packageKeyPrefix + "_" + index + "." + type;
packResults[module][packageKey] = [];
packResults[module][packageKey] = [];
util.map(files, function(index, file){
packResults[module][packageKey].push(file.replace(/\w+:/, "/"));
});
util.map(files, function(index, file){
packResults[module][packageKey].push(file.replace(/\w+:/, "/"));
});
}
});

@@ -56,2 +58,9 @@ }

util.map(packResults, function(module, packResult){
var autopackJson = sourceDir + "/auto-pack/" + module + "-autopack.json";
if(util.exists(autopackJson)){
//因为自动打包里面已经排除了所有的manual文件,所以它的先后顺序不影响打包结果
var conf = util.readJSON(autopackJson),
packConf = conf["pack"];
packResult = util.merge(packConf, packResult);
}
var packStr = JsonUtil.convertToString(packResult),

@@ -68,11 +77,12 @@ fileName = module + "/fis-pack.json";

/**
* @param dir : 编译后的项目目录
* @param sourceDir : 编译后的项目目录
* @param outputDir : 打包结果产出目录
* @param projectName : 项目名称
* @param modules : 所有需要计算打包的模块名
* @param staticType : staticTypes 需要打包的静态资源 数组 如js、css
* @param logUrl : 获取log日志的url
* @param callback : callback(error, result)
*/
module.exports.package = function(dir, outputDir, projectName, modules, logUrl, callback){
resources = codeAnalyzer.getResource(dir, hashTable, defaultPackages);
module.exports.package = function(sourceDir, outputDir, projectName, modules, staticType, logUrl, callback){
resources = codeAnalyzer.getResource(sourceDir, hashTable, defaultPackages);
logAnalyzer.analyzeLog(function(error, records){

@@ -107,5 +117,6 @@ if(error){

var staticUrlMapFile = packageReport.createStaticUrlMap(resources, records, outputDir, projectName);
var packageResults = packager.package(resources, defaultPackages);
//资源过滤需要在打包阶段来做,getResource阶段需要拿到完整的列表分析文件间的依赖关系
var packageResults = packager.package(resources, staticType, defaultPackages);
var predictPackageResultFile = packageReport.predictPackageResult(records, packageResults, outputDir, projectName);
var resultFile = createPackConf(packageResults, outputDir, modules, projectName);
var resultFile = createPackConf(packageResults, sourceDir, outputDir, modules, projectName);
resultFiles = {

@@ -112,0 +123,0 @@ "urlPv" : urlPvFile,

//todo : 是否需要产出收益分析文档报表
//todo : 打出每个包被使用的次数
var util = require("./util.js");

@@ -3,0 +4,0 @@

{
"name": "fis-auto-packager",
"version": "0.0.6",
"version": "0.0.9",
"description": "fis-auto-packager",

@@ -5,0 +5,0 @@ "main": "fis-auto-packager.js",

@@ -16,6 +16,13 @@ /**

module.exports.package = function(resources, defaultPackages){
/**
*
* @param resources
* @param staticTypes 需要打包的静态资源 数组 如js、css
* @param defaultPackages
* @returns {{}}
*/
module.exports.package = function(resources, staticTypes, defaultPackages){
log.debug(" start [package]");
var manualResult = mergeDefaultPackage(resources, defaultPackages);
var newResources = partResources(resources),
var newResources = partAndFilterResources(resources, staticTypes),
autoResult = {};

@@ -119,3 +126,9 @@

function partResources(resources){
/**
* 对静态资源进行分类,过滤不需要打包的数据
* @param resources
* @param staticTypes 需要打包的静态资源 数组 如js、css
* @returns {{}}
*/
function partAndFilterResources(resources, staticTypes){
var newResources = {};

@@ -125,3 +138,3 @@ for(var id in resources){

//排除掉非 js和css的文件
if(resources.hasOwnProperty(id) && resource.get("module") && (resource.get("type") == "js" || resource.get("type") == "css")){
if(resources.hasOwnProperty(id) && resource.get("module") && util.in_array(resource.get("type"), staticTypes)){
if(resource.get("loadType") == ""){

@@ -128,0 +141,0 @@ resource.setLoadType("sync");