-
Notifications
You must be signed in to change notification settings - Fork 1
feat(templates): load templates from remote base44/apps-examples repo #51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: base-brach
Are you sure you want to change the base?
Conversation
- Add remote template fetching from GitHub base44/apps-examples repository - Cache templates locally in ~/.base44/templates/ with 24-hour TTL - Combine bundled and remote templates in listTemplates() - Support both bundled and remote templates in renderTemplate() - Add 'source' field to Template schema for tracking origin - Fallback to bundled templates when offline The CLI now dynamically fetches templates from the apps-examples repo, allowing templates to be updated without releasing a new CLI version. Fixes #38
Code Review: Remote Templates FeatureSummaryThis PR implements dynamic template loading from the Critical Issues 🔴1. Tarball Extraction Logic Issues (src/core/project/remote.ts:172-198)The
Recommendation: Fix the strip logic and path handling to properly extract the template subdirectory. 2. Race Condition in Template Download (src/core/project/remote.ts:119-166)Multiple concurrent calls to Recommendation: Implement an in-memory promise cache to prevent concurrent downloads of the same template. 3. Incomplete Error Handling (src/core/project/template.ts:45-50)When both bundled and remote templates fail to load, the error message is generic and doesn't expose the actual errors that occurred. Recommendation: Capture and include the actual error messages to help with debugging. High Priority Issues 🟡4. Missing Resource CleanupThe temporary tarball cleanup silently ignores errors (src/core/project/remote.ts:160-165), which could lead to disk space leaks over time. Recommendation: At minimum, log cleanup failures. Better yet, use OS temp directories with auto-cleanup. 5. No Request Timeout or Retry LogicBoth GitHub API calls lack timeouts and retry logic (src/core/project/remote.ts:71, 127). This could cause hangs on slow networks or transient failures. Recommendation: Add AbortController-based timeouts (10s) and implement basic retry logic for transient failures. 6. Cache Invalidation Issues
Recommendation: Add a 7. Type Safety ConcernsThe Recommendation: Make Security Concerns 🔒8. Lack of Content VerificationTemplates are fetched from GitHub without integrity checks:
Recommendation: Add size limits and validation before extraction. Consider checksums in templates.json. 9. Path Traversal RiskThe tarball extraction doesn't explicitly prevent path traversal attacks using Recommendation: Add explicit path validation in the extraction filter to reject paths containing 10. Hardcoded API EndpointsGitHub API endpoints are hardcoded, limiting enterprise users who may use GitHub Enterprise. Recommendation: Make the API base URL configurable via environment variables. Performance Considerations ⚡11. Full Tarball Download for Single TemplateThe code downloads the entire repository tarball even when only one template is needed. For repos with many large templates, this wastes bandwidth and time. Recommendation: Use GitHub's contents API to fetch individual directories, or document that apps-examples should be kept lightweight. 12. Synchronous Directory ChecksMultiple sequential Test Coverage ❌13. No Tests for New FunctionalityThe PR adds 216 lines of complex logic in
Recommendation: Add comprehensive unit and integration tests covering cache behavior, network failures, extraction logic, and error scenarios. Code Quality & Best Practices ✨Positive Aspects ✅
Minor Improvements 🔧
Recommendations SummaryBefore merging (Critical):
Before merging (High Priority): Post-merge enhancements:
ConclusionThis is a valuable feature that improves the CLI's flexibility. The architecture is sound, but the implementation needs hardening before production use. The critical issues around tarball extraction and race conditions must be addressed, and test coverage is essential for such complex logic. Overall Assessment: Needs Changes - Please address critical issues and add tests before merging. Great work on the feature! Looking forward to the improvements. 🚀 |
Description
Load templates dynamically from the
base44/apps-examplesGitHub repository at runtime instead of bundling them in the CLI, allowing templates to be updated without releasing a new CLI version.Related Issue
Fixes #38
Type of Change
Changes Made
remote.tsmodule for fetching templates from GitHubbase44/apps-examplesrepository~/.base44/templates/with 24-hour TTLlistTemplates()renderTemplate()sourcefield to Template schema for tracking originTesting
npm test)Checklist
Additional Notes
Architecture
The CLI now:
https://github.com/base44/apps-examplesRemote Repository Requirements
The
base44/apps-examplesrepo should have either:templates.jsonfile at the root listing templatesCache Location
Templates are cached in
~/.base44/templates/to avoid repeated downloads.