chore(webpage): remove deploy command
This commit is contained in:
@@ -24,7 +24,7 @@ mytoolkit --help
|
|||||||
| `latex` | `compile` / `count` |
|
| `latex` | `compile` / `count` |
|
||||||
| `bib` | `to-markdown` / `cv-update` |
|
| `bib` | `to-markdown` / `cv-update` |
|
||||||
| `video` | `avi-to-mp4` |
|
| `video` | `avi-to-mp4` |
|
||||||
| `webpage` | Docusaurus build/list/rebuild/deploy/push |
|
| `webpage` | Docusaurus build/list/rebuild/push |
|
||||||
| `mail` | IMAP/SMTP client (read/draft/forward/reply, no auto-send) |
|
| `mail` | IMAP/SMTP client (read/draft/forward/reply, no auto-send) |
|
||||||
| `templates` | Register and inspect external template root |
|
| `templates` | Register and inspect external template root |
|
||||||
| `env` | Manage stored vars (api keys, paths, feishu app credentials) |
|
| `env` | Manage stored vars (api keys, paths, feishu app credentials) |
|
||||||
|
|||||||
+1
-71
@@ -1,4 +1,4 @@
|
|||||||
"""Webpage project utilities (Docusaurus build / clear / deploy / pdf / etc.).
|
"""Webpage project utilities (Docusaurus build / clear / pdf / etc.).
|
||||||
|
|
||||||
Project metadata lives in `server.py` so that adding a new webpage there
|
Project metadata lives in `server.py` so that adding a new webpage there
|
||||||
automatically wires it up here.
|
automatically wires it up here.
|
||||||
@@ -8,7 +8,6 @@ e.g. `mytoolkit webpage mywebpage build --serve`.
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
import re
|
import re
|
||||||
import shutil
|
|
||||||
import subprocess
|
import subprocess
|
||||||
import time
|
import time
|
||||||
|
|
||||||
@@ -90,66 +89,6 @@ def _push_impl(name: str, force: bool, push_args: tuple[str, ...]) -> None:
|
|||||||
click.secho(f"{svc.name} pushed.", fg="green")
|
click.secho(f"{svc.name} pushed.", fg="green")
|
||||||
|
|
||||||
|
|
||||||
def _deploy_impl(name: str, deploy_args: tuple[str, ...]) -> None:
|
|
||||||
svc = get_service(name)
|
|
||||||
assert svc.project_dir is not None
|
|
||||||
|
|
||||||
if not svc.project_dir.exists():
|
|
||||||
click.secho(f"Project directory not found: {svc.project_dir}", fg="red")
|
|
||||||
raise click.Abort()
|
|
||||||
|
|
||||||
env = no_color_env()
|
|
||||||
|
|
||||||
if not env.get("GIT_USER"):
|
|
||||||
use_ssh = env.get("USE_SSH", "").lower() == "true"
|
|
||||||
if not use_ssh:
|
|
||||||
login = ""
|
|
||||||
gh_path = shutil.which("gh")
|
|
||||||
if gh_path:
|
|
||||||
try:
|
|
||||||
result = subprocess.run(
|
|
||||||
[gh_path, "api", "user", "--jq", ".login"],
|
|
||||||
capture_output=True,
|
|
||||||
text=True,
|
|
||||||
timeout=5,
|
|
||||||
)
|
|
||||||
if result.returncode == 0:
|
|
||||||
login = result.stdout.strip()
|
|
||||||
except (subprocess.TimeoutExpired, FileNotFoundError):
|
|
||||||
pass
|
|
||||||
|
|
||||||
if not login:
|
|
||||||
try:
|
|
||||||
result = subprocess.run(
|
|
||||||
["git", "-C", str(svc.project_dir), "remote", "get-url", "origin"],
|
|
||||||
capture_output=True,
|
|
||||||
text=True,
|
|
||||||
timeout=5,
|
|
||||||
)
|
|
||||||
if result.returncode == 0:
|
|
||||||
origin = result.stdout.strip()
|
|
||||||
m = re.search(r"github\.com[:/]([^/]+)/", origin)
|
|
||||||
if m:
|
|
||||||
login = m.group(1)
|
|
||||||
except (subprocess.TimeoutExpired, FileNotFoundError):
|
|
||||||
pass
|
|
||||||
|
|
||||||
if login:
|
|
||||||
env["GIT_USER"] = login
|
|
||||||
click.secho(f"Inferred GIT_USER={login}", fg="bright_black")
|
|
||||||
|
|
||||||
click.secho(f"Deploying {svc.name} ({svc.description}) ...", fg="cyan")
|
|
||||||
cmd = ["npm", "run", "deploy"]
|
|
||||||
if deploy_args:
|
|
||||||
cmd.append("--")
|
|
||||||
cmd.extend(deploy_args)
|
|
||||||
proc = subprocess.run(cmd, cwd=svc.project_dir, env=env)
|
|
||||||
if proc.returncode != 0:
|
|
||||||
click.secho(f"Deploy failed for {svc.name}", fg="red")
|
|
||||||
raise click.Abort()
|
|
||||||
click.secho(f"{svc.name} deployed.", fg="green")
|
|
||||||
|
|
||||||
|
|
||||||
def _pdf_build_impl(name, output, title, subtitle, date, lang) -> None:
|
def _pdf_build_impl(name, output, title, subtitle, date, lang) -> None:
|
||||||
svc = get_service(name)
|
svc = get_service(name)
|
||||||
assert svc.project_dir is not None
|
assert svc.project_dir is not None
|
||||||
@@ -286,15 +225,6 @@ def _make_project_group(name: str, description: str) -> click.Group:
|
|||||||
"""
|
"""
|
||||||
_push_impl(name, force, push_args)
|
_push_impl(name, force, push_args)
|
||||||
|
|
||||||
@project_group.command("deploy", context_settings={"ignore_unknown_options": True})
|
|
||||||
@click.argument("deploy_args", nargs=-1, type=click.UNPROCESSED)
|
|
||||||
def deploy_cmd(deploy_args):
|
|
||||||
"""Deploy to GitHub Pages (`npm run deploy`).
|
|
||||||
|
|
||||||
Automatically infers GIT_USER from `gh` CLI or git origin URL.
|
|
||||||
"""
|
|
||||||
_deploy_impl(name, deploy_args)
|
|
||||||
|
|
||||||
@project_group.group(name="pdf")
|
@project_group.group(name="pdf")
|
||||||
def pdf_group():
|
def pdf_group():
|
||||||
"""Export docs to PDF or open existing PDF."""
|
"""Export docs to PDF or open existing PDF."""
|
||||||
|
|||||||
Reference in New Issue
Block a user