Skip to content

Instantly share code, notes, and snippets.

@spidgorny
Created October 9, 2019 16:22
Show Gist options
  • Save spidgorny/ed475cbbe303e1c09c0f6c9f9f57dcad to your computer and use it in GitHub Desktop.
Save spidgorny/ed475cbbe303e1c09c0f6c9f9f57dcad to your computer and use it in GitHub Desktop.
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']);
}
}
}
}
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
@spidgorny
Copy link
Author

@shlima Great upgrade. Thank you.

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