Created
October 13, 2021 04:44
-
-
Save tompec/93140d517974ff4a554d3436fca16663 to your computer and use it in GitHub Desktop.
Get the Laravel version for your local repositories
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
# Quick script to list the versions of your Laravel repositories. | |
# Replace repositories_folder with the path to your repositories folder, | |
# then run `python laravel-versions.py` | |
import os | |
import json | |
repositories_folder = "/Users/Thomas/code/" | |
results = {} | |
folders = os.listdir(repositories_folder) | |
for folder in folders: | |
composer_lock = folder + "/composer.lock" | |
if os.path.isfile(composer_lock): | |
with open(composer_lock) as f: | |
data = json.load(f) | |
f.close() | |
for i in data["packages"]: | |
if i["name"] == "laravel/framework": | |
if i["version"] not in results: | |
results[i["version"]] = [] | |
results[i["version"]].append(folder) | |
results = list(sorted(results.items())) | |
for i, k in results: | |
print(str(i), k) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment