diff --git a/CLAUDE.md b/CLAUDE.md index 1417217..ae66fb2 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -74,8 +74,26 @@ npm test # Run tests with coverage report (76% overall coverage) npm run test:coverage + +# Run a single test file +npm test -- tests/unit/models/Location.test.ts + +# Run tests matching a pattern +npm test -- --testNamePattern="should create a new location" + +# Run tests in watch mode for a specific file +npx jest --watch tests/unit/models/Location.test.ts + +# Run with debugging +node --inspect-brk ./node_modules/.bin/jest --runInBand tests/unit/models/Location.test.ts ``` +**Test Structure:** +- **Unit tests**: `tests/unit/` (models, services) +- **Integration tests**: `tests/integration/` (routes) +- **Test setup**: `tests/setup.ts` +- **Mocks**: `tests/__mocks__/` + **Test Coverage:** - **Unit Tests:** Location/ProfanityWord models, DatabaseService, ProfanityFilterService - **Integration Tests:** Public API routes, Admin API routes with authentication @@ -227,6 +245,9 @@ SCSS files are in `src/scss/`: 12. **Offline-First Design**: Service worker caching with automatic updates ### Deployment -- Automated deployment script for Debian 12 ARM64 in `scripts/deploy.sh` +- Automated deployment script for Debian 12 (ARM64/x86_64) in `scripts/deploy.sh` - Caddy reverse proxy configuration in `scripts/Caddyfile` -- Systemd service files for process management \ No newline at end of file +- Systemd service files for process management +- Application directory: `/opt/icewatch` +- System user: `icewatch` +- Public repository: https://git.deco.sh/deco/ice.git \ No newline at end of file diff --git a/README.md b/README.md index bf853b6..ad7d1a4 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ A community-driven web application for tracking winter road conditions and icy h 1. **Clone the repository:** ```bash - git clone git@git.deco.sh:deco/ice.git + git clone https://git.deco.sh/deco/ice.git cd ice ``` diff --git a/scripts/deploy.sh b/scripts/deploy.sh index 70413fb..3f23844 100644 --- a/scripts/deploy.sh +++ b/scripts/deploy.sh @@ -2,6 +2,15 @@ # Great Lakes Ice Report Deployment Script for Debian 12 (ARM64/x86_64) # Supports both ARM64 and x86_64 architectures +# +# Usage: +# ./deploy.sh # Downloads from default S3 bucket (ice-puremichigan-lol) +# S3_BUCKET_NAME=mybucket ./deploy.sh # Downloads from custom S3 bucket +# S3_BUCKET_NAME=none ./deploy.sh # Uses local files from repository +# +# When using S3, expects files at: +# https://{bucket}.s3.amazonaws.com/scripts/icewatch.service +# https://{bucket}.s3.amazonaws.com/scripts/Caddyfile set -e @@ -118,46 +127,76 @@ cd /opt/icewatch echo "👤 Creating icewatch user..." sudo useradd --system --shell /bin/false --home /opt/icewatch --create-home icewatch -# Download additional configuration files from S3 -echo "📥 Downloading configuration files..." -S3_BASE_URL="https://greatlakes-conditions.s3.amazonaws.com/scripts" +# Download or copy configuration files +# Use provided S3_BUCKET_NAME or fall back to ice-puremichigan-lol +S3_BUCKET_NAME="${S3_BUCKET_NAME:-ice-puremichigan-lol}" -# Download systemd service file -echo "📥 Downloading systemd service..." -curl -sSL "$S3_BASE_URL/icewatch.service" | sudo tee /etc/systemd/system/icewatch.service > /dev/null - -# Download Caddyfile template -echo "📥 Downloading Caddy configuration..." -curl -sSL "$S3_BASE_URL/Caddyfile" | sudo tee /etc/caddy/Caddyfile.template > /dev/null +if [ "$S3_BUCKET_NAME" != "none" ]; then + echo "📥 Downloading configuration files from S3 bucket: $S3_BUCKET_NAME" + S3_BASE_URL="https://${S3_BUCKET_NAME}.s3.amazonaws.com/scripts" + + # Download systemd service file + echo "📥 Downloading systemd service..." + curl -sSL "$S3_BASE_URL/icewatch.service" -o /tmp/icewatch.service + if [ $? -eq 0 ]; then + sudo mv /tmp/icewatch.service /etc/systemd/system/icewatch.service + echo "✅ Downloaded icewatch.service from S3" + else + echo "❌ Failed to download icewatch.service from S3" + exit 1 + fi + + # Download Caddyfile template + echo "📥 Downloading Caddy configuration..." + curl -sSL "$S3_BASE_URL/Caddyfile" -o /tmp/Caddyfile + if [ $? -eq 0 ]; then + sudo mv /tmp/Caddyfile /etc/caddy/Caddyfile.template + echo "✅ Downloaded Caddyfile from S3" + else + echo "❌ Failed to download Caddyfile from S3" + exit 1 + fi +else + echo "📋 Note: S3 downloads disabled (S3_BUCKET_NAME=none). Configuration files will be copied from the repository after cloning." + echo " The systemd service file and Caddyfile are located in the scripts/ directory." +fi echo "✅ Server setup complete!" echo "" echo "🚀 Next steps to deploy Great Lakes Ice Report:" echo "" echo "1. Clone your repository:" -echo " git clone git@git.deco.sh:deco/ice.git /opt/icewatch" +echo " git clone https://git.deco.sh/deco/ice.git /opt/icewatch" echo "" -echo "2. Set up the application:" +if [ "$S3_BUCKET_NAME" = "none" ]; then + echo "2. Copy configuration files:" + echo " sudo cp /opt/icewatch/scripts/icewatch.service /etc/systemd/system/" + echo " sudo cp /opt/icewatch/scripts/Caddyfile /etc/caddy/Caddyfile" + echo "" +else + echo "2. Configuration files already downloaded from S3" + echo "" +fi +echo "3. Set up the application:" echo " cd /opt/icewatch" echo " npm install" echo " cp .env.example .env" echo " nano .env # Add your MapBox token and admin password" echo "" -echo "3. Configure domain in Caddyfile:" -echo " sudo nano /etc/caddy/Caddyfile.template" -echo " # Replace 'yourdomain.com' with your actual domain" -echo " sudo mv /etc/caddy/Caddyfile.template /etc/caddy/Caddyfile" +echo "4. Configure domain in Caddyfile (if needed):" +echo " sudo nano /etc/caddy/Caddyfile" +echo " # The default is configured for ice.puremichigan.lol" echo "" -echo "4. Set permissions:" +echo "5. Set permissions:" echo " sudo chown -R icewatch:icewatch /opt/icewatch" echo " sudo chmod 660 /opt/icewatch/.env" echo "" -echo "5. Start services:" +echo "6. Start services:" echo " sudo systemctl daemon-reload" echo " sudo systemctl enable icewatch caddy" echo " sudo systemctl start icewatch caddy" echo "" -echo "6. Check status:" +echo "7. Check status:" echo " sudo systemctl status icewatch" echo " sudo systemctl status caddy" echo ""