npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

package-analyze

v1.1.0

Published

a command-line tool of package analyze

Downloads

7

Readme

npm 包依赖分析命令行工具

package-analyze将从当前目录下的package.json文件出发,通过递归分package.json中的指定的依赖项,来生成依赖关系数据,并利用 d3-graphviz进行可视化渲染。

开始使用

  1. 全局安装
npm install package-analyze -g
  1. 使用

安装完成后,在项目根目录的命令行窗口中运行以下命令来分析依赖项。分析结果将自动在d端口为3000的网页中打开。

analyze-cli analyze
analyze-cli aly    // 简写

还可以使用参数来限制递归分析的深度。--depth[n]

analyze-cli aly --depth [n]
analyze-cli aly -d [n]        // 简写

要将依赖关系保存为 JSON 文件而不打开网页,请使用参数并指定文件路径,若没有指定文件路径,则默认路径为命令行中键入的文件路径。--json [file-path]

analyze-cli aly --json [file-path]
analyze-cli aly -j [file-path]

如果希望在打开网页展示依赖关系的同时将依赖关系保存为JSON文件,可同采用--json--server

analyze-cli aly -server -json [file-path]
analyze-cli aly -s -j [file-path]

目录结构

├── bin                          // 存放可执行文件
│   └─ index.js                  // 主要的执行入口文件
├── config                       // 存放配置文件
│   └─ config.js                 // 配置文件,用于设置应用程序的参数
├── data                         // 存放数据文件
├── dist                         // 存放构建后的输出目录
│   ├── assets                   // 存放静态资源文件
│   │   ├── index-92da51cd.css    // CSS 文件
│   │   └── index-bf74e693.js     // JavaScript 文件
│   └── index.html               // HTML 文件
├── lib                          // 存放源代码库
│   ├── core                     // 核心功能模块
│   │   ├── action.js            // 执行相关的功能
│   │   ├── commander.js         // 命令解析器
│   │   └── help.js              // 帮助信息相关的功能
│   └── utils                    // 实用工具函数
│       ├── converToGraph.js     // 将数据转化为图格式数据
│       ├── getGraphData.js      // 得到前端需要的图数据格式
│       ├── getPackageJSON.js    // 处理package.json文件
│       └── hasCycle.js          // 检查循环依赖
├── server.js                    // 服务器启动文件
└── package.json                 // 项目配置文件

技术栈

功能开发:

  • 依赖关系图:使用d3-graphviz可视化

工程化:

  • 使用JavaScript 开发;
  • 使用 jest 实现单元测试;
  • 接入 eslint, prettier, lint-staged 代码风格自动化工具;