diff --git a/packages/android_alarm_manager/example/pubspec.yaml b/packages/android_alarm_manager/example/pubspec.yaml index 78525345ab5c..e948ac2994ab 100644 --- a/packages/android_alarm_manager/example/pubspec.yaml +++ b/packages/android_alarm_manager/example/pubspec.yaml @@ -1,5 +1,6 @@ name: android_alarm_manager_example description: Demonstrates how to use the android_alarm_manager plugin. +publish_to: none dependencies: flutter: diff --git a/packages/android_intent/example/pubspec.yaml b/packages/android_intent/example/pubspec.yaml index fc154511dfa1..0104749828c8 100644 --- a/packages/android_intent/example/pubspec.yaml +++ b/packages/android_intent/example/pubspec.yaml @@ -1,5 +1,6 @@ name: android_intent_example description: Demonstrates how to use the android_intent plugin. +publish_to: none dependencies: flutter: diff --git a/packages/battery/battery/example/pubspec.yaml b/packages/battery/battery/example/pubspec.yaml index 648e9f578db6..a2a65278c037 100644 --- a/packages/battery/battery/example/pubspec.yaml +++ b/packages/battery/battery/example/pubspec.yaml @@ -1,5 +1,6 @@ name: battery_example description: Demonstrates how to use the battery plugin. +publish_to: none dependencies: flutter: diff --git a/packages/camera/camera/example/pubspec.yaml b/packages/camera/camera/example/pubspec.yaml index 5fdaf5812d72..0c06de9aea7e 100644 --- a/packages/camera/camera/example/pubspec.yaml +++ b/packages/camera/camera/example/pubspec.yaml @@ -1,5 +1,6 @@ name: camera_example description: Demonstrates how to use the camera plugin. +publish_to: none dependencies: camera: diff --git a/packages/connectivity/connectivity/example/pubspec.yaml b/packages/connectivity/connectivity/example/pubspec.yaml index 58d6f0ddca61..2eb69539e7fd 100644 --- a/packages/connectivity/connectivity/example/pubspec.yaml +++ b/packages/connectivity/connectivity/example/pubspec.yaml @@ -1,5 +1,6 @@ name: connectivity_example description: Demonstrates how to use the connectivity plugin. +publish_to: none dependencies: flutter: diff --git a/packages/connectivity/connectivity_macos/example/pubspec.yaml b/packages/connectivity/connectivity_macos/example/pubspec.yaml index d130158c4364..27baef73b30c 100644 --- a/packages/connectivity/connectivity_macos/example/pubspec.yaml +++ b/packages/connectivity/connectivity_macos/example/pubspec.yaml @@ -1,5 +1,6 @@ name: connectivity_example description: Demonstrates how to use the connectivity plugin. +publish_to: none dependencies: flutter: diff --git a/packages/device_info/device_info/example/pubspec.yaml b/packages/device_info/device_info/example/pubspec.yaml index 36b6d6e9441c..5c158a3398d0 100644 --- a/packages/device_info/device_info/example/pubspec.yaml +++ b/packages/device_info/device_info/example/pubspec.yaml @@ -1,5 +1,6 @@ name: device_info_example description: Demonstrates how to use the device_info plugin. +publish_to: none dependencies: flutter: diff --git a/packages/device_info/device_info_platform_interface/lib/model/android_device_info.dart b/packages/device_info/device_info_platform_interface/lib/model/android_device_info.dart index 961d373e2dea..b61dc14a0420 100644 --- a/packages/device_info/device_info_platform_interface/lib/model/android_device_info.dart +++ b/packages/device_info/device_info_platform_interface/lib/model/android_device_info.dart @@ -29,7 +29,7 @@ class AndroidDeviceInfo { required this.isPhysicalDevice, required this.androidId, required List systemFeatures, - }) : supported32BitAbis = List.unmodifiable(supported32BitAbis), + }) : supported32BitAbis = List.unmodifiable(supported32BitAbis), supported64BitAbis = List.unmodifiable(supported64BitAbis), supportedAbis = List.unmodifiable(supportedAbis), systemFeatures = List.unmodifiable(systemFeatures); diff --git a/packages/espresso/example/pubspec.yaml b/packages/espresso/example/pubspec.yaml index 6e824acb4080..fe40421fc1cf 100644 --- a/packages/espresso/example/pubspec.yaml +++ b/packages/espresso/example/pubspec.yaml @@ -1,6 +1,6 @@ name: espresso_example description: Demonstrates how to use the espresso plugin. -publish_to: 'none' +publish_to: none environment: sdk: ">=2.12.0-259.9.beta <3.0.0" diff --git a/packages/file_selector/file_selector/example/pubspec.yaml b/packages/file_selector/file_selector/example/pubspec.yaml index 580237cad5ac..b2bbbb0d3e92 100644 --- a/packages/file_selector/file_selector/example/pubspec.yaml +++ b/packages/file_selector/file_selector/example/pubspec.yaml @@ -1,7 +1,6 @@ name: example description: A new Flutter project. - -publish_to: 'none' # Remove this line if you wish to publish to pub.dev +publish_to: none version: 1.0.0+1 diff --git a/packages/flutter_plugin_android_lifecycle/example/pubspec.yaml b/packages/flutter_plugin_android_lifecycle/example/pubspec.yaml index 4506437b1180..e0d225c032f4 100644 --- a/packages/flutter_plugin_android_lifecycle/example/pubspec.yaml +++ b/packages/flutter_plugin_android_lifecycle/example/pubspec.yaml @@ -1,5 +1,6 @@ name: flutter_plugin_android_lifecycle_example description: Demonstrates how to use the flutter_plugin_android_lifecycle plugin. +publish_to: none dependencies: flutter: diff --git a/packages/google_maps_flutter/google_maps_flutter/example/pubspec.yaml b/packages/google_maps_flutter/google_maps_flutter/example/pubspec.yaml index eb06e09a8757..0035c96d69ab 100644 --- a/packages/google_maps_flutter/google_maps_flutter/example/pubspec.yaml +++ b/packages/google_maps_flutter/google_maps_flutter/example/pubspec.yaml @@ -1,5 +1,6 @@ name: google_maps_flutter_example description: Demonstrates how to use the google_maps_flutter plugin. +publish_to: none environment: sdk: '>=2.12.0-259.9.beta <3.0.0' diff --git a/packages/google_maps_flutter/google_maps_flutter_web/lib/src/circles.dart b/packages/google_maps_flutter/google_maps_flutter_web/lib/src/circles.dart index 2a19d87adfec..ae8faa038ea6 100644 --- a/packages/google_maps_flutter/google_maps_flutter_web/lib/src/circles.dart +++ b/packages/google_maps_flutter/google_maps_flutter_web/lib/src/circles.dart @@ -15,7 +15,7 @@ class CirclesController extends GeometryController { /// Initialize the cache. The [StreamController] comes from the [GoogleMapController], and is shared with other controllers. CirclesController({ required StreamController stream, - }) : _streamController = stream, + }) : _streamController = stream, _circleIdToController = Map(); /// Returns the cache of [CircleController]s. Test only. diff --git a/packages/google_maps_flutter/google_maps_flutter_web/lib/src/markers.dart b/packages/google_maps_flutter/google_maps_flutter_web/lib/src/markers.dart index 704577b6e3fb..b650b9bcf1c8 100644 --- a/packages/google_maps_flutter/google_maps_flutter_web/lib/src/markers.dart +++ b/packages/google_maps_flutter/google_maps_flutter_web/lib/src/markers.dart @@ -15,7 +15,7 @@ class MarkersController extends GeometryController { /// Initialize the cache. The [StreamController] comes from the [GoogleMapController], and is shared with other controllers. MarkersController({ required StreamController stream, - }) : _streamController = stream, + }) : _streamController = stream, _markerIdToController = Map(); /// Returns the cache of [MarkerController]s. Test only. diff --git a/packages/google_maps_flutter/google_maps_flutter_web/lib/src/polygons.dart b/packages/google_maps_flutter/google_maps_flutter_web/lib/src/polygons.dart index ef51bd6043df..8a9643156351 100644 --- a/packages/google_maps_flutter/google_maps_flutter_web/lib/src/polygons.dart +++ b/packages/google_maps_flutter/google_maps_flutter_web/lib/src/polygons.dart @@ -15,7 +15,7 @@ class PolygonsController extends GeometryController { /// Initializes the cache. The [StreamController] comes from the [GoogleMapController], and is shared with other controllers. PolygonsController({ required StreamController stream, - }) : _streamController = stream, + }) : _streamController = stream, _polygonIdToController = Map(); /// Returns the cache of [PolygonController]s. Test only. diff --git a/packages/google_maps_flutter/google_maps_flutter_web/lib/src/polylines.dart b/packages/google_maps_flutter/google_maps_flutter_web/lib/src/polylines.dart index 184c0d954744..695b29554c04 100644 --- a/packages/google_maps_flutter/google_maps_flutter_web/lib/src/polylines.dart +++ b/packages/google_maps_flutter/google_maps_flutter_web/lib/src/polylines.dart @@ -15,7 +15,7 @@ class PolylinesController extends GeometryController { /// Initializes the cache. The [StreamController] comes from the [GoogleMapController], and is shared with other controllers. PolylinesController({ required StreamController stream, - }) : _streamController = stream, + }) : _streamController = stream, _polylineIdToController = Map(); /// Returns the cache of [PolylineContrller]s. Test only. diff --git a/packages/google_sign_in/google_sign_in/example/pubspec.yaml b/packages/google_sign_in/google_sign_in/example/pubspec.yaml index f08a131e484a..721e77e64e68 100755 --- a/packages/google_sign_in/google_sign_in/example/pubspec.yaml +++ b/packages/google_sign_in/google_sign_in/example/pubspec.yaml @@ -1,5 +1,6 @@ name: google_sign_in_example description: Example of Google Sign-In plugin. +publish_to: none dependencies: flutter: diff --git a/packages/image_picker/image_picker/example/pubspec.yaml b/packages/image_picker/image_picker/example/pubspec.yaml index b2e5b6399f47..a52b0f5c0f88 100755 --- a/packages/image_picker/image_picker/example/pubspec.yaml +++ b/packages/image_picker/image_picker/example/pubspec.yaml @@ -1,6 +1,6 @@ name: image_picker_example description: Demonstrates how to use the image_picker plugin. -author: Flutter Team +publish_to: none dependencies: video_player: ^2.0.0-nullsafety.7 diff --git a/packages/in_app_purchase/in_app_purchase/example/pubspec.yaml b/packages/in_app_purchase/in_app_purchase/example/pubspec.yaml index 8d193debb826..6625cb92e77c 100644 --- a/packages/in_app_purchase/in_app_purchase/example/pubspec.yaml +++ b/packages/in_app_purchase/in_app_purchase/example/pubspec.yaml @@ -1,6 +1,6 @@ name: in_app_purchase_example description: Demonstrates how to use the in_app_purchase plugin. -author: Flutter Team +publish_to: none dependencies: flutter: diff --git a/packages/integration_test/example/pubspec.yaml b/packages/integration_test/example/pubspec.yaml index 558d5f7bc1a1..e39f11539af5 100644 --- a/packages/integration_test/example/pubspec.yaml +++ b/packages/integration_test/example/pubspec.yaml @@ -1,6 +1,6 @@ name: integration_test_example description: Demonstrates how to use the integration_test plugin. -publish_to: 'none' +publish_to: none environment: sdk: ">=2.1.0 <3.0.0" diff --git a/packages/ios_platform_images/example/pubspec.yaml b/packages/ios_platform_images/example/pubspec.yaml index 552790ea74af..e87dd59d25ae 100644 --- a/packages/ios_platform_images/example/pubspec.yaml +++ b/packages/ios_platform_images/example/pubspec.yaml @@ -1,6 +1,6 @@ name: ios_platform_images_example description: Demonstrates how to use the ios_platform_images plugin. -publish_to: 'none' +publish_to: none homepage: https://github.com/flutter/plugins/tree/master/packages/ios_platform_images/ios_platform_images environment: diff --git a/packages/local_auth/example/pubspec.yaml b/packages/local_auth/example/pubspec.yaml index aad68c59f930..7cc6b392e21e 100644 --- a/packages/local_auth/example/pubspec.yaml +++ b/packages/local_auth/example/pubspec.yaml @@ -1,5 +1,6 @@ name: local_auth_example description: Demonstrates how to use the local_auth plugin. +publish_to: none dependencies: flutter: diff --git a/packages/package_info/example/pubspec.yaml b/packages/package_info/example/pubspec.yaml index 0e47ad232eaa..139b9e211449 100644 --- a/packages/package_info/example/pubspec.yaml +++ b/packages/package_info/example/pubspec.yaml @@ -1,5 +1,6 @@ name: package_info_example description: Demonstrates how to use the package_info plugin. +publish_to: none dependencies: flutter: diff --git a/packages/path_provider/path_provider/example/pubspec.yaml b/packages/path_provider/path_provider/example/pubspec.yaml index 326c68e0e3e5..6ebde4342e7f 100644 --- a/packages/path_provider/path_provider/example/pubspec.yaml +++ b/packages/path_provider/path_provider/example/pubspec.yaml @@ -1,5 +1,6 @@ name: path_provider_example description: Demonstrates how to use the path_provider plugin. +publish_to: none dependencies: flutter: diff --git a/packages/path_provider/path_provider_macos/example/pubspec.yaml b/packages/path_provider/path_provider_macos/example/pubspec.yaml index 1451dea36362..f91678c1fb2a 100644 --- a/packages/path_provider/path_provider_macos/example/pubspec.yaml +++ b/packages/path_provider/path_provider_macos/example/pubspec.yaml @@ -1,5 +1,6 @@ name: path_provider_example description: Demonstrates how to use the path_provider plugin. +publish_to: none dependencies: flutter: diff --git a/packages/path_provider/path_provider_windows/example/pubspec.yaml b/packages/path_provider/path_provider_windows/example/pubspec.yaml index 29e228d0fd19..8843e2d770ff 100644 --- a/packages/path_provider/path_provider_windows/example/pubspec.yaml +++ b/packages/path_provider/path_provider_windows/example/pubspec.yaml @@ -1,5 +1,6 @@ name: path_provider_example description: Demonstrates how to use the path_provider plugin. +publish_to: none dependencies: flutter: diff --git a/packages/quick_actions/quick_actions/example/pubspec.yaml b/packages/quick_actions/quick_actions/example/pubspec.yaml index b26f8432e9ad..391b4c35e94c 100644 --- a/packages/quick_actions/quick_actions/example/pubspec.yaml +++ b/packages/quick_actions/quick_actions/example/pubspec.yaml @@ -1,5 +1,6 @@ name: quick_actions_example description: Demonstrates how to use the quick_actions plugin. +publish_to: none dependencies: flutter: diff --git a/packages/sensors/example/lib/snake.dart b/packages/sensors/example/lib/snake.dart index 47177681020f..afa12e377c48 100644 --- a/packages/sensors/example/lib/snake.dart +++ b/packages/sensors/example/lib/snake.dart @@ -99,10 +99,10 @@ class SnakeState extends State { final math.Point? newDirection = currentAcceleration == null ? null : currentAcceleration.x.abs() < 1.0 && currentAcceleration.y.abs() < 1.0 - ? null - : (currentAcceleration.x.abs() < currentAcceleration.y.abs()) - ? math.Point(0, currentAcceleration.y.sign.toInt()) - : math.Point(-currentAcceleration.x.sign.toInt(), 0); + ? null + : (currentAcceleration.x.abs() < currentAcceleration.y.abs()) + ? math.Point(0, currentAcceleration.y.sign.toInt()) + : math.Point(-currentAcceleration.x.sign.toInt(), 0); state.step(newDirection); } } diff --git a/packages/sensors/example/pubspec.yaml b/packages/sensors/example/pubspec.yaml index 7d8effbcce87..884ebbb837af 100644 --- a/packages/sensors/example/pubspec.yaml +++ b/packages/sensors/example/pubspec.yaml @@ -1,5 +1,6 @@ name: sensors_example description: Demonstrates how to use the sensors plugin. +publish_to: none dependencies: flutter: diff --git a/packages/share/example/pubspec.yaml b/packages/share/example/pubspec.yaml index 378e25bc9c75..31deb1f77230 100644 --- a/packages/share/example/pubspec.yaml +++ b/packages/share/example/pubspec.yaml @@ -1,5 +1,6 @@ name: share_example description: Demonstrates how to use the share plugin. +publish_to: none dependencies: flutter: diff --git a/packages/shared_preferences/shared_preferences/example/pubspec.yaml b/packages/shared_preferences/shared_preferences/example/pubspec.yaml index 7a7b1ac7402f..c3454a573c5b 100644 --- a/packages/shared_preferences/shared_preferences/example/pubspec.yaml +++ b/packages/shared_preferences/shared_preferences/example/pubspec.yaml @@ -1,5 +1,6 @@ name: shared_preferences_example description: Demonstrates how to use the shared_preferences plugin. +publish_to: none dependencies: flutter: diff --git a/packages/shared_preferences/shared_preferences_linux/example/pubspec.yaml b/packages/shared_preferences/shared_preferences_linux/example/pubspec.yaml index a3a3cbced044..8b2c3933d03d 100644 --- a/packages/shared_preferences/shared_preferences_linux/example/pubspec.yaml +++ b/packages/shared_preferences/shared_preferences_linux/example/pubspec.yaml @@ -1,5 +1,6 @@ name: shared_preferences_linux_example description: Demonstrates how to use the shared_preferences_linux plugin. +publish_to: none dependencies: flutter: diff --git a/packages/shared_preferences/shared_preferences_macos/example/pubspec.yaml b/packages/shared_preferences/shared_preferences_macos/example/pubspec.yaml index 8ad710c6b984..c64fda7db00b 100644 --- a/packages/shared_preferences/shared_preferences_macos/example/pubspec.yaml +++ b/packages/shared_preferences/shared_preferences_macos/example/pubspec.yaml @@ -1,5 +1,6 @@ name: shared_preferences_example description: Demonstrates how to use the shared_preferences plugin. +publish_to: none dependencies: flutter: diff --git a/packages/shared_preferences/shared_preferences_windows/example/pubspec.yaml b/packages/shared_preferences/shared_preferences_windows/example/pubspec.yaml index e83598703a4b..db6401c53fcf 100644 --- a/packages/shared_preferences/shared_preferences_windows/example/pubspec.yaml +++ b/packages/shared_preferences/shared_preferences_windows/example/pubspec.yaml @@ -1,5 +1,6 @@ name: shared_preferences_windows_example description: Demonstrates how to use the shared_preferences_windows plugin. +publish_to: none environment: sdk: ">=2.12.0-259.9.beta <3.0.0" diff --git a/packages/url_launcher/url_launcher/example/pubspec.yaml b/packages/url_launcher/url_launcher/example/pubspec.yaml index 4ab235328e46..e56f76f977db 100644 --- a/packages/url_launcher/url_launcher/example/pubspec.yaml +++ b/packages/url_launcher/url_launcher/example/pubspec.yaml @@ -1,5 +1,6 @@ name: url_launcher_example description: Demonstrates how to use the url_launcher plugin. +publish_to: none dependencies: flutter: diff --git a/packages/url_launcher/url_launcher_linux/example/pubspec.yaml b/packages/url_launcher/url_launcher_linux/example/pubspec.yaml index e0c59fbbde54..389f3fd82110 100644 --- a/packages/url_launcher/url_launcher_linux/example/pubspec.yaml +++ b/packages/url_launcher/url_launcher_linux/example/pubspec.yaml @@ -1,5 +1,6 @@ name: url_launcher_example description: Demonstrates how to use the url_launcher plugin. +publish_to: none dependencies: flutter: diff --git a/packages/url_launcher/url_launcher_macos/example/pubspec.yaml b/packages/url_launcher/url_launcher_macos/example/pubspec.yaml index 595d1bc30dae..2e221dc061fb 100644 --- a/packages/url_launcher/url_launcher_macos/example/pubspec.yaml +++ b/packages/url_launcher/url_launcher_macos/example/pubspec.yaml @@ -1,5 +1,6 @@ name: url_launcher_example description: Demonstrates how to use the url_launcher plugin. +publish_to: none dependencies: flutter: diff --git a/packages/url_launcher/url_launcher_windows/example/pubspec.yaml b/packages/url_launcher/url_launcher_windows/example/pubspec.yaml index 86ceeecc369f..a0fecd5919b8 100644 --- a/packages/url_launcher/url_launcher_windows/example/pubspec.yaml +++ b/packages/url_launcher/url_launcher_windows/example/pubspec.yaml @@ -1,5 +1,6 @@ name: url_launcher_example description: Demonstrates the Windows implementation of the url_launcher plugin. +publish_to: none dependencies: flutter: diff --git a/packages/video_player/video_player/example/pubspec.yaml b/packages/video_player/video_player/example/pubspec.yaml index 354f3d18df00..6386a2beedf8 100644 --- a/packages/video_player/video_player/example/pubspec.yaml +++ b/packages/video_player/video_player/example/pubspec.yaml @@ -1,6 +1,5 @@ name: video_player_example description: Demonstrates how to use the video_player plugin. -version: 0.0.1 publish_to: none dependencies: diff --git a/packages/webview_flutter/example/pubspec.yaml b/packages/webview_flutter/example/pubspec.yaml index b70674197901..84e916372143 100644 --- a/packages/webview_flutter/example/pubspec.yaml +++ b/packages/webview_flutter/example/pubspec.yaml @@ -1,5 +1,6 @@ name: webview_flutter_example description: Demonstrates how to use the webview_flutter plugin. +publish_to: none environment: sdk: ">=2.12.0-259.9.beta <3.0.0" diff --git a/packages/webview_flutter/lib/webview_flutter.dart b/packages/webview_flutter/lib/webview_flutter.dart index 92ff8e00a50e..74d8af8d4687 100644 --- a/packages/webview_flutter/lib/webview_flutter.dart +++ b/packages/webview_flutter/lib/webview_flutter.dart @@ -180,7 +180,7 @@ class JavascriptChannel { JavascriptChannel({ required this.name, required this.onMessageReceived, - }) : assert(name != null), + }) : assert(name != null), assert(onMessageReceived != null), assert(_validChannelNames.hasMatch(name)); diff --git a/packages/wifi_info_flutter/wifi_info_flutter/example/pubspec.yaml b/packages/wifi_info_flutter/wifi_info_flutter/example/pubspec.yaml index 57edbe86daea..108bd398c7b6 100644 --- a/packages/wifi_info_flutter/wifi_info_flutter/example/pubspec.yaml +++ b/packages/wifi_info_flutter/wifi_info_flutter/example/pubspec.yaml @@ -1,6 +1,6 @@ name: wifi_info_flutter_example description: Demonstrates how to use the wifi_info_flutter plugin. -publish_to: 'none' +publish_to: none environment: sdk: ">=2.12.0-259.9.beta <3.0.0" diff --git a/script/tool/lib/src/common.dart b/script/tool/lib/src/common.dart index fc1fdca6a1cd..d8826c793088 100644 --- a/script/tool/lib/src/common.dart +++ b/script/tool/lib/src/common.dart @@ -596,10 +596,18 @@ class GitVersionFinder { return changedFiles.toList(); } - /// Get the package version specified in the pubspec file in `pubspecPath` and at the revision of `gitRef`. - Future getPackageVersion(String pubspecPath, String gitRef) async { - final io.ProcessResult gitShow = - await baseGitDir.runCommand(['show', '$gitRef:$pubspecPath']); + /// Get the package version specified in the pubspec file in `pubspecPath` and + /// at the revision of `gitRef` (defaulting to the base if not provided). + Future getPackageVersion(String pubspecPath, {String gitRef}) async { + final String ref = gitRef ?? (await _getBaseSha()); + + io.ProcessResult gitShow; + try { + gitShow = + await baseGitDir.runCommand(['show', '$ref:$pubspecPath']); + } on io.ProcessException { + return null; + } final String fileContent = gitShow.stdout as String; final String versionString = loadYaml(fileContent)['version'] as String; return versionString == null ? null : Version.parse(versionString); diff --git a/script/tool/lib/src/version_check_command.dart b/script/tool/lib/src/version_check_command.dart index 086fa548880f..14dc8fb28ef8 100644 --- a/script/tool/lib/src/version_check_command.dart +++ b/script/tool/lib/src/version_check_command.dart @@ -13,8 +13,6 @@ import 'package:pubspec_parse/pubspec_parse.dart'; import 'common.dart'; -const String _kBaseSha = 'base-sha'; - /// Categories of version change types. enum NextVersionType { /// A breaking change. @@ -96,48 +94,59 @@ class VersionCheckCommand extends PluginCommand { final List changedPubspecs = await gitVersionFinder.getChangedPubSpecs(); - final String baseSha = argResults[_kBaseSha] as String; + const String indentation = ' '; for (final String pubspecPath in changedPubspecs) { - try { - final File pubspecFile = fileSystem.file(pubspecPath); - if (!pubspecFile.existsSync()) { - continue; - } - final Pubspec pubspec = Pubspec.parse(pubspecFile.readAsStringSync()); - if (pubspec.publishTo == 'none') { - continue; - } + print('Checking versions for $pubspecPath...'); + final File pubspecFile = fileSystem.file(pubspecPath); + if (!pubspecFile.existsSync()) { + print('${indentation}Deleted; skipping.'); + continue; + } + final Pubspec pubspec = Pubspec.parse(pubspecFile.readAsStringSync()); + if (pubspec.publishTo == 'none') { + print('${indentation}Found "publish_to: none"; skipping.'); + continue; + } - final Version masterVersion = - await gitVersionFinder.getPackageVersion(pubspecPath, baseSha); - final Version headVersion = - await gitVersionFinder.getPackageVersion(pubspecPath, 'HEAD'); - if (headVersion == null) { - continue; // Example apps don't have versions - } + final Version headVersion = + await gitVersionFinder.getPackageVersion(pubspecPath, gitRef: 'HEAD'); + if (headVersion == null) { + printErrorAndExit( + errorMessage: '${indentation}No version found. A package that ' + 'intentionally has no version should be marked ' + '"publish_to: none".'); + } + final Version masterVersion = + await gitVersionFinder.getPackageVersion(pubspecPath); + if (masterVersion == null) { + print('${indentation}Unable to find pubspec in master. ' + 'Safe to ignore if the project is new.'); + } - final Map allowedNextVersions = - getAllowedNextVersions(masterVersion, headVersion); + if (masterVersion == headVersion) { + print('${indentation}No version change.'); + continue; + } - if (!allowedNextVersions.containsKey(headVersion)) { - final String error = '$pubspecPath incorrectly updated version.\n' - 'HEAD: $headVersion, master: $masterVersion.\n' - 'Allowed versions: $allowedNextVersions'; - printErrorAndExit(errorMessage: error); - } + final Map allowedNextVersions = + getAllowedNextVersions(masterVersion, headVersion); - final bool isPlatformInterface = - pubspec.name.endsWith('_platform_interface'); - if (isPlatformInterface && - allowedNextVersions[headVersion] == - NextVersionType.BREAKING_MAJOR) { - final String error = '$pubspecPath breaking change detected.\n' - 'Breaking changes to platform interfaces are strongly discouraged.\n'; - printErrorAndExit(errorMessage: error); - } - } on io.ProcessException { - print('Unable to find pubspec in master for $pubspecPath.' - ' Safe to ignore if the project is new.'); + if (!allowedNextVersions.containsKey(headVersion)) { + final String error = '${indentation}Incorrectly updated version.\n' + '${indentation}HEAD: $headVersion, master: $masterVersion.\n' + '${indentation}Allowed versions: $allowedNextVersions'; + printErrorAndExit(errorMessage: error); + } else { + print('$indentation$headVersion -> $masterVersion'); + } + + final bool isPlatformInterface = + pubspec.name.endsWith('_platform_interface'); + if (isPlatformInterface && + allowedNextVersions[headVersion] == NextVersionType.BREAKING_MAJOR) { + final String error = '$pubspecPath breaking change detected.\n' + 'Breaking changes to platform interfaces are strongly discouraged.\n'; + printErrorAndExit(errorMessage: error); } } @@ -153,7 +162,7 @@ class VersionCheckCommand extends PluginCommand { final String packageName = plugin.basename; print('-----------------------------------------'); print( - 'Checking the first version listed in CHANGELOG.MD matches the version in pubspec.yaml for $packageName.'); + 'Checking the first version listed in CHANGELOG.md matches the version in pubspec.yaml for $packageName.'); final Pubspec pubspec = _tryParsePubspec(plugin); if (pubspec == null) { @@ -169,12 +178,29 @@ class VersionCheckCommand extends PluginCommand { final Iterator iterator = lines.iterator; while (iterator.moveNext()) { if (iterator.current.trim().isNotEmpty) { - firstLineWithText = iterator.current; + firstLineWithText = iterator.current.trim(); break; } } // Remove all leading mark down syntax from the version line. - final String versionString = firstLineWithText.split(' ').last; + String versionString = firstLineWithText.split(' ').last; + + // Skip validation for the special NEXT version that's used to accumulate + // changes that don't warrant publishing on their own. + bool hasNextSection = versionString == 'NEXT'; + if (hasNextSection) { + print('Found NEXT; validating next version in the CHANGELOG.'); + // Ensure that the version in pubspec hasn't changed without updating + // CHANGELOG. That means the next version entry in the CHANGELOG pass the + // normal validation. + while (iterator.moveNext()) { + if (iterator.current.trim().startsWith('## ')) { + versionString = iterator.current.trim().split(' ').last; + break; + } + } + } + final Version fromChangeLog = Version.parse(versionString); if (fromChangeLog == null) { final String error = @@ -190,6 +216,18 @@ The first version listed in CHANGELOG.md is $fromChangeLog. '''; printErrorAndExit(errorMessage: error); } + + // If NEXT wasn't the first section, it should not exist at all. + if (!hasNextSection) { + final RegExp nextRegex = RegExp(r'^#+\s*NEXT\s*$'); + if (lines.any((String line) => nextRegex.hasMatch(line))) { + printErrorAndExit(errorMessage: ''' +When bumping the version for release, the NEXT section should be incorporated +into the new version's release notes. + '''); + } + } + print('$packageName passed version check'); } diff --git a/script/tool/pubspec.yaml b/script/tool/pubspec.yaml index e47123959005..9260e8f48fa3 100644 --- a/script/tool/pubspec.yaml +++ b/script/tool/pubspec.yaml @@ -1,6 +1,6 @@ name: flutter_plugin_tools description: Productivity utils for hosting multiple plugins within one repository. -publish_to: 'none' +publish_to: none dependencies: args: "^1.4.3" diff --git a/script/tool/test/version_check_test.dart b/script/tool/test/version_check_test.dart index 96a460d7e729..ed953e0b7fa4 100644 --- a/script/tool/test/version_check_test.dart +++ b/script/tool/test/version_check_test.dart @@ -62,6 +62,8 @@ void main() { final String response = gitShowResponses[invocation.positionalArguments[0][1]]; when(mockProcessResult.stdout as String).thenReturn(response); + } else if (invocation.positionalArguments[0][0] == 'merge-base') { + when(mockProcessResult.stdout as String).thenReturn('abc123'); } return Future.value(mockProcessResult); }); @@ -98,11 +100,12 @@ void main() { ); expect(gitDirCommands.length, equals(3)); expect( - gitDirCommands[0].join(' '), equals('diff --name-only master HEAD')); - expect(gitDirCommands[1].join(' '), - equals('show master:packages/plugin/pubspec.yaml')); - expect(gitDirCommands[2].join(' '), - equals('show HEAD:packages/plugin/pubspec.yaml')); + gitDirCommands, + containsAll([ + equals(['diff', '--name-only', 'master', 'HEAD']), + equals(['show', 'master:packages/plugin/pubspec.yaml']), + equals(['show', 'HEAD:packages/plugin/pubspec.yaml']), + ])); }); test('denies invalid version', () async { @@ -117,15 +120,50 @@ void main() { await expectLater( result, - throwsA(const TypeMatcher()), + throwsA(const TypeMatcher()), ); expect(gitDirCommands.length, equals(3)); expect( - gitDirCommands[0].join(' '), equals('diff --name-only master HEAD')); - expect(gitDirCommands[1].join(' '), - equals('show master:packages/plugin/pubspec.yaml')); - expect(gitDirCommands[2].join(' '), - equals('show HEAD:packages/plugin/pubspec.yaml')); + gitDirCommands, + containsAll([ + equals(['diff', '--name-only', 'master', 'HEAD']), + equals(['show', 'master:packages/plugin/pubspec.yaml']), + equals(['show', 'HEAD:packages/plugin/pubspec.yaml']), + ])); + }); + + test('allows valid version without explicit base-sha', () async { + createFakePlugin('plugin', includeChangeLog: true, includeVersion: true); + gitDiffResponse = 'packages/plugin/pubspec.yaml'; + gitShowResponses = { + 'abc123:packages/plugin/pubspec.yaml': 'version: 1.0.0', + 'HEAD:packages/plugin/pubspec.yaml': 'version: 2.0.0', + }; + final List output = + await runCapturingPrint(runner, ['version-check']); + + expect( + output, + containsAllInOrder([ + 'No version check errors found!', + ]), + ); + }); + + test('denies invalid version without explicit base-sha', () async { + createFakePlugin('plugin', includeChangeLog: true, includeVersion: true); + gitDiffResponse = 'packages/plugin/pubspec.yaml'; + gitShowResponses = { + 'abc123:packages/plugin/pubspec.yaml': 'version: 0.0.1', + 'HEAD:packages/plugin/pubspec.yaml': 'version: 0.2.0', + }; + final Future> result = + runCapturingPrint(runner, ['version-check']); + + await expectLater( + result, + throwsA(const TypeMatcher()), + ); }); test('gracefully handles missing pubspec.yaml', () async { @@ -143,6 +181,8 @@ void main() { output, orderedEquals([ 'Determine diff with base sha: master', + 'Checking versions for packages/plugin/pubspec.yaml...', + ' Deleted; skipping.', 'No version check errors found!', ]), ); @@ -171,13 +211,18 @@ void main() { ); expect(gitDirCommands.length, equals(3)); expect( - gitDirCommands[0].join(' '), equals('diff --name-only master HEAD')); - expect( - gitDirCommands[1].join(' '), - equals( - 'show master:packages/plugin_platform_interface/pubspec.yaml')); - expect(gitDirCommands[2].join(' '), - equals('show HEAD:packages/plugin_platform_interface/pubspec.yaml')); + gitDirCommands, + containsAll([ + equals(['diff', '--name-only', 'master', 'HEAD']), + equals([ + 'show', + 'master:packages/plugin_platform_interface/pubspec.yaml' + ]), + equals([ + 'show', + 'HEAD:packages/plugin_platform_interface/pubspec.yaml' + ]), + ])); }); test('disallows breaking changes to platform interfaces', () async { @@ -194,17 +239,22 @@ void main() { runner, ['version-check', '--base-sha=master']); await expectLater( output, - throwsA(const TypeMatcher()), + throwsA(const TypeMatcher()), ); expect(gitDirCommands.length, equals(3)); expect( - gitDirCommands[0].join(' '), equals('diff --name-only master HEAD')); - expect( - gitDirCommands[1].join(' '), - equals( - 'show master:packages/plugin_platform_interface/pubspec.yaml')); - expect(gitDirCommands[2].join(' '), - equals('show HEAD:packages/plugin_platform_interface/pubspec.yaml')); + gitDirCommands, + containsAll([ + equals(['diff', '--name-only', 'master', 'HEAD']), + equals([ + 'show', + 'master:packages/plugin_platform_interface/pubspec.yaml' + ]), + equals([ + 'show', + 'HEAD:packages/plugin_platform_interface/pubspec.yaml' + ]), + ])); }); test('Allow empty lines in front of the first version in CHANGELOG', @@ -230,7 +280,7 @@ void main() { expect( output, containsAllInOrder([ - 'Checking the first version listed in CHANGELOG.MD matches the version in pubspec.yaml for plugin.', + 'Checking the first version listed in CHANGELOG.md matches the version in pubspec.yaml for plugin.', 'plugin passed version check', 'No version check errors found!' ]), @@ -255,7 +305,7 @@ void main() { runner, ['version-check', '--base-sha=master']); await expectLater( output, - throwsA(const TypeMatcher()), + throwsA(const TypeMatcher()), ); try { final List outputValue = await output; @@ -291,7 +341,7 @@ void main() { expect( output, containsAllInOrder([ - 'Checking the first version listed in CHANGELOG.MD matches the version in pubspec.yaml for plugin.', + 'Checking the first version listed in CHANGELOG.md matches the version in pubspec.yaml for plugin.', 'plugin passed version check', 'No version check errors found!' ]), @@ -322,7 +372,121 @@ void main() { runner, ['version-check', '--base-sha=master']); await expectLater( output, - throwsA(const TypeMatcher()), + throwsA(const TypeMatcher()), + ); + try { + final List outputValue = await output; + await expectLater( + outputValue, + containsAllInOrder([ + ''' + versions for plugin in CHANGELOG.md and pubspec.yaml do not match. + The version in pubspec.yaml is 1.0.0. + The first version listed in CHANGELOG.md is 1.0.1. + ''', + ]), + ); + } on ToolExit catch (_) {} + }); + + test('Allow NEXT as a placeholder for gathering CHANGELOG entries', + () async { + createFakePlugin('plugin', includeChangeLog: true, includeVersion: true); + + final Directory pluginDirectory = + mockPackagesDir.childDirectory('plugin'); + + createFakePubspec(pluginDirectory, + isFlutter: true, includeVersion: true, version: '1.0.0'); + const String changelog = ''' +## NEXT + +* Some changes that won't be published until the next time there's a release. + +## 1.0.0 + +* Some other changes. +'''; + createFakeCHANGELOG(pluginDirectory, changelog); + final List output = await runCapturingPrint( + runner, ['version-check', '--base-sha=master']); + await expectLater( + output, + containsAllInOrder([ + 'Found NEXT; validating next version in the CHANGELOG.', + 'plugin passed version check', + 'No version check errors found!', + ]), + ); + }); + + test('Fail if NEXT is left in the CHANGELOG when adding a version bump', + () async { + createFakePlugin('plugin', includeChangeLog: true, includeVersion: true); + + final Directory pluginDirectory = + mockPackagesDir.childDirectory('plugin'); + + createFakePubspec(pluginDirectory, + isFlutter: true, includeVersion: true, version: '1.0.1'); + const String changelog = ''' +## 1.0.1 + +* Some changes. + +## NEXT + +* Some changes that should have been folded in 1.0.1. + +## 1.0.0 + +* Some other changes. +'''; + createFakeCHANGELOG(pluginDirectory, changelog); + final Future> output = runCapturingPrint( + runner, ['version-check', '--base-sha=master']); + await expectLater( + output, + throwsA(const TypeMatcher()), + ); + try { + final List outputValue = await output; + await expectLater( + outputValue, + containsAllInOrder([ + ''' + versions for plugin in CHANGELOG.md and pubspec.yaml do not match. + The version in pubspec.yaml is 1.0.0. + The first version listed in CHANGELOG.md is 1.0.1. + ''', + ]), + ); + } on ToolExit catch (_) {} + }); + + test('Fail if the version changes without replacing NEXT', () async { + createFakePlugin('plugin', includeChangeLog: true, includeVersion: true); + + final Directory pluginDirectory = + mockPackagesDir.childDirectory('plugin'); + + createFakePubspec(pluginDirectory, + isFlutter: true, includeVersion: true, version: '1.0.1'); + const String changelog = ''' +## NEXT + +* Some changes that should be listed as part of 1.0.1. + +## 1.0.0 + +* Some other changes. +'''; + createFakeCHANGELOG(pluginDirectory, changelog); + final Future> output = runCapturingPrint( + runner, ['version-check', '--base-sha=master']); + await expectLater( + output, + throwsA(const TypeMatcher()), ); try { final List outputValue = await output;