Last active
October 19, 2019 03:18
-
-
Save rinsuki/45362663b7ed8fd56f75d86b8403a943 to your computer and use it in GitHub Desktop.
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
import json | |
f = json.load(open("package.json", "r")) | |
packages = open("packages.txt", "r") | |
def sorted_dict(input): | |
r = sorted(input.items(), key=lambda x:x) | |
d = {} | |
for k, v in r: | |
d[k] = v | |
return d | |
for p in packages.readlines(): | |
p = p.strip() | |
if f["dependencies"].get(p) == None: | |
print(p) | |
if f["devDependencies"].get(p) != None: | |
f["dependencies"][p] = f["devDependencies"][p] | |
del f["devDependencies"][p] | |
else: | |
print("WARN!! " + p +" is used in built/**/*.js, but not found on devDependencies") | |
f["dependencies"] = sorted_dict(f["dependencies"]) | |
f["devDependencies"] = sorted_dict(f["devDependencies"]) | |
json.dump(f, open("package.json", "w"), indent=2) |
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
#!/bin/zsh | |
python3 search.py | sort | uniq > packages.txt |
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
import re | |
import os | |
import glob | |
r = re.compile(r"require\(['\"]([@a-zA-Z0-9\-/]+)['\"]\)") | |
for file in glob.glob('built/**/*.js', recursive = True): | |
if "client/assets" in file: | |
continue | |
s = open(file, "r").read() | |
for g in r.finditer(s): | |
print(g.group(1)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment