Add windows deploy script

This commit is contained in:
2026-02-20 17:44:27 +01:00
parent 75423b8d50
commit 4103275ec1
2 changed files with 116 additions and 1 deletions

115
deploy.ps1 Normal file
View File

@@ -0,0 +1,115 @@
# 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:\Web\lib\plugins\luxtools"
$DRY_RUN = $false
$DELETE = $true
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
}
$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."