feat(codegen): add CLI entry point generation option (cli.entryPoint)#739
Merged
pyramation merged 2 commits intomainfrom Feb 24, 2026
Merged
feat(codegen): add CLI entry point generation option (cli.entryPoint)#739pyramation merged 2 commits intomainfrom
pyramation merged 2 commits intomainfrom
Conversation
- Add cli-entry.ts template with CLI bootstrap code (inquirerer, --version, --tty) - Add generateEntryPointFile() to utils-generator.ts (template-copy pattern) - Add entryPoint option to CliConfig interface (default: false) - Wire up in generateCli() and generateMultiTargetCli() - Pass entryPoint through generateMulti() for unified CLI - When enabled, generates index.ts in cli/ output directory This removes the last remaining hack from the constructive-hub CLI e2e test script (manual index.ts generation at test time).
Contributor
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
…0.0.1' Uses getPackageJson(__dirname) from inquirerer to read the actual package.json version at runtime, matching the pattern used by cnc and pgpm CLIs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
feat(codegen): add CLI entry point generation option (
cli.entryPoint)Summary
Adds a new opt-in
entryPointboolean toCliConfig(defaultfalse). When enabled, codegen generates anindex.tsentry point file that bootstraps the CLI usinginquirerer, handling--version,--tty false, and error reporting.This follows the existing template-copy pattern used by
cli-utils.tsandnode-fetch.ts— the template lives insrc/core/codegen/templates/cli-entry.tsand is read/header-replaced at codegen time.Wired into both
generateCli()(single-target) andgenerateMultiTargetCli()(multi-target) code paths, and passed throughgenerateMulti()ingenerate.ts.Motivation: Eliminates the runtime entry point generation hack in the constructive-hub CLI e2e test script (lines 44–69 of
test-cli-e2e.sh), which manually creates this file at test time.Updates since last revision
'0.0.1'version withgetPackageJson(__dirname)frominquirerer, matching the exact pattern used bycncandpgpmCLIs. The generated entry point now reads the actual version from the nearestpackage.jsonat runtime.Review & Testing Checklist for Human
getPackageJson(__dirname)runtime behavior — the generatedindex.tscallsgetPackageJson(__dirname)to resolve the version for--version. Verify that when the generated CLI is compiled/bundled (e.g. viatsxortsc),__dirnameresolves to a path where apackage.jsonis discoverable. If the CLI is run directly from source (e.g.npx tsx cli/index.ts), the nearestpackage.jsonmight be the workspace root rather than the CLI-specific one.entryPoint: true. Consider adding a snapshot test that verifies the generatedindex.tscontent.index.tsfilename collision — verify no other codegen output produces anindex.tsin the CLI output directory, sincegenerateEntryPointFile()writes toindex.ts.generateCli(), the check istypeof cliConfig === 'object' && !!cliConfig.entryPoint. Confirm this is correct for all call sites (whencliConfigistruevs an object).Suggested test plan
entryPoint: trueto a codegen config YAML and run generationindex.tscontains the expected imports (getPackageJson) and CLI bootstrapentryPoint: false(or omitted) produces noindex.ts--versionand confirm it prints the version from the nearestpackage.jsonNotes
pnpm build), all 301 tests pass (pnpm test), no snapshot changes