# Deploy this luxtools plugin checkout into a mounted DokuWiki plugins dir. # Default target is the user's mount path. # # Usage: # .\deploy.ps1 # deploy to /thebe/Web/lib/plugins/luxtools/ # .\deploy.ps1 --dry-run # show what would change # .\deploy.ps1 C:\path\to\luxtools # .\deploy.ps1 --no-delete # don't delete extraneous files at target $TARGET = "S:\7-Infrastructure\lib\plugins\luxtools" $DRY_RUN = $false $DELETE = $true function Resolve-PathUsingExistingCase { param( [Parameter(Mandatory = $true)] [string]$Path ) $fullPath = [System.IO.Path]::GetFullPath($Path) $root = [System.IO.Path]::GetPathRoot($fullPath).TrimEnd('\\') if ($fullPath.TrimEnd('\\') -ieq $root) { return $root } $parent = Split-Path -Path $fullPath -Parent $leaf = Split-Path -Path $fullPath -Leaf $resolvedParent = Resolve-PathUsingExistingCase -Path $parent if (Test-Path -LiteralPath $resolvedParent) { $match = Get-ChildItem -LiteralPath $resolvedParent -Force -ErrorAction SilentlyContinue | Where-Object { $_.Name -ieq $leaf } | Select-Object -First 1 if ($null -ne $match) { return (Join-Path -Path $resolvedParent -ChildPath $match.Name) } } return (Join-Path -Path $resolvedParent -ChildPath $leaf) } foreach ($arg in $args) { if ($arg -eq "--dry-run" -or $arg -eq "-n") { $DRY_RUN = $true continue } if ($arg -eq "--no-delete") { $DELETE = $false continue } if ($arg -eq "-h" -or $arg -eq "--help") { Get-Content $PSCommandPath exit 0 } $TARGET = $arg } $TARGET = Resolve-PathUsingExistingCase -Path $TARGET $SRC_DIR = $PSScriptRoot # Safety checks: make sure source looks like luxtools plugin if (-not (Test-Path "$SRC_DIR/plugin.info.txt")) { Write-Error "Error: '$SRC_DIR' doesn't look like luxtools (missing plugin.info.txt)." exit 1 } # Ensure target dir exists New-Item -ItemType Directory -Force -Path "$TARGET" | Out-Null # Safety check: refuse to deploy to an obviously wrong directory. # Allow empty dir (fresh install) OR existing luxtools plugin dir. if (Test-Path "$TARGET/plugin.info.txt") { $content = Get-Content "$TARGET/plugin.info.txt" -ErrorAction SilentlyContinue if ($content -match "^base\s+luxtools" -or $content -match "^base\s+luxtools\s+") { # It's a luxtools plugin, allow it } else { Write-Error "Error: target '$TARGET' has a plugin.info.txt, but it doesn't look like luxtools." Write-Error "Refusing to deploy." exit 1 } } $EXCLUDE_DIRS = @( ".git", "_dokuwiki", "_agent-data", ".github", ".vscode", "_test" ) $EXCLUDE_FILES = @( "deploy.sh", "deleted.files", "*.swp", "*.swo", ".DS_Store" ) $ROBOCOPY_ARGS = @( "$SRC_DIR\", "$TARGET\", "*", "/E", # copy subdirectories, including empty "/XO", # exclude older files "/R:0", # retry 0 times "/W:0", # wait 0 seconds between retries "/MT:8", # multithreaded with 8 threads "/NFL", # no file list "/NDL", # no directory list "/NJH", # no job header "/NJS", # no job summary "/NS", # no sizes "/NP", # no progress "/Z" # restartable mode ) if ($EXCLUDE_DIRS.Count -gt 0) { $ROBOCOPY_ARGS += "/XD" $ROBOCOPY_ARGS += $EXCLUDE_DIRS } if ($EXCLUDE_FILES.Count -gt 0) { $ROBOCOPY_ARGS += "/XF" $ROBOCOPY_ARGS += $EXCLUDE_FILES } if ($DRY_RUN) { $ROBOCOPY_ARGS += "/L" # list mode } if ($DELETE) { $ROBOCOPY_ARGS += "/MIR" # mirror } Write-Host "Deploying luxtools from: $SRC_DIR\" Write-Host "Deploying luxtools to: $TARGET\" robocopy @ROBOCOPY_ARGS Write-Host "Done."