@stonyx/utils 0.2.3-beta.25 → 0.2.3-beta.26

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
@@ -245,6 +245,8 @@ Prompts the user with `(y/N)` and resolves to `true` only if the answer is `"y"`
245
245
  * `options.input` — Readable stream (default: `process.stdin`).
246
246
  * `options.output` — Writable stream (default: `process.stdout`).
247
247
 
248
+ **TTY required:** Rejects with an error if `process.stdin` is not a TTY and no custom `input` stream is provided. For headless/container deployments, use `autoMigrate` config or provide a custom input stream.
249
+
248
250
  #### `prompt(question, options={})`
249
251
 
250
252
  Prompts the user with a question and resolves to the trimmed input string.
@@ -252,6 +254,8 @@ Prompts the user with a question and resolves to the trimmed input string.
252
254
  * `options.input` — Readable stream (default: `process.stdin`).
253
255
  * `options.output` — Writable stream (default: `process.stdout`).
254
256
 
257
+ **TTY required:** Rejects with an error if `process.stdin` is not a TTY and no custom `input` stream is provided.
258
+
255
259
  ```js
256
260
  import { confirm, prompt } from '@stonyx/utils/prompt';
257
261
 
package/dist/prompt.js CHANGED
@@ -1,5 +1,9 @@
1
1
  import { createInterface } from 'readline';
2
2
  export function confirm(question, { input, output } = {}) {
3
+ if (!input && !process.stdin.isTTY) {
4
+ return Promise.reject(new Error('Interactive confirm() requires a TTY on stdin. ' +
5
+ 'For headless/container deployments, use the autoMigrate config option instead.'));
6
+ }
3
7
  const rl = createInterface({
4
8
  input: input ?? process.stdin,
5
9
  output: output ?? process.stdout,
@@ -12,6 +16,10 @@ export function confirm(question, { input, output } = {}) {
12
16
  });
13
17
  }
14
18
  export function prompt(question, { input, output } = {}) {
19
+ if (!input && !process.stdin.isTTY) {
20
+ return Promise.reject(new Error('Interactive prompt() requires a TTY on stdin. ' +
21
+ 'For headless/container deployments, configure non-interactive alternatives instead.'));
22
+ }
15
23
  const rl = createInterface({
16
24
  input: input ?? process.stdin,
17
25
  output: output ?? process.stdout,
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "keywords": [
4
4
  "stonyx-module"
5
5
  ],
6
- "version": "0.2.3-beta.25",
6
+ "version": "0.2.3-beta.26",
7
7
  "description": "Utils module for Stonyx Framework",
8
8
  "repository": {
9
9
  "type": "git",