Skip to content

Commit 13caccb

Browse files
feat(installer): upgrade multi-platform wizards, custom directory support, safe PATH injection, and uninstall switches
1 parent b30d1c8 commit 13caccb

4 files changed

Lines changed: 258 additions & 134 deletions

File tree

Lines changed: 69 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -1,131 +1,119 @@
11
@echo off
22
setlocal enabledelayedexpansion
3-
title CloudSync-CLI Setup
3+
title CloudSync-CLI Setup Wizard
44

5-
set "VERSION=1.0.5"
65
set "DEFAULT_DIR=%LOCALAPPDATA%\CloudSync-CLI"
6+
set "REPO=Tech4File/cloudsync-cli"
77

88
echo.
9-
echo ╔══════════════════════════════════════════════════════╗
10-
echo CloudSync-CLI v%VERSION% Installer ║
11-
echo Secure cloud-to-local file synchronization ║
12-
echo ╚══════════════════════════════════════════════════════╝
9+
echo ==============================================================
10+
echo CloudSync-CLI Windows Setup Wizard
11+
echo Secure Cloud-to-Local Synchronization CLI Suite
12+
echo ==============================================================
1313
echo.
14-
echo This wizard will install CloudSync-CLI on your computer.
14+
echo This wizard will install CloudSync-CLI on your system.
1515
echo.
16-
echo It will:
17-
echo * Copy the executable to your chosen location
18-
echo * Register the cloudsync command globally
19-
echo * Add the installation directory to your PATH
16+
echo It will automatically:
17+
echo 1. Install the standalone binary (cloudsync.exe)
18+
echo 2. Register cloudsync globally in your PATH environment variable
19+
echo 3. Verify functionality and command execution
2020
echo.
21-
echo ─────────────────────────────────────────────────────
22-
echo Step 1 of 3: Installation Directory
23-
echo ─────────────────────────────────────────────────────
21+
echo --------------------------------------------------------------
22+
echo Step 1: Choose Installation Directory
23+
echo --------------------------------------------------------------
2424
echo.
25-
echo Where should CloudSync-CLI be installed?
25+
echo [1] Default (Recommended): %DEFAULT_DIR%
26+
echo [2] Custom Directory
27+
echo [3] Exit Setup
2628
echo.
27-
echo [1] Default: %DEFAULT_DIR%
28-
echo [2] Custom path
29-
echo [3] Exit installer
30-
echo.
31-
set /p DIR_CHOICE=" Enter choice (1-3): "
29+
set /p DIR_CHOICE=" Enter selection (1-3): "
3230

3331
if "%DIR_CHOICE%"=="3" exit /b 0
3432
if "%DIR_CHOICE%"=="2" goto CUSTOM_DIR
3533
set "INSTALL_DIR=%DEFAULT_DIR%"
36-
goto CONFIRM_DIR
34+
goto PROCEED_INSTALL
3735

3836
:CUSTOM_DIR
3937
echo.
40-
set /p INSTALL_DIR=" Enter full installation path: "
41-
if "%INSTALL_DIR%"=="" set "INSTALL_DIR=%DEFAULT_DIR%"
38+
set /p USER_DIR=" Enter full custom install path: "
39+
if "%USER_DIR%"=="" (
40+
set "INSTALL_DIR=%DEFAULT_DIR%"
41+
) else (
42+
set "INSTALL_DIR=%USER_DIR%"
43+
)
4244

43-
:CONFIRM_DIR
45+
:PROCEED_INSTALL
4446
if not exist "%INSTALL_DIR%" mkdir "%INSTALL_DIR%" >nul 2>&1
4547
if errorlevel 1 (
46-
echo [ERROR] Could not create: %INSTALL_DIR%
47-
echo Try running as Administrator.
48+
echo.
49+
echo [ERROR] Could not create directory: %INSTALL_DIR%
50+
echo Please run this installer as Administrator.
4851
pause
4952
exit /b 1
5053
)
51-
echo Installing to: %INSTALL_DIR%
5254

5355
echo.
54-
echo ─────────────────────────────────────────────────────
55-
echo Step 2 of 3: Installing Files
56-
echo ─────────────────────────────────────────────────────
56+
echo --------------------------------------------------------------
57+
echo Step 2: Installing Executable & Files
58+
echo --------------------------------------------------------------
59+
echo Target: %INSTALL_DIR%
5760
echo.
5861

