Major Backend Rework - Modularized Many Functions

Users shouldn't see much of a difference on the front end. Version # 1.2.0 -> V1.2.1

Removed the following from Launcher.bat and created modular bat files for the sub-functionality.

- :start_st - > start_st.bat
- :exit - > exit_stl.bat
- :unresolved_unmerged -> unresolved_unmerged.bat
- :remove_pip_cache -> remove_pip_cache.bat
- :remove_node_modules - > remove_node_modules.bat
- :onboarding_flow -> onboarding_flow.bat
- :find_app_port -> find_app_port.bat
- :export_dxdiag -> export_dxdiag.bat

Moved all logs, dxdiag_info.txt and pids.txt to bin/logs/

updated start_st_rl to use same launching and auto-fixing function as start_st

Fixed :onboarding_flow to work with the new user data structure of SillyTavern

Added redirect flow controllers to troubleshooting sub function menus so they can redirect back to troubleshooting or home menus based on where they are called.
This commit is contained in:
Blueprint Coding
2024-07-06 18:08:02 -06:00
parent 30482653b8
commit 56bc5cbcee
11 changed files with 421 additions and 263 deletions

2
.gitignore vendored
View File

@@ -5,6 +5,6 @@ text-completion/
image-generation/
voice-generation/
xtts/
bin/
bin/*
!bin/functions/
!bin/functions/**

View File

@@ -428,9 +428,13 @@ if not defined choice set "choice=1"
REM ################## HOME - BACKEND #########################
if "%choice%"=="1" (
call :start_st
call %functions_dir%\launch\start_st.bat
if %errorlevel% equ 1 goto :home
) else if "%choice%"=="2" (
call :start_st_rl
start "" "%~dp0SillyTavern\Remote-Link.cmd"
echo "SillyTavern Remote Link Cloudflare Tunnel Launched"
call %functions_dir%\launch\start_st.bat
if %errorlevel% equ 1 goto :home
) else if "%choice%"=="3" (
if exist "%~dp0bin\settings\custom-shortcut.txt" (
call :launch_custom_shortcut
@@ -446,143 +450,13 @@ if "%choice%"=="1" (
) else if "%choice%"=="7" (
call :vraminfo
) else if "%choice%"=="0" (
call :exit
call %functions_dir%\launch\exit_stl.bat
) else (
echo [%DATE% %TIME%] %log_invalidinput% >> %log_path%
echo %red_bg%[%time%]%reset% %echo_invalidinput%
pause
goto :home
)
:exit
echo %red_bg%[%time%]%reset% %red_fg_strong%Terminating all started processes...%reset%
for /f %%a in ('type "%~dp0bin\logs\pids.txt"') do (
taskkill /F /PID %%a
)
del "%~dp0bin\logs\pids.txt"
exit
:start_st
REM Check if the folder exists
if not exist "%st_install_path%" (
echo %red_bg%[%time%]%reset% %red_fg_strong%[ERROR] Directory:%reset% %red_bg%SillyTavern%reset% %red_fg_strong%not found.%reset%
echo %red_fg_strong%Please make sure SillyTavern is located in: %~dp0%reset%
pause
goto :home
)
REM Check if Node.js is installed
node --version > nul 2>&1
if %errorlevel% neq 0 (
echo %red_bg%[%time%]%reset% %red_fg_strong%[ERROR] node command not found in PATH.%reset%
echo %red_fg_strong%Node.js is not installed or not found in the system PATH.%reset%
echo %red_fg_strong%To install Node.js go to:%reset% %blue_bg%/ Toolbox / App Installer / Core Utilities / Install Node.js%reset%
pause
goto :home
)
setlocal
set "command=%~1"
start /B cmd /C "%command%"
for /f "tokens=2 delims=," %%a in ('tasklist /FI "IMAGENAME eq cmd.exe" /FO CSV /NH') do (
set "pid=%%a"
echo %blue_bg%[%time%]%reset% %blue_fg_strong%[INFO]%reset% Started process with PID: %cyan_fg_strong%!pid!%reset%
echo !pid!>>"%~dp0bin\logs\pids.txt"
goto :st_found_pid
)
:st_found_pid
endlocal
REM Check if SSL info file exists and set the command accordingly
set "sslPathsFound=false"
if exist "%SSL_INFO_FILE%" (
for /f %%i in ('type "%SSL_INFO_FILE%"') do (
set "sslPathsFound=true"
goto :ST_SSL_Start
)
)
:ST_SSL_Start
if "%sslPathsFound%"=="true" (
echo %blue_bg%[%time%]%reset% %blue_fg_strong%[INFO]%reset% SillyTavern launched with SSL in a new window.
start cmd /k "title SillyTavern && cd /d %st_install_path% && call npm install --no-audit && call %functions_dir%\launch\log_wrapper.bat ssl"
) else (
echo %blue_bg%[%time%]%reset% %blue_fg_strong%[INFO]%reset% SillyTavern launched in a new window.
start cmd /k "title SillyTavern && cd /d %st_install_path% && call npm install --no-audit && call %functions_dir%\launch\log_wrapper.bat"
)
rem Clear the old log file
set "log_file=%~dp0bin\logs\st_console_output.log"
del "%log_file%"
echo %blue_bg%[%time%]%reset% %blue_fg_strong%[INFO]%reset% Waiting for log file to be created...
:wait_for_log
timeout /t 3 > nul
if not exist "%log_file%" (
goto :wait_for_log
)
goto :scan_log
:scan_log
echo %blue_bg%[%time%]%reset% %blue_fg_strong%[INFO]%reset% Log file found: %log_file%. Scanning log for errors...
:loop
REM Use PowerShell to search for the error message
powershell -Command "try { $content = Get-Content '%log_file%' -Raw; if ($content -match 'Error: Cannot find module') { exit 1 } elseif ($content -match 'SillyTavern is listening on:') { exit 0 } else { exit 2 } } catch { exit 2 }"
set "ps_errorlevel=%errorlevel%"
if %ps_errorlevel% equ 0 (
echo %blue_bg%[%time%]%reset% %blue_fg_strong%[INFO]%reset% %green_fg_strong%SillyTavern Launched Successfully. Returning home...%reset%
timeout /t 10
goto :home
) else if %ps_errorlevel% equ 1 (
echo %red_bg%[%time%]%reset% %red_fg_strong%[ERROR] Node.js Code: MODULE_NOT_FOUND%reset%
goto :attemptnodefix
) else (
timeout /t 3 > nul
goto :loop
)
:attemptnodefix
set /p "choice=Run troubleshooter to fix this error? [Y/n]: "
if /i "%choice%"=="" set choice=Y
if /i "%choice%"=="Y" (
call :remove_node_modules
)
:start_st_rl
REM Check if the folder exists
if not exist "%st_install_path%" (
echo %red_bg%[%time%]%reset% %red_fg_strong%[ERROR] Directory:%reset% %red_bg%SillyTavern%reset% %red_fg_strong%not found.%reset%
echo %red_fg_strong%Please make sure SillyTavern is located in: %~dp0%reset%
pause
goto :home
)
REM Check if Node.js is installed
node --version > nul 2>&1
if %errorlevel% neq 0 (
echo %red_bg%[%time%]%reset% %red_fg_strong%[ERROR] node command not found in PATH.%reset%
echo %red_fg_strong%Node.js is not installed or not found in the system PATH.%reset%
echo %red_fg_strong%To install Node.js go to:%reset% %blue_bg%/ Toolbox / App Installer / Core Utilities / Install Node.js%reset%
pause
goto :home
)
REM Check if SSL info file exists and set the command accordingly
if exist "%SSL_INFO_FILE%" (
for /f "skip=0 tokens=*" %%i in ('type "%SSL_INFO_FILE%"') do (
goto :sslPathsFoundRL
)
:sslPathsFoundRL
echo %blue_bg%[%time%]%reset% %blue_fg_strong%[INFO]%reset% SillyTavern launched with SSL in a new window.
start cmd /k "title SillyTavern && cd /d %st_install_path% && call npm install --no-audit && node server.js --ssl && pause && popd"
start "" "%~dp0SillyTavern\Remote-Link.cmd"
) else (
echo %blue_bg%[%time%]%reset% %blue_fg_strong%[INFO]%reset% SillyTavern launched in a new window.
start cmd /k "title SillyTavern && cd /d %st_install_path% && call npm install --no-audit && node server.js && pause && popd"
start "" "%~dp0SillyTavern\Remote-Link.cmd"
)
goto :home
REM ############################################################
@@ -5358,17 +5232,53 @@ set /p troubleshooting_choice=Choose Your Destiny:
REM ############## TROUBLESHOOTING - BACKEND ##################
if "%troubleshooting_choice%"=="1" (
call :remove_node_modules
set "caller=troubleshooting"
call %functions_dir%\troubleshooting\remove_node_modules.bat
if %errorlevel% equ 1 (
goto :home
) else (
goto :troubleshooting
)
) else if "%troubleshooting_choice%"=="2" (
call :remove_pip_cache
set "caller=troubleshooting"
call %functions_dir%\troubleshooting\remove_pip_cache.bat
if %errorlevel% equ 1 (
goto :home
) else (
goto :troubleshooting
)
) else if "%troubleshooting_choice%"=="3" (
call :unresolved_unmerged
set "caller=troubleshooting"
call %functions_dir%\troubleshooting\unresolved_unmerged.bat
if %errorlevel% equ 1 (
goto :home
) else (
goto :troubleshooting
)
) else if "%troubleshooting_choice%"=="4" (
call :export_dxdiag
set "caller=troubleshooting"
call %functions_dir%\troubleshooting\export_dxdiag.bat
if %errorlevel% equ 1 (
goto :home
) else (
goto :troubleshooting
)
) else if "%troubleshooting_choice%"=="5" (
call :find_app_port
set "caller=troubleshooting"
call %functions_dir%\troubleshooting\find_app_port.bat
if %errorlevel% equ 1 (
goto :home
) else (
goto :troubleshooting
)
) else if "%troubleshooting_choice%"=="6" (
call :onboarding_flow
set "caller=troubleshooting"
call %functions_dir%\troubleshooting\onboarding_flow.bat
if %errorlevel% equ 1 (
goto :home
) else (
goto :troubleshooting
)
) else if "%troubleshooting_choice%"=="0" (
goto :toolbox
) else (
@@ -5380,128 +5290,6 @@ if "%troubleshooting_choice%"=="1" (
:remove_node_modules
echo %blue_bg%[%time%]%reset% %blue_fg_strong%[INFO]%reset% Removing node_modules folder...
cd /d "%st_install_path%"
rmdir /s /q "node_modules"
del package-lock.json
call npm cache clean --force
echo %blue_bg%[%time%]%reset% %blue_fg_strong%[INFO]%reset% node_modules successfully removed.
pause
goto :troubleshooting
:remove_pip_cache
echo %blue_bg%[%time%]%reset% %blue_fg_strong%[INFO]%reset% Clearing pip cache...
pip cache purge
if %errorlevel% neq 0 (
echo %red_bg%[%time%]%reset% %red_fg_strong%[ERROR] Could not clear the pip cache.%reset%
echo Please try again.
pause
goto :troubleshooting
)
echo %blue_bg%[%time%]%reset% %blue_fg_strong%[INFO]%reset% %green_fg_strong%The pip cache has been cleared successfully.%reset%
pause
goto :troubleshooting
:unresolved_unmerged
echo %blue_bg%[%time%]%reset% %blue_fg_strong%[INFO]%reset% Trying to resolve unresolved conflicts in the working directory or unmerged files...
cd /d "%st_install_path%"
git merge --abort
git reset --hard
git pull --rebase --autostash
echo %blue_bg%[%time%]%reset% %blue_fg_strong%[INFO]%reset% Done.
pause
goto :troubleshooting
:export_dxdiag
echo %blue_bg%[%time%]%reset% %blue_fg_strong%[INFO]%reset% Exporting DirectX Diagnostic Tool information...
dxdiag /t "%~dp0bin\dxdiag_info.txt"
echo %blue_bg%[%time%]%reset% %blue_fg_strong%[INFO]%reset% %green_fg_strong%You can find the dxdiag_info.txt at: "%~dp0bin\dxdiag_info.txt"%reset%
pause
goto :troubleshooting
REM Function to find and display the application using the specified port
:find_app_port
cls
setlocal EnableDelayedExpansion
set /p port_choice="(0 to cancel)Insert port number: "
if "%port_choice%"=="0" goto :troubleshooting
REM Check if the input is a number
set "valid=true"
for /f "delims=0123456789" %%i in ("!port_choice!") do set "valid=false"
if "!valid!"=="false" (
echo %red_bg%[%time%]%reset% %red_fg_strong%[ERROR] Invalid input: Not a number.%reset%
pause
goto :troubleshooting
)
REM Check if the port is within range
if !port_choice! gtr 65535 (
echo %red_bg%[%time%]%reset% %red_fg_strong%[ERROR] Port out of range. There are only 65,535 possible port numbers.%reset%
echo [0-1023]: These ports are reserved for system services or commonly used protocols.
echo [1024-49151]: These ports can be used by user processes or applications.
echo [49152-65535]: These ports are available for use by any application or service on the system.
pause
goto :troubleshooting
)
echo %blue_bg%[%time%]%reset% %blue_fg_strong%[INFO]%reset% Searching for application using port: !port_choice!...
for /f "tokens=5" %%a in ('netstat -aon ^| findstr /r "\<!port_choice!\>"') do (
set pid=%%a
)
if defined pid (
for /f "tokens=2*" %%b in ('tasklist /fi "PID eq !pid!" /fo list ^| find "Image Name"') do (
set app_name=%%c
echo Application Name: %cyan_fg_strong%!app_name!%reset%
echo PID of Port !port_choice!: %cyan_fg_strong%!pid!%reset%
REM Fetch the page title for the specified port
call :fetch_page_title !port_choice!
if defined PAGE_TITLE (
echo Title of Application: %cyan_fg_strong%!PAGE_TITLE!%reset%
) else (
echo %yellow_bg%[%time%]%reset% %yellow_fg_strong%[WARN]%reset% Could not retrieve page title.
)
)
) else (
echo %yellow_bg%[%time%]%reset% %yellow_fg_strong%[WARN]%reset% Port: !port_choice! not found.
)
endlocal
pause
goto :troubleshooting
:fetch_page_title
setlocal
set "PORT=%1"
set "URL=http://localhost:%PORT%"
REM Use JScript to fetch and parse the title
for /f "delims=" %%I in ('cscript /nologo "%functions_dir%\troubleshooting\fetch_title.js" "%URL%"') do (
set "PAGE_TITLE=%%I"
)
endlocal & set "PAGE_TITLE=%PAGE_TITLE%"
goto :EOF
:onboarding_flow
set ONBOARDING_FLOW_VALUE=
set /p ONBOARDING_FLOW_VALUE="Enter new value for Onboarding Flow (true/false): "
yq eval -i ".firstRun = %ONBOARDING_FLOW_VALUE%" "%st_install_path%\public\settings.json"
goto :troubleshooting
REM ############################################################
REM ############## SWITCH BRANCH - FRONTEND ####################
REM ############################################################

View File

@@ -0,0 +1,12 @@
@echo off
REM Set base directory
set "base_dir=%~dp0\..\.."
:exit
echo %red_bg%[%time%]%reset% %red_fg_strong%Terminating all started processes...%reset%
for /f %%a in ('type "%base_dir%\logs\pids.txt"') do (
taskkill /F /PID %%a
)
del "%base_dir%\logs\pids.txt"
exit

View File

@@ -2,7 +2,7 @@
setlocal
REM Define the path to the log file
set LOG_FILE=..\bin\logs\st_console_output.log
set LOG_FILE=%~dp0..\..\logs\st_console_output.log
REM Set necessary environment variables for Node.js
set NODE_ENV=production

View File

@@ -0,0 +1,105 @@
@echo off
REM Set base directory
set "base_dir=%~dp0\..\.."
REM Check if the folder exists
if not exist "%st_install_path%" (
echo %red_bg%[%time%]%reset% %red_fg_strong%[ERROR] Directory:%reset% %red_bg%SillyTavern%reset% %red_fg_strong%not found.%reset%
echo %red_fg_strong%Please make sure SillyTavern is located in: %~dp0%reset%
pause
exit /b 1
)
REM Check if Node.js is installed
node --version > nul 2>&1
if %errorlevel% neq 0 (
echo %red_bg%[%time%]%reset% %red_fg_strong%[ERROR] node command not found in PATH.%reset%
echo %red_fg_strong%Node.js is not installed or not found in the system PATH.%reset%
echo %red_fg_strong%To install Node.js go to:%reset% %blue_bg%/ Toolbox / App Installer / Core Utilities / Install Node.js%reset%
pause
exit /b 1
)
setlocal
set "command=%~1"
start /B cmd /C "%command%"
for /f "tokens=2 delims=," %%a in ('tasklist /FI "IMAGENAME eq cmd.exe" /FO CSV /NH') do (
set "pid=%%a"
echo %blue_bg%[%time%]%reset% %blue_fg_strong%[INFO]%reset% Started process with PID: %cyan_fg_strong%!pid!%reset%
echo !pid!>>"%base_dir%\logs\pids.txt"
goto :st_found_pid
)
:st_found_pid
endlocal
REM Check if SSL info file exists and set the command accordingly
set "sslPathsFound=false"
if exist "%SSL_INFO_FILE%" (
for /f %%i in ('type "%SSL_INFO_FILE%"') do (
set "sslPathsFound=true"
goto :ST_SSL_Start
)
)
:ST_SSL_Start
if "%sslPathsFound%"=="true" (
echo %blue_bg%[%time%]%reset% %blue_fg_strong%[INFO]%reset% SillyTavern opened with SSL in a new window.
start cmd /k "title SillyTavern && cd /d %st_install_path% && call npm install --no-audit && call %base_dir%\functions\launch\log_wrapper.bat ssl"
) else (
echo %blue_bg%[%time%]%reset% %blue_fg_strong%[INFO]%reset% SillyTavern opened in a new window.
start cmd /k "title SillyTavern && cd /d %st_install_path% && call npm install --no-audit && call %base_dir%\functions\launch\log_wrapper.bat"
)
REM Clear the old log file if it exists
set "log_file=%base_dir%\logs\st_console_output.log"
if exist "%log_file%" (
del "%log_file%"
)
REM Wait for log file to be created, timeout after 60 seconds (20 iterations of 3 seconds)
echo %blue_bg%[%time%]%reset% %blue_fg_strong%[INFO]%reset% Waiting for SillyTavern to fully launch...
set "counter=0"
:wait_for_log
timeout /t 3 > nul
set /a counter+=1
if not exist "%log_file%" (
if %counter% lss 20 (
goto :wait_for_log
) else (
echo %red_bg%[%time%]%reset% %red_fg_strong%[ERROR]%reset% Log file not found, something went wrong. Close all SillyTavern command windows and try again.
pause
goto :home
)
)
goto :scan_log
:scan_log
echo %blue_bg%[%time%]%reset% %blue_fg_strong%[INFO]%reset% Log file found, scanning log for errors...
:loop
REM Use PowerShell to search for the error message
powershell -Command "try { $content = Get-Content '%log_file%' -Raw; if ($content -match 'Error: Cannot find module') { exit 1 } elseif ($content -match 'SillyTavern is listening on:') { exit 0 } else { exit 2 } } catch { exit 2 }"
set "ps_errorlevel=%errorlevel%"
if %ps_errorlevel% equ 0 (
echo %blue_bg%[%time%]%reset% %blue_fg_strong%[INFO]%reset% %green_fg_strong%SillyTavern Launched Successfully. Returning home...%reset%
timeout /t 10
exit /b 0
) else if %ps_errorlevel% equ 1 (
echo %red_bg%[%time%]%reset% %red_fg_strong%[ERROR] Node.js Code: MODULE_NOT_FOUND%reset%
goto :attemptnodefix
) else (
timeout /t 3 > nul
goto :loop
)
:attemptnodefix
set /p "choice=Run troubleshooter to fix this error? (If yes, close any open SillyTavern Command Windows first) [Y/n]: "
if /i "%choice%"=="" set choice=Y
if /i "%choice%"=="Y" (
set "caller=home"
call %base_dir%\functions\troubleshooting\remove_node_modules.bat
if %errorlevel% equ 0 goto :home
)
exit /b 1

View File

@@ -0,0 +1,22 @@
@echo off
REM Set base directory
set "base_dir=%~dp0\..\.."
:export_dxdiag
REM Ensure the logs directory exists
if not exist "%base_dir%\logs" (
mkdir "%base_dir%\logs"
)
echo %blue_bg%[%time%]%reset% %blue_fg_strong%[INFO]%reset% Exporting DirectX Diagnostic Tool information...
dxdiag /t "%base_dir%\logs\dxdiag_info.txt"
echo %blue_bg%[%time%]%reset% %blue_fg_strong%[INFO]%reset% %green_fg_strong%You can find the dxdiag_info.txt at: "bin\logs\dxdiag_info.txt"%reset%
pause
if "%caller%"=="home" (
exit /b 1
) else (
exit /b 0
)

View File

@@ -0,0 +1,78 @@
@echo off
REM Set base directory
set "base_dir=%~dp0\..\.."
REM Function to find and display the application using the specified port
:find_app_port
cls
setlocal EnableDelayedExpansion
set /p port_choice="(0 to cancel)Insert port number: "
if "%port_choice%"=="0" goto :troubleshooting
REM Check if the input is a number
set "valid=true"
for /f "delims=0123456789" %%i in ("!port_choice!") do set "valid=false"
if "!valid!"=="false" (
echo %red_bg%[%time%]%reset% %red_fg_strong%[ERROR] Invalid input: Not a number.%reset%
pause
goto :troubleshooting
)
REM Check if the port is within range
if !port_choice! gtr 65535 (
echo %red_bg%[%time%]%reset% %red_fg_strong%[ERROR] Port out of range. There are only 65,535 possible port numbers.%reset%
echo [0-1023]: These ports are reserved for system services or commonly used protocols.
echo [1024-49151]: These ports can be used by user processes or applications.
echo [49152-65535]: These ports are available for use by any application or service on the system.
pause
goto :troubleshooting
)
echo %blue_bg%[%time%]%reset% %blue_fg_strong%[INFO]%reset% Searching for application using port: !port_choice!...
for /f "tokens=5" %%a in ('netstat -aon ^| findstr /r "\<!port_choice!\>"') do (
set pid=%%a
)
if defined pid (
for /f "tokens=2*" %%b in ('tasklist /fi "PID eq !pid!" /fo list ^| find "Image Name"') do (
set app_name=%%c
echo Application Name: %cyan_fg_strong%!app_name!%reset%
echo PID of Port !port_choice!: %cyan_fg_strong%!pid!%reset%
REM Fetch the page title for the specified port
call :fetch_page_title !port_choice!
if defined PAGE_TITLE (
echo Title of Application: %cyan_fg_strong%!PAGE_TITLE!%reset%
) else (
echo %yellow_bg%[%time%]%reset% %yellow_fg_strong%[WARN]%reset% Could not retrieve page title.
)
)
) else (
echo %yellow_bg%[%time%]%reset% %yellow_fg_strong%[WARN]%reset% Port: !port_choice! not found.
)
endlocal
pause
goto :port_exit
:fetch_page_title
setlocal
set "PORT=%1"
set "URL=http://localhost:%PORT%"
REM Use JScript to fetch and parse the title
for /f "delims=" %%I in ('cscript /nologo "%base_dir%\functions\troubleshooting\fetch_title.js" "%URL%"') do (
set "PAGE_TITLE=%%I"
)
endlocal & set "PAGE_TITLE=%PAGE_TITLE%"
goto :EOF
:port_exit
if "%caller%"=="home" (
exit /b 1
) else (
exit /b 0
)

View File

@@ -0,0 +1,94 @@
@echo off
REM Set base directory
set "base_dir=%~dp0\..\.."
:onboarding_flow
REM Scan for user folders
set "user_folders="
for /d %%d in ("%st_install_path%\data\*") do (
if /i not "%%~nxd"=="_storage" if /i not "%%~nxd"=="_uploads" (
set "user_folders=!user_folders!%%~nxd|"
)
)
REM Remove the trailing pipe character
set "user_folders=%user_folders:~0,-1%"
REM Split user_folders into an array
setlocal enabledelayedexpansion
set i=1
set "user_count=0"
for %%a in (%user_folders:|= %) do (
echo !i!. %%a
set "user_folder_!i!=%%a"
set /a i+=1
set /a user_count+=1
)
REM If only one user folder is found, skip the selection
if %user_count%==1 (
set "selected_user_folder=!user_folder_1!"
goto skip_user_selection
)
:select_user_folder
REM Prompt user to select a folder
set "selected_user_folder="
set /p user_choice="Select a user folder (1-%user_count%) or press 0 to exit: "
REM Check if the user wants to exit
if "%user_choice%"=="0" (
if "%caller%"=="home" (
exit /b 1
) else (
exit /b 0
)
)
REM Get the selected folder name
for /l %%i in (1,1,%user_count%) do (
if "%user_choice%"=="%%i" set "selected_user_folder=!user_folder_%%i!"
)
if "%selected_user_folder%"=="" (
echo Invalid selection. Please enter a number between 1 and %user_count%, or press 0 to exit.
goto select_user_folder
)
:skip_user_selection
REM Replace backslashes with double backslashes in st_install_path
set "escaped_st_install_path=%st_install_path:\=\\%"
REM Get the current value of the Onboarding Flow setting using Node.js
for /f "tokens=*" %%i in ('node -e "const fs = require(`fs`); const path = require(`path`); const settingsPath = path.join(`%escaped_st_install_path%`, `data`, `%selected_user_folder%`, `settings.json`); const settings = JSON.parse(fs.readFileSync(settingsPath, `utf-8`)); console.log(settings.firstRun);"') do (
set "current_onboarding_value=%%i"
)
echo %blue_fg_strong%[INFO]%reset% Current Onboarding Flow value is: %yellow_fg_strong% %current_onboarding_value% %reset%
REM Toggle the value
if /i "%current_onboarding_value%"=="true" (
set "new_onboarding_value=false"
) else (
set "new_onboarding_value=true"
)
echo %blue_fg_strong%[INFO]%reset% New Onboarding Flow value will be: %green_fg_strong% %new_onboarding_value% %reset%
REM Prompt for confirmation to toggle the value
set /p confirm="Do you want to toggle the Onboarding Flow value to %new_onboarding_value%? (Y/N): "
if /i "%confirm%"=="Y" (
REM Update settings.json in the selected user folder using Node.js
node -e "const fs = require(`fs`); const path = require(`path`); const settingsPath = path.join(`%escaped_st_install_path%`, `data`, `%selected_user_folder%`, `settings.json`); const settings = JSON.parse(fs.readFileSync(settingsPath, `utf-8`)); settings.firstRun = %new_onboarding_value%; fs.writeFileSync(settingsPath, JSON.stringify(settings, null, 2)); console.log('Saving...');"
echo %green_fg_strong%[INFO]%reset% Onboarding flow updated for user: %selected_user_folder% to: %green_fg_strong%%new_onboarding_value%%reset%.
) else (
echo %blue_fg_strong%[INFO]%reset% No changes made.
)
pause
if "%caller%"=="home" (
exit /b 1
) else (
exit /b 0
)

View File

@@ -0,0 +1,18 @@
@echo off
REM Set base directory
set "base_dir=%~dp0\..\.."
:remove_node_modules
echo %blue_bg%[%time%]%reset% %blue_fg_strong%[INFO]%reset% Removing node_modules folder...
cd /d "%st_install_path%"
rmdir /s /q "node_modules"
del package-lock.json
call npm cache clean --force
echo %blue_bg%[%time%]%reset% %blue_fg_strong%[INFO]%reset% node_modules successfully removed.
pause
if "%caller%"=="home" (
exit /b 1
) else (
exit /b 0
)

View File

@@ -0,0 +1,22 @@
@echo off
REM Set base directory
set "base_dir=%~dp0\..\.."
:remove_pip_cache
echo %blue_bg%[%time%]%reset% %blue_fg_strong%[INFO]%reset% Clearing pip cache...
pip cache purge
if %errorlevel% neq 0 (
echo %red_bg%[%time%]%reset% %red_fg_strong%[ERROR] Could not clear the pip cache.%reset%
echo Please try again.
pause
goto :pip_exit
)
echo %blue_bg%[%time%]%reset% %blue_fg_strong%[INFO]%reset% %green_fg_strong%The pip cache has been cleared successfully.%reset%
pause
:pip_exit
if "%caller%"=="home" (
exit /b 1
) else (
exit /b 0
)

View File

@@ -0,0 +1,19 @@
@echo off
REM Set base directory
set "base_dir=%~dp0\..\.."
:unresolved_unmerged
echo %blue_bg%[%time%]%reset% %blue_fg_strong%[INFO]%reset% Trying to resolve unresolved conflicts in the working directory or unmerged files...
cd /d "%st_install_path%"
git merge --abort
git reset --hard
git pull --rebase --autostash
echo %blue_bg%[%time%]%reset% %blue_fg_strong%[INFO]%reset% Done.
pause
if "%caller%"=="home" (
exit /b 1
) else (
exit /b 0
)