Add self-downloading installer and README
- install.bat downloads exe from Gitea release or uses local copy - Adds to user PATH automatically - README with full usage guide, file structure, conflict resolution Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
94
install.bat
94
install.bat
@@ -1,55 +1,95 @@
|
||||
@echo off
|
||||
setlocal
|
||||
setlocal EnableDelayedExpansion
|
||||
|
||||
set "INSTALL_DIR=%LOCALAPPDATA%\kisync"
|
||||
set "EXE_NAME=kisync.exe"
|
||||
set "DOWNLOAD_URL=https://gitea.esh-service.ru/public/api_builder_cli_client/releases/download/v1.0.0/kisync.exe"
|
||||
|
||||
echo.
|
||||
echo KIS API Builder Sync - Installer
|
||||
echo =================================
|
||||
echo ==========================================
|
||||
echo kisync - KIS API Builder Sync - Installer
|
||||
echo ==========================================
|
||||
echo.
|
||||
|
||||
:: Create install directory
|
||||
if not exist "%INSTALL_DIR%" (
|
||||
mkdir "%INSTALL_DIR%"
|
||||
echo Created: %INSTALL_DIR%
|
||||
echo [+] Created directory: %INSTALL_DIR%
|
||||
) else (
|
||||
echo [=] Directory exists: %INSTALL_DIR%
|
||||
)
|
||||
|
||||
:: Copy exe
|
||||
copy /Y "%~dp0release\%EXE_NAME%" "%INSTALL_DIR%\%EXE_NAME%" >nul 2>&1
|
||||
if errorlevel 1 (
|
||||
echo ERROR: Could not copy %EXE_NAME%. Make sure release\kisync.exe exists.
|
||||
echo Run "npm run package" first to build the exe.
|
||||
:: Check if exe is next to this script (offline install)
|
||||
if exist "%~dp0release\%EXE_NAME%" (
|
||||
echo [~] Found local exe, copying...
|
||||
copy /Y "%~dp0release\%EXE_NAME%" "%INSTALL_DIR%\%EXE_NAME%" >nul 2>&1
|
||||
goto :check_copy
|
||||
)
|
||||
if exist "%~dp0%EXE_NAME%" (
|
||||
echo [~] Found local exe, copying...
|
||||
copy /Y "%~dp0%EXE_NAME%" "%INSTALL_DIR%\%EXE_NAME%" >nul 2>&1
|
||||
goto :check_copy
|
||||
)
|
||||
|
||||
:: Download from Gitea
|
||||
echo [~] Downloading kisync.exe ...
|
||||
echo %DOWNLOAD_URL%
|
||||
echo.
|
||||
powershell -Command "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; (New-Object Net.WebClient).DownloadFile('%DOWNLOAD_URL%', '%INSTALL_DIR%\%EXE_NAME%')" 2>nul
|
||||
|
||||
:check_copy
|
||||
if not exist "%INSTALL_DIR%\%EXE_NAME%" (
|
||||
echo.
|
||||
echo [!] ERROR: Failed to get kisync.exe
|
||||
echo Try downloading manually from:
|
||||
echo %DOWNLOAD_URL%
|
||||
echo and place it in: %INSTALL_DIR%\
|
||||
echo.
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
echo Installed: %INSTALL_DIR%\%EXE_NAME%
|
||||
|
||||
:: Check if already in PATH
|
||||
echo %PATH% | findstr /I /C:"%INSTALL_DIR%" >nul 2>&1
|
||||
if %errorlevel%==0 (
|
||||
echo PATH: already configured
|
||||
goto :done
|
||||
)
|
||||
:: Show version
|
||||
echo [+] Installed: %INSTALL_DIR%\%EXE_NAME%
|
||||
"%INSTALL_DIR%\%EXE_NAME%" --version 2>nul && echo.
|
||||
|
||||
:: Add to user PATH
|
||||
echo Adding to user PATH...
|
||||
:: Check if already in user PATH
|
||||
set "NEED_PATH=1"
|
||||
for /f "tokens=2*" %%a in ('reg query "HKCU\Environment" /v Path 2^>nul') do set "USER_PATH=%%b"
|
||||
|
||||
if defined USER_PATH (
|
||||
reg add "HKCU\Environment" /v Path /t REG_EXPAND_SZ /d "%USER_PATH%;%INSTALL_DIR%" /f >nul 2>&1
|
||||
) else (
|
||||
reg add "HKCU\Environment" /v Path /t REG_EXPAND_SZ /d "%INSTALL_DIR%" /f >nul 2>&1
|
||||
echo !USER_PATH! | findstr /I /C:"%INSTALL_DIR%" >nul 2>&1
|
||||
if !errorlevel!==0 (
|
||||
set "NEED_PATH=0"
|
||||
echo [=] PATH: already configured
|
||||
)
|
||||
)
|
||||
|
||||
:: Broadcast environment change so new terminals pick it up
|
||||
rundll32.exe user32.dll,UpdatePerIDesktopLayout >nul 2>&1
|
||||
if !NEED_PATH!==1 (
|
||||
echo [~] Adding to user PATH...
|
||||
if defined USER_PATH (
|
||||
reg add "HKCU\Environment" /v Path /t REG_EXPAND_SZ /d "%USER_PATH%;%INSTALL_DIR%" /f >nul 2>&1
|
||||
) else (
|
||||
reg add "HKCU\Environment" /v Path /t REG_EXPAND_SZ /d "%INSTALL_DIR%" /f >nul 2>&1
|
||||
)
|
||||
|
||||
echo PATH: added %INSTALL_DIR%
|
||||
:: Notify system about environment change
|
||||
powershell -Command "[Environment]::SetEnvironmentVariable('_kisync_refresh','1','User'); [Environment]::SetEnvironmentVariable('_kisync_refresh', $null, 'User')" 2>nul
|
||||
|
||||
echo [+] PATH: added %INSTALL_DIR%
|
||||
)
|
||||
|
||||
:done
|
||||
echo.
|
||||
echo Done! Open a NEW terminal and run:
|
||||
echo kisync --help
|
||||
echo ==========================================
|
||||
echo Installation complete!
|
||||
echo ==========================================
|
||||
echo.
|
||||
echo Open a NEW terminal and run:
|
||||
echo kisync --help
|
||||
echo.
|
||||
echo Quick start:
|
||||
echo cd my-project
|
||||
echo kisync init
|
||||
echo kisync pull
|
||||
echo.
|
||||
pause
|
||||
|
||||
Reference in New Issue
Block a user