feat(create-gen-app): decouple architecture and implement caching with TTL #15
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR refactors the create-gen-app package by decoupling its core components and introducing a robust caching mechanism with TTL (Time-To-Live) support. It also updates the create-gen-app-test CLI to orchestrate these components more cleanly, adding new features such as version checks and manual cache clearing.
🏗️ Architecture Improvements
Decoupled Components
The previously monolithic logic has been split into standalone, reusable classes:
CacheManager
Handles template caching, retrieval, and TTL-based expiration using appstash.
GitCloner
Encapsulates all git-related operations cleanly.
Templatizer
Pure local template processor responsible for extract → prompt → replace steps.
Orchestration Layer
GitCloner,CacheManager,Templatizer) together.✨ New Features
Caching + TTL Support
Manual Cache Clearing
--clear-cacheAllows users to manually wipe cached templates.
Automatic Version Check
create-gen-appversion and notifies the user if an update is available.🧪 Testing
Integration Tests Enabled
cached-template.test.ts.Test Stability Improvements
noTty: trueto avoid hanging prompts during tests.EMAIL).✔️ Verification Steps
1. Run Tests
pnpm test packages/create-gen-app-test 2. Verify CLI Behavior First run — should clone: node packages/create-gen-app-test/dist/cli.js \ --repo launchql/pgpm-boilerplates \ --template module \ --output /tmp/cga-test Second run — should use cache: node packages/create-gen-app-test/dist/cli.js \ --repo launchql/pgpm-boilerplates \ --template module \ --output /tmp/cga-test-2 Clear cache: node packages/create-gen-app-test/dist/cli.js --clear-cache