88 lines
1.9 KiB
Batchfile
88 lines
1.9 KiB
Batchfile
@echo off
|
|
setlocal EnableExtensions EnableDelayedExpansion
|
|
|
|
::
|
|
:: Generate test data script for webstore backend
|
|
:: Usage: generate-test-data.bat [--products N] [--orders N] [--reset]
|
|
::
|
|
:: Examples:
|
|
:: generate-test-data.bat (Creates 10 products, 5 orders)
|
|
:: generate-test-data.bat --products 20 (Creates 20 products, 5 orders)
|
|
:: generate-test-data.bat --products 50 --orders 10 --reset (Resets DB and generates data)
|
|
::
|
|
|
|
cd /d "%~dp0.."
|
|
|
|
echo.
|
|
echo ========================================
|
|
echo Test Data Generator for Webstore
|
|
echo ========================================
|
|
echo.
|
|
|
|
set "PRODUCTS=10"
|
|
set "ORDERS=5"
|
|
set "RESET_FLAG="
|
|
|
|
:parse_args
|
|
if "%~1"=="" goto start_generation
|
|
if "%~1"=="--products" (
|
|
if "%~2"=="" (
|
|
echo ERROR: --products requires a number argument
|
|
exit /b 1
|
|
)
|
|
set "PRODUCTS=%~2"
|
|
shift
|
|
shift
|
|
goto parse_args
|
|
)
|
|
if "%~1"=="--orders" (
|
|
if "%~2"=="" (
|
|
echo ERROR: --orders requires a number argument
|
|
exit /b 1
|
|
)
|
|
set "ORDERS=%~2"
|
|
shift
|
|
shift
|
|
goto parse_args
|
|
)
|
|
if "%~1"=="--reset" (
|
|
set "RESET_FLAG=--reset"
|
|
shift
|
|
goto parse_args
|
|
)
|
|
shift
|
|
goto parse_args
|
|
|
|
:start_generation
|
|
echo Configuration:
|
|
echo Products to generate: %PRODUCTS%
|
|
echo Orders to generate: %ORDERS%
|
|
if defined RESET_FLAG (
|
|
echo Reset database: YES (WARNING: All data will be deleted!)
|
|
) else (
|
|
echo Reset database: NO
|
|
)
|
|
echo.
|
|
|
|
echo Checking Node.js availability...
|
|
node --version >nul 2>&1
|
|
if errorlevel 1 (
|
|
echo ERROR: Node.js is not installed or not in PATH
|
|
exit /b 1
|
|
)
|
|
|
|
echo Running test data generator...
|
|
node scripts/generate-test-data.js --products %PRODUCTS% --orders %ORDERS% %RESET_FLAG%
|
|
|
|
if errorlevel 1 (
|
|
echo.
|
|
echo ERROR: Test data generation failed!
|
|
exit /b 1
|
|
)
|
|
|
|
echo.
|
|
echo ========================================
|
|
echo ✓ Test data generated successfully!
|
|
echo ========================================
|
|
exit /b 0
|