litestar-vite 0.8.1__tar.gz → 0.8.2__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.

Potentially problematic release.


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

Files changed (72) hide show
  1. {litestar_vite-0.8.1 → litestar_vite-0.8.2}/.gitignore +1 -0
  2. {litestar_vite-0.8.1 → litestar_vite-0.8.2}/PKG-INFO +1 -1
  3. {litestar_vite-0.8.1 → litestar_vite-0.8.2}/pyproject.toml +8 -2
  4. {litestar_vite-0.8.1 → litestar_vite-0.8.2}/src/py/litestar_vite/cli.py +1 -5
  5. {litestar_vite-0.8.1 → litestar_vite-0.8.2}/src/py/litestar_vite/commands.py +21 -13
  6. {litestar_vite-0.8.1 → litestar_vite-0.8.2}/src/py/litestar_vite/config.py +2 -0
  7. {litestar_vite-0.8.1 → litestar_vite-0.8.2}/src/py/litestar_vite/templates/vite.config.ts.j2 +0 -1
  8. {litestar_vite-0.8.1 → litestar_vite-0.8.2}/src/py/tests/test_cli/test_init.py +16 -6
  9. {litestar_vite-0.8.1 → litestar_vite-0.8.2}/src/py/tests/test_config.py +3 -2
  10. {litestar_vite-0.8.1 → litestar_vite-0.8.2}/LICENSE +0 -0
  11. {litestar_vite-0.8.1 → litestar_vite-0.8.2}/README.md +0 -0
  12. {litestar_vite-0.8.1 → litestar_vite-0.8.2}/src/js/LICENSE +0 -0
  13. {litestar_vite-0.8.1 → litestar_vite-0.8.2}/src/js/Makefile +0 -0
  14. {litestar_vite-0.8.1 → litestar_vite-0.8.2}/src/js/NOTICE +0 -0
  15. {litestar_vite-0.8.1 → litestar_vite-0.8.2}/src/js/README.md +0 -0
  16. {litestar_vite-0.8.1 → litestar_vite-0.8.2}/src/js/src/dev-server-index.html +0 -0
  17. {litestar_vite-0.8.1 → litestar_vite-0.8.2}/src/js/src/index.ts +0 -0
  18. {litestar_vite-0.8.1 → litestar_vite-0.8.2}/src/js/src/inertia-helpers/index.ts +0 -0
  19. {litestar_vite-0.8.1 → litestar_vite-0.8.2}/src/js/tests/__data__/dummy.ts +0 -0
  20. {litestar_vite-0.8.1 → litestar_vite-0.8.2}/src/js/tests/index.test.ts +0 -0
  21. {litestar_vite-0.8.1 → litestar_vite-0.8.2}/src/js/tsconfig.inertia-helpers.json +0 -0
  22. {litestar_vite-0.8.1 → litestar_vite-0.8.2}/src/js/tsconfig.json +0 -0
  23. {litestar_vite-0.8.1 → litestar_vite-0.8.2}/src/js/vitest.config.ts +0 -0
  24. {litestar_vite-0.8.1 → litestar_vite-0.8.2}/src/js/vitest.workspace.ts +0 -0
  25. {litestar_vite-0.8.1 → litestar_vite-0.8.2}/src/py/litestar_vite/__init__.py +0 -0
  26. {litestar_vite-0.8.1 → litestar_vite-0.8.2}/src/py/litestar_vite/__metadata__.py +0 -0
  27. {litestar_vite-0.8.1 → litestar_vite-0.8.2}/src/py/litestar_vite/inertia/__init__.py +0 -0
  28. {litestar_vite-0.8.1 → litestar_vite-0.8.2}/src/py/litestar_vite/inertia/_utils.py +0 -0
  29. {litestar_vite-0.8.1 → litestar_vite-0.8.2}/src/py/litestar_vite/inertia/config.py +0 -0
  30. {litestar_vite-0.8.1 → litestar_vite-0.8.2}/src/py/litestar_vite/inertia/exception_handler.py +0 -0
  31. {litestar_vite-0.8.1 → litestar_vite-0.8.2}/src/py/litestar_vite/inertia/middleware.py +0 -0
  32. {litestar_vite-0.8.1 → litestar_vite-0.8.2}/src/py/litestar_vite/inertia/plugin.py +0 -0
  33. {litestar_vite-0.8.1 → litestar_vite-0.8.2}/src/py/litestar_vite/inertia/request.py +0 -0
  34. {litestar_vite-0.8.1 → litestar_vite-0.8.2}/src/py/litestar_vite/inertia/response.py +0 -0
  35. {litestar_vite-0.8.1 → litestar_vite-0.8.2}/src/py/litestar_vite/inertia/routes.py +0 -0
  36. {litestar_vite-0.8.1 → litestar_vite-0.8.2}/src/py/litestar_vite/inertia/types.py +0 -0
  37. {litestar_vite-0.8.1 → litestar_vite-0.8.2}/src/py/litestar_vite/loader.py +0 -0
  38. {litestar_vite-0.8.1 → litestar_vite-0.8.2}/src/py/litestar_vite/plugin.py +0 -0
  39. {litestar_vite-0.8.1 → litestar_vite-0.8.2}/src/py/litestar_vite/py.typed +0 -0
  40. {litestar_vite-0.8.1 → litestar_vite-0.8.2}/src/py/litestar_vite/template_engine.py +0 -0
  41. {litestar_vite-0.8.1 → litestar_vite-0.8.2}/src/py/litestar_vite/templates/__init__.py +0 -0
  42. {litestar_vite-0.8.1 → litestar_vite-0.8.2}/src/py/litestar_vite/templates/index.html.j2 +0 -0
  43. {litestar_vite-0.8.1 → litestar_vite-0.8.2}/src/py/litestar_vite/templates/main.ts.j2 +0 -0
  44. {litestar_vite-0.8.1 → litestar_vite-0.8.2}/src/py/litestar_vite/templates/package.json.j2 +0 -0
  45. {litestar_vite-0.8.1 → litestar_vite-0.8.2}/src/py/litestar_vite/templates/styles.css.j2 +0 -0
  46. {litestar_vite-0.8.1 → litestar_vite-0.8.2}/src/py/litestar_vite/templates/tsconfig.json.j2 +0 -0
  47. {litestar_vite-0.8.1 → litestar_vite-0.8.2}/src/py/tests/__init__.py +0 -0
  48. {litestar_vite-0.8.1 → litestar_vite-0.8.2}/src/py/tests/conftest.py +0 -0
  49. {litestar_vite-0.8.1 → litestar_vite-0.8.2}/src/py/tests/templates/__init__.py +0 -0
  50. {litestar_vite-0.8.1 → litestar_vite-0.8.2}/src/py/tests/templates/index.html.j2 +0 -0
  51. {litestar_vite-0.8.1 → litestar_vite-0.8.2}/src/py/tests/test_app/__init__.py +0 -0
  52. {litestar_vite-0.8.1 → litestar_vite-0.8.2}/src/py/tests/test_app/app.py +0 -0
  53. {litestar_vite-0.8.1 → litestar_vite-0.8.2}/src/py/tests/test_app/web/__init__.py +0 -0
  54. {litestar_vite-0.8.1 → litestar_vite-0.8.2}/src/py/tests/test_app/web/public/.gitkeep +0 -0
  55. {litestar_vite-0.8.1 → litestar_vite-0.8.2}/src/py/tests/test_app/web/public/assets/main-l0sNRNKZ.js +0 -0
  56. {litestar_vite-0.8.1 → litestar_vite-0.8.2}/src/py/tests/test_app/web/public/assets/styles-l0sNRNKZ.js +0 -0
  57. {litestar_vite-0.8.1 → litestar_vite-0.8.2}/src/py/tests/test_app/web/public/manifest.json +0 -0
  58. {litestar_vite-0.8.1 → litestar_vite-0.8.2}/src/py/tests/test_app/web/resources/.gitkeep +0 -0
  59. {litestar_vite-0.8.1 → litestar_vite-0.8.2}/src/py/tests/test_app/web/resources/main.ts +0 -0
  60. {litestar_vite-0.8.1 → litestar_vite-0.8.2}/src/py/tests/test_app/web/resources/styles.css +0 -0
  61. {litestar_vite-0.8.1 → litestar_vite-0.8.2}/src/py/tests/test_app/web/templates/.gitkeep +0 -0
  62. {litestar_vite-0.8.1 → litestar_vite-0.8.2}/src/py/tests/test_app/web/templates/index.html +0 -0
  63. {litestar_vite-0.8.1 → litestar_vite-0.8.2}/src/py/tests/test_cli/__init__.py +0 -0
  64. {litestar_vite-0.8.1 → litestar_vite-0.8.2}/src/py/tests/test_cli/conftest.py +0 -0
  65. {litestar_vite-0.8.1 → litestar_vite-0.8.2}/src/py/tests/test_commands.py +0 -0
  66. {litestar_vite-0.8.1 → litestar_vite-0.8.2}/src/py/tests/test_inertia/__init__.py +0 -0
  67. {litestar_vite-0.8.1 → litestar_vite-0.8.2}/src/py/tests/test_inertia/conftest.py +0 -0
  68. {litestar_vite-0.8.1 → litestar_vite-0.8.2}/src/py/tests/test_inertia/templates/index.html.j2 +0 -0
  69. {litestar_vite-0.8.1 → litestar_vite-0.8.2}/src/py/tests/test_inertia/test_inertia_request.py +0 -0
  70. {litestar_vite-0.8.1 → litestar_vite-0.8.2}/src/py/tests/test_inertia/test_inertia_response.py +0 -0
  71. {litestar_vite-0.8.1 → litestar_vite-0.8.2}/src/py/tests/test_inertia/test_routes.py +0 -0
  72. {litestar_vite-0.8.1 → litestar_vite-0.8.2}/src/py/tests/test_template_engine.py +0 -0
