Prechádzať zdrojové kódy

chore: remove deployment scripts and documentation

Adam 3 mesiacov pred
rodič
commit
9fda607db3
11 zmenil súbory, kde vykonal 2 pridanie a 1827 odobranie
  1. 0 259
      DEPLOYMENT.md
  2. 0 112
      QUICK-DEPLOY.md
  3. 2 0
      README.md
  4. 0 289
      WARP.md
  5. 0 193
      create-deployment-package.js
  6. 0 25
      deploy-now.ps1
  7. 0 44
      deploy-now.sh
  8. 0 40
      deploy.bat
  9. BIN
      gooneral-wheelchair-deployment.zip
  10. 0 425
      prepare-deployment.ps1
  11. 0 440
      prepare-deployment.sh

+ 0 - 259
DEPLOYMENT.md

@@ -1,259 +0,0 @@
-# Gooneral Wheelchair - Production Deployment Guide
-
-## Prerequisites
-
-1. **Server with Node.js** (v18+ recommended)
-2. **Caddy web server** installed
-3. **Domain name** pointing to your server
-4. **SSH access** to your server
-
-## Deployment Steps
-
-### 1. Prepare the Production Environment
-
-On your server, create a directory for your application:
-
-```bash
-# Create application directory
-sudo mkdir -p /opt/gooneral-wheelchair
-sudo chown $USER:$USER /opt/gooneral-wheelchair
-cd /opt/gooneral-wheelchair
-```
-
-### 2. Upload Files
-
-Upload these files to your server:
-
-```
-/opt/gooneral-wheelchair/
-├── dist/                    # Built frontend files
-├── backend/                 # Backend application
-│   ├── server.js
-│   ├── start-production.js
-│   ├── package.json
-│   ├── .env.production      # Configure this!
-│   ├── auth.js
-│   ├── themes.js
-│   └── node_modules/        # Install dependencies
-├── public/
-│   └── posts/               # Your blog posts
-├── Caddyfile               # Caddy configuration
-└── DEPLOYMENT.md           # This file
-```
-
-### 3. Configure Environment Variables
-
-Edit `/opt/gooneral-wheelchair/backend/.env.production`:
-
-```env
-# REQUIRED: Change these values!
-NODE_ENV=production
-PORT=3001
-SESSION_SECRET=your-super-secret-session-key-generate-a-strong-one
-FRONTEND_URL=https://yourdomain.com
-
-# Optional: Customize paths if needed
-POSTS_DIR=../public/posts
-THEMES_FILE=./themes.json
-SESSIONS_DIR=./sessions
-
-# Security settings
-COOKIE_SECURE=true
-COOKIE_SAME_SITE=strict
-```
-
-**⚠️ IMPORTANT**: Generate a strong session secret:
-```bash
-node -e "console.log(require('crypto').randomBytes(64).toString('hex'))"
-```
-
-### 4. Install Backend Dependencies
-
-```bash
-cd /opt/gooneral-wheelchair/backend
-npm install --production
-```
-
-### 5. Create Required Directories
-
-```bash
-mkdir -p sessions
-mkdir -p ../public/posts
-```
-
-### 6. Set Up System User (Recommended)
-
-```bash
-# Create a system user for the application
-sudo useradd --system --shell /bin/false --home /opt/gooneral-wheelchair gooneral
-
-# Change ownership
-sudo chown -R gooneral:gooneral /opt/gooneral-wheelchair
-
-# Make start script executable
-sudo chmod +x /opt/gooneral-wheelchair/backend/start-production.js
-```
-
-### 7. Create Systemd Service
-
-Create `/etc/systemd/system/gooneral-wheelchair.service`:
-
-```ini
-[Unit]
-Description=Gooneral Wheelchair CMS Backend
-After=network.target
-
-[Service]
-Type=simple
-User=gooneral
-WorkingDirectory=/opt/gooneral-wheelchair/backend
-Environment=NODE_ENV=production
-ExecStart=/usr/bin/node start-production.js
-Restart=always
-RestartSec=10
-StandardOutput=syslog
-StandardError=syslog
-SyslogIdentifier=gooneral-wheelchair
-
-[Install]
-WantedBy=multi-user.target
-```
-
-Enable and start the service:
-
-```bash
-sudo systemctl daemon-reload
-sudo systemctl enable gooneral-wheelchair
-sudo systemctl start gooneral-wheelchair
-sudo systemctl status gooneral-wheelchair
-```
-
-### 8. Configure Caddy
-
-1. Update the Caddyfile with your domain:
-   ```
-   # Replace 'yourdomain.com' with your actual domain
-   yourdomain.com {
-       # ... rest of configuration
-   }
-   ```
-
-2. Copy Caddyfile to Caddy's configuration directory:
-   ```bash
-   sudo cp /opt/gooneral-wheelchair/Caddyfile /etc/caddy/Caddyfile
-   ```
-
-3. Test and reload Caddy:
-   ```bash
-   sudo caddy validate --config /etc/caddy/Caddyfile
-   sudo systemctl reload caddy
-   ```
-
-### 9. Create Initial Admin User
-
-SSH into your server and create an admin user:
-
-```bash
-cd /opt/gooneral-wheelchair/backend
-node -e "
-const bcrypt = require('bcryptjs');
-const fs = require('fs');
-const path = require('path');
-
-const username = 'admin';
-const password = 'your-secure-password'; // Change this!
-const hashedPassword = bcrypt.hashSync(password, 10);
-
-const usersFile = path.join(__dirname, 'users.json');
-const users = [
-  {
-    id: 1,
-    username: username,
-    password: hashedPassword,
-    role: 'admin'
-  }
-];
-
-fs.writeFileSync(usersFile, JSON.stringify(users, null, 2));
-console.log('Admin user created:', username);
-"
-```
-
-## Post-Deployment
-
-### 1. Test Your Deployment
-
-1. **Frontend**: Visit https://yourdomain.com
-2. **Backend API**: Visit https://yourdomain.com/api/health
-3. **Admin Login**: Visit https://yourdomain.com/login
-
-### 2. Monitor Logs
-
-```bash
-# Backend logs
-sudo journalctl -u gooneral-wheelchair -f
-
-# Caddy logs
-sudo journalctl -u caddy -f
-
-# Application logs (if configured)
-sudo tail -f /var/log/caddy/gooneral-wheelchair.log
-```
-
-### 3. Security Checklist
-
-- ✅ Strong session secret configured
-- ✅ HTTPS enabled (automatic with Caddy)
-- ✅ Secure cookies enabled in production
-- ✅ Security headers configured
-- ✅ Admin user created with strong password
-- ✅ Service running as non-root user
-- ✅ Firewall configured (only ports 80, 443, SSH open)
-
-## Updating Your Blog
-
-### 1. Add New Posts
-
-Upload markdown files to `/opt/gooneral-wheelchair/public/posts/`
-
-### 2. Update Application
-
-1. Build new version locally
-2. Upload new `dist/` directory
-3. Update backend files if needed
-4. Restart services:
-   ```bash
-   sudo systemctl restart gooneral-wheelchair
-   sudo systemctl reload caddy
-   ```
-
-## Troubleshooting
-
-### Backend Won't Start
-```bash
-sudo systemctl status gooneral-wheelchair
-sudo journalctl -u gooneral-wheelchair -n 50
-```
-
-### Frontend Not Loading
-- Check Caddy configuration
-- Verify `dist/` directory contains built files
-- Check Caddy logs
-
-### API Not Working
-- Verify backend is running on port 3001
-- Check CORS configuration matches your domain
-- Verify reverse proxy in Caddyfile
-
-### Session Issues
-- Check session secret is set
-- Verify cookie settings for HTTPS
-- Clear browser cookies and try again
-
-## Backup
-
-Regular backups should include:
-- `/opt/gooneral-wheelchair/public/posts/` (your blog posts)
-- `/opt/gooneral-wheelchair/backend/users.json` (user accounts)
-- `/opt/gooneral-wheelchair/backend/themes.json` (theme settings)
-- `/opt/gooneral-wheelchair/backend/sessions/` (active sessions - optional)

+ 0 - 112
QUICK-DEPLOY.md

