@forge/cli-shared

9.10.0-next.89.10.0-next.9
out/ui/command-line-ui.js
~out/ui/command-line-ui.jsModified
+11−1
Index: package/out/ui/command-line-ui.js
===================================================================
--- package/out/ui/command-line-ui.js
+++ package/out/ui/command-line-ui.js
@@ -31,8 +31,9 @@
 const ELLIPSIS_INTERVAL_MS = 400;
 class CommandLineUI {
     verbose;
     customEffectsEnabled;
+    nonInteractive;
     logger;
     spinner;
     promptInternal;
     insideProgress = false;
@@ -48,11 +49,12 @@
     static NON_TTY_ENV_DEFAULT_COLUMNS = 100;
     static STDIN_CHUNK_BYTES = 256;
     static STDIN_RETRY_MS = 10;
     static STDIN_READ_TIMEOUT_MS = 30_000;
-    constructor(verbose, statsigService, spinner, logger, customEffectsEnabled) {
+    constructor(verbose, statsigService, spinner, logger, customEffectsEnabled, nonInteractive) {
         this.verbose = verbose;
         this.customEffectsEnabled = customEffectsEnabled;
+        this.nonInteractive = nonInteractive;
         this.spinner = spinner || (0, ora_1.default)({ discardStdin: false });
         this.logger = logger || console;
         this.promptInternal = this.createPromptModule();
         this.statsigService = statsigService || null;
@@ -87,15 +89,23 @@
     getSpinner() {
         return this.cachedSpinnerConfig;
     }
     async prompt(questions, initialAnswers) {
+        if (this.nonInteractive?.()) {
+            throw new shared_1.MissingInputError(text_1.Text.nonInteractive.error.promptReached(CommandLineUI.questionMessage(questions)));
+        }
         try {
             return await this.promptInternal(questions, initialAnswers);
         }
         catch (e) {
             throw new shared_1.UIPromptError(e.message, e.isTtyError ?? false);
         }
     }
+    static questionMessage(questions) {
+        const first = Array.isArray(questions) ? questions[0] : questions;
+        const message = first?.message;
+        return typeof message === 'string' ? message : undefined;
+    }
     get traceEnabled() {
         return this.verbose();
     }
     get debugEnabled() {