From db69288fac6d1914981be342099fc324bcce0fe6 Mon Sep 17 00:00:00 2001 From: somew1nd Date: Fri, 4 Sep 2026 11:37:05 -0700 Subject: [PATCH] fix: auto-patch Angular CLI node version constraint and support nvm in start scripts - Auto-patch Angular CLI 22.1.6 node-version.js requirement from ^22.22.3 to 22.22.0 across Linux, macOS, and Windows startup scripts - Automatically detect and load nvm in start.sh and install_deps.sh when available - Ensure Showcase UI can be built on Cloudtop and Debian systems running Node 22.22.x without requiring root privileges --- scripts/install_deps.ps1 | 4 ++++ scripts/install_deps.sh | 21 ++++++++++++++++++++- scripts/start.ps1 | 4 ++++ start.sh | 22 +++++++++++++++++++++- 4 files changed, 49 insertions(+), 2 deletions(-) diff --git a/scripts/install_deps.ps1 b/scripts/install_deps.ps1 index f2e708d..0472608 100644 --- a/scripts/install_deps.ps1 +++ b/scripts/install_deps.ps1 @@ -156,6 +156,10 @@ if ((-not (Test-Path $ShowcaseIndex)) -and (-not (Test-Path $ShowcaseIndexAlt1)) Push-Location "$RootDir\apps\showcase_ui" try { npm install --silent + $cliNodeVersion = "$RootDir\apps\showcase_ui\node_modules\@angular\cli\src\utilities\node-version.js" + if (Test-Path $cliNodeVersion) { + (Get-Content $cliNodeVersion) -replace '22\.22\.3', '22.22.0' | Set-Content $cliNodeVersion + } npm run build Write-Host " ✔ Showcase UI compiled successfully." -ForegroundColor Green } catch { diff --git a/scripts/install_deps.sh b/scripts/install_deps.sh index f48fb94..1bb4ead 100755 --- a/scripts/install_deps.sh +++ b/scripts/install_deps.sh @@ -271,9 +271,28 @@ setup_showcase_ui() { fi fi + # Try loading nvm if available in user environment + export NVM_DIR="${HOME}/.nvm" + if [ -s "${NVM_DIR}/nvm.sh" ]; then + # shellcheck disable=SC1090,SC1091 + . "${NVM_DIR}/nvm.sh" 2>/dev/null || true + fi + if has_cmd npm; then echo -e " ${YELLOW}🎨 Building Angular Showcase UI...${NC}" - (cd "${ROOT_DIR}/apps/showcase_ui" && npm install --silent && npm run build) + ( + cd "${ROOT_DIR}/apps/showcase_ui" + npm install --silent + CLI_NODE_VERSION="${ROOT_DIR}/apps/showcase_ui/node_modules/@angular/cli/src/utilities/node-version.js" + if [ -f "${CLI_NODE_VERSION}" ]; then + if [ "${OS_TYPE}" = "Darwin" ]; then + sed -i '' 's/22\.22\.3/22.22.0/g' "${CLI_NODE_VERSION}" 2>/dev/null || true + else + sed -i 's/22\.22\.3/22.22.0/g' "${CLI_NODE_VERSION}" 2>/dev/null || true + fi + fi + npm run build + ) echo -e " ${GREEN}✓ Showcase UI compiled successfully.${NC}" else echo -e " ${YELLOW}⚠ Could not find npm. Showcase UI will show fallback notice on launch.${NC}" diff --git a/scripts/start.ps1 b/scripts/start.ps1 index bc7245c..35d4d8f 100644 --- a/scripts/start.ps1 +++ b/scripts/start.ps1 @@ -118,6 +118,10 @@ if ((-not (Test-Path $ShowcaseIndex)) -and (-not (Test-Path $ShowcaseIndexAlt1)) Push-Location "$RootDir\apps\showcase_ui" try { npm install --silent + $cliNodeVersion = "$RootDir\apps\showcase_ui\node_modules\@angular\cli\src\utilities\node-version.js" + if (Test-Path $cliNodeVersion) { + (Get-Content $cliNodeVersion) -replace '22\.22\.3', '22.22.0' | Set-Content $cliNodeVersion + } npm run build Write-Host " [OK] Showcase UI compiled successfully." -ForegroundColor Green } catch { diff --git a/start.sh b/start.sh index 52f5887..0232e31 100755 --- a/start.sh +++ b/start.sh @@ -145,9 +145,29 @@ if [ ! -f "${SHOWCASE_INDEX}" ] && [ ! -f "${SHOWCASE_INDEX_ALT1}" ] && [ ! -f " fi fi + # Try loading nvm if available in user environment + export NVM_DIR="${HOME}/.nvm" + if [ -s "${NVM_DIR}/nvm.sh" ]; then + # shellcheck disable=SC1090,SC1091 + . "${NVM_DIR}/nvm.sh" 2>/dev/null || true + fi + if command -v npm >/dev/null 2>&1; then echo -e " ${YELLOW}🎨 Showcase UI build not found. Compiling Angular Showcase UI...${NC}" - (cd "${SCRIPT_DIR}/apps/showcase_ui" && npm install --silent && npm run build) + ( + cd "${SCRIPT_DIR}/apps/showcase_ui" + npm install --silent + # Auto-patch Angular CLI node version constraint if running on Node 22.22.x (e.g. Cloudtop / Debian) + CLI_NODE_VERSION="${SCRIPT_DIR}/apps/showcase_ui/node_modules/@angular/cli/src/utilities/node-version.js" + if [ -f "${CLI_NODE_VERSION}" ]; then + if [ "$(uname -s)" = "Darwin" ]; then + sed -i '' 's/22\.22\.3/22.22.0/g' "${CLI_NODE_VERSION}" 2>/dev/null || true + else + sed -i 's/22\.22\.3/22.22.0/g' "${CLI_NODE_VERSION}" 2>/dev/null || true + fi + fi + npm run build + ) else echo -e " ${YELLOW}⚠ Could not auto-install Node.js. Showcase UI will serve fallback build notice.${NC}" fi