Skip to content

Instantly share code, notes, and snippets.

@tompec
Created October 13, 2021 04:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tompec/93140d517974ff4a554d3436fca16663 to your computer and use it in GitHub Desktop.
Save tompec/93140d517974ff4a554d3436fca16663 to your computer and use it in GitHub Desktop.
Get the Laravel version for your local repositories
# 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