44 lines
1.7 KiB
Python
44 lines
1.7 KiB
Python
#!/usr/bin/env python3
|
|
import argparse
|
|
from typing import cast
|
|
from script_common import ensure_npm_build, find_node_app_root, resolve_repo_root
|
|
|
|
|
|
def main() -> int:
|
|
parser = argparse.ArgumentParser(description="Cross-platform web/tauri publish helper")
|
|
_ = parser.add_argument("--target", choices=["web", "tauri"], default="web")
|
|
_ = parser.add_argument("--configuration", choices=["Release", "Debug"], default="Release")
|
|
_ = parser.add_argument("--tauri-bundles", choices=["none", "nsis", "msi"], default="none")
|
|
_ = parser.add_argument("--install-deps", action="store_true")
|
|
_ = parser.add_argument("--skip-install", action="store_true")
|
|
_ = parser.add_argument("--dry-run", action="store_true")
|
|
_ = parser.add_argument("--repo-root", default=None)
|
|
_ = parser.add_argument("--app-root", default=None, help="Relative or absolute app root with package.json")
|
|
args = parser.parse_args()
|
|
|
|
repo_root_val = cast(str | None, args.repo_root)
|
|
repo_root = resolve_repo_root(repo_root_val)
|
|
app_root_val = cast(str | None, args.app_root)
|
|
app_root = find_node_app_root(repo_root, app_root_val)
|
|
if app_root is None:
|
|
print("Unable to locate app root (no unique package.json found).")
|
|
return 2
|
|
|
|
# If dry-run is requested, we just print intent.
|
|
if args.dry_run:
|
|
print(f"Dry-run: Would build {args.target} ({args.configuration}) in {app_root}")
|
|
return 0
|
|
|
|
res = ensure_npm_build(
|
|
app_root=app_root,
|
|
target=str(args.target),
|
|
configuration=str(args.configuration),
|
|
tauri_bundles=str(args.tauri_bundles)
|
|
)
|
|
|
|
return int(res["exit_code"])
|
|
|
|
|
|
if __name__ == "__main__":
|
|
raise SystemExit(main())
|