summarylogtreecommitdiffstats
path: root/patch.py
blob: 6016192d567eb5b40570fc8cc8437412b33c2975 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/usr/bin/env python
from sys import argv, stderr, stdout
from json import load, dump

PRODUCT_JSON = "/usr/share/vscodium-translucent/resources/app/product.json"

if __name__ == "__main__":
    with open(PRODUCT_JSON) as f:
        product = load(f)

    if "-R" in argv:
        product["extensionsGallery"] = {
            "serviceUrl": "https://open-vsx.org/vscode/gallery",
            "itemUrl": "https://open-vsx.org/vscode/item",
        }
        product["linkProtectionTrustedDomains"] = ["https://open-vsx.org"]
    else:
        product["extensionsGallery"] = {
            "serviceUrl": "https://marketplace.visualstudio.com/_apis/public/gallery",
            "cacheUrl": "https://vscode.blob.core.windows.net/gallery/index",
            "itemUrl": "https://marketplace.visualstudio.com/items",
        }
        product.pop("linkProtectionTrustedDomains", None)

    with open(PRODUCT_JSON, "w") as f:
        dump(product, f, indent=2)

    print(f"Patched {PRODUCT_JSON}", file=stdout)