tractatus/scripts/sync-to-public.sh
TheFlow 0e6be3eaf1 refactor: remove website code and fix critical startup crashes (Phase 8)
CRITICAL FIX: Server would CRASH ON STARTUP (multiple import errors)

REMOVED (2 scripts):
1. scripts/framework-watchdog.js
   - Monitored .claude/session-state.json (OUR Claude Code setup)
   - Monitored .claude/token-checkpoints.json (OUR file structure)
   - Implementers won't have our .claude/ directory

2. scripts/init-db.js
   - Created website collections: blog_posts, media_inquiries, case_submissions
   - Created website collections: resources, moderation_queue, users, citations
   - Created website collections: translations, koha_donations
   - Next steps referenced deleted scripts (npm run seed:admin)

REWRITTEN (2 files):

src/models/index.js (29 lines → 27 lines)
- REMOVED imports: Document, BlogPost, MediaInquiry, CaseSubmission, Resource
- REMOVED imports: ModerationQueue, User (all deleted in Phase 2)
- KEPT imports: AuditLog, DeliberationSession, GovernanceLog, GovernanceRule
- KEPT imports: Precedent, Project, SessionState, VariableValue, VerificationLog
- Result: Only framework models exported

src/server.js (284 lines → 163 lines, 43% reduction)
- REMOVED: Imports to deleted middleware (csrf-protection, response-sanitization)
- REMOVED: Stripe webhook handling (/api/koha/webhook)
- REMOVED: Static file caching (for deleted public/ directory)
- REMOVED: Static file serving (public/ deleted in Phase 6)
- REMOVED: CSRF token endpoint
- REMOVED: Website homepage with "auth, documents, blog, admin" references
- REMOVED: Instruction sync (scripts/sync-instructions-to-db.js reference)
- REMOVED: Hardcoded log path (${process.env.HOME}/var/log/tractatus/...)
- REMOVED: Website-specific security middleware
- KEPT: Security headers, rate limiting, CORS, body parsers
- KEPT: API routes, governance services, MongoDB connections
- RESULT: Clean framework-only server

RESULT: Repository can now start without crashes, all imports resolve

🤖 Generated with Claude Code
Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-21 22:17:02 +13:00

68 lines
2 KiB
Bash
Executable file

#!/bin/bash
# Sync appropriate files to tractatus-framework public repo
SRC="/home/theflow/projects/tractatus"
DEST="/home/theflow/projects/tractatus-public"
echo "=== Syncing tractatus -> tractatus-framework (public) ==="
# Core application files
echo "Copying package files..."
cp "$SRC/package.json" "$DEST/"
cp "$SRC/package-lock.json" "$DEST/"
# Source code
echo "Copying src/ directory..."
rsync -av --delete "$SRC/src/" "$DEST/src/"
# Tests
echo "Copying tests/ directory..."
rsync -av --delete "$SRC/tests/" "$DEST/tests/"
# Scripts (excluding sensitive ones)
echo "Copying scripts/ directory..."
mkdir -p "$DEST/scripts"
rsync -av "$SRC/scripts/" "$DEST/scripts/" \
--exclude="*backup*" \
--exclude="*.old" \
--exclude="temp*"
# Public assets
echo "Copying public/ directory..."
rsync -av "$SRC/public/" "$DEST/public/" \
--exclude="downloads/*.pdf" \
--exclude="downloads/*.tar.gz"
# Systemd service files
echo "Copying systemd/ directory..."
rsync -av --delete "$SRC/systemd/" "$DEST/systemd/"
# Deployment quickstart
echo "Copying deployment-quickstart/ directory..."
rsync -av --delete "$SRC/deployment-quickstart/" "$DEST/deployment-quickstart/"
# Documentation - markdown
echo "Copying docs/markdown/..."
mkdir -p "$DEST/docs/markdown"
rsync -av --delete "$SRC/docs/markdown/" "$DEST/docs/markdown/"
# Documentation - API
echo "Copying docs/api/..."
mkdir -p "$DEST/docs/api"
rsync -av --delete "$SRC/docs/api/" "$DEST/docs/api/"
# Documentation - governance (PUBLIC ONLY)
echo "Copying docs/governance/ (public files only)..."
mkdir -p "$DEST/docs/governance"
cp "$SRC/docs/governance/TRA-VAL-0001-core-values-principles-v1-0.md" "$DEST/docs/governance/" 2>/dev/null || true
cp "$SRC/docs/governance/CODING_BEST_PRACTICES_SUMMARY.md" "$DEST/docs/governance/" 2>/dev/null || true
# Setup instructions
echo "Copying setup instructions..."
cp "$SRC/SETUP_INSTRUCTIONS.md" "$DEST/"
# .env.example (but NOT .env)
echo "Copying .env.example..."
cp "$SRC/.env.example" "$DEST/"
echo "=== Sync complete ==="