plain.dev 0.12.0__py3-none-any.whl → 0.14.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 +40 -17
- plain/dev/contribute/cli.py +25 -30
- {plain_dev-0.12.0.dist-info → plain_dev-0.14.0.dist-info}/METADATA +1 -1
- {plain_dev-0.12.0.dist-info → plain_dev-0.14.0.dist-info}/RECORD +7 -7
- {plain_dev-0.12.0.dist-info → plain_dev-0.14.0.dist-info}/LICENSE +0 -0
- {plain_dev-0.12.0.dist-info → plain_dev-0.14.0.dist-info}/WHEEL +0 -0
- {plain_dev-0.12.0.dist-info → plain_dev-0.14.0.dist-info}/entry_points.txt +0 -0
plain/dev/cli.py
CHANGED
@@ -30,15 +30,32 @@ ENTRYPOINT_GROUP = "plain.dev"
|
|
30
30
|
default=8443,
|
31
31
|
type=int,
|
32
32
|
help="Port to run the web server on",
|
33
|
-
envvar="PORT",
|
34
33
|
)
|
35
|
-
|
34
|
+
@click.option(
|
35
|
+
"--hostname",
|
36
|
+
"-h",
|
37
|
+
default=None,
|
38
|
+
type=str,
|
39
|
+
help="Hostname to run the web server on",
|
40
|
+
)
|
41
|
+
@click.option(
|
42
|
+
"--log-level",
|
43
|
+
"-l",
|
44
|
+
default="info",
|
45
|
+
type=click.Choice(["debug", "info", "warning", "error", "critical"]),
|
46
|
+
help="Log level",
|
47
|
+
)
|
48
|
+
def cli(ctx, port, hostname, log_level):
|
36
49
|
"""Start local development"""
|
37
50
|
|
38
51
|
if ctx.invoked_subcommand:
|
39
52
|
return
|
40
53
|
|
41
|
-
|
54
|
+
if not hostname:
|
55
|
+
project_name = os.path.basename(os.getcwd())
|
56
|
+
hostname = f"{project_name}.localhost"
|
57
|
+
|
58
|
+
returncode = Dev(port=port, hostname=hostname, log_level=log_level).run()
|
42
59
|
if returncode:
|
43
60
|
sys.exit(returncode)
|
44
61
|
|
@@ -68,19 +85,23 @@ def entrypoint(show_list, entrypoint):
|
|
68
85
|
|
69
86
|
|
70
87
|
class Dev:
|
71
|
-
def __init__(self, *, port):
|
72
|
-
self.poncho = PonchoManager()
|
88
|
+
def __init__(self, *, port, hostname, log_level):
|
73
89
|
self.port = port
|
74
|
-
self.
|
75
|
-
self.
|
76
|
-
|
90
|
+
self.hostname = hostname
|
91
|
+
self.log_level = log_level
|
92
|
+
|
93
|
+
self.poncho = PonchoManager()
|
94
|
+
|
77
95
|
self.ssl_key_path = None
|
96
|
+
self.ssl_cert_path = None
|
78
97
|
|
79
|
-
self.url = f"https://{self.
|
98
|
+
self.url = f"https://{self.hostname}:{self.port}"
|
80
99
|
|
81
100
|
self.plain_env = {
|
82
|
-
**os.environ,
|
83
101
|
"PYTHONUNBUFFERED": "true",
|
102
|
+
"PLAIN_LOG_LEVEL": self.log_level.upper(),
|
103
|
+
"APP_LOG_LEVEL": self.log_level.upper(),
|
104
|
+
**os.environ,
|
84
105
|
}
|
85
106
|
self.custom_process_env = {
|
86
107
|
**self.plain_env,
|
@@ -96,7 +117,7 @@ class Dev:
|
|
96
117
|
mkcert_manager = MkcertManager()
|
97
118
|
mkcert_manager.setup_mkcert(install_path=Path.home() / ".plain" / "dev")
|
98
119
|
self.ssl_cert_path, self.ssl_key_path = mkcert_manager.generate_certs(
|
99
|
-
domain=self.
|
120
|
+
domain=self.hostname,
|
100
121
|
storage_path=Path(settings.PLAIN_TEMP_PATH) / "dev" / "certs",
|
101
122
|
)
|
102
123
|
self.modify_hosts_file()
|
@@ -126,7 +147,7 @@ class Dev:
|
|
126
147
|
def modify_hosts_file(self):
|
127
148
|
"""Modify the hosts file to map the custom domain to 127.0.0.1."""
|
128
149
|
entry_identifier = "# Added by plain"
|
129
|
-
hosts_entry = f"127.0.0.1 {self.
|
150
|
+
hosts_entry = f"127.0.0.1 {self.hostname} {entry_identifier}"
|
130
151
|
|
131
152
|
if platform.system() == "Windows":
|
132
153
|
hosts_path = Path(r"C:\Windows\System32\drivers\etc\hosts")
|
@@ -140,7 +161,7 @@ class Dev:
|
|
140
161
|
# Entry does not exist; add it
|
141
162
|
with hosts_path.open("a") as f:
|
142
163
|
f.write(f"{hosts_entry}\n")
|
143
|
-
click.secho(f"Added {self.
|
164
|
+
click.secho(f"Added {self.hostname} to {hosts_path}", bold=True)
|
144
165
|
except PermissionError:
|
145
166
|
click.secho(
|
146
167
|
"Permission denied while modifying hosts file. Please run the script as an administrator.",
|
@@ -159,12 +180,12 @@ class Dev:
|
|
159
180
|
|
160
181
|
# Entry does not exist; append it using sudo
|
161
182
|
click.secho(
|
162
|
-
f"Adding {self.
|
183
|
+
f"Adding {self.hostname} to /etc/hosts file. You may be prompted for your password.\n",
|
163
184
|
bold=True,
|
164
185
|
)
|
165
186
|
cmd = f"echo '{hosts_entry}' | sudo tee -a {hosts_path} >/dev/null"
|
166
187
|
subprocess.run(cmd, shell=True, check=True)
|
167
|
-
click.secho(f"Added {self.
|
188
|
+
click.secho(f"Added {self.hostname} to {hosts_path}\n", bold=True)
|
168
189
|
except PermissionError:
|
169
190
|
click.secho(
|
170
191
|
"Permission denied while accessing hosts file.",
|
@@ -184,7 +205,7 @@ class Dev:
|
|
184
205
|
self.url,
|
185
206
|
]
|
186
207
|
)
|
187
|
-
allowed_hosts = json.dumps([self.
|
208
|
+
allowed_hosts = json.dumps([self.hostname])
|
188
209
|
|
189
210
|
# Set environment variables
|
190
211
|
self.plain_env["PLAIN_CSRF_TRUSTED_ORIGINS"] = csrf_trusted_origins
|
@@ -217,7 +238,7 @@ class Dev:
|
|
217
238
|
gunicorn_cmd = [
|
218
239
|
"gunicorn",
|
219
240
|
"--bind",
|
220
|
-
f"{self.
|
241
|
+
f"{self.hostname}:{self.port}",
|
221
242
|
"--certfile",
|
222
243
|
str(self.ssl_cert_path),
|
223
244
|
"--keyfile",
|
@@ -226,6 +247,8 @@ class Dev:
|
|
226
247
|
"plain.wsgi:app",
|
227
248
|
"--timeout",
|
228
249
|
"60",
|
250
|
+
"--log-level",
|
251
|
+
self.log_level,
|
229
252
|
"--access-logfile",
|
230
253
|
"-",
|
231
254
|
"--error-logfile",
|
plain/dev/contribute/cli.py
CHANGED
@@ -7,11 +7,11 @@ import click
|
|
7
7
|
|
8
8
|
@click.command("contribute")
|
9
9
|
@click.option("--repo", default="../plain", help="Path to the plain repo")
|
10
|
-
@click.argument("
|
11
|
-
def cli(
|
12
|
-
"""Contribute to plain by linking
|
10
|
+
@click.argument("packages", nargs=-1)
|
11
|
+
def cli(packages, repo):
|
12
|
+
"""Contribute to plain by linking packages locally."""
|
13
13
|
|
14
|
-
if
|
14
|
+
if "reset" in packages:
|
15
15
|
click.secho("Undoing any changes to pyproject.toml and uv.lock", bold=True)
|
16
16
|
result = subprocess.run(["git", "checkout", "pyproject.toml", "uv.lock"])
|
17
17
|
if result.returncode:
|
@@ -46,33 +46,28 @@ def cli(package, repo):
|
|
46
46
|
)
|
47
47
|
click.secho(f"Using repo at {repo} ({repo_branch} branch)", bold=True)
|
48
48
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
49
|
+
plain_packages = []
|
50
|
+
plainx_packages = []
|
51
|
+
|
52
|
+
for package in packages:
|
53
|
+
package = package.replace(".", "-")
|
54
|
+
click.secho(f"Linking {package} to {repo}", bold=True)
|
55
|
+
if package == "plain" or package.startswith("plain-"):
|
56
|
+
plain_packages.append(str(repo / package))
|
57
|
+
elif package.startswith("plainx-"):
|
58
|
+
plainx_packages.append(str(repo))
|
59
|
+
else:
|
60
|
+
click.secho(f"Unknown package {package}", fg="red")
|
61
|
+
sys.exit(2)
|
62
|
+
|
63
|
+
if plain_packages:
|
64
|
+
result = subprocess.run(["uv", "add", "--editable", "--dev"] + plain_packages)
|
60
65
|
if result.returncode:
|
61
|
-
click.secho("Failed to link
|
66
|
+
click.secho("Failed to link plain packages", fg="red")
|
62
67
|
sys.exit(result.returncode)
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
"uv",
|
67
|
-
"add",
|
68
|
-
"--editable",
|
69
|
-
"--dev",
|
70
|
-
str(repo),
|
71
|
-
]
|
72
|
-
)
|
68
|
+
|
69
|
+
if plainx_packages:
|
70
|
+
result = subprocess.run(["uv", "add", "--editable", "--dev"] + plainx_packages)
|
73
71
|
if result.returncode:
|
74
|
-
click.secho("Failed to link
|
72
|
+
click.secho("Failed to link plainx packages", fg="red")
|
75
73
|
sys.exit(result.returncode)
|
76
|
-
else:
|
77
|
-
click.secho(f"Unknown package {package}", fg="red")
|
78
|
-
sys.exit(2)
|
@@ -1,9 +1,9 @@
|
|
1
1
|
plain/dev/README.md,sha256=BQDaRKfsafIPzx7vtVt-zS-a8l6sxbQThhQTvu7tp3Y,3699
|
2
2
|
plain/dev/__init__.py,sha256=C1JrkNE5XX2DLgBXXLAV_UyhofwVd0ZPL59fPUMbOKo,139
|
3
|
-
plain/dev/cli.py,sha256=
|
3
|
+
plain/dev/cli.py,sha256=IzO14253uPogLV2emmZHKhBQgc7mCtr8VmfhR_g2O7g,10082
|
4
4
|
plain/dev/config.py,sha256=h6o5YZtJhg-cFIWoqIDWuMCC5T09cxEsBaa3BP4Nii0,632
|
5
5
|
plain/dev/contribute/__init__.py,sha256=9ByBOIdM8DebChjNz-RH2atdz4vWe8somlwNEsbhwh4,40
|
6
|
-
plain/dev/contribute/cli.py,sha256=
|
6
|
+
plain/dev/contribute/cli.py,sha256=vrHSYM0Y2XtIUbxmNcJqssoPN-ZbkH4T_p65NVkYrV4,2339
|
7
7
|
plain/dev/db/__init__.py,sha256=9ByBOIdM8DebChjNz-RH2atdz4vWe8somlwNEsbhwh4,40
|
8
8
|
plain/dev/db/cli.py,sha256=058HjRKLGz-FxauQEpwsPoh_LCiy-_NEIpRZl9W1ZKM,2855
|
9
9
|
plain/dev/db/container.py,sha256=RlPJU_CCMKA-zN8Kp0sYAu3jabOizxYAj8fSCsjCf60,5147
|
@@ -27,8 +27,8 @@ plain/dev/templates/dev/requests.html,sha256=kQKJZq5L77juuL_t8UjcAehEU61U4RXNnKa
|
|
27
27
|
plain/dev/urls.py,sha256=b4NL2I6Ok-t7nTPjRnKoz_LQRttE3_mp8l2NlmeYQ9I,146
|
28
28
|
plain/dev/utils.py,sha256=4wMzpvj1Is_c0QxhsTu34_P9wAYlzw4glNPfVtZr_0A,123
|
29
29
|
plain/dev/views.py,sha256=r2Ivk7OXytpRhXq4DZpsb7FXNP9vzmEE3D5kLajYG4w,1073
|
30
|
-
plain_dev-0.
|
31
|
-
plain_dev-0.
|
32
|
-
plain_dev-0.
|
33
|
-
plain_dev-0.
|
34
|
-
plain_dev-0.
|
30
|
+
plain_dev-0.14.0.dist-info/LICENSE,sha256=YDg-l_Rj7LVP5uDXy04eQPGb_DYVXAHAHYd9r3pU1Cg,2713
|
31
|
+
plain_dev-0.14.0.dist-info/METADATA,sha256=4g2sbwYs-P6FvdpJfOvXSERFu0vBB7r6j3wsBP74w8A,4722
|
32
|
+
plain_dev-0.14.0.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
|
33
|
+
plain_dev-0.14.0.dist-info/entry_points.txt,sha256=1FaE_73k95WYOJrmB0hcHBnEIFQa-Cfl56Z1LGxyvak,164
|
34
|
+
plain_dev-0.14.0.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|