plain 0.18.0__py3-none-any.whl → 0.19.1__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
@@ -287,29 +287,32 @@ def compile(keep_original, fingerprint, compress):
287
287
  )
288
288
  sys.exit(1)
289
289
 
290
+ # Run user-defined compile commands first
291
+ pyproject_path = plain.runtime.APP_PATH.parent / "pyproject.toml"
292
+ if pyproject_path.exists():
293
+ with pyproject_path.open("rb") as f:
294
+ pyproject = tomllib.load(f)
295
+
296
+ for name, data in (
297
+ pyproject.get("tool", {})
298
+ .get("plain", {})
299
+ .get("compile", {})
300
+ .get("run", {})
301
+ .items()
302
+ ):
303
+ click.secho(f"Running {name} from pyproject.toml", bold=True)
304
+ result = subprocess.run(data["cmd"], shell=True)
305
+ print()
306
+ if result.returncode:
307
+ click.secho(f"Error in {name} (exit {result.returncode})", fg="red")
308
+ sys.exit(result.returncode)
309
+
310
+ # Then run installed package compile steps (like tailwind, typically should run last...)
290
311
  for entry_point in entry_points(group="plain.assets.compile"):
291
312
  click.secho(f"Running {entry_point.name}", bold=True)
292
313
  result = entry_point.load()()
293
314
  print()
294
315
 
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"])
306
- print()
307
- if result.returncode:
308
- click.secho(
309
- f"Error in `npm run compile` (exit {result.returncode})", fg="red"
310
- )
311
- sys.exit(result.returncode)
312
-
313
316
  # Compile our assets
314
317
  target_dir = get_compiled_path()
315
318
  click.secho(f"Compiling assets to {target_dir}", bold=True)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: plain
3
- Version: 0.18.0
3
+ Version: 0.19.1
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=UNWIVnx2r2qn-eZejh2F_UA9C80HDNFysDd1rAWh2K4,14593
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.1.dist-info/METADATA,sha256=RlzXMJklCiL5RItFRnMBVVGWkv5DJ4mZWNWAQiTrToY,2518
142
+ plain-0.19.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
143
+ plain-0.19.1.dist-info/entry_points.txt,sha256=DHHprvufgd7xypiBiqMANYRnpJ9xPPYhYbnPGwOkWqE,40
144
+ plain-0.19.1.dist-info/licenses/LICENSE,sha256=m0D5O7QoH9l5Vz_rrX_9r-C8d9UNr_ciK6Qwac7o6yo,3175
145
+ plain-0.19.1.dist-info/RECORD,,
File without changes