@@ -25,6 +25,7 @@ share/python-wheels/
25
25
  .installed.cfg
26
26
  *.egg
27
27
  MANIFEST
28
+ tmp/
28
29
 
29
30
  # PyInstaller
30
31
  # Usually these files are written by a python script from a template
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: litestar-vite
3
- Version: 0.8.1
3
+ Version: 0.8.2
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
@@ -25,7 +25,7 @@ license = { text = "MIT" }
25
25
  name = "litestar-vite"
26
26
  readme = "README.md"
27
27
  requires-python = ">=3.8"
28
- version = "0.8.1"
28
+ version = "0.8.2"
29
29
 
30
30
  [project.urls]
31
31
  Changelog = "https://cofin.github.io/litestar-vite/latest/changelog"
@@ -85,7 +85,7 @@ test = [
85
85
  allow_dirty = true
86
86
  commit = true
87
87
  commit_args = "--no-verify"
88
- current_version = "0.8.1"
88
+ current_version = "0.8.2"
89
89
  ignore_missing_files = false
90
90
  ignore_missing_version = false
91
91
  message = "chore(release): bump to v{new_version}"
@@ -130,6 +130,7 @@ search = """
130
130
  "name": "litestar-vite-plugin",
131
131
  "version": "{current_version}",
132
132
  """
133
+
133
134
  [[tool.bumpversion.files]]
134
135
  filename = "package-lock.json"
135
136
  replace = """
@@ -141,6 +142,11 @@ search = """
141
142
  "version": "{current_version}",
142
143
  """
143
144
 
145
+ [[tool.bumpversion.files]]
146
+ filename = "src/py/litestar_vite/commands.py"
147
+ replace = ' "litestar-vite-plugin": "^{new_version}",'
148
+ search = ' "litestar-vite-plugin": "^{current_version}",'
149
+
144
150
  [tool.pytest.ini_options]
145
151
  addopts = "--dist loadfile -n auto"
146
152
  filterwarnings = ["ignore::DeprecationWarning:pkg_resources.*"]
@@ -125,6 +125,7 @@ def vite_init(
125
125
  config = plugin._config # pyright: ignore[reportPrivateUsage]
126
126
 
127
127
  console.rule("[yellow]Initializing Vite[/]", align="left")
128
+ root_path = Path(root_path or config.root_dir or Path.cwd())
128
129
  resource_path = Path(resource_path or config.resource_dir)
129
130
  public_path = Path(public_path or config.public_dir)
130
131
  bundle_path = Path(bundle_path or config.bundle_dir)
@@ -132,7 +133,6 @@ def vite_init(
132
133
  asset_url = asset_url or config.asset_url
133
134
  vite_port = vite_port or config.port
134
135
  hot_file = Path(bundle_path / config.hot_file)
135
- root_path = Path(root_path or config.root_dir or resource_path.parent)
136
136
 
137
137
  if any(output_path.exists() for output_path in (bundle_path, resource_path)) and not any(
138
138
  [overwrite, no_prompt],
@@ -143,10 +143,6 @@ def vite_init(
143
143
  if not confirm_overwrite:
144
144
  console.print("Skipping Vite initialization")
145
145
  sys.exit(2)
146
- for output_path in (bundle_path, resource_path, root_path):
147
- if output_path.exists():
148
- console.print(f" * Creating {output_path!s}")
149
- output_path.mkdir(parents=True, exist_ok=True)
150
146
 
151
147
  enable_ssr = (
152
148
  True
@@ -12,10 +12,10 @@ if TYPE_CHECKING:
12
12
  VITE_INIT_TEMPLATES: set[str] = {"package.json.j2", "tsconfig.json.j2", "vite.config.ts.j2"}
13
13
  DEFAULT_RESOURCES: set[str] = {"styles.css.j2", "main.ts.j2"}
14
14
  DEFAULT_DEV_DEPENDENCIES: dict[str, str] = {
15
- "typescript": "^5.3.3",
16
- "vite": "^5.3.3",
17
- "litestar-vite-plugin": "^0.6.2",
18
- "@types/node": "^20.14.10",
15
+ "typescript": "^5.7.2",
16
+ "vite": "^6.0.3",
17
+ "litestar-vite-plugin": "^0.8.2",
18
+ "@types/node": "^22.10.1",
19
19
  }
20
20
  DEFAULT_DEPENDENCIES: dict[str, str] = {"axios": "^1.7.2"}
21
21
 
@@ -78,10 +78,14 @@ def init_vite(
78
78
  template_name: get_template(environment=vite_template_env, name=template_name)
79
79
  for template_name in enabled_templates
80
80
  }
81
+
82
+ # Prepare root_path
83
+ root_path.mkdir(parents=True, exist_ok=True)
81
84
  for template_name, template in templates.items():
82
85
  target_file_name = template_name[:-3] if template_name.endswith(".j2") else template_name
83
- with Path(target_file_name).open(mode="w") as file:
84
- console.print(f" * Writing {target_file_name} to {Path(target_file_name)!s}")
86
+ target_file_path = root_path / target_file_name
87
+ with target_file_path.open(mode="w") as file:
88
+ console.print(f" * Writing {target_file_name} to {target_file_path!s}")
85
89
 
86
90
  file.write(
87
91
  template.render(
@@ -92,10 +96,10 @@ def init_vite(
92
96
  enable_ssr=enable_ssr,
93
97
  asset_url=asset_url,
94
98
  root_path=root_path,
95
- resource_path=str(resource_path.relative_to(root_path)),
96
- public_path=str(public_path.relative_to(root_path)),
97
- bundle_path=str(bundle_path.relative_to(root_path)),
98
- hot_file=str(hot_file.relative_to(root_path)),
99
+ resource_path=str(resource_path),
100
+ public_path=str(public_path),
101
+ bundle_path=str(bundle_path),
102
+ hot_file=str(hot_file),
99
103
  vite_port=str(vite_port),
100
104
  litestar_port=litestar_port,
101
105
  dependencies=to_json(dependencies),
@@ -103,12 +107,16 @@ def init_vite(
103
107
  ),
104
108
  )
105
109
 
110
+ (root_path / bundle_path).mkdir(parents=True, exist_ok=True)
111
+ (root_path / public_path).mkdir(parents=True, exist_ok=True)
112
+ (root_path / resource_path).mkdir(parents=True, exist_ok=True)
106
113
  for resource_name in enabled_resources:
107
114
  template = get_template(environment=vite_template_env, name=resource_name)
108
- target_file_name = f"{resource_path}/{resource_name[:-3] if resource_name.endswith('.j2') else resource_name}"
109
- with Path(target_file_name).open(mode="w") as file:
115
+ target_file_name = f"{resource_name[:-3] if resource_name.endswith('.j2') else resource_name}"
116
+ target_file_path = root_path / resource_path / target_file_name
117
+ with target_file_path.open(mode="w") as file:
110
118
  console.print(
111
- f" * Writing {resource_name[:-3] if resource_name.endswith('.j2') else resource_name} to {Path(target_file_name)!s}",
119
+ f" * Writing {resource_name[:-3] if resource_name.endswith('.j2') else resource_name} to {target_file_path!s}",
112
120
  )
113
121
  file.write(template.render())
114
122
  console.print("[yellow]Vite initialization completed.[/]")
@@ -111,6 +111,8 @@ class ViteConfig:
111
111
  """Ensure that directory is set if engine is a class."""
112
112
  if self.root_dir is not None and isinstance(self.root_dir, str):
113
113
  self.root_dir = Path(self.root_dir)
114
+ elif self.root_dir is None:
115
+ self.root_dir = Path()
114
116
  if self.template_dir is not None and isinstance(self.template_dir, str):
115
117
  self.template_dir = Path(self.template_dir)
116
118
  if self.public_dir and isinstance(self.public_dir, str):
@@ -8,7 +8,6 @@ const VITE_PORT = process.env.VITE_PORT || "5173";
8
8
  const VITE_HOST = process.env.VITE_HOST || "localhost";
9
9
  export default defineConfig({
10
10
  base: `${ASSET_URL}`,
11
- {% if root_path and root_path != '.' %} root: "{{ root_path }}",{% endif %}
12
11
  server: {
13
12
  host: "0.0.0.0",
14
13
  port: +`${VITE_PORT}`,
@@ -74,15 +74,25 @@ app = Litestar(plugins=[vite])
74
74
  app_file = create_app_file("command_test_app.py", content=app_file_content)
75
75
  result = runner.invoke(
76
76
  root_command,
77
- ["--app-dir", f"{app_file.parent!s}", "--app", f"{app_file.stem}:app", "assets", "init", "--no-prompt"],
77
+ [
78
+ "--app-dir",
79
+ f"{app_file.parent!s}",
80
+ "--app",
81
+ f"{app_file.stem}:app",
82
+ "assets",
83
+ "init",
84
+ "--no-prompt",
85
+ "--root-path",
86
+ "web",
87
+ ],
78
88
  )
79
89
 
80
90
  assert "Initializing Vite" in result.output
81
- assert Path(Path(tmp_project_dir) / "vite.config.ts").exists()
82
- assert Path(Path(tmp_project_dir) / "package.json").exists()
83
- assert Path(Path(tmp_project_dir) / "tsconfig.json").exists()
84
- assert Path(Path(tmp_project_dir) / "resources" / "main.ts").exists()
85
- assert Path(Path(tmp_project_dir) / "resources" / "styles.css").exists()
91
+ assert Path(Path(tmp_project_dir) / "web" / "vite.config.ts").exists()
92
+ assert Path(Path(tmp_project_dir) / "web" / "package.json").exists()
93
+ assert Path(Path(tmp_project_dir) / "web" / "tsconfig.json").exists()
94
+ assert Path(Path(tmp_project_dir) / "web" / "resources" / "main.ts").exists()
95
+ assert Path(Path(tmp_project_dir) / "web" / "resources" / "styles.css").exists()
86
96
 
87
97
 
88
98
  def test_init_install_build(
@@ -1,4 +1,4 @@
1
- from pathlib import Path
1
+ from pathlib import Path, PosixPath
2
2
 
3
3
  from litestar_vite.config import ViteConfig
4
4
 
@@ -9,4 +9,5 @@ def test_default_vite_config() -> None:
9
9
  assert isinstance(config.public_dir, Path)
10
10
  assert config.ssr_output_dir is None
11
11
  assert isinstance(config.resource_dir, Path)
12
- assert config.root_dir is None
12
+ assert isinstance(config.root_dir, (Path, PosixPath))
13
+ assert config.root_dir == PosixPath(".")
File without changes
File without changes