@ziniao-open/cli 0.1.0-beta.100 → 0.1.0-beta.103
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/README.md +2 -1
- package/package.json +1 -1
- package/scripts/remove-ziniao-cli-shims.sh +31 -1
- package/scripts/setup-ziniao-cli.sh +22 -2
package/README.md
CHANGED
|
@@ -28,7 +28,7 @@ Windows PowerShell 执行:
|
|
|
28
28
|
ziniao-cli doctor fix-path
|
|
29
29
|
```
|
|
30
30
|
|
|
31
|
-
遍历当前 PATH
|
|
31
|
+
遍历当前 PATH 清理旧的 `ziniao` shim,并清理 Unix 端的 `ziniaobrowser/cli` 缓存目录(默认只预览):
|
|
32
32
|
|
|
33
33
|
```powershell
|
|
34
34
|
& "$(npm root -g)\@ziniao-open\cli\scripts\remove-ziniao-cli-shims.ps1"
|
|
@@ -45,6 +45,7 @@ macOS/Linux:
|
|
|
45
45
|
脚本只探测 `ziniao.app` / `ziniao` 的安装目录;Windows 会优先查询卸载注册表中 `DisplayIcon` 包含 `ziniao.exe` 的条目,再从本体目录的 `resources/app.asar.unpacked/envkit/cli` 查找 CLI。Windows 使用 `%APPDATA%\ziniaobrowser\cli`,macOS 使用 `~/Library/Application Support/ziniaobrowser/cli`,Linux 使用 `${XDG_CONFIG_HOME:-~/.config}/ziniaobrowser/cli`,在目标目录缺少 CLI 或文件内容发生变化时同步最新文件,并注册当前用户 PATH。找不到源文件时只提示并继续,不阻断 PATH 配置。若安装目录无法自动探测,可设置 `ZINIAO_INSTALL_DIR`;若目标位置不同,可设置 `ZINIAO_APP_CACHE_DIR`。
|
|
46
46
|
Windows 同时会把找到的紫鸟本体绝对路径写入 `%APPDATA%\ziniaobrowser\gui-path`,供 CLI 定位桌面客户端。
|
|
47
47
|
macOS/Linux 也会在找到桌面本体时写入对应的 `gui-path`(macOS 为 `~/Library/Application Support/ziniaobrowser/gui-path`,Linux 为 `${XDG_CONFIG_HOME:-~/.config}/ziniaobrowser/gui-path`)。
|
|
48
|
+
macOS/Linux 还会在 `~/.local/bin/ziniao` 创建固定 shim,避免向随机 PATH 目录写入文件。
|
|
48
49
|
|
|
49
50
|
安装时会自动下载当前平台对应的预编译二进制(支持 macOS / Linux / Windows × amd64 / arm64),并做 SHA-256 校验。
|
|
50
51
|
|
package/package.json
CHANGED
|
@@ -45,7 +45,37 @@ for path_entry in ${PATH:-}; do
|
|
|
45
45
|
done
|
|
46
46
|
IFS="$old_ifs"
|
|
47
47
|
|
|
48
|
-
|
|
48
|
+
stable_shim="$home_dir/.local/bin/ziniao"
|
|
49
|
+
if [ -e "$stable_shim" ] || [ -L "$stable_shim" ]; then
|
|
50
|
+
if [ "$stable_shim" != "$target_dir/ziniao" ]; then
|
|
51
|
+
found=1
|
|
52
|
+
if [ "$apply" -eq 1 ]; then
|
|
53
|
+
rm -f -- "$stable_shim"
|
|
54
|
+
log "Removed: $stable_shim"
|
|
55
|
+
else
|
|
56
|
+
log "Would remove: $stable_shim"
|
|
57
|
+
fi
|
|
58
|
+
fi
|
|
59
|
+
fi
|
|
60
|
+
|
|
61
|
+
cache_found=0
|
|
62
|
+
if [ -d "$target_dir" ]; then
|
|
63
|
+
cache_found=1
|
|
64
|
+
if [ "$apply" -eq 1 ]; then
|
|
65
|
+
if [ -f "$target_dir/ziniao" ] || [ -L "$target_dir/ziniao" ]; then
|
|
66
|
+
rm -f -- "$target_dir/ziniao"
|
|
67
|
+
fi
|
|
68
|
+
if rmdir "$target_dir" 2>/dev/null; then
|
|
69
|
+
log "Removed CLI cache directory: $target_dir"
|
|
70
|
+
else
|
|
71
|
+
log "WARN: CLI cache directory is not empty; keeping it: $target_dir"
|
|
72
|
+
fi
|
|
73
|
+
else
|
|
74
|
+
log "Would remove CLI cache directory: $target_dir"
|
|
75
|
+
fi
|
|
76
|
+
fi
|
|
77
|
+
|
|
78
|
+
if [ "$found" -eq 0 ] && [ "$cache_found" -eq 0 ]; then
|
|
49
79
|
log "No ziniao shims found in PATH directories."
|
|
50
80
|
elif [ "$apply" -eq 0 ]; then
|
|
51
81
|
log "Preview only. Re-run with --apply to remove these files."
|
|
@@ -164,11 +164,30 @@ fi
|
|
|
164
164
|
shim_installed=0
|
|
165
165
|
install_path_shim() {
|
|
166
166
|
[ -f "$target_path" ] || return 0
|
|
167
|
+
shim_dir="$home_dir/.local/bin"
|
|
168
|
+
shim_path="$shim_dir/$source_name"
|
|
169
|
+
mkdir -p "$shim_dir"
|
|
170
|
+
if [ -L "$shim_path" ] && [ "$(readlink "$shim_path" 2>/dev/null || true)" = "$target_path" ]; then
|
|
171
|
+
shim_installed=1
|
|
172
|
+
log "The CLI shim already points to the AppCache CLI: $shim_path"
|
|
173
|
+
elif [ ! -e "$shim_path" ]; then
|
|
174
|
+
if ln -s "$target_path" "$shim_path" 2>/dev/null; then
|
|
175
|
+
shim_installed=1
|
|
176
|
+
log "Created the CLI shim: $shim_path"
|
|
177
|
+
else
|
|
178
|
+
log "WARN: Could not create the CLI shim: $shim_path"
|
|
179
|
+
fi
|
|
180
|
+
else
|
|
181
|
+
log "A file already exists at the CLI shim path; leaving it unchanged: $shim_path"
|
|
182
|
+
fi
|
|
167
183
|
case ":${PATH:-}:" in
|
|
168
184
|
*:"$target_dir":*)
|
|
169
185
|
shim_installed=1
|
|
170
186
|
log "The current PATH already contains the AppCache CLI directory: $target_dir"
|
|
171
187
|
;;
|
|
188
|
+
*:"$shim_dir":*)
|
|
189
|
+
[ "$shim_installed" -eq 1 ] && log "The current PATH contains the CLI shim directory: $shim_dir"
|
|
190
|
+
;;
|
|
172
191
|
*)
|
|
173
192
|
log "The AppCache CLI directory is not on the current PATH; no shim will be created elsewhere: $target_dir"
|
|
174
193
|
;;
|
|
@@ -177,7 +196,8 @@ install_path_shim() {
|
|
|
177
196
|
|
|
178
197
|
install_path_shim
|
|
179
198
|
|
|
180
|
-
|
|
199
|
+
shim_dir="$home_dir/.local/bin"
|
|
200
|
+
export PATH="$target_dir:$shim_dir${PATH:+:$PATH}"
|
|
181
201
|
|
|
182
202
|
profile=""
|
|
183
203
|
case "${SHELL:-}" in
|
|
@@ -192,7 +212,7 @@ if [ -z "$profile" ]; then
|
|
|
192
212
|
fi
|
|
193
213
|
|
|
194
214
|
marker="# ziniao-cli: AppCache CLI PATH"
|
|
195
|
-
path_line="export PATH=\"$target_dir:\$PATH\""
|
|
215
|
+
path_line="export PATH=\"$target_dir:$shim_dir:\$PATH\""
|
|
196
216
|
if ! grep -Fqx "$marker" "$profile" 2>/dev/null; then
|
|
197
217
|
mkdir -p "$(dirname "$profile")"
|
|
198
218
|
printf '\n%s\n' "$marker" >> "$profile"
|