5962
set "SETUP_DIR=%~dp0"
6063
if exist "%SETUP_DIR%cloudsync.exe" (
61-
copy /Y "%SETUP_DIR%cloudsync.exe" "%INSTALL_DIR%\cloudsync.exe" >nul 2>&1
62-
echo [OK] cloudsync.exe
64+
copy /Y "%SETUP_DIR%cloudsync.exe" "%INSTALL_DIR%\cloudsync.exe" >nul
65+
echo [OK] Copied cloudsync.exe
6366
) else (
64-
echo [SKIP] cloudsync.exe not found in setup directory
67+
echo [INFO] Local binary not found, downloading from GitHub Releases...
68+
powershell -NoProfile -Command "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; Invoke-WebRequest -Uri 'https://github.com/%REPO%/releases/latest/download/cloudsync.exe' -OutFile '%INSTALL_DIR%\cloudsync.exe'"
69+
if exist "%INSTALL_DIR%\cloudsync.exe" (
70+
echo [OK] Downloaded and installed cloudsync.exe
71+
) else (
72+
echo [ERROR] Failed to download cloudsync.exe
73+
pause
74+
exit /b 1
75+
)
6576
)
6677

67-
if exist "%SETUP_DIR%cloudsync-portable.exe" (
68-
copy /Y "%SETUP_DIR%cloudsync-portable.exe" "%INSTALL_DIR%\cloudsync-portable.exe" >nul 2>&1
69-
echo [OK] cloudsync-portable.exe
70-
)
71-
72-
echo @echo off > "%INSTALL_DIR%\cloudsync.bat"
73-
echo "%%INSTALL_DIR%%\cloudsync.exe" %%* >> "%INSTALL_DIR%\cloudsync.bat"
74-
echo [OK] cloudsync command wrapper
75-
76-
(
77-
echo CloudSync-CLI v%VERSION%
78-
echo Installed: %DATE% %TIME%
79-
echo Path: %INSTALL_DIR%
80-
echo Docs: https://github.com/Tech4File/cloudsync-cli
81-
) > "%INSTALL_DIR%\VERSION.txt"
82-
echo [OK] VERSION.txt
83-
78+
:: Create convenient uninstaller script
8479
(
8580
echo @echo off
8681
echo echo.
8782
echo echo CloudSync-CLI Uninstaller
88-
echo echo ────────────────────────
89-
echo choice /c YN /n /m " Uninstall? [Y/N] "
90-
echo if errorlevel 2 exit /b 0
83+
echo echo ----------------------------------------
84+
echo set /p CONFIRM=" Are you sure you want to uninstall CloudSync-CLI? (Y/N): "
85+
echo if /i not "%%CONFIRM%%"=="Y" exit /b 0
86+
echo powershell -NoProfile -Command "$p = [Environment]::GetEnvironmentVariable('Path', 'User'); $np = ($p -split ';' | Where-Object { $_ -and $_ -ne '%INSTALL_DIR%' }) -join ';'; [Environment]::SetEnvironmentVariable('Path', $np, 'User')"
9187
echo rmdir /S /Q "%INSTALL_DIR%" 2^>nul
92-
echo echo CloudSync-CLI has been uninstalled.
93-
echo echo Remove from PATH: %INSTALL_DIR%
88+
echo echo [OK] CloudSync-CLI has been uninstalled successfully.
9489
echo pause
9590
) > "%INSTALL_DIR%\uninstall.bat"
96-
echo [OK] Uninstaller
91+
echo [OK] Generated uninstaller: %INSTALL_DIR%\uninstall.bat
9792

9893
echo.
99-
echo ─────────────────────────────────────────────────────
100-
echo Step 3 of 3: System Integration
101-
echo ─────────────────────────────────────────────────────
102-
echo.
94+
echo --------------------------------------------------------------
95+
echo Step 3: Registering Environment Variables (PATH)
96+
echo --------------------------------------------------------------
10397

104-
setx PATH "%PATH%;%INSTALL_DIR%" >nul 2>&1
105-
if errorlevel 1 (
106-
echo [WARN] Could not update PATH automatically.
107-
echo Add manually: %INSTALL_DIR%
108-
) else (
109-
echo [OK] Added to user PATH
110-
)
98+
:: Use PowerShell to safely update User PATH without setx 1024 char limit
99+
powershell -NoProfile -Command "$dir = '%INSTALL_DIR%'; $p = [Environment]::GetEnvironmentVariable('Path', 'User'); $parts = if ($p) { $p -split ';' } else { @() }; if ($parts -notcontains $dir) { $np = ($parts + $dir | Where-Object { $_ }) -join ';'; [Environment]::SetEnvironmentVariable('Path', $np, 'User'); Write-Host ' [OK] Successfully registered in User PATH' } else { Write-Host ' [INFO] Already registered in User PATH' }"
111100

