Created
October 9, 2019 16:22
-
-
Save spidgorny/ed475cbbe303e1c09c0f6c9f9f57dcad to your computer and use it in GitHub Desktop.
This file contains hidden or 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 'dart:convert'; | |
import "dart:io"; | |
import 'package:html/dom.dart'; | |
import 'package:html/parser.dart' as parser; | |
import "package:http/http.dart" as http; | |
import 'package:http/http.dart'; | |
import "package:yaml/yaml.dart"; | |
main() async { | |
File file = new File('pubspec.yaml'); | |
String yamlString = file.readAsStringSync(); | |
Map yaml = loadYaml(yamlString); | |
YamlMap dependencies = yaml['dependencies']; | |
// print(dependencies); | |
for (var key in dependencies.keys) { | |
var version = dependencies[key]; | |
if (version is String) { | |
var versionNumber = version.replaceFirst('^', ''); | |
print(key + ': ' + versionNumber); | |
Response html = await http.get('https://pub.dev/packages/' + key); | |
Document document = parser.parse(html.body); | |
var jsonScript = | |
document.querySelector('script[type="application/ld+json"]'); | |
var json = jsonDecode(jsonScript.innerHtml); | |
// print(json['version']); | |
if (json['version'].toString().compareTo(versionNumber) > 0) { | |
print(' => ' + json['version']); | |
} | |
} | |
} | |
} |
This file contains hidden or 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
It reads pubspec.yaml and check for the latest version of each dependency. | |
Example: | |
cupertino_icons: 0.1.2 | |
location: 2.3.5 | |
flutter_local_notifications: 0.8.4 | |
http: 0.12.0+1 | |
=> 0.12.0+2 | |
haversine: 1.0.2 | |
flutter_map: 0.1.4 | |
=> 0.7.3 | |
map_native: 0.0.11 | |
url_launcher: 5.1.4 | |
flutter_html_view: 0.5.12 | |
flutter_html: 0.8.2 | |
background_fetch: 0.2.0 | |
=> 0.3.2 | |
package_info: 0.4.0+2 | |
=> 0.4.0+6 | |
liquid_pull_to_refresh: 1.1.1 | |
provider: 3.0.0 | |
=> 3.1.0 | |
yaml: any | |
google_maps_flutter: 0.5.21+7 |
Outputs:
cupertino_icons 0.1.2 => 0.1.3 (https://pub.dev/packages/cupertino_icons#-changelog-tab-)
simple_animations 1.3.8 => 1.3.9 (https://pub.dev/packages/simple_animations#-changelog-tab-)
percent_indicator 2.1.1 => 2.1.1+1 (https://pub.dev/packages/percent_indicator#-changelog-tab-)
flutter_secure_storage 3.3.1 => 3.3.1+1 (https://pub.dev/packages/flutter_secure_storage#-changelog-tab-)
shared_preferences 0.5.6 => 0.5.6+2 (https://pub.dev/packages/shared_preferences#-changelog-tab-)
crypto 2.1.3 => 2.1.4 (https://pub.dev/packages/crypto#-changelog-tab-)
flutter_i18n 0.10.0 => 0.10.1 (https://pub.dev/packages/flutter_i18n#-changelog-tab-)
pull_to_refresh 1.5.7 => 1.5.8 (https://pub.dev/packages/pull_to_refresh#-changelog-tab-)
⚠️ Failed to check flutter_test
test any => 1.14.2 (https://pub.dev/packages/test#-changelog-tab-)
⚠️ Failed to check flutter
⚠️ Failed to check flutter_driver
@shlima Great upgrade. Thank you.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I've modified a little bit your script:
pubspec.yml
file you wantdev_dependencies
tooJust puts the script into
project/bin/outdated.dart
and rundart bin/outdated.dart pubspec.yml