Keep web Material styling and preserve visible installer access URLs
This commit is contained in:
@@ -212,6 +212,26 @@ def build_apk(prefix, server_url=None, notes="", runner=subprocess.run, log=prin
|
||||
return target / "pipelines.apk"
|
||||
|
||||
|
||||
def print_web_urls(manifest, lan_host=None):
|
||||
"""Keep browser access details as the final installer output."""
|
||||
web = manifest.get("web") or {}
|
||||
if not web.get("port"):
|
||||
return
|
||||
host = web.get("host", "0.0.0.0")
|
||||
local = "localhost" if host in ("0.0.0.0", "127.0.0.1") else host
|
||||
urls = [f"http://{local}:{web['port']}/"]
|
||||
if host == "0.0.0.0":
|
||||
lan_host = lan_host or urlsplit(manifest.get("public_url", "")).hostname
|
||||
if lan_host and lan_host not in ("localhost", "127.0.0.1", "0.0.0.0"):
|
||||
urls.append(f"http://{lan_host}:{web['port']}/")
|
||||
public = manifest.get("opencode_env", {}).get("PIPELINES_WEB_PUBLIC_URL")
|
||||
if public:
|
||||
urls.append(public.rstrip("/") + "/")
|
||||
print("\nOpen Pipelines in your browser:")
|
||||
for url in dict.fromkeys(urls):
|
||||
print(" " + url)
|
||||
|
||||
|
||||
def main(argv=None):
|
||||
parser = argparse.ArgumentParser(description=__doc__.splitlines()[0])
|
||||
parser.add_argument("kind", choices=("web", "apk"))
|
||||
@@ -223,6 +243,7 @@ def main(argv=None):
|
||||
raise RuntimeError("Docker is required to build the app; start Docker and retry")
|
||||
if args.kind == "apk":
|
||||
build_apk(args.prefix, args.server_url, args.notes)
|
||||
print_web_urls(load_manifest(args.prefix))
|
||||
return
|
||||
manifest = load_manifest(args.prefix)
|
||||
web = manifest.get("web") or {}
|
||||
@@ -230,6 +251,7 @@ def main(argv=None):
|
||||
raise ValueError("This installation does not serve the app; rerun ./install")
|
||||
install_tree(build("web"), Path(web["root"]))
|
||||
print(f"Web app installed at {web['root']}; reload the page.")
|
||||
print_web_urls(manifest)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
Reference in New Issue
Block a user