native-update
Version:
Foundation package for building a comprehensive update system for Capacitor apps. Provides architecture and interfaces but requires backend implementation.
385 lines (301 loc) ⢠10.7 kB
Markdown
# Example Apps Simplification Plan
**Created:** 2025-12-27
**Status:** Planning Phase
**Goal:** Simplify all example apps to minimal, focused demonstrations of the native-update plugin
---
## šÆ Objectives
### Primary Goal
Create **ultra-simple** example apps that demonstrate ONLY the native-update plugin functionality with zero unnecessary complexity.
### Key Principles
1. **One clear purpose per app** - Show the plugin working, nothing else
2. **Minimal dependencies** - Only what's absolutely required
3. **Simple code structure** - Easy to understand and modify
4. **Clear demonstrations** - "Change this text and deploy" approach
5. **No side features** - No routing, state management libraries, complex UI components
---
## š± App 1: react-capacitor (Frontend Example)
### Current State Analysis
**Location:** `example-apps/react-capacitor/`
**Current Issues:**
- May have complex component structure
- Possibly using advanced React features unnecessarily
- Multiple pages/routes when we only need one
- Advanced state management when simple useState would work
- Complex UI when we just need a demo
### Target State
**Single Page Application:**
```
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
ā Native Update Demo ā
ā ā
ā Current Version: 1.0.0 ā
ā āāāāāāāāāāāāāāāāāāāāāāāāāāāāāā ā
ā ā Change This Text and ā ā
ā ā Deploy to Test OTA Updates ā ā
ā ā ā ā
ā ā [This text will update ā ā
ā ā when you deploy a new ā ā
ā ā version via OTA] ā ā
ā āāāāāāāāāāāāāāāāāāāāāāāāāāāāāā ā
ā ā
ā [Check for Updates] ā
ā [Download Update] ā
ā [Apply Update] ā
ā ā
ā Status: Connected to server ā
ā Last Check: 2 minutes ago ā
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
```
**File Structure:**
```
react-capacitor/
āāā src/
ā āāā App.tsx # Single component, all demo logic
ā āāā main.tsx # Entry point
ā āāā native-update.ts # Plugin integration wrapper
āāā public/
ā āāā index.html
āāā capacitor.config.ts
āāā package.json # Minimal dependencies
āāā tsconfig.json
āāā vite.config.ts
āāā README.md # Clear setup instructions
```
**Dependencies (Minimal):**
- @capacitor/core, @capacitor/android, @capacitor/ios
- native-update (workspace:*)
- react, react-dom
- vite, @vitejs/plugin-react
- typescript
**NO:**
- ā React Router
- ā Redux/Zustand/Context (use simple useState)
- ā UI component libraries
- ā Multiple pages
- ā Complex styling (simple CSS only)
- ā Advanced features
**Implementation Steps:**
1. **Analyze current structure** (10 min)
- Review current files and complexity
- Identify what to keep vs remove
2. **Simplify App.tsx** (30 min)
- Single component with all logic
- Basic useState for status tracking
- Clear button handlers for update operations
- Simple inline styles or minimal CSS
3. **Remove unnecessary files** (15 min)
- Remove extra components
- Remove routing if present
- Remove complex state management
- Keep only App.tsx and main.tsx
4. **Update package.json** (10 min)
- Remove all non-essential dependencies
- Keep only core Capacitor, React, Vite, TypeScript
- Verify workspace:* reference to native-update
5. **Create simple README** (15 min)
- Quick setup (3 steps)
- How to test OTA updates
- Backend server requirement
6. **Test the app** (20 min)
- Verify build works
- Test in browser
- Test basic plugin calls
**Total Time Estimate:** ~1.5 hours
---
## š„ App 2: firebase-backend (Backend Example)
### Current State Analysis
**Location:** `example-apps/firebase-backend/`
**Current Issues:**
- May have complex routing structure
- Multiple features beyond OTA updates
- Advanced authentication when simple API keys would work
- Complex database queries
- Unnecessary middleware
### Target State
**Minimal API Endpoints:**
```
POST /bundles/upload # Upload new bundle
GET /bundles/latest # Get latest bundle info
GET /bundles/:version # Download specific bundle
GET /health # Health check
```
**File Structure:**
```
firebase-backend/
āāā src/
ā āāā index.ts # Main Cloud Function entry
ā āāā utils/
ā āāā validation.ts # Basic version validation only
āāā firebase.json
āāā .firebaserc
āāā package.json # Minimal dependencies
āāā tsconfig.json
āāā README.md # Setup and deployment guide
```
**Dependencies (Minimal):**
- firebase-admin
- firebase-functions
- express (for routing)
- cors (for CORS handling)
- multer (for file uploads)
**NO:**
- ā Complex authentication (use simple API key check)
- ā Advanced analytics
- ā Multiple routes files
- ā Complex validation beyond version checking
- ā Unnecessary middleware
**Implementation Steps:**
1. **Analyze current structure** (10 min)
- Review routes and middleware
- Identify essential vs non-essential
2. **Consolidate to index.ts** (45 min)
- Move all routes into single file
- Simplify authentication (API key check only)
- Keep only bundle upload/download endpoints
- Basic CORS and error handling
3. **Remove unnecessary files** (15 min)
- Remove separate route files
- Remove complex middleware
- Remove advanced features
4. **Simplify validation** (15 min)
- Keep only version number validation
- Basic file type checking
- Remove complex business logic
5. **Update package.json** (10 min)
- Remove unnecessary dependencies
- Keep only core Firebase, Express, CORS, Multer
6. **Update README** (20 min)
- Firebase setup (project creation)
- Deployment steps
- API usage examples
7. **Test deployment** (25 min)
- Deploy to Firebase
- Test endpoints
- Verify bundle upload/download
**Total Time Estimate:** ~2 hours
---
## š App 3: node-express (Backend Example)
### Current State Analysis
**Location:** `example-apps/node-express/`
**Current Issues:**
- Production-ready features (too complex for example)
- Database setup scripts
- Complex authentication
- Rate limiting and security features (good but too much)
- Multiple database options
### Target State
**Minimal API Server:**
```
POST /bundles/upload # Upload new bundle
GET /bundles/latest # Get latest bundle info
GET /bundles/:version # Download specific bundle
GET /health # Health check
```
**File Structure:**
```
node-express/
āāā src/
ā āāā index.js # Main server file (all routes)
ā āāā bundles/ # Folder to store uploaded bundles
āāā package.json # Minimal dependencies
āāā .env.example
āāā README.md # Quick setup guide
```
**Dependencies (Minimal):**
- express
- cors
- multer (file uploads)
- dotenv (environment variables)
**NO:**
- ā SQLite/database (use file system storage)
- ā JWT authentication (simple API key)
- ā Rate limiting (remove for simplicity)
- ā Helmet, compression (production features)
- ā Complex logging (console.log is fine)
- ā Database migration scripts
**Implementation Steps:**
1. **Analyze current structure** (10 min)
- Review complexity level
- Identify production features to remove
2. **Simplify index.js** (60 min)
- Single file with all routes
- Remove database (use file system)
- Simple API key check (if needed)
- Basic CORS
- Store bundles as files in /bundles folder
3. **Remove unnecessary files** (20 min)
- Remove database setup scripts
- Remove separate route files
- Remove middleware files
- Remove complex logging
4. **Update package.json** (10 min)
- Remove all production dependencies
- Keep only: express, cors, multer, dotenv
5. **Create simple storage** (15 min)
- File system based bundle storage
- JSON file for bundle metadata
- Simple version tracking
6. **Update README** (20 min)
- Quick start (3 commands)
- API examples
- Testing instructions
7. **Test the server** (20 min)
- Start server
- Test all endpoints
- Verify file uploads
**Total Time Estimate:** ~2.5 hours
---
## š Success Criteria
### For Each Example App
ā
**Simplicity**
- Single file for main logic (or max 2-3 files)
- No unnecessary abstractions
- Easy to read and understand in 5 minutes
ā
**Functionality**
- Demonstrates plugin working correctly
- Clear "change and deploy" workflow
- All basic operations functional
ā
**Documentation**
- README with quick start (< 5 steps)
- Clear API examples
- Troubleshooting section
ā
**Dependencies**
- Minimal package.json
- Only essential dependencies
- No bloat
ā
**Testing**
- Build succeeds
- Basic functionality verified
- Integration with plugin confirmed
---
## š Execution Order
1. **react-capacitor** (Frontend) - 1.5 hours
- Most visible to users
- Sets the tone for simplicity
2. **node-express** (Backend) - 2.5 hours
- Simpler than Firebase
- Good for quick local testing
3. **firebase-backend** (Backend) - 2 hours
- More complex due to Firebase setup
- Alternative for users preferring serverless
**Total Estimated Time:** 6 hours
---
## š Risk Assessment
### Potential Issues
1. **Breaking existing functionality**
- **Mitigation:** Test each simplification step
- **Rollback plan:** Git commits for each major change
2. **Over-simplification**
- **Mitigation:** Ensure core plugin features still demonstrated
- **Balance:** Simple but functional
3. **Documentation gaps**
- **Mitigation:** Create README before simplifying code
- **Verification:** Test setup from README
---
## š Notes
- Keep this plan updated as we discover complexity during execution
- Track actual time vs estimated time
- Document any deviations from plan
- User requested "as simple as possible, no side bullshit" - this is our north star
---
**Next Step:** Create tracking document and begin execution with react-capacitor