Merge branch 'fix/chenxi-macos-deploy-runner'
This commit is contained in:
commit
e23fc595d6
@ -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) {
|
||||
@ -229,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
|
||||
@ -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()
|
||||
|
||||
@ -365,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
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user