feat: v0.10.1 — 新增一键安装脚本 scripts/install.sh,README 安装置顶 npm 方式
- scripts/install.sh:把插件以 npm 包形式装进 web profile(幂等写依赖 + 挂载行 + pnpm install;支持版本参数 / --restart / --dry-run) - 版本 0.10.0 -> 0.10.1(修正 npm 元数据 repository URL 到 omdsh-dev) - scripts/install.sh 纳入发布 files
This commit is contained in:
1 parent
b9f8eea56d
commit
a85d1ab004
5 files changed
+168
-8
No files matched your search
@@ -35,10 +35,22 @@ https://github.com/user-attachments/assets/23187822-047e-45cc-b480-fe997bd55b86
|
|||||||
|
|
||||||
## 🚀 安装
|
## 🚀 安装
|
||||||
|
|
||||||
前置:已安装 DSH(`dsh web` 可运行),Node.js ≥ 20、pnpm ≥ 10。插件已发布到 npm:**`dsh-better-sidebar@0.10.0`**(`@deepseek-ai/*` peer 依赖对齐宿主实际版本 `^0.1.0-rc.6` / `@deepseek-ai/cordis@^4.0.1`,同版本单实例)。挂载仍走 profile + `cordis.patch.yml`,依赖来源为 npm 包:
|
前置:已安装 DSH(`dsh web` 可运行),Node.js ≥ 20、pnpm ≥ 10。插件已发布到 npm:**`dsh-better-sidebar@0.10.1`**(`@deepseek-ai/*` peer 依赖对齐宿主实际版本 `^0.1.0-rc.6` / `@deepseek-ai/cordis@^4.0.1`,同版本单实例)。挂载仍走 profile + `cordis.patch.yml`,不修改 DSH 源码。
|
||||||
|
|
||||||
|
### 一键安装(推荐)
|
||||||
|
|
||||||
|
```sh
|
||||||
|
curl -fsSL https://raw.githubusercontent.com/omdsh-dev/DSH-better-sidebar/main/scripts/install.sh | bash
|
||||||
|
# 指定版本: curl -fsSL <同上> | bash -s 0.10.1
|
||||||
|
# 装完自动重启 DSH: curl -fsSL <同上> | bash -s -- --restart
|
||||||
|
```
|
||||||
|
|
||||||
|
脚本自动完成:登记 npm 依赖到 `~/.dsh/profiles/web/package.json`、幂等追加 `cordis.patch.yml` 挂载行、执行 `pnpm install`(版本默认 latest,可传参;`--dry-run` 只预览不落盘)。
|
||||||
|
|
||||||
|
### 手动安装(npm 包方式)
|
||||||
|
|
||||||
```text
|
```text
|
||||||
1. 在 ~/.dsh/profiles/web/package.json 的 dependencies 加 "dsh-better-sidebar": "^0.10.0"
|
1. 在 ~/.dsh/profiles/web/package.json 的 dependencies 加 "dsh-better-sidebar": "^0.10.1"
|
||||||
2. 在 ~/.dsh/profiles/web/cordis.patch.yml 追加挂载行:
|
2. 在 ~/.dsh/profiles/web/cordis.patch.yml 追加挂载行:
|
||||||
- insert:
|
- insert:
|
||||||
- id: better-sidebar
|
- id: better-sidebar
|
||||||
@@ -73,7 +85,7 @@ https://github.com/user-attachments/assets/23187822-047e-45cc-b480-fe997bd55b86
|
|||||||
5. 重启 DSH 并硬刷新
|
5. 重启 DSH 并硬刷新
|
||||||
```
|
```
|
||||||
|
|
||||||
更新:`git pull && pnpm install && pnpm build` → 重启 DSH(仅 client 改动可硬刷新)。切回 npm 通道时,把依赖改回 `"dsh-better-sidebar": "^0.10.0"` 再 `pnpm install`。
|
更新:`git pull && pnpm install && pnpm build` → 重启 DSH(仅 client 改动可硬刷新)。切回 npm 通道时,把依赖改回 `"dsh-better-sidebar": "^0.10.1"` 再 `pnpm install`。
|
||||||
|
|
||||||
</details>
|
</details>
|
||||||
|
|
||||||
|
|||||||
+15
-3
@@ -35,10 +35,22 @@ https://github.com/user-attachments/assets/23187822-047e-45cc-b480-fe997bd55b86
|
|||||||
|
|
||||||
## 🚀 Installation
|
## 🚀 Installation
|
||||||
|
|
||||||
Prerequisites: DSH installed (`dsh web` works), Node.js ≥ 20, pnpm ≥ 10. The plugin is published to npm as **`dsh-better-sidebar@0.10.0`** (`@deepseek-ai/*` peers aligned with the host's actual versions `^0.1.0-rc.6` / `@deepseek-ai/cordis@^4.0.1`, single instance). Mounting still goes through the profile + `cordis.patch.yml`; the dependency source is the npm package:
|
Prerequisites: DSH installed (`dsh web` works), Node.js ≥ 20, pnpm ≥ 10. The plugin is published to npm as **`dsh-better-sidebar@0.10.1`** (`@deepseek-ai/*` peers aligned with the host's actual versions `^0.1.0-rc.6` / `@deepseek-ai/cordis@^4.0.1`, single instance). Mounting still goes through the profile + `cordis.patch.yml`; the DSH source is never modified.
|
||||||
|
|
||||||
|
### One-click install (recommended)
|
||||||
|
|
||||||
|
```sh
|
||||||
|
curl -fsSL https://raw.githubusercontent.com/omdsh-dev/DSH-better-sidebar/main/scripts/install.sh | bash
|
||||||
|
# Pick a version: curl -fsSL <same URL> | bash -s 0.10.1
|
||||||
|
# Auto-restart DSH: curl -fsSL <same URL> | bash -s -- --restart
|
||||||
|
```
|
||||||
|
|
||||||
|
The script registers the npm dependency in `~/.dsh/profiles/web/package.json`, idempotently appends the `cordis.patch.yml` mount line, and runs `pnpm install` (version defaults to latest, pass one as an argument; `--dry-run` previews without writing anything).
|
||||||
|
|
||||||
|
### Manual install (npm package)
|
||||||
|
|
||||||
```text
|
```text
|
||||||
1. In ~/.dsh/profiles/web/package.json dependencies add "dsh-better-sidebar": "^0.10.0"
|
1. In ~/.dsh/profiles/web/package.json dependencies add "dsh-better-sidebar": "^0.10.1"
|
||||||
2. Append the mount line to ~/.dsh/profiles/web/cordis.patch.yml:
|
2. Append the mount line to ~/.dsh/profiles/web/cordis.patch.yml:
|
||||||
- insert:
|
- insert:
|
||||||
- id: better-sidebar
|
- id: better-sidebar
|
||||||
@@ -73,7 +85,7 @@ To debug local changes or track the dev branch, point the dependency at a local
|
|||||||
5. Restart DSH and hard-refresh
|
5. Restart DSH and hard-refresh
|
||||||
```
|
```
|
||||||
|
|
||||||
Update: `git pull && pnpm install && pnpm build` → restart DSH (client-only changes can just hard-refresh). To switch back to the npm channel, restore `"dsh-better-sidebar": "^0.10.0"` and re-run `pnpm install`.
|
Update: `git pull && pnpm install && pnpm build` → restart DSH (client-only changes can just hard-refresh). To switch back to the npm channel, restore `"dsh-better-sidebar": "^0.10.1"` and re-run `pnpm install`.
|
||||||
|
|
||||||
</details>
|
</details>
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"id": "dsh-external/dsh-better-sidebar",
|
"id": "dsh-external/dsh-better-sidebar",
|
||||||
"version": "0.10.0",
|
"version": "0.10.1",
|
||||||
"main": "./lib/index.js",
|
"main": "./lib/index.js",
|
||||||
"description": "VSCode 风格右侧侧边栏:文件资源管理器 / 编辑器 / 终端 / Git / 浏览器,按会话隔离。暴露服务供其他插件注册侧边栏页面和文件预览器",
|
"description": "VSCode 风格右侧侧边栏:文件资源管理器 / 编辑器 / 终端 / Git / 浏览器,按会话隔离。暴露服务供其他插件注册侧边栏页面和文件预览器",
|
||||||
"engines": {
|
"engines": {
|
||||||
|
|||||||
+2
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "dsh-better-sidebar",
|
"name": "dsh-better-sidebar",
|
||||||
"version": "0.10.0",
|
"version": "0.10.1",
|
||||||
"description": "DSH web plugin: a VSCode-like right sidebar (explorer / editor / terminal / git / browser), isolated per conversation session. Exposes a service for other plugins to register sidebar tabs and file viewers.",
|
"description": "DSH web plugin: a VSCode-like right sidebar (explorer / editor / terminal / git / browser), isolated per conversation session. Exposes a service for other plugins to register sidebar tabs and file viewers.",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"repository": {
|
"repository": {
|
||||||
@@ -62,6 +62,7 @@
|
|||||||
"lib/client-editor.js",
|
"lib/client-editor.js",
|
||||||
"lib/types/**/*.d.ts",
|
"lib/types/**/*.d.ts",
|
||||||
"src",
|
"src",
|
||||||
|
"scripts/install.sh",
|
||||||
"README.md",
|
"README.md",
|
||||||
"README_EN.md",
|
"README_EN.md",
|
||||||
"LICENSE"
|
"LICENSE"
|
||||||
|
|||||||
Executable
+135
@@ -0,0 +1,135 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
# =============================================================================
|
||||||
|
# dsh-better-sidebar 一键安装脚本(npm 包方式)
|
||||||
|
#
|
||||||
|
# 把插件以 npm 包形式装进 DSH 的 web profile(挂载仍走 cordis.patch.yml,
|
||||||
|
# 符合仓库硬约束:不修改 DSH 源码,插件永远作为独立包被 profile 引用)。
|
||||||
|
#
|
||||||
|
# 用法:
|
||||||
|
# bash scripts/install.sh [版本] [--restart] [--dry-run]
|
||||||
|
#
|
||||||
|
# 版本 npm 版本号/范围,缺省为 latest(自动解析为 ^<最新>)。
|
||||||
|
# 示例:0.10.1、^0.10.1、~0.10.1、latest
|
||||||
|
# --restart 装完后尝试 `pm2 restart dsh-web`(无 pm2 时仅打印提示)。
|
||||||
|
# 注意:重启会断开当前 DSH 页面会话,默认不自动重启。
|
||||||
|
# --dry-run 只打印将要执行的操作,不写任何文件。
|
||||||
|
#
|
||||||
|
# 环境:
|
||||||
|
# DSH_HOME 默认 ~/.dsh
|
||||||
|
# REGISTRY 默认 https://registry.npmjs.org(发布源;装依赖仍走 pnpm 配置)
|
||||||
|
#
|
||||||
|
# 幂等:依赖已存在且版本满足 → 跳过写入;cordis.patch.yml 已含挂载行 → 不重复追加。
|
||||||
|
# 回滚:把 profile package.json 的依赖改回 "dsh-better-sidebar": "link:<路径>" 再 pnpm install。
|
||||||
|
# =============================================================================
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
DSH_HOME="${DSH_HOME:-$HOME/.dsh}"
|
||||||
|
PROFILE_DIR="$DSH_HOME/profiles/web"
|
||||||
|
PKG_JSON="$PROFILE_DIR/package.json"
|
||||||
|
PATCH_YML="$PROFILE_DIR/cordis.patch.yml"
|
||||||
|
REGISTRY="${REGISTRY:-https://registry.npmjs.org}"
|
||||||
|
PKG="dsh-better-sidebar"
|
||||||
|
|
||||||
|
RESTART=false
|
||||||
|
DRY_RUN=false
|
||||||
|
VERSION_SPEC=""
|
||||||
|
for arg in "$@"; do
|
||||||
|
case "$arg" in
|
||||||
|
--restart) RESTART=true ;;
|
||||||
|
--dry-run) DRY_RUN=true ;;
|
||||||
|
-*) echo "未知参数: $arg" >&2; exit 2 ;;
|
||||||
|
*) VERSION_SPEC="$arg" ;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
say() { printf '\033[32m[install]\033[0m %s\n' "$*"; }
|
||||||
|
warn() { printf '\033[33m[warn]\033[0m %s\n' "$*" >&2; }
|
||||||
|
die() { printf '\033[31m[error]\033[0m %s\n' "$*" >&2; exit 1; }
|
||||||
|
|
||||||
|
# 解析用户给的版本 -> package.json 里要写的 spec("^x.y.z")
|
||||||
|
resolve_spec() {
|
||||||
|
local given="${1:-latest}"
|
||||||
|
case "$given" in
|
||||||
|
latest)
|
||||||
|
local v
|
||||||
|
v="$(npm view "$PKG" version --registry="$REGISTRY" 2>/dev/null)" \
|
||||||
|
|| die "无法从 $REGISTRY 解析 $PKG 的最新版本(请检查网络/登录)。可显式传版本号:bash scripts/install.sh 0.10.1"
|
||||||
|
printf '^%s' "$v"
|
||||||
|
;;
|
||||||
|
^*|~*) printf '%s' "$given" ;;
|
||||||
|
*) printf '^%s' "$given" ;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
[ -d "$PROFILE_DIR" ] || die "找不到 profile 目录:${PROFILE_DIR}(请先安装并运行过一次 dsh web)"
|
||||||
|
[ -f "$PKG_JSON" ] || die "找不到 $PKG_JSON"
|
||||||
|
[ -f "$PATCH_YML" ] || die "找不到 ${PATCH_YML}(请先初始化 web profile)"
|
||||||
|
|
||||||
|
SPEC="$(resolve_spec "$VERSION_SPEC")"
|
||||||
|
say "目标依赖:\"$PKG\": \"$SPEC\"(profile: ${PROFILE_DIR})"
|
||||||
|
|
||||||
|
if [ "$DRY_RUN" = true ]; then
|
||||||
|
say "[dry-run] 步骤 1:更新 $PKG_JSON 的 dependencies[\"$PKG\"] = \"$SPEC\""
|
||||||
|
say "[dry-run] 步骤 2:确保 $PATCH_YML 含挂载行(- insert: - id: better-sidebar)"
|
||||||
|
say "[dry-run] 步骤 3:在 $PROFILE_DIR 执行 pnpm install"
|
||||||
|
if [ "$RESTART" = true ]; then say "[dry-run] 步骤 4:pm2 restart dsh-web"; else say "[dry-run] 步骤 4:提示用户手动重启 DSH"; fi
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 步骤 1:写依赖(用 node 安全改 JSON,保留其余字段;替换已存在的 link:/旧版本条目)
|
||||||
|
node -e '
|
||||||
|
const fs = require("fs");
|
||||||
|
const pkgJson = process.argv[1];
|
||||||
|
const name = process.argv[2];
|
||||||
|
const spec = process.argv[3];
|
||||||
|
const p = JSON.parse(fs.readFileSync(pkgJson, "utf8"));
|
||||||
|
p.dependencies = p.dependencies || {};
|
||||||
|
const old = p.dependencies[name];
|
||||||
|
if (old === spec) {
|
||||||
|
console.log("unchanged");
|
||||||
|
} else {
|
||||||
|
p.dependencies[name] = spec;
|
||||||
|
fs.writeFileSync(pkgJson, JSON.stringify(p, null, 2) + "\n");
|
||||||
|
console.log(old === undefined ? `added ${name}@${spec}` : `replaced ${name}@${old} -> ${name}@${spec}`);
|
||||||
|
}
|
||||||
|
' "$PKG_JSON" "$PKG" "$SPEC"
|
||||||
|
|
||||||
|
# 步骤 2:确保 cordis.patch.yml 挂载行存在(幂等追加)
|
||||||
|
if grep -qE '^\s*- id: better-sidebar\b' "$PATCH_YML"; then
|
||||||
|
say "挂载行已存在,跳过 cordis.patch.yml"
|
||||||
|
else
|
||||||
|
# 确保文件末尾有换行
|
||||||
|
[ -n "$(tail -c1 "$PATCH_YML" 2>/dev/null)" ] && printf '\n' >> "$PATCH_YML"
|
||||||
|
cat >> "$PATCH_YML" <<'YAML'
|
||||||
|
|
||||||
|
# dsh-better-sidebar mount (added by scripts/install.sh)
|
||||||
|
- insert:
|
||||||
|
- id: better-sidebar
|
||||||
|
name: 'dsh-better-sidebar'
|
||||||
|
YAML
|
||||||
|
say "已追加挂载行到 cordis.patch.yml"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 步骤 3:安装
|
||||||
|
say "执行 pnpm install(${PROFILE_DIR})..."
|
||||||
|
if ! (cd "$PROFILE_DIR" && pnpm install); then
|
||||||
|
warn "pnpm install 失败。若提示 minimumReleaseAge(新版本发布 <24h),pnpm 通常会自动写入 minimumReleaseAgeExclude 并重试;"
|
||||||
|
warn "仍失败可尝试:cd $PROFILE_DIR && pnpm clean --lockfile && pnpm install"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
say "安装完成:$PKG@$SPEC"
|
||||||
|
|
||||||
|
# 步骤 4:重启提示
|
||||||
|
if [ "$RESTART" = true ]; then
|
||||||
|
if command -v pm2 >/dev/null 2>&1; then
|
||||||
|
say "重启 dsh-web(pm2)..."
|
||||||
|
pm2 restart dsh-web || warn "pm2 restart 失败,请手动重启 DSH"
|
||||||
|
else
|
||||||
|
warn "未找到 pm2,请手动重启 DSH(如:pm2 restart dsh-web 或 dsh web)"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
say "下一步:重启 DSH 并硬刷新(Cmd/Ctrl+Shift+R)使新副本生效。"
|
||||||
|
if command -v pm2 >/dev/null 2>&1; then
|
||||||
|
say "本机可用:pm2 restart dsh-web(会短暂断开当前页面会话)"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
Reference in new issue
Block a user