plain 0.18.0__py3-none-any.whl → 0.19.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/assets/views.py CHANGED
@@ -28,8 +28,11 @@ class AssetView(View):
28
28
  This class could be subclassed to further tweak the responses or behavior.
29
29
  """
30
30
 
31
+ def get_url_path(self):
32
+ return self.url_kwargs["path"]
33
+
31
34
  def get(self):
32
- url_path = self.url_kwargs["path"]
35
+ url_path = self.get_url_path()
33
36
 
34
37
  # Make a trailing slash work, but we don't expect it
35
38
  url_path = url_path.rstrip("/")
plain/cli/cli.py CHANGED
@@ -1,9 +1,9 @@
1
1
  import importlib
2
- import json
3
2
  import os
4
3
  import shutil
5
4
  import subprocess
6
5
  import sys
6
+ import tomllib
7
7
  import traceback
8
8
  from importlib.metadata import entry_points
9
9
  from importlib.util import find_spec
@@ -292,22 +292,23 @@ def compile(keep_original, fingerprint, compress):
292
292
  result = entry_point.load()()
293
293
  print()
294
294
 
295
- # TODO also look in [tool.plain.compile.run]
296
-
297
- # Run a "compile" script from package.json automatically
298
- package_json = Path("package.json")
299
- if package_json.exists():
300
- with package_json.open() as f:
301
- package = json.load(f)
302
-
303
- if package.get("scripts", {}).get("compile"):
304
- click.secho("Running `npm run compile`", bold=True)
305
- result = subprocess.run(["npm", "run", "compile"])
295
+ pyproject_path = plain.runtime.APP_PATH.parent / "pyproject.toml"
296
+ if pyproject_path.exists():
297
+ with pyproject_path.open("rb") as f:
298
+ pyproject = tomllib.load(f)
299
+
300
+ for name, data in (
301
+ pyproject.get("tool", {})
302
+ .get("plain", {})
303
+ .get("compile", {})
304
+ .get("run", {})
305
+ .items()
306
+ ):
307
+ click.secho(f"Running {name} from pyproject.toml", bold=True)
308
+ result = subprocess.run(data["cmd"], shell=True)
306
309
  print()
307
310
  if result.returncode:
308
- click.secho(
309
- f"Error in `npm run compile` (exit {result.returncode})", fg="red"
310
- )
311
+ click.secho(f"Error in {name} (exit {result.returncode})", fg="red")
311
312
  sys.exit(result.returncode)
312
313
 
313
314
  # Compile our assets
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: plain
3
- Version: 0.18.0
3
+ Version: 0.19.0
4
4
  Summary: A web framework for building products with Python.
5
5
  Author-email: Dave Gaeddert <dave.gaeddert@dropseed.dev>
6
6
  License-File: LICENSE
@@ -13,10 +13,10 @@ plain/assets/compile.py,sha256=lsnciN85YjHe6d8VIKJi1L8r7NGHNzMOe9L87wObM5I,3287
13
13
  plain/assets/finders.py,sha256=WEKAnXTmpuQ7UKLZz7vHPrKFdDOkuZSP6_JTKmIxrKg,1268
14
14
  plain/assets/fingerprints.py,sha256=1NKAnnXVlncY5iimXztr0NL3RIjBKsNlZRIe6nmItJc,931
15
15
  plain/assets/urls.py,sha256=ZTIoM1Zq35JaXZ3wFhXhfGa7VoITDNlH9i5RS0R5xow,933
16
- plain/assets/views.py,sha256=dhjIpMu0GDR_VGbXM90_6RnC84C2C4bFv1RxDVklGBk,9173
16
+ plain/assets/views.py,sha256=2Y2KVJinlaMBB2ZyMAVPj_ejuMv3cCO079TN8lSsbd8,9237
17
17
  plain/cli/README.md,sha256=TvWCnNwb1rNthPzJglCRMKacN5H_RLeEjYBMe62Uz4M,2461
18
18
  plain/cli/__init__.py,sha256=9ByBOIdM8DebChjNz-RH2atdz4vWe8somlwNEsbhwh4,40
19
- plain/cli/cli.py,sha256=akk7koDuFXNpFPsSv4mzJNbtEuXTSXTeMFhFGUbbB9A,14426
19
+ plain/cli/cli.py,sha256=LuX6wNx_HdWwUaeB-4TWiBNn7Uhn94AJ-Db-hrPFin8,14454
20
20
  plain/cli/formatting.py,sha256=1hZH13y1qwHcU2K2_Na388nw9uvoeQH8LrWL-O9h8Yc,2207
21
21
  plain/cli/packages.py,sha256=FqRJaizaxpQ8lSS4nYNjqIGpYGDbeTmCXCvkGxusGOM,2160
22
22
  plain/cli/print.py,sha256=XraUYrgODOJquIiEv78wSCYGRBplHXtXSS9QtFG5hqY,217
@@ -138,8 +138,8 @@ plain/views/forms.py,sha256=RhlaUcZCkeqokY_fvv-NOS-kgZAG4XhDLOPbf9K_Zlc,2691
138
138
  plain/views/objects.py,sha256=fRfS6KNehIGqkbPw4nSafj8HStxYExHmbggolBbzcxs,7921
139
139
  plain/views/redirect.py,sha256=KLnlktzK6ZNMTlaEiZpMKQMEP5zeTgGLJ9BIkIJfwBo,1733
140
140
  plain/views/templates.py,sha256=nF9CcdhhjAyp3LB0RrSYnBaHpHzMfPSw719RCdcXk7o,2007
141
- plain-0.18.0.dist-info/METADATA,sha256=Qik7zQyhLtbB8QcE6qwCar14RSDbiFaalX_6-VejaBc,2518
142
- plain-0.18.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
143
- plain-0.18.0.dist-info/entry_points.txt,sha256=DHHprvufgd7xypiBiqMANYRnpJ9xPPYhYbnPGwOkWqE,40
144
- plain-0.18.0.dist-info/licenses/LICENSE,sha256=m0D5O7QoH9l5Vz_rrX_9r-C8d9UNr_ciK6Qwac7o6yo,3175
145
- plain-0.18.0.dist-info/RECORD,,
141
+ plain-0.19.0.dist-info/METADATA,sha256=DN5qV_oxbzA6AKRICXSzZ2xhdhKI8w8T_K8SgZiwwNE,2518
142
+ plain-0.19.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
143
+ plain-0.19.0.dist-info/entry_points.txt,sha256=DHHprvufgd7xypiBiqMANYRnpJ9xPPYhYbnPGwOkWqE,40
144
+ plain-0.19.0.dist-info/licenses/LICENSE,sha256=m0D5O7QoH9l5Vz_rrX_9r-C8d9UNr_ciK6Qwac7o6yo,3175
145
+ plain-0.19.0.dist-info/RECORD,,
File without changes