Skip to content

Commit 871c667

Browse files
committed
docs: install shell md
1 parent af3286d commit 871c667

9 files changed

Lines changed: 130 additions & 47 deletions

File tree

INSTALL.md

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

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

11-
可选:`BAILIAN_CHANNEL`(默认 `latest`)、`BAILIAN_VERSION`钉版本)、`BAILIAN_CLI_CDN`(覆盖 CDN 根
11+
可选:默认读 `manifest.json`(正式版);`bash install.sh --channel sync-release` 读 channel 清单做验证;`--version` 钉版本`--cdn` / `BAILIAN_CLI_CDN` 覆盖资源 CDN 根。
1212

1313
Windows PowerShell:
1414

1515
```powershell
16-
irm https://bailian-wiki.oss-cn-hangzhou.aliyuncs.com/release/install.ps1 | iex
16+
irm https://bailian.aliyun.com/install.ps1 | iex
1717
```
1818

1919
校验:

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-wiki.oss-cn-hangzhou.aliyuncs.com/release/install.sh | bash
81+
curl -fsSL https://bailian.aliyun.com/install.sh | bash
8282

8383
# Windows (PowerShell)
84-
irm https://bailian-wiki.oss-cn-hangzhou.aliyuncs.com/release/install.ps1 | iex
84+
irm https://bailian.aliyun.com/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-wiki.oss-cn-hangzhou.aliyuncs.com/release/install.sh | bash
79+
curl -fsSL https://bailian.aliyun.com/install.sh | bash
8080

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

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

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-wiki.oss-cn-hangzhou.aliyuncs.com/release/install.sh | bash
81+
curl -fsSL https://bailian.aliyun.com/install.sh | bash
8282

8383
# Windows (PowerShell)
84-
irm https://bailian-wiki.oss-cn-hangzhou.aliyuncs.com/release/install.ps1 | iex
84+
irm https://bailian.aliyun.com/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-wiki.oss-cn-hangzhou.aliyuncs.com/release/install.sh | bash
79+
curl -fsSL https://bailian.aliyun.com/install.sh | bash
8080

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

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

packages/core/src/install/cdn.ts

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
*
66
* Layout under the base:
77
* v<version>/<asset>.zip —— immutable per-version binaries + SHA256SUMS
8-
* manifest.json —— stable pointer; same rolling-manifest shape as latest.json
9-
* latest.json —— stable rolling manifest (os-arch keyed, sha256)
10-
* <channel>.json —— per-channel rolling manifests (beta versions)
8+
* manifest.json —— stable install/update pointer (rolling-manifest shape)
9+
* latest.json —— stable alias; same body as manifest.json
10+
* <channel>.json —— per-channel rolling manifests (betas / local verify)
1111
*
1212
* Override with `BAILIAN_CLI_CDN`.
1313
*/
@@ -16,8 +16,9 @@ export const DEFAULT_CLI_CDN_BASE = "https://bailian-wiki.oss-cn-hangzhou.aliyun
1616
/** GitHub Releases base — used when writing manifests attached to gh release assets. */
1717
export const GITHUB_RELEASES_BASE = "https://github.com/modelstudioai/cli/releases";
1818

19-
export const DEFAULT_INSTALL_SCRIPT_URL = `${DEFAULT_CLI_CDN_BASE}/install.sh`;
20-
export const DEFAULT_INSTALL_PS1_URL = `${DEFAULT_CLI_CDN_BASE}/install.ps1`;
19+
/** User-facing install entry (docs / update hints); asset downloads still use getCliCdnBase(). */
20+
export const DEFAULT_INSTALL_SCRIPT_URL = "https://bailian.aliyun.com/install.sh";
21+
export const DEFAULT_INSTALL_PS1_URL = "https://bailian.aliyun.com/install.ps1";
2122

2223
export function getCliCdnBase(): string {
2324
const fromEnv = process.env.BAILIAN_CLI_CDN?.trim();
@@ -26,12 +27,17 @@ export function getCliCdnBase(): string {
2627
}
2728

2829
/**
29-
* Rolling channel manifest at the CDN base root: `{base}/{channel}.json`.
30-
* `latest.json` (stable) and `<channel>.json` (betas) share the same shape;
31-
* both are written by CI on publish.
30+
* Rolling manifest URL at the CDN base root.
31+
* Stable (`latest` / `stable` / empty) → `manifest.json`.
32+
* Named channel → `{channel}.json` (e.g. sync-release for local verify).
33+
* All share the same rolling-manifest shape from binary-build.
3234
*/
3335
export function channelManifestUrl(channel = "latest"): string {
34-
return `${getCliCdnBase()}/${channel}.json`;
36+
const normalized = channel.trim();
37+
if (!normalized || normalized === "latest" || normalized === "stable") {
38+
return `${getCliCdnBase()}/manifest.json`;
39+
}
40+
return `${getCliCdnBase()}/${normalized}.json`;
3541
}
3642

3743
/** Immutable per-version asset: `{base}/v{version}/{fileName}`. */

packages/core/tests/install-method.test.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,20 @@ test("binaryInnerFileName keeps exe suffix inside zip", () => {
3333
expect(binaryInnerFileName("1.2.3", "windows", "x64", true)).toBe("bl-1.2.3-windows-x64.exe");
3434
expect(binaryInnerFileName("1.2.3", "darwin", "arm64", false)).toBe("bl-1.2.3-darwin-arm64");
3535
});
36+
37+
test("channelManifestUrl maps stable to manifest.json", async () => {
38+
const { channelManifestUrl } = await import("../src/install/cdn.ts");
39+
const previous = process.env.BAILIAN_CLI_CDN;
40+
delete process.env.BAILIAN_CLI_CDN;
41+
expect(channelManifestUrl()).toBe(
42+
"https://bailian-wiki.oss-cn-hangzhou.aliyuncs.com/release/manifest.json",
43+
);
44+
expect(channelManifestUrl("latest")).toBe(
45+
"https://bailian-wiki.oss-cn-hangzhou.aliyuncs.com/release/manifest.json",
46+
);
47+
expect(channelManifestUrl("sync-release")).toBe(
48+
"https://bailian-wiki.oss-cn-hangzhou.aliyuncs.com/release/sync-release.json",
49+
);
50+
if (previous === undefined) delete process.env.BAILIAN_CLI_CDN;
51+
else process.env.BAILIAN_CLI_CDN = previous;
52+
});

packaging/install.ps1

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
1-
# Binary install script for the OSS release layout (see packages/core/src/install/cdn.ts).
1+
# Binary install script for the OSS release
22
#
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
3+
# irm https://bailian.aliyun.com/install.ps1 | iex
4+
# .\install.ps1 -Channel sync-release # local / channel verify
5+
# .\install.ps1 -Version 1.10.1
66
#
7-
# Layout:
8-
# {CDN}/{channel}.json — rolling manifest (version + assets)
9-
# {CDN}/v{version}/{file}.zip — per-platform zip
10-
param()
7+
param(
8+
[string]$Channel = $env:BAILIAN_CHANNEL,
9+
[string]$Version = $env:BAILIAN_VERSION,
10+
[string]$Cdn = $env:BAILIAN_CLI_CDN
11+
)
1112

1213
$ErrorActionPreference = "Stop"
1314

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
15+
$CdnBase = if ($Cdn) { $Cdn.TrimEnd("/") } else { "https://bailian-wiki.oss-cn-hangzhou.aliyuncs.com/release" }
1716
$InstallRoot = if ($env:BAILIAN_SHARE_DIR) { $env:BAILIAN_SHARE_DIR } else { Join-Path $env:LOCALAPPDATA "bailian-cli" }
1817
$ConfigDir = if ($env:BAILIAN_CONFIG_DIR) { $env:BAILIAN_CONFIG_DIR } else { Join-Path $env:USERPROFILE ".bailian" }
1918

@@ -32,7 +31,13 @@ if ($Arch -eq "arm64") {
3231
}
3332
$PlatformKey = "windows-$Arch"
3433

35-
$ManifestUrl = "$CdnBase/$Channel.json"
34+
if (-not [string]::IsNullOrWhiteSpace($Channel) -and $Channel -ne "latest" -and $Channel -ne "stable") {
35+
$ManifestLabel = "$Channel.json"
36+
$ManifestUrl = "$CdnBase/$Channel.json"
37+
} else {
38+
$ManifestLabel = "manifest.json"
39+
$ManifestUrl = "$CdnBase/manifest.json"
40+
}
3641
Write-Log "Fetching $ManifestUrl"
3742
$Manifest = Invoke-RestMethod -Uri $ManifestUrl
3843

@@ -41,7 +46,7 @@ if ([string]::IsNullOrWhiteSpace($Version)) {
4146
$Version = $Manifest.version
4247
}
4348
if ([string]::IsNullOrWhiteSpace($Version)) {
44-
throw "Could not parse version from $Channel channel manifest"
49+
throw "Could not parse version from $ManifestLabel"
4550
}
4651

4752
$ZipFile = $null
@@ -126,7 +131,7 @@ try {
126131
Write-Log "Added $ShimDir to your user PATH. Open a new terminal to use bl."
127132
}
128133

129-
Write-Log "Installed: $Target (bailian-cli $Version) [$Channel]"
134+
Write-Log "Installed: $Target (bailian-cli $Version) [$ManifestLabel]"
130135
Write-Log "Done. Run: bl --help"
131136
}
132137
finally {

packaging/install.sh

Lines changed: 68 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,16 @@
11
#!/usr/bin/env bash
2-
# Binary install script for the OSS release layout (see packages/core/src/install/cdn.ts).
2+
# Binary install script for the OSS release
33
#
4-
# curl -fsSL https://bailian-wiki.oss-cn-hangzhou.aliyuncs.com/release/install.sh | bash
5-
# BAILIAN_CHANNEL=latest bash install.sh
6-
# BAILIAN_CHANNEL=sync-release bash install.sh
7-
# BAILIAN_VERSION=1.10.1 bash install.sh
4+
# curl -fsSL https://bailian.aliyun.com/install.sh | bash
5+
# bash install.sh --channel sync-release # local / channel verify
6+
# bash install.sh --version 1.10.1
7+
# curl -fsSL …/install.sh | bash -s -- --channel sync-release
88
#
9-
# Layout:
10-
# {CDN}/{channel}.json —— rolling manifest (version + assets)
11-
# {CDN}/v{version}/{file}.zip —— per-platform zip
129
set -euo pipefail
1310

1411
CDN_BASE="${BAILIAN_CLI_CDN:-https://bailian-wiki.oss-cn-hangzhou.aliyuncs.com/release}"
1512
CDN_BASE="${CDN_BASE%/}"
16-
CHANNEL="${BAILIAN_CHANNEL:-latest}"
13+
CHANNEL="${BAILIAN_CHANNEL:-}"
1714
VERSION="${BAILIAN_VERSION:-}"
1815
BIN_DIR="${BAILIAN_BIN_DIR:-${HOME}/.local/bin}"
1916
SHARE_DIR="${BAILIAN_SHARE_DIR:-${HOME}/.local/share/bailian-cli}"
@@ -22,10 +19,61 @@ CONFIG_DIR="${BAILIAN_CONFIG_DIR:-${HOME}/.bailian}"
2219
ZIP_FILE=""
2320
ZIP_SHA256=""
2421
INNER_NAME=""
22+
MANIFEST_LABEL="manifest.json"
2523

2624
log() { printf '%s\n' "$*" >&2; }
2725
die() { log "error: $*"; exit 1; }
2826

27+
usage() {
28+
cat >&2 <<'EOF'
29+
Usage: install.sh [--channel <name>] [--version <ver>] [--cdn <url>] [--help]
30+
31+
--channel <name> Install from {CDN}/{name}.json (default: manifest.json)
32+
--version <ver> Pin a release version (checksum via SHA256SUMS if needed)
33+
--cdn <url> Override CDN base (default / BAILIAN_CLI_CDN)
34+
--help Show this help
35+
36+
Env fallbacks: BAILIAN_CHANNEL, BAILIAN_VERSION, BAILIAN_CLI_CDN,
37+
BAILIAN_BIN_DIR, BAILIAN_SHARE_DIR, BAILIAN_CONFIG_DIR
38+
EOF
39+
}
40+
41+
parse_args() {
42+
while [[ $# -gt 0 ]]; do
43+
case "$1" in
44+
--channel|-c)
45+
[[ $# -ge 2 ]] || die "$1 requires a value"
46+
CHANNEL="$2"
47+
shift 2
48+
;;
49+
--version)
50+
[[ $# -ge 2 ]] || die "$1 requires a value"
51+
VERSION="$2"
52+
shift 2
53+
;;
54+
--cdn)
55+
[[ $# -ge 2 ]] || die "$1 requires a value"
56+
CDN_BASE="${2%/}"
57+
shift 2
58+
;;
59+
--help|-h)
60+
usage
61+
exit 0
62+
;;
63+
--)
64+
shift
65+
break
66+
;;
67+
-*)
68+
die "unknown option: $1 (try --help)"
69+
;;
70+
*)
71+
die "unexpected argument: $1 (try --help)"
72+
;;
73+
esac
74+
done
75+
}
76+
2977
need_cmd() {
3078
command -v "$1" >/dev/null 2>&1 || die "required command not found: $1"
3179
}
@@ -141,7 +189,13 @@ resolve_asset() {
141189
need_cmd curl
142190
local manifest_path parsed manifest_url
143191
manifest_path="$(mktemp)"
144-
manifest_url="${CDN_BASE}/${CHANNEL}.json"
192+
if [[ -n "${CHANNEL}" && "${CHANNEL}" != "latest" && "${CHANNEL}" != "stable" ]]; then
193+
MANIFEST_LABEL="${CHANNEL}.json"
194+
manifest_url="${CDN_BASE}/${CHANNEL}.json"
195+
else
196+
MANIFEST_LABEL="manifest.json"
197+
manifest_url="${CDN_BASE}/manifest.json"
198+
fi
145199
log "Fetching ${manifest_url}"
146200
if ! curl -fsSL "${manifest_url}" -o "${manifest_path}"; then
147201
rm -f "${manifest_path}"
@@ -150,7 +204,7 @@ resolve_asset() {
150204

151205
if ! parsed="$(parse_manifest_asset "${manifest_path}" "${PLATFORM_KEY}" "${VERSION}")"; then
152206
rm -f "${manifest_path}"
153-
die "failed to parse asset metadata from ${CHANNEL}.json for ${PLATFORM_KEY}"
207+
die "failed to parse asset metadata from ${MANIFEST_LABEL} for ${PLATFORM_KEY}"
154208
fi
155209
rm -f "${manifest_path}"
156210

@@ -160,7 +214,7 @@ resolve_asset() {
160214
INNER_NAME="$(printf '%s\n' "${parsed}" | cut -f4)"
161215

162216
[[ -n "${VERSION}" && -n "${ZIP_FILE}" && -n "${INNER_NAME}" ]] \
163-
|| die "incomplete asset metadata from ${CHANNEL}.json"
217+
|| die "incomplete asset metadata from ${MANIFEST_LABEL}"
164218
}
165219

166220
sha256_file() {
@@ -253,11 +307,12 @@ warn_npm_conflict() {
253307
}
254308

255309
main() {
310+
parse_args "$@"
256311
need_cmd curl
257312
need_cmd uname
258313
detect_os_arch
259314
resolve_asset
260-
log "Installing bailian-cli ${VERSION} (${PLATFORM_KEY}) from ${CDN_BASE} [${CHANNEL}]"
315+
log "Installing bailian-cli ${VERSION} (${PLATFORM_KEY}) from ${CDN_BASE} [${MANIFEST_LABEL}]"
261316
download_and_install
262317
warn_npm_conflict
263318
warn_path

0 commit comments

Comments
 (0)