@ziniao-open/cli 0.1.0-beta.95 → 0.1.0-beta.98
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 -0
- package/package.json +1 -1
- package/scripts/setup-ziniao-cli.ps1 +18 -0
- package/scripts/setup-ziniao-cli.sh +40 -0
package/README.md
CHANGED
|
@@ -36,6 +36,8 @@ ziniao-cli doctor fix-path
|
|
|
36
36
|
```
|
|
37
37
|
|
|
38
38
|
脚本只探测 `ziniao.app` / `ziniao` 的安装目录;Windows 会优先查询卸载注册表中 `DisplayIcon` 包含 `ziniao.exe` 的条目,再从本体目录的 `resources/app.asar.unpacked/envkit/cli` 查找 CLI。Windows 使用 `%APPDATA%\ziniaobrowser\cli`,macOS/Linux 使用 `~/.local/bin`,在目标目录缺少 CLI 或文件内容发生变化时同步最新文件,并注册当前用户 PATH。找不到源文件时只提示并继续,不阻断 PATH 配置。若安装目录无法自动探测,可设置 `ZINIAO_INSTALL_DIR`;若目标位置不同,可设置 `ZINIAO_APP_CACHE_DIR`。
|
|
39
|
+
Windows 同时会把找到的紫鸟本体绝对路径写入 `%APPDATA%\ziniaobrowser\gui-path`,供 CLI 定位桌面客户端。
|
|
40
|
+
macOS/Linux 也会在找到桌面本体时写入对应的 `gui-path`(macOS 为 `~/Library/Application Support/ziniao/gui-path`,Linux 为 `${XDG_CONFIG_HOME:-~/.config}/ziniao/gui-path`)。
|
|
39
41
|
|
|
40
42
|
安装时会自动下载当前平台对应的预编译二进制(支持 macOS / Linux / Windows × amd64 / arm64),并做 SHA-256 校验。
|
|
41
43
|
|
package/package.json
CHANGED
|
@@ -26,6 +26,7 @@ $sourceRelative = Join-Path "envkit\cli\win32\$archDir" $sourceName
|
|
|
26
26
|
$resourceRoot = "resources\app.asar.unpacked"
|
|
27
27
|
|
|
28
28
|
$sourcePath = $null
|
|
29
|
+
$guiExecutablePath = $null
|
|
29
30
|
$checkedSourcePaths = @()
|
|
30
31
|
if ($env:ZINIAO_CLI_SOURCE -and (Test-Path -LiteralPath $env:ZINIAO_CLI_SOURCE -PathType Leaf)) {
|
|
31
32
|
$sourcePath = $env:ZINIAO_CLI_SOURCE
|
|
@@ -54,6 +55,8 @@ if (-not $sourcePath) {
|
|
|
54
55
|
} else {
|
|
55
56
|
continue
|
|
56
57
|
}
|
|
58
|
+
if (-not (Test-Path -LiteralPath $executablePath -PathType Leaf)) { continue }
|
|
59
|
+
$guiExecutablePath = $executablePath
|
|
57
60
|
$installDir = Split-Path -Parent $executablePath
|
|
58
61
|
$candidate = Join-Path $installDir "$resourceRoot\$sourceRelative"
|
|
59
62
|
$checkedSourcePaths += $candidate
|
|
@@ -75,6 +78,21 @@ $targetDir = Join-Path $appCacheDir "cli"
|
|
|
75
78
|
$targetPath = Join-Path $targetDir $sourceName
|
|
76
79
|
New-Item -ItemType Directory -Path $targetDir -Force | Out-Null
|
|
77
80
|
|
|
81
|
+
if ($guiExecutablePath) {
|
|
82
|
+
$guiPathFile = Join-Path $env:APPDATA "ziniaobrowser\gui-path"
|
|
83
|
+
try {
|
|
84
|
+
New-Item -ItemType Directory -Path (Split-Path -Parent $guiPathFile) -Force | Out-Null
|
|
85
|
+
[System.IO.File]::WriteAllText(
|
|
86
|
+
$guiPathFile,
|
|
87
|
+
"$guiExecutablePath$([Environment]::NewLine)",
|
|
88
|
+
[System.Text.Encoding]::ASCII
|
|
89
|
+
)
|
|
90
|
+
Write-Log "Wrote GUI path hint: $guiPathFile"
|
|
91
|
+
} catch {
|
|
92
|
+
Write-Log "WARN: Could not write GUI path hint: $($_.Exception.Message)"
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
78
96
|
function Get-FileSha256([string]$Path) {
|
|
79
97
|
$sha256 = [System.Security.Cryptography.SHA256]::Create()
|
|
80
98
|
$stream = [System.IO.File]::OpenRead($Path)
|
|
@@ -82,6 +82,30 @@ find_source() {
|
|
|
82
82
|
return 1
|
|
83
83
|
}
|
|
84
84
|
|
|
85
|
+
find_gui_executable() {
|
|
86
|
+
case "$platform_dir" in
|
|
87
|
+
darwin)
|
|
88
|
+
for candidate in \
|
|
89
|
+
"/Applications/ziniao.app/Contents/MacOS/ziniaobrowser" \
|
|
90
|
+
"/Applications/ziniao.app/Contents/MacOS/ziniao" \
|
|
91
|
+
"$home_dir/Applications/ziniao.app/Contents/MacOS/ziniaobrowser" \
|
|
92
|
+
"$home_dir/Applications/ziniao.app/Contents/MacOS/ziniao"; do
|
|
93
|
+
[ -f "$candidate" ] && { printf '%s\n' "$candidate"; return 0; }
|
|
94
|
+
done
|
|
95
|
+
;;
|
|
96
|
+
linux)
|
|
97
|
+
for candidate in \
|
|
98
|
+
"/opt/ziniao/ziniaobrowser" \
|
|
99
|
+
"/opt/ziniao/ziniao" \
|
|
100
|
+
"/usr/lib/ziniaobrowser/ziniaobrowser" \
|
|
101
|
+
"/usr/lib/ziniaobrowser/ziniao"; do
|
|
102
|
+
[ -f "$candidate" ] && { printf '%s\n' "$candidate"; return 0; }
|
|
103
|
+
done
|
|
104
|
+
;;
|
|
105
|
+
esac
|
|
106
|
+
return 1
|
|
107
|
+
}
|
|
108
|
+
|
|
85
109
|
if [ -n "${ZINIAO_APP_CACHE_DIR:-}" ]; then
|
|
86
110
|
target_dir="$ZINIAO_APP_CACHE_DIR/cli"
|
|
87
111
|
else
|
|
@@ -90,8 +114,24 @@ else
|
|
|
90
114
|
fi
|
|
91
115
|
|
|
92
116
|
source_path="$(find_source || true)"
|
|
117
|
+
gui_executable_path="$(find_gui_executable || true)"
|
|
93
118
|
target_path="$target_dir/$source_name"
|
|
94
119
|
mkdir -p "$target_dir"
|
|
120
|
+
|
|
121
|
+
if [ -n "$gui_executable_path" ]; then
|
|
122
|
+
case "$platform_dir" in
|
|
123
|
+
darwin) gui_path_file="$home_dir/Library/Application Support/ziniao/gui-path" ;;
|
|
124
|
+
*)
|
|
125
|
+
xdg_config_home="${XDG_CONFIG_HOME:-$home_dir/.config}"
|
|
126
|
+
gui_path_file="$xdg_config_home/ziniao/gui-path"
|
|
127
|
+
;;
|
|
128
|
+
esac
|
|
129
|
+
if mkdir -p "$(dirname "$gui_path_file")" && printf '%s\n' "$gui_executable_path" > "$gui_path_file"; then
|
|
130
|
+
log "已写入 GUI 路径提示: $gui_path_file"
|
|
131
|
+
else
|
|
132
|
+
log "WARN: 无法写入 GUI 路径提示: $gui_path_file"
|
|
133
|
+
fi
|
|
134
|
+
fi
|
|
95
135
|
if [ -z "$source_path" ]; then
|
|
96
136
|
if [ -f "$target_path" ]; then
|
|
97
137
|
log "未找到安装目录中的 CLI 源文件,保留现有 AppCache CLI: $target_path"
|