@@ -1,112 +0,0 @@
-# 🚀 Gooneral Wheelchair - One-Click Deployment
-
-Ready to deploy your blog? Choose your method:
-
-## 🎯 Option 1: Super Simple (Batch File)
-
-Just double-click `deploy.bat` and enter your domain, or run from command line:
-
-```batch
-# Create deployment package
-deploy.bat yourdomain.com
-
-# Deploy directly to server (requires SSH keys set up)
-deploy.bat yourdomain.com your.server.ip username
-```
-
-## 🎯 Option 2: PowerShell Commands
-
-```powershell
-# Create deployment package only
-.\deploy-now.ps1 -Domain "yourdomain.com"
-
-# Deploy directly to server
-.\deploy-now.ps1 -Domain "yourdomain.com" -ServerHost "your.server.ip" -ServerUser "username"
-```
-
-## 🎯 Option 3: Advanced PowerShell
-
-```powershell
-# Full control over the deployment process
-.\prepare-deployment.ps1 -Domain "yourdomain.com" -ServerHost "192.168.1.100" -ServerUser "myuser" -UploadToServer
-```
-
-## ✨ What Happens Automatically
-
-The scripts will:
-
-### 🏗️ **Build Phase**
-- ✅ Build your React frontend for production
-- ✅ Generate secure session secrets
-- ✅ Create production configuration files
-- ✅ Package everything for deployment
-
-### 🚀 **Deploy Phase** (if server specified)
-- ✅ Upload files to your server
-- ✅ Install Node.js dependencies
-- ✅ Create system user for security
-- ✅ Set up systemd service
-- ✅ Configure Caddy with auto-SSL
-- ✅ Create admin user with random password
-- ✅ Start all services
-
-### 🎉 **Result**
-- 🌐 Your blog live at `https://yourdomain.com`
-- 🔧 Admin panel at `https://yourdomain.com/admin`
-- 🔐 Secure HTTPS with automatic certificates
-- 👤 Admin credentials displayed after deployment
-
-## 📋 Prerequisites
-
-### On Your Windows Machine:
-- ✅ Node.js installed
-- ✅ PowerShell execution policy allows scripts
-- ✅ SSH client (for direct deployment)
-
-### On Your Server:
-- ✅ Ubuntu/Debian/CentOS Linux
-- ✅ Node.js v18+ installed
-- ✅ Caddy web server installed
-- ✅ Domain pointing to server IP
-- ✅ SSH access configured
-
-## 🔥 Example Usage
-
-```batch
-# I want to deploy myblog.com to my server at 192.168.1.100
-deploy.bat myblog.com 192.168.1.100 myuser
-```
-
-That's it! The script will handle everything and show you the admin credentials at the end.
-
-## 🛠️ Manual Upload Method
-
-If direct deployment doesn't work:
-
-1. Run: `deploy.bat yourdomain.com` (creates package only)
-2. Upload the `deployment-ready` folder to your server
-3. SSH to your server: `ssh user@your.server.ip`
-4. Navigate to uploaded folder: `cd deployment-ready`
-5. Run: `chmod +x deploy.sh && ./deploy.sh`
-
-## 🔐 Security Notes
-
-- 🚨 **Keep deployment files secure** - they contain session secrets
-- 🚨 **Change admin password** after first login
-- 🚨 **Enable firewall** on your server (ports 80, 443, SSH only)
-- 🚨 **Regular backups** of `/opt/gooneral-wheelchair/`
-
-## 💡 Tips
-
-- **First time?** Use the package-only option to review files before deploying
-- **Multiple sites?** Run the script multiple times with different domains
-- **Updates?** Just run the script again - it will update your existing installation
-- **Troubleshooting?** Check the logs with `sudo journalctl -u gooneral-wheelchair -f`
-
-## 🆘 Need Help?
-
-If something goes wrong:
-1. Check `DEPLOYMENT.md` for detailed manual instructions
-2. Verify prerequisites are installed
-3. Check server logs for error messages
-4. Ensure domain DNS is pointing to your server

+ 2 - 0
README.md

@@ -1,3 +1,5 @@
 # The gooneral wheelchair.
 
 This is my CMS. Why? Because I can.
+
+Set-

+ 0 - 289
WARP.md

