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:
@@ -52,6 +52,7 @@ func init() {
|
|||||||
|
|
||||||
rootCmd.AddCommand(enhanceCmd)
|
rootCmd.AddCommand(enhanceCmd)
|
||||||
rootCmd.AddCommand(serveCmd)
|
rootCmd.AddCommand(serveCmd)
|
||||||
|
rootCmd.AddCommand(restoreCmd)
|
||||||
}
|
}
|
||||||
|
|
||||||
func initConfig() {
|
func initConfig() {
|
||||||
|
|||||||
9
justfile
9
justfile
@@ -135,7 +135,7 @@ health port="8080":
|
|||||||
@echo "🔍 Checking API server health..."
|
@echo "🔍 Checking API server health..."
|
||||||
@curl -s http://localhost:{{port}}/health | jq . || echo "❌ Server not responding at localhost:{{port}}"
|
@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:
|
clean:
|
||||||
rm -rf lib/dist
|
rm -rf lib/dist
|
||||||
rm -rf insertr
|
rm -rf insertr
|
||||||
@@ -145,6 +145,12 @@ clean:
|
|||||||
rm -rf lib/node_modules
|
rm -rf lib/node_modules
|
||||||
rm -f dev.db
|
rm -f dev.db
|
||||||
rm -f insertr.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 code (placeholder for now)
|
||||||
lint:
|
lint:
|
||||||
@@ -180,6 +186,7 @@ status:
|
|||||||
@echo " just enhance - Build-time content injection"
|
@echo " just enhance - Build-time content injection"
|
||||||
@echo ""
|
@echo ""
|
||||||
@echo "🔍 Check server: just health"
|
@echo "🔍 Check server: just health"
|
||||||
|
@echo "🧹 Restore clean: just restore-clean"
|
||||||
|
|
||||||
# Generate sqlc code (for database schema changes)
|
# Generate sqlc code (for database schema changes)
|
||||||
sqlc:
|
sqlc:
|
||||||
|
|||||||
@@ -235,6 +235,8 @@ export class InsertrAuth {
|
|||||||
if (editToggle) {
|
if (editToggle) {
|
||||||
editToggle.addEventListener('click', () => this.toggleEditMode());
|
editToggle.addEventListener('click', () => this.toggleEditMode());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -313,6 +315,9 @@ export class InsertrAuth {
|
|||||||
editBtn.textContent = `Edit Mode: ${this.state.editMode ? 'On' : 'Off'}`;
|
editBtn.textContent = `Edit Mode: ${this.state.editMode ? 'On' : 'Off'}`;
|
||||||
editBtn.className = `insertr-auth-btn ${this.state.editMode ? 'insertr-edit-active' : ''}`;
|
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 = `
|
const statusHtml = `
|
||||||
<div id="insertr-status" class="insertr-status">
|
<div id="insertr-status-controls" class="insertr-status-controls">
|
||||||
<div class="insertr-status-content">
|
<div id="insertr-status" class="insertr-status">
|
||||||
<span class="insertr-status-text">Visitor Mode</span>
|
<div class="insertr-status-content">
|
||||||
<span class="insertr-status-dot"></span>
|
<span class="insertr-status-text">Visitor Mode</span>
|
||||||
|
<span class="insertr-status-dot"></span>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<button id="insertr-enhance-btn" class="insertr-enhance-btn" style="display: none;" title="Enhance files with latest content">
|
<button id="insertr-enhance-btn" class="insertr-auth-btn" style="display: none;" title="Enhance files with latest content">🔄 Enhance</button>
|
||||||
🔄 Enhance
|
|
||||||
</button>
|
|
||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
|
|
||||||
@@ -362,8 +367,7 @@ export class InsertrAuth {
|
|||||||
statusDot.className = 'insertr-status-dot insertr-status-authenticated';
|
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 {
|
body.insertr-hide-gates .insertr-gate {
|
||||||
display: none !important;
|
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');
|
const styleSheet = document.createElement('style');
|
||||||
@@ -486,17 +468,23 @@ export class InsertrAuth {
|
|||||||
background: #b91c1c;
|
background: #b91c1c;
|
||||||
}
|
}
|
||||||
|
|
||||||
.insertr-status {
|
.insertr-status-controls {
|
||||||
position: fixed;
|
position: fixed;
|
||||||
bottom: 20px;
|
bottom: 20px;
|
||||||
left: 20px;
|
left: 20px;
|
||||||
z-index: 9999;
|
z-index: 9999;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 8px;
|
||||||
|
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
|
||||||
|
}
|
||||||
|
|
||||||
|
.insertr-status {
|
||||||
background: white;
|
background: white;
|
||||||
border: 1px solid #e5e7eb;
|
border: 1px solid #e5e7eb;
|
||||||
border-radius: 8px;
|
border-radius: 8px;
|
||||||
padding: 8px 12px;
|
padding: 8px 12px;
|
||||||
box-shadow: 0 4px 12px rgba(0,0,0,0.1);
|
box-shadow: 0 4px 12px rgba(0,0,0,0.1);
|
||||||
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
|
|
||||||
max-width: 200px;
|
max-width: 200px;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -631,8 +619,14 @@ export class InsertrAuth {
|
|||||||
enhanceBtn.textContent = '⏳ Enhancing...';
|
enhanceBtn.textContent = '⏳ Enhancing...';
|
||||||
enhanceBtn.disabled = true;
|
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
|
// Call enhance API
|
||||||
const response = await fetch(`/api/enhance?site_id=${siteId}`, {
|
const response = await fetch(enhanceUrl, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
|
|||||||
Reference in New Issue
Block a user