2020-11-11 21:38:56 +00:00
|
|
|
[CmdletBinding(SupportsShouldProcess)]param(
|
2021-03-23 05:06:49 +00:00
|
|
|
[ArgumentCompleter({Invoke-Command -ScriptBlock $_DockerComposeDirsCompleter -ArgumentList $args})]
|
2020-11-11 21:38:56 +00:00
|
|
|
[string[]]$ProjectPath=@($PWD),
|
|
|
|
[switch]$Force,
|
|
|
|
[string[]]$AdditionalFiles
|
|
|
|
|
|
|
|
)
|
2020-10-31 21:10:32 +00:00
|
|
|
|
2021-01-14 22:24:29 +00:00
|
|
|
$local:EditCandidates = @('docker-compose.###','.base.docker-compose.###')
|
|
|
|
$local:EditBonus = @('Dockerfile', '.env', '*.env')
|
2020-10-31 21:10:32 +00:00
|
|
|
$local:editFiles = @()
|
2021-01-14 22:24:29 +00:00
|
|
|
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
|
2021-01-19 00:04:39 +00:00
|
|
|
$editFiles += Get-ChildItem $(Join-Path $path '*') -Include $EditBonus -Depth 1 |
|
|
|
|
Select-Object -ExpandProperty FullName
|
2021-01-14 22:24:29 +00:00
|
|
|
}
|
|
|
|
}
|
2020-10-31 21:10:32 +00:00
|
|
|
}
|
2021-01-19 00:04:39 +00:00
|
|
|
if( $editFiles ) {
|
|
|
|
break
|
|
|
|
}
|
2020-10-31 21:10:32 +00:00
|
|
|
}
|
|
|
|
|
2021-01-24 02:46:48 +00:00
|
|
|
$AdditionalFiles = $AdditionalFiles | Where-Object { $_ } | ForEach-Object {
|
2021-01-24 02:25:39 +00:00
|
|
|
$_ -replace
|
|
|
|
'^#lsi$','#/*linuxserver.yml' -replace
|
|
|
|
'^#tr?$','#/*traefik.yml' -replace
|
|
|
|
'^#/',"$env:SZ_DOCKER_SYSTEM_PATH"
|
|
|
|
} |
|
|
|
|
Get-ChildItem -Force |
|
|
|
|
Select-Object -ExpandProperty FullName
|
|
|
|
|
2021-01-19 00:04:39 +00:00
|
|
|
$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"
|
|
|
|
}
|
2021-02-04 00:43:12 +00:00
|
|
|
$FinalEditList = (@() + $FinalEditList + @() + $AdditionalFiles) | Select-Object -Unique
|
2021-01-19 00:04:39 +00:00
|
|
|
|
|
|
|
Edit-TextFile $FinalEditList
|
2020-10-31 21:10:32 +00:00
|
|
|
|
2021-01-24 03:07:36 +00:00
|
|
|
dcc -ProjectPath $ProjectPath -TestOnly
|