simple-module-hosting 0.0.8__tar.gz → 0.0.10__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 (45) hide show
  1. {simple_module_hosting-0.0.8 → simple_module_hosting-0.0.10}/PKG-INFO +3 -3
  2. {simple_module_hosting-0.0.8 → simple_module_hosting-0.0.10}/pyproject.toml +3 -3
  3. {simple_module_hosting-0.0.8 → simple_module_hosting-0.0.10}/simple_module_hosting/manifest.py +27 -2
  4. simple_module_hosting-0.0.10/tests/test_manifest.py +60 -0
  5. {simple_module_hosting-0.0.8 → simple_module_hosting-0.0.10}/.gitignore +0 -0
  6. {simple_module_hosting-0.0.8 → simple_module_hosting-0.0.10}/LICENSE +0 -0
  7. {simple_module_hosting-0.0.8 → simple_module_hosting-0.0.10}/README.md +0 -0
  8. {simple_module_hosting-0.0.8 → simple_module_hosting-0.0.10}/simple_module_hosting/__init__.py +0 -0
  9. {simple_module_hosting-0.0.8 → simple_module_hosting-0.0.10}/simple_module_hosting/__main__.py +0 -0
  10. {simple_module_hosting-0.0.8 → simple_module_hosting-0.0.10}/simple_module_hosting/_error_handlers.py +0 -0
  11. {simple_module_hosting-0.0.8 → simple_module_hosting-0.0.10}/simple_module_hosting/_host_services.py +0 -0
  12. {simple_module_hosting-0.0.8 → simple_module_hosting-0.0.10}/simple_module_hosting/_hydrate_step.py +0 -0
  13. {simple_module_hosting-0.0.8 → simple_module_hosting-0.0.10}/simple_module_hosting/_inertia_setup.py +0 -0
  14. {simple_module_hosting-0.0.8 → simple_module_hosting-0.0.10}/simple_module_hosting/_inertia_shared.py +0 -0
  15. {simple_module_hosting-0.0.8 → simple_module_hosting-0.0.10}/simple_module_hosting/_observability.py +0 -0
  16. {simple_module_hosting-0.0.8 → simple_module_hosting-0.0.10}/simple_module_hosting/_phase_helpers.py +0 -0
  17. {simple_module_hosting-0.0.8 → simple_module_hosting-0.0.10}/simple_module_hosting/app_builder.py +0 -0
  18. {simple_module_hosting-0.0.8 → simple_module_hosting-0.0.10}/simple_module_hosting/bootstrap_settings.py +0 -0
  19. {simple_module_hosting-0.0.8 → simple_module_hosting-0.0.10}/simple_module_hosting/health.py +0 -0
  20. {simple_module_hosting-0.0.8 → simple_module_hosting-0.0.10}/simple_module_hosting/host_cli.py +0 -0
  21. {simple_module_hosting-0.0.8 → simple_module_hosting-0.0.10}/simple_module_hosting/host_settings.py +0 -0
  22. {simple_module_hosting-0.0.8 → simple_module_hosting-0.0.10}/simple_module_hosting/i18n_deps.py +0 -0
  23. {simple_module_hosting-0.0.8 → simple_module_hosting-0.0.10}/simple_module_hosting/i18n_manifest.py +0 -0
  24. {simple_module_hosting-0.0.8 → simple_module_hosting-0.0.10}/simple_module_hosting/i18n_middleware.py +0 -0
  25. {simple_module_hosting-0.0.8 → simple_module_hosting-0.0.10}/simple_module_hosting/inertia_deps.py +0 -0
  26. {simple_module_hosting-0.0.8 → simple_module_hosting-0.0.10}/simple_module_hosting/inertia_utils.py +0 -0
  27. {simple_module_hosting-0.0.8 → simple_module_hosting-0.0.10}/simple_module_hosting/logging.py +0 -0
  28. {simple_module_hosting-0.0.8 → simple_module_hosting-0.0.10}/simple_module_hosting/middleware.py +0 -0
  29. {simple_module_hosting-0.0.8 → simple_module_hosting-0.0.10}/simple_module_hosting/migrations.py +0 -0
  30. {simple_module_hosting-0.0.8 → simple_module_hosting-0.0.10}/simple_module_hosting/permissions.py +0 -0
  31. {simple_module_hosting-0.0.8 → simple_module_hosting-0.0.10}/simple_module_hosting/py.typed +0 -0
  32. {simple_module_hosting-0.0.8 → simple_module_hosting-0.0.10}/simple_module_hosting/redirects.py +0 -0
  33. {simple_module_hosting-0.0.8 → simple_module_hosting-0.0.10}/simple_module_hosting/settings.py +0 -0
  34. {simple_module_hosting-0.0.8 → simple_module_hosting-0.0.10}/tests/test_app.py +0 -0
  35. {simple_module_hosting-0.0.8 → simple_module_hosting-0.0.10}/tests/test_health.py +0 -0
  36. {simple_module_hosting-0.0.8 → simple_module_hosting-0.0.10}/tests/test_host_cli.py +0 -0
  37. {simple_module_hosting-0.0.8 → simple_module_hosting-0.0.10}/tests/test_hosting_permissions.py +0 -0
  38. {simple_module_hosting-0.0.8 → simple_module_hosting-0.0.10}/tests/test_i18n_manifest.py +0 -0
  39. {simple_module_hosting-0.0.8 → simple_module_hosting-0.0.10}/tests/test_inertia_i18n_shared_props.py +0 -0
  40. {simple_module_hosting-0.0.8 → simple_module_hosting-0.0.10}/tests/test_locale_middleware.py +0 -0
  41. {simple_module_hosting-0.0.8 → simple_module_hosting-0.0.10}/tests/test_logging.py +0 -0
  42. {simple_module_hosting-0.0.8 → simple_module_hosting-0.0.10}/tests/test_settings_i18n.py +0 -0
  43. {simple_module_hosting-0.0.8 → simple_module_hosting-0.0.10}/tests/test_settings_secrets.py +0 -0
  44. {simple_module_hosting-0.0.8 → simple_module_hosting-0.0.10}/tests/test_tenant_middleware.py +0 -0
  45. {simple_module_hosting-0.0.8 → simple_module_hosting-0.0.10}/tests/test_translator_dep.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: simple_module_hosting