112101
echo.
113-
echo ╔══════════════════════════════════════════════════════╗
114-
echo Installation Complete!
115-
echo ╚══════════════════════════════════════════════════════╝
102+
echo ==============================================================
103+
echo Installation Complete!
104+
echo ==============================================================
116105
echo.
117-
echo Location: %INSTALL_DIR%
118-
echo Uninstall: %INSTALL_DIR%\uninstall.bat
106+
echo Location: %INSTALL_DIR%
107+
echo Executable: %INSTALL_DIR%\cloudsync.exe
108+
echo Uninstaller: %INSTALL_DIR%\uninstall.bat
119109
echo.
120-
echo To get started:
121-
echo 1. Open a NEW terminal window
122-
echo 2. Run: cloudsync --version
123-
echo 3. Run: cloudsync --help
110+
echo Verification:
111+
"%INSTALL_DIR%\cloudsync.exe" --version
124112
echo.
125-
echo Full documentation:
126-
echo https://github.com/Tech4File/cloudsync-cli#readme
113+
echo Next steps:
114+
echo 1. Open a new terminal / Command Prompt / PowerShell
115+
echo 2. Type: cloudsync --help
127116
echo.
128-
echo ╔══════════════════════════════════════════════════════╗
129-
echo ║ Press any key to close... ║
130-
echo ╚══════════════════════════════════════════════════════╝
117+
echo ==============================================================
118+
echo Press any key to exit wizard...
131119
pause >nul

cloudsync-cli/installer/CloudSync.iss

Lines changed: 27 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,52 @@
11
; CloudSync-CLI Inno Setup Script
22
; Build: "C:\Program Files (x86)\Inno Setup 6\ISCC.exe" CloudSync.iss
33

