diff options
-rwxr-xr-x | cargo_check.py | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/cargo_check.py b/cargo_check.py new file mode 100755 index 0000000..3350c56 --- /dev/null +++ b/cargo_check.py @@ -0,0 +1,28 @@ +#!/usr/bin/env python3 +# Written by Martin Fischer <martin@push-f.com> and licensed under MIT. +from multiprocessing.dummy import Pool +import toml +import requests + +sess = requests.session() +sess.headers['user-agent'] = 'cargo_check.py' + +tasks = [] + +with open('Cargo.toml') as f: + data = toml.load(f) + for name, info in data['dependencies'].items(): + version = info if isinstance(info, str) else info.get('version') + tasks.append((name, version)) + +def check_package(info): + name, version = info + res = sess.get('https://crates.io/api/v1/crates/{}'.format(name)) + latest_version = res.json()['versions'][0] + if latest_version['yanked']: + print(name, 'was yanked') + elif not latest_version['num'].startswith(version): + print('{} is outdated ({}), {} is available'.format(name, version, latest_version['num'])) + +pool = Pool() +pool.map(check_package, tasks) |