-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart-dev.ps1
More file actions
87 lines (74 loc) · 3.09 KB
/
start-dev.ps1
File metadata and controls
87 lines (74 loc) · 3.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# Script to start Personal Task Manager development environment
# Save as start-dev.ps1
# Function to check if a process is running
function Test-ProcessRunning {
param($ProcessName)
$process = Get-Process -Name $ProcessName -ErrorAction SilentlyContinue
return $null -ne $process
}
# Get the root directory (assuming script is in the project root)
$rootDir = $PSScriptRoot
$backendDir = Join-Path $rootDir "personal-task-manager/backend"
$frontendDir = Join-Path $rootDir "personal-task-manager"
# Start backend service in a new PowerShell window
$backendScript = @"
Set-Location "$backendDir"
Write-Host "Activating virtual environment..."
.\\venv\\Scripts\\Activate.ps1
Write-Host "Starting backend server..."
`$host.UI.RawUI.WindowTitle = 'Backend Server'
# Verify .env file exists and has correct path
if (-not (Test-Path ".env")) {
Write-Host "Warning: .env file not found in backend directory - this will cause login issues" -ForegroundColor Red
}
# Start the server in the same directory context (important for .env file path resolution)
uvicorn main:app --reload
"@
$backendProcess = Start-Process powershell -ArgumentList "-NoExit", "-Command", $backendScript -WindowStyle Normal -PassThru
# Minimize the backend window (if desired)
Start-Sleep -Seconds 3
if ($backendProcess -ne $null) {
Add-Type -TypeDefinition @"
using System;
using System.Runtime.InteropServices;
public class WindowTools {
[DllImport("user32.dll")]
public static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);
}
"@
[void][WindowTools]::ShowWindow($backendProcess.MainWindowHandle, 6) # 6 is SW_MINIMIZE
}
# Give backend time to start
Start-Sleep -Seconds 5
# Start frontend service in a new PowerShell window
$frontendScript = @"
Set-Location "$frontendDir"
Write-Host "Starting frontend development server..."
`$host.UI.RawUI.WindowTitle = 'Frontend Server'
npm run dev
"@
$frontendProcess = Start-Process powershell -ArgumentList "-NoExit", "-Command", $frontendScript -WindowStyle Normal -PassThru
# Minimize the frontend window (if desired)
Start-Sleep -Seconds 3
if ($frontendProcess -ne $null) {
Add-Type -TypeDefinition @"
using System;
using System.Runtime.InteropServices;
public class WindowTools {
[DllImport("user32.dll")]
public static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);
}
"@
[void][WindowTools]::ShowWindow($frontendProcess.MainWindowHandle, 6) # 6 is SW_MINIMIZE
}
# Open Firefox browser to localhost:3000
Start-Sleep -Seconds 5 # Give frontend time to start
if (Test-ProcessRunning -ProcessName "firefox") {
Start-Process "firefox.exe" -ArgumentList "-new-tab", "http://localhost:3000"
} else {
Start-Process "firefox.exe" -ArgumentList "http://localhost:3000"
}
Write-Host "Development environment started! Both terminal windows have been minimized."
Write-Host ""
Write-Host "NOTE: If you're having login issues, please check that your .env file exists in the backend directory" -ForegroundColor Yellow
Write-Host " and contains the necessary connection_string and secret_key values." -ForegroundColor Yellow