Skip to content
This repository was archived by the owner on Aug 18, 2020. It is now read-only.

Commit

Permalink
manager: Improve vendor update script's handling of raw JS/CSS files
Browse files Browse the repository at this point in the history
Also fix some formatting
  • Loading branch information
anonymoose2 committed Apr 24, 2020
1 parent 81bfbf2 commit c5e4aa4
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions manager/scripts/update-vendor.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ def get_tarball_url(self, version: str) -> str:
req.raise_for_status()

return req.json()["dist"]["tarball"]


def get_github_latest_release_name(repo: str) -> str:
return requests.get("https://api.github.com/repos/" + repo + "/releases/latest").json()["tag_name"]
Expand Down Expand Up @@ -482,7 +482,7 @@ def download_version(self, version: str, vendor_path: str) -> None:
extract_base_path=os.path.join(vendor_path, "js"),
limit_files=["messenger.min.js", "messenger-theme-flat.js"],
)


class ReconnectingWebsocketVendoredDependency(VendoredDependency):
name = "reconnecting-websocket"
Expand Down Expand Up @@ -558,7 +558,19 @@ def list_existing_vendored_dependencies() -> Dict[str, str]:
# Remove old version
if dependency.name in old_dependencies:
print("Removing version " + old_dependencies[dependency.name])
shutil.rmtree(os.path.join(vendor_dir, dependency.name + "-" + old_dependencies[dependency.name]))

orig_fpath = os.path.join(vendor_dir, dependency.name + "-" + old_dependencies[dependency.name])
for suffix in ["", ".css", ".js", ".min.css", ".min.js"]:
fpath = orig_fpath + suffix
if os.path.exists(fpath):
if os.path.isdir(fpath):
shutil.rmtree(fpath)
else:
os.remove(fpath)

break
else:
print("Error: could not find old version " + old_dependencies[dependency.name], file=sys.stderr)

prefix = "{% static 'vendor/" + dependency.name + "-"

Expand Down

0 comments on commit c5e4aa4

Please sign in to comment.