some prettier
This commit is contained in:
@@ -1,18 +1,12 @@
|
||||
# Manage symlink state. Reconnect = disconnect && connect
|
||||
param(
|
||||
[string]$action = "reconnect" # connect | disconnect | reconnect
|
||||
[string]$action = "reconnect"
|
||||
)
|
||||
|
||||
Write-Host "Apps Manager started with action: $action"
|
||||
Write-Host "AppData Manager started with action: $action" -ForegroundColor Yellow
|
||||
|
||||
# CSV file with applications
|
||||
$config = $appsAll
|
||||
|
||||
# Import CSV
|
||||
$csv = Import-Csv -Path $config
|
||||
$csv = Import-Csv -Path $appsAll
|
||||
|
||||
foreach ($app in $csv) {
|
||||
# Skip disabled entries
|
||||
if ($app.Enabled -ne "1") { continue }
|
||||
|
||||
$AppName = $app.App
|
||||
@@ -30,12 +24,12 @@ foreach ($app in $csv) {
|
||||
$to = Join-Path $env:USERPROFILE $to
|
||||
}
|
||||
|
||||
Write-Host "=============================="
|
||||
Write-Host "Processing $AppName with action $action (Type=$($app.Type))"
|
||||
Write-Host " Raw From: $rawFrom"
|
||||
Write-Host " Raw To : $rawTo"
|
||||
Write-Host " Expanded From: $from"
|
||||
Write-Host " Expanded To : $to"
|
||||
Write-Host "==============================" -ForegroundColor Gray
|
||||
Write-Host "Processing $AppName with action $action (Type=$($app.Type))" -ForegroundColor White
|
||||
Write-Host " Raw From: $rawFrom" -ForegroundColor White
|
||||
Write-Host " Raw To : $rawTo" -ForegroundColor White
|
||||
Write-Host " Expanded From: $from" -ForegroundColor White
|
||||
Write-Host " Expanded To : $to" -ForegroundColor White
|
||||
|
||||
# Handle isolate type: execute a script instead of symlinks
|
||||
if ($app.Type -eq "isolate") {
|
||||
@@ -52,41 +46,41 @@ foreach ($app in $csv) {
|
||||
$scriptPath = Join-Path $apps "$safeName.ps1"
|
||||
}
|
||||
|
||||
Write-Host " Isolate mode: Executing script $scriptPath"
|
||||
Write-Host " Isolate mode: Executing script $scriptPath" -ForegroundColor Yellow
|
||||
if (Test-Path $scriptPath) {
|
||||
try {
|
||||
# Pass action and app context to the script
|
||||
& $scriptPath -Action $action -AppName $AppName -From $from -To $to
|
||||
} catch {
|
||||
Write-Error "Script failed for $AppName`: $($_.Exception.Message)"
|
||||
Write-Error "Script failed for $AppName`: $($_.Exception.Message)" -ForegroundColor Red
|
||||
}
|
||||
} else {
|
||||
Write-Warning "Isolate script not found: $scriptPath"
|
||||
Write-Warning "Isolate script not found: $scriptPath" -ForegroundColor Red
|
||||
}
|
||||
continue # Skip symlink handling
|
||||
continue
|
||||
}
|
||||
|
||||
switch ($action.ToLower()) {
|
||||
"disconnect" {
|
||||
Write-Host " Removing $to"
|
||||
Write-Host " Removing $to" -ForegroundColor Red
|
||||
if (Test-Path $to) { Remove-Item $to -Recurse -Force }
|
||||
}
|
||||
"connect" {
|
||||
Write-Host " Creating symlink $to -> $from"
|
||||
Write-Host " Creating symlink $to -> $from" -ForegroundColor Blue
|
||||
if (-not (Test-Path $to)) {
|
||||
New-Item -Path $to -ItemType SymbolicLink -Value $from | Out-Null
|
||||
}
|
||||
}
|
||||
"reconnect" {
|
||||
Write-Host " Removing $to"
|
||||
Write-Host " Removing $to" -ForegroundColor Red
|
||||
if (Test-Path $to) { Remove-Item $to -Recurse -Force }
|
||||
Write-Host " Creating symlink $to -> $from"
|
||||
Write-Host " Creating symlink $to -> $from" -ForegroundColor Blue
|
||||
if (-not (Test-Path $to)) {
|
||||
New-Item -Path $to -ItemType SymbolicLink -Value $from | Out-Null
|
||||
}
|
||||
}
|
||||
default {
|
||||
Write-Warning "Unknown action: $action"
|
||||
Write-Warning "Unknown action: $action" -ForegroundColor DarkYellow
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ param(
|
||||
[string]$Action = 'apply'
|
||||
)
|
||||
|
||||
Write-Host "Deployment Manager started with action: $Action"
|
||||
Write-Host "Deployment Manager started with action: $Action" -ForegroundColor Yellow
|
||||
|
||||
# Define modules with their respective actions
|
||||
$Modules = @(
|
||||
@@ -16,7 +16,7 @@ $Modules = @(
|
||||
|
||||
foreach ($module in $Modules) {
|
||||
$currentAction = if ($Action -eq 'apply') { $module.Apply } else { $module.Clean }
|
||||
Write-Host "`n=== $($module.Name) : $currentAction"
|
||||
Write-Host "`n=== $($module.Name) : $currentAction" -ForegroundColor White
|
||||
try {
|
||||
# Resolve the script path stored in a variable with the same name
|
||||
$scriptPath = (Get-Variable -Name $module.Name -ErrorAction Stop).Value
|
||||
@@ -25,12 +25,12 @@ foreach ($module in $Modules) {
|
||||
& $scriptPath $currentAction
|
||||
}
|
||||
else {
|
||||
Write-Warning "Module script not found: $scriptPath"
|
||||
Write-Warning "Module script not found: $scriptPath" -ForegroundColor DarkYellow
|
||||
}
|
||||
}
|
||||
catch {
|
||||
Write-Warning "Could not resolve path for module '$($module.Name)': $_"
|
||||
Write-Warning "Could not resolve path for module '$($module.Name)': $_" -ForegroundColor DarkYellow
|
||||
}
|
||||
}
|
||||
|
||||
Write-Host "`nDeployment finished."
|
||||
Write-Host "`nDeployment finished." -ForegroundColor Green
|
||||
@@ -1,15 +1,10 @@
|
||||
param(
|
||||
[string]$action = "reconnect" # connect | disconnect | reconnect
|
||||
[string]$action = "reconnect"
|
||||
)
|
||||
|
||||
Write-Host "Folder Symlink Manager started with action: $action"
|
||||
|
||||
# CSV file with folder mappings
|
||||
$config = $mountsAll # переменная с путём к CSV
|
||||
|
||||
# Import CSV
|
||||
$csv = Import-Csv -Path $config
|
||||
Write-Host "Mounts Manager started with action: $action" -ForegroundColor Yellow
|
||||
|
||||
$csv = Import-Csv -Path $mountsAll
|
||||
foreach ($entry in $csv) {
|
||||
if ($entry.Enabled -ne "1") { continue }
|
||||
|
||||
@@ -28,26 +23,26 @@ foreach ($entry in $csv) {
|
||||
$to = Join-Path $env:USERPROFILE $to
|
||||
}
|
||||
|
||||
Write-Host "=============================="
|
||||
Write-Host "Processing $Name with action $action"
|
||||
Write-Host " From: $from"
|
||||
Write-Host " To : $to"
|
||||
Write-Host "===============================" -ForegroundColor Gray
|
||||
Write-Host "Processing $Name with action $action" -ForegroundColor White
|
||||
Write-Host " From: $from" -ForegroundColor White
|
||||
Write-Host " To : $to" -ForegroundColor White
|
||||
|
||||
switch ($action.ToLower()) {
|
||||
"disconnect" {
|
||||
Write-Host " Removing $to"
|
||||
Write-Host " Removing $to" -ForegroundColor Red
|
||||
if (Test-Path $to) { Remove-Item $to -Recurse -Force }
|
||||
}
|
||||
"connect" {
|
||||
Write-Host " Creating symlink $to -> $from"
|
||||
Write-Host " Creating symlink $to -> $from" -ForegroundColor Blue
|
||||
if (-not (Test-Path $to)) {
|
||||
New-Item -Path $to -ItemType SymbolicLink -Value $from | Out-Null
|
||||
}
|
||||
}
|
||||
"reconnect" {
|
||||
Write-Host " Removing $to"
|
||||
Write-Host " Removing $to" -ForegroundColor Red
|
||||
if (Test-Path $to) { Remove-Item $to -Recurse -Force }
|
||||
Write-Host " Creating symlink $to -> $from"
|
||||
Write-Host " Creating symlink $to -> $from" -ForegroundColor Blue
|
||||
if (-not (Test-Path $to)) {
|
||||
New-Item -Path $to -ItemType SymbolicLink -Value $from | Out-Null
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user