Socket
Socket
Sign inDemoInstall

react-dependence-analyze

Package Overview
Dependencies
0
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    react-dependence-analyze

reactjs project tool


Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Install size
74.1 kB
Created
Weekly downloads
 

Readme

Source

react-dependence-analyze Build Status npm version

只支持 import 依赖的解析,赞不支持 require

使用说明

FileUtils

  • 实例属性
    • allFiles 显示所有文件
  • 实例方法
    • constructor(options)
      • options.baseDir string 工程路径(默认:'./')
      • options.ext string[] 解析的文件后缀(默认:['.jsx', '.js'])
      • options.blackList RegExp[] 用文件绝对路径名过滤,不包含在分析中
      • options.whiteList RegExp[] 用文件绝对路径名过滤,包含在分析中(whiteList 存在则无视 blackList)
      • options.ignoreModule string[] 忽略分析的模块(默认:['react', 'react-router', 'react-dom', 'antd', 'moment', 'lodash', 'classnames', 'babel-polyfill'])
    • getCurrentFilesFromDir(path: string): Promise<IFileInfo> 获取所有目录下的文件
      • path 相对工程目录的路径
    • getAllFiles(): Promise<void> 获取工程下的所有文件
      • 解析后 allFiles 才有值
    • analyzeDependence(): Promise<void> 获取依赖
      • 解析后 每个 FileInfo.dependenceList 才有值
  • 静态方法
    • 待完成...

FileInfo

  • 实例属性
    • ext string 后缀
    • path string 路径
    • filename string 文件名
    • dependenceList FileInfo[] 依赖文件
  • 实例方法
    • equals(fileInfo: string | FileInfo): boolean 比较是否相同(dependenceList 中的文件存放的并不是 FileInfo 的引用,而是重新生成的 FileInfo)
    • toString(): string 路径 + 文件名

example 1

var rcDepAnalyze = require('react-dependence-analyze');

var options = {
  baseDir: '/home/usr1/project/react-proj', // 工程路径
}
var fileUtil = new rcDepAnalyze.FileUtils(options);
fileUtil.getAllFiles()
  .then(function() {
    return fileUtil.analyzeDependence();
  }).then(function() {
    console.log(fileUtil.allFiles); // 依赖获取完成
  });

example 2

For command line syntax:

​rda-cli 工程根目录 -t filename 依赖分析对象 [-e ext(逗号分隔)] [-b blackList(逗号分隔 RegExp 表达式)] [-w whiteList(逗号分隔 RegExp 表达式)] [-i ignoreModule(逗号分隔)] [-full(显示为绝对路径)]

node_modules/.bin/rda-cli test/testData -t test/testData/components/MainMenu.jsx
// => dependence trace:
// => .../react-dependence-analyze/test/testData/containers/Application.jsx

history log

0.1.1 => 0.1.2

  • 支持 import 指定到文件夹、默认取文件夹下 index.js 或者 index.jsx 的这种情况
  • cli 默认输出相对路径,添加 cli 参数 -full,若设置 -full 则输出绝对路径

0.1.0 => 0.1.1

  • 修剪 npm 包内容、依赖

Keywords

FAQs

Last updated on 29 Nov 2016

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc