Skip to content

Commit dfd81b6

Browse files
committed
docs: 替换 AtomGit 源为 GitHub 源并完善相关检查
1. 更新 readme.md 中的安装脚本地址为 GitHub 原生源 2. 新增安装链接校验测试脚本 3. 重构 install.ps1 的架构检测逻辑,优先使用系统环境变量而非 RuntimeInformation 4. 新增 install.ps1 的架构检测校验规则 5. 优化文档中的编码检查说明
1 parent 8293118 commit dfd81b6

5 files changed

Lines changed: 47 additions & 10 deletions

File tree

AGENTS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
- 与用户沟通、代码注释、文档、日志和面向用户的界面文案,尽量使用中文。
66
- 技术专有名词、代码标识符、第三方库名称和命令可保留英文,以保证准确性与可检索性。
7-
-`irm ... | iex` 直接执行的 PowerShell 安装脚本必须保存为 UTF-8 无 BOM;BOM 会被管道执行当作脚本首字符,导致 `CmdletBinding` 解析失败。对此保留自动化编码检查。
7+
-`irm ... | iex` 直接执行的 PowerShell 安装脚本必须保存为 UTF-8 无 BOM;BOM 会被管道执行当作脚本首字符,导致 `CmdletBinding` 解析失败。Windows 安装脚本的 CPU 架构检测应优先使用 `PROCESSOR_ARCHITEW6432``PROCESSOR_ARCHITECTURE` 等环境变量,不能依赖旧版 .NET 中可能为空的 `RuntimeInformation.OSArchitecture`对此保留自动化编码检查。
88

99
## TDD 开发
1010

readme.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,15 @@ Certd Client 是 [Certd](https://github.com/certd/certd) 的证书部署客户
4343
在 PowerShell 中执行:
4444

4545
```powershell
46-
irm https://raw.atomgit.com/certd/certd-client/raw/main/scripts/install.ps1 | iex
46+
irm https://raw.githubusercontent.com/certd/certd-client/main/scripts/install.ps1 | iex
4747
```
4848

4949
脚本会提示安装目录。直接回车时,客户端安装到当前目录的 `certd-client` 子目录;再次执行同一命令会更新已有客户端。
5050

5151
### Linux 和 macOS
5252

5353
```bash
54-
curl -fsSL https://raw.atomgit.com/certd/certd-client/raw/main/scripts/install.sh | sh
54+
curl -fsSL https://raw.githubusercontent.com/certd/certd-client/main/scripts/install.sh | sh
5555
```
5656

5757
### 确认安装

scripts/install.ps1

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,21 @@ if (-not $InstallDir) {
1313
$InstallDir = if ($inputDir) { $inputDir } else { $defaultDir }
1414
}
1515

16-
$architecture = switch ([System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture.ToString()) {
17-
"X64" { "amd64" }
18-
"Arm64" { "arm64" }
19-
default { throw "不支持的 CPU 架构:$([System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture)" }
16+
$processorArchitecture = $env:PROCESSOR_ARCHITEW6432
17+
if (-not $processorArchitecture) {
18+
$processorArchitecture = $env:PROCESSOR_ARCHITECTURE
19+
}
20+
$architecture = switch -Regex ($processorArchitecture) {
21+
"^(AMD64|X64)$" { "amd64" }
22+
"^ARM64$" { "arm64" }
23+
default {
24+
if ([Environment]::Is64BitOperatingSystem) {
25+
"amd64"
26+
}
27+
else {
28+
throw "不支持的 CPU 架构:$processorArchitecture"
29+
}
30+
}
2031
}
2132
$asset = "certd-client-windows-$architecture.zip"
2233
$githubUrl = "https://github.com/$repository/releases/latest/download/$asset"

scripts/install_links_test.ps1

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
$ErrorActionPreference = "Stop"
2+
3+
$readmePath = Join-Path $PSScriptRoot "..\README.md"
4+
$readme = [System.IO.File]::ReadAllText($readmePath, [System.Text.Encoding]::UTF8)
5+
6+
if ($readme -match "raw\.atomgit\.com") {
7+
throw "README must not use raw.atomgit.com: it does not serve install scripts."
8+
}
9+
10+
if ($readme -notmatch "https://raw\.githubusercontent\.com/certd/certd-client/main/scripts/install\.ps1") {
11+
throw "README must provide the GitHub PowerShell install script URL."
12+
}
13+
14+
if ($readme -notmatch "https://raw\.githubusercontent\.com/certd/certd-client/main/scripts/install\.sh") {
15+
throw "README must provide the GitHub Shell install script URL."
16+
}
17+
18+
Write-Host "Install link check passed"

scripts/install_test.ps1

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,20 @@ $scriptPath = Join-Path $PSScriptRoot "install.ps1"
44
$bytes = [System.IO.File]::ReadAllBytes($scriptPath)
55

66
if ($bytes.Length -ge 3 -and $bytes[0] -eq 0xEF -and $bytes[1] -eq 0xBB -and $bytes[2] -eq 0xBF) {
7-
throw "install.ps1 不能使用 UTF-8 BOM,否则 irm | iex 会将 BOM 作为脚本首字符并解析失败"
7+
throw "install.ps1 must not use a UTF-8 BOM because irm | iex treats it as the first script character."
88
}
99

1010
$content = [System.Text.Encoding]::UTF8.GetString($bytes)
1111
if (-not $content.StartsWith("[CmdletBinding()]")) {
12-
throw "install.ps1 必须以 [CmdletBinding()] 作为首个字符,确保可通过 irm | iex 运行"
12+
throw "install.ps1 must start with [CmdletBinding()] for irm | iex."
1313
}
1414

15-
Write-Host "install.ps1 编码检查通过"
15+
if ($content -match "RuntimeInformation\]::OSArchitecture\.ToString") {
16+
throw "install.ps1 must not rely on RuntimeInformation.OSArchitecture because older Windows/.NET can return null."
17+
}
18+
19+
if ($content -notmatch "PROCESSOR_ARCHITEW6432") {
20+
throw "install.ps1 must support architecture detection from 32-bit PowerShell on 64-bit Windows."
21+
}
22+
23+
Write-Host "install.ps1 checks passed"

0 commit comments

Comments
 (0)