3
- Version: 0.0.8
3
+ Version: 0.0.10
4
4
  Summary: FastAPI + Inertia.js host runtime for simple_module — app_builder, middleware stack, CLI (sm / simple-module), scaffolding
5
5
  Project-URL: Homepage, https://github.com/antosubash/simple_module_python
6
6
  Project-URL: Repository, https://github.com/antosubash/simple_module_python
@@ -26,8 +26,8 @@ Requires-Dist: fastapi-inertia>=1.0
26
26
  Requires-Dist: fastapi>=0.115
27
27
  Requires-Dist: httpx>=0.27
28
28
  Requires-Dist: jinja2>=3.1
29
- Requires-Dist: simple-module-core==0.0.8
30
- Requires-Dist: simple-module-db==0.0.8
29
+ Requires-Dist: simple-module-core==0.0.10
30
+ Requires-Dist: simple-module-db==0.0.10
31
31
  Requires-Dist: starlette>=0.44
32
32
  Requires-Dist: tomlkit>=0.13
33
33
  Requires-Dist: uvicorn[standard]>=0.34
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "simple_module_hosting"
3
- version = "0.0.8"
3
+ version = "0.0.10"
4
4
  description = "FastAPI + Inertia.js host runtime for simple_module — app_builder, middleware stack, CLI (sm / simple-module), scaffolding"
5
5
  readme = "README.md"
6
6
  license = "MIT"
