simple-module-cli 0.0.44__py3-none-any.whl → 0.0.45__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.
- simple_module_cli/_app_project_manifests.py +7 -1
- simple_module_cli/_lint_tooling.py +37 -0
- simple_module_cli/_version_check.py +53 -0
- simple_module_cli/app_project.py +10 -7
- simple_module_cli/new.py +3 -0
- simple_module_cli/pins.py +4 -1
- simple_module_cli/pypi.py +2 -2
- simple_module_cli/scaffolding.py +9 -0
- simple_module_cli/skills/simple-module-conventions/SKILL.md +3 -1
- simple_module_cli/skills/simple-module-creating/SKILL.md +1 -1
- simple_module_cli/skills/simple-module-doctor/SKILL.md +3 -3
- simple_module_cli/skills/simple-module-inertia-pages/SKILL.md +2 -0
- simple_module_cli/templates/host/alembic.ini +15 -0
- simple_module_cli/templates/host/client_app/app.tsx +10 -26
- simple_module_cli/templates/host/client_app/pages/Landing.tsx +17 -8
- simple_module_cli/templates/host/client_app/tsconfig.json +1 -1
- simple_module_cli/templates/host/client_app/vite.config.ts +18 -16
- simple_module_cli/templates/host/pyproject.toml.tpl +7 -1
- simple_module_cli/templates/module/__PACKAGE__/contracts/schemas.py.tpl +1 -1
- simple_module_cli/templates/module/__PACKAGE__/module.py.tpl +1 -13
- simple_module_cli/templates/module/__PACKAGE__/pages/Browse.tsx.tpl +3 -0
- simple_module_cli/templates/module/__PACKAGE__/pages/Create.tsx.tpl +3 -0
- simple_module_cli/templates/module/__PACKAGE__/pages/Edit.tsx.tpl +3 -0
- simple_module_cli/templates/module/_optional/framework_repo/__PACKAGE__/pages/Browse.tsx.tpl +3 -0
- simple_module_cli/templates/module/_optional/framework_repo/__PACKAGE__/pages/Create.tsx.tpl +3 -0
- simple_module_cli/templates/module/_optional/framework_repo/__PACKAGE__/pages/Edit.tsx.tpl +3 -0
- simple_module_cli/templates/workspace/pyproject.toml.tpl +1 -1
- {simple_module_cli-0.0.44.data → simple_module_cli-0.0.45.data}/data/simple_module_cli/templates/host/alembic.ini +15 -0
- {simple_module_cli-0.0.44.data → simple_module_cli-0.0.45.data}/data/simple_module_cli/templates/host/client_app/app.tsx +10 -26
- {simple_module_cli-0.0.44.data → simple_module_cli-0.0.45.data}/data/simple_module_cli/templates/host/client_app/pages/Landing.tsx +17 -8
- {simple_module_cli-0.0.44.data → simple_module_cli-0.0.45.data}/data/simple_module_cli/templates/host/client_app/tsconfig.json +1 -1
- {simple_module_cli-0.0.44.data → simple_module_cli-0.0.45.data}/data/simple_module_cli/templates/host/client_app/vite.config.ts +18 -16
- {simple_module_cli-0.0.44.data → simple_module_cli-0.0.45.data}/data/simple_module_cli/templates/host/pyproject.toml.tpl +7 -1
- {simple_module_cli-0.0.44.data → simple_module_cli-0.0.45.data}/data/simple_module_cli/templates/module/__PACKAGE__/contracts/schemas.py.tpl +1 -1
- {simple_module_cli-0.0.44.data → simple_module_cli-0.0.45.data}/data/simple_module_cli/templates/module/__PACKAGE__/module.py.tpl +1 -13
- {simple_module_cli-0.0.44.data → simple_module_cli-0.0.45.data}/data/simple_module_cli/templates/module/__PACKAGE__/pages/Browse.tsx.tpl +3 -0
- {simple_module_cli-0.0.44.data → simple_module_cli-0.0.45.data}/data/simple_module_cli/templates/module/__PACKAGE__/pages/Create.tsx.tpl +3 -0
- {simple_module_cli-0.0.44.data → simple_module_cli-0.0.45.data}/data/simple_module_cli/templates/module/__PACKAGE__/pages/Edit.tsx.tpl +3 -0
- {simple_module_cli-0.0.44.data → simple_module_cli-0.0.45.data}/data/simple_module_cli/templates/module/_optional/framework_repo/__PACKAGE__/pages/Browse.tsx.tpl +3 -0
- {simple_module_cli-0.0.44.data → simple_module_cli-0.0.45.data}/data/simple_module_cli/templates/module/_optional/framework_repo/__PACKAGE__/pages/Create.tsx.tpl +3 -0
- {simple_module_cli-0.0.44.data → simple_module_cli-0.0.45.data}/data/simple_module_cli/templates/module/_optional/framework_repo/__PACKAGE__/pages/Edit.tsx.tpl +3 -0
- {simple_module_cli-0.0.44.data → simple_module_cli-0.0.45.data}/data/simple_module_cli/templates/workspace/pyproject.toml.tpl +1 -1
- {simple_module_cli-0.0.44.dist-info → simple_module_cli-0.0.45.dist-info}/METADATA +2 -2
- {simple_module_cli-0.0.44.dist-info → simple_module_cli-0.0.45.dist-info}/RECORD +114 -112
- {simple_module_cli-0.0.44.data → simple_module_cli-0.0.45.data}/data/simple_module_cli/templates/docker/Makefile.snippet +0 -0
- {simple_module_cli-0.0.44.data → simple_module_cli-0.0.45.data}/data/simple_module_cli/templates/docker/compose-base-postgres.yml.tpl +0 -0
- {simple_module_cli-0.0.44.data → simple_module_cli-0.0.45.data}/data/simple_module_cli/templates/docker/compose-base-sqlite.yml.tpl +0 -0
- {simple_module_cli-0.0.44.data → simple_module_cli-0.0.45.data}/data/simple_module_cli/templates/docker/compose-tasks-postgres.yml.tpl +0 -0
- {simple_module_cli-0.0.44.data → simple_module_cli-0.0.45.data}/data/simple_module_cli/templates/docker/compose-tasks-sqlite.yml.tpl +0 -0
- {simple_module_cli-0.0.44.data → simple_module_cli-0.0.45.data}/data/simple_module_cli/templates/docker/compose-worker.yml.tpl +0 -0
- {simple_module_cli-0.0.44.data → simple_module_cli-0.0.45.data}/data/simple_module_cli/templates/docker/dockerignore +0 -0
- {simple_module_cli-0.0.44.data → simple_module_cli-0.0.45.data}/data/simple_module_cli/templates/docker/host-flat.Dockerfile +0 -0
- {simple_module_cli-0.0.44.data → simple_module_cli-0.0.45.data}/data/simple_module_cli/templates/docker/host.Dockerfile +0 -0
- {simple_module_cli-0.0.44.data → simple_module_cli-0.0.45.data}/data/simple_module_cli/templates/docker/worker.Dockerfile.tpl +0 -0
- {simple_module_cli-0.0.44.data → simple_module_cli-0.0.45.data}/data/simple_module_cli/templates/host/.env.example +0 -0
- {simple_module_cli-0.0.44.data → simple_module_cli-0.0.45.data}/data/simple_module_cli/templates/host/.gitignore +0 -0
- {simple_module_cli-0.0.44.data → simple_module_cli-0.0.45.data}/data/simple_module_cli/templates/host/Makefile +0 -0
- {simple_module_cli-0.0.44.data → simple_module_cli-0.0.45.data}/data/simple_module_cli/templates/host/README.md.tpl +0 -0
- {simple_module_cli-0.0.44.data → simple_module_cli-0.0.45.data}/data/simple_module_cli/templates/host/_optional/background_tasks/Makefile.snippet +0 -0
- {simple_module_cli-0.0.44.data → simple_module_cli-0.0.45.data}/data/simple_module_cli/templates/host/_optional/background_tasks/run_worker.py +0 -0
- {simple_module_cli-0.0.44.data → simple_module_cli-0.0.45.data}/data/simple_module_cli/templates/host/client_app/main.tsx +0 -0
- {simple_module_cli-0.0.44.data → simple_module_cli-0.0.45.data}/data/simple_module_cli/templates/host/client_app/module-assets.ts +0 -0
- {simple_module_cli-0.0.44.data → simple_module_cli-0.0.45.data}/data/simple_module_cli/templates/host/client_app/package.json.tpl +0 -0
- {simple_module_cli-0.0.44.data → simple_module_cli-0.0.45.data}/data/simple_module_cli/templates/host/client_app/pages/Error.tsx +0 -0
- {simple_module_cli-0.0.44.data → simple_module_cli-0.0.45.data}/data/simple_module_cli/templates/host/client_app/pages.ts +0 -0
- {simple_module_cli-0.0.44.data → simple_module_cli-0.0.45.data}/data/simple_module_cli/templates/host/client_app/styles.css +0 -0
- {simple_module_cli-0.0.44.data → simple_module_cli-0.0.45.data}/data/simple_module_cli/templates/host/client_app/vite.dev-url.ts +0 -0
- {simple_module_cli-0.0.44.data → simple_module_cli-0.0.45.data}/data/simple_module_cli/templates/host/main.py +0 -0
- {simple_module_cli-0.0.44.data → simple_module_cli-0.0.45.data}/data/simple_module_cli/templates/host/migrations/env.py +0 -0
- {simple_module_cli-0.0.44.data → simple_module_cli-0.0.45.data}/data/simple_module_cli/templates/host/migrations/script.py.mako +0 -0
- {simple_module_cli-0.0.44.data → simple_module_cli-0.0.45.data}/data/simple_module_cli/templates/host/migrations/versions/.gitkeep +0 -0
- {simple_module_cli-0.0.44.data → simple_module_cli-0.0.45.data}/data/simple_module_cli/templates/host/routes.py +0 -0
- {simple_module_cli-0.0.44.data → simple_module_cli-0.0.45.data}/data/simple_module_cli/templates/host/templates/index.html +0 -0
- {simple_module_cli-0.0.44.data → simple_module_cli-0.0.45.data}/data/simple_module_cli/templates/module/.github/workflows/ci.yml +0 -0
- {simple_module_cli-0.0.44.data → simple_module_cli-0.0.45.data}/data/simple_module_cli/templates/module/.github/workflows/publish.yml.tpl +0 -0
- {simple_module_cli-0.0.44.data → simple_module_cli-0.0.45.data}/data/simple_module_cli/templates/module/.gitignore +0 -0
- {simple_module_cli-0.0.44.data → simple_module_cli-0.0.45.data}/data/simple_module_cli/templates/module/README.md.tpl +0 -0
- {simple_module_cli-0.0.44.data → simple_module_cli-0.0.45.data}/data/simple_module_cli/templates/module/__PACKAGE__/__init__.py +0 -0
- {simple_module_cli-0.0.44.data → simple_module_cli-0.0.45.data}/data/simple_module_cli/templates/module/__PACKAGE__/contracts/__init__.py.tpl +0 -0
- {simple_module_cli-0.0.44.data → simple_module_cli-0.0.45.data}/data/simple_module_cli/templates/module/__PACKAGE__/core/__init__.py +0 -0
- {simple_module_cli-0.0.44.data → simple_module_cli-0.0.45.data}/data/simple_module_cli/templates/module/__PACKAGE__/core/constants.py.tpl +0 -0
- {simple_module_cli-0.0.44.data → simple_module_cli-0.0.45.data}/data/simple_module_cli/templates/module/__PACKAGE__/core/services.py.tpl +0 -0
- {simple_module_cli-0.0.44.data → simple_module_cli-0.0.45.data}/data/simple_module_cli/templates/module/__PACKAGE__/core/settings.py.tpl +0 -0
- {simple_module_cli-0.0.44.data → simple_module_cli-0.0.45.data}/data/simple_module_cli/templates/module/__PACKAGE__/locales/en.json.tpl +0 -0
- {simple_module_cli-0.0.44.data → simple_module_cli-0.0.45.data}/data/simple_module_cli/templates/module/__PACKAGE__/models.py.tpl +0 -0
- {simple_module_cli-0.0.44.data → simple_module_cli-0.0.45.data}/data/simple_module_cli/templates/module/__PACKAGE__/pages/api.generated.ts.tpl +0 -0
- {simple_module_cli-0.0.44.data → simple_module_cli-0.0.45.data}/data/simple_module_cli/templates/module/__PACKAGE__/pages/api.ts.tpl +0 -0
- {simple_module_cli-0.0.44.data → simple_module_cli-0.0.45.data}/data/simple_module_cli/templates/module/__PACKAGE__/py.typed +0 -0
- {simple_module_cli-0.0.44.data → simple_module_cli-0.0.45.data}/data/simple_module_cli/templates/module/__PACKAGE__/web/__init__.py +0 -0
- {simple_module_cli-0.0.44.data → simple_module_cli-0.0.45.data}/data/simple_module_cli/templates/module/__PACKAGE__/web/deps.py.tpl +0 -0
- {simple_module_cli-0.0.44.data → simple_module_cli-0.0.45.data}/data/simple_module_cli/templates/module/__PACKAGE__/web/endpoints/__init__.py +0 -0
- {simple_module_cli-0.0.44.data → simple_module_cli-0.0.45.data}/data/simple_module_cli/templates/module/__PACKAGE__/web/endpoints/api.py.tpl +0 -0
- {simple_module_cli-0.0.44.data → simple_module_cli-0.0.45.data}/data/simple_module_cli/templates/module/__PACKAGE__/web/endpoints/views.py.tpl +0 -0
- {simple_module_cli-0.0.44.data → simple_module_cli-0.0.45.data}/data/simple_module_cli/templates/module/__PACKAGE__/web/service.py.tpl +0 -0
- {simple_module_cli-0.0.44.data → simple_module_cli-0.0.45.data}/data/simple_module_cli/templates/module/_optional/framework_repo/LICENSE +0 -0
- {simple_module_cli-0.0.44.data → simple_module_cli-0.0.45.data}/data/simple_module_cli/templates/module/_optional/framework_repo/README.md.tpl +0 -0
- {simple_module_cli-0.0.44.data → simple_module_cli-0.0.45.data}/data/simple_module_cli/templates/module/_optional/framework_repo/pyproject.toml.tpl +0 -0
- {simple_module_cli-0.0.44.data → simple_module_cli-0.0.45.data}/data/simple_module_cli/templates/module/_optional/standalone/package.json.tpl +0 -0
- {simple_module_cli-0.0.44.data → simple_module_cli-0.0.45.data}/data/simple_module_cli/templates/module/_optional/standalone/tsconfig.json.tpl +0 -0
- {simple_module_cli-0.0.44.data → simple_module_cli-0.0.45.data}/data/simple_module_cli/templates/module/package.json.tpl +0 -0
- {simple_module_cli-0.0.44.data → simple_module_cli-0.0.45.data}/data/simple_module_cli/templates/module/pyproject.toml.tpl +0 -0
- {simple_module_cli-0.0.44.data → simple_module_cli-0.0.45.data}/data/simple_module_cli/templates/module/tests/conftest.py +0 -0
- {simple_module_cli-0.0.44.data → simple_module_cli-0.0.45.data}/data/simple_module_cli/templates/module/tests/core/contracts/test___PACKAGE___schemas.py.tpl +0 -0
- {simple_module_cli-0.0.44.data → simple_module_cli-0.0.45.data}/data/simple_module_cli/templates/module/tests/core/module/test___PACKAGE___module.py.tpl +0 -0
- {simple_module_cli-0.0.44.data → simple_module_cli-0.0.45.data}/data/simple_module_cli/templates/module/tests/web/crud/test___PACKAGE___crud.py.tpl +0 -0
- {simple_module_cli-0.0.44.data → simple_module_cli-0.0.45.data}/data/simple_module_cli/templates/module/tsconfig.json.tpl +0 -0
- {simple_module_cli-0.0.44.data → simple_module_cli-0.0.45.data}/data/simple_module_cli/templates/workspace/.env.example +0 -0
- {simple_module_cli-0.0.44.data → simple_module_cli-0.0.45.data}/data/simple_module_cli/templates/workspace/.gitignore +0 -0
- {simple_module_cli-0.0.44.data → simple_module_cli-0.0.45.data}/data/simple_module_cli/templates/workspace/Makefile +0 -0
- {simple_module_cli-0.0.44.data → simple_module_cli-0.0.45.data}/data/simple_module_cli/templates/workspace/README.md.tpl +0 -0
- {simple_module_cli-0.0.44.data → simple_module_cli-0.0.45.data}/data/simple_module_cli/templates/workspace/package.json.tpl +0 -0
- {simple_module_cli-0.0.44.dist-info → simple_module_cli-0.0.45.dist-info}/WHEEL +0 -0
- {simple_module_cli-0.0.44.dist-info → simple_module_cli-0.0.45.dist-info}/entry_points.txt +0 -0
- {simple_module_cli-0.0.44.dist-info → simple_module_cli-0.0.45.dist-info}/licenses/LICENSE +0 -0
|
@@ -4,6 +4,7 @@ from __future__ import annotations
|
|
|
4
4
|
|
|
5
5
|
from collections.abc import Sequence
|
|
6
6
|
|
|
7
|
+
from simple_module_cli._lint_tooling import TY_REQUIREMENT
|
|
7
8
|
from simple_module_cli.scaffolding import resolve_framework_version
|
|
8
9
|
|
|
9
10
|
_FRAMEWORK_VERSION = resolve_framework_version()
|
|
@@ -22,7 +23,7 @@ _APP_PY_DEV_DEPS = [
|
|
|
22
23
|
# Floor: unpinned, uv backtracks playwright to 1.18 (GH #445).
|
|
23
24
|
"playwright>=1.45",
|
|
24
25
|
"ruff>=0.8",
|
|
25
|
-
|
|
26
|
+
TY_REQUIREMENT,
|
|
26
27
|
]
|
|
27
28
|
|
|
28
29
|
_APP_NPM_DEPS = {
|
|
@@ -50,6 +51,11 @@ _APP_NPM_DEV_DEPS = {
|
|
|
50
51
|
"vite": "^8.2.2",
|
|
51
52
|
}
|
|
52
53
|
|
|
54
|
+
# `@tailwindcss/typography` (pulled in by @simple-module-py/ui) pins
|
|
55
|
+
# postcss-selector-parser 6.0.10, which `npm audit` flags as a moderate ReDoS
|
|
56
|
+
# (GH #900). This repo's root package.json carries the same override.
|
|
57
|
+
_APP_NPM_OVERRIDES = {"postcss-selector-parser": "^6.1.5"}
|
|
58
|
+
|
|
53
59
|
|
|
54
60
|
def _db_url(db: str, db_name: str, *, flat: bool, password: str = "<POSTGRES_PASSWORD>") -> str:
|
|
55
61
|
if db == "postgres":
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"""Values that keep a scaffolded app passing its own ``make lint`` (GH #896)."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
# ty is pre-1.0 and renames rules between releases (0.0.100 renamed
|
|
6
|
+
# ``unresolved-attribute``, which the scaffold's ``[tool.ty.rules]`` names), so
|
|
7
|
+
# new apps get the range this repo is tested on, not the newest ty.
|
|
8
|
+
# ``test_scaffold_lint_tooling.py`` fails once ``uv.lock`` moves past it.
|
|
9
|
+
TY_REQUIREMENT = "ty>=0.0.90,<0.0.100"
|
|
10
|
+
|
|
11
|
+
# Apps turn ty's ``invalid-assignment`` off, so this ignore would be reported as
|
|
12
|
+
# unused there; only a module inside the framework repo, which checks the rule,
|
|
13
|
+
# gets it.
|
|
14
|
+
MODEL_CONFIG_TY_IGNORE = " # ty: ignore[invalid-assignment]"
|
|
15
|
+
|
|
16
|
+
_MODULE_CONSTANTS = (
|
|
17
|
+
"API_PREFIX",
|
|
18
|
+
"LOCALE_NAMESPACE",
|
|
19
|
+
"MENU_ICON",
|
|
20
|
+
"MENU_LABEL",
|
|
21
|
+
"MENU_LABEL_KEY",
|
|
22
|
+
"MENU_ORDER",
|
|
23
|
+
"MENU_URL",
|
|
24
|
+
"PERM_GROUP",
|
|
25
|
+
"VIEW_PREFIX",
|
|
26
|
+
)
|
|
27
|
+
_MODULE_PERMISSIONS = ("CREATE", "DELETE", "EDIT", "VIEW")
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def module_constants_import(package_upper: str) -> str:
|
|
31
|
+
"""The ``module.py`` constants import list, in the order ruff's isort wants.
|
|
32
|
+
|
|
33
|
+
Where ``PERM_GROUP`` falls among ``PERM_<PACKAGE>_*`` depends on the package
|
|
34
|
+
name, so a fixed template order is unsorted for half of all names.
|
|
35
|
+
"""
|
|
36
|
+
names = [*_MODULE_CONSTANTS, *(f"PERM_{package_upper}_{p}" for p in _MODULE_PERMISSIONS)]
|
|
37
|
+
return "\n".join(f" {name}," for name in sorted(names, key=str.lower))
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"""Warn when ``smpy new`` runs from an older CLI than PyPI's latest (GH #899).
|
|
2
|
+
|
|
3
|
+
A new app pins every framework package to the running CLI's own version, and
|
|
4
|
+
``uvx --from simple_module_cli`` quietly reuses a ``uv tool install``-ed copy, so
|
|
5
|
+
an old tool scaffolds an old app without saying so. The check is best effort: a
|
|
6
|
+
short timeout, and any failure (offline, PyPI down, bad JSON) skips it.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
from __future__ import annotations
|
|
10
|
+
|
|
11
|
+
from functools import partial
|
|
12
|
+
|
|
13
|
+
import typer
|
|
14
|
+
from packaging.version import Version
|
|
15
|
+
|
|
16
|
+
from simple_module_cli.pins import PLACEHOLDER_VERSION
|
|
17
|
+
from simple_module_cli.pypi import PYPI_URL, Fetcher, default_fetcher, fetch_latest
|
|
18
|
+
|
|
19
|
+
CLI_DIST = "simple_module_cli"
|
|
20
|
+
_TIMEOUT_SECONDS = 3
|
|
21
|
+
_quick_fetcher: Fetcher = partial(default_fetcher, timeout=_TIMEOUT_SECONDS)
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def newer_release(current: str, fetcher: Fetcher | None = None) -> str | None:
|
|
25
|
+
"""The latest stable ``simple_module_cli`` on PyPI if it is newer than ``current``."""
|
|
26
|
+
if current == PLACEHOLDER_VERSION:
|
|
27
|
+
return None
|
|
28
|
+
try:
|
|
29
|
+
running = Version(current)
|
|
30
|
+
if running.is_prerelease or running.is_devrelease or running.local:
|
|
31
|
+
return None # pre-release, dev or local build: not what PyPI ships
|
|
32
|
+
latest = fetch_latest(CLI_DIST, include_pre=False, fetcher=fetcher or _quick_fetcher)
|
|
33
|
+
if latest is not None and Version(latest) > running:
|
|
34
|
+
return latest
|
|
35
|
+
except Exception:
|
|
36
|
+
# OSError (timeouts, sockets), ValueError (bad JSON/versions), but also
|
|
37
|
+
# http.client.IncompleteRead and AttributeError on an unexpected payload shape.
|
|
38
|
+
return None
|
|
39
|
+
return None
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def warn_if_outdated(current: str, fetcher: Fetcher | None = None) -> None:
|
|
43
|
+
latest = newer_release(current, fetcher)
|
|
44
|
+
if latest is None:
|
|
45
|
+
return
|
|
46
|
+
typer.echo(
|
|
47
|
+
f"WARNING: this smpy is {current}, but {CLI_DIST} {latest} is on PyPI "
|
|
48
|
+
f"({PYPI_URL.format(name=CLI_DIST)}). The new app will pin the framework to "
|
|
49
|
+
f"{current}.\n"
|
|
50
|
+
f" Upgrade the installed tool: uv tool upgrade {CLI_DIST} (pipx upgrade {CLI_DIST})\n"
|
|
51
|
+
f" or run the latest once: uvx --from {CLI_DIST}@latest smpy new ...",
|
|
52
|
+
err=True,
|
|
53
|
+
)
|
simple_module_cli/app_project.py
CHANGED
|
@@ -22,6 +22,7 @@ from typing import Any
|
|
|
22
22
|
from simple_module_cli._app_project_manifests import (
|
|
23
23
|
_APP_NPM_DEPS,
|
|
24
24
|
_APP_NPM_DEV_DEPS,
|
|
25
|
+
_APP_NPM_OVERRIDES,
|
|
25
26
|
_APP_PY_DEV_DEPS,
|
|
26
27
|
_FRAMEWORK_VERSION,
|
|
27
28
|
_db_url,
|
|
@@ -160,19 +161,21 @@ def create_app_project(
|
|
|
160
161
|
)
|
|
161
162
|
host_pyproject.write_text(text, encoding="utf-8")
|
|
162
163
|
|
|
164
|
+
pkg_path = target / "package.json"
|
|
165
|
+
pkg_data: dict[str, Any] = (
|
|
166
|
+
_json.loads(pkg_path.read_text(encoding="utf-8"))
|
|
167
|
+
if pkg_path.exists()
|
|
168
|
+
else {"name": to_kebab_case(name), "private": True, "type": "module"}
|
|
169
|
+
)
|
|
163
170
|
if flat:
|
|
164
171
|
# The workspace template already emits a top-level package.json
|
|
165
172
|
# with workspaces; flat mode has none, so seed one with the
|
|
166
173
|
# framework npm pins so `npm install` resolves at the root.
|
|
167
|
-
pkg_path = target / "package.json"
|
|
168
|
-
pkg_data: dict[str, Any] = (
|
|
169
|
-
_json.loads(pkg_path.read_text(encoding="utf-8"))
|
|
170
|
-
if pkg_path.exists()
|
|
171
|
-
else {"name": to_kebab_case(name), "private": True, "type": "module"}
|
|
172
|
-
)
|
|
173
174
|
pkg_data.setdefault("dependencies", {}).update(_APP_NPM_DEPS)
|
|
174
175
|
pkg_data.setdefault("devDependencies", {}).update(_APP_NPM_DEV_DEPS)
|
|
175
|
-
|
|
176
|
+
# npm reads `overrides` only from the root package.json, in both layouts.
|
|
177
|
+
pkg_data.setdefault("overrides", {}).update(_APP_NPM_OVERRIDES)
|
|
178
|
+
pkg_path.write_text(_json.dumps(pkg_data, indent=2) + "\n", encoding="utf-8")
|
|
176
179
|
|
|
177
180
|
ctx = ScaffoldCtx(name=name, db=db, tenancy=tenancy, selected=tuple(resolved))
|
|
178
181
|
for mod_name in resolved:
|
simple_module_cli/new.py
CHANGED
|
@@ -10,10 +10,12 @@ from typing import Annotated
|
|
|
10
10
|
|
|
11
11
|
import typer
|
|
12
12
|
|
|
13
|
+
from simple_module_cli._version_check import warn_if_outdated
|
|
13
14
|
from simple_module_cli.add_cmd import run_add
|
|
14
15
|
from simple_module_cli.app_project import create_app_project
|
|
15
16
|
from simple_module_cli.case import InvalidScaffoldNameError, to_kebab_case, validate_scaffold_name
|
|
16
17
|
from simple_module_cli.catalog import PRESETS, expand_deps
|
|
18
|
+
from simple_module_cli.pins import resolve_framework_version
|
|
17
19
|
from simple_module_cli.wizard import run_wizard
|
|
18
20
|
|
|
19
21
|
__all__ = ["new_project"]
|
|
@@ -110,6 +112,7 @@ def new_project(
|
|
|
110
112
|
except InvalidScaffoldNameError as exc:
|
|
111
113
|
typer.echo(f"ERROR: {exc}", err=True)
|
|
112
114
|
raise typer.Exit(code=1) from exc
|
|
115
|
+
warn_if_outdated(resolve_framework_version())
|
|
113
116
|
pypi_name = to_kebab_case(name)
|
|
114
117
|
if pypi_name != name:
|
|
115
118
|
typer.echo(f"Normalizing PyPI name to {pypi_name!r}.")
|
simple_module_cli/pins.py
CHANGED
|
@@ -15,6 +15,9 @@ from __future__ import annotations
|
|
|
15
15
|
|
|
16
16
|
from pathlib import Path
|
|
17
17
|
|
|
18
|
+
# What resolve_framework_version() returns for an install without dist-info.
|
|
19
|
+
PLACEHOLDER_VERSION = "0.0.0"
|
|
20
|
+
|
|
18
21
|
|
|
19
22
|
def resolve_framework_version() -> str:
|
|
20
23
|
"""Resolve the framework version that scaffolded apps should pin against.
|
|
@@ -31,7 +34,7 @@ def resolve_framework_version() -> str:
|
|
|
31
34
|
try:
|
|
32
35
|
return pkg_version("simple_module_cli")
|
|
33
36
|
except PackageNotFoundError:
|
|
34
|
-
return
|
|
37
|
+
return PLACEHOLDER_VERSION
|
|
35
38
|
|
|
36
39
|
|
|
37
40
|
def _pin_one(dep: str, version: str) -> str:
|
simple_module_cli/pypi.py
CHANGED
|
@@ -57,6 +57,6 @@ def fetch_latest(name: str, *, include_pre: bool, fetcher: Fetcher) -> str | Non
|
|
|
57
57
|
return fallback if is_valid_version(fallback) else None
|
|
58
58
|
|
|
59
59
|
|
|
60
|
-
def default_fetcher(url: str) -> dict[str, Any]:
|
|
61
|
-
with urllib.request.urlopen(url, timeout=
|
|
60
|
+
def default_fetcher(url: str, timeout: float = 10) -> dict[str, Any]:
|
|
61
|
+
with urllib.request.urlopen(url, timeout=timeout) as resp:
|
|
62
62
|
return json.loads(resp.read().decode("utf-8"))
|
simple_module_cli/scaffolding.py
CHANGED
|
@@ -21,6 +21,12 @@ from collections.abc import Sequence
|
|
|
21
21
|
from pathlib import Path
|
|
22
22
|
from typing import TypeGuard
|
|
23
23
|
|
|
24
|
+
from simple_module_cli._lint_tooling import (
|
|
25
|
+
MODEL_CONFIG_TY_IGNORE,
|
|
26
|
+
TY_REQUIREMENT,
|
|
27
|
+
module_constants_import,
|
|
28
|
+
)
|
|
29
|
+
|
|
24
30
|
# The template engine lives in _templating.py; the private names are imported
|
|
25
31
|
# here because long-standing tests monkeypatch them on this module.
|
|
26
32
|
from simple_module_cli._templating import (
|
|
@@ -137,6 +143,7 @@ def create_workspace(
|
|
|
137
143
|
"{{HOST_NAME}}": validate_scaffold_name(name),
|
|
138
144
|
"{{HOST_PYPI_NAME}}": to_kebab_case(name),
|
|
139
145
|
"{{FRAMEWORK_VERSION}}": framework_version,
|
|
146
|
+
"{{TY_REQUIREMENT}}": TY_REQUIREMENT,
|
|
140
147
|
},
|
|
141
148
|
preserve_existing=preserve_existing,
|
|
142
149
|
)
|
|
@@ -239,6 +246,8 @@ def create_module(
|
|
|
239
246
|
"{{SINGULAR}}": singular,
|
|
240
247
|
"{{SINGULAR_UPPER}}": singular.upper(),
|
|
241
248
|
"{{SINGULAR_CLASS}}": to_pascal_case(singular),
|
|
249
|
+
"{{CONSTANTS_IMPORTS}}": module_constants_import(package_name.upper()),
|
|
250
|
+
"{{MODEL_CONFIG_TY_IGNORE}}": MODEL_CONFIG_TY_IGNORE if framework_repo else "",
|
|
242
251
|
# npm-side pin for @simple-module-py/* devDependencies; "*" when the
|
|
243
252
|
# caller skips pinning (mirrors _should_pin_framework_version).
|
|
244
253
|
"{{FRAMEWORK_VERSION}}": (
|
|
@@ -30,6 +30,8 @@ class OrderOut(SQLModel): # DTO — plain SQLModel, no table=True
|
|
|
30
30
|
name: str
|
|
31
31
|
```
|
|
32
32
|
|
|
33
|
+
On a DTO, `Field(regex=...)` is accepted but never enforced, and `Field(pattern=...)` raises `TypeError`, so check formats with a pydantic `field_validator`. Length and range limits work.
|
|
34
|
+
|
|
33
35
|
Forbidden in module code: `pydantic.BaseModel` for DTOs, and SQLAlchemy `DeclarativeBase` + `Mapped[...]` / `mapped_column(...)` for tables. Autogenerate, fixtures, Inertia serialization, and the shared mixins all assume the SQLModel metaclass.
|
|
34
36
|
|
|
35
37
|
### 2. The file-size cap
|
|
@@ -39,7 +41,7 @@ Treat 300 lines as the design pressure on every `.py`, `.ts`, and `.tsx` file (t
|
|
|
39
41
|
New module settings and their app-state container live in `core/settings.py`
|
|
40
42
|
and `core/services.py`; HTTP dependencies and services live in `web/`. Keep
|
|
41
43
|
root lookup files in place and put non-page frontend code in `ui/`. See
|
|
42
|
-
[Module layout](
|
|
44
|
+
[Module layout](https://docs.py.simplemodule.dev/module-layout).
|
|
43
45
|
|
|
44
46
|
### 3. Per-module settings: `register_module_settings` → `app.state.<module>`
|
|
45
47
|
|
|
@@ -66,7 +66,7 @@ Modules use this area layout.
|
|
|
66
66
|
Area initializers hold only a docstring. Private helpers stay in their area.
|
|
67
67
|
Tests have no `__init__.py`, keep `conftest.py` at their root and use globally
|
|
68
68
|
unique `test_orders_*.py` basenames; JS tests stay in `tests-js/`.
|
|
69
|
-
See [Module layout](
|
|
69
|
+
See [Module layout](https://docs.py.simplemodule.dev/module-layout) for the lookup consumers and shim policy.
|
|
70
70
|
|
|
71
71
|
## The contract: pyproject.toml + module.py
|
|
72
72
|
|
|
@@ -9,7 +9,7 @@ description: Use when interpreting a simple_module_python diagnostic code (SM001
|
|
|
9
9
|
|
|
10
10
|
The same diagnostics also run at host boot, but **only in development** (`SM_ENVIRONMENT == development`) — they print to the boot logs and `raise SystemExit` if there's any ERROR. **In production the diagnostics pass is skipped**; what protects prod is that module *discovery* runs strictly (any bad entry point — broken import, missing `meta`, non-`ModuleBase` class — or a missing `depends_on` target raises and fails the boot). So "errors fail prod boot" is true for discovery-level breakage (surfaced as **SM001**), not for the per-finding checks below, which you'll catch via `make doctor` / dev boot before you ever deploy.
|
|
11
11
|
|
|
12
|
-
You can also call `run_diagnostics(...)` from `simple_module_core` programmatically (e.g. in a CI job) to surface issues without booting the full app — pass `migration_state=` / `module_tables=` / `migrated_tables=` to additionally get **SM010/SM011** (the
|
|
12
|
+
You can also call `run_diagnostics(...)` from `simple_module_core` programmatically (e.g. in a CI job) to surface issues without booting the full app — pass `migration_state=` / `module_tables=` / `migrated_tables=` to additionally get **SM010/SM011** (`make doctor` reads those from the database itself), and `i18n_supported_locales=` / `i18n_default_locale=` to get the locale checks.
|
|
13
13
|
|
|
14
14
|
## Code reference
|
|
15
15
|
|
|
@@ -21,8 +21,8 @@ You can also call `run_diagnostics(...)` from `simple_module_core` programmatica
|
|
|
21
21
|
| **SM007** | INFO | Module overrides no `register_*` hooks at all — likely scaffolded but empty | Either implement at least one hook or delete the module if unused |
|
|
22
22
|
| **SM008** | ERROR | Two modules declare the same `ModuleMeta.name`, or two names collide once lowercased as table prefixes in the shared schema (one finding per collision, from either the duplicate-name or the schema-conflict check) | Rename one module's `meta.name` |
|
|
23
23
|
| **SM009** | ERROR | A `framework/*` package directly imports from a plugin module (`modules/*`) | Move the symbol *up* into `simple_module_core` / `simple_module_hosting`, or invert the dependency via the event bus / a registry |
|
|
24
|
-
| **SM010** | ERROR |
|
|
25
|
-
| **SM011** | WARNING | A module
|
|
24
|
+
| **SM010** | ERROR / WARNING | `make doctor` compares `alembic_version` in `SM_DATABASE_URL` with the heads in `alembic.ini` (else `host/alembic.ini`): ERROR when any head is missing, WARNING when the DB was never migrated or could not be read | Run `make migrate` before booting; in CI, ensure migrations are part of the deploy step. The live boot enforces it separately: the lifespan raises a plain `RuntimeError` in dev and prod if the DB is behind head (a never-migrated first run goes to `/setup`) |
|
|
25
|
+
| **SM011** | WARNING | A table in a module's `models` is missing from a database at every head, so no migration creates it. Reported by `make doctor` and by a development boot once the database is open; skipped while the DB is behind head | Run `make migration msg="..."`, review the revision, apply |
|
|
26
26
|
| **SM012** | WARNING (dev only) | `register_settings` is overridden but nothing was added to `app.state.<module_lower>` | Either store the module's settings dataclass on `app.state.<module_lower>` or remove the empty override |
|
|
27
27
|
| **SM013** | WARNING | A locale file declared in `locale_dirs()` is missing for one of the supported locales | Create the file (even if empty) or trim `SM_I18N_SUPPORTED_LOCALES` |
|
|
28
28
|
| **SM014** | WARNING | A non-default locale is missing keys present in the default locale | Add the missing keys, or accept that a fallback to default applies |
|
|
@@ -39,6 +39,8 @@ Boot regenerates it too; mid-session adds need the manual call before HMR sees t
|
|
|
39
39
|
|
|
40
40
|
**Typing them in TSX.** A page receives its own props as typed component arguments (`export default function Browse({ items }: Props)`). Shared props are typed globally: `usePage().props.auth` is already a `SharedProps['auth']`. Components and layouts that need page props too use `usePageProps<Props>()` from `@simple-module-py/ui` (it returns `Props & SharedProps & { errors }`). Never write `usePage<{ props: X }>().props as unknown as X`; `make lint` rejects `as unknown as` outside tests unless the line carries `// cast-ok: <reason>`.
|
|
41
41
|
|
|
42
|
+
**A page sets its own layout.** The host applies none by default, so a page with no `Page.layout` renders without the sidebar, header and footer. Signed-in screens end the file with `Browse.layout = [AuthenticatedLayout];` (import from `@simple-module-py/ui/layouts/AuthenticatedLayout`); `/admin/*` pages use `AdminLayout`, public ones `PublicLayout`. The module scaffold generates this.
|
|
43
|
+
|
|
42
44
|
**`auth.user` is `None` when no `principal_serializer` is registered**, even if the user is authenticated. The framework can't know the shape of your user object. The `auth` module registers the callable during `register_settings(app)` (`modules/auth/auth/module.py`):
|
|
43
45
|
|
|
44
46
|
```python
|
|
@@ -4,8 +4,23 @@
|
|
|
4
4
|
# the repo root is what lets alembic read the repo-root .env — and therefore
|
|
5
5
|
# the same SM_DATABASE_URL the app itself uses.
|
|
6
6
|
script_location = %(here)s/migrations
|
|
7
|
+
# Split prepend_sys_path / version_locations on os.pathsep, not on spaces, so a
|
|
8
|
+
# checkout path with a space works and Alembic does not warn (GH #872).
|
|
9
|
+
path_separator = os
|
|
7
10
|
sqlalchemy.url =
|
|
8
11
|
|
|
12
|
+
# Run the project's ruff on every new revision, so `make migration` output
|
|
13
|
+
# passes `make lint` (GH #896). Only the import rules are fixed: the unused
|
|
14
|
+
# `sa`/`op` imports of an empty revision stay for its author to use.
|
|
15
|
+
[post_write_hooks]
|
|
16
|
+
hooks = ruff_imports, ruff_format
|
|
17
|
+
ruff_imports.type = module
|
|
18
|
+
ruff_imports.module = ruff
|
|
19
|
+
ruff_imports.options = check --select I --fix --quiet REVISION_SCRIPT_FILENAME
|
|
20
|
+
ruff_format.type = module
|
|
21
|
+
ruff_format.module = ruff
|
|
22
|
+
ruff_format.options = format --quiet REVISION_SCRIPT_FILENAME
|
|
23
|
+
|
|
9
24
|
[loggers]
|
|
10
25
|
keys = root,sqlalchemy,alembic
|
|
11
26
|
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { createInertiaApp, router } from '@inertiajs/react';
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
bootI18nFromInitialPage,
|
|
4
|
+
type I18nPageBlock,
|
|
5
|
+
subscribeI18nToNavigation,
|
|
6
|
+
} from '@simple-module-py/i18n/inertia';
|
|
3
7
|
import { formatTitle, setTitleAppName } from '@simple-module-py/ui/lib/app-title';
|
|
4
8
|
import { resolveServerHead } from '@simple-module-py/ui/lib/server-head';
|
|
5
9
|
import {
|
|
@@ -11,12 +15,6 @@ import { initTheme } from '@simple-module-py/ui/lib/theme';
|
|
|
11
15
|
import { createRoot } from 'react-dom/client';
|
|
12
16
|
import { resolvePage } from './pages';
|
|
13
17
|
|
|
14
|
-
type I18nBlock = {
|
|
15
|
-
locale: string;
|
|
16
|
-
supportedLocales?: string[];
|
|
17
|
-
messages: Record<string, string> | null;
|
|
18
|
-
};
|
|
19
|
-
|
|
20
18
|
createInertiaApp({
|
|
21
19
|
title: (title) => formatTitle(title),
|
|
22
20
|
// Re-emits the `_head` prop (server-rendered SEO tags) on client visits.
|
|
@@ -26,30 +24,16 @@ createInertiaApp({
|
|
|
26
24
|
},
|
|
27
25
|
setup({ el, App, props }) {
|
|
28
26
|
const pageProps = props.initialPage.props as {
|
|
29
|
-
i18n?:
|
|
27
|
+
i18n?: I18nPageBlock;
|
|
30
28
|
branding?: { appName?: string | null };
|
|
31
29
|
};
|
|
32
30
|
setTitleAppName(pageProps.branding?.appName);
|
|
33
31
|
// Before the first render, so a dark-theme user never sees a light frame.
|
|
34
32
|
initTheme();
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
});
|
|
40
|
-
router.on('success', (event) => {
|
|
41
|
-
const block = (event.detail.page.props as { i18n?: I18nBlock }).i18n;
|
|
42
|
-
// A non-null `messages` payload IS the server's signal that the client
|
|
43
|
-
// needs it — the backend sends `null` whenever the catalog the client
|
|
44
|
-
// already holds is still good. Gating on a locale change instead drops
|
|
45
|
-
// the catalog that arrives when the *audience* changes: signing in swaps
|
|
46
|
-
// the anonymous snapshot for one including admin-only modules, at the
|
|
47
|
-
// same locale, so every admin screen rendered raw keys
|
|
48
|
-
// ("dashboard.home.title") until a hard refresh.
|
|
49
|
-
if (block?.messages) {
|
|
50
|
-
updateI18n({ locale: block.locale, messages: block.messages });
|
|
51
|
-
}
|
|
52
|
-
});
|
|
33
|
+
// Reports this tab's catalog in `X-SM-I18n` on every visit and adopts the
|
|
34
|
+
// catalog the server sends back, so each tab keeps its own (#788, #871).
|
|
35
|
+
bootI18nFromInitialPage(pageProps.i18n);
|
|
36
|
+
subscribeI18nToNavigation(router);
|
|
53
37
|
// Authored content (pagebuilder widgets, markdown and rich-text fields)
|
|
54
38
|
// renders author-entered URLs as plain <a href>, which the browser would
|
|
55
39
|
// follow with a full document load. This app is client-rendered, so that
|
|
@@ -20,9 +20,7 @@ export default function Landing({ isAuthenticated }: LandingProps) {
|
|
|
20
20
|
<p className="text-xs font-semibold uppercase tracking-[0.18em] text-muted-foreground">
|
|
21
21
|
simple_module_py
|
|
22
22
|
</p>
|
|
23
|
-
<h1 className="text-4xl font-bold tracking-tight sm:text-5xl">
|
|
24
|
-
Your app is up.
|
|
25
|
-
</h1>
|
|
23
|
+
<h1 className="text-4xl font-bold tracking-tight sm:text-5xl">Your app is up.</h1>
|
|
26
24
|
<p className="text-base text-muted-foreground sm:text-lg">
|
|
27
25
|
This is the host's landing page — generated by{' '}
|
|
28
26
|
<code className="rounded bg-secondary px-1.5 py-0.5 font-mono text-sm">smpy new</code>.
|
|
@@ -42,7 +40,7 @@ export default function Landing({ isAuthenticated }: LandingProps) {
|
|
|
42
40
|
{primaryLabel}
|
|
43
41
|
</a>
|
|
44
42
|
<a
|
|
45
|
-
href="https://
|
|
43
|
+
href="https://docs.py.simplemodule.dev/guide/first-module"
|
|
46
44
|
className="inline-flex items-center justify-center rounded-md border border-border bg-background px-5 py-2.5 text-sm font-medium transition-colors hover:bg-secondary"
|
|
47
45
|
>
|
|
48
46
|
Read the docs
|
|
@@ -53,15 +51,26 @@ export default function Landing({ isAuthenticated }: LandingProps) {
|
|
|
53
51
|
<h2 className="mb-3 text-sm font-semibold">Next steps</h2>
|
|
54
52
|
<ul className="space-y-2 text-sm text-muted-foreground">
|
|
55
53
|
<li>
|
|
56
|
-
|
|
54
|
+
Scaffold a module:{' '}
|
|
57
55
|
<code className="rounded bg-secondary px-1.5 py-0.5 font-mono text-[13px] text-foreground">
|
|
58
|
-
|
|
56
|
+
smpy create-module orders --dest modules/orders
|
|
59
57
|
</code>
|
|
60
58
|
</li>
|
|
61
59
|
<li>
|
|
62
|
-
|
|
60
|
+
Wire it into the host:{' '}
|
|
63
61
|
<code className="rounded bg-secondary px-1.5 py-0.5 font-mono text-[13px] text-foreground">
|
|
64
|
-
smpy
|
|
62
|
+
smpy add ../modules/orders --path host
|
|
63
|
+
</code>{' '}
|
|
64
|
+
(
|
|
65
|
+
<code className="rounded bg-secondary px-1.5 py-0.5 font-mono text-[13px] text-foreground">
|
|
66
|
+
smpy add ./modules/orders
|
|
67
|
+
</code>{' '}
|
|
68
|
+
in a flat app)
|
|
69
|
+
</li>
|
|
70
|
+
<li>
|
|
71
|
+
Create its tables:{' '}
|
|
72
|
+
<code className="rounded bg-secondary px-1.5 py-0.5 font-mono text-[13px] text-foreground">
|
|
73
|
+
make migration msg="add orders" && make migrate
|
|
65
74
|
</code>
|
|
66
75
|
</li>
|
|
67
76
|
<li>
|
|
@@ -3,8 +3,8 @@ import path from 'node:path';
|
|
|
3
3
|
import tailwindcss from '@tailwindcss/vite';
|
|
4
4
|
import react from '@vitejs/plugin-react';
|
|
5
5
|
import { type Plugin, defineConfig } from 'vite';
|
|
6
|
-
import { loadModuleAssets } from './module-assets';
|
|
7
|
-
import { viteDevServer } from './vite.dev-url';
|
|
6
|
+
import { loadModuleAssets } from './module-assets.ts';
|
|
7
|
+
import { viteDevServer } from './vite.dev-url.ts';
|
|
8
8
|
|
|
9
9
|
// Force every importer (host, workspace module, wheel-installed module)
|
|
10
10
|
// to resolve to one React copy + a single Inertia hook context. Without
|
|
@@ -29,11 +29,11 @@ function findNodeModulesRoot(start: string): string {
|
|
|
29
29
|
}
|
|
30
30
|
return start;
|
|
31
31
|
}
|
|
32
|
-
const fsRoot = findNodeModulesRoot(
|
|
32
|
+
const fsRoot = findNodeModulesRoot(import.meta.dirname);
|
|
33
33
|
|
|
34
34
|
// Walks up from client_app to the directory holding the project .env itself —
|
|
35
35
|
// fsRoot tracks node_modules, which (in flat mode) is NOT where .env lives.
|
|
36
|
-
const { origin: devUrl, port: devPort } = viteDevServer(
|
|
36
|
+
const { origin: devUrl, port: devPort } = viteDevServer(import.meta.dirname);
|
|
37
37
|
|
|
38
38
|
const {
|
|
39
39
|
fsAllow: moduleFsAllow,
|
|
@@ -42,7 +42,7 @@ const {
|
|
|
42
42
|
pagesPrefixes: modulePagesPrefixes,
|
|
43
43
|
aliases: moduleAliases,
|
|
44
44
|
npmNames: moduleNpmNames,
|
|
45
|
-
} = loadModuleAssets(
|
|
45
|
+
} = loadModuleAssets(import.meta.dirname);
|
|
46
46
|
const fakeWorkspaceImporter = path.join(fsRoot, 'package.json');
|
|
47
47
|
|
|
48
48
|
// CJS-only deps like `clsx`, `tailwind-merge`, `class-variance-authority`
|
|
@@ -99,7 +99,7 @@ function collectOptimizeIncludes(): string[] {
|
|
|
99
99
|
'use-sync-external-store/shim/with-selector',
|
|
100
100
|
]);
|
|
101
101
|
const visited = new Set<string>();
|
|
102
|
-
const queue: string[] = [path.join(
|
|
102
|
+
const queue: string[] = [path.join(import.meta.dirname, 'package.json'), ...modulePkgJsonPaths];
|
|
103
103
|
while (queue.length > 0) {
|
|
104
104
|
const pkgJsonPath = queue.shift();
|
|
105
105
|
if (!pkgJsonPath || visited.has(pkgJsonPath)) continue;
|
|
@@ -177,7 +177,7 @@ function moduleBareImportResolver(): Plugin {
|
|
|
177
177
|
|
|
178
178
|
export default defineConfig({
|
|
179
179
|
plugins: [moduleBareImportResolver(), react(), tailwindcss()],
|
|
180
|
-
root:
|
|
180
|
+
root: import.meta.dirname,
|
|
181
181
|
resolve: {
|
|
182
182
|
// `#module/<pkg>` -> that module's package directory. Optional sugar for
|
|
183
183
|
// hand-written imports; modules.generated.css does not rely on it.
|
|
@@ -187,22 +187,24 @@ export default defineConfig({
|
|
|
187
187
|
optimizeDeps: {
|
|
188
188
|
entries: ['main.tsx', 'pages/**/*.tsx', ...moduleOptimizeEntries],
|
|
189
189
|
include: collectOptimizeIncludes(),
|
|
190
|
-
// Vite's dep scanner runs
|
|
190
|
+
// Vite's dep scanner runs Rolldown against every entry above. When the
|
|
191
191
|
// entry sits outside the workspace (a wheel-installed module's
|
|
192
|
-
// pages/, or sometimes even a workspace module's pages/),
|
|
193
|
-
//
|
|
194
|
-
//
|
|
195
|
-
// fallback
|
|
196
|
-
// scan-imports. See GitHub issue #152.
|
|
197
|
-
|
|
198
|
-
|
|
192
|
+
// pages/, or sometimes even a workspace module's pages/), the upward
|
|
193
|
+
// node_modules walk from the importer does not always reach the
|
|
194
|
+
// hoisted node_modules at fsRoot. Adding it to the resolve search is
|
|
195
|
+
// a NODE_PATH-style fallback, so bare specifiers like `maplibre-gl`
|
|
196
|
+
// resolve during scan-imports. See GitHub issue #152.
|
|
197
|
+
rolldownOptions: {
|
|
198
|
+
resolve: {
|
|
199
|
+
modules: ['node_modules', path.join(fsRoot, 'node_modules')],
|
|
200
|
+
},
|
|
199
201
|
},
|
|
200
202
|
},
|
|
201
203
|
build: {
|
|
202
204
|
outDir: '../static/dist',
|
|
203
205
|
manifest: true,
|
|
204
206
|
rollupOptions: {
|
|
205
|
-
input: path.resolve(
|
|
207
|
+
input: path.resolve(import.meta.dirname, 'main.tsx'),
|
|
206
208
|
},
|
|
207
209
|
},
|
|
208
210
|
server: {
|
|
@@ -8,11 +8,17 @@ dependencies = [
|
|
|
8
8
|
"simple_module_db>=1.0,<2.0",
|
|
9
9
|
"simple_module_hosting>=1.0,<2.0",
|
|
10
10
|
"simple_module_settings>=1.0,<2.0",
|
|
11
|
-
|
|
11
|
+
# 1.16.3 added the `module` runner host/alembic.ini's post-write hooks use.
|
|
12
|
+
"alembic>=1.16.3",
|
|
12
13
|
"uvicorn[standard]>=0.34",
|
|
13
14
|
{{MODULE_DEPS}}
|
|
14
15
|
]
|
|
15
16
|
|
|
17
|
+
# `host/alembic.ini` runs ruff on every new revision. `smpy new` replaces this
|
|
18
|
+
# group with the app's full dev tooling; a standalone `smpy create-host` keeps it.
|
|
19
|
+
[dependency-groups]
|
|
20
|
+
dev = ["ruff>=0.8"]
|
|
21
|
+
|
|
16
22
|
# Host is an application, not a distributable package.
|
|
17
23
|
[tool.uv]
|
|
18
24
|
package = false
|
|
@@ -13,7 +13,7 @@ from {{PACKAGE_NAME}}.core.constants import DESCRIPTION_MAX_LENGTH, NAME_MAX_LEN
|
|
|
13
13
|
class {{SINGULAR_CLASS}}Out(SQLModel):
|
|
14
14
|
"""{{SINGULAR_CLASS}} data returned by the API."""
|
|
15
15
|
|
|
16
|
-
model_config = ConfigDict(from_attributes=True)
|
|
16
|
+
model_config = ConfigDict(from_attributes=True){{MODEL_CONFIG_TY_IGNORE}}
|
|
17
17
|
|
|
18
18
|
id: int
|
|
19
19
|
name: str
|
|
@@ -12,19 +12,7 @@ from simple_module_core.module_settings import register_module_settings
|
|
|
12
12
|
from simple_module_core.permissions import PermissionRegistry
|
|
13
13
|
|
|
14
14
|
from {{PACKAGE_NAME}}.core.constants import (
|
|
15
|
-
|
|
16
|
-
LOCALE_NAMESPACE,
|
|
17
|
-
MENU_ICON,
|
|
18
|
-
MENU_LABEL,
|
|
19
|
-
MENU_LABEL_KEY,
|
|
20
|
-
MENU_ORDER,
|
|
21
|
-
MENU_URL,
|
|
22
|
-
PERM_GROUP,
|
|
23
|
-
PERM_{{PACKAGE_NAME_UPPER}}_CREATE,
|
|
24
|
-
PERM_{{PACKAGE_NAME_UPPER}}_DELETE,
|
|
25
|
-
PERM_{{PACKAGE_NAME_UPPER}}_EDIT,
|
|
26
|
-
PERM_{{PACKAGE_NAME_UPPER}}_VIEW,
|
|
27
|
-
VIEW_PREFIX,
|
|
15
|
+
{{CONSTANTS_IMPORTS}}
|
|
28
16
|
)
|
|
29
17
|
|
|
30
18
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Head, Link, router } from '@inertiajs/react';
|
|
2
2
|
import { PageShell } from '@simple-module-py/ui/components/PageShell';
|
|
3
|
+
import { AuthenticatedLayout } from '@simple-module-py/ui/layouts/AuthenticatedLayout';
|
|
3
4
|
import { apiResult } from '@simple-module-py/ui/lib/api';
|
|
4
5
|
import { useState } from 'react';
|
|
5
6
|
import { api } from './api';
|
|
@@ -55,3 +56,5 @@ export default function Browse({ items }: { items: Item[] }) {
|
|
|
55
56
|
</PageShell>
|
|
56
57
|
);
|
|
57
58
|
}
|
|
59
|
+
|
|
60
|
+
Browse.layout = [AuthenticatedLayout];
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Head, useForm } from '@inertiajs/react';
|
|
2
2
|
import { PageShell } from '@simple-module-py/ui/components/PageShell';
|
|
3
|
+
import { AuthenticatedLayout } from '@simple-module-py/ui/layouts/AuthenticatedLayout';
|
|
3
4
|
|
|
4
5
|
export default function Create() {
|
|
5
6
|
const form = useForm({ name: '', description: '' });
|
|
@@ -41,3 +42,5 @@ export default function Create() {
|
|
|
41
42
|
</PageShell>
|
|
42
43
|
);
|
|
43
44
|
}
|
|
45
|
+
|
|
46
|
+
Create.layout = [AuthenticatedLayout];
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Head, useForm } from '@inertiajs/react';
|
|
2
2
|
import { PageShell } from '@simple-module-py/ui/components/PageShell';
|
|
3
|
+
import { AuthenticatedLayout } from '@simple-module-py/ui/layouts/AuthenticatedLayout';
|
|
3
4
|
import type { components } from './api.generated';
|
|
4
5
|
|
|
5
6
|
type Item = components['schemas']['{{SINGULAR_CLASS}}Out'];
|
|
@@ -44,3 +45,5 @@ export default function Edit({ item }: { item: Item }) {
|
|
|
44
45
|
</PageShell>
|
|
45
46
|
);
|
|
46
47
|
}
|
|
48
|
+
|
|
49
|
+
Edit.layout = [AuthenticatedLayout];
|
simple_module_cli/templates/module/_optional/framework_repo/__PACKAGE__/pages/Browse.tsx.tpl
CHANGED
|
@@ -2,6 +2,7 @@ import { Head, Link, router } from '@inertiajs/react';
|
|
|
2
2
|
import { keys, useT } from '@simple-module-py/i18n';
|
|
3
3
|
import { PageShell } from '@simple-module-py/ui/components/PageShell';
|
|
4
4
|
import { useApiErrorToast } from '@simple-module-py/ui/hooks/use-api-error-toast';
|
|
5
|
+
import { AuthenticatedLayout } from '@simple-module-py/ui/layouts/AuthenticatedLayout';
|
|
5
6
|
import { apiResult } from '@simple-module-py/ui/lib/api';
|
|
6
7
|
import { api } from './api';
|
|
7
8
|
import type { components } from './api.generated';
|
|
@@ -61,3 +62,5 @@ export default function Browse({ items }: { items: Item[] }) {
|
|
|
61
62
|
</PageShell>
|
|
62
63
|
);
|
|
63
64
|
}
|
|
65
|
+
|
|
66
|
+
Browse.layout = [AuthenticatedLayout];
|