Skip to content

Commit 6465c4a

Browse files
committed
feat: install shell test
1 parent ebbd173 commit 6465c4a

8 files changed

Lines changed: 421 additions & 13 deletions

File tree

INSTALL.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,15 @@
55
## 1. 推荐:二进制安装(无需 Node)
66

77
```bash
8-
curl -fsSL https://bailian-cli.oss-cn-hangzhou.aliyuncs.com/bailian-cli/install.sh | bash
8+
curl -fsSL https://bailian-wiki.oss-cn-hangzhou.aliyuncs.com/release/install.sh | bash
99
```
1010

11+
可选:`BAILIAN_CHANNEL`(默认 `latest`)、`BAILIAN_VERSION`(钉版本)、`BAILIAN_CLI_CDN`(覆盖 CDN 根)。
12+
1113
Windows PowerShell:
1214

1315
```powershell
14-
irm https://bailian-cli.oss-cn-hangzhou.aliyuncs.com/bailian-cli/install.ps1 | iex
16+
irm https://bailian-wiki.oss-cn-hangzhou.aliyuncs.com/release/install.ps1 | iex
1517
```
1618

1719
校验:

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,10 @@ No timeline scrubbing. No frame-by-frame editing. Just one sentence → one vide
7878

7979
```bash
8080
# Recommended — no Node required
81-
curl -fsSL https://bailian-cli.oss-cn-hangzhou.aliyuncs.com/bailian-cli/install.sh | bash
81+
curl -fsSL https://bailian-wiki.oss-cn-hangzhou.aliyuncs.com/release/install.sh | bash
8282

8383
# Windows (PowerShell)
84-
irm https://bailian-cli.oss-cn-hangzhou.aliyuncs.com/bailian-cli/install.ps1 | iex
84+
irm https://bailian-wiki.oss-cn-hangzhou.aliyuncs.com/release/install.ps1 | iex
8585

8686
# Node users / developers (Node.js >= 18.17)
8787
npm install -g bailian-cli

README.zh.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,10 @@ _专为 AI Agent 打造,每个命令均可作为结构化工具调用。_
7676

7777
```bash
7878
# 推荐 — 无需本机 Node.js
79-
curl -fsSL https://bailian-cli.oss-cn-hangzhou.aliyuncs.com/bailian-cli/install.sh | bash
79+
curl -fsSL https://bailian-wiki.oss-cn-hangzhou.aliyuncs.com/release/install.sh | bash
8080

8181
# Windows(PowerShell)
82-
irm https://bailian-cli.oss-cn-hangzhou.aliyuncs.com/bailian-cli/install.ps1 | iex
82+
irm https://bailian-wiki.oss-cn-hangzhou.aliyuncs.com/release/install.ps1 | iex
8383

8484
# Node 用户 / 开发者(需要 Node.js >= 18.17)
8585
npm install -g bailian-cli

