Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Check pub.dev for updates to dart packages
"""
MIT LICENSE
Copyright (c) 2019 Taormina Innovations LLC
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
"""
from pyquery import PyQuery as pq
from termcolor import colored
import sys
mostRecent = ": ^"
def getLatestPackage(package):
url = "https://pub.dev/packages/" + package
d = pq(url=url)
return d("h2.title").html()
def isVersionDeclaration(line):
return mostRecent in line and "#" not in line
with open(sys.argv[1],"r") as ff:
lines = [tuple(line.strip().split(mostRecent)) for line in ff.readlines() if isVersionDeclaration(line)]
for package, version in lines:
available = getLatestPackage(package)
if version in available:
print(colored(available, 'green'))
else:
print(colored(available + " <- " + version, 'red', attrs=['bold']) + " - Changelog @ " + getUrl(package) + "#-changelog-tab-")
@Taormina

This comment has been minimized.

Copy link
Owner Author

@Taormina Taormina commented Jun 21, 2019

Example usage:
python check-for-updates.py ~/Code/danger_world/pubspec.yaml

cloud_firestore 0.12.5+2
firebase_analytics 3.0.3
firebase_auth 0.11.1+7
firebase_core 0.4.0+6
firebase_crashlytics 0.0.4+8
http 0.12.0+2
liquid_pull_to_refresh 1.1.1
package_info 0.4.0+4
share 0.6.1+1
shared_preferences 0.5.3+1
url_launcher 5.0.3

python check-for-updates.py ~/Code/example/pubspec.yaml

google_maps_flutter 0.5.18 <- 0.5.7
image_picker 0.6.0+10 <- 0.5.3
url_launcher 5.0.3 <- 5.0.2
flutter_google_places 0.2.3 <- 0.2.1
flutter_range_slider 1.3.0 <- 1.1.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.