# Deliberately use $args: unknown switches belong to the underlying command. $ErrorActionPreference = 'Stop' $Command = if ($args.Count) { $args[0] } else { '' } $Forward = @($args | Select-Object -Skip 1) try { switch ($Command) { { $_ -in 'migrate', 'seed' } { [Console]::Error.WriteLine("$Command unavailable until M2 (#12); #10 remains open") exit 1 } 'up' { $ComposeArgs = @('up', '-d', '--build') } 'down' { foreach ($Argument in $Forward) { if ($Argument -match '^--volumes|^-v$') { [Console]::Error.WriteLine('Volume removal is forbidden by this wrapper') exit 2 } } $ComposeArgs = @('down') } { $_ -in 'test', 'lint' } { $ComposeArgs = @('run', '--rm', '--no-deps', '-T', '--entrypoint', 'composer', 'app', $Command) } 'assets' { $ComposeArgs = @('run', '--rm', '--no-deps', '-T', 'assets', 'npm', 'run', 'build', '--') } { $_ -in 'watch', 'assets:watch' } { $ComposeArgs = @('run', '--rm', '--no-deps', '-T', 'assets', 'npm', 'run', 'watch', '--') } default { [Console]::Error.WriteLine('Usage: dev.ps1 up|down|test|lint|assets|watch|migrate|seed [arguments]') exit 2 } } Push-Location $PSScriptRoot try { & docker compose @ComposeArgs @Forward $Result = $LASTEXITCODE } finally { Pop-Location } exit $Result } catch { [Console]::Error.WriteLine($_.Exception.Message) exit 1 }