New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

fis-project-analyzer

Package Overview
Dependencies
Maintainers
1
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fis-project-analyzer - npm Package Compare versions

Comparing version 0.0.12 to 0.0.13

out.log

51

lib/pageAnalyzer.js

@@ -9,8 +9,2 @@ /*

/**
*
* @param project projectLoader
* @returns {{getDeps: getDeps}}
*/
var fis = require('fis-kernel');

@@ -34,3 +28,4 @@ var fs = require('fs');

function getStaticResource(pageConf){
var deps = getDeps(pageConf);
var deps = getRecursiveDeps(pageConf);
var analyzeCache = {};
var staticSyncPool = [];

@@ -62,6 +57,16 @@ var staticAsyncPool = [];

function getStaticDepsFromMapJson(id){
if (!analyzeCache[id])
analyzeCache[id] = true;
else
return {sync:[],async:[]};
fis.log.debug('analyze resource deps ['+id+']');
var conf = project.getResource(id);
//check if conf is exist
if (!conf)
return {sync:[],async:[]};
var sync = conf.deps || [];
var async = [];
conf.extras && conf.extras.async && (async = conf.extras.async);
if (conf.extras && conf.extras.async){
async = conf.extras.async;
}
sync.forEach(function(dep){

@@ -90,6 +95,8 @@ var deps = getStaticDepsFromMapJson(dep);

deps.async.forEach(function(async){
pkg.async.push(getResourceUri(async));
var uri = getResourceUri(async);
uri && pkg.async.push(uri);
});
deps.sync.forEach(function(sync){
pkg.sync.push(getResourceUri(sync));
var uri = getResourceUri(sync);
uri && pkg.sync.push(uri);
});

@@ -103,2 +110,4 @@ return {

var resource = project.getResource(id);
if (!resource)
return false;
assert.notEqual(resource,null);

@@ -118,5 +127,5 @@ var uri = resource.uri;

*/
function getDeps(pageConf){
function getRecursiveDeps(pageConf){
fis.log.debug('analyze tpl [' + (pageConf.id || pageConf) + ']');
var result = analyzeTpl(pageConf);
var result = getCurrentDeps(pageConf);
//fix for-loop length to prevent recall new widget analyze

@@ -126,3 +135,3 @@ for (var i= 0, length = result['widget'].length; i < length; i++){

fis.log.debug('call widget tpl [' + widget + '] analyze from [' + (pageConf.id || pageConf) + ']');
var widgetModule = getDeps(widget);
var widgetModule = getRecursiveDeps(widget);
arrayMerge(result['widget'], widgetModule['widget']);

@@ -133,3 +142,3 @@ arrayMerge(result['require'], widgetModule['require']);

fis.log.debug('call extends tpl [' + page + '] analyze from [' + (pageConf.id || pageConf) + ']');
var pageModule = getDeps(page);
var pageModule = getRecursiveDeps(page);
arrayMerge(result['widget'], pageModule['widget']);

@@ -155,3 +164,3 @@ arrayMerge(result['require'], pageModule['require']);

*/
function analyzeTpl(page){
function getCurrentDeps(page){
var pageConf = page;

@@ -174,3 +183,3 @@ if (typeof page == 'string')

var data = fs.readFileSync(path);
donePage[path] = analyzeTplByContent(data, pageConf.id);
donePage[path] = getCurrentDepsByContent(data, pageConf.id);
workingPage[path] = null;

@@ -189,3 +198,3 @@ return donePage[path];

*/
function analyzeTplByContent(content, exclude){
function getCurrentDepsByContent(content, exclude){
if (exclude instanceof Array == false){

@@ -203,3 +212,3 @@ exclude = [exclude||""];

//format extends path
if (tag == 'extends'){
if (tag === 'extends'){
//extends file need trans to resource id

@@ -232,5 +241,5 @@ id = id.replace(pagePathReg, function(input, namespace, path, file){

return {
getDeps:getDeps,
analyzeTpl:analyzeTpl,
analyzeTplByContent:analyzeTplByContent,
getRecursiveDeps:getRecursiveDeps,
getCurrentDeps:getCurrentDeps,
getCurrentDepsByContent:getCurrentDepsByContent,
getStaticResource:getStaticResource,

@@ -237,0 +246,0 @@ getStaticResourcePkg:getStaticResourcePkg

@@ -42,2 +42,3 @@ /*

var fileName = fileMatch[1];
fis.log.debug('read conf from ['+file+']');
var moduleConf = fis.util.readJSON(file);

@@ -96,5 +97,5 @@ var res = moduleConf['res'];

getPackage:getPackage
}
};
};
module.exports = projectLoader;
{
"name": "fis-project-analyzer",
"version": "0.0.12",
"version": "0.0.13",
"main": "index.js",

@@ -5,0 +5,0 @@ "description": "A tool to analyze fis-plus project deps",

@@ -7,2 +7,3 @@ fis-project-analyzer

[![Build Status](https://travis-ci.org/hefangshi/fis-project-analyzer.svg?branch=master)](https://travis-ci.org/hefangshi/fis-project-analyzer)
[![Code Climate](https://codeclimate.com/github/hefangshi/fis-project-analyzer.png)](https://codeclimate.com/github/hefangshi/fis-project-analyzer)

@@ -12,5 +13,5 @@ ## Usage

```javascript
var analyzer = require('fis-project-analyzer');
var PageAnalyzer = analyzer.PageAnalyzer;
var ProjectLoader = analyzer.ProjectLoader;
var analyzerlib = require('fis-project-analyzer');
var PageAnalyzer = analyzerlib.PageAnalyzer;
var ProjectLoader = analyzerlib.ProjectLoader;
var projectPath = __dirname + "/../testProject";

@@ -23,5 +24,5 @@ //set project path for analyzer

//get tpl deps from smarty
var result = analyzer.analyzeTpl(page);
var result = analyzer.getCurrentDeps(page);
//get page deps from smarty recursivly
result = analyzer.getDeps(page);
result = analyzer.getRecursiveDeps(page);
//get static resource

@@ -28,0 +29,0 @@ result = analyzer.getStaticResource(page);

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