Skip to content

Commit f925f7d

Browse files
authored
install node in goose dir (#7220) (#7267)
1 parent 674cf0f commit f925f7d

File tree

4 files changed

+33
-55
lines changed

4 files changed

+33
-55
lines changed

.github/workflows/bundle-desktop-windows.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
name: "Bundle Desktop (Windows)"
22

33
on:
4+
workflow_dispatch:
45
workflow_call:
56
inputs:
67
version:

ui/desktop/src/platform/windows/bin/install-node.cmd

Lines changed: 0 additions & 37 deletions
This file was deleted.
Lines changed: 31 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,45 @@
11
@ECHO OFF
22
SETLOCAL EnableDelayedExpansion
33

4-
SET "SCRIPT_DIR=%~dp0"
4+
SET "NODE_VERSION=22.14.0"
5+
SET "GOOSE_NODE_DIR=%LOCALAPPDATA%\Goose\node"
56

6-
REM Try to find Node.js in standard locations first
7-
if exist "C:\Program Files\nodejs\npx.cmd" (
8-
"C:\Program Files\nodejs\npx.cmd" %*
9-
exit /b %errorlevel%
7+
REM === Check for previously downloaded portable Node.js (matching version) ===
8+
if exist "%GOOSE_NODE_DIR%\node-v%NODE_VERSION%.installed" (
9+
SET "PATH=%GOOSE_NODE_DIR%;!PATH!"
10+
"%GOOSE_NODE_DIR%\npx.cmd" %*
11+
exit /b !errorlevel!
1012
)
1113

12-
if exist "C:\Program Files (x86)\nodejs\npx.cmd" (
13-
"C:\Program Files (x86)\nodejs\npx.cmd" %*
14-
exit /b %errorlevel%
15-
)
14+
REM === Download portable Node.js ===
15+
echo [Goose] Node.js not found. Downloading portable Node.js v%NODE_VERSION%... 1>&2
16+
17+
SET "NODE_ZIP=%TEMP%\goose-node-%NODE_VERSION%.zip"
18+
SET "NODE_EXTRACT=%TEMP%\goose-node-extract"
1619

17-
REM If Node.js not found, run installer
18-
call "%SCRIPT_DIR%install-node.cmd" "https://nodejs.org/dist/v23.10.0/node-v23.10.0-x64.msi"
20+
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 }"
1921
if errorlevel 1 (
20-
echo Failed to install Node.js
22+
echo [Goose] ERROR: Failed to download Node.js. Please install manually from https://nodejs.org/ 1>&2
23+
del "%NODE_ZIP%" >nul 2>&1
2124
exit /b 1
2225
)
2326

24-
REM Try using the newly installed Node.js
25-
if exist "C:\Program Files\nodejs\npx.cmd" (
26-
"C:\Program Files\nodejs\npx.cmd" %*
27-
exit /b %errorlevel%
27+
REM Clean previous version and install to Goose directory
28+
rmdir /s /q "%GOOSE_NODE_DIR%" >nul 2>&1
29+
mkdir "%GOOSE_NODE_DIR%" >nul 2>&1
30+
xcopy /s /e /q /y "%NODE_EXTRACT%\node-v%NODE_VERSION%-win-x64\*" "%GOOSE_NODE_DIR%\" >nul 2>&1
31+
32+
REM Clean up
33+
del "%NODE_ZIP%" >nul 2>&1
34+
rmdir /s /q "%NODE_EXTRACT%" >nul 2>&1
35+
36+
if exist "%GOOSE_NODE_DIR%\npx.cmd" (
37+
echo.>"%GOOSE_NODE_DIR%\node-v%NODE_VERSION%.installed"
38+
SET "PATH=%GOOSE_NODE_DIR%;!PATH!"
39+
echo [Goose] Node.js v%NODE_VERSION% ready. 1>&2
40+
"%GOOSE_NODE_DIR%\npx.cmd" %*
41+
exit /b !errorlevel!
2842
)
2943

30-
echo Failed to find npx after Node.js installation
44+
echo [Goose] ERROR: Installation failed. Please install Node.js manually from https://nodejs.org/ 1>&2
3145
exit /b 1

ui/desktop/src/utils/winShims.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export async function ensureWinShims(): Promise<void> {
2121
await fs.promises.mkdir(tgtDir, { recursive: true });
2222

2323
// Copy command-line tools, NOT goosed.exe (which should always be used locally)
24-
const shims = ['uvx.exe', 'uv.exe', 'npx.cmd', 'install-node.cmd'];
24+
const shims = ['uvx.exe', 'uv.exe', 'npx.cmd'];
2525

2626
await Promise.all(
2727
shims.map(async (shim) => {

0 commit comments

Comments
 (0)