@zhaofx/deplens 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/assets/depLens.ico +0 -0
- package/bin/assets/depLens.png +0 -0
- package/bin/config.js +5 -0
- package/bin/diffView.js +304 -0
- package/bin/env-checker.js +188 -0
- package/bin/env-recorder.js +58 -0
- package/bin/index.js +84 -0
- package/bin/template.html +684 -0
- package/package.json +39 -0
- package/readme.md +92 -0
package/package.json
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@zhaofx/deplens",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "专业级项目依赖镜像空间与环境溯源工具",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"bin": {
|
|
8
|
+
"depLens": "bin/index.js"
|
|
9
|
+
},
|
|
10
|
+
"files": [
|
|
11
|
+
"bin",
|
|
12
|
+
"dist",
|
|
13
|
+
"template.html"
|
|
14
|
+
],
|
|
15
|
+
"engines": {
|
|
16
|
+
"node": ">=18.0.0",
|
|
17
|
+
"pnpm": ">=8.0.0"
|
|
18
|
+
},
|
|
19
|
+
"dependencies": {
|
|
20
|
+
"@babel/parser": "^7.23.6",
|
|
21
|
+
"@babel/traverse": "^7.23.6",
|
|
22
|
+
"fs-extra": "^11.1.0",
|
|
23
|
+
"glob": "^10.3.10",
|
|
24
|
+
"inquirer": "^13.3.2",
|
|
25
|
+
"open": "^9.1.0",
|
|
26
|
+
"polka": "^0.5.2",
|
|
27
|
+
"sirv": "^2.0.3",
|
|
28
|
+
"yaml": "^2.3.1"
|
|
29
|
+
},
|
|
30
|
+
"scripts": {
|
|
31
|
+
"record": "node ./bin/env-recorder.js",
|
|
32
|
+
"dev": "node ./bin/index.js --dev",
|
|
33
|
+
"lint": "eslint . --ext .js,.jsx,.ts,.tsx"
|
|
34
|
+
},
|
|
35
|
+
"keywords": [],
|
|
36
|
+
"author": "dafei",
|
|
37
|
+
"license": "ISC",
|
|
38
|
+
"packageManager": "pnpm@10.30.3"
|
|
39
|
+
}
|
package/readme.md
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
DepLens 🔍
|
|
2
|
+
English | 中文说明
|
|
3
|
+
|
|
4
|
+
English
|
|
5
|
+
|
|
6
|
+
DepLens is a high-performance dependency analyzer and environment tracing tool, specifically optimized for `pnpm` projects. It combines AST source code scanning with Hierarchical Treemap visualizations to reveal "ancestor-to-grandchild" relationships while ensuring team-wide development environment consistency.
|
|
7
|
+
|
|
8
|
+
### ✨ Key Features
|
|
9
|
+
|
|
10
|
+
- **Hierarchical Treemap**: A nested "box-in-box" visualization that mimics the actual dependency tree, making it easy to spot heavy sub-dependencies.
|
|
11
|
+
- **Ghost Dependency Detection**: Powered by `@babel/parser`. It scans your `src/` directory to find packages you import but forgot to declare in `package.json`.
|
|
12
|
+
- **Environment Tracing (New)**: Automatically records Node.js/npm versions, package manager types, and registry mirrors to prevent "It works on my machine" errors.
|
|
13
|
+
- **Privacy First**: 100% local execution. No dependency data or source code snippets are ever uploaded to any server.
|
|
14
|
+
- **Enhanced UI**: Redesigned sidebar with a close button and a header display for real-time environment version tracking.
|
|
15
|
+
|
|
16
|
+
### 🚀 Quick Start
|
|
17
|
+
|
|
18
|
+
Install:
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
npm install -g depLens
|
|
22
|
+
|
|
23
|
+
Usage: Navigate to your project root (ensure `pnpm-lock.yaml` exists) and use the unified command:
|
|
24
|
+
|
|
25
|
+
Start Visualization:
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
depLens -view
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Opens a local web server to explore the dependency map.
|
|
32
|
+
|
|
33
|
+
Record Environment:
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
depLens -track
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Snapshots your current Node.js, npm, and registry settings into `.deplens.history.json`.
|
|
40
|
+
|
|
41
|
+
Team Integration (Best Practice): Add this to your Git pre-commit hook (e.g., via Husky) to ensure every commit includes the environment state:
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
depLens -track && git add .deplens.history.json
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
## 中文说明
|
|
50
|
+
|
|
51
|
+
DepLens 是一款专为 pnpm 项目打造的高性能、隐私优先的依赖分析与环境溯源工具。
|
|
52
|
+
它通过 **AST 源码扫描** 与 **嵌套层级树(Hierarchical Treemap)** 可视化,直观呈现依赖的“祖孙”嵌套关系,并精准识别“幽灵依赖”,同时解决团队成员因开发环境不一致导致的构建失败问题。
|
|
53
|
+
|
|
54
|
+
### ✨ 核心特性
|
|
55
|
+
|
|
56
|
+
- **嵌套层级视图**: 采用“大盒套小盒”布局,完整复现依赖树结构,一眼看清冗余子包。
|
|
57
|
+
- **幽灵依赖检测**: 深度扫描 `src/` 目录,揪出已引用但未在 `package.json` 中声明的依赖。
|
|
58
|
+
- **环境溯源 (新)**: 自动记录 Node.js/npm 版本、包管理器类型及 Registry 镜像地址,为排查环境问题提供精准快照。
|
|
59
|
+
- **可视化增强**: 侧边栏新增关闭按钮; Header 头部实时显示当前 Node/npm 版本,支持导入快照进行版本对比。
|
|
60
|
+
- **隐私至上**: 100% 本地分析。所有数据均在本地完成,绝不上传至任何服务器。
|
|
61
|
+
|
|
62
|
+
### 🚀 快速上手
|
|
63
|
+
|
|
64
|
+
安装:
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
npm install -g depLens
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
核心命令: 在项目根目录(包含 `pnpm-lock.yaml`)下执行:
|
|
71
|
+
|
|
72
|
+
启动可视化面板:
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
depLens -view
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
在浏览器打开交互式地图,支持下钻查看与环境校验。
|
|
79
|
+
|
|
80
|
+
记录环境快照:
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
depLens -track
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
生成 `.deplens.history.json`,记录当前 Node、npm 版本及镜像源等核心参数。
|
|
87
|
+
|
|
88
|
+
团队集成 (推荐): 配合 Husky 集成到 Git Hooks 中,在提交代码前自动同步环境信息,实现环境问题的“事后追溯”:
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
depLens -track && git add .deplens.history.json
|
|
92
|
+
```
|