@@ -1,289 +0,0 @@
-# WARP.md
-
-This file provides guidance to WARP (warp.dev) when working with code in this repository.
-
-## Project Overview
-
-"The gooneral wheelchair" is a full-stack personal CMS (Content Management System) built with React frontend and Node.js/Express backend. The system provides both a public blog interface and a complete admin dashboard for managing posts dynamically through a REST API.
-
-## Development Commands
-
-### Full-Stack Development
-- **Start both servers**: `npm run dev` - Runs both frontend (Vite) and backend (Express) servers concurrently
-- **Frontend only**: `npm run dev:frontend` - Runs Vite dev server on port 5173
-- **Backend only**: `npm run dev:backend` - Runs Express API server on port 3001
-
-### Production Commands
-- **Build frontend**: `npm run build` - Creates optimized production build in `dist/`
-- **Start backend**: `npm run start:backend` - Starts production Express server
-- **Preview frontend**: `npm run preview` - Serves the built application locally
-
-### Code Quality
-- **Lint code**: `npm run lint` - Runs ESLint on all JavaScript/JSX files
-
-### Package Management
-- **Install all dependencies**: `npm install && cd backend && npm install`
-- **Add frontend dependency**: `npm install <package-name>`
-- **Add backend dependency**: `cd backend && npm install <package-name>`
-- **Add dev dependency**: `npm install -D <package-name>`
-
-## Architecture Overview
-
-### Full-Stack Architecture
-- **Frontend**: React SPA with React Router for navigation
-- **Backend**: Node.js/Express API server with REST endpoints
-- **Database**: File-system based (markdown files in `public/posts/`)
-- **Communication**: Frontend communicates with backend via REST API calls
-
-### Frontend Structure
-- **Entry Point**: `src/main.jsx` - React application entry with StrictMode
-- **Main Router**: `src/App.jsx` - React Router setup with route definitions
-- **Components**: 
-  - `BlogHome` - Public blog homepage with post grid
-  - `PostView` - Individual post display component
-  - `AdminDashboard` - Admin interface for managing posts
-  - `PostEditor` - Create/edit post interface with live preview
-- **Styling**: Tailwind CSS 4.x via Vite plugin
-
-### Backend API Structure
-- **Server**: `backend/server.js` - Express server with CORS and session management
-- **Authentication**: Session-based authentication with bcrypt password hashing
-- **API Base URL**: `http://localhost:3001/api`
-- **Public Endpoints**:
-  - `GET /api/posts` - Fetch all posts with metadata
-  - `GET /api/posts/:slug` - Fetch specific post
-  - `GET /api/health` - Health check endpoint
-- **Authentication Endpoints**:
-  - `POST /api/auth/login` - User login
-  - `POST /api/auth/logout` - User logout
-  - `GET /api/auth/me` - Get current user info
-  - `POST /api/auth/change-password` - Change user password (requires auth)
-- **Protected Endpoints** (require admin authentication):
-  - `POST /api/posts` - Create new post
-  - `PUT /api/posts/:slug` - Update existing post
-  - `DELETE /api/posts/:slug` - Delete post
-
-### Content Management System
-The CMS operates on a hybrid approach:
-
-1. **Post Storage**: Markdown files in `public/posts/` directory
-2. **API Layer**: Express server handles CRUD operations on markdown files
-3. **Dynamic Index**: Backend automatically generates `index.json` when posts change
-4. **Metadata Handling**: Server-side parsing of frontmatter (`title:`, `desc:`, `tags:`)
-5. **Admin Interface**: Full CRUD interface accessible at `/admin`
-
-### Markdown Processing Pipeline
-The application uses an extensive MarkdownIt setup with multiple plugins:
-
-- **Base Configuration**: HTML enabled, linkify, typographer
-- **Extensions**: Emoji, abbreviations, subscript/superscript, insertions, marks, definition lists, footnotes, spoilers
-- **Custom Containers**: Info, warning, and spoiler containers
-- **Table Enhancement**: Wraps tables in scrollable containers
-- **Sanitization**: DOMPurify for XSS protection
-
-### Client-Side Routing
-- Uses React Router for navigation
-- Route pattern: `/posts/{slug}` maps to post slugs
-- Home route `/` shows post grid
-- Admin routes under `/admin` for content management
-
-### Routing Structure
-**Frontend Routes**:
-- `/` - Blog homepage (BlogHome component)
-- `/posts/:slug` - Individual post view (PostView component)
-- `/login` - Login form (LoginForm component)
-- `/admin` - Admin dashboard (AdminDashboard component) - **Protected**
-- `/admin/post/new` - Create new post (PostEditor component) - **Protected**
-- `/admin/post/:slug/edit` - Edit existing post (PostEditor component) - **Protected**
-
-**API Routes**:
-- `GET /api/posts` - List all posts
-- `GET /api/posts/:slug` - Get single post
-- `POST /api/posts` - Create post
-- `PUT /api/posts/:slug` - Update post
-- `DELETE /api/posts/:slug` - Delete post
-
-## File Structure Patterns
-
-### Frontend Source Code
-- `src/App.jsx` - Main router component with route definitions and auth integration
-- `src/main.jsx` - React entry point
-- `src/index.css` - Global styles (Tailwind imports)
-- `src/contexts/AuthContext.jsx` - Authentication context and state management
-- `src/components/AdminDashboard.jsx` - Admin interface component
-- `src/components/PostEditor.jsx` - Post creation/editing interface
-- `src/components/LoginForm.jsx` - User login form
-- `src/components/ProtectedRoute.jsx` - Route protection wrapper
-
-### Backend Source Code
-- `backend/server.js` - Express API server with authentication
-- `backend/auth.js` - Authentication utilities and user management
-- `backend/users.json` - User data storage (auto-generated)
-- `backend/package.json` - Backend dependencies and scripts
-
-### Content
-- `public/posts/*.md` - Blog post markdown files (managed via API)
-- `public/posts/index.json` - Auto-generated file list (managed by backend)
-- `public/posts/image.png` - Post assets (images referenced in markdown)
-
-### Configuration
-- `package.json` - Frontend dependencies and development scripts
-- `backend/package.json` - Backend dependencies
-- `vite.config.js` - Vite configuration with React and Tailwind (no custom plugins)
-- `eslint.config.js` - ESLint configuration with React rules
-
-## Development Workflow
-
-### Adding New Posts
-**Via Admin Interface (Recommended)**:
-1. Navigate to `/admin` in your browser
-2. Click "New Post" button
-3. Fill in title, description, tags, and content
-4. Use the Preview tab to see rendered markdown
-5. Click "Create Post" to save
-
-**Manual File Creation**:
-1. Create new `.md` file in `public/posts/` directory
-2. Include frontmatter: `title: Your Title`, `desc: Description`, `tags: tag1, tag2`
-3. Write content using supported markdown extensions
-4. Restart backend server to recognize new file
-
-### Editing Posts
-**Via Admin Interface**:
-1. Go to `/admin` and click "Edit" on any post
-2. Modify content in the editor with live preview
-3. Click "Update Post" to save changes
-
-**Direct File Editing**:
-1. Edit the `.md` file directly in `public/posts/`
-2. Changes will be reflected immediately via API
-
-### Markdown Features Supported
-**WYSIWYG Editor Features**:
-- **Visual toolbar**: Quick access to formatting (bold, italic, headers, lists, links, images, code)
-- **Multiple editing modes**: Edit, Preview, and Live (split) modes
-- **Syntax highlighting**: Enhanced code editing with monospace font
-- **Drag-to-resize**: Adjustable panes in live mode
-
-**Standard Markdown Syntax Support**:
-- **Text formatting**: Bold, italic, strikethrough
-- **Headers**: All levels (H1-H6)
-- **Lists**: Ordered and unordered (with nesting)
-- **Links and images**: Standard `[text](url)` and `![alt](src)` syntax
-- **Code**: Inline `code` and fenced code blocks with syntax highlighting
-- **Tables**: GitHub-style tables (automatically made scrollable)
-- **Blockquotes**: Standard `>` syntax, great for callouts with emoji
-- **Horizontal rules**: `---` or `***`
-- **HTML support**: Standard HTML tags when needed
-- **Emoji**: GitHub-style `:emoji_name:` syntax
-- **Footnotes**: Standard `[^ref]` syntax
-- **Collapsible content**: HTML `<details><summary>` tags
-- **Line breaks**: Proper paragraph handling
-
-### Code Style
-- Uses ESLint with React-specific rules
-- Unused variables allowed if they follow `^[A-Z_]` pattern
-- ES2020+ features enabled
-- JSX support configured
-
-### Markdown Compatibility
-- **Standards-compliant**: Uses only widely-supported markdown features
-- **Portable content**: Markdown files work with GitHub, GitLab, and other platforms
-- **No custom extensions**: Avoids proprietary syntax that doesn't work elsewhere
-- **HTML fallback**: When markdown isn't enough, standard HTML tags are supported
-
-## Custom Implementation Notes
-
-### State Management
-Each React component manages its own state with useState hooks:
-- **BlogHome**: `posts`, `loading`, `error` - For blog homepage
-- **PostView**: `post`, `loading`, `error` - For individual post display
-- **AdminDashboard**: `posts`, `loading`, `error` - For admin post list
-- **PostEditor**: `formData`, `loading`, `saving`, `error`, `previewMode` - For post editing
-
-### API Integration
-All components use fetch() to communicate with the Express backend:
-- **Base URL**: `http://localhost:3001/api`
-- **Error Handling**: Consistent error states across components
-- **Loading States**: All API calls show loading indicators
-- **CRUD Operations**: Full create, read, update, delete functionality
-
-### Unusual Function Names
-The codebase contains intentionally obscure function names (e.g., `giveFoxHerHeir`, `getTingyun`, `travelToExpress`, `conceiveFoxFromSemen`) - this appears to be a stylistic choice and should be preserved when making changes.
-
-### Content Processing
-- Metadata extracted via regex patterns from markdown content
-- HTML content sanitized with DOMPurify before rendering
-- Dynamic title updates based on selected post
-- Custom image credit parsing for blog post assets
-
-## Development Setup
-
-### Initial Setup
-1. Install frontend dependencies: `npm install`
-2. Install backend dependencies: `cd backend && npm install`
-3. Start development servers: `npm run dev`
-4. Frontend will be available at `http://localhost:5173`
-5. Backend API will be available at `http://localhost:3001`
-6. Admin interface accessible at `http://localhost:5173/admin`
-
-### Production Deployment
-**Frontend**: Can be deployed to static hosting (Netlify, Vercel, etc.)
-**Backend**: Requires Node.js server environment (Heroku, Railway, DigitalOcean, etc.)
-**Database**: File system based, no external database required
-
-### Environment Variables
-- `PORT` - Backend server port (default: 3001)
-- `NODE_ENV` - Environment mode for backend
-
-## Authentication System
-
-### Default Credentials
-- **Username**: `admin`
-- **Password**: `admin123`
-- **⚠️ IMPORTANT**: Change the default password immediately after first login
-
-### Security Features
-- Session-based authentication with secure cookies
-- Bcrypt password hashing (10 rounds)
-- Protected API endpoints require admin role
-- Frontend route protection with automatic redirects
-- Session timeout after 24 hours of inactivity
-
-### User Management
-- Single admin user system (expandable)
-- Password change functionality in admin interface
-- Automatic user file creation on first server start
-- Session persistence across browser sessions
-
-## Admin Interface Features
-
-### Authentication Flow
-1. Navigate to `/admin` without authentication → redirected to `/login`
-2. Login with credentials → redirected to intended admin page
-3. Admin navigation only visible when authenticated
-4. Logout clears session and redirects to homepage
-
-### Dashboard (`/admin`) - **Requires Authentication**
-- Overview statistics (total posts, recent posts)
-- Post management table with edit/delete actions
-- Quick access to create new posts
-- User greeting and logout functionality
-
-### Post Editor (`/admin/post/new` or `/admin/post/:slug/edit`) - **Requires Authentication**
-- Rich form interface for post metadata (title, description, tags)
-- **WYSIWYG Markdown Editor** with multiple editing modes:
-  - **Edit Mode**: Source code editing with syntax highlighting
-  - **Preview Mode**: Live rendered markdown preview
-  - **Live Mode**: Split view with edit and preview side-by-side
-- Visual toolbar with formatting buttons (bold, italic, headers, lists, links, etc.)
-- Drag-to-resize editor panes in live mode
-- Full support for standard markdown features (tables, footnotes, emoji, HTML tags)
-- Save/cancel actions with error handling
-- Automatic slug generation from title for new posts
-
-### Login Form (`/login`)
-- Clean, responsive login interface
-- Error handling for invalid credentials
-- Default credentials display for initial setup
-- Automatic redirect after successful login

