@zhaofx/deplens 1.0.1 → 1.0.2
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/env-checker.js +0 -1
- package/package.json +8 -3
- package/readme.md +70 -45
package/bin/env-checker.js
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zhaofx/deplens",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "1.0.2",
|
|
4
|
+
"description": "专业级前端项目依赖镜像空间与环境溯源工具",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"bin": {
|
|
@@ -27,10 +27,15 @@
|
|
|
27
27
|
"sirv": "^2.0.3",
|
|
28
28
|
"yaml": "^2.3.1"
|
|
29
29
|
},
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"terser": "^5.46.1"
|
|
32
|
+
},
|
|
30
33
|
"scripts": {
|
|
31
34
|
"record": "node ./bin/env-recorder.js",
|
|
35
|
+
"publish": "npm publish --access public --auth-type=web",
|
|
32
36
|
"dev": "node ./bin/index.js --dev",
|
|
33
|
-
"lint": "eslint . --ext .js,.jsx,.ts,.tsx"
|
|
37
|
+
"lint": "eslint . --ext .js,.jsx,.ts,.tsx",
|
|
38
|
+
"minify": "node scripts/minify-bin.js"
|
|
34
39
|
},
|
|
35
40
|
"keywords": [],
|
|
36
41
|
"author": "zhaofx",
|
package/readme.md
CHANGED
|
@@ -1,92 +1,117 @@
|
|
|
1
|
-
|
|
2
|
-
English | 中文说明
|
|
1
|
+
## English
|
|
3
2
|
|
|
4
|
-
|
|
3
|
+
# DepLens 🔍
|
|
5
4
|
|
|
6
|
-
|
|
5
|
+
[English](#english) | [中文说明](#中文说明)
|
|
6
|
+
|
|
7
|
+
**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
|
|
|
8
9
|
### ✨ Key Features
|
|
9
10
|
|
|
10
11
|
- **Hierarchical Treemap**: A nested "box-in-box" visualization that mimics the actual dependency tree, making it easy to spot heavy sub-dependencies.
|
|
11
12
|
- **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
|
|
13
|
+
- **Environment Tracing**: Automatically records Node.js/npm versions, package manager types, and registry mirrors to prevent "It works on my machine" errors.
|
|
14
|
+
- **Environment Validation**: Compare your current environment against a recorded baseline (e.g., `.deplens.history.json`) to catch inconsistencies before they cause bugs.
|
|
15
|
+
- **Project Initialization**: Quickly scaffold standard config files (like `.nvmrc`, `.npmrc`, `depLens.json`) to enforce team-wide standards.
|
|
16
|
+
- **Automated Dependency Installation**: Smart install that respects the project's package manager (pnpm/npm/yarn) and registry mirror.
|
|
13
17
|
- **Privacy First**: 100% local execution. No dependency data or source code snippets are ever uploaded to any server.
|
|
14
18
|
- **Enhanced UI**: Redesigned sidebar with a close button and a header display for real-time environment version tracking.
|
|
15
19
|
|
|
16
20
|
### 🚀 Quick Start
|
|
17
21
|
|
|
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:
|
|
22
|
+
**Install**:
|
|
26
23
|
|
|
27
24
|
```bash
|
|
28
|
-
|
|
25
|
+
npm install -g @zhaofx/deplens
|
|
29
26
|
```
|
|
30
27
|
|
|
31
|
-
|
|
28
|
+
**Usage**: Navigate to your project root (ensure `pnpm-lock.yaml` exists for `-view` / `-track`).
|
|
32
29
|
|
|
33
|
-
|
|
30
|
+
| Command | Description |
|
|
31
|
+
| -------------------------- | --------------------------------------------------------------------------------------- |
|
|
32
|
+
| `depLens -init` | Initialize project standards (creates `.nvmrc`, `.npmrc`, `deplens.history.json`, etc.) |
|
|
33
|
+
| `depLens -track` | Record current Node.js, npm, registry settings into `.deplens.history.json` |
|
|
34
|
+
| `depLens -view` | Start local web server to explore hierarchical dependency treemap |
|
|
35
|
+
| `depLens -check` | Verify current environment matches the recorded baseline (exit code 1 if mismatch) |
|
|
36
|
+
| `depLens -install` | Automatically install dependencies using the project's detected package manager |
|
|
37
|
+
| `depLens -package` or `-p` | Display supported package managers (pnpm, npm, yarn) and detected current one |
|
|
38
|
+
| `depLens -h` | Show help information |
|
|
39
|
+
| `depLens -v` | Show version |
|
|
34
40
|
|
|
35
|
-
|
|
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:
|
|
41
|
+
**Team Integration (Best Practice)**: Add to your Git pre-commit hook (e.g., via Husky):
|
|
42
42
|
|
|
43
43
|
```bash
|
|
44
44
|
depLens -track && git add .deplens.history.json
|
|
45
45
|
```
|
|
46
46
|
|
|
47
|
-
|
|
47
|
+
For CI pipelines, run `depLens -check` before `depLens -install` to ensure environment consistency.
|
|
48
|
+
|
|
49
|
+
***
|
|
48
50
|
|
|
49
51
|
## 中文说明
|
|
50
52
|
|
|
51
|
-
DepLens
|
|
53
|
+
# DepLens 🔍
|
|
54
|
+
|
|
55
|
+
DepLens 是一款专为 pnpm 项目打造的高性能、隐私优先的依赖分析与环境溯源工具。\
|
|
52
56
|
它通过 **AST 源码扫描** 与 **嵌套层级树(Hierarchical Treemap)** 可视化,直观呈现依赖的“祖孙”嵌套关系,并精准识别“幽灵依赖”,同时解决团队成员因开发环境不一致导致的构建失败问题。
|
|
53
57
|
|
|
54
58
|
### ✨ 核心特性
|
|
55
59
|
|
|
56
|
-
-
|
|
57
|
-
-
|
|
58
|
-
-
|
|
59
|
-
-
|
|
60
|
-
-
|
|
60
|
+
- **嵌套层级视图**:采用“大盒套小盒”布局,完整复现依赖树结构,一眼看清冗余子包。
|
|
61
|
+
- **幽灵依赖检测**:深度扫描 `src/` 目录,揪出已引用但未在 `package.json` 中声明的依赖。
|
|
62
|
+
- **环境溯源**:自动记录 Node.js/npm 版本、包管理器类型及 Registry 镜像地址,为排查环境问题提供精准快照。
|
|
63
|
+
- **环境校验**:对比当前环境与已记录的标准快照(如 `.deplens.history.json`),提前发现不一致。
|
|
64
|
+
- **项目初始化**:一键生成团队标准配置文件(如 `.nvmrc`、`.npmrc`、`depLens.json`),规范成员开发环境。
|
|
65
|
+
- **自动安装依赖**:根据项目锁文件智能识别包管理器(pnpm/npm/yarn)并安装依赖,自动使用记录的镜像源。
|
|
66
|
+
- **隐私至上**:100% 本地分析。所有数据均在本地完成,绝不上传至任何服务器。
|
|
67
|
+
- **可视化增强**:侧边栏新增关闭按钮;Header 头部实时显示当前 Node/npm 版本,支持导入快照进行版本对比。
|
|
61
68
|
|
|
62
69
|
### 🚀 快速上手
|
|
63
70
|
|
|
64
|
-
|
|
71
|
+
**安装**:
|
|
65
72
|
|
|
66
73
|
```bash
|
|
67
|
-
npm install -g
|
|
74
|
+
npm install -g @zhaofx/deplens
|
|
68
75
|
```
|
|
69
76
|
|
|
70
|
-
|
|
77
|
+
**核心命令**:在项目根目录(建议包含 `pnpm-lock.yaml` 或其它锁文件)下执行:
|
|
78
|
+
|
|
79
|
+
| 命令 | 说明 |
|
|
80
|
+
| ------------------------- | --------------------------------------------------- |
|
|
81
|
+
| `depLens -init` | 初始化项目标准(生成 `.nvmrc`、`.npmrc`、`depLens.json` 等) |
|
|
82
|
+
| `depLens -track` | 记录当前 Node、npm 版本及镜像源等核心参数 → `.deplens.history.json` |
|
|
83
|
+
| `depLens -view` | 启动本地 Web 服务,查看依赖空间镜像(嵌套层级视图) |
|
|
84
|
+
| `depLens -check` | 检查当前环境是否符合已记录的环境标准(不符合时返回非零退出码) |
|
|
85
|
+
| `depLens -install` | 自动安装项目依赖(根据锁文件自动选择 pnpm/npm/yarn) |
|
|
86
|
+
| `depLens -package` 或 `-p` | 查看支持的包管理器列表,并显示当前项目检测到的管理器 |
|
|
87
|
+
| `depLens -h` | 显示帮助信息 |
|
|
88
|
+
| `depLens -v` | 查看版本 |
|
|
71
89
|
|
|
72
|
-
|
|
90
|
+
**团队集成(推荐)**:配合 Husky 集成到 Git Hooks 中,在提交代码前自动同步环境信息:
|
|
73
91
|
|
|
74
92
|
```bash
|
|
75
|
-
depLens -
|
|
93
|
+
depLens -track && git add .deplens.history.json
|
|
76
94
|
```
|
|
77
95
|
|
|
78
|
-
|
|
96
|
+
在 CI 流程中,建议先执行 `depLens -check`,通过后再执行 `depLens -install`,确保环境一致性。
|
|
79
97
|
|
|
80
|
-
|
|
98
|
+
***
|
|
81
99
|
|
|
82
|
-
|
|
83
|
-
depLens -track
|
|
84
|
-
```
|
|
100
|
+
## 帮助信息(命令行)
|
|
85
101
|
|
|
86
|
-
|
|
102
|
+
```text
|
|
103
|
+
用法: depLens [选项]
|
|
87
104
|
|
|
88
|
-
|
|
105
|
+
选项:
|
|
106
|
+
-init 初始化项目标准(生成 .nvmrc, .npmrc, depLens.json 等)
|
|
107
|
+
-track 记录当前 Node/npm/镜像 等环境信息到 .deplens.history.json
|
|
108
|
+
-view 启动本地 Web 服务查看依赖空间镜像(嵌套层级视图)
|
|
109
|
+
-check 检查当前环境是否符合记录的环境标准
|
|
110
|
+
-install 自动安装项目依赖(自动识别包管理器)
|
|
111
|
+
-package, -p 查看支持的包管理器及当前项目使用的管理器
|
|
112
|
+
-h 显示帮助信息
|
|
113
|
+
-v 查看版本
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
***
|
|
89
117
|
|
|
90
|
-
```bash
|
|
91
|
-
depLens -track && git add .deplens.history.json
|
|
92
|
-
```
|