Skip to content

Commit 9a70cd7

Browse files
feat: add new command "ap serve" and an empty faq.yml
1 parent 5f7b177 commit 9a70cd7

3 files changed

Lines changed: 31 additions & 0 deletions

File tree

afterpython/faq.yml

Whitespace-only changes.
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import subprocess
2+
3+
import click
4+
from click.exceptions import Exit
5+
6+
7+
@click.command()
8+
@click.pass_context
9+
def serve(ctx):
10+
"""Serve the production build of the project website"""
11+
from afterpython.utils import find_node_env, is_website_initialized
12+
13+
if not is_website_initialized():
14+
click.echo(
15+
"Website has not been initialized. Skipping serve.\n"
16+
"Run 'ap update website' to initialize the website."
17+
)
18+
return
19+
20+
paths = ctx.obj["paths"]
21+
node_env = find_node_env()
22+
click.echo(
23+
"Serving the production build of the project website (including myst's builds)..."
24+
)
25+
result = subprocess.run(
26+
["pnpm", "serve"], cwd=paths.website_path, env=node_env, check=False
27+
)
28+
if result.returncode != 0:
29+
raise Exit(result.returncode)

src/afterpython/cli/main.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
from afterpython.cli.commands.preview import preview
2626
from afterpython.cli.commands.release import release
2727
from afterpython.cli.commands.remove import remove
28+
from afterpython.cli.commands.serve import serve
2829
from afterpython.cli.commands.start import blog, doc, example, guide, start, tutorial
2930
from afterpython.cli.commands.sync import sync
3031
from afterpython.cli.commands.update import update
@@ -118,6 +119,7 @@ def afterpython_group(ctx):
118119
afterpython_group.add_command(example)
119120
afterpython_group.add_command(guide)
120121
afterpython_group.add_command(preview)
122+
afterpython_group.add_command(serve)
121123
afterpython_group.add_command(clean)
122124
afterpython_group.add_command(pre_commit)
123125
afterpython_group.add_command(pre_commit, name="pc")

0 commit comments

Comments
 (0)