Last active
February 16, 2022 00:06
-
-
Save ghassanmas/069dfa78f7b2469d757d667ea1f4e5fd to your computer and use it in GitHub Desktop.
It's just a simple script that check for the package.json for selected MFEs and it then outputs two main thing:
This file contains 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
import os | |
from urllib import request | |
import json | |
MFES = ['frontend-app-account','frontend-app-gradebook','frontend-app-profile','frontend-app-learning'] | |
GITHUB_PERFIX = 'https://raw.githubusercontent.com/openedx/' | |
BRANCH = 'master' | |
def get_package_json(): | |
for mfe in MFES: | |
if os.path.isfile(mfe+'_package.json'): | |
continue | |
request.urlretrieve(render_url(mfe),mfe+'_package.json') | |
def find_shared(): | |
all_depens=[] | |
for mfe in MFES: | |
f = open(mfe+'_package.json','r') | |
depn=json.loads(f.read())['dependencies'] | |
all_depens.append(depn) | |
shared_strict = [{t[0]:t[1]} for t in (set.intersection(*(set(d.items()) for d in all_depens))) ] | |
shared = set.intersection(*(set(d.keys()) for d in all_depens)) | |
save_json(list(shared),'shared') | |
save_json(shared_strict,'shared_strict') | |
def save_json(data,path): | |
with open(path+".json","w") as outfile: | |
json.dump(data,outfile) | |
def render_url(mfe): | |
return(GITHUB_PERFIX+mfe+'/'+BRANCH+'/package.json') | |
get_package_json() | |
find_shared() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment