litestar-vite 0.11.0__py3-none-any.whl → 0.11.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.

Potentially problematic release.


This version of litestar-vite might be problematic. Click here for more details.

litestar_vite/commands.py CHANGED
@@ -14,7 +14,7 @@ DEFAULT_RESOURCES: set[str] = {"styles.css.j2", "main.ts.j2"}
14
14
  DEFAULT_DEV_DEPENDENCIES: dict[str, str] = {
15
15
  "typescript": "^5.7.2",
16
16
  "vite": "^6.0.3",
17
- "litestar-vite-plugin": "^0.11.0",
17
+ "litestar-vite-plugin": "^0.11.1",
18
18
  "@types/node": "^22.10.1",
19
19
  }
20
20
  DEFAULT_DEPENDENCIES: dict[str, str] = {"axios": "^1.7.2"}
litestar_vite/plugin.py CHANGED
@@ -1,12 +1,15 @@
1
1
  from __future__ import annotations
2
2
 
3
3
  import os
4
+ import platform
4
5
  import signal
6
+ import subprocess
5
7
  import threading
6
8
  from contextlib import contextmanager
7
9
  from pathlib import Path
8
10
  from typing import TYPE_CHECKING, Iterator, cast
9
11
 
12
+ from litestar.cli._utils import console
10
13
  from litestar.contrib.jinja import JinjaTemplateEngine
11
14
  from litestar.exceptions import ImproperlyConfiguredException
12
15
  from litestar.plugins import CLIPlugin, InitPluginProtocol
@@ -37,50 +40,43 @@ class ViteProcess:
37
40
  """Manages the Vite process."""
38
41
 
39
42
  def __init__(self) -> None:
40
- self.process: threading.Thread | None = None
43
+ self.process: subprocess.Popen | None = None # pyright: ignore[reportUnknownMemberType,reportMissingTypeArgument]
41
44
  self._lock = threading.Lock()
42
45
 
43
46
  def start(self, command: list[str], cwd: Path | str | None) -> None:
44
47
  """Start the Vite process."""
45
- from litestar.cli._utils import console
46
-
47
- from litestar_vite.commands import execute_command
48
48
 
49
49
  try:
50
50
  with self._lock:
51
- if self.process and self.process.is_alive():
51
+ if self.process and self.process.poll() is None: # pyright: ignore[reportUnknownMemberType]
52
52
  return
53
53
 
54
- self.process = threading.Thread(
55
- name="vite",
56
- target=execute_command,
57
- args=[],
58
- kwargs={"command_to_run": command, "cwd": cwd},
59
- daemon=True, # Make thread daemon so it exits when main thread exits
60
- )
61
54
  console.print(f"Starting Vite process with command: {command}")
62
- self.process.start()
55
+ self.process = subprocess.Popen(
56
+ command,
57
+ cwd=cwd,
58
+ shell=platform.system() == "Windows",
59
+ )
63
60
  except Exception as e:
64
61
  console.print(f"[red]Failed to start Vite process: {e!s}[/]")
65
62
  raise
66
63
 
67
64
  def stop(self, timeout: float = 5.0) -> None:
68
65
  """Stop the Vite process."""
69
- from litestar.cli._utils import console
70
66
 
71
67
  try:
72
68
  with self._lock:
73
- if self.process and self.process.is_alive():
69
+ if self.process and self.process.poll() is None: # pyright: ignore[reportUnknownMemberType]
74
70
  # Send SIGTERM to child process
75
- if hasattr(signal, "SIGTERM") and self.process.ident is not None:
76
- os.kill(self.process.ident, signal.SIGTERM)
77
- self.process.join(timeout=timeout)
78
-
79
- # Force kill if still alive
80
- if self.process.is_alive():
81
- if hasattr(signal, "SIGKILL") and self.process.ident is not None:
82
- os.kill(self.process.ident, signal.SIGKILL)
83
- self.process.join(timeout=1.0)
71
+ if hasattr(signal, "SIGTERM"):
72
+ self.process.terminate() # pyright: ignore[reportUnknownMemberType]
73
+ try:
74
+ self.process.wait(timeout=timeout) # pyright: ignore[reportUnknownMemberType]
75
+ except subprocess.TimeoutExpired:
76
+ # Force kill if still alive
77
+ if hasattr(signal, "SIGKILL"):
78
+ self.process.kill() # pyright: ignore[reportUnknownMemberType]
79
+ self.process.wait(timeout=1.0) # pyright: ignore[reportUnknownMemberType]
84
80
  console.print("Stopping Vite process")
85
81
  except Exception as e:
86
82
  console.print(f"[red]Failed to stop Vite process: {e!s}[/]")