docs/agents/publish.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ publish-stable.mjs / publish-channel.mjs ← 唯一发版入口
1919
└─ binary(lib/binary-release
2020
→ binary-build
2121
→ gh-release
22-
→ oss-sync-webhook
22+
→ oss-direct-upload
2323
```
2424

25-
`tools/release/lib/binary-release.mjs` 等是实现,一般不要单独当发版入口(调试可用)。详细约定见 [binary-distribution](binary-distribution.md)
25+
`tools/release/lib/binary-release.mjs` 等是实现,一般不要单独当发版入口(调试可用)。
2626

2727
两种模式:
2828

@@ -108,7 +108,7 @@ node tools/release/publish-channel.mjs --channel test --knowledge --dry-run
108108

109109
- [ ] 验证 npm 上能装:`npm view bailian-cli@<tag> version`;如发布 `knowledge-studio-cli`,同时 `npm view knowledge-studio-cli@<tag> version`
110110
- [ ] 试装一次:`npm i -g bailian-cli@<tag> && bl --version`;如发布 `knowledge-studio-cli`,同时 `npm i -g knowledge-studio-cli@<tag> && kscli --version`
111-
- [ ] (若本次含二进制)GitHub Release 可见 `bl-*.zip` + `SHA256SUMS`;OSS 侧 `channels/latest.json` install 脚本由 FC/仓外维护;清单见 [binary-distribution.md](binary-distribution.md)
111+
- [ ] (若本次含二进制)GitHub Release 可见 `bl-*.zip` + `SHA256SUMS`;OSS 侧 `latest.json` / `<channel>.json``v<ver>/*``install.sh`/`install.ps1` 已由 CI 直传
112112

113113
## 常见漏点(基于历史踩坑)
114114

packages/cli/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,10 @@ No timeline scrubbing. No frame-by-frame editing. Just one sentence → one vide
7878

7979
```bash
8080
# Recommended — no Node required
81-
curl -fsSL https://bailian-cli.oss-cn-hangzhou.aliyuncs.com/bailian-cli/install.sh | bash
81+
curl -fsSL https://bailian-wiki.oss-cn-hangzhou.aliyuncs.com/release/install.sh | bash
8282

8383
# Windows (PowerShell)
84-
irm https://bailian-cli.oss-cn-hangzhou.aliyuncs.com/bailian-cli/install.ps1 | iex
84+
irm https://bailian-wiki.oss-cn-hangzhou.aliyuncs.com/release/install.ps1 | iex
8585

8686
# Node users / developers (Node.js >= 18.17)
8787
npm install -g bailian-cli

packages/cli/README.zh.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,10 @@ _专为 AI Agent 打造,每个命令均可作为结构化工具调用。_
7676

7777
```bash
7878
# 推荐 — 无需本机 Node.js
79-
curl -fsSL https://bailian-cli.oss-cn-hangzhou.aliyuncs.com/bailian-cli/install.sh | bash
79+
curl -fsSL https://bailian-wiki.oss-cn-hangzhou.aliyuncs.com/release/install.sh | bash
8080

8181
# Windows(PowerShell)
82-
irm https://bailian-cli.oss-cn-hangzhou.aliyuncs.com/bailian-cli/install.ps1 | iex
82+
irm https://bailian-wiki.oss-cn-hangzhou.aliyuncs.com/release/install.ps1 | iex
8383

8484
# Node 用户 / 开发者(需要 Node.js >= 18.17)
8585
npm install -g bailian-cli

packaging/install.ps1

Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
# Binary install script for the OSS release layout (see packages/core/src/install/cdn.ts).
2+
#
3+
# irm https://bailian-wiki.oss-cn-hangzhou.aliyuncs.com/release/install.ps1 | iex
4+
# $env:BAILIAN_CHANNEL = "sync-release"; irm ... | iex
5+
# $env:BAILIAN_VERSION = "1.10.1"; irm ... | iex
6+
#
7+
# Layout:
8+
# {CDN}/{channel}.json — rolling manifest (version + assets)
9+
# {CDN}/v{version}/{file}.zip — per-platform zip
10+
param()
11+
12+
$ErrorActionPreference = "Stop"
13+
14+
$CdnBase = if ($env:BAILIAN_CLI_CDN) { $env:BAILIAN_CLI_CDN.TrimEnd("/") } else { "https://bailian-wiki.oss-cn-hangzhou.aliyuncs.com/release" }
15+
$Channel = if ($env:BAILIAN_CHANNEL) { $env:BAILIAN_CHANNEL } else { "latest" }
16+
$Version = $env:BAILIAN_VERSION
17+
$InstallRoot = if ($env:BAILIAN_SHARE_DIR) { $env:BAILIAN_SHARE_DIR } else { Join-Path $env:LOCALAPPDATA "bailian-cli" }
18+
$ConfigDir = if ($env:BAILIAN_CONFIG_DIR) { $env:BAILIAN_CONFIG_DIR } else { Join-Path $env:USERPROFILE ".bailian" }
19+
20+
function Write-Log([string]$Message) {
21+
[Console]::Error.WriteLine($Message)
22+
}
23+
24+
function Get-VersionTag([string]$Ver) {
25+
if ($Ver.StartsWith("v")) { return $Ver }
26+
return "v$Ver"
27+
}
28+
29+
$Arch = if ($env:PROCESSOR_ARCHITECTURE -eq "ARM64") { "arm64" } else { "x64" }
30+
if ($Arch -eq "arm64") {
31+
throw "windows arm64 is not supported for binary install; use: npm install -g bailian-cli"
32+
}
33+
$PlatformKey = "windows-$Arch"
34+
35+
$ManifestUrl = "$CdnBase/$Channel.json"
36+
Write-Log "Fetching $ManifestUrl"
37+
$Manifest = Invoke-RestMethod -Uri $ManifestUrl
38+
39+
$PinnedVersion = $Version
40+
if ([string]::IsNullOrWhiteSpace($Version)) {
41+
$Version = $Manifest.version
42+
}
43+
if ([string]::IsNullOrWhiteSpace($Version)) {
44+
throw "Could not parse version from $Channel channel manifest"
45+
}
46+
47+
$ZipFile = $null
48+
$ExpectedSha = $null
49+
$InnerName = $null
50+
$AssetMeta = $null
51+
if ($Manifest.assets -and $Manifest.assets.$PlatformKey) {
52+
$AssetMeta = $Manifest.assets.$PlatformKey
53+
}
54+
55+
$UseManifestAsset = $AssetMeta -and (
56+
[string]::IsNullOrWhiteSpace($PinnedVersion) -or ($PinnedVersion -eq $Manifest.version)
57+
)
58+
59+
if ($UseManifestAsset) {
60+
$ZipFile = $AssetMeta.file
61+
$ExpectedSha = $AssetMeta.sha256
62+
$InnerName = $AssetMeta.inner
63+
} else {
64+
$ZipFile = "bl-$Version-$PlatformKey.zip"
65+
$InnerName = "bl-$Version-$PlatformKey.exe"
66+
}
67+
68+
if ([string]::IsNullOrWhiteSpace($ZipFile) -or [string]::IsNullOrWhiteSpace($InnerName)) {
69+
throw "Manifest missing asset metadata for $PlatformKey"
70+
}
71+
72+
$Tag = Get-VersionTag $Version
73+
$Url = "$CdnBase/$Tag/$ZipFile"
74+
$TempDir = Join-Path ([System.IO.Path]::GetTempPath()) ("bailian-cli-install-" + [guid]::NewGuid().ToString("N"))
75+
New-Item -ItemType Directory -Path $TempDir | Out-Null
76+
77+
try {
78+
$ZipPath = Join-Path $TempDir $ZipFile
79+
Write-Log "Downloading $ZipFile"
80+
Invoke-WebRequest -Uri $Url -OutFile $ZipPath
81+
82+
$Actual = (Get-FileHash -Algorithm SHA256 -Path $ZipPath).Hash.ToLowerInvariant()
83+
if (-not [string]::IsNullOrWhiteSpace($ExpectedSha)) {
84+
if ($ExpectedSha.ToLowerInvariant() -ne $Actual) {
85+
throw "Checksum mismatch for $ZipFile"
86+
}
87+
} else {
88+
$SumsUrl = "$CdnBase/$Tag/SHA256SUMS"
89+
$SumsPath = Join-Path $TempDir "SHA256SUMS"
90+
Invoke-WebRequest -Uri $SumsUrl -OutFile $SumsPath
91+
$Expected = $null
92+
Get-Content $SumsPath | ForEach-Object {
93+
if ($_ -match "^([a-fA-F0-9]+)\s+$([regex]::Escape($ZipFile))\s*$") {
94+
$Expected = $Matches[1].ToLowerInvariant()
95+
}
96+
}
97+
if (-not $Expected) { throw "Checksum for $ZipFile not found in SHA256SUMS" }
98+
if ($Expected -ne $Actual) { throw "Checksum mismatch for $ZipFile" }
99+
}
100+
101+
Write-Log "Extracting $InnerName"
102+
Expand-Archive -Path $ZipPath -DestinationPath $TempDir -Force
103+
$ExtractPath = Join-Path $TempDir $InnerName
104+
if (-not (Test-Path -LiteralPath $ExtractPath)) {
105+
# Some Expand-Archive versions nest a single top-level folder.
106+
$Found = Get-ChildItem -Path $TempDir -Recurse -File | Where-Object { $_.Name -eq $InnerName } | Select-Object -First 1
107+
if (-not $Found) { throw "Extracted binary missing: $InnerName" }
108+
$ExtractPath = $Found.FullName
109+
}
110+
111+
$VersionDir = Join-Path $InstallRoot "versions\$Version"
112+
New-Item -ItemType Directory -Force -Path $VersionDir | Out-Null
113+
New-Item -ItemType Directory -Force -Path $ConfigDir | Out-Null
114+
$Target = Join-Path $VersionDir "bl.exe"
115+
Copy-Item -Force $ExtractPath $Target
116+
117+
$ShimDir = Join-Path $InstallRoot "bin"
118+
New-Item -ItemType Directory -Force -Path $ShimDir | Out-Null
119+
Copy-Item -Force $Target (Join-Path $ShimDir "bl.exe")
120+
Copy-Item -Force $Target (Join-Path $ShimDir "bailian.exe")
121+
Set-Content -Path (Join-Path $ConfigDir "install-method") -Value "binary" -NoNewline
122+
123+
$UserPath = [Environment]::GetEnvironmentVariable("Path", "User")
124+
if (-not ($UserPath -split ";" | Where-Object { $_ -eq $ShimDir })) {
125+
[Environment]::SetEnvironmentVariable("Path", "$ShimDir;$UserPath", "User")
126+
Write-Log "Added $ShimDir to your user PATH. Open a new terminal to use bl."
127+
}
128+
129+
Write-Log "Installed: $Target (bailian-cli $Version) [$Channel]"
130+
Write-Log "Done. Run: bl --help"
131+
}
132+
finally {
133+
Remove-Item -Recurse -Force $TempDir -ErrorAction SilentlyContinue
134+
}

0 commit comments

Comments
 (0)