From 163a358bb6437b1e9d022be3762594824dfef339 Mon Sep 17 00:00:00 2001 From: Stuart Morgan Date: Fri, 21 Oct 2022 15:00:20 -0400 Subject: [PATCH 1/4] [tool] Rename all-plugins-app command Renames `all-plugins-app` to `create-all-packages-app`, to make it clear that it's not plugin-specific (in preparation for the repo merge). See https://github.com/flutter/packages/pull/2724 for context. --- .ci/scripts/build_all_plugins.sh | 2 +- .ci/scripts/create_all_plugins_app.sh | 2 +- .cirrus.yml | 6 ++-- script/tool/CHANGELOG.md | 6 ++++ ...t => create_all_packages_app_command.dart} | 23 +++++++------- script/tool/lib/src/main.dart | 4 +-- script/tool/pubspec.yaml | 2 +- ...create_all_packages_app_command_test.dart} | 30 ++++++++++--------- 8 files changed, 43 insertions(+), 32 deletions(-) rename script/tool/lib/src/{create_all_plugins_app_command.dart => create_all_packages_app_command.dart} (93%) rename script/tool/test/{create_all_plugins_app_command_test.dart => create_all_packages_app_command_test.dart} (81%) diff --git a/.ci/scripts/build_all_plugins.sh b/.ci/scripts/build_all_plugins.sh index 008dea7c5e13..734194615673 100644 --- a/.ci/scripts/build_all_plugins.sh +++ b/.ci/scripts/build_all_plugins.sh @@ -3,6 +3,6 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. -cd all_plugins +cd all_packages flutter build windows --debug flutter build windows --release diff --git a/.ci/scripts/create_all_plugins_app.sh b/.ci/scripts/create_all_plugins_app.sh index 196fef9b06c9..eeba137045a9 100644 --- a/.ci/scripts/create_all_plugins_app.sh +++ b/.ci/scripts/create_all_plugins_app.sh @@ -3,5 +3,5 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. -dart ./script/tool/bin/flutter_plugin_tools.dart all-plugins-app \ +dart ./script/tool/bin/flutter_plugin_tools.dart creat-all-packages-app \ --output-dir=. --exclude script/configs/exclude_all_plugins_app.yaml diff --git a/.cirrus.yml b/.cirrus.yml index 89e1405a901e..548090719182 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -52,16 +52,16 @@ flutter_upgrade_template: &FLUTTER_UPGRADE_TEMPLATE build_all_plugins_app_template: &BUILD_ALL_PLUGINS_APP_TEMPLATE create_all_plugins_app_script: - - $PLUGIN_TOOL_COMMAND all-plugins-app --output-dir=. --exclude script/configs/exclude_all_plugins_app.yaml + - $PLUGIN_TOOL_COMMAND create-all-packages-app --output-dir=. --exclude script/configs/exclude_all_plugins_app.yaml build_all_plugins_debug_script: - - cd all_plugins + - cd all_packages - if [[ "$BUILD_ALL_ARGS" == "web" ]]; then - echo "Skipping; web does not support debug builds" - else - flutter build $BUILD_ALL_ARGS --debug - fi build_all_plugins_release_script: - - cd all_plugins + - cd all_packages - flutter build $BUILD_ALL_ARGS --release # Light-workload Linux tasks. diff --git a/script/tool/CHANGELOG.md b/script/tool/CHANGELOG.md index c492dc00905e..e5ad322aeea7 100644 --- a/script/tool/CHANGELOG.md +++ b/script/tool/CHANGELOG.md @@ -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 * Modifies `publish_check_command.dart` to do a `dart pub get` in all examples diff --git a/script/tool/lib/src/create_all_plugins_app_command.dart b/script/tool/lib/src/create_all_packages_app_command.dart similarity index 93% rename from script/tool/lib/src/create_all_plugins_app_command.dart rename to script/tool/lib/src/create_all_packages_app_command.dart index a23dc83d98f3..4c0028181e35 100644 --- a/script/tool/lib/src/create_all_plugins_app_command.dart +++ b/script/tool/lib/src/create_all_packages_app_command.dart @@ -15,10 +15,12 @@ import 'common/repository_package.dart'; const String _outputDirectoryFlag = 'output-dir'; +const String _projectName = 'all_packages'; + /// 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. - CreateAllPluginsAppCommand( + CreateAllPackagesAppCommand( Directory packagesDir, { Directory? pluginsRoot, }) : super(packagesDir) { @@ -26,24 +28,25 @@ class CreateAllPluginsAppCommand extends PackageCommand { pluginsRoot ?? packagesDir.fileSystem.currentDirectory; argParser.addOption(_outputDirectoryFlag, 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.'); } /// The location to create the synthesized app project. Directory get _appDirectory => packagesDir.fileSystem .directory(getStringArg(_outputDirectoryFlag)) - .childDirectory('all_plugins'); + .childDirectory(_projectName); /// The synthesized app project. RepositoryPackage get app => RepositoryPackage(_appDirectory); @override String get description => - 'Generate Flutter app that includes all plugins in packages.'; + 'Generate Flutter app that includes all target packagas.'; @override - String get name => 'all-plugins-app'; + String get name => 'create-all-packages-app'; @override Future run() async { @@ -74,7 +77,7 @@ class CreateAllPluginsAppCommand extends PackageCommand { [ 'create', '--template=app', - '--project-name=all_plugins', + '--project-name=$_projectName', '--android-language=java', _appDirectory.path, ], @@ -134,9 +137,9 @@ class CreateAllPluginsAppCommand extends PackageCommand { final StringBuffer newManifest = StringBuffer(); for (final String line in manifestFile.readAsLinesSync()) { - if (line.contains('package="com.example.all_plugins"')) { + if (line.contains('package="com.example.$_projectName"')) { newManifest - ..writeln('package="com.example.all_plugins"') + ..writeln('package="com.example.$_projectName"') ..writeln('xmlns:tools="http://schemas.android.com/tools">') ..writeln() ..writeln( @@ -165,7 +168,7 @@ class CreateAllPluginsAppCommand extends PackageCommand { final Map pluginDeps = await _getValidPathDependencies(); final Pubspec pubspec = Pubspec( - 'all_plugins', + _projectName, description: 'Flutter app containing all 1st party plugins.', version: Version.parse('1.0.0+1'), environment: { diff --git a/script/tool/lib/src/main.dart b/script/tool/lib/src/main.dart index 414ca7f303c0..2d48f079b306 100644 --- a/script/tool/lib/src/main.dart +++ b/script/tool/lib/src/main.dart @@ -11,7 +11,7 @@ import 'package:file/local.dart'; import 'analyze_command.dart'; import 'build_examples_command.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 'dependabot_check_command.dart'; import 'drive_examples_command.dart'; @@ -56,7 +56,7 @@ void main(List args) { 'Productivity utils for hosting multiple plugins within one repository.') ..addCommand(AnalyzeCommand(packagesDir)) ..addCommand(BuildExamplesCommand(packagesDir)) - ..addCommand(CreateAllPluginsAppCommand(packagesDir)) + ..addCommand(CreateAllPackagesAppCommand(packagesDir)) ..addCommand(CustomTestCommand(packagesDir)) ..addCommand(DependabotCheckCommand(packagesDir)) ..addCommand(DriveExamplesCommand(packagesDir)) diff --git a/script/tool/pubspec.yaml b/script/tool/pubspec.yaml index eecff3703b4c..fb1bbfe5978e 100644 --- a/script/tool/pubspec.yaml +++ b/script/tool/pubspec.yaml @@ -1,7 +1,7 @@ name: flutter_plugin_tools description: Productivity utils for flutter/plugins and flutter/packages repository: https://github.com/flutter/plugins/tree/main/script/tool -version: 0.12.1 +version: 0.13.0 dependencies: args: ^2.1.0 diff --git a/script/tool/test/create_all_plugins_app_command_test.dart b/script/tool/test/create_all_packages_app_command_test.dart similarity index 81% rename from script/tool/test/create_all_plugins_app_command_test.dart rename to script/tool/test/create_all_packages_app_command_test.dart index 830dd59a8d42..1bb4924b3ed2 100644 --- a/script/tool/test/create_all_plugins_app_command_test.dart +++ b/script/tool/test/create_all_packages_app_command_test.dart @@ -7,16 +7,16 @@ import 'dart:io' as io; import 'package:args/command_runner.dart'; import 'package:file/file.dart'; import 'package:file/local.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:test/test.dart'; import 'util.dart'; void main() { - group('$CreateAllPluginsAppCommand', () { + group('$CreateAllPackagesAppCommand', () { late CommandRunner runner; - late CreateAllPluginsAppCommand command; + late CreateAllPackagesAppCommand command; late FileSystem fileSystem; late Directory testRoot; late Directory packagesDir; @@ -29,12 +29,12 @@ void main() { testRoot = fileSystem.systemTempDirectory.createTempSync(); packagesDir = testRoot.childDirectory('packages'); - command = CreateAllPluginsAppCommand( + command = CreateAllPackagesAppCommand( packagesDir, pluginsRoot: testRoot, ); runner = CommandRunner( - 'create_all_test', 'Test for $CreateAllPluginsAppCommand'); + 'create_all_test', 'Test for $CreateAllPackagesAppCommand'); runner.addCommand(command); }); @@ -47,7 +47,7 @@ void main() { createFakePlugin('pluginb', packagesDir); createFakePlugin('pluginc', packagesDir); - await runCapturingPrint(runner, ['all-plugins-app']); + await runCapturingPrint(runner, ['create-all-packages-app']); final List pubspec = command.app.pubspecFile.readAsLinesSync(); expect( @@ -64,7 +64,7 @@ void main() { createFakePlugin('pluginb', packagesDir); createFakePlugin('pluginc', packagesDir); - await runCapturingPrint(runner, ['all-plugins-app']); + await runCapturingPrint(runner, ['create-all-packages-app']); final List pubspec = command.app.pubspecFile.readAsLinesSync(); expect( @@ -95,7 +95,7 @@ void main() { createFakePlugin('plugina', packagesDir); - await runCapturingPrint(runner, ['all-plugins-app']); + await runCapturingPrint(runner, ['create-all-packages-app']); final Pubspec generatedPubspec = command.app.parsePubspec(); const String dartSdkKey = 'sdk'; @@ -108,11 +108,13 @@ void main() { final Directory customOutputDir = fileSystem.systemTempDirectory.createTempSync(); - await runCapturingPrint(runner, - ['all-plugins-app', '--output-dir=${customOutputDir.path}']); + await runCapturingPrint(runner, [ + 'create-all-packages-app', + '--output-dir=${customOutputDir.path}' + ]); - expect( - command.app.path, customOutputDir.childDirectory('all_plugins').path); + expect(command.app.path, + customOutputDir.childDirectory('all_packages').path); }); test('logs exclusions', () async { @@ -120,8 +122,8 @@ void main() { createFakePlugin('pluginb', packagesDir); createFakePlugin('pluginc', packagesDir); - final List output = await runCapturingPrint( - runner, ['all-plugins-app', '--exclude=pluginb,pluginc']); + final List output = await runCapturingPrint(runner, + ['create-all-packages-app', '--exclude=pluginb,pluginc']); expect( output, From 959b7d410abd41e68739d94c3c5c709115e195a2 Mon Sep 17 00:00:00 2001 From: stuartmorgan Date: Thu, 27 Oct 2022 12:58:00 -0400 Subject: [PATCH 2/4] Typo --- .ci/scripts/create_all_plugins_app.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.ci/scripts/create_all_plugins_app.sh b/.ci/scripts/create_all_plugins_app.sh index eeba137045a9..100e8aca804a 100644 --- a/.ci/scripts/create_all_plugins_app.sh +++ b/.ci/scripts/create_all_plugins_app.sh @@ -3,5 +3,5 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. -dart ./script/tool/bin/flutter_plugin_tools.dart creat-all-packages-app \ +dart ./script/tool/bin/flutter_plugin_tools.dart create-all-packages-app \ --output-dir=. --exclude script/configs/exclude_all_plugins_app.yaml From 192966c677634cf489aef8ab5ce04a4ac77551b6 Mon Sep 17 00:00:00 2001 From: Stuart Morgan Date: Mon, 31 Oct 2022 11:13:01 -0400 Subject: [PATCH 3/4] Fix tests that were broken on macOS on HEAD --- .../create_all_packages_app_command_test.dart | 118 +++++++++++------- 1 file changed, 72 insertions(+), 46 deletions(-) diff --git a/script/tool/test/create_all_packages_app_command_test.dart b/script/tool/test/create_all_packages_app_command_test.dart index 90375c00906d..319aebaa55dc 100644 --- a/script/tool/test/create_all_packages_app_command_test.dart +++ b/script/tool/test/create_all_packages_app_command_test.dart @@ -16,26 +16,42 @@ import 'mocks.dart'; import 'util.dart'; void main() { - group('$CreateAllPackagesAppCommand', () { - late CommandRunner runner; - late CreateAllPackagesAppCommand command; - late FileSystem fileSystem; - late Directory testRoot; - late Directory packagesDir; - late RecordingProcessRunner processRunner; + late CommandRunner runner; + late CreateAllPackagesAppCommand command; + late FileSystem fileSystem; + late Directory testRoot; + late Directory packagesDir; + 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( + 'create_all_test', 'Test for $CreateAllPackagesAppCommand'); + runner.addCommand(command); + }); - 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(); + tearDown(() { + testRoot.deleteSync(recursive: true); + }); + group('linux host', () { + setUp(() { command = CreateAllPackagesAppCommand( packagesDir, processRunner: processRunner, + platform: MockPlatform(isLinux: true), pluginsRoot: testRoot, ); runner = CommandRunner( @@ -43,10 +59,6 @@ void main() { runner.addCommand(command); }); - tearDown(() { - testRoot.deleteSync(recursive: true); - }); - test('pubspec includes all plugins', () async { createFakePlugin('plugina', packagesDir); createFakePlugin('pluginb', packagesDir); @@ -108,33 +120,6 @@ void main() { baselinePubspec.environment?[dartSdkKey]); }); - test('macOS deployment target is modified in Podfile', () async { - createFakePlugin('plugina', packagesDir); - - final File podfileFile = command.packagesDir.parent - .childDirectory('all_packages') - .childDirectory('macos') - .childFile('Podfile'); - podfileFile.createSync(recursive: true); - podfileFile.writeAsStringSync(""" -platform :osx, '10.11' -# some other line -"""); - - await runCapturingPrint(runner, ['create-all-packages-app']); - final List 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 { createFakePlugin('plugina', packagesDir); @@ -224,4 +209,45 @@ platform :osx, '10.11' ])); }); }); + + group('macOS host', () { + setUp(() { + command = CreateAllPackagesAppCommand( + packagesDir, + processRunner: processRunner, + platform: MockPlatform(isMacOS: true), + pluginsRoot: testRoot, + ); + runner = CommandRunner( + '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, ['create-all-packages-app']); + final List 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); + }); } From 13f1d9c62a0fc43fb84c1d9d88e8e0ca622f65c6 Mon Sep 17 00:00:00 2001 From: Stuart Morgan Date: Mon, 31 Oct 2022 11:24:26 -0400 Subject: [PATCH 4/4] Fix Windows --- script/tool/test/create_all_packages_app_command_test.dart | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/script/tool/test/create_all_packages_app_command_test.dart b/script/tool/test/create_all_packages_app_command_test.dart index 319aebaa55dc..54551cbc3712 100644 --- a/script/tool/test/create_all_packages_app_command_test.dart +++ b/script/tool/test/create_all_packages_app_command_test.dart @@ -46,12 +46,15 @@ void main() { testRoot.deleteSync(recursive: true); }); - group('linux host', () { + group('non-macOS host', () { setUp(() { command = CreateAllPackagesAppCommand( packagesDir, processRunner: processRunner, - platform: MockPlatform(isLinux: true), + // 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, ); runner = CommandRunner(