+ 0 - 193
create-deployment-package.js

@@ -1,193 +0,0 @@
-#!/usr/bin/env node
-
-import fs from 'fs-extra';
-import path from 'path';
-import { fileURLToPath } from 'url';
-import archiver from 'archiver';
-
-const __filename = fileURLToPath(import.meta.url);
-const __dirname = path.dirname(__filename);
-
-const deploymentDir = path.join(__dirname, 'deployment-package');
-const archivePath = path.join(__dirname, 'gooneral-wheelchair-deployment.zip');
-
-console.log('🚀 Creating deployment package...\n');
-
-async function createDeploymentPackage() {
-  try {
-    // Clean up previous package
-    await fs.remove(deploymentDir);
-    await fs.remove(archivePath);
-    
-    // Create deployment directory
-    await fs.ensureDir(deploymentDir);
-    
-    console.log('📁 Copying files...');
-    
-    // Copy built frontend
-    if (await fs.pathExists(path.join(__dirname, 'dist'))) {
-      await fs.copy(path.join(__dirname, 'dist'), path.join(deploymentDir, 'dist'));
-      console.log('✅ Frontend build copied');
-    } else {
-      console.log('⚠️  Frontend not built - run "npm run build" first');
-    }
-    
-    // Copy backend files
-    const backendFiles = [
-      'server.js',
-      'start-production.js',
-      'package.json',
-      'auth.js',
-      'themes.js',
-      '.env.production'
-    ];
-    
-    const backendDir = path.join(deploymentDir, 'backend');
-    await fs.ensureDir(backendDir);
-    
-    for (const file of backendFiles) {
-      const srcPath = path.join(__dirname, 'backend', file);
-      const destPath = path.join(backendDir, file);
-      
-      if (await fs.pathExists(srcPath)) {
-        await fs.copy(srcPath, destPath);
-        console.log(`✅ ${file} copied`);
-      } else {
-        console.log(`⚠️  ${file} not found`);
-      }
-    }
-    
-    // Copy public directory
-    if (await fs.pathExists(path.join(__dirname, 'public'))) {
-      await fs.copy(path.join(__dirname, 'public'), path.join(deploymentDir, 'public'));
-      console.log('✅ Public directory copied');
-    }
-    
-    // Copy configuration files
-    const configFiles = [
-      'Caddyfile',
-      'DEPLOYMENT.md'
-    ];
-    
-    for (const file of configFiles) {
-      const srcPath = path.join(__dirname, file);
-      const destPath = path.join(deploymentDir, file);
-      
-      if (await fs.pathExists(srcPath)) {
-        await fs.copy(srcPath, destPath);
-        console.log(`✅ ${file} copied`);
-      }
-    }
-    
-    // Create systemd service file
-    const systemdService = `[Unit]
-Description=Gooneral Wheelchair CMS Backend
-After=network.target
-
-[Service]
-Type=simple
-User=gooneral
-WorkingDirectory=/opt/gooneral-wheelchair/backend
-Environment=NODE_ENV=production
-ExecStart=/usr/bin/node start-production.js
-Restart=always
-RestartSec=10
-StandardOutput=syslog
-StandardError=syslog
-SyslogIdentifier=gooneral-wheelchair
-
-[Install]
-WantedBy=multi-user.target
-`;
-    
-    await fs.writeFile(path.join(deploymentDir, 'gooneral-wheelchair.service'), systemdService);
-    console.log('✅ Systemd service file created');
-    
-    // Create deployment script
-    const deployScript = `#!/bin/bash
-
-# Gooneral Wheelchair Deployment Script
-echo "🚀 Deploying Gooneral Wheelchair CMS..."
-
-# Check if running as root
-if [[ $EUID -eq 0 ]]; then
-   echo "❌ This script should not be run as root"
-   exit 1
-fi
-
-# Create application directory
-sudo mkdir -p /opt/gooneral-wheelchair
-sudo chown $USER:$USER /opt/gooneral-wheelchair
-
-# Copy files
-echo "📁 Copying application files..."
-cp -r dist /opt/gooneral-wheelchair/
-cp -r backend /opt/gooneral-wheelchair/
-cp -r public /opt/gooneral-wheelchair/
-cp Caddyfile /opt/gooneral-wheelchair/
-
-# Install backend dependencies
-echo "📦 Installing backend dependencies..."
-cd /opt/gooneral-wheelchair/backend
-npm install --production
-
-# Create directories
-mkdir -p sessions
-mkdir -p ../public/posts
-
-# Set up systemd service
-echo "⚙️ Setting up systemd service..."
-sudo cp ../gooneral-wheelchair.service /etc/systemd/system/
-sudo systemctl daemon-reload
-
-echo "✅ Deployment complete!"
-echo ""
-echo "Next steps:"
-echo "1. Edit /opt/gooneral-wheelchair/backend/.env.production"
-echo "2. Update Caddyfile with your domain"
-echo "3. Create admin user (see DEPLOYMENT.md)"
-echo "4. Start services:"
-echo "   sudo systemctl enable gooneral-wheelchair"
-echo "   sudo systemctl start gooneral-wheelchair"
-echo "   sudo systemctl reload caddy"
-`;
-    
-    await fs.writeFile(path.join(deploymentDir, 'deploy.sh'), deployScript);
-    await fs.chmod(path.join(deploymentDir, 'deploy.sh'), '755');
-    console.log('✅ Deployment script created');
-    
-    console.log('\n📦 Creating ZIP archive...');
-    
-    // Create ZIP archive
-    const output = fs.createWriteStream(archivePath);
-    const archive = archiver('zip', { zlib: { level: 9 } });
-    
-    archive.pipe(output);
-    archive.directory(deploymentDir, 'gooneral-wheelchair');
-    await archive.finalize();
-    
-    await new Promise((resolve, reject) => {
-      output.on('close', resolve);
-      archive.on('error', reject);
-    });
-    
-    console.log(`✅ Deployment package created: ${path.basename(archivePath)}`);
-    console.log(`📊 Archive size: ${(archive.pointer() / 1024 / 1024).toFixed(2)} MB`);
-    
-    // Clean up temporary directory
-    await fs.remove(deploymentDir);
-    
-    console.log('\n🎉 Ready for deployment!');
-    console.log('\nNext steps:');
-    console.log('1. Upload gooneral-wheelchair-deployment.zip to your server');
-    console.log('2. Extract: unzip gooneral-wheelchair-deployment.zip');
-    console.log('3. Run: cd gooneral-wheelchair && ./deploy.sh');
-    console.log('4. Follow the instructions in DEPLOYMENT.md');
-    
-  } catch (error) {
-    console.error('❌ Error creating deployment package:', error);
-    process.exit(1);
-  }
-}
-
-createDeploymentPackage();

+ 0 - 25
deploy-now.ps1

@@ -1,25 +0,0 @@
-# Gooneral Wheelchair - One-Line Deployment
-# Usage: .\deploy-now.ps1 -Domain "yourdomain.com" [-ServerHost "your.server.ip"] [-ServerUser "username"]
-
-param(
-    [Parameter(Mandatory=$true)]
-    [string]$Domain,
-    
-    [Parameter(Mandatory=$false)]
-    [string]$ServerHost,
-    
-    [Parameter(Mandatory=$false)]
-    [string]$ServerUser = "root"
-)
-
-if ($ServerHost) {
-    Write-Host "🚀 Running full deployment to server..." -ForegroundColor Green
-    & .\prepare-deployment.ps1 -Domain $Domain -ServerHost $ServerHost -ServerUser $ServerUser -UploadToServer
-} else {
-    Write-Host "📦 Preparing deployment package..." -ForegroundColor Green
-    & .\prepare-deployment.ps1 -Domain $Domain
-    
-    Write-Host ""
-    Write-Host "✨ Want to deploy directly to your server?" -ForegroundColor Yellow
-    Write-Host "Run: .\deploy-now.ps1 -Domain '$Domain' -ServerHost 'your.server.ip' -ServerUser 'username'" -ForegroundColor Gray
-}

+ 0 - 44
deploy-now.sh

