Skip to content

Commit e49a047

Browse files
author
wangjiasheng
committed
docs: update README with multi-level node_modules support
- Restructure README: English (README.md) as main, Chinese (README_CN.md) - Add multi-level node_modules support documentation - Add GitHub Actions release workflow - Add vsce and ovsx publishing scripts
1 parent ca91bc1 commit e49a047

5 files changed

Lines changed: 240 additions & 51 deletions

File tree

.github/workflows/release.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: Release Extension
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*.*.*'
7+
8+
permissions:
9+
contents: read
10+
11+
jobs:
12+
release:
13+
runs-on: ubuntu-latest
14+
permissions:
15+
contents: write
16+
id-token: write # 用于 OIDC 发布到 Open VSX
17+
steps:
18+
- name: Checkout code
19+
uses: actions/checkout@v4
20+
21+
- name: Setup Node.js
22+
uses: actions/setup-node@v4
23+
with:
24+
node-version: '20'
25+
cache: 'npm'
26+
27+
- name: Install dependencies
28+
run: npm ci
29+
30+
- name: Run tests
31+
run: npm test
32+
continue-on-error: true
33+
34+
- name: Build extension
35+
run: npm run build
36+
37+
- name: Publish to Visual Studio Marketplace
38+
run: npm run publish:vsce
39+
env:
40+
VSCE_PAT: ${{ secrets.VSCE_PAT }}
41+
42+
- name: Publish to Open VSX Registry
43+
run: npm run publish:ovsx
44+
env:
45+
OVSX_PAT: ${{ secrets.OVSX_PAT }}
46+
47+
- name: Create GitHub Release
48+
uses: softprops/action-gh-release@v2
49+
with:
50+
files: |
51+
*.vsix
52+
generate_release_notes: true
53+
draft: false
54+
prerelease: false

README.en.md

Lines changed: 0 additions & 32 deletions
This file was deleted.

README.md

