Skip to content

Instantly share code, notes, and snippets.

@mono0926
Last active January 12, 2024 12:32
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mono0926/c1f959cb05328e7f19da0bd275a282e0 to your computer and use it in GitHub Desktop.
Save mono0926/c1f959cb05328e7f19da0bd275a282e0 to your computer and use it in GitHub Desktop.
import 'package:collection/collection.dart';
import 'package:grinder/grinder.dart';
void main(List<String> args) => grind(args);
@Task('Open Upgraded Package Changelog')
void openUpgradedPackageChangelog() {
_openUpgradedPackageChangelog(
[
'.',
'packages/admin',
'packages/xxx_common',
],
);
}
void _openUpgradedPackageChangelog(List<String> directories) {
final packageRegex = RegExp(r'\s*name: (.+)[.\s\S]+?\+ version: "(.+)"');
final preReleaseRegex = RegExp(r'\d+\.\d+.\d+-.+');
final urls = Set.of(
directories.map((directory) {
final diff = run(
'git',
arguments: [
'diff',
'./$directory/pubspec.lock',
],
);
return packageRegex.allMatches(diff).map((match) {
final texts = match.groups([1, 2]);
final name = texts[0]!;
final version = texts[1]!;
final versionAdjusted = version.replaceAll(RegExp(r'\.|\+'), '');
final isPreRelease = preReleaseRegex.firstMatch(version) != null;
final preReleasePath = isPreRelease ? '/versions/$version' : '';
return 'https://pub.dev/packages/$name$preReleasePath/changelog#$versionAdjusted';
});
}).expand((e) => e),
);
for (final url in urls) {
run('open', arguments: [url]);
}
}
@mono0926
Copy link
Author

Example log

  open https://pub.dev/packages/firebase_auth/changelog#313
  open https://pub.dev/packages/firebase_auth_web/changelog#312
  open https://pub.dev/packages/firebase_crashlytics/changelog#223
  open https://pub.dev/packages/firebase_storage/changelog#1005
  open https://pub.dev/packages/flutter_riverpod/versions/1.0.0-dev.11/changelog#100-dev11
  open https://pub.dev/packages/freezed/changelog#01501
  open https://pub.dev/packages/google_sign_in_platform_interface/changelog#210
  open https://pub.dev/packages/hooks_riverpod/versions/1.0.0-dev.11/changelog#100-dev11
  open https://pub.dev/packages/material_design_icons_flutter/changelog#506295
  open https://pub.dev/packages/riverpod/versions/1.0.0-dev.10/changelog#100-dev10
  open https://pub.dev/packages/share_plus/changelog#302
  open https://pub.dev/packages/firestore_ref/changelog#01241

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment