Deprecate make-host-app-editable (#59217)
This commit is contained in:
@@ -3,8 +3,6 @@
|
|||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import '../base/common.dart';
|
|
||||||
import '../project.dart';
|
|
||||||
import '../runner/flutter_command.dart';
|
import '../runner/flutter_command.dart';
|
||||||
|
|
||||||
class MakeHostAppEditableCommand extends FlutterCommand {
|
class MakeHostAppEditableCommand extends FlutterCommand {
|
||||||
@@ -23,43 +21,18 @@ class MakeHostAppEditableCommand extends FlutterCommand {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
FlutterProject _project;
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
final String name = 'make-host-app-editable';
|
final String name = 'make-host-app-editable';
|
||||||
|
|
||||||
@override
|
@override
|
||||||
final String description = 'Moves host apps from generated directories to non-generated directories so that they can be edited by developers.\n\n'
|
bool get deprecated => true;
|
||||||
'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.';
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<void> validateCommand() async {
|
final String description = 'Moves host apps from generated directories to non-generated directories so that they can be edited by developers.';
|
||||||
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.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<FlutterCommandResult> runCommand() async {
|
Future<FlutterCommandResult> runCommand() async {
|
||||||
await _project.ensureReadyForPlatformSpecificTooling(checkProjects: false);
|
// Deprecated. No-op.
|
||||||
|
|
||||||
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();
|
|
||||||
}
|
|
||||||
|
|
||||||
return FlutterCommandResult.success();
|
return FlutterCommandResult.success();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import '../base/common.dart';
|
|||||||
import '../base/context.dart';
|
import '../base/context.dart';
|
||||||
import '../base/io.dart' as io;
|
import '../base/io.dart' as io;
|
||||||
import '../base/signals.dart';
|
import '../base/signals.dart';
|
||||||
|
import '../base/terminal.dart';
|
||||||
import '../base/user_messages.dart';
|
import '../base/user_messages.dart';
|
||||||
import '../base/utils.dart';
|
import '../base/utils.dart';
|
||||||
import '../build_info.dart';
|
import '../build_info.dart';
|
||||||
@@ -150,6 +151,11 @@ abstract class FlutterCommand extends Command<void> {
|
|||||||
|
|
||||||
bool get shouldUpdateCache => true;
|
bool get shouldUpdateCache => true;
|
||||||
|
|
||||||
|
bool get deprecated => false;
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool get hidden => deprecated;
|
||||||
|
|
||||||
bool _excludeDebug = false;
|
bool _excludeDebug = false;
|
||||||
|
|
||||||
BuildMode _defaultBuildMode;
|
BuildMode _defaultBuildMode;
|
||||||
@@ -715,6 +721,7 @@ abstract class FlutterCommand extends Command<void> {
|
|||||||
body: () async {
|
body: () async {
|
||||||
// Prints the welcome message if needed.
|
// Prints the welcome message if needed.
|
||||||
globals.flutterUsage.printWelcome();
|
globals.flutterUsage.printWelcome();
|
||||||
|
_printDeprecationWarning();
|
||||||
final String commandPath = await usagePath;
|
final String commandPath = await usagePath;
|
||||||
_registerSignalHandlers(commandPath, startTime);
|
_registerSignalHandlers(commandPath, startTime);
|
||||||
FlutterCommandResult commandResult = FlutterCommandResult.fail();
|
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) {
|
void _registerSignalHandlers(String commandPath, DateTime startTime) {
|
||||||
final SignalHandler handler = (io.ProcessSignal s) {
|
final SignalHandler handler = (io.ProcessSignal s) {
|
||||||
Cache.releaseLock();
|
Cache.releaseLock();
|
||||||
@@ -948,6 +963,8 @@ abstract class FlutterCommand extends Command<void> {
|
|||||||
description.length + 2,
|
description.length + 2,
|
||||||
);
|
);
|
||||||
final String help = <String>[
|
final String help = <String>[
|
||||||
|
if (deprecated)
|
||||||
|
'$warningMark Deprecated. This command will be removed in a future version of Flutter.',
|
||||||
description,
|
description,
|
||||||
'',
|
'',
|
||||||
'Global options:',
|
'Global options:',
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'dart:io' as io;
|
import 'dart:io' as io;
|
||||||
|
|
||||||
|
import 'package:args/command_runner.dart';
|
||||||
import 'package:flutter_tools/src/base/common.dart';
|
import 'package:flutter_tools/src/base/common.dart';
|
||||||
import 'package:flutter_tools/src/base/error_handling_file_system.dart';
|
import 'package:flutter_tools/src/base/error_handling_file_system.dart';
|
||||||
import 'package:flutter_tools/src/base/io.dart';
|
import 'package:flutter_tools/src/base/io.dart';
|
||||||
@@ -43,7 +44,7 @@ void main() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
testUsingContext('help text contains global options', () {
|
testUsingContext('help text contains global options', () {
|
||||||
final FakeCommand fake = FakeCommand();
|
final FakeDeprecatedCommand fake = FakeDeprecatedCommand();
|
||||||
createTestCommandRunner(fake);
|
createTestCommandRunner(fake);
|
||||||
expect(fake.usage, contains('Global options:\n'));
|
expect(fake.usage, contains('Global options:\n'));
|
||||||
});
|
});
|
||||||
@@ -52,6 +53,8 @@ void main() {
|
|||||||
final DummyFlutterCommand flutterCommand = DummyFlutterCommand(shouldUpdateCache: false);
|
final DummyFlutterCommand flutterCommand = DummyFlutterCommand(shouldUpdateCache: false);
|
||||||
await flutterCommand.run();
|
await flutterCommand.run();
|
||||||
verifyZeroInteractions(cache);
|
verifyZeroInteractions(cache);
|
||||||
|
expect(flutterCommand.deprecated, isFalse);
|
||||||
|
expect(flutterCommand.hidden, isFalse);
|
||||||
},
|
},
|
||||||
overrides: <Type, Generator>{
|
overrides: <Type, Generator>{
|
||||||
Cache: () => cache,
|
Cache: () => cache,
|
||||||
@@ -73,6 +76,21 @@ void main() {
|
|||||||
Cache: () => cache,
|
Cache: () => cache,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
testUsingContext('deprecated command should warn', () async {
|
||||||
|
final FakeDeprecatedCommand flutterCommand = FakeDeprecatedCommand();
|
||||||
|
final CommandRunner<void> runner = createTestCommandRunner(flutterCommand);
|
||||||
|
await runner.run(<String>['deprecated']);
|
||||||
|
|
||||||
|
expect(testLogger.statusText,
|
||||||
|
contains('The "deprecated" command is deprecated and will be removed in '
|
||||||
|
'a future version of Flutter.'));
|
||||||
|
expect(flutterCommand.usage,
|
||||||
|
contains('Deprecated. This command will be removed in a future version '
|
||||||
|
'of Flutter.'));
|
||||||
|
expect(flutterCommand.deprecated, isTrue);
|
||||||
|
expect(flutterCommand.hidden, isTrue);
|
||||||
|
});
|
||||||
|
|
||||||
testUsingContext('uses the error handling file system', () async {
|
testUsingContext('uses the error handling file system', () async {
|
||||||
final DummyFlutterCommand flutterCommand = DummyFlutterCommand(
|
final DummyFlutterCommand flutterCommand = DummyFlutterCommand(
|
||||||
commandFunction: () async {
|
commandFunction: () async {
|
||||||
@@ -429,12 +447,15 @@ void main() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
class FakeCommand extends FlutterCommand {
|
class FakeDeprecatedCommand extends FlutterCommand {
|
||||||
@override
|
@override
|
||||||
String get description => 'A fake command';
|
String get description => 'A fake command';
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String get name => 'fake';
|
String get name => 'deprecated';
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool get deprecated => true;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<FlutterCommandResult> runCommand() async {
|
Future<FlutterCommandResult> runCommand() async {
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import 'package:process/process.dart';
|
|||||||
import '../src/common.dart';
|
import '../src/common.dart';
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
test('All development tools are hidden and help text is not verbose', () async {
|
test('All development tools and deprecated commands are hidden and help text is not verbose', () async {
|
||||||
final String flutterBin = globals.fs.path.join(getFlutterRoot(), 'bin', 'flutter');
|
final String flutterBin = globals.fs.path.join(getFlutterRoot(), 'bin', 'flutter');
|
||||||
final ProcessResult result = await const LocalProcessManager().run(<String>[
|
final ProcessResult result = await const LocalProcessManager().run(<String>[
|
||||||
flutterBin,
|
flutterBin,
|
||||||
@@ -17,9 +17,14 @@ void main() {
|
|||||||
'-v',
|
'-v',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
// Development tools.
|
||||||
expect(result.stdout, isNot(contains('ide-config')));
|
expect(result.stdout, isNot(contains('ide-config')));
|
||||||
expect(result.stdout, isNot(contains('update-packages')));
|
expect(result.stdout, isNot(contains('update-packages')));
|
||||||
expect(result.stdout, isNot(contains('inject-plugins')));
|
expect(result.stdout, isNot(contains('inject-plugins')));
|
||||||
|
|
||||||
|
// Deprecated.
|
||||||
|
expect(result.stdout, isNot(contains('make-host-app-editable')));
|
||||||
|
|
||||||
// Only printed by verbose tool.
|
// Only printed by verbose tool.
|
||||||
expect(result.stdout, isNot(contains('exiting with code 0')));
|
expect(result.stdout, isNot(contains('exiting with code 0')));
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user