Lines changed: 81 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,95 @@
1-
README.md Language: [中文](https://github.com/zyrong/vscode-node-modules/blob/master/README.md) | [English](https://github.com/zyrong/vscode-node-modules/blob/master/README.en.md)
1+
Language: [English](./README.md) | [中文](./README_CN.md)
22
<br/><br/>
33

44
# node-modules
5-
<!-- ![](https://vsmarketplacebadge.apphb.com/version/zyrong.node-modules.svg) ![](https://vsmarketplacebadge.apphb.com/installs/zyrong.node-modules.svg) -->
5+
6+
Forked from [zyrong/vscode-node-modules](https://github.com/zyrong/vscode-node-modules) with enhanced support for multi-level node_modules directory structure.
67

78
<br/>
89

910
## Features
1011

11-
-`package.json`文件中 将鼠标悬停在`packageName`上会出现相关提示
12-
如果此packageName对应的package在已经安装的情况下,点击悬浮框中的包名,会跳转到包的安装目录下
13-
![](https://raw.githubusercontent.com/zyrong/vscode-node-modules/master/resources/images/hover-pkgjson-pkgname.gif)
12+
### Package.json Hover Tip
13+
14+
Hover the mouse over `packageName` in the `package.json` file and a related prompt will appear. If the package corresponding to this packageName is already installed, click the package name in the floating box, and it will jump to the installation directory of the package.
15+
16+
![](https://raw.githubusercontent.com/wangjs-jacky/vscode-node-modules/master/resources/images/hover-pkgjson-pkgname.gif)
17+
18+
### Import/Require Hover Tip
19+
20+
When importing `package` using `import` or `require` in `.ts`, `.js`, `.jsx`, `.tsx`, `.vue` files, move the mouse over the `PackageName`, you will get relevant tips.
21+
22+
![](https://raw.githubusercontent.com/wangjs-jacky/vscode-node-modules/master/resources/images/hover-import-pkgname.gif)
23+
24+
### Go to Definition
25+
26+
In package.json file, `press Ctrl` and `click packageName` to jump to node_modules corresponding package directory.
27+
28+
![](https://raw.githubusercontent.com/wangjs-jacky/vscode-node-modules/master/resources/images/goToDefine.gif)
1429

15-
-`.ts` `.js` `.jsx` `.tsx` `.vue`文件中使用`import``require`导入`package`时,鼠标移动到`PackageName`上,将会得到相关提示。
16-
![](https://raw.githubusercontent.com/zyrong/vscode-node-modules/master/resources/images/hover-import-pkgname.gif)
30+
### Search Package
31+
32+
Right-click the node_modules folder and click Search Package in the pop-up menu to search the node_modules packages.
33+
34+
![](https://raw.githubusercontent.com/wangjs-jacky/vscode-node-modules/master/resources/images/search-package.gif)
35+
36+
### Search node_modules
37+
38+
In the pop-up menu, click Search node_modules to search the node_modules path.
39+
40+
![](https://raw.githubusercontent.com/wangjs-jacky/vscode-node-modules/master/resources/images/search-node_modules.gif)
41+
42+
### Copy Real Path of Symlink
43+
44+
![](https://raw.githubusercontent.com/wangjs-jacky/vscode-node-modules/master/resources/images/copyRealPath.gif)
45+
46+
<br/>
1747

18-
- 在package.json文件中 `按住ctrl`+`点击packageName`将跳转到node_modules对应package目录下.
19-
![](https://raw.githubusercontent.com/zyrong/vscode-node-modules/master/resources/images/goToDefine.gif)
48+
## Multi-level node_modules Support
2049

21-
- 对 node_modules文件夹 点击右键,在弹出的菜单,点击搜索 Package,可以对node_modules的package进行搜索。
22-
![](https://raw.githubusercontent.com/zyrong/vscode-node-modules/master/resources/images/search-package.gif)
50+
This fork version enhances support for multi-level node_modules directory structure, suitable for the following scenarios:
2351

24-
- 在弹出的菜单中,点击搜索 node_modules,可以对node_modules进行路径搜索。
25-
![](https://raw.githubusercontent.com/zyrong/vscode-node-modules/master/resources/images/search-node_modules.gif)
52+
### 1. Nested node_modules Lookup
53+
54+
When the project has nested node_modules structure (e.g., `node_modules/package-a/node_modules/package-b`), the extension automatically traverses upward to find dependency packages until the target package is found or the workspace root is reached.
55+
56+
### 2. package-lock.json Support
57+
58+
Support in `package-lock.json` and `npm-shrinkwrap.json`:
59+
- Parse nested package paths under `packages` field
60+
- Parse hierarchical dependency relationships under `dependencies` field
61+
- Automatically recognize `.package-lock.json` files
62+
63+
### 3. pnpm Directory Structure Support
64+
65+
Search Package feature supports pnpm's special directory structure:
66+
- Packages under `node_modules/.pnpm/node_modules/`
67+
68+
### 4. Monorepo Workspace Support
69+
70+
In monorepo projects, supports correctly resolving dependencies from sub-package directories, following Node.js module resolution rules to search upward.
71+
72+
<br/>
73+
74+
## Keyboard Shortcuts
75+
76+
| Feature | Windows | macOS |
77+
|---------|---------|-------|
78+
| Search Package | `Ctrl+K P` | `Cmd+K P` |
79+
| Search node_modules | `Ctrl+K N` | `Cmd+K N` |
80+
81+
<br/>
82+
83+
## Configuration
84+
85+
| Setting | Default | Description |
86+
|---------|---------|-------------|
87+
| `node_modules.general.debug` | `false` | Enable debug logging |
88+
| `node_modules.hovers.pkgName.bundleSize` | `true` | Show bundle size in hover tips |
89+
| `node_modules.resolve.preserveSymlinks` | `false` | Whether to preserve symlinks (not resolve to real paths) |
90+
91+
<br/>
2692

27-
- 复制符号链接对应的实际路径
28-
![](https://raw.githubusercontent.com/zyrong/vscode-node-modules/master/resources/images/copyRealPath.gif)
93+
## Acknowledgments
2994

30-
> 快捷键:
31-
> 搜索 Package: windows(ctrl+k p)、mac(cmd+k p)
32-
> 搜索 node_modules: windows(ctrl+k n)、mac(cmd+k n)
95+
This project is forked from [zyrong/vscode-node-modules](https://github.com/zyrong/vscode-node-modules). Thanks to the original author for the excellent work.

README_CN.md

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
Language: [English](./README.md) | [中文](./README_CN.md)
2+
<br/><br/>
3+
4+
# node-modules
5+
6+
基于 [zyrong/vscode-node-modules](https://github.com/zyrong/vscode-node-modules) fork,增强支持多层级 node_modules 目录结构。
7+
8+
<br/>
9+
10+
## Features
11+
12+
### package.json 悬浮提示
13+
14+
`package.json` 文件中将鼠标悬停在 `packageName` 上会出现相关提示。如果此 packageName 对应的 package 已经安装,点击悬浮框中的包名,会跳转到包的安装目录下。
15+
16+
![](https://raw.githubusercontent.com/wangjs-jacky/vscode-node-modules/master/resources/images/hover-pkgjson-pkgname.gif)
17+
18+
### import/require 悬浮提示
19+
20+
`.ts` `.js` `.jsx` `.tsx` `.vue` 文件中使用 `import``require` 导入 `package` 时,鼠标移动到 `PackageName` 上,将会得到相关提示。
21+
22+
![](https://raw.githubusercontent.com/wangjs-jacky/vscode-node-modules/master/resources/images/hover-import-pkgname.gif)
23+
24+
### 跳转到定义
25+
26+
在 package.json 文件中 `按住 ctrl` + `点击 packageName` 将跳转到 node_modules 对应 package 目录下。
27+
28+
![](https://raw.githubusercontent.com/wangjs-jacky/vscode-node-modules/master/resources/images/goToDefine.gif)
29+
30+
### 搜索 Package
31+
32+
对 node_modules 文件夹点击右键,在弹出的菜单中点击搜索 Package,可以对 node_modules 的 package 进行搜索。
33+
34+
![](https://raw.githubusercontent.com/wangjs-jacky/vscode-node-modules/master/resources/images/search-package.gif)
35+
36+
### 搜索 node_modules
37+
38+
在弹出的菜单中,点击搜索 node_modules,可以对 node_modules 进行路径搜索。
39+
40+
![](https://raw.githubusercontent.com/wangjs-jacky/vscode-node-modules/master/resources/images/search-node_modules.gif)
41+
42+
### 复制符号链接实际路径
43+
44+
![](https://raw.githubusercontent.com/wangjs-jacky/vscode-node-modules/master/resources/images/copyRealPath.gif)
45+
46+
<br/>
47+
48+
## 多层级 node_modules 支持
49+
50+
本 fork 版本增强支持了多层级 node_modules 目录结构,适用于以下场景:
51+
52+
### 1. 嵌套 node_modules 查找
53+
54+
当项目存在多层嵌套的 node_modules 结构时(如 `node_modules/package-a/node_modules/package-b`),插件会自动向上遍历查找依赖包,直到找到目标包或到达工作区根目录。
55+
56+
### 2. package-lock.json 支持
57+
58+
支持在 `package-lock.json``npm-shrinkwrap.json` 中:
59+
- 解析 `packages` 字段下的嵌套包路径
60+
- 解析 `dependencies` 字段下的层级依赖关系
61+
- 自动识别 `.package-lock.json` 文件
62+
63+
### 3. pnpm 目录结构支持
64+
65+
搜索 Package 功能支持 pnpm 的特殊目录结构:
66+
- `node_modules/.pnpm/node_modules/` 目录下的包
67+
68+
### 4. Monorepo 工作区支持
69+
70+
在 monorepo 项目中,支持从子包目录正确解析依赖关系,按照 Node.js 模块解析规则向上查找。
71+
72+
<br/>
73+
74+
## 快捷键
75+
76+
| 功能 | Windows | macOS |
77+
|------|---------|-------|
78+
| 搜索 Package | `Ctrl+K P` | `Cmd+K P` |
79+
| 搜索 node_modules | `Ctrl+K N` | `Cmd+K N` |
80+
81+
<br/>
82+
83+
## 配置项
84+
85+
| 配置项 | 默认值 | 说明 |
86+
|--------|--------|------|
87+
| `node_modules.general.debug` | `false` | 开启调试日志 |
88+
| `node_modules.hovers.pkgName.bundleSize` | `true` | 悬浮提示显示包体积信息 |
89+
| `node_modules.resolve.preserveSymlinks` | `false` | 是否保留符号链接(不解析为真实路径) |
90+
91+
<br/>
92+
93+
## 致谢
94+
95+
本项目 fork 自 [zyrong/vscode-node-modules](https://github.com/zyrong/vscode-node-modules),感谢原作者的优秀工作。

package.json

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,8 @@
224224
}
225225
]
226226
},
227+
"vsce": {},
228+
"ovsx": {},
227229
"scripts": {
228230
"esbuild-base": "esbuild ./src/extension.ts --bundle --outfile=out/extension.js --format=cjs --platform=node --external:vscode --external:node-gyp",
229231
"esbuild": "npm run esbuild-base -- --sourcemap",
@@ -235,6 +237,11 @@
235237
"release-version": "standard-version",
236238
"vscode:prepublish": "npm run esbuild-base -- --minify",
237239
"build": "vsce package",
240+
"package:vsix": "vsce package",
241+
"publish:vsce": "vsce publish",
242+
"publish:ovsx": "ovsx publish",
243+
"publish:all": "npm run publish:vsce && npm run publish:ovsx",
244+
"deploy": "npm run build && npm run publish:all",
238245
"eslint:fix": "eslint ./src --config ./.eslintrc.js --fix --ext .js,.ts",
239246
"prettier": "prettier --config ./.prettierrc.js --write \"./src/**/*.{js,ts}\"",
240247
"format-imports": "format-imports --config ./import-sorter.json \"./src\""
@@ -290,7 +297,9 @@
290297
"rimraf": "^3.0.2",
291298
"sinon": "^14.0.0",
292299
"standard-version": "^9.5.0",
293-
"typescript": "^4.7.4"
300+
"typescript": "^4.7.4",
301+
"@vscode/vsce": "^3.2.1",
302+
"ovsx": "^0.10.9"
294303
},
295304
"config": {
296305
"commitizen": {

0 commit comments

Comments
 (0)