@@ -26,8 +26,8 @@ dependencies = [
26
26
  "fastapi-inertia>=1.0",
27
27
  "httpx>=0.27",
28
28
  "jinja2>=3.1",
29
- "simple_module_core==0.0.8",
30
- "simple_module_db==0.0.8",
29
+ "simple_module_core==0.0.10",
30
+ "simple_module_db==0.0.10",
31
31
  "starlette>=0.44",
32
32
  "tomlkit>=0.13",
33
33
  "uvicorn[standard]>=0.34",
@@ -45,13 +45,38 @@ _GENERATED_CSS_HEADER = """\
45
45
 
46
46
 
47
47
  def repo_root_from_client_app(client_app_dir: Path) -> Path:
48
- """Repo root is two levels above ``host/client_app/``.
48
+ """Locate the workspace/repo root that contains ``client_app_dir``.
49
49
 
50
50
  Both ``write_module_pages_manifest`` and the ``sync-js-deps`` CLI
51
51
  derive the workspace root from the host's client_app directory.
52
52
  Centralized here so the heuristic lives in exactly one place.
53
+
54
+ Walks up looking for the nearest ``package.json`` that declares
55
+ ``workspaces`` (the workspace root npm uses), falling back to any
56
+ ``package.json``. This handles both the framework repo's
57
+ ``host/client_app/`` layout and the flat ``sm new`` scaffold's
58
+ ``client_app/`` layout (where the parent IS the workspace root).
53
59
  """
54
- return client_app_dir.resolve().parent.parent
60
+ here = client_app_dir.resolve()
61
+ fallback: Path | None = None
62
+ for parent in (here.parent, *here.parents):
63
+ pkg = parent / "package.json"
64
+ if not pkg.is_file():
65
+ continue
66
+ if fallback is None:
67
+ fallback = parent
68
+ try:
69
+ data = json.loads(pkg.read_text(encoding="utf-8"))
70
+ except json.JSONDecodeError:
71
+ continue
72
+ if "workspaces" in data:
73
+ return parent
74
+ if fallback is not None:
75
+ return fallback
76
+ # No package.json found anywhere on the way up — preserve the legacy
77
+ # two-levels-up shape so framework-internal callers still get a valid
78
+ # path even before any npm setup has happened.
79
+ return here.parent.parent
55
80
 
56
81
 
57
82
  def compute_module_pages(modules: Sequence[ModuleBase]) -> dict[str, Path]:
@@ -0,0 +1,60 @@
1
+ """Tests for ``simple_module_hosting.manifest`` helpers."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import json
6
+ from pathlib import Path
7
+
8
+ from simple_module_hosting.manifest import repo_root_from_client_app
9
+
10
+
11
+ def test_repo_root_finds_workspace_root_in_framework_layout(tmp_path: Path) -> None:
12
+ """``host/client_app/`` shape: walk up to the workspace package.json."""
13
+ workspace = tmp_path / "ws"
14
+ (workspace / "host" / "client_app").mkdir(parents=True)
15
+ (workspace / "package.json").write_text(
16
+ json.dumps({"name": "ws", "workspaces": ["host/client_app", "modules/*"]})
17
+ )
18
+ (workspace / "host" / "package.json").write_text(json.dumps({"name": "ws-host"}))
19
+
20
+ assert repo_root_from_client_app(workspace / "host" / "client_app") == workspace.resolve()
21
+
22
+
23
+ def test_repo_root_finds_root_in_flat_scaffold_layout(tmp_path: Path) -> None:
24
+ """Flat scaffold: ``client_app/`` directly under the host root."""
25
+ host = tmp_path / "my-app"
26
+ (host / "client_app").mkdir(parents=True)
27
+ (host / "package.json").write_text(json.dumps({"name": "my-app"}))
28
+
29
+ assert repo_root_from_client_app(host / "client_app") == host.resolve()
30
+
31
+
32
+ def test_repo_root_prefers_workspace_package_json_over_nearer_one(tmp_path: Path) -> None:
33
+ """When a non-workspace package.json sits between client_app and the
34
+ workspace root, the workspace one wins so npm install runs at the right cwd."""
35
+ workspace = tmp_path / "ws"
36
+ (workspace / "host" / "client_app").mkdir(parents=True)
37
+ (workspace / "package.json").write_text(
38
+ json.dumps({"name": "ws", "workspaces": ["host/client_app"]})
39
+ )
40
+ (workspace / "host" / "package.json").write_text(json.dumps({"name": "ws-host"}))
41
+
42
+ assert repo_root_from_client_app(workspace / "host" / "client_app") == workspace.resolve()
43
+
44
+
45
+ def test_repo_root_falls_back_to_nearest_package_json(tmp_path: Path) -> None:
46
+ """No workspaces field anywhere — settle on the nearest package.json found."""
47
+ root = tmp_path / "root"
48
+ (root / "client_app").mkdir(parents=True)
49
+ (root / "package.json").write_text(json.dumps({"name": "root"}))
50
+
51
+ assert repo_root_from_client_app(root / "client_app") == root.resolve()
52
+
53
+
54
+ def test_repo_root_falls_back_to_two_levels_up_if_no_package_json(tmp_path: Path) -> None:
55
+ """No package.json exists yet — preserve the legacy two-up behaviour so
56
+ framework-internal callers still get a path before any npm setup."""
57
+ deep = tmp_path / "outer" / "inner" / "client_app"
58
+ deep.mkdir(parents=True)
59
+
60
+ assert repo_root_from_client_app(deep) == (tmp_path / "outer").resolve()