begin develop configloader
This commit is contained in:
@@ -1,28 +1,59 @@
|
||||
# Update subfolders with the latest UpdateSequences and UpdateAllSequences scripts
|
||||
|
||||
$sourceBat = "R:\Creative\artsy\maya\0 ProjectStructure\UpdateSequences.bat"
|
||||
$sourceAllBat = "R:\Creative\artsy\maya\0 ProjectStructure\UpdateAllSequences.bat"
|
||||
Set-StrictMode -Version Latest
|
||||
$ErrorActionPreference = 'Stop'
|
||||
|
||||
if (-not (Test-Path $sourceBat)) { Write-Error "Source file not found: $sourceBat"; exit 1 }
|
||||
if (-not (Test-Path $sourceAllBat)) { Write-Error "Source file not found: $sourceAllBat"; exit 1 }
|
||||
if (-not $PSScriptRoot) {
|
||||
$PSScriptRoot = Split-Path -Parent $MyInvocation.MyCommand.Path
|
||||
}
|
||||
|
||||
$root = "R:\Creative\artsy\maya"
|
||||
$configLoader = Join-Path -Path $PSScriptRoot -ChildPath 'ConfigLoader.ps1'
|
||||
if (-not (Test-Path -LiteralPath $configLoader)) {
|
||||
throw "Missing ConfigLoader.ps1 in $PSScriptRoot"
|
||||
}
|
||||
. $configLoader
|
||||
|
||||
$structDir = Get-StructDirectory
|
||||
$projectsRoot = Get-ProjectsRoot
|
||||
|
||||
$sourceBat = Join-Path -Path $structDir -ChildPath 'UpdateSequences.bat'
|
||||
$sourceAllBat = Join-Path -Path $structDir -ChildPath 'UpdateAllSequences.bat'
|
||||
$sourceZipBat = Join-Path -Path $structDir -ChildPath 'ZipSeqArchv.bat'
|
||||
$sourceUnzipBat = Join-Path -Path $structDir -ChildPath 'UnzipSeqArchv.bat'
|
||||
$configLoaderSource = Join-Path -Path $structDir -ChildPath 'ConfigLoader.ps1'
|
||||
$configJsonSource = Join-Path -Path $structDir -ChildPath 'config.json'
|
||||
|
||||
if (-not (Test-Path -LiteralPath $sourceBat)) { Write-Error "Source file not found: $sourceBat"; exit 1 }
|
||||
if (-not (Test-Path -LiteralPath $sourceAllBat)) { Write-Error "Source file not found: $sourceAllBat"; exit 1 }
|
||||
if (-not (Test-Path -LiteralPath $sourceZipBat)) { Write-Error "Source file not found: $sourceZipBat"; exit 1 }
|
||||
if (-not (Test-Path -LiteralPath $sourceUnzipBat)) { Write-Error "Source file not found: $sourceUnzipBat"; exit 1 }
|
||||
if (-not (Test-Path -LiteralPath $configLoaderSource)) { Write-Error "Config loader not found: $configLoaderSource"; exit 1 }
|
||||
if (-not (Test-Path -LiteralPath $configJsonSource)) { Write-Error "Config file not found: $configJsonSource"; exit 1 }
|
||||
|
||||
$specs = @(
|
||||
@{ Name = "UpdateSequences.bat"; Source = $sourceBat },
|
||||
@{ Name = "UpdateAllSequences.bat"; Source = $sourceAllBat }
|
||||
@{ Name = "UpdateAllSequences.bat"; Source = $sourceAllBat },
|
||||
@{ Name = "ZipSeqArchv.bat"; Source = $sourceZipBat },
|
||||
@{ Name = "UnzipSeqArchv.bat"; Source = $sourceUnzipBat }
|
||||
)
|
||||
|
||||
$sharedAssets = @(
|
||||
@{ Name = 'ConfigLoader.ps1'; Source = $configLoaderSource },
|
||||
@{ Name = 'config.json'; Source = $configJsonSource }
|
||||
)
|
||||
|
||||
$grandTotal = 0
|
||||
$grandUpdated = 0
|
||||
$grandFailed = 0
|
||||
$touchedDirs = @{}
|
||||
|
||||
foreach ($spec in $specs) {
|
||||
Write-Host "=== Updating $($spec.Name) files ===" -ForegroundColor Cyan
|
||||
Write-Host "Source: $($spec.Source)" -ForegroundColor White
|
||||
Write-Host ""
|
||||
|
||||
$targets = Get-ChildItem -Path $root -Recurse -Filter $spec.Name | Where-Object { $_.FullName -ne $spec.Source }
|
||||
|
||||
$targets = Get-ChildItem -LiteralPath $projectsRoot -Recurse -Filter $spec.Name -File -ErrorAction SilentlyContinue |
|
||||
Where-Object { $_.FullName -ne $spec.Source }
|
||||
Write-Host "Found $($targets.Count) target files to update:" -ForegroundColor Yellow
|
||||
foreach ($t in $targets) { Write-Host " - $($t.FullName)" -ForegroundColor Gray }
|
||||
Write-Host ""
|
||||
@@ -30,10 +61,24 @@ foreach ($spec in $specs) {
|
||||
$updated = 0
|
||||
$failed = 0
|
||||
foreach ($t in $targets) {
|
||||
$targetDir = $t.Directory.FullName
|
||||
try {
|
||||
Copy-Item -Path $spec.Source -Destination $t.FullName -Force
|
||||
Write-Host "✓ Updated: $($t.FullName)" -ForegroundColor Green
|
||||
$updated++
|
||||
|
||||
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 "✗ Failed to copy $($asset.Name) to $targetDir" -ForegroundColor Red
|
||||
Write-Host " Error: $($_.Exception.Message)" -ForegroundColor Red
|
||||
}
|
||||
}
|
||||
$touchedDirs[$targetDir] = $true
|
||||
}
|
||||
}
|
||||
catch {
|
||||
Write-Host "✗ Failed to update: $($t.FullName)" -ForegroundColor Red
|
||||
|
||||
Reference in New Issue
Block a user