diff --git a/package.json b/package.json index 82a4e2939..fc1d4eb5c 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,6 @@ "description": "", "scripts": { "test": "echo \"Error: no test specified\" && exit 1", - "postinstall": "(cd ./api && npm install) ; (cd ./ui && npm install) ; (cd ./upload-api && npm install)", "env": "npm start", "api": "cd ./api && npm run dev", "upload": "cd ./upload-api && npm run dev", @@ -44,4 +43,4 @@ "dependencies": { "@contentstack/cli-utilities": "^1.8.4" } -} +} \ No newline at end of file diff --git a/setup-continue.bat b/setup-continue.bat new file mode 100644 index 000000000..b09830986 --- /dev/null +++ b/setup-continue.bat @@ -0,0 +1,15 @@ +@echo off +SET SCRIPT_DIR=%~dp0 +CD /D "%SCRIPT_DIR%" + +echo Using Node version: +node -v + +call npm run setup:file +call npm run create:env + +start "API" cmd /k "cd /d %SCRIPT_DIR%\api && npm install && npm run windev" +start "Upload API" cmd /k "cd /d %SCRIPT_DIR%\upload-api && npm install && npm run start" +start "UI" cmd /k "cd /d %SCRIPT_DIR%\ui && npm install && npm run start" + +echo All services started! \ No newline at end of file diff --git a/setup-nvm.bat b/setup-nvm.bat new file mode 100644 index 000000000..885033ee0 --- /dev/null +++ b/setup-nvm.bat @@ -0,0 +1,52 @@ +@echo off +SETLOCAL + +echo Checking if NVM is already installed... + +where nvm >nul 2>nul +IF %ERRORLEVEL% EQU 0 ( + echo NVM is already installed. Skipping installation. + goto run_setup +) + +echo NVM not found. Checking for winget... + +where winget >nul 2>nul +IF %ERRORLEVEL% EQU 0 ( + echo Installing NVM using winget... + winget install -e --id CoreyButler.NVMforWindows + goto check_nvm +) + +echo winget not found. Installing NVM manually... +SET NVM_URL=https://github.com/coreybutler/nvm-windows/releases/latest/download/nvm-setup.exe +SET NVM_INSTALLER=%TEMP%\nvm-setup.exe + +IF EXIST "%NVM_INSTALLER%" DEL /F /Q "%NVM_INSTALLER%" + +powershell -Command "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; Invoke-WebRequest -Uri '%NVM_URL%' -OutFile '%NVM_INSTALLER%'" + +IF EXIST "%NVM_INSTALLER%" ( + echo Running NVM installer... + start /wait "" "%NVM_INSTALLER%" +) ELSE ( + echo Failed to download NVM installer. + pause + exit /b 1 +) + +:check_nvm +echo Verifying NVM installation... + +where nvm >nul 2>nul +IF %ERRORLEVEL% NEQ 0 ( + echo NVM installation failed or not detected in PATH. + echo Please restart your terminal and try again, or install manually: + echo https://github.com/coreybutler/nvm-windows + pause + exit /b 1 +) + +:run_setup +echo NVM is ready. Running setup.bat... +call setup.bat diff --git a/setup.bat b/setup.bat new file mode 100644 index 000000000..f8d1001e0 --- /dev/null +++ b/setup.bat @@ -0,0 +1,10 @@ +SETLOCAL ENABLEDELAYEDEXPANSION + +SET SCRIPT_DIR=%~dp0 +CD /D "%SCRIPT_DIR%" + +call nvm install 21 +call nvm use 21 + +REM Call second script in a new process to reload env +start "" cmd /k "%SCRIPT_DIR%setup-continue.bat" \ No newline at end of file