@wjm200509/dsh-plugin-version-watch 0.0.0-stage → 0.1.4
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/LICENSE +21 -0
- package/README.md +48 -3
- package/icon.svg +6 -0
- package/lib/client.js +613 -0
- package/lib/index.js +658 -0
- package/lib/lockfile.js +100 -0
- package/lib/spec.js +175 -0
- package/locale/en.json +6 -0
- package/locale/zh.json +6 -0
- package/package.json +52 -4
- package/patch.yml +6 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 JiaMingWang-CN
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,48 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
# dsh-plugin-version-watch
|
|
2
|
+
|
|
3
|
+
[English](#english) · 中文
|
|
4
|
+
|
|
5
|
+
在 DSH 设置的“插件更新”页监控已安装插件的版本,并一键更新;更新通过 HMR 热重载生效,通常不需要重启。
|
|
6
|
+
|
|
7
|
+
## 它做什么
|
|
8
|
+
|
|
9
|
+
- **列出版本**:设置页按 profile 的依赖列出所有已安装插件,显示当前版本、来源和启用状态。
|
|
10
|
+
- **检查更新**:
|
|
11
|
+
- **Git 来源**(`github:owner/repo#path:...`、Git URL):从 `pnpm-lock.yaml` 读出已安装的精确提交,用 `git ls-remote` 取远端分支/标签的最新提交;能读到时再通过 GitHub 原始文件接口读出该提交下该子目录的 `package.json` 版本号。
|
|
12
|
+
- **npm 注册表来源**:调用 DSH 插件管理器自带的版本列表,取最新的、声明为 bundle、未弃用且兼容当前 DSH 的版本。
|
|
13
|
+
- 本地目录、压缩包、版本范围安装等来源显示为“不支持自动更新”,不会误操作。
|
|
14
|
+
- **一键更新**:
|
|
15
|
+
- Git 来源:按 profile 记录的原始 spec 先 `removeBundle` 再 `installBundle`,pnpm 会重新解析远端最新提交;插件管理器的 HMR 重组让新代码直接生效。
|
|
16
|
+
- 注册表来源:调用 `updateBundle`,复用官方的版本校验、失败回滚流程。
|
|
17
|
+
- 结果会明确显示“已实时生效,无需重启”或“需要重启(原因)”。Git 重装失败时旧版本已卸载,界面会提示到 Plugins 页面重新安装。
|
|
18
|
+
- **监控**:打开页面时自动检查一次,并每 15 分钟复查;顶部提供“全部重新检查”。
|
|
19
|
+
|
|
20
|
+
## 安装
|
|
21
|
+
|
|
22
|
+
```sh
|
|
23
|
+
# 从 npm
|
|
24
|
+
dsh plugin --profile <profile> add "@wjm200509/dsh-plugin-version-watch"
|
|
25
|
+
|
|
26
|
+
# 本地目录
|
|
27
|
+
dsh plugin --profile <profile> add /path/to/dsh-plugin-version-watch
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
安装后在 **设置 → 插件更新** 打开页面。
|
|
31
|
+
|
|
32
|
+
## 实现
|
|
33
|
+
|
|
34
|
+
| 半边 | 文件 | 作用 |
|
|
35
|
+
| --- | --- | --- |
|
|
36
|
+
| Host | `lib/index.js` | 注册两条经连接层认证的路由:`GET /api/version-watch/status` 与 `POST /api/version-watch/update`;读 profile 清单与锁文件,执行检查与更新。 |
|
|
37
|
+
| Host | `lib/spec.js` | 解析已保存的依赖 spec(GitHub 简写、Git URL、注册表、本地、压缩包),构造 GitHub 原始文件 URL。 |
|
|
38
|
+
| Host | `lib/lockfile.js` | 只读 `pnpm-lock.yaml` 的根 importer 依赖及其解析版本,取出已安装的 Git 提交。 |
|
|
39
|
+
| Client | `lib/client.js` | 在 `settings.section` 注册“插件更新”页与导航图标,负责检查、更新按钮、结果提示和自动复查。 |
|
|
40
|
+
|
|
41
|
+
所有写操作都经由 DSH 的 `pluginManager` 服务,不直接改 profile 文件;因此删除/安装/启用的规则、版本兼容检查与失败恢复都与插件管理器保持一致。
|
|
42
|
+
|
|
43
|
+
## 限制
|
|
44
|
+
|
|
45
|
+
- Git 来源的“最新版本”比较的是提交;即使子目录 `package.json` 版本号没变,只要远端有新提交就会显示“有新提交”。重新安装后若代码实际未变,属于无害的空更新。
|
|
46
|
+
- 私有仓库依赖本机 Git 凭据;检查使用 `git ls-remote` 且关闭终端提示与凭据助手,读不到时显示“检查失败/无法连接远端”。
|
|
47
|
+
- 更新 Git 插件会让它移动到 bundle 选择列表末尾(插件管理器的既有行为),可能改变配置层的优先级。
|
|
48
|
+
- 仅支持有 bundle patch 的插件;普通依赖不会出现在列表中。
|
package/icon.svg
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64" width="64" height="64" role="img" aria-label="Plugin version watch">
|
|
2
|
+
<rect x="6" y="6" width="52" height="52" rx="14" fill="#247bbf"/>
|
|
3
|
+
<path d="M32 17v21" fill="none" stroke="#ffffff" stroke-width="5" stroke-linecap="round"/>
|
|
4
|
+
<path d="M23 29.5 32 39l9-9.5" fill="none" stroke="#ffffff" stroke-width="5" stroke-linecap="round" stroke-linejoin="round"/>
|
|
5
|
+
<rect x="18" y="45" width="28" height="5" rx="2.5" fill="#d6ecff"/>
|
|
6
|
+
</svg>
|