Skip to content

Instantly share code, notes, and snippets.

@ghassanmas
Last active February 16, 2022 00:06
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 ghassanmas/069dfa78f7b2469d757d667ea1f4e5fd to your computer and use it in GitHub Desktop.
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:
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()
["@edx/frontend-platform", "redux", "@edx/paragon", "regenerator-runtime", "react-redux", "@fortawesome/free-solid-svg-icons", "@fortawesome/free-brands-svg-icons", "react-router-dom", "@edx/frontend-component-header", "prop-types", "react-dom", "react-router", "@fortawesome/fontawesome-svg-core", "@edx/brand", "@edx/frontend-component-footer", "react", "@fortawesome/react-fontawesome", "classnames", "core-js"]
[{"prop-types": "15.7.2"}, {"@edx/frontend-component-footer": "10.1.6"}]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment