Files
breeze/scripts/package-web-bundle.py
T
waozi e3b1d7f7b1
Cloudflare Pages / Build and verify the site (push) Failing after 3m15s
Breeze build / Linux native (push) Successful in 23m30s
Package the Web app bundle for Firefox review
2026-11-29 08:01:10 -03:00

44 lines
1.1 KiB
Python

#!/usr/bin/env python3
"""Stage the portable app bundle within the Web distribution's file limits."""
import argparse
import json
import shutil
from pathlib import Path
PART_BYTES = 24 * 1024 * 1024
def package_bundle(bundle: Path, output: Path) -> None:
if output.exists():
shutil.rmtree(output)
output.mkdir()
size = 0
parts = []
with bundle.open("rb") as source:
while block := source.read(PART_BYTES):
name = f"part-{len(parts):03d}.bin"
(output / name).write_bytes(block)
parts.append(name)
size += len(block)
if not parts:
raise ValueError(f"Empty app bundle: {bundle}")
(output / "manifest.json").write_text(
json.dumps({"size": size, "parts": parts}) + "\n", encoding="utf-8"
)
def main() -> None:
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("bundle", type=Path)
parser.add_argument("output", type=Path)
args = parser.parse_args()
package_bundle(args.bundle, args.output)
if __name__ == "__main__":
main()