feat(webpage): add server subcommand delegating to mytoolkit server
`mytoolkit webpage <project> server <action>` mirrors `mytoolkit server <action> <project>`, so each Docusaurus project can manage its own dev/serve lifecycle from the webpage namespace.
This commit is contained in:
+40
-1
@@ -14,7 +14,15 @@ import time
|
|||||||
|
|
||||||
import click
|
import click
|
||||||
|
|
||||||
from bin.commands.server import manageable_services, get_service, no_color_env
|
from bin.commands.server import (
|
||||||
|
manageable_services,
|
||||||
|
get_service,
|
||||||
|
no_color_env,
|
||||||
|
server_start,
|
||||||
|
server_stop,
|
||||||
|
server_restart,
|
||||||
|
server_status,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
_PROJECTS = manageable_services()
|
_PROJECTS = manageable_services()
|
||||||
@@ -313,6 +321,37 @@ def _make_project_group(name: str, description: str) -> click.Group:
|
|||||||
"""Open the exported PDF with the default application."""
|
"""Open the exported PDF with the default application."""
|
||||||
_pdf_open_impl(name, output)
|
_pdf_open_impl(name, output)
|
||||||
|
|
||||||
|
@project_group.group(name="server")
|
||||||
|
def server_group():
|
||||||
|
"""Manage this project's local dev/serve server (delegates to `mytoolkit server`)."""
|
||||||
|
pass
|
||||||
|
|
||||||
|
@server_group.command("start")
|
||||||
|
@click.option("--dev", is_flag=True, help="Start hot-reload dev server on the dev port (default: serve)")
|
||||||
|
@click.option("--rebuild", is_flag=True, help="Force npm run build before serve (no effect with --dev)")
|
||||||
|
def server_start_cmd(dev, rebuild):
|
||||||
|
"""Start the project server in the background."""
|
||||||
|
click.get_current_context().invoke(server_start, name=name, dev=dev, rebuild=rebuild)
|
||||||
|
|
||||||
|
@server_group.command("stop")
|
||||||
|
@click.option("--dev", is_flag=True, help="Stop the dev-port instance instead of serve")
|
||||||
|
@click.option("--all", "all_modes", is_flag=True, help="Stop both dev and serve instances")
|
||||||
|
def server_stop_cmd(dev, all_modes):
|
||||||
|
"""Stop the project server."""
|
||||||
|
click.get_current_context().invoke(server_stop, name=name, dev=dev, all_modes=all_modes)
|
||||||
|
|
||||||
|
@server_group.command("restart")
|
||||||
|
@click.option("--dev", is_flag=True, help="Restart the dev instance (default: serve)")
|
||||||
|
@click.option("--rebuild", is_flag=True, help="Force npm run build before serve (no effect with --dev)")
|
||||||
|
def server_restart_cmd(dev, rebuild):
|
||||||
|
"""Restart the project server."""
|
||||||
|
click.get_current_context().invoke(server_restart, name=name, dev=dev, rebuild=rebuild)
|
||||||
|
|
||||||
|
@server_group.command("status")
|
||||||
|
def server_status_cmd():
|
||||||
|
"""Show detailed server status (serve and dev ports)."""
|
||||||
|
click.get_current_context().invoke(server_status, name=name)
|
||||||
|
|
||||||
return project_group
|
return project_group
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user