From ca9a2931e8d0f122942e2245a1395fccb3f353d1 Mon Sep 17 00:00:00 2001 From: Anto Subash Date: Tue, 12 May 2026 23:39:15 +0200 Subject: [PATCH] fix(cli): drop view_prefix from sample module template (#138) The scaffolded `hello` module declared `view_prefix="/hello"` and overrode `register_routes` but shipped no views, menu items, or permissions, tripping the SM019 boot warning on every fresh `smpy new`. Drop `view_prefix` so the sample is API-only; authors who want a sidebar entry add `view_prefix` + `register_menu_items` together. --- .../templates/module/__PACKAGE__/module.py.tpl | 1 - framework/cli/tests/test_cli_new_regressions.py | 14 ++++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/framework/cli/simple_module_cli/templates/module/__PACKAGE__/module.py.tpl b/framework/cli/simple_module_cli/templates/module/__PACKAGE__/module.py.tpl index 34b14172..3e2a2c9e 100644 --- a/framework/cli/simple_module_cli/templates/module/__PACKAGE__/module.py.tpl +++ b/framework/cli/simple_module_cli/templates/module/__PACKAGE__/module.py.tpl @@ -13,7 +13,6 @@ class {{MODULE_NAME}}Module(ModuleBase): meta = ModuleMeta( name="{{MODULE_NAME}}", route_prefix="/api/{{MODULE_SLUG}}", - view_prefix="/{{MODULE_SLUG}}", depends_on=[], version="0.1.0", requires_framework=">=1.0,<2.0", diff --git a/framework/cli/tests/test_cli_new_regressions.py b/framework/cli/tests/test_cli_new_regressions.py index 03f6e77b..7b5bdd46 100644 --- a/framework/cli/tests/test_cli_new_regressions.py +++ b/framework/cli/tests/test_cli_new_regressions.py @@ -59,3 +59,17 @@ def test_sm_new_sample_module_seeds_static_dist_placeholder(tmp_path: Path) -> N ) static_dist = target / "modules" / "hello" / "hello" / "static" / "dist" assert static_dist.is_dir(), "static/dist/ must exist for hatch force-include" + + +def test_sm_new_sample_module_does_not_declare_view_prefix(tmp_path: Path) -> None: + """Issue #138: fresh scaffold must not declare view_prefix so it boots + without an SM019 warning (view routes registered but no menu entry or + permissions).""" + runner = CliRunner() + target = tmp_path / "demo" + runner.invoke( + app, + ["new", "demo", "--yes", "--db", "sqlite", "--no-install", "--dest", str(target)], + ) + module_py = (target / "modules" / "hello" / "hello" / "module.py").read_text() + assert "view_prefix" not in module_py