@@ -168,7 +164,6 @@ class VitePlugin(InitPluginProtocol, CLIPlugin):
168
164
  @contextmanager
169
165
  def server_lifespan(self, app: Litestar) -> Iterator[None]:
170
166
  """Manage Vite server process lifecycle."""
171
- from litestar.cli._utils import console
172
167
 
173
168
  if self._config.use_server_lifespan and self._config.dev_mode:
174
169
  command_to_run = self._config.run_command if self._config.hot_reload else self._config.build_watch_command
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: litestar-vite
3
- Version: 0.11.0
3
+ Version: 0.11.1
4
4
  Summary: Vite plugin for Litestar
5
5
  Project-URL: Changelog, https://cofin.github.io/litestar-vite/latest/changelog
6
6
  Project-URL: Discord, https://discord.gg/X3FJqy8d2j
@@ -1,10 +1,10 @@
1
1
  litestar_vite/__init__.py,sha256=OioNGhH88mdivQlFz9JlbJV8R6wyjSYE3c8C-RIM4Ls,277
2
2
  litestar_vite/__metadata__.py,sha256=_Wo-vNQuj5co9J4FwJAB2rRafbFo8ztTHrXmEPrYrV8,514
3
3
  litestar_vite/cli.py,sha256=CBSRohDLU9cDeKMAfSbFiw1x8OE_b15ZlUaxji9Rdw8,10749
4
- litestar_vite/commands.py,sha256=aGpSmrRfArSg4hkpL6GTuKZPRyZm1y-qhon0P5mUoEQ,5228
4
+ litestar_vite/commands.py,sha256=E-PaU7Hk9BDj63d8u7-FSwR8oH9hfSB41BGOpmVuv3o,5228
5
5
  litestar_vite/config.py,sha256=cZWIwTwNnBYScCty8OxxPaOL8cELx57dm7JQeV8og3Y,4565
6
6
  litestar_vite/loader.py,sha256=nrXL2txXoBZEsdLZnysgBYZSreMXQ7ckLuNcu7MqnSM,10277
7
- litestar_vite/plugin.py,sha256=XZ1RxyRS9aX3coJis02Uv2AMB2frI2eqKSlK_zZWwSY,8091
7
+ litestar_vite/plugin.py,sha256=2ypzvlW5TaOeXTWPa2yHXzkPUf4okRBDl9YHo2qg-cM,8043
8
8
  litestar_vite/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
9
9
  litestar_vite/inertia/__init__.py,sha256=Fab61KXbBnyub2Nx-2AHYv2U6QiYUIrqhEZia_f9xik,863
10
10
  litestar_vite/inertia/_utils.py,sha256=ijO9Lgka7ZPIAHkby9szbTGoSg0nDShC2bqWT9cDxi0,1956
@@ -23,7 +23,7 @@ litestar_vite/templates/package.json.j2,sha256=0JWgdTuaSZ25EmCltF_zbqDdpxfvCLeYu
23
23
  litestar_vite/templates/styles.css.j2,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
24
24
  litestar_vite/templates/tsconfig.json.j2,sha256=q1REIuVyXUHCy4Zi2kgTkmrhdT98vyY89k-WTrImOj8,843
25
25
  litestar_vite/templates/vite.config.ts.j2,sha256=bF5kOPFafYMkhhV0VkIwetN-_zoVMGVM1jEMX_wKoNc,1037
26
- litestar_vite-0.11.0.dist-info/METADATA,sha256=vwSng0cRQYYu4oWOP7a0auIl2p7kLiaxUCOS3TT5fAA,6222
27
- litestar_vite-0.11.0.dist-info/WHEEL,sha256=C2FUgwZgiLbznR-k0b_5k3Ai_1aASOXDss3lzCUsUug,87
28
- litestar_vite-0.11.0.dist-info/licenses/LICENSE,sha256=HeTiEfEgvroUXZe_xAmYHxtTBgw--mbXyZLsWDYabHc,1069
29
- litestar_vite-0.11.0.dist-info/RECORD,,
26
+ litestar_vite-0.11.1.dist-info/METADATA,sha256=_qb3u3hyEBieCsfpMOPNBSjCPRfX8JH9tt0UyJOxh5Y,6222
27
+ litestar_vite-0.11.1.dist-info/WHEEL,sha256=C2FUgwZgiLbznR-k0b_5k3Ai_1aASOXDss3lzCUsUug,87
28
+ litestar_vite-0.11.1.dist-info/licenses/LICENSE,sha256=HeTiEfEgvroUXZe_xAmYHxtTBgw--mbXyZLsWDYabHc,1069
29
+ litestar_vite-0.11.1.dist-info/RECORD,,