@@ -1,44 +0,0 @@
-#!/bin/bash
-
-# Gooneral Wheelchair - One-Line Deployment for Linux/macOS
-# Usage: ./deploy-now.sh yourdomain.com [server-host] [server-user]
-
-# Colors for output
-RED='\033[0;31m'
-GREEN='\033[0;32m'
-YELLOW='\033[1;33m'
-BLUE='\033[0;34m'
-CYAN='\033[0;36m'
-NC='\033[0m' # No Color
-
-DOMAIN="$1"
-SERVER_HOST="$2"
-SERVER_USER="${3:-root}"
-
-if [ -z "$DOMAIN" ]; then
-    echo -e "${RED}❌ Error: Domain name is required${NC}"
-    echo ""
-    echo "Usage Examples:"
-    echo "  $0 yourdomain.com                    # Create deployment package"
-    echo "  $0 yourdomain.com server-ip          # Deploy directly to server" 
-    echo "  $0 yourdomain.com server-ip username # Deploy with custom user"
-    exit 1
-fi
-
-echo -e "${GREEN}🚀 Gooneral Wheelchair - One-Line Deploy${NC}"
-echo -e "${CYAN}📁 Domain: $DOMAIN${NC}"
-if [ -n "$SERVER_HOST" ]; then
-    echo -e "${CYAN}🌐 Server: $SERVER_HOST${NC}"
-fi
-
-if [ -n "$SERVER_HOST" ]; then
-    echo -e "${GREEN}🚀 Running full deployment to server...${NC}"
-    ./prepare-deployment.sh "$DOMAIN" "$SERVER_HOST" "$SERVER_USER"
-else
-    echo -e "${GREEN}📦 Preparing deployment package...${NC}"
-    ./prepare-deployment.sh "$DOMAIN"
-    
-    echo ""
-    echo -e "${YELLOW}✨ Want to deploy directly to your server?${NC}"
-    echo -e "${BLUE}Run: $0 $DOMAIN your.server.ip username${NC}"
-fi

+ 0 - 40
deploy.bat

@@ -1,40 +0,0 @@
-@echo off
-echo 🚀 Gooneral Wheelchair - Quick Deploy Script
-echo.
-
-if "%1"=="" (
-    echo ❌ Error: Domain name is required
-    echo.
-    echo Usage Examples:
-    echo   deploy.bat yourdomain.com
-    echo   deploy.bat yourdomain.com server-ip username
-    echo.
-    pause
-    exit /b 1
-)
-
-set DOMAIN=%1
-set SERVER_HOST=%2
-set SERVER_USER=%3
-
-if "%SERVER_USER%"=="" set SERVER_USER=root
-
-echo 📁 Domain: %DOMAIN%
-if not "%SERVER_HOST%"=="" echo 🌐 Server: %SERVER_HOST%
-
-if "%SERVER_HOST%"=="" (
-    echo 📦 Creating deployment package...
-    powershell -ExecutionPolicy Bypass -File "deploy-now.ps1" -Domain "%DOMAIN%"
-) else (
-    echo 🚀 Deploying directly to server...
-    powershell -ExecutionPolicy Bypass -File "deploy-now.ps1" -Domain "%DOMAIN%" -ServerHost "%SERVER_HOST%" -ServerUser "%SERVER_USER%"
-)
-
-echo.
-if %ERRORLEVEL% EQU 0 (
-    echo ✅ Deployment script completed!
-) else (
-    echo ❌ Deployment script failed!
-)
-
-pause

BIN
gooneral-wheelchair-deployment.zip


+ 0 - 425
prepare-deployment.ps1

