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

dep-analyze-cli

v2.1.0

Published

display dependency information of the package and run a server to graphical display

Downloads

9

Readme

项目名称

dep-analyze-cli

项目说明

dep-analyze-cli是一个命令行工具,用于分析使用nodejs开发的前后端项目依赖关系。并可以启动一个本地服务器,使用前端渲染库D3可视化展示依赖关系。

功能特点

  • 分析并输出当前项目及当前项目下任意依赖包的生产环境依赖关系
  • 前端可视化展示当前项目及当前项目下任意依赖包的生产环境依赖关系、是否存在循环依赖以及是否存在多个相同包名不同版本号的依赖等信息

实现难点

  1. 众多依赖的版本号是否规范是本项目健壮运行的关键,但由于npm依赖安装方式的多样性和npm包开发者对语义化版本号不彻底遵循,导致本项目无法解析所有的npm依赖包的版本号格式,只能通过semver包解析规范的语义化版本号和一些妥协的手段保证项目的运行。
  2. 图的深度优先遍历是在已经有图的实例的情况下进行的操作,而在本项目只能通过构建扩展图与深度遍历同时并举的方式进行,这会使得求图的深度和正确构建扩展图的操作更加细粒度。
  3. 可以通过设置节点的访问标志解决循环依赖造成的死循环问题,但难以辨别重复访问一个节点是循环依赖导致的还是多个节点依赖相同节点导致的,因而如何辨别循环依赖是一个难点,本项目通过一个栈保存每个节点到入口节点的访问路径,如果下一个访问节点在栈中,那就表示是循环依赖导致的重复访问一个节点。

技术栈

  • prettier + eslint + lint-staged + husky
  • typescript + express + vue + D3
  • vitest
  • datastructure:graph

安装方式

  1. 在安装dep-analyze-cli工具之前,必须确保已经安装了nodejs
  2. 本项目已经发布到npm上,可以直接使用npm安装。 全局安装:npm install dep-analyze-cli -g 本地安装:npm install dep-analyze-cli

使用方式

  1. 全局安装方式,在windows下可以直接使用,在linux下必须要找到dep-analyze-cli路径,并将其链接到/usr/bin/下。
  2. 本地安装方式,可以在当前项目控制台中输出./node_moduels/.bin/dep-analyze-cli使用该工具,也可以在package.json中构造命令脚本。
  3. 使用描述
Usage: dep-analyze-cli [arguments] [options] 

Description:
  dep-analyze-cli can display the dependencies of a package and run a server to graphical display

Options:
  -h, --help     Display help information
  -p, --package  Specify a package name and also provide a version number
  -v, --version  Specify a version number and also provide a package name
  -d, --depth    Specify the depth of traversal 
  -j, --json     Specify the saved path of dependency information

Arguments:
  help           Display help information without any options
  analyze        Analyze the dependencies of a package. If no parameters are specified, the current project package will be analyzed by default

Examples:
  dep-analyze-cli help || dep-analyze-cli || dep-analyze-cli analyze -h       Display help information
  dep-analyze-cli runserver                                                   Run a server to graphically display dependency information of the current project package
  dep-analyze-cli analyze                                                     Display dependencies  of the current package and run a server
  dep-analyze-cli analyze -p=test -v=1.0.0                                    Display dependencies  of the package [email protected]
  dep-analyze-cli analyze -d=4                                                Display The first four levels dependency information of the current package with a server
  dep-analyze-cli analyze -j=./data/save.json                                 Save dependency information of the current package with a server
  1. 使用注意事项

如果指定包名和版本号,那么必须同时指定且指定的报名和版本号必须正确无误,否则前端页面将会渲染失败。