diff --git a/bin/main.dart b/bin/main.dart index 11232fe1..d6e8d07b 100755 --- a/bin/main.dart +++ b/bin/main.dart @@ -7,16 +7,7 @@ import 'package:fvm/src/utils/context.dart'; import 'package:scope/scope.dart'; Future main(List args) async { - final editableArgs = List.from(args); - final skipInput = editableArgs.remove('--fvm-skip-input'); - final scope = Scope() - ..value( - contextKey, - FVMContext.create( - args: editableArgs, - skipInput: skipInput, - ), - ); + final scope = Scope()..value(contextKey, FVMContext.create(args: args)); await _flushThenExit( await scope.run(() async => FvmCommandRunner().run((args))), diff --git a/lib/src/services/logger_service.dart b/lib/src/services/logger_service.dart index 6caeb26a..e4a762ec 100644 --- a/lib/src/services/logger_service.dart +++ b/lib/src/services/logger_service.dart @@ -64,17 +64,17 @@ class LoggerService extends ContextService { return progress; } - bool confirm(String? message, {bool? defaultValue, bool? ciDefaultValue}) { + bool confirm(String? message, {required bool defaultValue}) { // When running tests, always return true. if (context.isTest) return true; - if (context.skipInput) { - if (ciDefaultValue != null) { - return ciDefaultValue; - } else if (defaultValue != null) { - return defaultValue; - } - exit(ExitCode.usage.code); + if (context.isCI || context.skipInput) { + logger.info(message ?? ''); + logger + ..warn('Skipping input confirmation') + ..warn('Using default value of $defaultValue'); + + return defaultValue; } return interact.Confirm(prompt: message ?? '', defaultValue: defaultValue) @@ -134,8 +134,6 @@ class LoggerService extends ContextService { final dot = '\u{25CF}'; // ● final rightArrow = '\u{2192}'; // → -/// Logger for FVM -/// Console controller instance final consoleController = ConsoleController(); /// Console Controller diff --git a/lib/src/utils/context.dart b/lib/src/utils/context.dart index eb55dbe5..9f3b04ad 100644 --- a/lib/src/utils/context.dart +++ b/lib/src/utils/context.dart @@ -79,7 +79,6 @@ class FVMContext with FVMContextMappable { static FVMContext create({ String? id, List? args, - bool? skipInput, AppConfig? configOverrides, String? workingDirectory, Map? generatorOverrides, @@ -95,13 +94,16 @@ class FVMContext with FVMContextMappable { final environment = {...Platform.environment, ...?environmentOverrides}; + // Skips input if running in CI + final skipInput = args?.remove('--fvm-skip-input') ?? false; + return FVMContext.base( id: id ?? 'MAIN', workingDirectory: workingDirectory, config: config, environment: environment, args: args ?? [], - skipInput: skipInput ?? false, + skipInput: skipInput, generators: { LoggerService: (context) => LoggerService( level: level, diff --git a/lib/src/utils/deprecation_util.dart b/lib/src/utils/deprecation_util.dart index d2022dd7..25286b6d 100644 --- a/lib/src/utils/deprecation_util.dart +++ b/lib/src/utils/deprecation_util.dart @@ -21,6 +21,7 @@ void _warnDeprecatedEnvVars() { logger.info('Please use ${ConfigKeys.flutterUrl.envKey}'); final confirmation = logger.confirm( 'Do you want to proceed? This might impact the expected behavior.', + defaultValue: false, ); if (!confirmation) { exit(ExitCode.success.code); diff --git a/lib/src/version.dart b/lib/src/version.dart index 54d58d26..518a1829 100644 --- a/lib/src/version.dart +++ b/lib/src/version.dart @@ -1,2 +1,2 @@ // Generated code. Do not modify. -const packageVersion = '3.1.7'; +const packageVersion = '3.2.0'; diff --git a/lib/src/workflows/ensure_cache.workflow.dart b/lib/src/workflows/ensure_cache.workflow.dart index f495bc52..d46aa8f2 100644 --- a/lib/src/workflows/ensure_cache.workflow.dart +++ b/lib/src/workflows/ensure_cache.workflow.dart @@ -75,7 +75,6 @@ Future ensureCacheWorkflow( final shouldInstallConfirmed = logger.confirm( 'Would you like to install it now?', defaultValue: true, - ciDefaultValue: false, ); if (!shouldInstallConfirmed) { diff --git a/lib/src/workflows/use_version.workflow.dart b/lib/src/workflows/use_version.workflow.dart index 540bd0aa..f8104e23 100644 --- a/lib/src/workflows/use_version.workflow.dart +++ b/lib/src/workflows/use_version.workflow.dart @@ -48,7 +48,10 @@ Future useVersionWorkflow({ logger ..spacer ..info('No pubspec.yaml detected in this directory'); - final proceed = logger.confirm('Would you like to continue?'); + final proceed = logger.confirm( + 'Would you like to continue?', + defaultValue: true, + ); if (!proceed) exit(ExitCode.success.code); }