Repository navigation
Conversation
The CLI only skipped its prompts on CI. When a script or an AI coding agent ran it without a terminal and without `CI` set, the first prompt waited forever for an answer that could never come. The CLI is now non-interactive on CI or when stdin is not a terminal. `stdin.hasTerminal` alone is not enough: it is also true for other character devices such as `/dev/null`, the stdin many tools run commands with, so stdin's echo mode is read as well. When non-interactive, each prompt either uses the value given by the flags, or exits with an error naming the flag to pass (`--platforms`, `--plugins`, `--out`, `--overwrite-firebase-options`, ...). The prompt helpers throw a `NonInteractiveException` as a safety net for any call site that does not. Behavior in a terminal and on CI is unchanged, apart from prompts that used to hang on CI now failing with an error.
72cc57e to
69cfc6e
Compare
|
Tested this branch on Windows, since the description mentions Windows wasn't run locally. Environment: Windows 11 (build 26300), Dart 3.13.7 (Flutter 3.47.9), Windows PowerShell 5.1. Tests: Real stdin on Windows, to check the
So The real CLI, in a Flutter app with no platform folders and without the Firebase CLI on It stops right away with "The FlutterFire CLI currently requires the official Firebase CLI to also be installed". With the published 1.5.0, the same situation (run from a script, Firebase CLI not on Two small things in that output, in case they're worth it (not blocking):
|
Description
The CLI only skipped its prompts on CI. Run by a script or an AI coding agent without a terminal (and without
CIset), the first prompt waited forever:flutterfire configureandflutterfire install latestwith stdin from/dev/nullboth hung until killed.The CLI is now non-interactive on CI or when stdin is not a terminal (
isNonInteractiveincommon/utils.dart).stdin.hasTerminalalone is not enough: it is also true for other character devices such as/dev/null, which many tools use as stdin, so stdin's echo mode is read as well (it throws unless stdin is a real terminal).When non-interactive, each prompt either uses the value given by the flags or exits 1 with an error naming the flag to pass, for example:
isCIcheck guarding a prompt now usesisNonInteractive, and the messages name the flag (--platforms,--out,--android-out,--ios-build-config/--ios-target,--overwrite-firebase-options, ...).firebase.json?" question, an invalid--out, the Apple service file path, and overwriting an existingfirebase_options.dart.NonInteractiveExceptioninstead of callinginteractas a safety net for any other call site.--versionskips the update check without a terminal, as it already did on CI.Behavior in a terminal is unchanged (checked with a pty). On CI it is unchanged too, except that prompts that used to hang there now fail with an error. Piping answers in (
yes | flutterfire ...) never worked withinteractand now fails fast instead of hanging.Testing
test/non_interactive_test.dart(21 tests): fake stdin throughIOOverrides(pipe,/dev/null, terminal), plus the real CLI as a subprocess with stdin piped and from/dev/null. With the fix reverted, 15 of them fail.dart analyze --fatal-infosclean, all offline tests pass (89).FIREBASE_TOKEN, and Windows.Type of Change
feat-- New feature (non-breaking change which adds functionality)fix-- Bug fix (non-breaking change which fixes an issue)!-- Breaking change (fix or feature that would cause existing functionality to change)refactor-- Code refactorci-- Build configuration changedocs-- Documentationchore-- Chore