mirror of
https://github.com/kellymichels/zscripts-token-savers
synced 2026-10-07 07:18:18 +00:00
All 16 repos moved to the evomedia-net org and were renamed into the evo.* namespace, so every github.com/kellymichels/<old-name> reference in source headers, CI badges, security links and docs pointed at a redirect. Mechanical URL-only rewrite, applied longest-name-first so smartplantehs-docs could not be clobbered by the smartplantehs rule. Nothing else changes: no code, no product names, no behaviour. smartplantehs -> evo.ehs here is the REPO url only; the product rename is separate and still pending.
67 lines
2.3 KiB
PowerShell
67 lines
2.3 KiB
PowerShell
# Evomedia.net Token Savers — https://github.com/evomedia-net/evo.zscripts
|
|
# Created by Kelly Michels · dev@evomedia.net
|
|
# Licensed under the MIT License. See LICENSE.
|
|
# Version: v1.0.0.0.0
|
|
|
|
# ZKiller.ps1 — kill then restart dev servers for any project in zconfig.json.
|
|
#
|
|
# Usage:
|
|
# zrestart <project> [<project> ...] [-Port N] [-KillAll] [-NoRestart] [-Detached] [-BindHost host]
|
|
#
|
|
# Examples:
|
|
# zrestart viteapp
|
|
# zrestart pyapp -Detached
|
|
#
|
|
param(
|
|
[Parameter(Position = 0, ValueFromRemainingArguments = $true)]
|
|
[string[]]$Projects = @(),
|
|
[Alias("p")][int]$Port = 0,
|
|
[switch]$KillAll,
|
|
[switch]$NoRestart,
|
|
[switch]$Detached,
|
|
[string]$BindHost = "127.0.0.1"
|
|
)
|
|
|
|
$ErrorActionPreference = "Stop"
|
|
. (Join-Path $PSScriptRoot "ZHelpers.ps1")
|
|
Start-ZTracking
|
|
|
|
$KillScript = Join-Path $PSScriptRoot "ZKillOnly.ps1"
|
|
$StartScript = Join-Path $PSScriptRoot "zstart.ps1"
|
|
|
|
if ($Projects.Count -eq 0) {
|
|
$keys = (Get-ZProjectKeys) -join ', '
|
|
Write-Host ""
|
|
Write-Host "Usage: zrestart <project> [<project> ...] [-Port N] [-KillAll] [-NoRestart] [-Detached] [-BindHost host]" -ForegroundColor Yellow
|
|
Write-Host " Projects in zconfig.json: $keys" -ForegroundColor Gray
|
|
Stop-ZTracking; exit 1
|
|
}
|
|
|
|
Write-Host ""
|
|
Write-Host "=== zrestart ===" -ForegroundColor Cyan
|
|
|
|
foreach ($key in $Projects) {
|
|
Write-Host "--- $key ---" -ForegroundColor DarkCyan
|
|
|
|
# Splat named params via a hashtable, not an array. The target scripts bind
|
|
# $Projects with ValueFromRemainingArguments (greedy), which swallows an
|
|
# array-splatted "-Detached"/"-KillAll" string as a literal project value
|
|
# instead of binding the switch. Hashtable splatting binds switches reliably.
|
|
$killParams = @{}
|
|
if ($Port -gt 0) { $killParams.Port = $Port }
|
|
if ($KillAll) { $killParams.KillAll = $true }
|
|
& $KillScript $key @killParams
|
|
if ($LASTEXITCODE -ne 0) { Stop-ZTracking; exit $LASTEXITCODE }
|
|
|
|
if (-not $NoRestart) {
|
|
Start-Sleep -Seconds 1
|
|
$startParams = @{}
|
|
if ($Port -gt 0) { $startParams.Port = $Port }
|
|
if ($BindHost -ne "127.0.0.1") { $startParams.BindHost = $BindHost }
|
|
if ($Detached) { $startParams.Detached = $true }
|
|
& $StartScript $key @startParams
|
|
if ($LASTEXITCODE -ne 0) { Stop-ZTracking; exit $LASTEXITCODE }
|
|
}
|
|
}
|
|
Stop-ZTracking
|