plain.dev 0.14.2__py3-none-any.whl → 0.16.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- plain/dev/cli.py +41 -11
- plain/dev/contribute/cli.py +5 -2
- plain/dev/poncho/printer.py +7 -33
- {plain_dev-0.14.2.dist-info → plain_dev-0.16.0.dist-info}/METADATA +2 -1
- {plain_dev-0.14.2.dist-info → plain_dev-0.16.0.dist-info}/RECORD +8 -8
- {plain_dev-0.14.2.dist-info → plain_dev-0.16.0.dist-info}/WHEEL +0 -0
- {plain_dev-0.14.2.dist-info → plain_dev-0.16.0.dist-info}/entry_points.txt +0 -0
- {plain_dev-0.14.2.dist-info → plain_dev-0.16.0.dist-info}/licenses/LICENSE +0 -0
plain/dev/cli.py
CHANGED
@@ -10,6 +10,9 @@ from importlib.util import find_spec
|
|
10
10
|
from pathlib import Path
|
11
11
|
|
12
12
|
import click
|
13
|
+
from rich.columns import Columns
|
14
|
+
from rich.console import Console
|
15
|
+
from rich.text import Text
|
13
16
|
|
14
17
|
from plain.runtime import APP_PATH, settings
|
15
18
|
|
@@ -17,6 +20,7 @@ from .db import cli as db_cli
|
|
17
20
|
from .mkcert import MkcertManager
|
18
21
|
from .pid import Pid
|
19
22
|
from .poncho.manager import Manager as PonchoManager
|
23
|
+
from .poncho.printer import Printer
|
20
24
|
from .services import Services
|
21
25
|
from .utils import has_pyproject_toml
|
22
26
|
|
@@ -73,7 +77,7 @@ def services():
|
|
73
77
|
)
|
74
78
|
@click.argument("entrypoint", required=False)
|
75
79
|
def entrypoint(show_list, entrypoint):
|
76
|
-
|
80
|
+
"""Entrypoints registered under plain.dev"""
|
77
81
|
if not show_list and not entrypoint:
|
78
82
|
click.secho("Please provide an entrypoint name or use --list", fg="red")
|
79
83
|
sys.exit(1)
|
@@ -91,12 +95,11 @@ class Dev:
|
|
91
95
|
self.hostname = hostname
|
92
96
|
self.log_level = log_level
|
93
97
|
|
94
|
-
self.poncho = PonchoManager()
|
95
|
-
|
96
98
|
self.ssl_key_path = None
|
97
99
|
self.ssl_cert_path = None
|
98
100
|
|
99
101
|
self.url = f"https://{self.hostname}:{self.port}"
|
102
|
+
self.tunnel_url = os.environ.get("PLAIN_DEV_TUNNEL_URL", "")
|
100
103
|
|
101
104
|
self.plain_env = {
|
102
105
|
"PYTHONUNBUFFERED": "true",
|
@@ -110,6 +113,9 @@ class Dev:
|
|
110
113
|
"PLAIN_DEV_URL": self.url,
|
111
114
|
}
|
112
115
|
|
116
|
+
self.console = Console(markup=False, highlight=False)
|
117
|
+
self.poncho = PonchoManager(printer=Printer(lambda s: self.console.out(s)))
|
118
|
+
|
113
119
|
def run(self):
|
114
120
|
pid = Pid()
|
115
121
|
pid.write()
|
@@ -133,15 +139,39 @@ class Dev:
|
|
133
139
|
self.add_pyproject_run()
|
134
140
|
self.add_services()
|
135
141
|
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
142
|
+
click.secho("\nStarting dev...", italic=True, dim=True)
|
143
|
+
|
144
|
+
if self.tunnel_url:
|
145
|
+
status_bar = Columns(
|
146
|
+
[
|
147
|
+
Text.from_markup(
|
148
|
+
f"[bold]Tunnel URL[/bold] [underline][link={self.tunnel_url}]{self.tunnel_url}[/link][/underline]"
|
149
|
+
),
|
150
|
+
Text.from_markup(
|
151
|
+
f"[dim][bold]Localhost URL[/bold] [link={self.url}]{self.url}[/link][/dim]"
|
152
|
+
),
|
153
|
+
Text.from_markup(
|
154
|
+
"[dim]Press [bold]Ctrl+C[/bold] to stop[/dim]",
|
155
|
+
justify="right",
|
156
|
+
),
|
157
|
+
],
|
158
|
+
expand=True,
|
159
|
+
)
|
160
|
+
else:
|
161
|
+
status_bar = Columns(
|
162
|
+
[
|
163
|
+
Text.from_markup(
|
164
|
+
f"[bold]Localhost URL[/bold] [underline][link={self.url}]{self.url}[/link][/underline]"
|
165
|
+
),
|
166
|
+
Text.from_markup(
|
167
|
+
"[dim][bold]Ctrl+C[/bold] to stop[/dim]", justify="right"
|
168
|
+
),
|
169
|
+
],
|
170
|
+
expand=True,
|
171
|
+
)
|
143
172
|
|
144
|
-
self.
|
173
|
+
with self.console.status(status_bar):
|
174
|
+
self.poncho.loop()
|
145
175
|
|
146
176
|
return self.poncho.returncode
|
147
177
|
finally:
|
plain/dev/contribute/cli.py
CHANGED
@@ -7,11 +7,14 @@ import click
|
|
7
7
|
|
8
8
|
@click.command("contribute")
|
9
9
|
@click.option("--repo", default="../plain", help="Path to the plain repo")
|
10
|
+
@click.option(
|
11
|
+
"--reset", is_flag=True, help="Undo any changes to pyproject.toml and uv.lock"
|
12
|
+
)
|
10
13
|
@click.argument("packages", nargs=-1)
|
11
|
-
def cli(packages, repo):
|
14
|
+
def cli(packages, repo, reset):
|
12
15
|
"""Contribute to plain by linking packages locally."""
|
13
16
|
|
14
|
-
if
|
17
|
+
if reset:
|
15
18
|
click.secho("Undoing any changes to pyproject.toml and uv.lock", bold=True)
|
16
19
|
result = subprocess.run(["git", "checkout", "pyproject.toml", "uv.lock"])
|
17
20
|
if result.returncode:
|
plain/dev/poncho/printer.py
CHANGED
@@ -1,8 +1,5 @@
|
|
1
|
-
import sys
|
2
1
|
from collections import namedtuple
|
3
2
|
|
4
|
-
from .compat import ON_WINDOWS
|
5
|
-
|
6
3
|
Message = namedtuple("Message", "type data time name color")
|
7
4
|
|
8
5
|
|
@@ -15,27 +12,18 @@ class Printer:
|
|
15
12
|
|
16
13
|
def __init__(
|
17
14
|
self,
|
18
|
-
|
15
|
+
print_func,
|
19
16
|
time_format="%H:%M:%S",
|
20
17
|
width=0,
|
21
18
|
color=True,
|
22
19
|
prefix=True,
|
23
20
|
):
|
24
|
-
self.
|
21
|
+
self.print_func = print_func
|
25
22
|
self.time_format = time_format
|
26
23
|
self.width = width
|
27
24
|
self.color = color
|
28
25
|
self.prefix = prefix
|
29
26
|
|
30
|
-
try:
|
31
|
-
# We only want to print colored messages if the given output supports
|
32
|
-
# ANSI escape sequences. Usually, testing if it is a TTY is safe enough.
|
33
|
-
self._colors_supported = self.output.isatty()
|
34
|
-
except AttributeError:
|
35
|
-
# If the given output does not implement isatty(), we assume that it
|
36
|
-
# is not able to handle ANSI escape sequences.
|
37
|
-
self._colors_supported = False
|
38
|
-
|
39
27
|
def write(self, message):
|
40
28
|
if message.type != "line":
|
41
29
|
raise RuntimeError('Printer can only process messages of type "line"')
|
@@ -58,28 +46,14 @@ class Printer:
|
|
58
46
|
if self.prefix:
|
59
47
|
time_formatted = message.time.strftime(self.time_format)
|
60
48
|
prefix = f"{time_formatted} {name}| "
|
61
|
-
if self.color and
|
49
|
+
if self.color and message.color:
|
62
50
|
prefix = _color_string(message.color, prefix)
|
63
|
-
print(prefix + line, file=self.output, flush=True)
|
64
51
|
|
65
|
-
|
66
|
-
def _ansi(code):
|
67
|
-
return f"\033[{code}m"
|
52
|
+
self.print_func(prefix + line)
|
68
53
|
|
69
54
|
|
70
55
|
def _color_string(color, s):
|
71
|
-
|
56
|
+
def _ansi(code):
|
57
|
+
return f"\033[{code}m"
|
72
58
|
|
73
|
-
|
74
|
-
if ON_WINDOWS:
|
75
|
-
# The colorama package provides transparent support for ANSI color codes
|
76
|
-
# on Win32 platforms. We try and import and configure that, but fall back
|
77
|
-
# to no color if we fail.
|
78
|
-
try:
|
79
|
-
import colorama
|
80
|
-
except ImportError:
|
81
|
-
|
82
|
-
def _color_string(color, s):
|
83
|
-
return s
|
84
|
-
else:
|
85
|
-
colorama.init()
|
59
|
+
return f"{_ansi(0)}{_ansi(color)}{s}{_ansi(0)}"
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: plain.dev
|
3
|
-
Version: 0.
|
3
|
+
Version: 0.16.0
|
4
4
|
Summary: Local development tools for Plain.
|
5
5
|
Author-email: Dave Gaeddert <dave.gaeddert@dropseed.dev>
|
6
6
|
License-Expression: BSD-3-Clause
|
@@ -13,6 +13,7 @@ Requires-Dist: plain<1.0.0
|
|
13
13
|
Requires-Dist: psycopg[binary]~=3.2.2
|
14
14
|
Requires-Dist: python-dotenv~=1.0.0
|
15
15
|
Requires-Dist: requests>=2.0.0
|
16
|
+
Requires-Dist: rich
|
16
17
|
Description-Content-Type: text/markdown
|
17
18
|
|
18
19
|
<!-- This file is compiled from plain-dev/plain/dev/README.md. Do not edit this file directly. -->
|
@@ -1,6 +1,6 @@
|
|
1
1
|
plain/dev/README.md,sha256=-yR4qzwEP7vDVvCAHJ22aaQHQ7rXVW9uy0KEZjCzmz4,3662
|
2
2
|
plain/dev/__init__.py,sha256=C1JrkNE5XX2DLgBXXLAV_UyhofwVd0ZPL59fPUMbOKo,139
|
3
|
-
plain/dev/cli.py,sha256=
|
3
|
+
plain/dev/cli.py,sha256=La7Tcw6Szla-eTAqnQkbKYv_ctzHPd7f5YNtd1acAsA,11924
|
4
4
|
plain/dev/debug.py,sha256=fIrecLfAK_lXSDyn3WmYikzZSse3KY47xcVVbZqJGhk,294
|
5
5
|
plain/dev/default_settings.py,sha256=uXWYORWP_aRDwXIFXdu5kHyiBFUZzARIJdhPeFaX35c,75
|
6
6
|
plain/dev/entrypoints.py,sha256=qBTP2A9pgxQmZ9hGV0OiBL92v9wa7TeJdOXnKZcX6AE,81
|
@@ -13,7 +13,7 @@ plain/dev/urls.py,sha256=b4NL2I6Ok-t7nTPjRnKoz_LQRttE3_mp8l2NlmeYQ9I,146
|
|
13
13
|
plain/dev/utils.py,sha256=4wMzpvj1Is_c0QxhsTu34_P9wAYlzw4glNPfVtZr_0A,123
|
14
14
|
plain/dev/views.py,sha256=r2Ivk7OXytpRhXq4DZpsb7FXNP9vzmEE3D5kLajYG4w,1073
|
15
15
|
plain/dev/contribute/__init__.py,sha256=9ByBOIdM8DebChjNz-RH2atdz4vWe8somlwNEsbhwh4,40
|
16
|
-
plain/dev/contribute/cli.py,sha256=
|
16
|
+
plain/dev/contribute/cli.py,sha256=mIK4u1rhee8iMovUpuHTNjfWolqNgS24_gTb8ZaSY-8,2432
|
17
17
|
plain/dev/db/__init__.py,sha256=9ByBOIdM8DebChjNz-RH2atdz4vWe8somlwNEsbhwh4,40
|
18
18
|
plain/dev/db/cli.py,sha256=058HjRKLGz-FxauQEpwsPoh_LCiy-_NEIpRZl9W1ZKM,2855
|
19
19
|
plain/dev/db/container.py,sha256=RlPJU_CCMKA-zN8Kp0sYAu3jabOizxYAj8fSCsjCf60,5147
|
@@ -21,13 +21,13 @@ plain/dev/poncho/__init__.py,sha256=MDOk2rhhoR3V-I-rg6tMHFeX60vTGJuQ14RI-_N6tQY,
|
|
21
21
|
plain/dev/poncho/color.py,sha256=Dk77inPR9qNc9vCaZOGk8W9skXfRgoUlxp_E6mhPNns,610
|
22
22
|
plain/dev/poncho/compat.py,sha256=l66WZLR7kRpO8P8DI5-aUsbNlohPaXEurQ5xXESQYDs,1276
|
23
23
|
plain/dev/poncho/manager.py,sha256=l_m_RhNTF9Fs6p0Tk8pdjd5ZxQxU1kbGEgDD-qJaFGs,6366
|
24
|
-
plain/dev/poncho/printer.py,sha256=
|
24
|
+
plain/dev/poncho/printer.py,sha256=wt1ioaGcPnVyrPy-UjvdsR9zfcr4DTTycmapW1MIdSU,1785
|
25
25
|
plain/dev/poncho/process.py,sha256=JJOKy-C6vMCg7-6JMCtu6C649h7HmOBSJqDP_hnX49I,2637
|
26
26
|
plain/dev/precommit/__init__.py,sha256=9ByBOIdM8DebChjNz-RH2atdz4vWe8somlwNEsbhwh4,40
|
27
27
|
plain/dev/precommit/cli.py,sha256=D_A5Mk2eXqjJDSUE6qyCFFddhM7wBZR3C9hgkDRx_v8,3411
|
28
28
|
plain/dev/templates/dev/requests.html,sha256=kQKJZq5L77juuL_t8UjcAehEU61U4RXNnKaAET-wAm8,7627
|
29
|
-
plain_dev-0.
|
30
|
-
plain_dev-0.
|
31
|
-
plain_dev-0.
|
32
|
-
plain_dev-0.
|
33
|
-
plain_dev-0.
|
29
|
+
plain_dev-0.16.0.dist-info/METADATA,sha256=YNoKWIzI0wrsff1bmX6HCdFD8xFl6NiHRx5PkffCtzg,4274
|
30
|
+
plain_dev-0.16.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
31
|
+
plain_dev-0.16.0.dist-info/entry_points.txt,sha256=jncRPB4B7d27YWkzWqzt68y534ntliHPNukv_kQu5KY,171
|
32
|
+
plain_dev-0.16.0.dist-info/licenses/LICENSE,sha256=YDg-l_Rj7LVP5uDXy04eQPGb_DYVXAHAHYd9r3pU1Cg,2713
|
33
|
+
plain_dev-0.16.0.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|