plain.dev 0.11.0__tar.gz → 0.13.0__tar.gz

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.
Files changed (33) hide show
  1. {plain_dev-0.11.0 → plain_dev-0.13.0}/PKG-INFO +1 -1
  2. {plain_dev-0.11.0 → plain_dev-0.13.0}/plain/dev/cli.py +48 -20
  3. {plain_dev-0.11.0 → plain_dev-0.13.0}/pyproject.toml +1 -1
  4. {plain_dev-0.11.0 → plain_dev-0.13.0}/LICENSE +0 -0
  5. {plain_dev-0.11.0 → plain_dev-0.13.0}/README.md +0 -0
  6. {plain_dev-0.11.0 → plain_dev-0.13.0}/plain/dev/README.md +0 -0
  7. {plain_dev-0.11.0 → plain_dev-0.13.0}/plain/dev/__init__.py +0 -0
  8. {plain_dev-0.11.0 → plain_dev-0.13.0}/plain/dev/config.py +0 -0
  9. {plain_dev-0.11.0 → plain_dev-0.13.0}/plain/dev/contribute/__init__.py +0 -0
  10. {plain_dev-0.11.0 → plain_dev-0.13.0}/plain/dev/contribute/cli.py +0 -0
  11. {plain_dev-0.11.0 → plain_dev-0.13.0}/plain/dev/db/__init__.py +0 -0
  12. {plain_dev-0.11.0 → plain_dev-0.13.0}/plain/dev/db/cli.py +0 -0
  13. {plain_dev-0.11.0 → plain_dev-0.13.0}/plain/dev/db/container.py +0 -0
  14. {plain_dev-0.11.0 → plain_dev-0.13.0}/plain/dev/debug.py +0 -0
  15. {plain_dev-0.11.0 → plain_dev-0.13.0}/plain/dev/default_settings.py +0 -0
  16. {plain_dev-0.11.0 → plain_dev-0.13.0}/plain/dev/entrypoints.py +0 -0
  17. {plain_dev-0.11.0 → plain_dev-0.13.0}/plain/dev/gunicorn_logging.json +0 -0
  18. {plain_dev-0.11.0 → plain_dev-0.13.0}/plain/dev/mkcert.py +0 -0
  19. {plain_dev-0.11.0 → plain_dev-0.13.0}/plain/dev/pid.py +0 -0
  20. {plain_dev-0.11.0 → plain_dev-0.13.0}/plain/dev/poncho/__init__.py +0 -0
  21. {plain_dev-0.11.0 → plain_dev-0.13.0}/plain/dev/poncho/color.py +0 -0
  22. {plain_dev-0.11.0 → plain_dev-0.13.0}/plain/dev/poncho/compat.py +0 -0
  23. {plain_dev-0.11.0 → plain_dev-0.13.0}/plain/dev/poncho/manager.py +0 -0
  24. {plain_dev-0.11.0 → plain_dev-0.13.0}/plain/dev/poncho/printer.py +0 -0
  25. {plain_dev-0.11.0 → plain_dev-0.13.0}/plain/dev/poncho/process.py +0 -0
  26. {plain_dev-0.11.0 → plain_dev-0.13.0}/plain/dev/precommit/__init__.py +0 -0
  27. {plain_dev-0.11.0 → plain_dev-0.13.0}/plain/dev/precommit/cli.py +0 -0
  28. {plain_dev-0.11.0 → plain_dev-0.13.0}/plain/dev/requests.py +0 -0
  29. {plain_dev-0.11.0 → plain_dev-0.13.0}/plain/dev/services.py +0 -0
  30. {plain_dev-0.11.0 → plain_dev-0.13.0}/plain/dev/templates/dev/requests.html +0 -0
  31. {plain_dev-0.11.0 → plain_dev-0.13.0}/plain/dev/urls.py +0 -0
  32. {plain_dev-0.11.0 → plain_dev-0.13.0}/plain/dev/utils.py +0 -0
  33. {plain_dev-0.11.0 → plain_dev-0.13.0}/plain/dev/views.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: plain.dev
3
- Version: 0.11.0
3
+ Version: 0.13.0
4
4
  Summary: Local development tools for Plain.
5
5
  Home-page: https://plainframework.com
6
6
  License: BSD-3-Clause
@@ -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
- def cli(ctx, port):
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
- returncode = Dev(port=port).run()
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,21 +85,29 @@ 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
90
+ self.hostname = hostname
91
+ self.log_level = log_level
92
+
93
+ self.poncho = PonchoManager()
94
+
95
+ self.ssl_key_path = None
96
+ self.ssl_cert_path = None
97
+
98
+ self.url = f"https://{self.hostname}:{self.port}"
99
+
74
100
  self.plain_env = {
75
- **os.environ,
76
101
  "PYTHONUNBUFFERED": "true",
102
+ "PLAIN_LOG_LEVEL": self.log_level.upper(),
103
+ "APP_LOG_LEVEL": self.log_level.upper(),
104
+ **os.environ,
77
105
  }
78
106
  self.custom_process_env = {
79
107
  **self.plain_env,
80
108
  "PORT": str(self.port),
109
+ "PLAIN_DEV_URL": self.url,
81
110
  }
82
- self.project_name = os.path.basename(os.getcwd())
83
- self.domain = f"{self.project_name}.localhost"
84
- self.ssl_cert_path = None
85
- self.ssl_key_path = None
86
111
 
