Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- """
- add the following command to package.json
- - "merge-packages-json": "python3 src/react-utils/merge_packages_json.py react-utils"
- """
- import json
- import sys
- paths = sys.argv[1:]
- main_package = "package.json"
- main = None
- with open(main_package) as fh:
- main = json.load(fh)
- obj_conflict = {}
- first = False
- for path in paths:
- package_path = f"src/{path}/package.json"
- with open(package_path) as fh:
- obj = json.load(fh)
- for key in obj["dependencies"]:
- if key in main["dependencies"]:
- if not first:
- print("\nCONFLICT DETECTED IN DEPENDENCIES!!!\n")
- print(f"Package conflict: {key}")
- v_main, v_obj = main["dependencies"][key], obj["dependencies"][key]
- cmd = input(f"Type a number (default: 0):\n(0) highest\n(1) {v_main}\n(2) {v_obj}")
- cmd = "0" if cmd == "" else cmd
- first = True
- if cmd == "0":
- # to-do: fix because 18.0.6 < 18.0.10, but lexicographically "18.0.6" > "18.0.10"
- obj_conflict[key] = max([v_main, v_obj])
- elif cmd == "1":
- obj_conflict[key] = v_main
- elif cmd == "2":
- obj_conflict[key] = v_obj
- print(f"Selected: {obj_conflict[key]}\n")
- print(obj_conflict)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement