From ab96f1462bd2a054d548b8e976776b460fbfb1a1 Mon Sep 17 00:00:00 2001 From: "Namhyeon, Go" Date: Sat, 18 Apr 2026 14:32:21 +0900 Subject: [PATCH] Add WelsonJS One-Click Installer script #404 Add WelsonJS One-Click Installer script #404 --- install.ps1 | 100 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 100 insertions(+) create mode 100644 install.ps1 diff --git a/install.ps1 b/install.ps1 new file mode 100644 index 0000000..6703ced --- /dev/null +++ b/install.ps1 @@ -0,0 +1,100 @@ +# WelsonJS One-Click Installer (install.ps1) +# Copyright 2019-2025, Namhyeon Go and the WelsonJS contributors. +# SPDX-License-Identifier: GPL-3.0-or-later +# https://github.com/gnh1201/welsonjs +# +# Usage: +# irm https://welson.js.org/install.ps1 | iex +# irm https://welson.js.org/install.ps1 | iex -dev main +# irm https://welson.js.org/install.ps1 | iex -dev dev +# +param( + [string]$dev = "master" # Default branch +) + +$ErrorActionPreference = "Stop" + +function Write-Step($msg) { + Write-Host "[*] $msg" -ForegroundColor Cyan +} + +function Write-Ok($msg) { + Write-Host "[+] $msg" -ForegroundColor Green +} + +function Write-Err($msg) { + Write-Host "[!] $msg" -ForegroundColor Red +} + +try { + # Step 1: Create a temporary working directory using a UUID + Write-Step "Creating temporary workspace..." + + $uuid = [guid]::NewGuid().ToString() + $tempDir = Join-Path $env:TEMP $uuid + + New-Item -ItemType Directory -Path $tempDir | Out-Null + + Write-Ok "Temp directory: $tempDir" + + $repo = "gnh1201/welsonjs" + $zipPath = Join-Path $tempDir "package.zip" + + # Step 2: Determine branch (default: master) + $branch = $dev + + Write-Step "Using branch: $branch" + + # GitHub branch ZIP URL + $downloadUrl = "https://github.com/$repo/archive/refs/heads/$branch.zip" + + Write-Ok "Download URL: $downloadUrl" + + # Step 3: Download the ZIP package + Write-Step "Downloading package..." + + irm $downloadUrl -OutFile $zipPath + + Write-Ok "Downloaded: $zipPath" + + # Step 4: Extract the ZIP archive + Write-Step "Extracting package..." + + Expand-Archive -Path $zipPath -DestinationPath $tempDir + + Write-Ok "Extraction completed" + + # Step 5: Locate bootstrap.bat within extracted files + Write-Step "Locating bootstrap.bat..." + + $bootstrap = Get-ChildItem -Path $tempDir -Recurse -Filter "bootstrap.bat" | Select-Object -First 1 + + if (-not $bootstrap) { + throw "bootstrap.bat not found" + } + + Write-Ok "Found: $($bootstrap.FullName)" + + # Step 6: Execute bootstrap.bat via cmd.exe for compatibility + Write-Step "Executing bootstrap..." + + $proc = Start-Process -FilePath "cmd.exe" ` + -ArgumentList "/c `"$($bootstrap.FullName)`"" ` + -Wait -PassThru + + if ($proc.ExitCode -ne 0) { + throw "bootstrap failed with exit code $($proc.ExitCode)" + } + + Write-Ok "Bootstrap executed successfully" + + # Step 7: Final message + Write-Host "" + Write-Host "WelsonJS installation completed!" -ForegroundColor Green + Write-Host "" + +} +catch { + Write-Err $_ + exit 1 +}