22param (
33 [string ]$StagingRoot ,
44 [switch ]$RemoveMetadata ,
5+ [string ]$EnvFilePath ,
56 [switch ]$Apply ,
67 [switch ]$DryRun ,
78 [switch ]$ConfirmDestructive
@@ -13,16 +14,19 @@ $ErrorActionPreference = "Stop"
1314. (Join-Path $PSScriptRoot " WebsiteRepoDeploymentCommon.ps1" )
1415Assert-DeployScriptLocation - ScriptPath $PSCommandPath
1516$executionMode = Resolve-DeployExecutionMode - Apply:$Apply.IsPresent - DryRun:$DryRun.IsPresent
17+ $resolvedRemoveMetadata = if ($PSBoundParameters.ContainsKey (" RemoveMetadata" )) { [Nullable [bool ]]$RemoveMetadata.IsPresent } else { $null }
18+ $config = Resolve-DeployScriptConfig - StagingRoot $StagingRoot - RemoveMetadata $resolvedRemoveMetadata - EnvFilePath $EnvFilePath
19+ Write-DeployConfigLoadLog - ScriptName " Clean-WebsiteRepoDeployment" - Config $config
1620
17- $paths = Get-WebsiteDeploymentPaths - StagingRoot $StagingRoot
21+ $paths = Get-WebsiteDeploymentPaths - StagingRoot $config .stagingRoot
1822Test-StagingRootSafety - StagingRoot $paths.stagingRoot
1923$environment = Assert-DeployEnvironmentReadiness - Paths $paths
2024
2125$targets = New-Object System.Collections.Generic.List[string ]
2226if (Test-Path - LiteralPath $paths.siteRoot ) {
2327 $targets.Add ($paths.siteRoot )
2428}
25- if ($RemoveMetadata .IsPresent ) {
29+ if ($config .removeMetadata ) {
2630 foreach ($metadataPath in @ ($paths.planPath , $paths.updateReportPath , $paths.dockerfilePath , $paths.composePath , $paths.dockerIgnorePath )) {
2731 if (Test-Path - LiteralPath $metadataPath ) {
2832 $targets.Add ($metadataPath )
@@ -34,6 +38,7 @@ if ($targets.Count -eq 0) {
3438 Write-DeployLog - Level " INFO" - Message " Nothing to clean." - Data @ {
3539 script = " Clean-WebsiteRepoDeployment"
3640 stagingRoot = $paths.stagingRoot
41+ removeMetadata = $config.removeMetadata
3742 }
3843 exit 0
3944}
@@ -46,6 +51,7 @@ if ($executionMode.isDryRun) {
4651 targets = @ ($targets )
4752 dockerCliFound = $environment.dockerCliFound
4853 destructiveConfirmationRequired = $true
54+ removeMetadata = $config.removeMetadata
4955 }
5056 Write-DeployLog - Level " INFO" - Message " Next step: run Clean-WebsiteRepoDeployment.ps1 -Apply -ConfirmDestructive after reviewing the dry-run output."
5157 exit 0
@@ -68,4 +74,5 @@ Write-DeployLog -Level "SUCCESS" -Message "Cleaned website deployment artifacts.
6874 mode = $executionMode.label
6975 targetCount = $targets.Count
7076 dockerCliFound = $environment.dockerCliFound
77+ removeMetadata = $config.removeMetadata
7178}
0 commit comments