mirror of
https://github.com/flutter/packages.git
synced 2025-06-17 10:58:42 +08:00
[tool] Rename all-plugins-app command (#6600)
This commit is contained in:
@ -1,3 +1,9 @@
|
|||||||
|
## 0.13.0
|
||||||
|
|
||||||
|
* Renames `all-plugins-app` to `create-all-packages-app` to clarify what it
|
||||||
|
actually does. Also renames the project directory it creates from
|
||||||
|
`all_plugins` to `all_packages`.
|
||||||
|
|
||||||
## 0.12.1
|
## 0.12.1
|
||||||
|
|
||||||
* Modifies `publish_check_command.dart` to do a `dart pub get` in all examples
|
* Modifies `publish_check_command.dart` to do a `dart pub get` in all examples
|
||||||
|
@ -17,14 +17,16 @@ import 'common/repository_package.dart';
|
|||||||
|
|
||||||
const String _outputDirectoryFlag = 'output-dir';
|
const String _outputDirectoryFlag = 'output-dir';
|
||||||
|
|
||||||
|
const String _projectName = 'all_packages';
|
||||||
|
|
||||||
const int _exitUpdateMacosPodfileFailed = 3;
|
const int _exitUpdateMacosPodfileFailed = 3;
|
||||||
const int _exitUpdateMacosPbxprojFailed = 4;
|
const int _exitUpdateMacosPbxprojFailed = 4;
|
||||||
const int _exitGenNativeBuildFilesFailed = 5;
|
const int _exitGenNativeBuildFilesFailed = 5;
|
||||||
|
|
||||||
/// A command to create an application that builds all in a single application.
|
/// A command to create an application that builds all in a single application.
|
||||||
class CreateAllPluginsAppCommand extends PackageCommand {
|
class CreateAllPackagesAppCommand extends PackageCommand {
|
||||||
/// Creates an instance of the builder command.
|
/// Creates an instance of the builder command.
|
||||||
CreateAllPluginsAppCommand(
|
CreateAllPackagesAppCommand(
|
||||||
Directory packagesDir, {
|
Directory packagesDir, {
|
||||||
ProcessRunner processRunner = const ProcessRunner(),
|
ProcessRunner processRunner = const ProcessRunner(),
|
||||||
Directory? pluginsRoot,
|
Directory? pluginsRoot,
|
||||||
@ -34,24 +36,25 @@ class CreateAllPluginsAppCommand extends PackageCommand {
|
|||||||
pluginsRoot ?? packagesDir.fileSystem.currentDirectory;
|
pluginsRoot ?? packagesDir.fileSystem.currentDirectory;
|
||||||
argParser.addOption(_outputDirectoryFlag,
|
argParser.addOption(_outputDirectoryFlag,
|
||||||
defaultsTo: defaultDir.path,
|
defaultsTo: defaultDir.path,
|
||||||
help: 'The path the directory to create the "all_plugins" project in.\n'
|
help:
|
||||||
|
'The path the directory to create the "$_projectName" project in.\n'
|
||||||
'Defaults to the repository root.');
|
'Defaults to the repository root.');
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The location to create the synthesized app project.
|
/// The location to create the synthesized app project.
|
||||||
Directory get _appDirectory => packagesDir.fileSystem
|
Directory get _appDirectory => packagesDir.fileSystem
|
||||||
.directory(getStringArg(_outputDirectoryFlag))
|
.directory(getStringArg(_outputDirectoryFlag))
|
||||||
.childDirectory('all_plugins');
|
.childDirectory(_projectName);
|
||||||
|
|
||||||
/// The synthesized app project.
|
/// The synthesized app project.
|
||||||
RepositoryPackage get app => RepositoryPackage(_appDirectory);
|
RepositoryPackage get app => RepositoryPackage(_appDirectory);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String get description =>
|
String get description =>
|
||||||
'Generate Flutter app that includes all plugins in packages.';
|
'Generate Flutter app that includes all target packagas.';
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String get name => 'all-plugins-app';
|
String get name => 'create-all-packages-app';
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<void> run() async {
|
Future<void> run() async {
|
||||||
@ -100,7 +103,7 @@ class CreateAllPluginsAppCommand extends PackageCommand {
|
|||||||
<String>[
|
<String>[
|
||||||
'create',
|
'create',
|
||||||
'--template=app',
|
'--template=app',
|
||||||
'--project-name=all_plugins',
|
'--project-name=$_projectName',
|
||||||
'--android-language=java',
|
'--android-language=java',
|
||||||
_appDirectory.path,
|
_appDirectory.path,
|
||||||
],
|
],
|
||||||
@ -160,9 +163,9 @@ class CreateAllPluginsAppCommand extends PackageCommand {
|
|||||||
|
|
||||||
final StringBuffer newManifest = StringBuffer();
|
final StringBuffer newManifest = StringBuffer();
|
||||||
for (final String line in manifestFile.readAsLinesSync()) {
|
for (final String line in manifestFile.readAsLinesSync()) {
|
||||||
if (line.contains('package="com.example.all_plugins"')) {
|
if (line.contains('package="com.example.$_projectName"')) {
|
||||||
newManifest
|
newManifest
|
||||||
..writeln('package="com.example.all_plugins"')
|
..writeln('package="com.example.$_projectName"')
|
||||||
..writeln('xmlns:tools="http://schemas.android.com/tools">')
|
..writeln('xmlns:tools="http://schemas.android.com/tools">')
|
||||||
..writeln()
|
..writeln()
|
||||||
..writeln(
|
..writeln(
|
||||||
@ -191,7 +194,7 @@ class CreateAllPluginsAppCommand extends PackageCommand {
|
|||||||
final Map<String, PathDependency> pluginDeps =
|
final Map<String, PathDependency> pluginDeps =
|
||||||
await _getValidPathDependencies();
|
await _getValidPathDependencies();
|
||||||
final Pubspec pubspec = Pubspec(
|
final Pubspec pubspec = Pubspec(
|
||||||
'all_plugins',
|
_projectName,
|
||||||
description: 'Flutter app containing all 1st party plugins.',
|
description: 'Flutter app containing all 1st party plugins.',
|
||||||
version: Version.parse('1.0.0+1'),
|
version: Version.parse('1.0.0+1'),
|
||||||
environment: <String, VersionConstraint>{
|
environment: <String, VersionConstraint>{
|
@ -11,7 +11,7 @@ import 'package:file/local.dart';
|
|||||||
import 'analyze_command.dart';
|
import 'analyze_command.dart';
|
||||||
import 'build_examples_command.dart';
|
import 'build_examples_command.dart';
|
||||||
import 'common/core.dart';
|
import 'common/core.dart';
|
||||||
import 'create_all_plugins_app_command.dart';
|
import 'create_all_packages_app_command.dart';
|
||||||
import 'custom_test_command.dart';
|
import 'custom_test_command.dart';
|
||||||
import 'dependabot_check_command.dart';
|
import 'dependabot_check_command.dart';
|
||||||
import 'drive_examples_command.dart';
|
import 'drive_examples_command.dart';
|
||||||
@ -56,7 +56,7 @@ void main(List<String> args) {
|
|||||||
'Productivity utils for hosting multiple plugins within one repository.')
|
'Productivity utils for hosting multiple plugins within one repository.')
|
||||||
..addCommand(AnalyzeCommand(packagesDir))
|
..addCommand(AnalyzeCommand(packagesDir))
|
||||||
..addCommand(BuildExamplesCommand(packagesDir))
|
..addCommand(BuildExamplesCommand(packagesDir))
|
||||||
..addCommand(CreateAllPluginsAppCommand(packagesDir))
|
..addCommand(CreateAllPackagesAppCommand(packagesDir))
|
||||||
..addCommand(CustomTestCommand(packagesDir))
|
..addCommand(CustomTestCommand(packagesDir))
|
||||||
..addCommand(DependabotCheckCommand(packagesDir))
|
..addCommand(DependabotCheckCommand(packagesDir))
|
||||||
..addCommand(DriveExamplesCommand(packagesDir))
|
..addCommand(DriveExamplesCommand(packagesDir))
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
name: flutter_plugin_tools
|
name: flutter_plugin_tools
|
||||||
description: Productivity utils for flutter/plugins and flutter/packages
|
description: Productivity utils for flutter/plugins and flutter/packages
|
||||||
repository: https://github.com/flutter/plugins/tree/main/script/tool
|
repository: https://github.com/flutter/plugins/tree/main/script/tool
|
||||||
version: 0.12.1
|
version: 0.13.0
|
||||||
|
|
||||||
dependencies:
|
dependencies:
|
||||||
args: ^2.1.0
|
args: ^2.1.0
|
||||||
|
@ -8,7 +8,7 @@ import 'package:args/command_runner.dart';
|
|||||||
import 'package:file/file.dart';
|
import 'package:file/file.dart';
|
||||||
import 'package:file/local.dart';
|
import 'package:file/local.dart';
|
||||||
import 'package:flutter_plugin_tools/src/common/core.dart';
|
import 'package:flutter_plugin_tools/src/common/core.dart';
|
||||||
import 'package:flutter_plugin_tools/src/create_all_plugins_app_command.dart';
|
import 'package:flutter_plugin_tools/src/create_all_packages_app_command.dart';
|
||||||
import 'package:platform/platform.dart';
|
import 'package:platform/platform.dart';
|
||||||
import 'package:test/test.dart';
|
import 'package:test/test.dart';
|
||||||
|
|
||||||
@ -16,43 +16,58 @@ import 'mocks.dart';
|
|||||||
import 'util.dart';
|
import 'util.dart';
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
group('$CreateAllPluginsAppCommand', () {
|
late CommandRunner<void> runner;
|
||||||
late CommandRunner<void> runner;
|
late CreateAllPackagesAppCommand command;
|
||||||
late CreateAllPluginsAppCommand command;
|
late FileSystem fileSystem;
|
||||||
late FileSystem fileSystem;
|
late Directory testRoot;
|
||||||
late Directory testRoot;
|
late Directory packagesDir;
|
||||||
late Directory packagesDir;
|
late RecordingProcessRunner processRunner;
|
||||||
late RecordingProcessRunner processRunner;
|
|
||||||
|
|
||||||
|
setUp(() {
|
||||||
|
// Since the core of this command is a call to 'flutter create', the test
|
||||||
|
// has to use the real filesystem. Put everything possible in a unique
|
||||||
|
// temporary to minimize effect on the host system.
|
||||||
|
fileSystem = const LocalFileSystem();
|
||||||
|
testRoot = fileSystem.systemTempDirectory.createTempSync();
|
||||||
|
packagesDir = testRoot.childDirectory('packages');
|
||||||
|
processRunner = RecordingProcessRunner();
|
||||||
|
|
||||||
|
command = CreateAllPackagesAppCommand(
|
||||||
|
packagesDir,
|
||||||
|
processRunner: processRunner,
|
||||||
|
pluginsRoot: testRoot,
|
||||||
|
);
|
||||||
|
runner = CommandRunner<void>(
|
||||||
|
'create_all_test', 'Test for $CreateAllPackagesAppCommand');
|
||||||
|
runner.addCommand(command);
|
||||||
|
});
|
||||||
|
|
||||||
|
tearDown(() {
|
||||||
|
testRoot.deleteSync(recursive: true);
|
||||||
|
});
|
||||||
|
|
||||||
|
group('non-macOS host', () {
|
||||||
setUp(() {
|
setUp(() {
|
||||||
// Since the core of this command is a call to 'flutter create', the test
|
command = CreateAllPackagesAppCommand(
|
||||||
// has to use the real filesystem. Put everything possible in a unique
|
|
||||||
// temporary to minimize effect on the host system.
|
|
||||||
fileSystem = const LocalFileSystem();
|
|
||||||
testRoot = fileSystem.systemTempDirectory.createTempSync();
|
|
||||||
packagesDir = testRoot.childDirectory('packages');
|
|
||||||
processRunner = RecordingProcessRunner();
|
|
||||||
|
|
||||||
command = CreateAllPluginsAppCommand(
|
|
||||||
packagesDir,
|
packagesDir,
|
||||||
processRunner: processRunner,
|
processRunner: processRunner,
|
||||||
|
// Set isWindows or not based on the actual host, so that
|
||||||
|
// `flutterCommand` works, since these tests actually call 'flutter'.
|
||||||
|
// The important thing is that isMacOS always returns false.
|
||||||
|
platform: MockPlatform(isWindows: const LocalPlatform().isWindows),
|
||||||
pluginsRoot: testRoot,
|
pluginsRoot: testRoot,
|
||||||
);
|
);
|
||||||
runner = CommandRunner<void>(
|
runner = CommandRunner<void>(
|
||||||
'create_all_test', 'Test for $CreateAllPluginsAppCommand');
|
'create_all_test', 'Test for $CreateAllPackagesAppCommand');
|
||||||
runner.addCommand(command);
|
runner.addCommand(command);
|
||||||
});
|
});
|
||||||
|
|
||||||
tearDown(() {
|
|
||||||
testRoot.deleteSync(recursive: true);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('pubspec includes all plugins', () async {
|
test('pubspec includes all plugins', () async {
|
||||||
createFakePlugin('plugina', packagesDir);
|
createFakePlugin('plugina', packagesDir);
|
||||||
createFakePlugin('pluginb', packagesDir);
|
createFakePlugin('pluginb', packagesDir);
|
||||||
createFakePlugin('pluginc', packagesDir);
|
createFakePlugin('pluginc', packagesDir);
|
||||||
|
|
||||||
await runCapturingPrint(runner, <String>['all-plugins-app']);
|
await runCapturingPrint(runner, <String>['create-all-packages-app']);
|
||||||
final List<String> pubspec = command.app.pubspecFile.readAsLinesSync();
|
final List<String> pubspec = command.app.pubspecFile.readAsLinesSync();
|
||||||
|
|
||||||
expect(
|
expect(
|
||||||
@ -69,7 +84,7 @@ void main() {
|
|||||||
createFakePlugin('pluginb', packagesDir);
|
createFakePlugin('pluginb', packagesDir);
|
||||||
createFakePlugin('pluginc', packagesDir);
|
createFakePlugin('pluginc', packagesDir);
|
||||||
|
|
||||||
await runCapturingPrint(runner, <String>['all-plugins-app']);
|
await runCapturingPrint(runner, <String>['create-all-packages-app']);
|
||||||
final List<String> pubspec = command.app.pubspecFile.readAsLinesSync();
|
final List<String> pubspec = command.app.pubspecFile.readAsLinesSync();
|
||||||
|
|
||||||
expect(
|
expect(
|
||||||
@ -100,7 +115,7 @@ void main() {
|
|||||||
|
|
||||||
createFakePlugin('plugina', packagesDir);
|
createFakePlugin('plugina', packagesDir);
|
||||||
|
|
||||||
await runCapturingPrint(runner, <String>['all-plugins-app']);
|
await runCapturingPrint(runner, <String>['create-all-packages-app']);
|
||||||
final Pubspec generatedPubspec = command.app.parsePubspec();
|
final Pubspec generatedPubspec = command.app.parsePubspec();
|
||||||
|
|
||||||
const String dartSdkKey = 'sdk';
|
const String dartSdkKey = 'sdk';
|
||||||
@ -108,37 +123,10 @@ void main() {
|
|||||||
baselinePubspec.environment?[dartSdkKey]);
|
baselinePubspec.environment?[dartSdkKey]);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('macOS deployment target is modified in Podfile', () async {
|
|
||||||
createFakePlugin('plugina', packagesDir);
|
|
||||||
|
|
||||||
final File podfileFile = command.packagesDir.parent
|
|
||||||
.childDirectory('all_plugins')
|
|
||||||
.childDirectory('macos')
|
|
||||||
.childFile('Podfile');
|
|
||||||
podfileFile.createSync(recursive: true);
|
|
||||||
podfileFile.writeAsStringSync("""
|
|
||||||
platform :osx, '10.11'
|
|
||||||
# some other line
|
|
||||||
""");
|
|
||||||
|
|
||||||
await runCapturingPrint(runner, <String>['all-plugins-app']);
|
|
||||||
final List<String> podfile = command.app
|
|
||||||
.platformDirectory(FlutterPlatform.macos)
|
|
||||||
.childFile('Podfile')
|
|
||||||
.readAsLinesSync();
|
|
||||||
|
|
||||||
expect(
|
|
||||||
podfile,
|
|
||||||
everyElement((String line) =>
|
|
||||||
!line.contains('platform :osx') || line.contains("'10.15'")));
|
|
||||||
},
|
|
||||||
// Podfile is only generated (and thus only edited) on macOS.
|
|
||||||
skip: !io.Platform.isMacOS);
|
|
||||||
|
|
||||||
test('macOS deployment target is modified in pbxproj', () async {
|
test('macOS deployment target is modified in pbxproj', () async {
|
||||||
createFakePlugin('plugina', packagesDir);
|
createFakePlugin('plugina', packagesDir);
|
||||||
|
|
||||||
await runCapturingPrint(runner, <String>['all-plugins-app']);
|
await runCapturingPrint(runner, <String>['create-all-packages-app']);
|
||||||
final List<String> pbxproj = command.app
|
final List<String> pbxproj = command.app
|
||||||
.platformDirectory(FlutterPlatform.macos)
|
.platformDirectory(FlutterPlatform.macos)
|
||||||
.childDirectory('Runner.xcodeproj')
|
.childDirectory('Runner.xcodeproj')
|
||||||
@ -155,7 +143,7 @@ platform :osx, '10.11'
|
|||||||
test('calls flutter pub get', () async {
|
test('calls flutter pub get', () async {
|
||||||
createFakePlugin('plugina', packagesDir);
|
createFakePlugin('plugina', packagesDir);
|
||||||
|
|
||||||
await runCapturingPrint(runner, <String>['all-plugins-app']);
|
await runCapturingPrint(runner, <String>['create-all-packages-app']);
|
||||||
|
|
||||||
expect(
|
expect(
|
||||||
processRunner.recordedCalls,
|
processRunner.recordedCalls,
|
||||||
@ -163,10 +151,10 @@ platform :osx, '10.11'
|
|||||||
ProcessCall(
|
ProcessCall(
|
||||||
getFlutterCommand(const LocalPlatform()),
|
getFlutterCommand(const LocalPlatform()),
|
||||||
const <String>['pub', 'get'],
|
const <String>['pub', 'get'],
|
||||||
testRoot.childDirectory('all_plugins').path),
|
testRoot.childDirectory('all_packages').path),
|
||||||
]));
|
]));
|
||||||
},
|
},
|
||||||
// See comment about Windows in create_all_plugins_app_command.dart
|
// See comment about Windows in create_all_packages_app_command.dart
|
||||||
skip: io.Platform.isWindows);
|
skip: io.Platform.isWindows);
|
||||||
|
|
||||||
test('fails if flutter pub get fails', () async {
|
test('fails if flutter pub get fails', () async {
|
||||||
@ -178,7 +166,7 @@ platform :osx, '10.11'
|
|||||||
];
|
];
|
||||||
Error? commandError;
|
Error? commandError;
|
||||||
final List<String> output = await runCapturingPrint(
|
final List<String> output = await runCapturingPrint(
|
||||||
runner, <String>['all-plugins-app'], errorHandler: (Error e) {
|
runner, <String>['create-all-packages-app'], errorHandler: (Error e) {
|
||||||
commandError = e;
|
commandError = e;
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -190,7 +178,7 @@ platform :osx, '10.11'
|
|||||||
"Failed to generate native build files via 'flutter pub get'"),
|
"Failed to generate native build files via 'flutter pub get'"),
|
||||||
]));
|
]));
|
||||||
},
|
},
|
||||||
// See comment about Windows in create_all_plugins_app_command.dart
|
// See comment about Windows in create_all_packages_app_command.dart
|
||||||
skip: io.Platform.isWindows);
|
skip: io.Platform.isWindows);
|
||||||
|
|
||||||
test('handles --output-dir', () async {
|
test('handles --output-dir', () async {
|
||||||
@ -198,11 +186,13 @@ platform :osx, '10.11'
|
|||||||
|
|
||||||
final Directory customOutputDir =
|
final Directory customOutputDir =
|
||||||
fileSystem.systemTempDirectory.createTempSync();
|
fileSystem.systemTempDirectory.createTempSync();
|
||||||
await runCapturingPrint(runner,
|
await runCapturingPrint(runner, <String>[
|
||||||
<String>['all-plugins-app', '--output-dir=${customOutputDir.path}']);
|
'create-all-packages-app',
|
||||||
|
'--output-dir=${customOutputDir.path}'
|
||||||
|
]);
|
||||||
|
|
||||||
expect(
|
expect(command.app.path,
|
||||||
command.app.path, customOutputDir.childDirectory('all_plugins').path);
|
customOutputDir.childDirectory('all_packages').path);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('logs exclusions', () async {
|
test('logs exclusions', () async {
|
||||||
@ -210,8 +200,8 @@ platform :osx, '10.11'
|
|||||||
createFakePlugin('pluginb', packagesDir);
|
createFakePlugin('pluginb', packagesDir);
|
||||||
createFakePlugin('pluginc', packagesDir);
|
createFakePlugin('pluginc', packagesDir);
|
||||||
|
|
||||||
final List<String> output = await runCapturingPrint(
|
final List<String> output = await runCapturingPrint(runner,
|
||||||
runner, <String>['all-plugins-app', '--exclude=pluginb,pluginc']);
|
<String>['create-all-packages-app', '--exclude=pluginb,pluginc']);
|
||||||
|
|
||||||
expect(
|
expect(
|
||||||
output,
|
output,
|
||||||
@ -222,4 +212,45 @@ platform :osx, '10.11'
|
|||||||
]));
|
]));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
group('macOS host', () {
|
||||||
|
setUp(() {
|
||||||
|
command = CreateAllPackagesAppCommand(
|
||||||
|
packagesDir,
|
||||||
|
processRunner: processRunner,
|
||||||
|
platform: MockPlatform(isMacOS: true),
|
||||||
|
pluginsRoot: testRoot,
|
||||||
|
);
|
||||||
|
runner = CommandRunner<void>(
|
||||||
|
'create_all_test', 'Test for $CreateAllPackagesAppCommand');
|
||||||
|
runner.addCommand(command);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('macOS deployment target is modified in Podfile', () async {
|
||||||
|
createFakePlugin('plugina', packagesDir);
|
||||||
|
|
||||||
|
final File podfileFile = RepositoryPackage(
|
||||||
|
command.packagesDir.parent.childDirectory('all_packages'))
|
||||||
|
.platformDirectory(FlutterPlatform.macos)
|
||||||
|
.childFile('Podfile');
|
||||||
|
podfileFile.createSync(recursive: true);
|
||||||
|
podfileFile.writeAsStringSync("""
|
||||||
|
platform :osx, '10.11'
|
||||||
|
# some other line
|
||||||
|
""");
|
||||||
|
|
||||||
|
await runCapturingPrint(runner, <String>['create-all-packages-app']);
|
||||||
|
final List<String> podfile = command.app
|
||||||
|
.platformDirectory(FlutterPlatform.macos)
|
||||||
|
.childFile('Podfile')
|
||||||
|
.readAsLinesSync();
|
||||||
|
|
||||||
|
expect(
|
||||||
|
podfile,
|
||||||
|
everyElement((String line) =>
|
||||||
|
!line.contains('platform :osx') || line.contains("'10.15'")));
|
||||||
|
},
|
||||||
|
// Podfile is only generated (and thus only edited) on macOS.
|
||||||
|
skip: !io.Platform.isMacOS);
|
||||||
|
});
|
||||||
}
|
}
|
Reference in New Issue
Block a user