File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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
Original file line number Diff line number Diff 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### 确认安装
Original file line number Diff line number Diff 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 "
Original file line number Diff line number Diff line change 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"
Original file line number Diff line number Diff line change @@ -4,12 +4,20 @@ $scriptPath = Join-Path $PSScriptRoot "install.ps1"
44$bytes = [System.IO.File ]::ReadAllBytes($scriptPath )
55
66if ($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 )
1111if (-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"
You can’t perform that action at this time.
0 commit comments