install node in goose dir (#7220)

This commit is contained in:
Lifei Zhou
2026-02-17 19:17:48 +11:00
committed by GitHub
parent 9ccd20d472
commit 18cbe96ca0
4 changed files with 33 additions and 55 deletions
@@ -1,6 +1,7 @@
name: "Bundle Desktop (Windows)"
on:
workflow_dispatch:
workflow_call:
inputs:
version:
@@ -1,37 +0,0 @@
@echo off
setlocal enabledelayedexpansion
REM Check if Node.js is installed in Program Files
if exist "C:\Program Files\nodejs\node.exe" (
echo Node.js found in Program Files
set "NODE_EXE=C:\Program Files\nodejs\node.exe"
goto :found
)
REM Check if Node.js is installed in Program Files (x86)
if exist "C:\Program Files (x86)\nodejs\node.exe" (
echo "Node.js found in Program Files (x86)"
set "NODE_EXE=C:\Program Files (x86)\nodejs\node.exe"
goto :found
)
echo Node.js not found in standard locations, installing...
REM Download Node.js MSI installer
powershell -Command "& {[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; Invoke-WebRequest -Uri '%1' -OutFile '%TEMP%\node-setup.msi'}"
REM Install Node.js silently
msiexec /i "%TEMP%\node-setup.msi" /qn
REM Wait a bit for installation to complete
timeout /t 5 /nobreak
REM Clean up
del "%TEMP%\node-setup.msi"
REM Set path to installed Node.js
set "NODE_EXE=C:\Program Files\nodejs\node.exe"
:found
echo Using Node.js: %NODE_EXE%
exit /b 0
+31 -17
View File
@@ -1,31 +1,45 @@
@ECHO OFF
SETLOCAL EnableDelayedExpansion
SET "SCRIPT_DIR=%~dp0"
SET "NODE_VERSION=22.14.0"
SET "GOOSE_NODE_DIR=%LOCALAPPDATA%\Goose\node"
REM Try to find Node.js in standard locations first
if exist "C:\Program Files\nodejs\npx.cmd" (
"C:\Program Files\nodejs\npx.cmd" %*
exit /b %errorlevel%
REM === Check for previously downloaded portable Node.js (matching version) ===
if exist "%GOOSE_NODE_DIR%\node-v%NODE_VERSION%.installed" (
SET "PATH=%GOOSE_NODE_DIR%;!PATH!"
"%GOOSE_NODE_DIR%\npx.cmd" %*
exit /b !errorlevel!
)
if exist "C:\Program Files (x86)\nodejs\npx.cmd" (
"C:\Program Files (x86)\nodejs\npx.cmd" %*
exit /b %errorlevel%
)
REM === Download portable Node.js ===
echo [Goose] Node.js not found. Downloading portable Node.js v%NODE_VERSION%... 1>&2
REM If Node.js not found, run installer
call "%SCRIPT_DIR%install-node.cmd" "https://nodejs.org/dist/v23.10.0/node-v23.10.0-x64.msi"
SET "NODE_ZIP=%TEMP%\goose-node-%NODE_VERSION%.zip"
SET "NODE_EXTRACT=%TEMP%\goose-node-extract"
powershell -NoProfile -Command "$ProgressPreference='SilentlyContinue'; try { [Net.ServicePointManager]::SecurityProtocol=[Net.SecurityProtocolType]::Tls12; Invoke-WebRequest -Uri 'https://nodejs.org/dist/v%NODE_VERSION%/node-v%NODE_VERSION%-win-x64.zip' -OutFile '%NODE_ZIP%' -UseBasicParsing; Expand-Archive -Path '%NODE_ZIP%' -DestinationPath '%NODE_EXTRACT%' -Force; exit 0 } catch { Write-Error $_.Exception.Message; exit 1 }"
if errorlevel 1 (
echo Failed to install Node.js
echo [Goose] ERROR: Failed to download Node.js. Please install manually from https://nodejs.org/ 1>&2
del "%NODE_ZIP%" >nul 2>&1
exit /b 1
)
REM Try using the newly installed Node.js
if exist "C:\Program Files\nodejs\npx.cmd" (
"C:\Program Files\nodejs\npx.cmd" %*
exit /b %errorlevel%
REM Clean previous version and install to Goose directory
rmdir /s /q "%GOOSE_NODE_DIR%" >nul 2>&1
mkdir "%GOOSE_NODE_DIR%" >nul 2>&1
xcopy /s /e /q /y "%NODE_EXTRACT%\node-v%NODE_VERSION%-win-x64\*" "%GOOSE_NODE_DIR%\" >nul 2>&1
REM Clean up
del "%NODE_ZIP%" >nul 2>&1
rmdir /s /q "%NODE_EXTRACT%" >nul 2>&1
if exist "%GOOSE_NODE_DIR%\npx.cmd" (
echo.>"%GOOSE_NODE_DIR%\node-v%NODE_VERSION%.installed"
SET "PATH=%GOOSE_NODE_DIR%;!PATH!"
echo [Goose] Node.js v%NODE_VERSION% ready. 1>&2
"%GOOSE_NODE_DIR%\npx.cmd" %*
exit /b !errorlevel!
)
echo Failed to find npx after Node.js installation
echo [Goose] ERROR: Installation failed. Please install Node.js manually from https://nodejs.org/ 1>&2
exit /b 1
+1 -1
View File
@@ -21,7 +21,7 @@ export async function ensureWinShims(): Promise<void> {
await fs.promises.mkdir(tgtDir, { recursive: true });
// Copy command-line tools, NOT goosed.exe (which should always be used locally)
const shims = ['uvx.exe', 'uv.exe', 'npx.cmd', 'install-node.cmd'];
const shims = ['uvx.exe', 'uv.exe', 'npx.cmd'];
await Promise.all(
shims.map(async (shim) => {