Last active
January 12, 2024 12:32
-
-
Save mono0926/c1f959cb05328e7f19da0bd275a282e0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Example log