UNPKG

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
# 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