Deprecate make-host-app-editable (#59217)
This commit is contained in:
@@ -3,8 +3,6 @@
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'dart:async';
|
||||
import '../base/common.dart';
|
||||
import '../project.dart';
|
||||
import '../runner/flutter_command.dart';
|
||||
|
||||
class MakeHostAppEditableCommand extends FlutterCommand {
|
||||
@@ -23,43 +21,18 @@ class MakeHostAppEditableCommand extends FlutterCommand {
|
||||
);
|
||||
}
|
||||
|
||||
FlutterProject _project;
|
||||
|
||||
@override
|
||||
final String name = 'make-host-app-editable';
|
||||
|
||||
@override
|
||||
final String description = 'Moves host apps from generated directories to non-generated directories so that they can be edited by developers.\n\n'
|
||||
'Use flags to specify which host app to make editable. If no flags are provided then all host apps will be made editable.\n\n'
|
||||
'Once a host app is made editable, that host app cannot be regenerated by Flutter and it will not receive future template changes.';
|
||||
bool get deprecated => true;
|
||||
|
||||
@override
|
||||
Future<void> validateCommand() async {
|
||||
await super.validateCommand();
|
||||
_project = FlutterProject.current();
|
||||
if (!_project.isModule) {
|
||||
throw ToolExit("Only projects created using 'flutter create -t module' can have their host apps made editable.");
|
||||
}
|
||||
}
|
||||
final String description = 'Moves host apps from generated directories to non-generated directories so that they can be edited by developers.';
|
||||
|
||||
@override
|
||||
Future<FlutterCommandResult> runCommand() async {
|
||||
await _project.ensureReadyForPlatformSpecificTooling(checkProjects: false);
|
||||
|
||||
final bool isAndroidRequested = boolArg('android');
|
||||
final bool isIOSRequested = boolArg('ios');
|
||||
|
||||
if (isAndroidRequested == isIOSRequested) {
|
||||
// No flags provided, or both flags provided. Make Android and iOS host
|
||||
// apps editable.
|
||||
await _project.android.makeHostAppEditable();
|
||||
await _project.ios.makeHostAppEditable();
|
||||
} else if (isAndroidRequested) {
|
||||
await _project.android.makeHostAppEditable();
|
||||
} else if (isIOSRequested) {
|
||||
await _project.ios.makeHostAppEditable();
|
||||
}
|
||||
|
||||
// Deprecated. No-op.
|
||||
return FlutterCommandResult.success();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ import '../base/common.dart';
|
||||
import '../base/context.dart';
|
||||
import '../base/io.dart' as io;
|
||||
import '../base/signals.dart';
|
||||
import '../base/terminal.dart';
|
||||
import '../base/user_messages.dart';
|
||||
import '../base/utils.dart';
|
||||
import '../build_info.dart';
|
||||
@@ -150,6 +151,11 @@ abstract class FlutterCommand extends Command<void> {
|
||||
|
||||
bool get shouldUpdateCache => true;
|
||||
|
||||
bool get deprecated => false;
|
||||
|
||||
@override
|
||||
bool get hidden => deprecated;
|
||||
|
||||
bool _excludeDebug = false;
|
||||
|
||||
BuildMode _defaultBuildMode;
|
||||
@@ -715,6 +721,7 @@ abstract class FlutterCommand extends Command<void> {
|
||||
body: () async {
|
||||
// Prints the welcome message if needed.
|
||||
globals.flutterUsage.printWelcome();
|
||||
_printDeprecationWarning();
|
||||
final String commandPath = await usagePath;
|
||||
_registerSignalHandlers(commandPath, startTime);
|
||||
FlutterCommandResult commandResult = FlutterCommandResult.fail();
|
||||
@@ -729,6 +736,14 @@ abstract class FlutterCommand extends Command<void> {
|
||||
);
|
||||
}
|
||||
|
||||
void _printDeprecationWarning() {
|
||||
if (deprecated) {
|
||||
globals.printStatus('$warningMark The "$name" command is deprecated and '
|
||||
'will be removed in a future version of Flutter.');
|
||||
globals.printStatus('');
|
||||
}
|
||||
}
|
||||
|
||||
void _registerSignalHandlers(String commandPath, DateTime startTime) {
|
||||
final SignalHandler handler = (io.ProcessSignal s) {
|
||||
Cache.releaseLock();
|
||||
@@ -948,6 +963,8 @@ abstract class FlutterCommand extends Command<void> {
|
||||
description.length + 2,
|
||||
);
|
||||
final String help = <String>[
|
||||
if (deprecated)
|
||||
'$warningMark Deprecated. This command will be removed in a future version of Flutter.',
|
||||
description,
|
||||
'',
|
||||
'Global options:',
|
||||
|
||||
Reference in New Issue
Block a user