-
-
Notifications
You must be signed in to change notification settings - Fork 5.1k
fix: ensure --yes flag assigns defaults for all config fields #1907
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -735,12 +735,13 @@ class ConfigCollector { | |
| // Skip prompts mode: use all defaults without asking | ||
| if (this.skipPrompts) { | ||
| await prompts.log.info(`Using default configuration for ${moduleDisplayName}`); | ||
| // Use defaults for all questions | ||
| // Use defaults for all questions; use empty string for fields without defaults | ||
| for (const question of questions) { | ||
| const hasDefault = question.default !== undefined && question.default !== null && question.default !== ''; | ||
| if (hasDefault && typeof question.default !== 'function') { | ||
| allAnswers[question.name] = question.default; | ||
| if (typeof question.default === 'function') { | ||
| continue; | ||
| } | ||
| const hasDefault = question.default !== undefined && question.default !== null && question.default !== ''; | ||
| allAnswers[question.name] = hasDefault ? question.default : ''; | ||
|
Comment on lines
+743
to
+744
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't serialize This bypasses the prompt's validation rules and produces the wrong shape for non-input questions like 🤖 Prompt for AI Agents
Lines 596-618 and 958-980 resolve placeholders with truthiness checks. A blank written here will be ignored by that code, so dependent 🤖 Prompt for AI Agents |
||
| } | ||
| } else { | ||
| if (!this._silentConfig) await prompts.log.step(`Configuring ${moduleDisplayName}`); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Evaluate computed defaults here instead of dropping them.
Line 1151 already turns same-module defaults into
question.default(answers).continuehere skips those fields entirely, so--yescan still leave computed defaults unset.Suggested fix
for (const question of questions) { - if (typeof question.default === 'function') { - continue; - } - const hasDefault = question.default !== undefined && question.default !== null && question.default !== ''; - allAnswers[question.name] = hasDefault ? question.default : ''; + const resolvedDefault = + typeof question.default === 'function' + ? question.default(allAnswers) + : question.default; + const hasDefault = + resolvedDefault !== undefined && + resolvedDefault !== null && + resolvedDefault !== ''; + allAnswers[question.name] = hasDefault ? resolvedDefault : ''; }🤖 Prompt for AI Agents