plain.dev 0.12.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.12.0 → plain_dev-0.13.0}/PKG-INFO +1 -1
  2. {plain_dev-0.12.0 → plain_dev-0.13.0}/plain/dev/cli.py +40 -17
  3. {plain_dev-0.12.0 → plain_dev-0.13.0}/pyproject.toml +1 -1
  4. {plain_dev-0.12.0 → plain_dev-0.13.0}/LICENSE +0 -0
  5. {plain_dev-0.12.0 → plain_dev-0.13.0}/README.md +0 -0
  6. {plain_dev-0.12.0 → plain_dev-0.13.0}/plain/dev/README.md +0 -0
  7. {plain_dev-0.12.0 → plain_dev-0.13.0}/plain/dev/__init__.py +0 -0
  8. {plain_dev-0.12.0 → plain_dev-0.13.0}/plain/dev/config.py +0 -0
  9. {plain_dev-0.12.0 → plain_dev-0.13.0}/plain/dev/contribute/__init__.py +0 -0
  10. {plain_dev-0.12.0 → plain_dev-0.13.0}/plain/dev/contribute/cli.py +0 -0
  11. {plain_dev-0.12.0 → plain_dev-0.13.0}/plain/dev/db/__init__.py +0 -0
  12. {plain_dev-0.12.0 → plain_dev-0.13.0}/plain/dev/db/cli.py +0 -0
  13. {plain_dev-0.12.0 → plain_dev-0.13.0}/plain/dev/db/container.py +0 -0
  14. {plain_dev-0.12.0 → plain_dev-0.13.0}/plain/dev/debug.py +0 -0
  15. {plain_dev-0.12.0 → plain_dev-0.13.0}/plain/dev/default_settings.py +0 -0
  16. {plain_dev-0.12.0 → plain_dev-0.13.0}/plain/dev/entrypoints.py +0 -0
  17. {plain_dev-0.12.0 → plain_dev-0.13.0}/plain/dev/gunicorn_logging.json +0 -0
  18. {plain_dev-0.12.0 → plain_dev-0.13.0}/plain/dev/mkcert.py +0 -0
  19. {plain_dev-0.12.0 → plain_dev-0.13.0}/plain/dev/pid.py +0 -0
  20. {plain_dev-0.12.0 → plain_dev-0.13.0}/plain/dev/poncho/__init__.py +0 -0
  21. {plain_dev-0.12.0 → plain_dev-0.13.0}/plain/dev/poncho/color.py +0 -0
  22. {plain_dev-0.12.0 → plain_dev-0.13.0}/plain/dev/poncho/compat.py +0 -0
  23. {plain_dev-0.12.0 → plain_dev-0.13.0}/plain/dev/poncho/manager.py +0 -0
  24. {plain_dev-0.12.0 → plain_dev-0.13.0}/plain/dev/poncho/printer.py +0 -0
  25. {plain_dev-0.12.0 → plain_dev-0.13.0}/plain/dev/poncho/process.py +0 -0
  26. {plain_dev-0.12.0 → plain_dev-0.13.0}/plain/dev/precommit/__init__.py +0 -0
  27. {plain_dev-0.12.0 → plain_dev-0.13.0}/plain/dev/precommit/cli.py +0 -0
  28. {plain_dev-0.12.0 → plain_dev-0.13.0}/plain/dev/requests.py +0 -0
  29. {plain_dev-0.12.0 → plain_dev-0.13.0}/plain/dev/services.py +0 -0
  30. {plain_dev-0.12.0 → plain_dev-0.13.0}/plain/dev/templates/dev/requests.html +0 -0
  31. {plain_dev-0.12.0 → plain_dev-0.13.0}/plain/dev/urls.py +0 -0
  32. {plain_dev-0.12.0 → plain_dev-0.13.0}/plain/dev/utils.py +0 -0
  33. {plain_dev-0.12.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.12.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,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.project_name = os.path.basename(os.getcwd())
75
- self.domain = f"{self.project_name}.localhost"
76
- self.ssl_cert_path = None
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.domain}:{self.port}"
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.domain,
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.domain} {entry_identifier}"
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.domain} to {hosts_path}", bold=True)
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.domain} to /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",
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.domain} to {hosts_path}\n", bold=True)
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.domain])
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.domain}:{self.port}",
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",
@@ -5,7 +5,7 @@ packages = [
5
5
  { include = "plain" },
6
6
  ]
7
7
 
8
- version = "0.12.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