Merge remote-tracking branch 'upstream/main' into feat/dws-devapp
# Conflicts: # CHANGELOG.md
This commit is contained in:
@@ -19,6 +19,8 @@ set -eu
|
||||
REPO="DingTalk-Real-AI/dingtalk-workspace-cli"
|
||||
# China mirror: Gitee repo "owner/repo". When set, version + asset URLs resolve via Gitee API.
|
||||
GITEE_REPO="${DWS_GITEE_REPO:-}"
|
||||
# Auto-fallback Gitee mirror used when GitHub is unreachable (see pick_source).
|
||||
GITEE_FALLBACK_REPO="${DWS_GITEE_FALLBACK_REPO:-DingTalk-Real-AI/dingtalk-workspace-cli}"
|
||||
VERSION="${DWS_VERSION:-latest}"
|
||||
SKILL_NAME="dws"
|
||||
ROOT="${DWS_SKILLS_ROOT:-$PWD}"
|
||||
@@ -48,6 +50,14 @@ gitee_api() {
|
||||
return 1
|
||||
}
|
||||
|
||||
pick_source() {
|
||||
[ -n "$GITEE_REPO" ] && return 0
|
||||
[ "${DWS_NO_FALLBACK:-0}" = "1" ] && return 0
|
||||
curl -fsS --connect-timeout 5 --max-time 12 -o /dev/null "https://github.com/${REPO}/releases/latest" 2>/dev/null && return 0
|
||||
GITEE_REPO="$GITEE_FALLBACK_REPO"
|
||||
printf ' ⚠ GitHub 不可达,自动切换国内 Gitee 镜像: %s\n' "$GITEE_REPO"
|
||||
}
|
||||
|
||||
resolve_version() {
|
||||
if [ "$VERSION" = "latest" ]; then
|
||||
if [ -n "$GITEE_REPO" ]; then
|
||||
@@ -199,6 +209,7 @@ install_skills_to_root() {
|
||||
|
||||
main() {
|
||||
need_cmd curl
|
||||
pick_source
|
||||
resolve_version
|
||||
|
||||
printf '\n'
|
||||
|
||||
@@ -29,6 +29,8 @@ $Repo = "DingTalk-Real-AI/dingtalk-workspace-cli"
|
||||
$BinName = "dws"
|
||||
# China mirror: Gitee repo "owner/repo". When set, version + asset URLs resolve via the Gitee API.
|
||||
$GiteeRepo = if ($env:DWS_GITEE_REPO) { $env:DWS_GITEE_REPO } else { "" }
|
||||
# Auto-fallback Gitee mirror used when GitHub is unreachable (see Resolve-Source).
|
||||
$GiteeFallbackRepo = if ($env:DWS_GITEE_FALLBACK_REPO) { $env:DWS_GITEE_FALLBACK_REPO } else { "DingTalk-Real-AI/dingtalk-workspace-cli" }
|
||||
$InstallDir = if ($env:DWS_INSTALL_DIR) { $env:DWS_INSTALL_DIR } else { Join-Path $HOME ".local\bin" }
|
||||
$Version = if ($env:DWS_VERSION) { $env:DWS_VERSION } else { "latest" }
|
||||
$NoSkills = $env:DWS_NO_SKILLS -eq "1"
|
||||
@@ -148,6 +150,20 @@ function Get-GiteeAssetUrl {
|
||||
return ""
|
||||
}
|
||||
|
||||
function Resolve-Source {
|
||||
# Explicit DWS_GITEE_REPO wins; else probe GitHub and fall back to Gitee when unreachable.
|
||||
if ($GiteeRepo -ne "") { return }
|
||||
if ($env:DWS_NO_FALLBACK -eq "1") { return }
|
||||
try {
|
||||
Invoke-WebRequest -Uri "https://github.com/$Repo/releases/latest" -Method Head `
|
||||
-TimeoutSec 12 -UseBasicParsing -ErrorAction Stop 2>$null | Out-Null
|
||||
return
|
||||
} catch {
|
||||
$script:GiteeRepo = $GiteeFallbackRepo
|
||||
Write-Say "⚠ GitHub 不可达,自动切换国内 Gitee 镜像: $script:GiteeRepo"
|
||||
}
|
||||
}
|
||||
|
||||
function Resolve-LatestVersion {
|
||||
if ($Version -eq "latest") {
|
||||
if ($GiteeRepo -ne "") {
|
||||
@@ -593,6 +609,10 @@ $SourceRoot = Resolve-SourceRoot
|
||||
|
||||
Write-Banner
|
||||
|
||||
# Pick GitHub vs Gitee mirror (auto-fallback when GitHub is unreachable).
|
||||
# Skipped when installing from a local source checkout (no download needed).
|
||||
if (-not $SourceRoot) { Resolve-Source }
|
||||
|
||||
if (!$NoSkills) {
|
||||
Resolve-SkillMode
|
||||
}
|
||||
|
||||
@@ -28,6 +28,11 @@ BIN_NAME="dws"
|
||||
# the Gitee API (https://gitee.com/api/v5) instead of GitHub. Gitee attachment URLs
|
||||
# carry an unstable numeric id, so every asset is resolved by name at install time.
|
||||
GITEE_REPO="${DWS_GITEE_REPO:-}"
|
||||
# Auto-fallback: when DWS_GITEE_REPO is not set, the installer probes GitHub and,
|
||||
# if it is unreachable (typical in mainland China), automatically switches to this
|
||||
# Gitee mirror — so a plain `curl … | sh` works everywhere with no env var.
|
||||
# Set DWS_NO_FALLBACK=1 to disable the probe and force GitHub.
|
||||
GITEE_FALLBACK_REPO="${DWS_GITEE_FALLBACK_REPO:-DingTalk-Real-AI/dingtalk-workspace-cli}"
|
||||
INSTALL_DIR="${DWS_INSTALL_DIR:-$HOME/.local/bin}"
|
||||
INSTALL_NAME="${DWS_INSTALL_NAME:-$BIN_NAME}"
|
||||
VERSION="${DWS_VERSION:-latest}"
|
||||
@@ -153,6 +158,21 @@ detect_arch() {
|
||||
esac
|
||||
}
|
||||
|
||||
# Decide the download source. An explicit DWS_GITEE_REPO always wins. Otherwise
|
||||
# probe GitHub Releases; if it is unreachable (typical in mainland China), switch
|
||||
# GITEE_REPO to the mirror so every subsequent resolve/download uses Gitee.
|
||||
pick_source() {
|
||||
[ -n "$GITEE_REPO" ] && return 0
|
||||
[ "${DWS_NO_FALLBACK:-0}" = "1" ] && return 0
|
||||
if need_cmd curl; then
|
||||
curl -fsS --connect-timeout 5 --max-time 12 -o /dev/null "https://github.com/${REPO}/releases/latest" 2>/dev/null && return 0
|
||||
elif need_cmd wget; then
|
||||
wget -q --timeout=12 --tries=1 -O /dev/null "https://github.com/${REPO}/releases/latest" 2>/dev/null && return 0
|
||||
fi
|
||||
GITEE_REPO="$GITEE_FALLBACK_REPO"
|
||||
say "⚠ GitHub 不可达,自动切换国内 Gitee 镜像: ${GITEE_REPO}"
|
||||
}
|
||||
|
||||
# Resolve the latest version tag from GitHub
|
||||
resolve_version() {
|
||||
if [ "$VERSION" = "latest" ]; then
|
||||
@@ -615,6 +635,10 @@ main() {
|
||||
|
||||
print_banner
|
||||
|
||||
# Pick GitHub vs Gitee mirror (auto-fallback when GitHub is unreachable).
|
||||
# Skipped when installing from a local source checkout (no download needed).
|
||||
[ -z "$source_root" ] && pick_source
|
||||
|
||||
# Resolve skill mode only when we are actually going to touch skills.
|
||||
if [ "$NO_SKILLS" != "1" ]; then
|
||||
resolve_skill_mode
|
||||
|
||||
Reference in New Issue
Block a user