fix(preset): use default enquirer import so interactive workspace creation works#898
Merged
Conversation
…ation works (#897) `import * as enquirer` compiles to a native ESM namespace import since the plugin migrated to ESM. enquirer is CommonJS with `prompt` assigned as a runtime static, which the module lexer can't surface as a named export, so `enquirer.prompt` was `undefined` and creating a workspace without `--no-interactive` crashed with "enquirer.prompt is not a function". Switch to a default import. Also guard the engagementId prompt on `process.stdin.isTTY`: `create-nx-workspace` runs the preset via `exec` (a data-less stdin pipe), so the prompt would otherwise hang once the crash was fixed. The prompt still runs when the preset is invoked directly via `nx generate` in a real terminal. Rename the `no-interactive` smoke test to `create-workspace` and add an interactive case that drives the preset generator through a PTY and answers the engagementId prompt, covering the previously untested interactive path.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #898 +/- ##
=======================================
Coverage 87.36% 87.36%
=======================================
Files 155 155
Lines 5388 5388
Branches 1263 1263
=======================================
Hits 4707 4707
Misses 359 359
Partials 322 322 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
The enquirer default-import is the fix for the interactive workspace creation crash; the process.stdin.isTTY guard is unnecessary.
cogwirrel
approved these changes
Jul 7, 2026
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.
Reason for this change
Creating a workspace interactively (without
--no-interactive) crashed:import * as enquirercompiles to a native ESM namespace import since the plugin migrated to ESM (#853). enquirer is a CommonJS package whosepromptis assigned as a runtime static, whichcjs-module-lexercan't surface as a named export — soenquirer.promptwasundefined. Under the old CommonJS output the sameimport * ascompiled torequire()and worked, so this regressed with the ESM migration.Description of changes
import enquirer from 'enquirer'), for whichenquirer.promptresolves correctly.process.stdin.isTTY.create-nx-workspaceruns the preset viaexec, which gives it a data-less stdin pipe (the parent TTY is never forwarded across anexecboundary). Once the crash is fixed, prompting there would hang forever. With the guard, the prompt is skipped when there's no terminal, and creation completes. The prompt still runs when the preset is invoked directly vianx generatein a real terminal (the samespawn/inherited-TTY path the agent-chat CLI uses).no-interactivesmoke test tocreate-workspaceand add an interactive case that drives the preset generator through a PTY (node-pty, mirroringlocal-dev.spec.ts'schatStreamsReply) and answers the engagementId prompt — covering the previously untested interactive path. CI/PR matrix entry renamed accordingly.Description of how you validated changes
import * as enquirer,enquirer.promptisundefined; with the default import it's a function.create-workspacesmoke test locally against the fixed build: the non-interactive npm/pnpm/yarn-4 cases pass, and the new interactive case drives the engagementId prompt end-to-end (typesMyEngagementId, submits, asserts it's written as a tag inaws-nx-plugin.config.mts). (bun and yarn-classic fail only due to local env — bun not installed, and a local verdaccio transitive-dep passthrough quirk.)pnpm nx run @aws/nx-plugin:buildpasses (lint + unit tests, 33 preset tests green).Issue # (if applicable)
Closes #897.
Checklist
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license