further deployment implementation to .config directory
This commit is contained in:
@@ -55,9 +55,10 @@ $specs = @(
|
||||
@{ Name = 'NewDaily.bat'; Source = Join-Path -Path $structDir -ChildPath 'NewDaily.bat' }
|
||||
)
|
||||
|
||||
$sharedAssets = @(
|
||||
@{ Name = 'ConfigLoader.ps1'; Source = Join-Path -Path $structDir -ChildPath 'ConfigLoader.ps1' },
|
||||
@{ Name = 'config.json'; Source = Join-Path -Path $structDir -ChildPath 'config.json' }
|
||||
# Config files to deploy to projectroot\.config\
|
||||
$configAssets = @(
|
||||
@{ Name = 'config.json'; Source = Join-Path -Path $structDir -ChildPath 'config.json' },
|
||||
@{ Name = 'GetStructDir.ps1'; Source = Join-Path -Path $structDir -ChildPath 'GetStructDir.ps1' }
|
||||
)
|
||||
|
||||
foreach ($spec in $specs) {
|
||||
@@ -67,13 +68,20 @@ foreach ($spec in $specs) {
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($asset in $sharedAssets) {
|
||||
foreach ($asset in $configAssets) {
|
||||
if (-not (Test-Path -LiteralPath $asset.Source -PathType Leaf)) {
|
||||
Write-Error "Shared asset not found: $($asset.Source)"
|
||||
Write-Error "Config asset not found: $($asset.Source)"
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
|
||||
# Ensure .config directory exists in project root
|
||||
$projectConfigDir = Join-Path -Path $resolvedProject -ChildPath '.config'
|
||||
if (-not (Test-Path -LiteralPath $projectConfigDir -PathType Container)) {
|
||||
New-Item -Path $projectConfigDir -ItemType Directory -Force | Out-Null
|
||||
Write-Host "Created .config directory: $projectConfigDir" -ForegroundColor Cyan
|
||||
}
|
||||
|
||||
$touchedDirs = @{}
|
||||
$summary = @()
|
||||
|
||||
@@ -106,14 +114,6 @@ foreach ($spec in $specs) {
|
||||
|
||||
$targetDir = $target.Directory.FullName
|
||||
if (-not $touchedDirs.ContainsKey($targetDir)) {
|
||||
foreach ($asset in $sharedAssets) {
|
||||
try {
|
||||
Copy-Item -Path $asset.Source -Destination (Join-Path -Path $targetDir -ChildPath $asset.Name) -Force
|
||||
}
|
||||
catch {
|
||||
Write-Host " [FAIL] Failed to copy $($asset.Name) into ${targetDir}: $($_.Exception.Message)" -ForegroundColor Red
|
||||
}
|
||||
}
|
||||
$touchedDirs[$targetDir] = $true
|
||||
}
|
||||
}
|
||||
@@ -145,3 +145,20 @@ if (($summary | Measure-Object -Property Failed -Sum).Sum -gt 0) {
|
||||
|
||||
Write-Host "All batch files refreshed successfully." -ForegroundColor Green
|
||||
|
||||
# Deploy config files to projectroot\.config\
|
||||
Write-Host "`n=== Deploying config files to .config\ ===" -ForegroundColor Magenta
|
||||
foreach ($asset in $configAssets) {
|
||||
$targetPath = Join-Path -Path $projectConfigDir -ChildPath $asset.Name
|
||||
try {
|
||||
Copy-Item -Path $asset.Source -Destination $targetPath -Force
|
||||
Write-Host "[OK] $targetPath" -ForegroundColor Green
|
||||
}
|
||||
catch {
|
||||
Write-Host "[FAIL] $targetPath" -ForegroundColor Red
|
||||
Write-Host " $($_.Exception.Message)" -ForegroundColor DarkRed
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
|
||||
Write-Host "Config files deployed successfully." -ForegroundColor Green
|
||||
|
||||
|
||||
Reference in New Issue
Block a user