Skip to content

Commit d8de94b

Browse files
committed
feat: detect existing installs and run doctor for migrations
1 parent aa9a6a6 commit d8de94b

File tree

2 files changed

+84
-15
lines changed

2 files changed

+84
-15
lines changed

public/install.ps1

Lines changed: 45 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -81,15 +81,40 @@ function Install-Node {
8181
exit 1
8282
}
8383

84+
# Check for existing Clawdbot installation
85+
function Check-ExistingClawdbot {
86+
try {
87+
$null = Get-Command clawdbot -ErrorAction Stop
88+
Write-Host "→ Existing Clawdbot installation detected" -ForegroundColor Yellow
89+
return $true
90+
} catch {
91+
return $false
92+
}
93+
}
94+
8495
# Install Clawdbot
8596
function Install-Clawdbot {
8697
Write-Host "→ Installing Clawdbot..." -ForegroundColor Yellow
8798
npm install -g clawdbot@latest
8899
Write-Host "✓ Clawdbot installed" -ForegroundColor Green
89100
}
90101

102+
# Run doctor for migrations (safe, non-interactive)
103+
function Run-Doctor {
104+
Write-Host "→ Running doctor to migrate settings..." -ForegroundColor Yellow
105+
try {
106+
clawdbot doctor --non-interactive
107+
} catch {
108+
# Ignore errors from doctor
109+
}
110+
Write-Host "✓ Migration complete" -ForegroundColor Green
111+
}
112+
91113
# Main installation flow
92114
function Main {
115+
# Check for existing installation
116+
$isUpgrade = Check-ExistingClawdbot
117+
93118
# Step 1: Node.js
94119
if (-not (Check-Node)) {
95120
Install-Node
@@ -106,18 +131,30 @@ function Main {
106131
# Step 2: Clawdbot
107132
Install-Clawdbot
108133

134+
# Step 3: Run doctor for migrations if upgrading
135+
if ($isUpgrade) {
136+
Run-Doctor
137+
}
138+
109139
Write-Host ""
110140
Write-Host "🦞 Clawdbot installed successfully!" -ForegroundColor Green
111141
Write-Host ""
112-
Write-Host "Run " -NoNewline
113-
Write-Host "clawdbot onboard" -ForegroundColor Cyan -NoNewline
114-
Write-Host " to set up your assistant."
115-
Write-Host ""
116142

117-
# Ask to run onboard
118-
$response = Read-Host "Start setup now? [Y/n]"
119-
if ($response -eq "" -or $response -eq "Y" -or $response -eq "y") {
120-
clawdbot onboard
143+
if ($isUpgrade) {
144+
Write-Host "Upgrade complete. Run " -NoNewline
145+
Write-Host "clawdbot doctor" -ForegroundColor Cyan -NoNewline
146+
Write-Host " to check for additional migrations."
147+
} else {
148+
Write-Host "Run " -NoNewline
149+
Write-Host "clawdbot onboard" -ForegroundColor Cyan -NoNewline
150+
Write-Host " to set up your assistant."
151+
Write-Host ""
152+
153+
# Ask to run onboard (new installs only)
154+
$response = Read-Host "Start setup now? [Y/n]"
155+
if ($response -eq "" -or $response -eq "Y" -or $response -eq "y") {
156+
clawdbot onboard
157+
}
121158
}
122159
}
123160

public/install.sh

Lines changed: 39 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -97,15 +97,37 @@ install_node() {
9797
fi
9898
}
9999

100+
# Check for existing Clawdbot installation
101+
check_existing_clawdbot() {
102+
if command -v clawdbot &> /dev/null; then
103+
echo -e "${YELLOW}${NC} Existing Clawdbot installation detected"
104+
return 0
105+
fi
106+
return 1
107+
}
108+
100109
# Install Clawdbot
101110
install_clawdbot() {
102111
echo -e "${YELLOW}${NC} Installing Clawdbot..."
103112
npm install -g clawdbot@latest
104113
echo -e "${GREEN}${NC} Clawdbot installed"
105114
}
106115

116+
# Run doctor for migrations (safe, non-interactive)
117+
run_doctor() {
118+
echo -e "${YELLOW}${NC} Running doctor to migrate settings..."
119+
clawdbot doctor --non-interactive || true
120+
echo -e "${GREEN}${NC} Migration complete"
121+
}
122+
107123
# Main installation flow
108124
main() {
125+
# Check for existing installation
126+
local is_upgrade=false
127+
if check_existing_clawdbot; then
128+
is_upgrade=true
129+
fi
130+
109131
# Step 1: Homebrew (macOS only)
110132
install_homebrew
111133

@@ -117,17 +139,27 @@ main() {
117139
# Step 3: Clawdbot
118140
install_clawdbot
119141

142+
# Step 4: Run doctor for migrations if upgrading
143+
if [[ "$is_upgrade" == "true" ]]; then
144+
run_doctor
145+
fi
146+
120147
echo ""
121148
echo -e "${GREEN}${BOLD}🦞 Clawdbot installed successfully!${NC}"
122149
echo ""
123-
echo -e "Run ${CYAN}clawdbot onboard${NC} to set up your assistant."
124-
echo ""
125150

126-
# Ask to run onboard
127-
read -p "Start setup now? [Y/n] " -n 1 -r
128-
echo
129-
if [[ $REPLY =~ ^[Yy]$ ]] || [[ -z $REPLY ]]; then
130-
exec clawdbot onboard
151+
if [[ "$is_upgrade" == "true" ]]; then
152+
echo -e "Upgrade complete. Run ${CYAN}clawdbot doctor${NC} to check for additional migrations."
153+
else
154+
echo -e "Run ${CYAN}clawdbot onboard${NC} to set up your assistant."
155+
echo ""
156+
157+
# Ask to run onboard (new installs only)
158+
read -p "Start setup now? [Y/n] " -n 1 -r
159+
echo
160+
if [[ $REPLY =~ ^[Yy]$ ]] || [[ -z $REPLY ]]; then
161+
exec clawdbot onboard
162+
fi
131163
fi
132164
}
133165

0 commit comments

Comments
 (0)