progresspulse-pwa
Version:
A modern PWA for tracking progress and achieving goals with iPhone-style design
218 lines (170 loc) ⢠6.15 kB
JavaScript
#!/usr/bin/env node
import { writeFileSync } from 'fs';
import { join, dirname } from 'path';
import { fileURLToPath } from 'url';
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
const projectRoot = join(__dirname, '..');
console.log('š ProgressPulse Production Setup');
console.log('==================================\n');
// Create .env.example file
const envExample = `# ProgressPulse Environment Variables
# Copy this file to .env and fill in your actual values
# Firebase Configuration (Required for push notifications)
FIREBASE_API_KEY=your_firebase_api_key_here
FIREBASE_AUTH_DOMAIN=your-project.firebaseapp.com
FIREBASE_PROJECT_ID=your-firebase-project-id
FIREBASE_STORAGE_BUCKET=your-project.appspot.com
FIREBASE_MESSAGING_SENDER_ID=123456789012
FIREBASE_APP_ID=1:123456789012:web:abcdef123456
# VAPID Keys for Web Push (Generate at https://vapidkeys.com/)
VAPID_PUBLIC_KEY=your_vapid_public_key_here
VAPID_PRIVATE_KEY=your_vapid_private_key_here
# CDN Configuration (Optional)
CDN_BASE_URL=https://your-cdn.com
UPDATE_BASE_URL=https://your-cdn.com/updates
# Database Configuration (Optional)
DATABASE_URL=your_database_connection_string
# Monitoring (Optional)
SENTRY_DSN=your_sentry_dsn
ANALYTICS_ID=your_analytics_id
`;
writeFileSync(join(projectRoot, '.env.example'), envExample);
// Create deployment checklist
const deploymentChecklist = `# š ProgressPulse Deployment Checklist
## Pre-Deployment Setup
### 1. Environment Configuration
- [ ] Copy \`.env.example\` to \`.env\`
- [ ] Configure Firebase project and add credentials
- [ ] Generate VAPID keys for push notifications
- [ ] Set up CDN for update distribution
- [ ] Configure database connection (if using external DB)
### 2. Firebase Setup
- [ ] Create Firebase project
- [ ] Enable Authentication
- [ ] Enable Firestore Database
- [ ] Enable Cloud Messaging
- [ ] Add web app to Firebase project
- [ ] Download and configure service account key
### 3. Push Notifications Setup
- [ ] Generate VAPID key pair
- [ ] Configure Firebase Cloud Messaging
- [ ] Test push notification delivery
- [ ] Set up notification templates
### 4. CDN Configuration
- [ ] Set up CDN for static assets
- [ ] Configure update package distribution
- [ ] Set up proper CORS headers
- [ ] Test download speeds from different regions
## Deployment Steps
### 1. Build and Test
\`\`\`bash
npm run build
npm run test-update
npm run demo-update
\`\`\`
### 2. Deploy to Production
\`\`\`bash
# Deploy to your hosting platform
npm run deploy
# Or manual deployment
npm run build
# Upload dist/ folder to your server
\`\`\`
### 3. Post-Deployment Verification
- [ ] Test app loading and functionality
- [ ] Verify push notifications work
- [ ] Test update system end-to-end
- [ ] Check analytics and monitoring
- [ ] Verify PWA installation works
## Update Publishing Workflow
### For Bug Fixes (Patch)
\`\`\`bash
npm run version:patch
\`\`\`
### For New Features (Minor)
\`\`\`bash
npm run version:minor
\`\`\`
### For Breaking Changes (Major)
\`\`\`bash
npm run version:major
\`\`\`
### Manual Update Publishing
\`\`\`bash
npm run build
npm run publish-update
\`\`\`
## Monitoring and Maintenance
### Daily Checks
- [ ] Monitor update delivery success rates
- [ ] Check push notification delivery
- [ ] Review error logs and user feedback
- [ ] Monitor app performance metrics
### Weekly Tasks
- [ ] Review update adoption rates
- [ ] Analyze user engagement metrics
- [ ] Check for security updates
- [ ] Update dependencies if needed
### Monthly Tasks
- [ ] Review and update documentation
- [ ] Analyze user feedback and feature requests
- [ ] Plan next release cycle
- [ ] Security audit and penetration testing
## Troubleshooting
### Common Issues
1. **Push notifications not working**
- Check VAPID keys configuration
- Verify Firebase setup
- Ensure HTTPS in production
2. **Updates not downloading**
- Check CDN configuration
- Verify CORS headers
- Test network connectivity
3. **Installation failures**
- Check service worker registration
- Verify update package integrity
- Check browser compatibility
### Debug Commands
\`\`\`bash
# Enable debug logging
localStorage.setItem('debug-updates', 'true');
# Test update system
npm run test-update
# Create demo update
npm run demo-update
\`\`\`
## Security Considerations
- [ ] All communications use HTTPS
- [ ] Update packages are signed and verified
- [ ] User data is encrypted at rest and in transit
- [ ] Regular security audits are performed
- [ ] Dependency vulnerabilities are monitored
## Performance Optimization
- [ ] Enable gzip/brotli compression
- [ ] Configure proper caching headers
- [ ] Optimize images and assets
- [ ] Use CDN for global distribution
- [ ] Monitor Core Web Vitals
## Backup and Recovery
- [ ] Regular database backups
- [ ] Version control for all code changes
- [ ] Rollback plan for failed deployments
- [ ] Disaster recovery procedures documented
`;
writeFileSync(join(projectRoot, 'DEPLOYMENT.md'), deploymentChecklist);
console.log('ā
Created .env.example file');
console.log('ā
Created DEPLOYMENT.md checklist');
console.log('\nš§ Next Steps:');
console.log('1. Copy .env.example to .env and configure');
console.log('2. Set up Firebase project and get credentials');
console.log('3. Generate VAPID keys at https://vapidkeys.com/');
console.log('4. Follow DEPLOYMENT.md for complete setup');
console.log('\nšÆ Quick Start for Development:');
console.log('npm run demo-update # Create demo update');
console.log('npm run dev # Start development server');
console.log('# Go to Settings ā Updates to test');
console.log('\nš Documentation:');
console.log('⢠UPDATE_SYSTEM.md - Complete update system guide');
console.log('⢠DEPLOYMENT.md - Production deployment checklist');
console.log('⢠.env.example - Environment variables template');