Update deploy scripts
This commit is contained in:
50
deploy.ps1
50
deploy.ps1
@@ -11,7 +11,8 @@ $TARGET = "S:\7-Infrastructure\lib\plugins\luxtools"
|
||||
$DRY_RUN = $false
|
||||
$DELETE = $true
|
||||
|
||||
function Resolve-PathUsingExistingCase {
|
||||
function Resolve-PathUsingExistingCase
|
||||
{
|
||||
param(
|
||||
[Parameter(Mandatory = $true)]
|
||||
[string]$Path
|
||||
@@ -20,7 +21,8 @@ function Resolve-PathUsingExistingCase {
|
||||
$fullPath = [System.IO.Path]::GetFullPath($Path)
|
||||
$root = [System.IO.Path]::GetPathRoot($fullPath).TrimEnd('\\')
|
||||
|
||||
if ($fullPath.TrimEnd('\\') -ieq $root) {
|
||||
if ($fullPath.TrimEnd('\\') -ieq $root)
|
||||
{
|
||||
return $root
|
||||
}
|
||||
|
||||
@@ -28,12 +30,14 @@ function Resolve-PathUsingExistingCase {
|
||||
$leaf = Split-Path -Path $fullPath -Leaf
|
||||
$resolvedParent = Resolve-PathUsingExistingCase -Path $parent
|
||||
|
||||
if (Test-Path -LiteralPath $resolvedParent) {
|
||||
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) {
|
||||
if ($null -ne $match)
|
||||
{
|
||||
return (Join-Path -Path $resolvedParent -ChildPath $match.Name)
|
||||
}
|
||||
}
|
||||
@@ -41,18 +45,22 @@ function Resolve-PathUsingExistingCase {
|
||||
return (Join-Path -Path $resolvedParent -ChildPath $leaf)
|
||||
}
|
||||
|
||||
foreach ($arg in $args) {
|
||||
if ($arg -eq "--dry-run" -or $arg -eq "-n") {
|
||||
foreach ($arg in $args)
|
||||
{
|
||||
if ($arg -eq "--dry-run" -or $arg -eq "-n")
|
||||
{
|
||||
$DRY_RUN = $true
|
||||
continue
|
||||
}
|
||||
|
||||
if ($arg -eq "--no-delete") {
|
||||
if ($arg -eq "--no-delete")
|
||||
{
|
||||
$DELETE = $false
|
||||
continue
|
||||
}
|
||||
|
||||
if ($arg -eq "-h" -or $arg -eq "--help") {
|
||||
if ($arg -eq "-h" -or $arg -eq "--help")
|
||||
{
|
||||
Get-Content $PSCommandPath
|
||||
exit 0
|
||||
}
|
||||
@@ -65,7 +73,8 @@ $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")) {
|
||||
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
|
||||
}
|
||||
@@ -75,11 +84,14 @@ 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") {
|
||||
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+") {
|
||||
if ($content -match "^base\s+luxtools" -or $content -match "^base\s+luxtools\s+")
|
||||
{
|
||||
# It's a luxtools plugin, allow it
|
||||
} else {
|
||||
} 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
|
||||
@@ -92,6 +104,8 @@ $EXCLUDE_DIRS = @(
|
||||
"_agent-data",
|
||||
".github",
|
||||
".vscode",
|
||||
".zed",
|
||||
".claude",
|
||||
"_test"
|
||||
)
|
||||
|
||||
@@ -121,21 +135,25 @@ $ROBOCOPY_ARGS = @(
|
||||
"/Z" # restartable mode
|
||||
)
|
||||
|
||||
if ($EXCLUDE_DIRS.Count -gt 0) {
|
||||
if ($EXCLUDE_DIRS.Count -gt 0)
|
||||
{
|
||||
$ROBOCOPY_ARGS += "/XD"
|
||||
$ROBOCOPY_ARGS += $EXCLUDE_DIRS
|
||||
}
|
||||
|
||||
if ($EXCLUDE_FILES.Count -gt 0) {
|
||||
if ($EXCLUDE_FILES.Count -gt 0)
|
||||
{
|
||||
$ROBOCOPY_ARGS += "/XF"
|
||||
$ROBOCOPY_ARGS += $EXCLUDE_FILES
|
||||
}
|
||||
|
||||
if ($DRY_RUN) {
|
||||
if ($DRY_RUN)
|
||||
{
|
||||
$ROBOCOPY_ARGS += "/L" # list mode
|
||||
}
|
||||
|
||||
if ($DELETE) {
|
||||
if ($DELETE)
|
||||
{
|
||||
$ROBOCOPY_ARGS += "/MIR" # mirror
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user