From 8b6731d0d852fa3ec9bb53e14f6bc69f2a722a39 Mon Sep 17 00:00:00 2001 From: chenxi Date: Mon, 28 Sep 2026 10:13:14 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E6=94=AF=E6=8C=81=E4=BB=8E=20macOS=20?= =?UTF-8?q?=E5=B7=A5=E4=BD=9C=E7=AB=99=E8=BF=90=E8=A1=8C=E6=AD=A3=E5=BC=8F?= =?UTF-8?q?=E5=8F=91=E5=B8=83=E8=84=9A=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/build-frontend.ps1 | 24 +++++++++++++++++------- scripts/deploy-from-workstation.ps1 | 5 +++-- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/scripts/build-frontend.ps1 b/scripts/build-frontend.ps1 index 6b4673f0..42b12ca8 100644 --- a/scripts/build-frontend.ps1 +++ b/scripts/build-frontend.ps1 @@ -10,12 +10,18 @@ param( $ErrorActionPreference = 'Stop' $repoRoot = (Resolve-Path (Join-Path $PSScriptRoot '..')).Path -$toolRoot = Join-Path $env:LOCALAPPDATA 'CaiWuXiTong\tools' -$nodeFolderName = "node-v$NodeVersion-win-x64" +$toolBase = if ($IsWindows) { $env:LOCALAPPDATA } else { Join-Path $HOME '.cache' } +$toolRoot = Join-Path $toolBase 'CaiWuXiTong/tools' +$nodePlatform = if ($IsMacOS) { + if ([Runtime.InteropServices.RuntimeInformation]::OSArchitecture -eq [Runtime.InteropServices.Architecture]::Arm64) { 'darwin-arm64' } else { 'darwin-x64' } +} elseif ($IsLinux) { + if ([Runtime.InteropServices.RuntimeInformation]::OSArchitecture -eq [Runtime.InteropServices.Architecture]::Arm64) { 'linux-arm64' } else { 'linux-x64' } +} else { 'win-x64' } +$nodeFolderName = "node-v$NodeVersion-$nodePlatform" $nodeRoot = Join-Path $toolRoot $nodeFolderName -$nodeExe = Join-Path $nodeRoot 'node.exe' -$npmCmd = Join-Path $nodeRoot 'npm.cmd' -$archiveName = "$nodeFolderName.zip" +$nodeExe = if ($IsWindows) { Join-Path $nodeRoot 'node.exe' } else { Join-Path $nodeRoot 'bin/node' } +$npmCmd = if ($IsWindows) { Join-Path $nodeRoot 'npm.cmd' } else { Join-Path $nodeRoot 'bin/npm' } +$archiveName = if ($IsWindows) { "$nodeFolderName.zip" } else { "$nodeFolderName.tar.gz" } $archivePath = Join-Path $toolRoot $archiveName $checksumPath = Join-Path $toolRoot 'SHASUMS256.txt' $trackedCssPath = Join-Path $repoRoot 'public/css/app.css' @@ -213,7 +219,11 @@ if (-not (Test-Path -LiteralPath $nodeExe)) { throw 'The Node archive SHA-256 checksum verification failed.' } - Expand-Archive -LiteralPath $archivePath -DestinationPath $toolRoot -Force + if ($IsWindows) { + Expand-Archive -LiteralPath $archivePath -DestinationPath $toolRoot -Force + } else { + Invoke-Native { tar -xzf $archivePath -C $toolRoot } 'The Node archive could not be extracted.' + } } finally { if (Test-Path -LiteralPath $archivePath) { @@ -242,7 +252,7 @@ else { Push-Location $repoRoot try { - $env:Path = "$nodeRoot;$originalPath" + $env:Path = "$(if ($IsWindows) { $nodeRoot } else { Join-Path $nodeRoot 'bin' })$([IO.Path]::PathSeparator)$originalPath" $env:NODE_OPTIONS = "--max-old-space-size=$MaxOldSpaceSizeMB" $env:CAIWU_TERSER_WORKERS = $TerserWorkers.ToString() diff --git a/scripts/deploy-from-workstation.ps1 b/scripts/deploy-from-workstation.ps1 index 270440f9..e8122b54 100644 --- a/scripts/deploy-from-workstation.ps1 +++ b/scripts/deploy-from-workstation.ps1 @@ -200,7 +200,8 @@ function Compress-Gzip { } function Get-RegctlPath { - $toolRoot = Join-Path $env:LOCALAPPDATA 'CaiWuXiTong\tools' + $toolBase = if ($IsWindows) { $env:LOCALAPPDATA } else { Join-Path $HOME '.cache' } + $toolRoot = Join-Path $toolBase 'CaiWuXiTong/tools' $regctlAsset = 'regctl-windows-amd64.exe' $regctlExtension = '.exe' $expectedHash = $regctlSha256 @@ -269,7 +270,7 @@ function Start-RegistryTunnel { param([int]$LocalPort) $sshPath = (Get-Command ssh -ErrorAction Stop).Source - $curlPath = (Get-Command curl.exe -ErrorAction Stop).Source + $curlPath = (Get-Command $(if ($IsWindows) { 'curl.exe' } else { 'curl' }) -CommandType Application -ErrorAction Stop).Source $startInfo = [Diagnostics.ProcessStartInfo]::new() $startInfo.FileName = $sshPath $startInfo.UseShellExecute = $false From 93cce7224e43d3c13a01fdad41020dd1841f548c Mon Sep 17 00:00:00 2001 From: chenxi Date: Mon, 28 Sep 2026 10:35:50 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=20macOS=20=E5=89=8D?= =?UTF-8?q?=E7=AB=AF=E6=9E=84=E5=BB=BA=20PATH?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/build-frontend.ps1 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/build-frontend.ps1 b/scripts/build-frontend.ps1 index 42b12ca8..6f49e0af 100644 --- a/scripts/build-frontend.ps1 +++ b/scripts/build-frontend.ps1 @@ -239,7 +239,7 @@ if (-not (Test-Path -LiteralPath $nodeExe) -or -not (Test-Path -LiteralPath $npm throw "The project-local Node $NodeVersion installation is incomplete." } -$originalPath = $env:Path +$originalPath = $env:PATH $originalNodeOptions = $env:NODE_OPTIONS $originalBuildTarget = $env:CAIWU_BUILD_TARGET $originalTerserWorkers = $env:CAIWU_TERSER_WORKERS @@ -252,7 +252,7 @@ else { Push-Location $repoRoot try { - $env:Path = "$(if ($IsWindows) { $nodeRoot } else { Join-Path $nodeRoot 'bin' })$([IO.Path]::PathSeparator)$originalPath" + $env:PATH = "$(if ($IsWindows) { $nodeRoot } else { Join-Path $nodeRoot 'bin' })$([IO.Path]::PathSeparator)$originalPath" $env:NODE_OPTIONS = "--max-old-space-size=$MaxOldSpaceSizeMB" $env:CAIWU_TERSER_WORKERS = $TerserWorkers.ToString() @@ -375,7 +375,7 @@ try { } finally { Pop-Location - $env:Path = $originalPath + $env:PATH = $originalPath $env:NODE_OPTIONS = $originalNodeOptions $env:CAIWU_BUILD_TARGET = $originalBuildTarget $env:CAIWU_TERSER_WORKERS = $originalTerserWorkers