Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion install.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@

$ErrorActionPreference = "Stop"

# Force TLS 1.2 — PowerShell 5.1 defaults to TLS 1.0 which modern HTTPS endpoints reject
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12

$InstallDir = if ($env:CODEBLOG_INSTALL_DIR) { $env:CODEBLOG_INSTALL_DIR } else { "$env:USERPROFILE\.local\bin" }
$BinName = "codeblog"
$NpmRegistry = "https://registry.npmjs.org"
Expand Down Expand Up @@ -72,7 +75,23 @@ function Write-Header {

# ── Platform detection ──────────────────────────────────────────────────────
function Get-Platform {
$arch = [System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture.ToString().ToLower()
# PowerShell 7+ has RuntimeInformation; PowerShell 5.1 (.NET Framework) does not.
# Fall back to PROCESSOR_ARCHITECTURE env var which works on all Windows versions.
$arch = $null
try {
$arch = [System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture.ToString().ToLower()
} catch {}

if (-not $arch) {
$envArch = $env:PROCESSOR_ARCHITECTURE
switch ($envArch) {
"AMD64" { $arch = "x64" }
"x86" { $arch = "x64" } # 32-bit PS on 64-bit OS — still download x64 binary
"ARM64" { $arch = "arm64" }
default { Write-Fail "Unsupported architecture: $envArch" }
}
}

if ($arch -eq "x64") { return "x64" }
elseif ($arch -eq "arm64") { return "arm64" }
else { Write-Fail "Unsupported architecture: $arch" }
Expand Down
26 changes: 25 additions & 1 deletion packages/codeblog/script/release.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,31 @@ try {
console.log(" ⚠ Could not verify install.sh version")
}

// 7c. Verify platform packages
// 7c. Verify codeblog.ai/install.ps1 has Windows compatibility guards
try {
const remote = await fetch("https://codeblog.ai/install.ps1").then((r) => r.text())
const local = await Bun.file(path.join(root, "install.ps1")).text()
const normRemote = remote.replaceAll("\r\n", "\n")
const normLocal = local.replaceAll("\r\n", "\n")
if (normRemote === normLocal) {
console.log(" ✓ install.ps1 is synced to codeblog.ai")
} else {
console.log(" ⚠ install.ps1 on codeblog.ai differs from repository install.ps1")
}
const guard = [
"[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12",
"$env:PROCESSOR_ARCHITECTURE",
].every((s) => normRemote.includes(s))
if (guard) {
console.log(" ✓ install.ps1 includes TLS 1.2 + architecture fallback guards")
} else {
console.log(" ⚠ install.ps1 is missing TLS/architecture guards needed for PowerShell 5.1")
}
} catch {
console.log(" ⚠ Could not verify codeblog.ai/install.ps1")
}

// 7d. Verify platform packages
for (const p of platforms) {
try {
const res = await fetch(`https://registry.npmjs.org/codeblog-app-${p}/latest`)
Expand Down
Loading