[CmdletBinding(SupportsShouldProcess)]param( [ArgumentCompleter({Invoke-Command -ScriptBlock $_DockerComposeDirsCompleter -ArgumentList $args})] [string[]]$ProjectPath=@($PWD), [switch]$Force, [string[]]$AdditionalFiles ) $local:EditCandidates = @('docker-compose.###','.base.docker-compose.###') $local:EditBonus = @('Dockerfile', '.env', '*.env') $local:editFiles = @() foreach( $local:ext in @('.yml', '.yaml') ) { $local:rawEditCandidates = $EditCandidates | ForEach-Object { $_ -replace '\.###',$ext } foreach( $local:fileName in $rawEditCandidates ) { foreach( $local:path in $ProjectPath ) { $local:testPath = Join-Path $path $fileName if( $Force -or $(Test-Path $testPath) ) { $editFiles += $testPath $editFiles += Get-ChildItem $(Join-Path $path '*') -Include $EditBonus -Depth 1 | Select-Object -ExpandProperty FullName } } } if( $editFiles ) { break } } $AdditionalFiles = $AdditionalFiles | Where-Object { $_ } | ForEach-Object { $_ -replace '^#lsi$','#/*linuxserver.yml' -replace '^#tr?$','#/*traefik.yml' -replace '^#/',"$env:SZ_DOCKER_SYSTEM_PATH" } | Get-ChildItem -Force | Select-Object -ExpandProperty FullName $local:FinalEditList = $editFiles | Where-Object {$_} | Sort-Object { $local:n = [System.IO.Path]::GetFileName($_) Join-Path [PSystem.IO.ath]::GetDirectoryName($_) "$(if( $n[0] -eq '.' ) { "9" } else { "1" })$n" } $FinalEditList = (@() + $FinalEditList + @() + $AdditionalFiles) | Select-Object -Unique Edit-TextFile $FinalEditList dcc -ProjectPath $ProjectPath -TestOnly