Skip to content

Conversation

@sdqede
Copy link
Contributor

@sdqede sdqede commented Nov 26, 2025

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

  • The create-gen-app-test CLI now functions as the top-most orchestration layer, wiring all components (GitCloner, CacheManager, Templatizer) together.

✨ New Features

Caching + TTL Support

  • Templates are now cached locally.
  • Default TTL: 1 week.
  • When TTL expires, the CLI warns the user and automatically re-fetches templates.

Manual Cache Clearing

  • New flag: --clear-cache
    Allows users to manually wipe cached templates.

Automatic Version Check

  • On startup, the CLI checks npm for the latest create-gen-app version and notifies the user if an update is available.

🧪 Testing

Integration Tests Enabled

  • Re-enabled and fixed tests in cached-template.test.ts.

Test Stability Improvements

  • Forced noTty: true to avoid hanging prompts during tests.
  • Updated test helpers to include required template variables (e.g., EMAIL).
  • Updated snapshots to align with the latest template output.

✔️ 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

…s into dedicated subdirectories and classes.
…DME to detail modular API components and remove `ignore` pattern references.
…mically

- add TTL opt-out flow to create-gen-app-test (new --ttl/--no-ttl flags) and avoid forcing 1-week default
- read package name from package.json (fallback @launchql/cli) for version checks instead of hard-coding create-gen-app
- expose CacheManager appstash dirs via getters and allow caller-provided dirs to own appstash lifecycle
- update callers/tests to use getReposDir() and refresh README to document optional TTL and dirs injection
@sdqede sdqede requested a review from pyramation November 26, 2025 10:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants