Skip to content

Instantly share code, notes, and snippets.

@alifgiant
Last active September 5, 2021 06:03
Show Gist options
  • Save alifgiant/98acd650fe23a279f8f642dde8554979 to your computer and use it in GitHub Desktop.
Save alifgiant/98acd650fe23a279f8f642dde8554979 to your computer and use it in GitHub Desktop.
Flutter Check Deps and Compatibility
### prerequisite: python 3.6+
### pip install pyyaml
### pip install beautifulsoup4
###
### use this script to check your flutter deps to find out lates deps
### and check whether it is compatible to your platform target
### it will create a table in markdown file (compability_deps.md)
import urllib.request
import yaml
from bs4 import BeautifulSoup
def saveCheck(doc):
with open('compability_deps.md', 'w') as file:
file.write('| deps | current version | latest version | compatible with |\n')
file.write('| ---- | --------------- | -------------- | --------------- |\n')
for item, data in doc.items():
line = f'| {item} | {data[0]} | {data[1]} | {data[2]} |\n'
file.write(line)
def checkDeps(deps):
doc = {}
for item, ver in deps.items():
html_text = urllib.request.urlopen(f'http://pub.dev/packages/{item}').read()
soup = BeautifulSoup(html_text, 'html.parser')
title = soup.select_one('h1.title')
compatibles = soup.select('.tag-badge-sub')
latestVer = title.getText().split(' ')[1]
compatibility = [x.text for x in compatibles]
print(item, ":", ver)
print(compatibility)
doc[item] = [ver, latestVer, compatibility]
saveCheck(doc)
if __name__ == "__main__":
with open(r'pubspec.yaml') as file:
pubspec = yaml.load(file, Loader=yaml.FullLoader)
deps = pubspec['dependencies']
deps.pop('flutter')
checkDeps(deps)
@alifgiant
Copy link
Author

result
image

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