feat: Add Windows build and run automation scripts (#8861)
* 🔧 (build_and_run.bat): Add a Windows batch script to build frontend, copy build files to backend, and run Langflow 🔧 (build_and_run.ps1): Add a Windows PowerShell script to build frontend, copy build files to backend, and run Langflow * 📝 scripts/windows/build_and_run.bat: improve script messages for better clarity and consistency 📝 scripts/windows/build_and_run.ps1: update script steps numbering and messages for consistency and clarity * 📝 (build_and_run.bat): Add attention message to wait for uvicorn to run before opening the browser 📝 (build_and_run.ps1): Add attention message to wait for uvicorn to run before opening the browser
This commit is contained in:
parent
c8b9aafe56
commit
78d64eb7af
2 changed files with 168 additions and 0 deletions
84
scripts/windows/build_and_run.bat
Normal file
84
scripts/windows/build_and_run.bat
Normal file
|
|
@ -0,0 +1,84 @@
|
|||
@echo off
|
||||
echo Starting Langflow build and run process...
|
||||
|
||||
echo.
|
||||
echo Step 1: Installing frontend dependencies...
|
||||
cd ..\..\src\frontend
|
||||
if errorlevel 1 (
|
||||
echo Error: Could not navigate to src\frontend directory
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
echo Running npm install...
|
||||
call npm install
|
||||
if errorlevel 1 (
|
||||
echo Error: npm install failed
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
echo.
|
||||
echo Step 2: Building frontend...
|
||||
echo Running npm run build...
|
||||
call npm run build
|
||||
if errorlevel 1 (
|
||||
echo Error: npm run build failed
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
echo.
|
||||
echo Step 3: Copying build files to backend...
|
||||
cd ..\..
|
||||
|
||||
REM Check if build directory exists
|
||||
if not exist "src\frontend\build" (
|
||||
if not exist "src\frontend\dist" (
|
||||
echo Error: Neither build nor dist directory found in src\frontend
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
set BUILD_DIR=src\frontend\dist
|
||||
) else (
|
||||
set BUILD_DIR=src\frontend\build
|
||||
)
|
||||
|
||||
echo Copying from %BUILD_DIR% to src\backend\base\langflow\frontend\
|
||||
REM Create target directory if it doesn't exist
|
||||
if not exist "src\backend\base\langflow\frontend" (
|
||||
mkdir "src\backend\base\langflow\frontend"
|
||||
)
|
||||
|
||||
REM Remove existing files in target directory (FORCES CLEAN REPLACEMENT)
|
||||
echo Removing existing files from target directory...
|
||||
if exist "src\backend\base\langflow\frontend\*" (
|
||||
del /q /s "src\backend\base\langflow\frontend\*"
|
||||
for /d %%d in ("src\backend\base\langflow\frontend\*") do rmdir /s /q "%%d"
|
||||
)
|
||||
|
||||
REM Copy all files from build directory
|
||||
xcopy "%BUILD_DIR%\*" "src\backend\base\langflow\frontend\" /e /i /y
|
||||
if errorlevel 1 (
|
||||
echo Error: Failed to copy build files
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
echo Build files copied successfully!
|
||||
|
||||
echo.
|
||||
echo Step 4: Running Langflow...
|
||||
echo.
|
||||
echo Attention: Wait until uvicorn is running before opening the browser
|
||||
echo.
|
||||
uv run langflow run
|
||||
if errorlevel 1 (
|
||||
echo Error: Failed to run langflow
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
echo.
|
||||
echo Langflow build and run process completed!
|
||||
pause
|
||||
84
scripts/windows/build_and_run.ps1
Normal file
84
scripts/windows/build_and_run.ps1
Normal file
|
|
@ -0,0 +1,84 @@
|
|||
#!/usr/bin/env pwsh
|
||||
|
||||
Write-Host "Starting Langflow build and run process..." -ForegroundColor Green
|
||||
|
||||
# Step 1: Install frontend dependencies
|
||||
Write-Host "`nStep 1: Installing frontend dependencies..." -ForegroundColor Yellow
|
||||
try {
|
||||
Set-Location "..\..\src\frontend"
|
||||
Write-Host "Running npm install..."
|
||||
npm install
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
throw "npm install failed"
|
||||
}
|
||||
} catch {
|
||||
Write-Host "Error in frontend dependency installation: $_" -ForegroundColor Red
|
||||
Read-Host "Press Enter to exit"
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Step 2: Build frontend
|
||||
Write-Host "`nStep 2: Building frontend..." -ForegroundColor Yellow
|
||||
try {
|
||||
Write-Host "Running npm run build..."
|
||||
npm run build
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
throw "npm run build failed"
|
||||
}
|
||||
} catch {
|
||||
Write-Host "Error in frontend build: $_" -ForegroundColor Red
|
||||
Read-Host "Press Enter to exit"
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Step 3: Copy build files
|
||||
Write-Host "`nStep 3: Copying build files to backend..." -ForegroundColor Yellow
|
||||
try {
|
||||
Set-Location "..\.."
|
||||
|
||||
# Determine build directory
|
||||
$buildDir = if (Test-Path "src\frontend\build") {
|
||||
"src\frontend\build"
|
||||
} elseif (Test-Path "src\frontend\dist") {
|
||||
"src\frontend\dist"
|
||||
} else {
|
||||
throw "Neither build nor dist directory found in src\frontend"
|
||||
}
|
||||
|
||||
$targetDir = "src\backend\base\langflow\frontend"
|
||||
Write-Host "Copying from $buildDir to $targetDir"
|
||||
|
||||
# Create target directory if it doesn't exist
|
||||
if (-not (Test-Path $targetDir)) {
|
||||
New-Item -Path $targetDir -ItemType Directory -Force | Out-Null
|
||||
}
|
||||
|
||||
# Remove existing files in target directory (FORCES CLEAN REPLACEMENT)
|
||||
Write-Host "Removing existing files from target directory..." -ForegroundColor Cyan
|
||||
if (Test-Path "$targetDir\*") {
|
||||
Remove-Item "$targetDir\*" -Recurse -Force
|
||||
}
|
||||
|
||||
# Copy all files from build directory
|
||||
Copy-Item "$buildDir\*" -Destination $targetDir -Recurse -Force
|
||||
Write-Host "Build files copied successfully!" -ForegroundColor Green
|
||||
|
||||
} catch {
|
||||
Write-Host "Error copying files: $_" -ForegroundColor Red
|
||||
Read-Host "Press Enter to exit"
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Step 4: Run Langflow
|
||||
Write-Host "`nStep 4: Running Langflow..." -ForegroundColor Yellow
|
||||
Write-Host "`nAttention: Wait until uvicorn is running before opening the browser" -ForegroundColor Red
|
||||
try {
|
||||
uv run langflow run
|
||||
} catch {
|
||||
Write-Host "Error running langflow: $_" -ForegroundColor Red
|
||||
Read-Host "Press Enter to exit"
|
||||
exit 1
|
||||
}
|
||||
|
||||
Write-Host "`nLangflow build and run process completed!" -ForegroundColor Green
|
||||
Read-Host "Press Enter to exit"
|
||||
Loading…
Add table
Add a link
Reference in a new issue