Skip to content

Conversation

@sdqede
Copy link

@sdqede sdqede commented Nov 21, 2025

cga-1

Summary

  • add a production-ready CLI (bin entries for create-gen-app and cga) with sensible defaults (launchql/pgpm-boilerplates + dot), repo/branch/path/template/output/force/no-tty/--version flags, and argv overrides so users can npm install -g create-gen-app and scaffold directly
  • replace all mocked flow/CLI tests with real integration suites that clone launchql/pgpm-boilerplates from GitHub, gather answers, rewrite files, and assert on the actual filesystem output (package.json, README, LICENSE removal, etc.)
  • auto-generate or overwrite LICENSE files based on the user’s choice using built-in templates for MIT, Apache-2.0, ISC, GPL-3.0, BSD-3-Clause, MPL-2.0, and Unlicense, injecting year/author/email
  • upgrade extraction/prompt handling: four-underscore placeholders, .questions overrides, ignore support (paths + content), question-name normalization, raw-mode cleanup, CLI dev script, README docs
  • add guardrails: friendly warning when .questions references a license not supported by the embedded templates, ensure .questions.* files are removed post-generation, strengthen README usage docs

Testing

  • yarn workspace create-gen-app test (runs the true integration suites; requires git + network access)

Manual CLI smoke test

🛠️ Local CLI Testing Workflow

  1. 🏗️ Build the workspace package

    cd /Users/easonsmith/Desktop/hw/templating-playground/inquirerer
    yarn workspace create-gen-app build
  2. 🔧 Make executable

    chmod +x packages/create-gen-app/dist/cli.js
  3. 🔗 Link globally

    cd packages/create-gen-app/dist
    npm link
  4. 🧪 Test the CLI

    # Check version & help
    cga -v
    cga --help
    
    # Run a generation task
    cga \
      --repo https://github.com/launchql/pgpm-boilerplates.git \
      --branch license \
      --output /tmp/create-gen-module
  5. 🧹 Cleanup

    npm unlink create-gen-app

pyramation and others added 11 commits November 17, 2025 02:02
…mpts

Fix two critical input handling bugs that prevented proper user interaction:

1. Duplicate character input: Characters were being registered twice due to
   multiple Inquirerer instances not being properly closed, causing event
   listeners to accumulate.

2. No input response: TerminalKeypress was setting raw mode in constructor,
   which blocked readline from receiving input for text/number/confirm questions.

Changes:
- Add prompter.close() in promptUser() to properly cleanup Inquirerer instances
- Add inquirerer.close() in dev script after template selection prompt
- Refactor TerminalKeypress to only enable raw mode when needed (resume())
- Ensure raw mode is disabled (cooked mode restored) in destroy() for readline compatibility

This ensures:
- text/number/confirm questions use readline with cooked mode (normal input)
- checkbox/list/autocomplete questions use raw mode for custom key handling
- Each prompt properly cleans up before the next one starts
- No event listener leaks or stdin conflicts between prompts

Fixes input duplication and unresponsive keyboard issues in create-gen-app dev workflow.
- guard `promptUser` teardown so mocked `Inquirerer` instances without `close()` don’t crash tests while real prompts still release their resources
- exclude `<rootDir>/test-output/` from Jest runs so generated template fixtures (e.g. ones importing `pgsql-test`) no longer break the suite

This keeps interactive prompts stable and restores `yarn workspace create-gen-app test`.
- support fromBranch/fromPath in createGen and cloneRepo
- enhance dev script with CLI flags
- update tests and docs, add minimist dependency
- allow .questions ignore entries to filter both paths and file contents
- introduce default ignored tokens (__tests__, __snapshots__)
- normalize question names and update unit tests accordingly
- treat variables as ____VAR____ throughout extraction, prompts, and README
- add automatic normalization for question names using ____VAR____ or legacy __VAR__
- extend ignore logic to cover content tokens by default
- update unit tests for new placeholder format
Update test fixtures to use ____VAR____ format instead of __
…scovery

- Add bin entries for `create-gen-app` and `cga` commands in package.json
- Implement CLI script with default repo (launchql/pgpm-boilerplates) and path (.)
- Support --repo, --branch, --path, --template, --output, --force, --no-tty flags
- Add --version/-v flag to display package version
- Auto-discover templates when multiple exist, auto-select when only one
- Forward extra CLI args as variable overrides (e.g., --PACKAGE_NAME=value)
- Add comprehensive CLI tests covering all flag combinations and edge cases
- Update README with CLI usage examples and command reference

This enables users to run `npm install -g create-gen-app` and use `cga` or
`create-gen-app` commands directly, with sensible defaults for the LaunchQL
template repository.
- Replace mocked `createGen` and CLI tests with true integration coverage
- Tests now clone `launchql/pgpm-boilerplates` from GitHub and validate actual filesystem output
- Introduce `test-utils/integration-helpers.ts` to centralize test constants, temporary workspace management, and deterministic answer maps
- Update `create-gen-flow.test.ts` and `cli.test.ts` to utilize these integration helpers and perform end-to-end validation
- Remove reliance on `jest.mock` for `cloneRepo` and `Inquirerer` in these suites

This ensures tests validate the full pipeline (clone → extract → prompt → replace) against real GitHub repositories, meeting Dan's requirement for tests that "do this for us" with the default template repository.
- Add built-in license templates (MIT, Apache-2.0, ISC) in `src/licenses.ts`
- Automatically generate or overwrite LICENSE file based on user's selection
- Replace placeholders (year, author name, email) with user-provided values
- Show friendly warning when template doesn't support selected license type
- Update `replaceVariables` to call `ensureLicenseFile()` after file replacement
- Add unit tests for license template rendering
- Update integration tests to validate LICENSE file generation in real GitHub flows
- Document license generation feature in README

This ensures generated projects always have proper LICENSE files matching the
user's selection, whether the template originally included one or not.
- Introduce new license templates for GPL-3.0, BSD-3-Clause, Unlicense, and MPL-2.0 in `src/licenses.ts`
- Expand the functionality of the license generation feature to support a wider range of open-source licenses

This enhancement allows users to select from more licensing options when generating projects, ensuring compliance with various open-source requirements.
@sdqede sdqede requested review from Jovonni and pyramation November 21, 2025 03:34
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.

3 participants