-
Notifications
You must be signed in to change notification settings - Fork 7
/
generate-sources
executable file
·51 lines (45 loc) · 1.63 KB
/
generate-sources
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/env python3
import json
import os
import subprocess
import requests
if __name__ == "__main__":
root = os.path.dirname(__file__)
generated_sources_path = f"{root}/generated-sources.json"
subprocess.call(
[
"flatpak-node-generator",
"yarn",
"--electron-node-headers",
"--node-chromedriver-from-electron",
"9.3.1",
"-r",
f"{root}/desktop/yarn.lock",
"-R",
"yarn.lock",
"-R",
"app/yarn.lock",
],
cwd=root,
)
with open(generated_sources_path, "r") as fp:
generated_sources = json.load(fp)
# Move electron-cache files to match what @electron/get expects
# https://github.com/electron/get/blob/master/src/Cache.ts
for source in generated_sources:
if source.get("dest"):
if source["dest"] == "flatpak-node/electron-cache":
cache_dir = (
source["url"]
.split("?")[0]
.split("#")[0]
.translate(str.maketrans("", "", '<>:"/\\|?*'))[:255]
)
source["dest"] = f"flatpak-node/electron-cache/{cache_dir}"
del source["dest-filename"]
if source.get("type")=="git" and source.get("url") == "https://github.com/sergiou87/prebuild":
req = requests.get("https://api.github.com/repos/sergiou87/prebuild/commits/master")
jsn = req.json()
source["commit"] = jsn["sha"]
with open(generated_sources_path, "w") as fp:
json.dump(generated_sources, fp, indent=4)