# Setup script for monicahq/monica on Windows (PowerShell), from https://gitmanual.com/monicahq/monica # Read it before you run it: the commands come from the repo's own README and files. # Run: powershell -ExecutionPolicy Bypass -File .\setup.ps1 $ErrorActionPreference = "Stop" function Write-Step($t) { Write-Host "`n==> $t" -ForegroundColor Cyan } # Windows ships a python that only opens the Microsoft Store; it doesn't count. function Have($c) { $cmd = Get-Command $c -ErrorAction SilentlyContinue; [bool]$cmd -and $cmd.Source -notlike '*\WindowsApps\*' } # New installs change PATH; pick it up without opening a new window. function Update-Path { $env:Path = [Environment]::GetEnvironmentVariable("Path", "Machine") + ";" + [Environment]::GetEnvironmentVariable("Path", "User") } # Stop when a program fails, like bash's set -e. Dot-sourced, so cd and venv activation carry on to the next step. function Invoke-Step([scriptblock]$Block) { $global:LASTEXITCODE = 0; . $Block; if ($LASTEXITCODE) { throw "Failed with exit code $LASTEXITCODE" } } Write-Step '1/6 Clone the repository' if (-not (Test-Path 'monica')) { Invoke-Step { git clone https://github.com/monicahq/monica.git } } Set-Location 'monica' Write-Step '2/6 Install the required runtimes' # Node.js 22.13.1, PHP ^8.3 if (-not (Have 'mise') -and -not ((Have 'node') -and (Have 'php'))) { Invoke-Step { winget install jdx.mise -e --accept-source-agreements --accept-package-agreements }; Update-Path } if ((Have 'node') -and (Have 'php')) { Write-Host 'Using the installed node, php' } else { Invoke-Step { mise trust --yes } Invoke-Step { mise install } $env:Path = "$env:LOCALAPPDATA\mise\shims;$env:Path" } Write-Step '3/6 Configure environment variables' # Fill in secrets: APP_KEY, MEILISEARCH_KEY, TYPESENSE_API_KEY, TELEGRAM_BOT_TOKEN, UPLOADCARE_PUBLIC_KEY, UPLOADCARE_PRIVATE_KEY, LOCATION_IQ_API_KEY, MAPBOX_API_KEY if (-not (Test-Path .env)) { Copy-Item .env.example .env; Write-Host 'Created .env. Fill in secrets: APP_KEY, MEILISEARCH_KEY, TYPESENSE_API_KEY, TELEGRAM_BOT_TOKEN, UPLOADCARE_PUBLIC_KEY, UPLOADCARE_PRIVATE_KEY, LOCATION_IQ_API_KEY, MAPBOX_API_KEY in .env, then run this script again.'; exit 0 } Write-Step '4/6 Start backing services' # Needs: MariaDB, Redis, Memcached, Meilisearch, Mail catcher if (-not (Have 'docker')) { Invoke-Step { winget install Docker.DockerDesktop -e --accept-source-agreements --accept-package-agreements }; Update-Path } Invoke-Step { docker compose -f docker-compose.yml up -d } Write-Step '5/6 Install dependencies' Invoke-Step { corepack enable } Invoke-Step { yarn install } Invoke-Step { composer install } Write-Step '6/6 Set up the database / app' Invoke-Step { php artisan key:generate } Invoke-Step { php artisan migrate } Write-Host 'Set up monicahq/monica.' Write-Host 'Fill in secrets: APP_KEY, MEILISEARCH_KEY, TYPESENSE_API_KEY, TELEGRAM_BOT_TOKEN, UPLOADCARE_PUBLIC_KEY, UPLOADCARE_PRIVATE_KEY, LOCATION_IQ_API_KEY, MAPBOX_API_KEY' Write-Host 'Next, from the project folder:' Write-Host ' yarn dev' Write-Host ' php artisan serve' Write-Host ' yarn test' Write-Host 'Manual: https://gitmanual.com/monicahq/monica'