4+
#define MyAppName "CloudSync-CLI"
5+
#define MyAppPublisher "Tech4File"
6+
#define MyAppURL "https://github.com/Tech4File/cloudsync-cli"
7+
#define MyAppExeName "cloudsync.exe"
8+
49
[Setup]
5-
AppName=CloudSync-CLI
6-
AppVersion=1.0.5
7-
AppPublisher=Tech4File
8-
AppPublisherURL=https://github.com/Tech4File/cloudsync-cli
9-
DefaultDirName={autopf}\CloudSync-CLI
10-
DefaultGroupName=CloudSync-CLI
10+
AppId={{D37B4A11-66DF-47B2-B2A6-75010B0E232F}
11+
AppName={#MyAppName}
12+
AppVersion=2026.8
13+
AppPublisher={#MyAppPublisher}
14+
AppPublisherURL={#MyAppURL}
15+
AppSupportURL={#MyAppURL}
16+
AppUpdatesURL={#MyAppURL}/releases
17+
DefaultDirName={autopf}\{#MyAppName}
18+
DefaultGroupName={#MyAppName}
1119
OutputDir=output
12-
OutputBaseFilename=CloudSync-Setup-1.0.5
13-
Compression=lzma2
20+
OutputBaseFilename=CloudSync-Setup
21+
Compression=lzma2/ultra64
1422
SolidCompression=yes
1523
WizardStyle=modern
16-
PrivilegesRequired=admin
24+
PrivilegesRequired=lowest
25+
PrivilegesRequiredOverridesAllowed=dialog
1726
ArchitecturesAllowed=x64compatible
1827
ArchitecturesInstallIn64BitMode=x64compatible
19-
UninstallDisplayName=CloudSync-CLI
28+
UninstallDisplayName={#MyAppName}
2029

2130
[Languages]
2231
Name: "english"; MessagesFile: "compiler:Default.isl"
2332

2433
[Tasks]
25-
Name: "addtopath"; Description: "Add to PATH (Recommended)"; GroupDescription: "System Integration:"; Flags: checkedonce
34+
Name: "addtopath"; Description: "Add CloudSync to PATH environment variable (Recommended)"; GroupDescription: "System Integration:"; Flags: checkedonce
2635

2736
[Files]
2837
Source: "cloudsync.exe"; DestDir: "{app}"; Flags: ignoreversion
29-
Source: "cloudsync-portable.exe"; DestDir: "{app}"; Flags: ignoreversion
38+
Source: "..\README.md"; DestDir: "{app}"; Flags: ignoreversion skipifsourcedoesntexist
39+
Source: "..\LICENSE"; DestDir: "{app}"; Flags: ignoreversion skipifsourcedoesntexist
3040

3141
[Icons]
32-
Name: "{group}\CloudSync-CLI"; Filename: "{app}\cloudsync.exe"
33-
Name: "{group}\Uninstall CloudSync-CLI"; Filename: "{uninstallexe}"
42+
Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
43+
Name: "{group}\Uninstall {#MyAppName}"; Filename: "{uninstallexe}"
3444

3545
[Run]
36-
Filename: "{app}\cloudsync.exe"; Description: "Launch CloudSync-CLI"; Flags: nowait postinstall skipifsilent; Parameters: "--help"
46+
Filename: "{app}\{#MyAppExeName}"; Description: "View CloudSync-CLI Help Documentation"; Flags: nowait postinstall skipifsilent; Parameters: "--help"
3747

3848
[Registry]
39-
Root: HKLM; Subkey: "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"; \
49+
Root: HKCU; Subkey: "Environment"; \
4050
ValueType: expandsz; ValueName: "Path"; ValueData: "{olddata};{app}"; \
4151
Flags: preservestringtype; Tasks: addtopath; Check: NeedsAddPath('{app}')
4252

@@ -45,9 +55,7 @@ function NeedsAddPath(Param: string): boolean;
4555
var
4656
OrigPath: string;
4757
begin
48-
if not RegQueryStringValue(HKEY_LOCAL_MACHINE,
49-
'SYSTEM\CurrentControlSet\Control\Session Manager\Environment',
50-
'Path', OrigPath) then
58+
if not RegQueryStringValue(HKEY_CURRENT_USER, 'Environment', 'Path', OrigPath) then
5159
begin
5260
Result := True;
5361
exit;
Lines changed: 84 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,104 @@
1-
# CloudSync-CLI Automated Installer for Windows PowerShell
2-
# Usage: irm https://raw.githubusercontent.com/Tech4File/cloudsync-cli/main/installer/Install-CloudSync.ps1 | iex
1+
# CloudSync-CLI Universal Installer for Windows PowerShell
2+
# Usage:
3+
# Install: irm https://raw.githubusercontent.com/Tech4File/cloudsync-cli/main/installer/Install-CloudSync.ps1 | iex
4+
# Custom: & .\Install-CloudSync.ps1 -InstallDir "C:\Tools\cloudsync"
5+
# Uninstall: & .\Install-CloudSync.ps1 -Uninstall
36

4-
$ErrorActionPreference = "Stop"
7+
param(
8+
[string]$InstallDir = "$HOME\.cloudsync\bin",
9+
[string]$Version = "latest",
10+
[switch]$Uninstall
11+
)
512

13+
$ErrorActionPreference = "Stop"
614
$Repo = "Tech4File/cloudsync-cli"
7-
$InstallDir = "$HOME\.cloudsync\bin"
8-
$Executable = "$InstallDir\cloudsync.exe"
9-
$DownloadUrl = "https://github.com/$Repo/releases/latest/download/cloudsync.exe"
15+
$Executable = Join-Path $InstallDir "cloudsync.exe"
1016

1117
Write-Host "`n🔒 CloudSync-CLI Windows Installer" -ForegroundColor Cyan
1218
Write-Host ("" * 60) -ForegroundColor Gray
1319

20+
# ─────────────────────────────────────────────────────────────
21+
# UNINSTALL MODE
22+
# ─────────────────────────────────────────────────────────────
23+
if ($Uninstall) {
24+
Write-Host "🗑️ Uninstalling CloudSync-CLI..." -ForegroundColor Yellow
25+
if (Test-Path $InstallDir) {
26+
Remove-Item -Path $InstallDir -Recurse -Force -ErrorAction SilentlyContinue
27+
Write-Host "✅ Removed installation directory: $InstallDir" -ForegroundColor Green
28+
}
29+
30+
# Remove from User PATH
31+
$UserPath = [Environment]::GetEnvironmentVariable("Path", "User")
32+
if ($UserPath -like "*$InstallDir*") {
33+
$CleanPath = ($UserPath -split ';' | Where-Object { $_ -and $_ -ne $InstallDir }) -join ';'
34+
[Environment]::SetEnvironmentVariable("Path", $CleanPath, "User")
35+
Write-Host "📝 Removed $InstallDir from User PATH environment variable." -ForegroundColor Cyan
36+
}
37+
38+
Write-Host ("" * 60) -ForegroundColor Gray
39+
Write-Host "🎉 CloudSync-CLI has been cleanly uninstalled.`n" -ForegroundColor Green
40+
exit 0
41+
}
42+
43+
# ─────────────────────────────────────────────────────────────
44+
# INSTALLATION MODE
45+
# ─────────────────────────────────────────────────────────────
1446
if (!(Test-Path $InstallDir)) {
1547
New-Item -ItemType Directory -Path $InstallDir -Force | Out-Null
1648
}
1749

18-
Write-Host "📥 Downloading cloudsync.exe from latest release..." -ForegroundColor Yellow
19-
Invoke-WebRequest -Uri $DownloadUrl -OutFile $Executable
50+
$DownloadUrl = if ($Version -eq "latest") {
51+
"https://github.com/$Repo/releases/latest/download/cloudsync.exe"
52+
} else {
53+
"https://github.com/$Repo/releases/download/v$Version/cloudsync.exe"
54+
}
55+
56+
Write-Host "📦 Target Directory: $InstallDir" -ForegroundColor White
57+
Write-Host "📥 Downloading cloudsync.exe from $DownloadUrl..." -ForegroundColor Yellow
58+
59+
try {
60+
# Use TLS 1.2+ for secure downloads
61+
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 -bor [Net.SecurityProtocolType]::Tls13
62+
Invoke-WebRequest -Uri $DownloadUrl -OutFile $Executable -UseBasicParsing
63+
} catch {
64+
Write-Host "❌ Download failed: $_" -ForegroundColor Red
65+
Write-Host " Check your internet connection or verify release availability at https://github.com/$Repo/releases" -ForegroundColor Gray
66+
exit 1
67+
}
68+
69+
if (!(Test-Path $Executable)) {
70+
Write-Host "❌ Failed to install cloudsync.exe" -ForegroundColor Red
71+
exit 1
72+
}
2073

2174
Write-Host "✅ Binary installed to: $Executable" -ForegroundColor Green
2275

23-
# Add to User PATH if not already present
76+
# ─────────────────────────────────────────────────────────────
77+
# ENVIRONMENT VARIABLES & GLOBAL PATH RECOGNITION
78+
# ─────────────────────────────────────────────────────────────
2479
$UserPath = [Environment]::GetEnvironmentVariable("Path", "User")
25-
if ($UserPath -notlike "*$InstallDir*") {
26-
[Environment]::SetEnvironmentVariable("Path", "$UserPath;$InstallDir", "User")
80+
$PathParts = if ($UserPath) { $UserPath -split ';' } else { @() }
81+
82+
if ($PathParts -notcontains $InstallDir) {
83+
$NewPath = ($PathParts + $InstallDir | Where-Object { $_ }) -join ';'
84+
[Environment]::SetEnvironmentVariable("Path", $NewPath, "User")
2785
$env:Path = "$env:Path;$InstallDir"
28-
Write-Host "📝 Added $InstallDir to User PATH environment variable." -ForegroundColor Cyan
86+
Write-Host "📝 Added $InstallDir to User PATH environment variable (Globally Recognized)." -ForegroundColor Cyan
87+
} else {
88+
Write-Host "ℹ️ $InstallDir is already registered in User PATH." -ForegroundColor Gray
89+
}
90+
91+
# ─────────────────────────────────────────────────────────────
92+
# FUNCTIONALITY & EXECUTION VERIFICATION
93+
# ─────────────────────────────────────────────────────────────
94+
Write-Host "🔍 Verifying installation..." -ForegroundColor Yellow
95+
try {
96+
$VerOutput = & "$Executable" --version
97+
Write-Host "✅ Verified CloudSync-CLI version: $VerOutput" -ForegroundColor Green
98+
} catch {
99+
Write-Host "⚠️ Executable installed but verification encountered a warning: $_" -ForegroundColor Yellow
29100
}
30101

31102
Write-Host ("" * 60) -ForegroundColor Gray
32103
Write-Host "🎉 CloudSync-CLI installed successfully!" -ForegroundColor Green
33-
Write-Host "🚀 Run 'cloudsync --help' in a new terminal window to get started.`n" -ForegroundColor White
104+
Write-Host "🚀 Run 'cloudsync --help' in your terminal to get started.`n" -ForegroundColor White

0 commit comments

Comments
 (0)