|
3 | 3 | import platform
|
4 | 4 | import subprocess
|
5 | 5 | import sys
|
| 6 | +from importlib.metadata import entry_points |
6 | 7 | from importlib.util import find_spec
|
7 | 8 | from pathlib import Path
|
8 | 9 |
|
|
16 | 17 | from .pid import Pid
|
17 | 18 | from .poncho.manager import Manager as PonchoManager
|
18 | 19 | from .services import Services
|
19 |
| -from .utils import has_pyproject_toml, plainpackage_installed |
| 20 | +from .utils import has_pyproject_toml |
| 21 | + |
| 22 | +ENTRYPOINT_GROUP = "plain.dev" |
20 | 23 |
|
21 | 24 |
|
22 | 25 | @click.group(invoke_without_command=True)
|
@@ -46,6 +49,24 @@ def services():
|
46 | 49 | Services().run()
|
47 | 50 |
|
48 | 51 |
|
| 52 | +@cli.command() |
| 53 | +@click.option( |
| 54 | + "--list", "-l", "show_list", is_flag=True, help="List available entrypoints" |
| 55 | +) |
| 56 | +@click.argument("entrypoint", required=False) |
| 57 | +def entrypoint(show_list, entrypoint): |
| 58 | + f"""Entrypoints registered under {ENTRYPOINT_GROUP}""" |
| 59 | + if not show_list and not entrypoint: |
| 60 | + click.secho("Please provide an entrypoint name or use --list", fg="red") |
| 61 | + sys.exit(1) |
| 62 | + |
| 63 | + for entry_point in entry_points().select(group=ENTRYPOINT_GROUP): |
| 64 | + if show_list: |
| 65 | + click.echo(entry_point.name) |
| 66 | + elif entrypoint == entry_point.name: |
| 67 | + entry_point.load()() |
| 68 | + |
| 69 | + |
49 | 70 | class Dev:
|
50 | 71 | def __init__(self, *, port):
|
51 | 72 | self.poncho = PonchoManager()
|
@@ -82,7 +103,7 @@ def run(self):
|
82 | 103 |
|
83 | 104 | # Processes for poncho to run simultaneously
|
84 | 105 | self.add_gunicorn()
|
85 |
| - self.add_tailwind() |
| 106 | + self.add_entrypoints() |
86 | 107 | self.add_pyproject_run()
|
87 | 108 | self.add_services()
|
88 | 109 |
|
@@ -230,11 +251,11 @@ def add_gunicorn(self):
|
230 | 251 |
|
231 | 252 | self.poncho.add_process("plain", runserver_cmd, env=self.plain_env)
|
232 | 253 |
|
233 |
| - def add_tailwind(self): |
234 |
| - if not plainpackage_installed("tailwind"): |
235 |
| - return |
236 |
| - |
237 |
| - self.poncho.add_process("tailwind", "plain tailwind compile --watch") |
| 254 | + def add_entrypoints(self): |
| 255 | + for entry_point in entry_points().select(group=ENTRYPOINT_GROUP): |
| 256 | + self.poncho.add_process( |
| 257 | + f"plain dev entrypoint {entry_point.name}", env=self.plain_env |
| 258 | + ) |
238 | 259 |
|
239 | 260 | def add_pyproject_run(self):
|
240 | 261 | if not has_pyproject_toml(APP_PATH.parent):
|
|
0 commit comments