-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRemove-Project.ps1
More file actions
92 lines (72 loc) · 2.5 KB
/
Remove-Project.ps1
File metadata and controls
92 lines (72 loc) · 2.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
<#
.SYNOPSIS
Unregisters a project from the watchdog
.DESCRIPTION
Removes a project from the Claude Code Watchdog registry
.PARAMETER ProjectName
Name of the project to unregister
.PARAMETER KeepState
If specified, preserves the project state files
.EXAMPLE
.\Remove-Project.ps1 -ProjectName "my-project"
.EXAMPLE
.\Remove-Project.ps1 -ProjectName "my-project" -KeepState
.NOTES
Part of the Claude Code Watchdog project
#>
[CmdletBinding()]
param(
[Parameter(Mandatory)]
[string]$ProjectName,
[Parameter()]
[switch]$KeepState
)
Write-Host "🗑️ Removing project: $ProjectName..." -ForegroundColor Yellow
try {
# Load registry
$registryPath = "$HOME/.claude-automation/registry.json"
if (-not (Test-Path $registryPath)) {
Write-Error "No registry found. No projects are registered."
exit 1
}
$registry = Get-Content $registryPath -Raw | ConvertFrom-Json
# Check if project exists
if (-not $registry.projects.$ProjectName) {
Write-Error "Project not found in registry: $ProjectName"
exit 1
}
# Get project info before removing
$project = $registry.projects.$ProjectName
# Remove from registry
$registry.projects.PSObject.Properties.Remove($ProjectName)
$registry.lastUpdated = Get-Date -Format "o"
# Save registry
$registry | ConvertTo-Json -Depth 10 | Set-Content $registryPath -Force
Write-Host "✅ Project removed from registry" -ForegroundColor Green
# Optionally remove state files
if (-not $KeepState) {
# Load project config to find state directory
if (Test-Path $project.configPath) {
$config = Get-Content $project.configPath -Raw | ConvertFrom-Json
$stateDir = Join-Path $config.repoPath ".claude-automation"
if (Test-Path $stateDir) {
$confirm = Read-Host "Delete state files in $stateDir ? (y/N)"
if ($confirm -eq 'y') {
Remove-Item $stateDir -Recurse -Force
Write-Host "✅ State files removed" -ForegroundColor Green
}
else {
Write-Host "ℹ️ State files preserved" -ForegroundColor Gray
}
}
}
}
else {
Write-Host "ℹ️ State files preserved (-KeepState specified)" -ForegroundColor Gray
}
Write-Host "`n✅ Project unregistered: $ProjectName" -ForegroundColor Green
}
catch {
Write-Error "Failed to remove project: $_"
exit 1
}