feat: add restore command integration and development workflow improvements

- Add restore command to CLI root (cmd/root.go)
- Add restore-clean justfile target for development workflow
- Update justfile clean command to remove backups
- Improve auth UI status display and enhance button visibility
- Clean up auth.js formatting and enhance button management
This commit is contained in:
2025-09-11 14:16:17 +02:00
parent ef1d1083ce
commit 74a54e4b5e
3 changed files with 38 additions and 36 deletions

View File

@@ -52,6 +52,7 @@ func init() {
rootCmd.AddCommand(enhanceCmd)
rootCmd.AddCommand(serveCmd)
rootCmd.AddCommand(restoreCmd)
}
func initConfig() {

View File

@@ -135,7 +135,7 @@ health port="8080":
@echo "🔍 Checking API server health..."
@curl -s http://localhost:{{port}}/health | jq . || echo "❌ Server not responding at localhost:{{port}}"
# Clean all build artifacts
# Clean all build artifacts and backups
clean:
rm -rf lib/dist
rm -rf insertr
@@ -145,6 +145,12 @@ clean:
rm -rf lib/node_modules
rm -f dev.db
rm -f insertr.db
@echo "🧹 Cleaned all build artifacts and backups"
# Restore demo site to clean original state
restore-clean:
@echo "🧹 Restoring demo site to clean state..."
./insertr restore demo --clean
# Lint code (placeholder for now)
lint:
@@ -180,6 +186,7 @@ status:
@echo " just enhance - Build-time content injection"
@echo ""
@echo "🔍 Check server: just health"
@echo "🧹 Restore clean: just restore-clean"
# Generate sqlc code (for database schema changes)
sqlc:

View File

@@ -235,6 +235,8 @@ export class InsertrAuth {
if (editToggle) {
editToggle.addEventListener('click', () => this.toggleEditMode());
}
}
/**
@@ -313,6 +315,9 @@ export class InsertrAuth {
editBtn.textContent = `Edit Mode: ${this.state.editMode ? 'On' : 'Off'}`;
editBtn.className = `insertr-auth-btn ${this.state.editMode ? 'insertr-edit-active' : ''}`;
}
// Update enhance button visibility
this.updateEnhanceButtonVisibility();
}
/**
@@ -325,14 +330,14 @@ export class InsertrAuth {
}
const statusHtml = `
<div id="insertr-status" class="insertr-status">
<div class="insertr-status-content">
<span class="insertr-status-text">Visitor Mode</span>
<span class="insertr-status-dot"></span>
<div id="insertr-status-controls" class="insertr-status-controls">
<div id="insertr-status" class="insertr-status">
<div class="insertr-status-content">
<span class="insertr-status-text">Visitor Mode</span>
<span class="insertr-status-dot"></span>
</div>
</div>
<button id="insertr-enhance-btn" class="insertr-enhance-btn" style="display: none;" title="Enhance files with latest content">
🔄 Enhance
</button>
<button id="insertr-enhance-btn" class="insertr-auth-btn" style="display: none;" title="Enhance files with latest content">🔄 Enhance</button>
</div>
`;
@@ -362,8 +367,7 @@ export class InsertrAuth {
statusDot.className = 'insertr-status-dot insertr-status-authenticated';
}
// Update enhance button visibility
this.updateEnhanceButtonVisibility();
}
/**
@@ -405,28 +409,6 @@ export class InsertrAuth {
body.insertr-hide-gates .insertr-gate {
display: none !important;
}
/* Enhance button styles */
.insertr-enhance-btn {
background: #2563eb;
color: white;
border: none;
padding: 4px 8px;
border-radius: 4px;
font-size: 11px;
margin-left: 8px;
cursor: pointer;
transition: background 0.2s ease;
}
.insertr-enhance-btn:hover {
background: #1d4ed8;
}
.insertr-enhance-btn:disabled {
background: #9ca3af;
cursor: not-allowed;
}
`;
const styleSheet = document.createElement('style');
@@ -486,17 +468,23 @@ export class InsertrAuth {
background: #b91c1c;
}
.insertr-status {
.insertr-status-controls {
position: fixed;
bottom: 20px;
left: 20px;
z-index: 9999;
display: flex;
flex-direction: column;
gap: 8px;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}
.insertr-status {
background: white;
border: 1px solid #e5e7eb;
border-radius: 8px;
padding: 8px 12px;
box-shadow: 0 4px 12px rgba(0,0,0,0.1);
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
max-width: 200px;
}
@@ -631,8 +619,14 @@ export class InsertrAuth {
enhanceBtn.textContent = '⏳ Enhancing...';
enhanceBtn.disabled = true;
// Smart server detection for enhance API (same logic as ApiClient)
const isDevelopment = window.location.hostname === 'localhost' || window.location.hostname === '127.0.0.1';
const enhanceUrl = isDevelopment
? `http://localhost:8080/api/enhance?site_id=${siteId}` // Development: separate API server
: `/api/enhance?site_id=${siteId}`; // Production: same-origin API
// Call enhance API
const response = await fetch(`/api/enhance?site_id=${siteId}`, {
const response = await fetch(enhanceUrl, {
method: 'POST',
headers: {
'Content-Type': 'application/json',