@@ -1,425 +0,0 @@
-# Gooneral Wheelchair - Local Deployment Preparation Script
-# Run this on your Windows development machine
-
-param(
-    [Parameter(Mandatory=$true)]
-    [string]$Domain,
-    
-    [Parameter(Mandatory=$false)]
-    [string]$ServerUser = "root",
-    
-    [Parameter(Mandatory=$false)]
-    [string]$ServerHost,
-    
-    [Parameter(Mandatory=$false)]
-    [switch]$UploadToServer
-)
-
-Write-Host "🚀 Preparing Gooneral Wheelchair for deployment..." -ForegroundColor Green
-Write-Host "📁 Domain: $Domain" -ForegroundColor Cyan
-
-# Generate a secure session secret
-$SessionSecret = [System.Web.Security.Membership]::GeneratePassword(64, 10)
-
-# Build the frontend
-Write-Host "🏗️  Building frontend..." -ForegroundColor Yellow
-npm run build
-if ($LASTEXITCODE -ne 0) {
-    Write-Host "❌ Frontend build failed!" -ForegroundColor Red
-    exit 1
-}
-
-# Create deployment directory
-$DeployDir = ".\deployment-ready"
-if (Test-Path $DeployDir) {
-    Remove-Item $DeployDir -Recurse -Force
-}
-New-Item -ItemType Directory -Path $DeployDir -Force | Out-Null
-
-Write-Host "📦 Packaging files..." -ForegroundColor Yellow
-
-# Copy built frontend
-Copy-Item -Path ".\dist" -Destination "$DeployDir\dist" -Recurse
-
-# Copy backend files
-$BackendDir = "$DeployDir\backend"
-New-Item -ItemType Directory -Path $BackendDir -Force | Out-Null
-
-$BackendFiles = @(
-    "server.js",
-    "start-production.js", 
-    "package.json",
-    "auth.js",
-    "themes.js"
-)
-
-foreach ($file in $BackendFiles) {
-    if (Test-Path ".\backend\$file") {
-        Copy-Item -Path ".\backend\$file" -Destination "$BackendDir\$file"
-    }
-}
-
-# Copy public directory
-if (Test-Path ".\public") {
-    Copy-Item -Path ".\public" -Destination "$DeployDir\public" -Recurse
-}
-
-# Create production environment file with the generated secret
-$EnvContent = @"
-# Production Environment Variables - Generated $(Get-Date)
-
-# Server Configuration
-NODE_ENV=production
-PORT=3001
-
-# IMPORTANT: This session secret was auto-generated
-# Keep this secret and secure!
-SESSION_SECRET=$SessionSecret
-
-# CORS Configuration
-FRONTEND_URL=https://$Domain
-
-# Database/Storage paths (relative to backend directory)  
-POSTS_DIR=../public/posts
-THEMES_FILE=./themes.json
-SESSIONS_DIR=./sessions
-
-# Security Settings
-COOKIE_SECURE=true
-COOKIE_SAME_SITE=strict
-"@
-
-$EnvContent | Out-File -FilePath "$BackendDir\.env.production" -Encoding UTF8
-
-# Create Caddyfile with the actual domain
-$CaddyContent = @"
-# Caddy configuration for $Domain
-$Domain {
-    # Enable automatic HTTPS
-    # Caddy will automatically get and renew SSL certificates
-
-    # Serve the React frontend (static files)
-    root * dist
-    
-    # Try to serve static files first, then fallback to index.html for SPA routing
-    try_files {path} /index.html
-    
-    # API routes - proxy to backend
-    handle /api/* {
-        reverse_proxy localhost:3001
-    }
-    
-    # Health check endpoint  
-    handle /health {
-        reverse_proxy localhost:3001
-    }
-    
-    # Serve static files with proper headers
-    header /assets/* {
-        Cache-Control "public, max-age=31536000, immutable"
-    }
-    
-    # Security headers
-    header {
-        # Enable HSTS
-        Strict-Transport-Security "max-age=63072000; includeSubDomains; preload"
-        
-        # Prevent clickjacking
-        X-Frame-Options "DENY"
-        
-        # Prevent MIME type sniffing
-        X-Content-Type-Options "nosniff"
-        
-        # XSS protection
-        X-XSS-Protection "1; mode=block"
-        
-        # Referrer policy
-        Referrer-Policy "strict-origin-when-cross-origin"
-        
-        # Content Security Policy (adjust as needed)
-        Content-Security-Policy "default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; style-src 'self' 'unsafe-inline'; img-src 'self' data: https:; font-src 'self' data:;"
-    }
-    
-    # Gzip compression
-    encode gzip
-    
-    # Logging
-    log {
-        output file /var/log/caddy/gooneral-wheelchair.log
-        format json
-    }
-}
-"@
-
-$CaddyContent | Out-File -FilePath "$DeployDir\Caddyfile" -Encoding UTF8
-
-# Create systemd service file
-$ServiceContent = @"
-[Unit]
-Description=Gooneral Wheelchair CMS Backend
-After=network.target
-
-[Service]
-Type=simple
-User=gooneral
-WorkingDirectory=/opt/gooneral-wheelchair/backend
-Environment=NODE_ENV=production
-ExecStart=/usr/bin/node start-production.js
-Restart=always
-RestartSec=10
-StandardOutput=syslog
-StandardError=syslog
-SyslogIdentifier=gooneral-wheelchair
-
-[Install]
-WantedBy=multi-user.target
-"@
-
-$ServiceContent | Out-File -FilePath "$DeployDir\gooneral-wheelchair.service" -Encoding UTF8
-
-# Create the server deployment script
-$ServerDeployScript = @"
-#!/bin/bash
-
-# Gooneral Wheelchair - Automated Server Deployment Script
-# This script will fully set up your CMS on the server
-
-set -e  # Exit on any error
-
-echo "🚀 Starting automated deployment of Gooneral Wheelchair CMS..."
-
-# Check if running as root
-if [[ `$EUID -eq 0 ]]; then
-   echo "❌ Please run this script as a regular user with sudo privileges, not as root"
-   exit 1
-fi
-
-# Check if required commands exist
-for cmd in node npm caddy systemctl; do
-    if ! command -v `$cmd &> /dev/null; then
-        echo "❌ Required command '`$cmd' not found. Please install it first."
-        exit 1
-    fi
-done
-
-echo "✅ Prerequisites check passed"
-
-# Generate random password for admin user
-ADMIN_PASSWORD=`$(openssl rand -base64 32 | tr -d "=+/" | cut -c1-16)
-
-# Create application directory
-echo "📁 Setting up application directory..."
-sudo mkdir -p /opt/gooneral-wheelchair
-sudo chown `$USER:`$USER /opt/gooneral-wheelchair
-
-# Copy files
-echo "📦 Installing application files..."
-cp -r dist /opt/gooneral-wheelchair/
-cp -r backend /opt/gooneral-wheelchair/
-cp -r public /opt/gooneral-wheelchair/ 2>/dev/null || mkdir -p /opt/gooneral-wheelchair/public/posts
-
-# Install backend dependencies
-echo "📥 Installing backend dependencies..."
-cd /opt/gooneral-wheelchair/backend
-npm install --production --silent
-
-# Create required directories
-mkdir -p sessions
-mkdir -p ../public/posts
-
-# Set up system user for security
-echo "👤 Setting up system user..."
-if ! id "gooneral" &>/dev/null; then
-    sudo useradd --system --shell /bin/false --home /opt/gooneral-wheelchair gooneral
-fi
-
-# Set proper ownership
-sudo chown -R gooneral:gooneral /opt/gooneral-wheelchair
-
-# Make start script executable  
-chmod +x start-production.js
-
-# Install and start systemd service
-echo "⚙️ Setting up systemd service..."
-sudo cp ../gooneral-wheelchair.service /etc/systemd/system/
-sudo systemctl daemon-reload
-sudo systemctl enable gooneral-wheelchair
-sudo systemctl start gooneral-wheelchair
-
-# Give the service a moment to start
-sleep 3
-
-if sudo systemctl is-active --quiet gooneral-wheelchair; then
-    echo "✅ Backend service started successfully"
-else
-    echo "❌ Backend service failed to start. Checking logs..."
-    sudo systemctl status gooneral-wheelchair
-    exit 1
-fi
-
-# Set up Caddy
-echo "🌐 Configuring Caddy..."
-sudo cp Caddyfile /etc/caddy/Caddyfile
-
-# Test Caddy configuration
-if sudo caddy validate --config /etc/caddy/Caddyfile; then
-    echo "✅ Caddy configuration is valid"
-    sudo systemctl reload caddy
-else
-    echo "❌ Caddy configuration is invalid"
-    exit 1
-fi
-
-# Create admin user
-echo "👨‍💼 Creating admin user..."
-cd /opt/gooneral-wheelchair/backend
-node -e "
-const bcrypt = require('bcryptjs');
-const fs = require('fs');
-const path = require('path');
-
-const username = 'admin';
-const password = '`$ADMIN_PASSWORD';
-const hashedPassword = bcrypt.hashSync(password, 10);
-
-const usersFile = path.join(__dirname, 'users.json');
-const users = [
-  {
-    id: 1,
-    username: username,
-    password: hashedPassword,
-    role: 'admin'
-  }
-];
-
-fs.writeFileSync(usersFile, JSON.stringify(users, null, 2));
-console.log('Admin user created successfully');
-"
-
-# Set proper ownership again after creating files
-sudo chown -R gooneral:gooneral /opt/gooneral-wheelchair
-
-# Final status check
-echo ""
-echo "🎉 Deployment completed successfully!"
-echo ""
-echo "==================== IMPORTANT ===================="
-echo "🔐 Your admin credentials:"
-echo "   Username: admin"
-echo "   Password: `$ADMIN_PASSWORD"
-echo ""
-echo "⚠️  SAVE THESE CREDENTIALS SECURELY!"
-echo "⚠️  Change the password after first login!"
-echo "==================== IMPORTANT ===================="
-echo ""
-echo "🌐 Your blog is now available at: https://$Domain"
-echo "🔧 Admin panel: https://$Domain/admin"
-echo ""
-echo "📊 Service status:"
-sudo systemctl status gooneral-wheelchair --no-pager
-echo ""
-sudo systemctl status caddy --no-pager
-echo ""
-echo "📝 To view logs:"
-echo "   Backend: sudo journalctl -u gooneral-wheelchair -f"
-echo "   Caddy: sudo journalctl -u caddy -f"
-echo ""
-echo "✅ Deployment complete!"
-"@
-
-$ServerDeployScript | Out-File -FilePath "$DeployDir\deploy.sh" -Encoding UTF8
-
-# Create a README for the deployment
-$ReadmeContent = @"
-# Gooneral Wheelchair - Deployment Package
-
-## Quick Deployment
-
-1. Upload this entire directory to your server
-2. Run the deployment script: `./deploy.sh`
-3. Access your blog at https://$Domain
-
-## What's Included
-
-- Built frontend in `dist/`
-- Backend application in `backend/`
-- Auto-configured Caddyfile for $Domain  
-- Systemd service configuration
-- Automated deployment script
-
-## Generated Configuration
-
-- **Domain**: $Domain
-- **Session Secret**: Auto-generated (64 characters)
-- **Admin User**: Will be created automatically
-- **SSL**: Automatic via Caddy + Let's Encrypt
-
-## After Deployment
-
-The script will output your admin credentials. Save them securely!
-
-Access your blog:
-- **Blog**: https://$Domain
-- **Admin**: https://$Domain/admin
-
-## Manual Steps (if needed)
-
-If the automated script doesn't work, see DEPLOYMENT.md for manual instructions.
-"@
-
-$ReadmeContent | Out-File -FilePath "$DeployDir\README.md" -Encoding UTF8
-
-# Copy the detailed deployment guide
-Copy-Item -Path ".\DEPLOYMENT.md" -Destination "$DeployDir\DEPLOYMENT.md"
-
-# Create the upload script if server details provided
-if ($ServerHost -and $UploadToServer) {
-    Write-Host "📤 Uploading to server..." -ForegroundColor Yellow
-    
-    # Create a tar.gz for easier upload (requires tar on Windows or WSL)
-    $TarFile = "gooneral-wheelchair-deployment.tar.gz"
-    
-    if (Get-Command tar -ErrorAction SilentlyContinue) {
-        tar -czf $TarFile -C $DeployDir .
-        
-        # Upload and deploy
-        scp $TarFile "${ServerUser}@${ServerHost}:~/"
-        ssh "${ServerUser}@${ServerHost}" "
-            mkdir -p gooneral-wheelchair-deploy
-            cd gooneral-wheelchair-deploy  
-            tar -xzf ../$TarFile
-            chmod +x deploy.sh
-            ./deploy.sh
-        "
-        
-        Remove-Item $TarFile
-        Write-Host "✅ Deployment completed remotely!" -ForegroundColor Green
-    } else {
-        Write-Host "⚠️  tar command not found. Please upload manually or install tar." -ForegroundColor Yellow
-    }
-}
-
-Write-Host ""
-Write-Host "🎉 Deployment package ready!" -ForegroundColor Green
-Write-Host "📁 Location: $DeployDir" -ForegroundColor Cyan
-Write-Host ""
-Write-Host "Next steps:" -ForegroundColor Yellow
-Write-Host "1. Upload the '$DeployDir' folder to your server" -ForegroundColor White
-Write-Host "2. SSH to your server and run: ./deploy.sh" -ForegroundColor White
-Write-Host "3. Access your blog at https://$Domain" -ForegroundColor White
-Write-Host ""
-Write-Host "💡 Or run this again with -UploadToServer and -ServerHost flags for automatic upload" -ForegroundColor Gray
-
-# Save deployment info
-$DeployInfo = @{
-    Domain = $Domain
-    SessionSecret = $SessionSecret
-    DeploymentTime = Get-Date
-    DeploymentPath = $DeployDir
-}
-
-$DeployInfo | ConvertTo-Json | Out-File -FilePath "$DeployDir\deployment-info.json" -Encoding UTF8
-
-Write-Host ""
-Write-Host "✅ Session secret generated and saved securely in deployment package" -ForegroundColor Green
-Write-Host "🔐 Keep your deployment files secure - they contain sensitive configuration!" -ForegroundColor Red

+ 0 - 440
prepare-deployment.sh

@@ -1,440 +0,0 @@
-#!/bin/bash
-
-# Gooneral Wheelchair - Linux/macOS Deployment Preparation Script
-# Usage: ./prepare-deployment.sh yourdomain.com [server-host] [server-user]
-
-set -e  # Exit on any error
-
-# Colors for output
-RED='\033[0;31m'
-GREEN='\033[0;32m'
-YELLOW='\033[1;33m'
-BLUE='\033[0;34m'
-CYAN='\033[0;36m'
-NC='\033[0m' # No Color
-
-# Parse arguments
-DOMAIN="$1"
-SERVER_HOST="$2"
-SERVER_USER="${3:-root}"
-
-if [ -z "$DOMAIN" ]; then
-    echo -e "${RED}❌ Error: Domain name is required${NC}"
-    echo ""
-    echo "Usage:"
-    echo "  $0 yourdomain.com                    # Create deployment package"
-    echo "  $0 yourdomain.com server-ip          # Deploy directly to server"
-    echo "  $0 yourdomain.com server-ip username # Deploy with custom user"
-    exit 1
-fi
-
-echo -e "${GREEN}🚀 Preparing Gooneral Wheelchair for deployment...${NC}"
-echo -e "${CYAN}📁 Domain: $DOMAIN${NC}"
-
-# Generate secure session secret
-SESSION_SECRET=$(openssl rand -base64 64 | tr -d "=+/" | cut -c1-64)
-
-# Build the frontend
-echo -e "${YELLOW}🏗️  Building frontend...${NC}"
-npm run build
-if [ $? -ne 0 ]; then
-    echo -e "${RED}❌ Frontend build failed!${NC}"
-    exit 1
-fi
-
-# Create deployment directory
-DEPLOY_DIR="./deployment-ready"
-if [ -d "$DEPLOY_DIR" ]; then
-    rm -rf "$DEPLOY_DIR"
-fi
-mkdir -p "$DEPLOY_DIR"
-
-echo -e "${YELLOW}📦 Packaging files...${NC}"
-
-# Copy built frontend
-cp -r ./dist "$DEPLOY_DIR/"
-
-# Copy backend files
-BACKEND_DIR="$DEPLOY_DIR/backend"
-mkdir -p "$BACKEND_DIR"
-
-BACKEND_FILES=(
-    "server.js"
-    "start-production.js"
-    "package.json"
-    "auth.js"
-    "themes.js"
-)
-
-for file in "${BACKEND_FILES[@]}"; do
-    if [ -f "./backend/$file" ]; then
-        cp "./backend/$file" "$BACKEND_DIR/"
-    fi
-done
-
-# Copy public directory if it exists
-if [ -d "./public" ]; then
-    cp -r ./public "$DEPLOY_DIR/"
-fi
-
-# Create production environment file
-cat > "$BACKEND_DIR/.env.production" << EOF
-# Production Environment Variables - Generated $(date)
-
-# Server Configuration
-NODE_ENV=production
-PORT=3001
-
-# IMPORTANT: This session secret was auto-generated
-# Keep this secret and secure!
-SESSION_SECRET=$SESSION_SECRET
-
-# CORS Configuration
-FRONTEND_URL=https://$DOMAIN
-
-# Database/Storage paths (relative to backend directory)
-POSTS_DIR=../public/posts
-THEMES_FILE=./themes.json
-SESSIONS_DIR=./sessions
-
-# Security Settings
-COOKIE_SECURE=true
-COOKIE_SAME_SITE=strict
-EOF
-
-# Create Caddyfile with the actual domain
-cat > "$DEPLOY_DIR/Caddyfile" << EOF
-# Caddy configuration for $DOMAIN
-$DOMAIN {
-    # Enable automatic HTTPS
-    # Caddy will automatically get and renew SSL certificates
-
-    # Serve the React frontend (static files)
-    root * dist
-    
-    # Try to serve static files first, then fallback to index.html for SPA routing
-    try_files {path} /index.html
-    
-    # API routes - proxy to backend
-    handle /api/* {
-        reverse_proxy localhost:3001
-    }
-    
-    # Health check endpoint
-    handle /health {
-        reverse_proxy localhost:3001
-    }
-    
-    # Serve static files with proper headers
-    header /assets/* {
-        Cache-Control "public, max-age=31536000, immutable"
-    }
-    
-    # Security headers
-    header {
-        # Enable HSTS
-        Strict-Transport-Security "max-age=63072000; includeSubDomains; preload"
-        
-        # Prevent clickjacking
-        X-Frame-Options "DENY"
-        
-        # Prevent MIME type sniffing
-        X-Content-Type-Options "nosniff"
-        
-        # XSS protection
-        X-XSS-Protection "1; mode=block"
-        
-        # Referrer policy
-        Referrer-Policy "strict-origin-when-cross-origin"
-        
-        # Content Security Policy (adjust as needed)
-        Content-Security-Policy "default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; style-src 'self' 'unsafe-inline'; img-src 'self' data: https:; font-src 'self' data:;"
-    }
-    
-    # Gzip compression
-    encode gzip
-    
-    # Logging
-    log {
-        output file /var/log/caddy/gooneral-wheelchair.log
-        format json
-    }
-}
-EOF
-
-# Create systemd service file
-cat > "$DEPLOY_DIR/gooneral-wheelchair.service" << EOF
-[Unit]
-Description=Gooneral Wheelchair CMS Backend
-After=network.target
-
-[Service]
-Type=simple
-User=gooneral
-WorkingDirectory=/opt/gooneral-wheelchair/backend
-Environment=NODE_ENV=production
-ExecStart=/usr/bin/node start-production.js
-Restart=always
-RestartSec=10
-StandardOutput=syslog
-StandardError=syslog
-SyslogIdentifier=gooneral-wheelchair
-
-[Install]
-WantedBy=multi-user.target
-EOF
-
-# Create the server deployment script
-cat > "$DEPLOY_DIR/deploy.sh" << 'EOF'
-#!/bin/bash
-
-# Gooneral Wheelchair - Automated Server Deployment Script
-# This script will fully set up your CMS on the server
-
-set -e  # Exit on any error
-
-# Colors for output
-RED='\033[0;31m'
-GREEN='\033[0;32m'
-YELLOW='\033[1;33m'
-BLUE='\033[0;34m'
-NC='\033[0m'
-
-echo -e "${GREEN}🚀 Starting automated deployment of Gooneral Wheelchair CMS...${NC}"
-
-# Check if running as root
-if [[ $EUID -eq 0 ]]; then
-   echo -e "${RED}❌ Please run this script as a regular user with sudo privileges, not as root${NC}"
-   exit 1
-fi
-
-# Check if required commands exist
-for cmd in node npm caddy systemctl; do
-    if ! command -v $cmd &> /dev/null; then
-        echo -e "${RED}❌ Required command '$cmd' not found. Please install it first.${NC}"
-        exit 1
-    fi
-done
-
-echo -e "${GREEN}✅ Prerequisites check passed${NC}"
-
-# Generate random password for admin user
-ADMIN_PASSWORD=$(openssl rand -base64 32 | tr -d "=+/" | cut -c1-16)
-
-# Create application directory
-echo -e "${YELLOW}📁 Setting up application directory...${NC}"
-sudo mkdir -p /opt/gooneral-wheelchair
-sudo chown $USER:$USER /opt/gooneral-wheelchair
-
-# Copy files
-echo -e "${YELLOW}📦 Installing application files...${NC}"
-cp -r dist /opt/gooneral-wheelchair/
-cp -r backend /opt/gooneral-wheelchair/
-cp -r public /opt/gooneral-wheelchair/ 2>/dev/null || mkdir -p /opt/gooneral-wheelchair/public/posts
-
-# Install backend dependencies
-echo -e "${YELLOW}📥 Installing backend dependencies...${NC}"
-cd /opt/gooneral-wheelchair/backend
-npm install --production --silent
-
-# Create required directories
-mkdir -p sessions
-mkdir -p ../public/posts
-
-# Set up system user for security
-echo -e "${YELLOW}👤 Setting up system user...${NC}"
-if ! id "gooneral" &>/dev/null; then
-    sudo useradd --system --shell /bin/false --home /opt/gooneral-wheelchair gooneral
-fi
-
-# Set proper ownership
-sudo chown -R gooneral:gooneral /opt/gooneral-wheelchair
-
-# Make start script executable
-chmod +x start-production.js
-
-# Install and start systemd service
-echo -e "${YELLOW}⚙️ Setting up systemd service...${NC}"
-sudo cp ../gooneral-wheelchair.service /etc/systemd/system/
-sudo systemctl daemon-reload
-sudo systemctl enable gooneral-wheelchair
-sudo systemctl start gooneral-wheelchair
-
-# Give the service a moment to start
-sleep 3
-
-if sudo systemctl is-active --quiet gooneral-wheelchair; then
-    echo -e "${GREEN}✅ Backend service started successfully${NC}"
-else
-    echo -e "${RED}❌ Backend service failed to start. Checking logs...${NC}"
-    sudo systemctl status gooneral-wheelchair
-    exit 1
-fi
-
-# Set up Caddy
-echo -e "${YELLOW}🌐 Configuring Caddy...${NC}"
-sudo cp Caddyfile /etc/caddy/Caddyfile
-
-# Test Caddy configuration
-if sudo caddy validate --config /etc/caddy/Caddyfile; then
-    echo -e "${GREEN}✅ Caddy configuration is valid${NC}"
-    sudo systemctl reload caddy
-else
-    echo -e "${RED}❌ Caddy configuration is invalid${NC}"
-    exit 1
-fi
-
-# Create admin user
-echo -e "${YELLOW}👨‍💼 Creating admin user...${NC}"
-cd /opt/gooneral-wheelchair/backend
-node -e "
-const bcrypt = require('bcryptjs');
-const fs = require('fs');
-const path = require('path');
-
-const username = 'admin';
-const password = '$ADMIN_PASSWORD';
-const hashedPassword = bcrypt.hashSync(password, 10);
-
-const usersFile = path.join(__dirname, 'users.json');
-const users = [
-  {
-    id: 1,
-    username: username,
-    password: hashedPassword,
-    role: 'admin'
-  }
-];
-
-fs.writeFileSync(usersFile, JSON.stringify(users, null, 2));
-console.log('Admin user created successfully');
-"
-
-# Set proper ownership again after creating files
-sudo chown -R gooneral:gooneral /opt/gooneral-wheelchair
-
-# Extract domain from Caddyfile
-DOMAIN=$(grep -E '^[a-zA-Z0-9.-]+\.[a-zA-Z]{2,} {' Caddyfile | head -1 | cut -d' ' -f1)
-
-# Final status check
-echo ""
-echo -e "${GREEN}🎉 Deployment completed successfully!${NC}"
-echo ""
-echo "==================== IMPORTANT ===================="
-echo -e "${BLUE}🔐 Your admin credentials:${NC}"
-echo "   Username: admin"
-echo "   Password: $ADMIN_PASSWORD"
-echo ""
-echo -e "${RED}⚠️  SAVE THESE CREDENTIALS SECURELY!${NC}"
-echo -e "${RED}⚠️  Change the password after first login!${NC}"
-echo "==================== IMPORTANT ===================="
-echo ""
-echo -e "${CYAN}🌐 Your blog is now available at: https://$DOMAIN${NC}"
-echo -e "${CYAN}🔧 Admin panel: https://$DOMAIN/admin${NC}"
-echo ""
-echo -e "${YELLOW}📊 Service status:${NC}"
-sudo systemctl status gooneral-wheelchair --no-pager
-echo ""
-sudo systemctl status caddy --no-pager
-echo ""
-echo -e "${YELLOW}📝 To view logs:${NC}"
-echo "   Backend: sudo journalctl -u gooneral-wheelchair -f"
-echo "   Caddy: sudo journalctl -u caddy -f"
-echo ""
-echo -e "${GREEN}✅ Deployment complete!${NC}"
-EOF
-
-chmod +x "$DEPLOY_DIR/deploy.sh"
-
-# Create README
-cat > "$DEPLOY_DIR/README.md" << EOF
-# Gooneral Wheelchair - Deployment Package
-
-## Quick Deployment
-
-1. Upload this entire directory to your server
-2. Run the deployment script: \`./deploy.sh\`
-3. Access your blog at https://$DOMAIN
-
-## What's Included
-
-- Built frontend in \`dist/\`
-- Backend application in \`backend/\`
-- Auto-configured Caddyfile for $DOMAIN
-- Systemd service configuration
-- Automated deployment script
-
-## Generated Configuration
-
-- **Domain**: $DOMAIN
-- **Session Secret**: Auto-generated (64 characters)
-- **Admin User**: Will be created automatically
-- **SSL**: Automatic via Caddy + Let's Encrypt
-
-## After Deployment
-
-The script will output your admin credentials. Save them securely!
-
-Access your blog:
-- **Blog**: https://$DOMAIN
-- **Admin**: https://$DOMAIN/admin
-
-## Manual Steps (if needed)
-
-If the automated script doesn't work, see DEPLOYMENT.md for manual instructions.
-EOF
-
-# Copy the detailed deployment guide
-cp ./DEPLOYMENT.md "$DEPLOY_DIR/" 2>/dev/null || echo "Note: DEPLOYMENT.md not found, skipping..."
-
-# Upload and deploy if server specified
-if [ -n "$SERVER_HOST" ]; then
-    echo -e "${YELLOW}📤 Uploading to server...${NC}"
-    
-    # Create tarball
-    TAR_FILE="gooneral-wheelchair-deployment.tar.gz"
-    tar -czf "$TAR_FILE" -C "$DEPLOY_DIR" .
-    
-    echo -e "${YELLOW}🚀 Deploying to $SERVER_HOST...${NC}"
-    
-    # Upload and execute deployment
-    scp "$TAR_FILE" "${SERVER_USER}@${SERVER_HOST}:~/"
-    ssh "${SERVER_USER}@${SERVER_HOST}" "
-        mkdir -p gooneral-wheelchair-deploy
-        cd gooneral-wheelchair-deploy
-        tar -xzf ../$TAR_FILE
-        chmod +x deploy.sh
-        ./deploy.sh
-    "
-    
-    # Clean up local tarball
-    rm "$TAR_FILE"
-    
-    echo -e "${GREEN}✅ Remote deployment completed!${NC}"
-else
-    echo ""
-    echo -e "${GREEN}🎉 Deployment package ready!${NC}"
-    echo -e "${CYAN}📁 Location: $DEPLOY_DIR${NC}"
-    echo ""
-    echo -e "${YELLOW}Next steps:${NC}"
-    echo "1. Upload the '$DEPLOY_DIR' folder to your server"
-    echo "2. SSH to your server and run: ./deploy.sh"
-    echo "3. Access your blog at https://$DOMAIN"
-    echo ""
-    echo -e "${BLUE}💡 Or run this again with server details for automatic deployment:${NC}"
-    echo "./prepare-deployment.sh $DOMAIN your.server.ip username"
-fi
-
-# Save deployment info
-cat > "$DEPLOY_DIR/deployment-info.json" << EOF
-{
-    "domain": "$DOMAIN",
-    "sessionSecret": "$SESSION_SECRET",
-    "deploymentTime": "$(date -Iseconds)",
-    "deploymentPath": "$DEPLOY_DIR"
-}
-EOF
-
-echo ""
-echo -e "${GREEN}✅ Session secret generated and saved securely in deployment package${NC}"
-echo -e "${RED}🔐 Keep your deployment files secure - they contain sensitive configuration!${NC}"