87
112
  def run(self):
88
113
  pid = Pid()
@@ -92,7 +117,7 @@ class Dev:
92
117
  mkcert_manager = MkcertManager()
93
118
  mkcert_manager.setup_mkcert(install_path=Path.home() / ".plain" / "dev")
94
119
  self.ssl_cert_path, self.ssl_key_path = mkcert_manager.generate_certs(
95
- domain=self.domain,
120
+ domain=self.hostname,
96
121
  storage_path=Path(settings.PLAIN_TEMP_PATH) / "dev" / "certs",
97
122
  )
98
123
  self.modify_hosts_file()
@@ -106,9 +131,8 @@ class Dev:
106
131
  self.add_services()
107
132
 
108
133
  # Output the clickable link before starting the manager loop
109
- url = f"https://{self.domain}:{self.port}/"
110
134
  click.secho(
111
- f"\nYour app will run at: {click.style(url, fg='green', underline=True)}\n",
135
+ f"\nYour app will run at: {click.style(self.url, fg='green', underline=True)}\n",
112
136
  bold=True,
113
137
  )
114
138
 
@@ -123,7 +147,7 @@ class Dev:
123
147
  def modify_hosts_file(self):
124
148
  """Modify the hosts file to map the custom domain to 127.0.0.1."""
125
149
  entry_identifier = "# Added by plain"
126
- hosts_entry = f"127.0.0.1 {self.domain} {entry_identifier}"
150
+ hosts_entry = f"127.0.0.1 {self.hostname} {entry_identifier}"
127
151
 
128
152
  if platform.system() == "Windows":
129
153
  hosts_path = Path(r"C:\Windows\System32\drivers\etc\hosts")
@@ -137,7 +161,7 @@ class Dev:
137
161
  # Entry does not exist; add it
138
162
  with hosts_path.open("a") as f:
139
163
  f.write(f"{hosts_entry}\n")
140
- click.secho(f"Added {self.domain} to {hosts_path}", bold=True)
164
+ click.secho(f"Added {self.hostname} to {hosts_path}", bold=True)
141
165
  except PermissionError:
142
166
  click.secho(
143
167
  "Permission denied while modifying hosts file. Please run the script as an administrator.",
@@ -156,12 +180,12 @@ class Dev:
156
180
 
157
181
  # Entry does not exist; append it using sudo
158
182
  click.secho(
159
- "Modifying /etc/hosts file. You may be prompted for your password.\n",
183
+ f"Adding {self.hostname} to /etc/hosts file. You may be prompted for your password.\n",
160
184
  bold=True,
161
185
  )
162
186
  cmd = f"echo '{hosts_entry}' | sudo tee -a {hosts_path} >/dev/null"
163
187
  subprocess.run(cmd, shell=True, check=True)
164
- click.secho(f"Added {self.domain} to {hosts_path}\n", bold=True)
188
+ click.secho(f"Added {self.hostname} to {hosts_path}\n", bold=True)
165
189
  except PermissionError:
166
190
  click.secho(
167
191
  "Permission denied while accessing hosts file.",
@@ -178,10 +202,10 @@ class Dev:
178
202
  def set_csrf_and_allowed_hosts(self):
179
203
  csrf_trusted_origins = json.dumps(
180
204
  [
181
- f"https://{self.domain}:{self.port}",
205
+ self.url,
182
206
  ]
183
207
  )
184
- allowed_hosts = json.dumps([self.domain])
208
+ allowed_hosts = json.dumps([self.hostname])
185
209
 
186
210
  # Set environment variables
187
211
  self.plain_env["PLAIN_CSRF_TRUSTED_ORIGINS"] = csrf_trusted_origins
@@ -214,7 +238,7 @@ class Dev:
214
238
  gunicorn_cmd = [
215
239
  "gunicorn",
216
240
  "--bind",
217
- f"{self.domain}:{self.port}",
241
+ f"{self.hostname}:{self.port}",
218
242
  "--certfile",
219
243
  str(self.ssl_cert_path),
220
244
  "--keyfile",
@@ -223,6 +247,8 @@ class Dev:
223
247
  "plain.wsgi:app",
224
248
  "--timeout",
225
249
  "60",
250
+ "--log-level",
251
+ self.log_level,
226
252
  "--access-logfile",
227
253
  "-",
228
254
  "--error-logfile",
@@ -255,6 +281,7 @@ class Dev:
255
281
  )
256
282
 
257
283
  def add_pyproject_run(self):
284
+ """Additional processes that only run during `plain dev`."""
258
285
  if not has_pyproject_toml(APP_PATH.parent):
259
286
  return
260
287
 
@@ -272,6 +299,7 @@ class Dev:
272
299
  self.poncho.add_process(name, data["cmd"], env=env)
273
300
 
274
301
  def add_services(self):
302
+ """Services are things that also run during tests (like a database), and are critical for the app to function."""
275
303
  services = Services.get_services(APP_PATH.parent)
276
304
  for name, data in services.items():
277
305
  env = {
@@ -5,7 +5,7 @@ packages = [
5
5
  { include = "plain" },
6
6
  ]
7
7
 
8
- version = "0.11.0"
8
+ version = "0.13.0"
9
9
  description = "Local development tools for Plain."
10
10
  authors = ["Dave Gaeddert <dave.gaeddert@dropseed.dev>"]
11
11
  license = "BSD-3-Clause"
File without changes
File without changes
File without changes
File without changes