inquirerer 4.5.1 → 4.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -146,8 +146,10 @@ interface BaseQuestion {
146
146
  default?: any; // Default value
147
147
  defaultFrom?: string; // Dynamic default from resolver (e.g., 'git.user.name')
148
148
  setFrom?: string; // Auto-set value from resolver, bypassing prompt entirely
149
+ optionsFrom?: string; // Dynamic options from another answer's value
149
150
  useDefault?: boolean; // Skip prompt and use default
150
151
  required?: boolean; // Validation requirement
152
+ skipPrompt?: boolean; // Skip prompting entirely (field still in man pages / CLI flags)
151
153
  validate?: (input: any, answers: any) => boolean | Validation;
152
154
  sanitize?: (input: any, answers: any) => any;
153
155
  pattern?: string; // Regex pattern for validation
@@ -156,6 +158,40 @@ interface BaseQuestion {
156
158
  }
157
159
  ```
158
160
 
161
+ #### Skipping Prompts
162
+
163
+ Use `skipPrompt: true` to skip interactive prompting for a question entirely. The field is omitted from the answers object unless the user explicitly passes it via a CLI flag. This is useful for fields with backend-managed defaults where the CLI should not prompt, but should still allow overrides.
164
+
165
+ ```typescript
166
+ const questions: Question[] = [
167
+ {
168
+ type: 'text',
169
+ name: 'username',
170
+ message: 'Username',
171
+ required: true
172
+ },
173
+ {
174
+ type: 'text',
175
+ name: 'status',
176
+ message: 'Account status',
177
+ skipPrompt: true // Won't prompt, but user can pass --status active
178
+ }
179
+ ];
180
+
181
+ const result = await prompter.prompt({}, questions);
182
+ // { username: 'john' } — status is not included
183
+
184
+ const result2 = await prompter.prompt({ status: 'active' }, questions);
185
+ // { username: 'john', status: 'active' } — CLI flag override works
186
+ ```
187
+
188
+ Key behaviors:
189
+ - The question still appears in generated man pages
190
+ - CLI flag overrides (e.g. `--status active`) still work
191
+ - The field is simply left out of the answers if not provided
192
+ - Different from `when`: `skipPrompt` is unconditional, while `when` depends on other answers
193
+ - Different from `useDefault`: `skipPrompt` does not apply a default value
194
+
159
195
  ### Non-Interactive Mode
160
196
 
161
197
  When running in CI/CD or without a TTY, inquirerer automatically falls back to default values:
package/esm/keypress.js CHANGED
@@ -121,6 +121,9 @@ export class TerminalKeypress {
121
121
  pause() {
122
122
  this.active = false;
123
123
  this.clearHandlers();
124
+ if (typeof this.input.setRawMode === 'function') {
125
+ this.input.setRawMode(false);
126
+ }
124
127
  }
125
128
  resume() {
126
129
  this.active = true;
package/esm/prompt.js CHANGED
@@ -360,6 +360,14 @@ export class Inquirerer {
360
360
  ctx.nextQuestion();
361
361
  continue;
362
362
  }
363
+ // Skip prompt entirely if skipPrompt is set.
364
+ // The question still appears in man pages and CLI flag overrides still work
365
+ // (handled by the `question.name in obj` check above), but no interactive
366
+ // prompt is shown. The field is simply left out of the answers object.
367
+ if (question.skipPrompt) {
368
+ ctx.nextQuestion();
369
+ continue;
370
+ }
363
371
  // Apply default value if applicable
364
372
  // this is if useDefault is set, rare! not typical defaults which happen AFTER
365
373
  // this is mostly to avoid a prompt for "hidden" options
@@ -1133,7 +1141,11 @@ export class Inquirerer {
1133
1141
  close() {
1134
1142
  if (this.rl) {
1135
1143
  this.rl.close();
1144
+ this.rl = null;
1145
+ }
1146
+ if (this.keypress) {
1136
1147
  this.keypress.destroy();
1148
+ this.keypress = null;
1137
1149
  }
1138
1150
  }
1139
1151
  }
package/keypress.js CHANGED
@@ -124,6 +124,9 @@ class TerminalKeypress {
124
124
  pause() {
125
125
  this.active = false;
126
126
  this.clearHandlers();
127
+ if (typeof this.input.setRawMode === 'function') {
128
+ this.input.setRawMode(false);
129
+ }
127
130
  }
128
131
  resume() {
129
132
  this.active = true;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "inquirerer",
3
- "version": "4.5.1",
3
+ "version": "4.6.0",
4
4
  "author": "Constructive <developers@constructive.io>",
5
5
  "description": "TypeScript-first library for building beautiful CLI interfaces with interactive prompts",
6
6
  "main": "index.js",
@@ -46,5 +46,5 @@
46
46
  "makage": "0.1.10",
47
47
  "string-width": "4.2.3"
48
48
  },
49
- "gitHead": "1d2795da97e2217a7df24b2942a0b4e5879ac16f"
49
+ "gitHead": "52e4d3ecdb5d323b70c2bb0269ff3ccd41cc85b9"
50
50
  }
package/prompt.js CHANGED
@@ -367,6 +367,14 @@ class Inquirerer {
367
367
  ctx.nextQuestion();
368
368
  continue;
369
369
  }
370
+ // Skip prompt entirely if skipPrompt is set.
371
+ // The question still appears in man pages and CLI flag overrides still work
372
+ // (handled by the `question.name in obj` check above), but no interactive
373
+ // prompt is shown. The field is simply left out of the answers object.
374
+ if (question.skipPrompt) {
375
+ ctx.nextQuestion();
376
+ continue;
377
+ }
370
378
  // Apply default value if applicable
371
379
  // this is if useDefault is set, rare! not typical defaults which happen AFTER
372
380
  // this is mostly to avoid a prompt for "hidden" options
@@ -1140,7 +1148,11 @@ class Inquirerer {
1140
1148
  close() {
1141
1149
  if (this.rl) {
1142
1150
  this.rl.close();
1151
+ this.rl = null;
1152
+ }
1153
+ if (this.keypress) {
1143
1154
  this.keypress.destroy();
1155
+ this.keypress = null;
1144
1156
  }
1145
1157
  }
1146
1158
  }
@@ -30,6 +30,7 @@ export interface BaseQuestion {
30
30
  pattern?: string;
31
31
  dependsOn?: string[];
32
32
  when?: (answers: any) => boolean;
33
+ skipPrompt?: boolean;
33
34
  }
34
35
  export interface ConfirmQuestion extends BaseQuestion {
35
36
  type: 'confirm';