simple-module-cli 0.0.45__py3-none-any.whl → 0.0.46__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.
Files changed (110) hide show
  1. simple_module_cli/_add_install.py +26 -2
  2. simple_module_cli/_lint_tooling.py +2 -3
  3. simple_module_cli/cli.py +33 -20
  4. simple_module_cli/module_cmd.py +2 -0
  5. simple_module_cli/new.py +54 -31
  6. simple_module_cli/scaffolding.py +5 -4
  7. simple_module_cli/skills/simple-module-cli/SKILL.md +9 -5
  8. simple_module_cli/skills/simple-module-conventions/SKILL.md +1 -1
  9. simple_module_cli/skills/simple-module-creating/SKILL.md +8 -2
  10. simple_module_cli/templates/docker/host-flat.Dockerfile +4 -1
  11. simple_module_cli/templates/docker/host.Dockerfile +4 -1
  12. simple_module_cli/templates/host/Makefile +3 -1
  13. simple_module_cli/templates/host/pyproject.toml.tpl +2 -1
  14. simple_module_cli/templates/module/README.md.tpl +7 -0
  15. simple_module_cli/templates/module/__PACKAGE__/pages/Browse.tsx.tpl +21 -15
  16. simple_module_cli/templates/module/__PACKAGE__/pages/Create.tsx.tpl +7 -5
  17. simple_module_cli/templates/module/__PACKAGE__/pages/Edit.tsx.tpl +7 -5
  18. simple_module_cli/templates/module/_optional/{framework_repo → standalone}/__PACKAGE__/pages/Browse.tsx.tpl +15 -21
  19. simple_module_cli/templates/module/_optional/{framework_repo → standalone}/__PACKAGE__/pages/Create.tsx.tpl +5 -7
  20. simple_module_cli/templates/module/_optional/{framework_repo → standalone}/__PACKAGE__/pages/Edit.tsx.tpl +5 -7
  21. simple_module_cli/templates/workspace/Makefile +3 -1
  22. simple_module_cli/templates/workspace/README.md.tpl +4 -2
  23. simple_module_cli/templates/workspace/pyproject.toml.tpl +10 -2
  24. {simple_module_cli-0.0.45.data → simple_module_cli-0.0.46.data}/data/simple_module_cli/templates/docker/host-flat.Dockerfile +4 -1
  25. {simple_module_cli-0.0.45.data → simple_module_cli-0.0.46.data}/data/simple_module_cli/templates/docker/host.Dockerfile +4 -1
  26. {simple_module_cli-0.0.45.data → simple_module_cli-0.0.46.data}/data/simple_module_cli/templates/host/Makefile +3 -1
  27. {simple_module_cli-0.0.45.data → simple_module_cli-0.0.46.data}/data/simple_module_cli/templates/host/pyproject.toml.tpl +2 -1
  28. {simple_module_cli-0.0.45.data → simple_module_cli-0.0.46.data}/data/simple_module_cli/templates/module/README.md.tpl +7 -0
  29. {simple_module_cli-0.0.45.data → simple_module_cli-0.0.46.data}/data/simple_module_cli/templates/workspace/Makefile +3 -1
  30. {simple_module_cli-0.0.45.data → simple_module_cli-0.0.46.data}/data/simple_module_cli/templates/workspace/README.md.tpl +4 -2
  31. {simple_module_cli-0.0.45.data → simple_module_cli-0.0.46.data}/data/simple_module_cli/templates/workspace/pyproject.toml.tpl +10 -2
  32. {simple_module_cli-0.0.45.dist-info → simple_module_cli-0.0.46.dist-info}/METADATA +1 -1
  33. {simple_module_cli-0.0.45.dist-info → simple_module_cli-0.0.46.dist-info}/RECORD +110 -110
  34. {simple_module_cli-0.0.45.data → simple_module_cli-0.0.46.data}/data/simple_module_cli/templates/docker/Makefile.snippet +0 -0
  35. {simple_module_cli-0.0.45.data → simple_module_cli-0.0.46.data}/data/simple_module_cli/templates/docker/compose-base-postgres.yml.tpl +0 -0
  36. {simple_module_cli-0.0.45.data → simple_module_cli-0.0.46.data}/data/simple_module_cli/templates/docker/compose-base-sqlite.yml.tpl +0 -0
  37. {simple_module_cli-0.0.45.data → simple_module_cli-0.0.46.data}/data/simple_module_cli/templates/docker/compose-tasks-postgres.yml.tpl +0 -0
  38. {simple_module_cli-0.0.45.data → simple_module_cli-0.0.46.data}/data/simple_module_cli/templates/docker/compose-tasks-sqlite.yml.tpl +0 -0
  39. {simple_module_cli-0.0.45.data → simple_module_cli-0.0.46.data}/data/simple_module_cli/templates/docker/compose-worker.yml.tpl +0 -0
  40. {simple_module_cli-0.0.45.data → simple_module_cli-0.0.46.data}/data/simple_module_cli/templates/docker/dockerignore +0 -0
  41. {simple_module_cli-0.0.45.data → simple_module_cli-0.0.46.data}/data/simple_module_cli/templates/docker/worker.Dockerfile.tpl +0 -0
  42. {simple_module_cli-0.0.45.data → simple_module_cli-0.0.46.data}/data/simple_module_cli/templates/host/.env.example +0 -0
  43. {simple_module_cli-0.0.45.data → simple_module_cli-0.0.46.data}/data/simple_module_cli/templates/host/.gitignore +0 -0
  44. {simple_module_cli-0.0.45.data → simple_module_cli-0.0.46.data}/data/simple_module_cli/templates/host/README.md.tpl +0 -0
  45. {simple_module_cli-0.0.45.data → simple_module_cli-0.0.46.data}/data/simple_module_cli/templates/host/_optional/background_tasks/Makefile.snippet +0 -0
  46. {simple_module_cli-0.0.45.data → simple_module_cli-0.0.46.data}/data/simple_module_cli/templates/host/_optional/background_tasks/run_worker.py +0 -0
  47. {simple_module_cli-0.0.45.data → simple_module_cli-0.0.46.data}/data/simple_module_cli/templates/host/alembic.ini +0 -0
  48. {simple_module_cli-0.0.45.data → simple_module_cli-0.0.46.data}/data/simple_module_cli/templates/host/client_app/app.tsx +0 -0
  49. {simple_module_cli-0.0.45.data → simple_module_cli-0.0.46.data}/data/simple_module_cli/templates/host/client_app/main.tsx +0 -0
  50. {simple_module_cli-0.0.45.data → simple_module_cli-0.0.46.data}/data/simple_module_cli/templates/host/client_app/module-assets.ts +0 -0
  51. {simple_module_cli-0.0.45.data → simple_module_cli-0.0.46.data}/data/simple_module_cli/templates/host/client_app/package.json.tpl +0 -0
  52. {simple_module_cli-0.0.45.data → simple_module_cli-0.0.46.data}/data/simple_module_cli/templates/host/client_app/pages/Error.tsx +0 -0
  53. {simple_module_cli-0.0.45.data → simple_module_cli-0.0.46.data}/data/simple_module_cli/templates/host/client_app/pages/Landing.tsx +0 -0
  54. {simple_module_cli-0.0.45.data → simple_module_cli-0.0.46.data}/data/simple_module_cli/templates/host/client_app/pages.ts +0 -0
  55. {simple_module_cli-0.0.45.data → simple_module_cli-0.0.46.data}/data/simple_module_cli/templates/host/client_app/styles.css +0 -0
  56. {simple_module_cli-0.0.45.data → simple_module_cli-0.0.46.data}/data/simple_module_cli/templates/host/client_app/tsconfig.json +0 -0
  57. {simple_module_cli-0.0.45.data → simple_module_cli-0.0.46.data}/data/simple_module_cli/templates/host/client_app/vite.config.ts +0 -0
  58. {simple_module_cli-0.0.45.data → simple_module_cli-0.0.46.data}/data/simple_module_cli/templates/host/client_app/vite.dev-url.ts +0 -0
  59. {simple_module_cli-0.0.45.data → simple_module_cli-0.0.46.data}/data/simple_module_cli/templates/host/main.py +0 -0
  60. {simple_module_cli-0.0.45.data → simple_module_cli-0.0.46.data}/data/simple_module_cli/templates/host/migrations/env.py +0 -0
  61. {simple_module_cli-0.0.45.data → simple_module_cli-0.0.46.data}/data/simple_module_cli/templates/host/migrations/script.py.mako +0 -0
  62. {simple_module_cli-0.0.45.data → simple_module_cli-0.0.46.data}/data/simple_module_cli/templates/host/migrations/versions/.gitkeep +0 -0
  63. {simple_module_cli-0.0.45.data → simple_module_cli-0.0.46.data}/data/simple_module_cli/templates/host/routes.py +0 -0
  64. {simple_module_cli-0.0.45.data → simple_module_cli-0.0.46.data}/data/simple_module_cli/templates/host/templates/index.html +0 -0
  65. {simple_module_cli-0.0.45.data → simple_module_cli-0.0.46.data}/data/simple_module_cli/templates/module/.github/workflows/ci.yml +0 -0
  66. {simple_module_cli-0.0.45.data → simple_module_cli-0.0.46.data}/data/simple_module_cli/templates/module/.github/workflows/publish.yml.tpl +0 -0
  67. {simple_module_cli-0.0.45.data → simple_module_cli-0.0.46.data}/data/simple_module_cli/templates/module/.gitignore +0 -0
  68. {simple_module_cli-0.0.45.data → simple_module_cli-0.0.46.data}/data/simple_module_cli/templates/module/__PACKAGE__/__init__.py +0 -0
  69. {simple_module_cli-0.0.45.data → simple_module_cli-0.0.46.data}/data/simple_module_cli/templates/module/__PACKAGE__/contracts/__init__.py.tpl +0 -0
  70. {simple_module_cli-0.0.45.data → simple_module_cli-0.0.46.data}/data/simple_module_cli/templates/module/__PACKAGE__/contracts/schemas.py.tpl +0 -0
  71. {simple_module_cli-0.0.45.data → simple_module_cli-0.0.46.data}/data/simple_module_cli/templates/module/__PACKAGE__/core/__init__.py +0 -0
  72. {simple_module_cli-0.0.45.data → simple_module_cli-0.0.46.data}/data/simple_module_cli/templates/module/__PACKAGE__/core/constants.py.tpl +0 -0
  73. {simple_module_cli-0.0.45.data → simple_module_cli-0.0.46.data}/data/simple_module_cli/templates/module/__PACKAGE__/core/services.py.tpl +0 -0
  74. {simple_module_cli-0.0.45.data → simple_module_cli-0.0.46.data}/data/simple_module_cli/templates/module/__PACKAGE__/core/settings.py.tpl +0 -0
  75. {simple_module_cli-0.0.45.data → simple_module_cli-0.0.46.data}/data/simple_module_cli/templates/module/__PACKAGE__/locales/en.json.tpl +0 -0
  76. {simple_module_cli-0.0.45.data → simple_module_cli-0.0.46.data}/data/simple_module_cli/templates/module/__PACKAGE__/models.py.tpl +0 -0
  77. {simple_module_cli-0.0.45.data → simple_module_cli-0.0.46.data}/data/simple_module_cli/templates/module/__PACKAGE__/module.py.tpl +0 -0
  78. {simple_module_cli-0.0.45.data/data/simple_module_cli/templates/module/_optional/framework_repo → simple_module_cli-0.0.46.data/data/simple_module_cli/templates/module}/__PACKAGE__/pages/Browse.tsx.tpl +0 -0
  79. {simple_module_cli-0.0.45.data/data/simple_module_cli/templates/module/_optional/framework_repo → simple_module_cli-0.0.46.data/data/simple_module_cli/templates/module}/__PACKAGE__/pages/Create.tsx.tpl +0 -0
  80. {simple_module_cli-0.0.45.data/data/simple_module_cli/templates/module/_optional/framework_repo → simple_module_cli-0.0.46.data/data/simple_module_cli/templates/module}/__PACKAGE__/pages/Edit.tsx.tpl +0 -0
  81. {simple_module_cli-0.0.45.data → simple_module_cli-0.0.46.data}/data/simple_module_cli/templates/module/__PACKAGE__/pages/api.generated.ts.tpl +0 -0
  82. {simple_module_cli-0.0.45.data → simple_module_cli-0.0.46.data}/data/simple_module_cli/templates/module/__PACKAGE__/pages/api.ts.tpl +0 -0
  83. {simple_module_cli-0.0.45.data → simple_module_cli-0.0.46.data}/data/simple_module_cli/templates/module/__PACKAGE__/py.typed +0 -0
  84. {simple_module_cli-0.0.45.data → simple_module_cli-0.0.46.data}/data/simple_module_cli/templates/module/__PACKAGE__/web/__init__.py +0 -0
  85. {simple_module_cli-0.0.45.data → simple_module_cli-0.0.46.data}/data/simple_module_cli/templates/module/__PACKAGE__/web/deps.py.tpl +0 -0
  86. {simple_module_cli-0.0.45.data → simple_module_cli-0.0.46.data}/data/simple_module_cli/templates/module/__PACKAGE__/web/endpoints/__init__.py +0 -0
  87. {simple_module_cli-0.0.45.data → simple_module_cli-0.0.46.data}/data/simple_module_cli/templates/module/__PACKAGE__/web/endpoints/api.py.tpl +0 -0
  88. {simple_module_cli-0.0.45.data → simple_module_cli-0.0.46.data}/data/simple_module_cli/templates/module/__PACKAGE__/web/endpoints/views.py.tpl +0 -0
  89. {simple_module_cli-0.0.45.data → simple_module_cli-0.0.46.data}/data/simple_module_cli/templates/module/__PACKAGE__/web/service.py.tpl +0 -0
  90. {simple_module_cli-0.0.45.data → simple_module_cli-0.0.46.data}/data/simple_module_cli/templates/module/_optional/framework_repo/LICENSE +0 -0
  91. {simple_module_cli-0.0.45.data → simple_module_cli-0.0.46.data}/data/simple_module_cli/templates/module/_optional/framework_repo/README.md.tpl +0 -0
  92. {simple_module_cli-0.0.45.data → simple_module_cli-0.0.46.data}/data/simple_module_cli/templates/module/_optional/framework_repo/pyproject.toml.tpl +0 -0
  93. {simple_module_cli-0.0.45.data/data/simple_module_cli/templates/module → simple_module_cli-0.0.46.data/data/simple_module_cli/templates/module/_optional/standalone}/__PACKAGE__/pages/Browse.tsx.tpl +0 -0
  94. {simple_module_cli-0.0.45.data/data/simple_module_cli/templates/module → simple_module_cli-0.0.46.data/data/simple_module_cli/templates/module/_optional/standalone}/__PACKAGE__/pages/Create.tsx.tpl +0 -0
  95. {simple_module_cli-0.0.45.data/data/simple_module_cli/templates/module → simple_module_cli-0.0.46.data/data/simple_module_cli/templates/module/_optional/standalone}/__PACKAGE__/pages/Edit.tsx.tpl +0 -0
  96. {simple_module_cli-0.0.45.data → simple_module_cli-0.0.46.data}/data/simple_module_cli/templates/module/_optional/standalone/package.json.tpl +0 -0
  97. {simple_module_cli-0.0.45.data → simple_module_cli-0.0.46.data}/data/simple_module_cli/templates/module/_optional/standalone/tsconfig.json.tpl +0 -0
  98. {simple_module_cli-0.0.45.data → simple_module_cli-0.0.46.data}/data/simple_module_cli/templates/module/package.json.tpl +0 -0
  99. {simple_module_cli-0.0.45.data → simple_module_cli-0.0.46.data}/data/simple_module_cli/templates/module/pyproject.toml.tpl +0 -0
  100. {simple_module_cli-0.0.45.data → simple_module_cli-0.0.46.data}/data/simple_module_cli/templates/module/tests/conftest.py +0 -0
  101. {simple_module_cli-0.0.45.data → simple_module_cli-0.0.46.data}/data/simple_module_cli/templates/module/tests/core/contracts/test___PACKAGE___schemas.py.tpl +0 -0
  102. {simple_module_cli-0.0.45.data → simple_module_cli-0.0.46.data}/data/simple_module_cli/templates/module/tests/core/module/test___PACKAGE___module.py.tpl +0 -0
  103. {simple_module_cli-0.0.45.data → simple_module_cli-0.0.46.data}/data/simple_module_cli/templates/module/tests/web/crud/test___PACKAGE___crud.py.tpl +0 -0
  104. {simple_module_cli-0.0.45.data → simple_module_cli-0.0.46.data}/data/simple_module_cli/templates/module/tsconfig.json.tpl +0 -0
  105. {simple_module_cli-0.0.45.data → simple_module_cli-0.0.46.data}/data/simple_module_cli/templates/workspace/.env.example +0 -0
  106. {simple_module_cli-0.0.45.data → simple_module_cli-0.0.46.data}/data/simple_module_cli/templates/workspace/.gitignore +0 -0
  107. {simple_module_cli-0.0.45.data → simple_module_cli-0.0.46.data}/data/simple_module_cli/templates/workspace/package.json.tpl +0 -0
  108. {simple_module_cli-0.0.45.dist-info → simple_module_cli-0.0.46.dist-info}/WHEEL +0 -0
  109. {simple_module_cli-0.0.45.dist-info → simple_module_cli-0.0.46.dist-info}/entry_points.txt +0 -0
  110. {simple_module_cli-0.0.45.dist-info → simple_module_cli-0.0.46.dist-info}/licenses/LICENSE +0 -0
@@ -8,6 +8,8 @@ from pathlib import Path
8
8
 
9
9
  import typer
10
10
 
11
+ from simple_module_cli.uv_workspace import find_workspace_root, is_workspace_member
12
+
11
13
  ExecRunner = Callable[[list[str], Path], int]
12
14
 
13
15
 
@@ -28,6 +30,24 @@ def _default_exec_runner(cmd: list[str], cwd: Path) -> int:
28
30
  return subprocess.run(cmd, cwd=cwd, check=False).returncode
29
31
 
30
32
 
33
+ def _sync_command(project_dir: Path) -> tuple[list[str], Path]:
34
+ """How to sync after editing ``project_dir``'s pyproject.
35
+
36
+ A host inside an app workspace shares one venv with the root's dev tools
37
+ and every module member. ``uv sync`` from ``host/`` would sync the host
38
+ alone and uninstall the rest (GH #916), so sync the workspace from its
39
+ root, as ``make install`` does.
40
+ """
41
+ root = find_workspace_root(project_dir)
42
+ if (
43
+ root is not None
44
+ and root != project_dir.resolve()
45
+ and is_workspace_member(project_dir, project_dir)
46
+ ):
47
+ return ["uv", "sync", "--all-packages"], root
48
+ return ["uv", "sync"], project_dir
49
+
50
+
31
51
  def _fail(message: str) -> typer.Exit:
32
52
  typer.echo(f"ERROR: {message}", err=True)
33
53
  return typer.Exit(code=1)
@@ -40,8 +60,12 @@ def post_install(
40
60
  exec_runner: ExecRunner,
41
61
  ) -> None:
42
62
  """uv sync → gen-pages → sync-js-deps → entry-point check → reminders."""
43
- if exec_runner(["uv", "sync"], project_dir) != 0:
44
- raise _fail("`uv sync` failed — pyproject was written; fix and re-run `uv sync`.")
63
+ sync_cmd, sync_dir = _sync_command(project_dir)
64
+ if exec_runner(sync_cmd, sync_dir) != 0:
65
+ shown = " ".join(sync_cmd)
66
+ raise _fail(
67
+ f"`{shown}` failed — pyproject was written; fix and re-run `{shown}` from {sync_dir}."
68
+ )
45
69
  if (project_dir / "client_app").is_dir():
46
70
  exec_runner(["uv", "run", "smpy", "host", "gen-pages"], project_dir)
47
71
  exec_runner(["uv", "run", "smpy", "host", "sync-js-deps"], project_dir)
@@ -2,11 +2,10 @@
2
2
 
3
3
  from __future__ import annotations
4
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
5
+ # ty is pre-1.0 and renames rules between releases, so
7
6
  # new apps get the range this repo is tested on, not the newest ty.
8
7
  # ``test_scaffold_lint_tooling.py`` fails once ``uv.lock`` moves past it.
9
- TY_REQUIREMENT = "ty>=0.0.90,<0.0.100"
8
+ TY_REQUIREMENT = "ty>=0.0.100,<0.0.101"
10
9
 
11
10
  # Apps turn ty's ``invalid-assignment`` off, so this ignore would be reported as
12
11
  # unused there; only a module inside the framework repo, which checks the rule,
simple_module_cli/cli.py CHANGED
@@ -126,25 +126,35 @@ def create_host(
126
126
  typer.echo(" python main.py")
127
127
 
128
128
 
129
- def _echo_workspace_hint(target: Path) -> None:
130
- """Tell the user how to wire a workspace-member module into the host (GH #442)."""
129
+ def _app_add_command(target: Path) -> str | None:
130
+ """``smpy add …`` wiring a module into its app's host, or None outside an app (GH #442)."""
131
131
  root = find_workspace_root(target.parent)
132
132
  if root is None:
133
- return
133
+ return None
134
134
  host = root / "host"
135
135
  if not (host / "pyproject.toml").is_file() or not is_workspace_member(host, target):
136
- return
136
+ return None
137
137
  rel = os.path.relpath(target.resolve(), host.resolve())
138
138
  if not rel.startswith("."):
139
139
  rel = f"./{rel}" # parse_add_spec reads a bare "a/b" as a PyPI requirement
140
- host_arg = os.path.relpath(host.resolve(), Path.cwd())
141
- if host_arg.startswith(".."):
142
- host_arg = str(host.resolve())
143
- typer.echo(
144
- f"\nThis module is a uv workspace member. Wire it into the host with:\n"
145
- f" smpy add {rel} --path {host_arg}"
146
- " # adds it as { workspace = true }"
147
- )
140
+ # The steps are printed "from the app root", so name the host relative to it.
141
+ host_arg = host.resolve().relative_to(root.resolve()).as_posix()
142
+ return f"smpy add {rel} --path {host_arg}"
143
+
144
+
145
+ def _echo_app_next_steps(add_command: str, slug: str) -> None:
146
+ """The module lives in an app's workspace: wire it in with the app's own commands.
147
+
148
+ Never ``uv sync`` inside the module: that syncs the module alone and
149
+ uninstalls the rest of the app from the shared venv (GH #916).
150
+ """
151
+ typer.echo("\nNext steps (from the app root):")
152
+ typer.echo(f" {add_command} # adds it as {{ workspace = true }}")
153
+ typer.echo(" make install")
154
+ typer.echo(f' make migration msg="add {slug}"')
155
+ typer.echo(" make migrate")
156
+ typer.echo(" make test")
157
+ typer.echo("Then restart `make dev`: modules are discovered at start-up, not on reload.")
148
158
 
149
159
 
150
160
  @app.command("create-module")
@@ -193,14 +203,17 @@ def create_module(
193
203
  "Skipped .github/ workflows: this module is inside an existing repo, "
194
204
  "where nested workflows never run. Use --standalone to emit them."
195
205
  )
196
- _echo_workspace_hint(target)
197
- typer.echo("\nNext steps:")
198
- typer.echo(f" cd {target}")
199
- typer.echo(" uv sync --extra dev")
200
- typer.echo(" uv run pytest")
201
- typer.echo(" npm install")
202
- typer.echo(" npm run typecheck")
203
- typer.echo(" uv run smpy module verify")
206
+ add_command = _app_add_command(target)
207
+ if add_command is not None:
208
+ _echo_app_next_steps(add_command, slug)
209
+ else:
210
+ typer.echo("\nNext steps:")
211
+ typer.echo(f" cd {target}")
212
+ typer.echo(" uv sync --extra dev")
213
+ typer.echo(" uv run pytest")
214
+ typer.echo(" npm install")
215
+ typer.echo(" npm run typecheck")
216
+ typer.echo(" uv run smpy module verify")
204
217
  typer.echo(
205
218
  "\nThe pages ship sample API types (pages/api.generated.ts). Once the host serves "
206
219
  "the module, refresh them after any endpoint change:\n"
@@ -50,6 +50,8 @@ def run_verify(info: ModuleInfo, *, fresh: bool = False, runner=subprocess.run)
50
50
  ],
51
51
  host,
52
52
  ),
53
+ # Keyed pages read `keys.<module>`, which only the host's gen-i18n adds (GH #918).
54
+ ("gen-i18n", [uv, "run", "python", "-m", "simple_module_hosting", "gen-i18n"], host),
53
55
  ("frontend build (tsc + vite)", [npm, "run", "build"], client_app),
54
56
  )
55
57
  for label, cmd, cwd in steps:
simple_module_cli/new.py CHANGED
@@ -4,6 +4,7 @@ from __future__ import annotations
4
4
 
5
5
  import shutil
6
6
  import subprocess
7
+ from collections.abc import Sequence
7
8
  from enum import StrEnum
8
9
  from pathlib import Path
9
10
  from typing import Annotated
@@ -174,61 +175,83 @@ def new_project(
174
175
  rel = path.relative_to(target) if path.is_relative_to(target) else path
175
176
  typer.echo(f" {rel}")
176
177
  typer.echo("\nGenerated secrets were written to .env (gitignored), not .env.example.")
177
- typer.echo("\nNext steps:")
178
- typer.echo(f" cd {target}")
178
+ manual_setup = ["make install", 'make migration msg="initial schema"', "make migrate"]
179
179
  if no_install:
180
- typer.echo(" uv sync")
181
- typer.echo(" npm install")
182
- typer.echo(' make migration msg="initial schema"')
183
- typer.echo(" make migrate")
184
- typer.echo(" make dev")
185
- typer.echo(" make docker-up # or run the full stack in containers")
186
- if "background_tasks" in resolved:
187
- typer.echo(" docker compose up -d redis worker beat # background jobs")
180
+ _echo_next_steps(target, manual_setup, resolved)
188
181
  return
189
182
 
190
- typer.echo("Installing dependencies...")
191
- for cmd in (["uv", "sync"], ["npm", "install"]):
183
+ typer.echo("\nInstalling dependencies...")
184
+ # What `make install` runs: a workspace syncs every member, not just the root.
185
+ uv_sync = ["uv", "sync"] if flat else ["uv", "sync", "--all-packages"]
186
+ for cmd in (uv_sync, ["npm", "install"]):
192
187
  if shutil.which(cmd[0]) is None:
193
188
  typer.echo(
194
189
  f"WARNING: '{cmd[0]}' not found on PATH; skipping `{' '.join(cmd)}`. "
195
190
  "Install it and finish setup manually.",
196
191
  err=True,
197
192
  )
193
+ _echo_next_steps(target, manual_setup, resolved)
198
194
  return
199
- result = subprocess.run(cmd, cwd=target, check=False)
200
- if result.returncode != 0:
201
- typer.echo(
202
- f"WARNING: {' '.join(cmd)} failed (exit {result.returncode}); "
203
- "finish setup manually.",
204
- err=True,
205
- )
195
+ if not _run_quietly(cmd, target):
196
+ _echo_next_steps(target, manual_setup, resolved)
206
197
  return
207
198
 
208
199
  alembic = _alembic_argv(target, host_dir)
209
- _bootstrap_initial_migration(target, host_dir, alembic)
200
+ typer.echo("Creating the database...")
201
+ if not _bootstrap_initial_migration(target, host_dir, alembic):
202
+ _echo_next_steps(target, manual_setup[1:], resolved)
203
+ return
210
204
  # `heads` (plural) applies every per-module branch head; `head` (singular)
211
205
  # errors once a second module ships its own migration branch label.
212
- subprocess.run([*alembic, "upgrade", "heads"], cwd=target, check=False)
213
- typer.echo("\nSetup complete. Run `make dev` in the new directory.")
214
- typer.echo("To run the full stack in containers instead: make docker-up")
206
+ if not _run_quietly([*alembic, "upgrade", "heads"], target):
207
+ # The revision exists now; regenerating it would create a duplicate.
208
+ _echo_next_steps(target, manual_setup[2:], resolved)
209
+ return
210
+ typer.echo("\nSetup complete.")
211
+ _echo_next_steps(target, [], resolved)
212
+
213
+
214
+ def _run_quietly(cmd: list[str], cwd: Path) -> bool:
215
+ """Run a setup step, showing its output only when it fails (GH #917)."""
216
+ try:
217
+ result = subprocess.run(
218
+ cmd, cwd=cwd, check=False, capture_output=True, text=True, errors="replace"
219
+ )
220
+ except OSError as exc: # the executable is missing
221
+ typer.echo(
222
+ f"WARNING: {' '.join(cmd)} could not run ({exc}); finish setup manually.", err=True
223
+ )
224
+ return False
225
+ if result.returncode == 0:
226
+ return True
227
+ typer.echo(f"{result.stdout}{result.stderr}", err=True)
228
+ typer.echo(
229
+ f"WARNING: {' '.join(cmd)} failed (exit {result.returncode}); finish setup manually.",
230
+ err=True,
231
+ )
232
+ return False
233
+
234
+
235
+ def _echo_next_steps(target: Path, setup: list[str], resolved: Sequence[str]) -> None:
236
+ typer.echo("\nNext steps:")
237
+ typer.echo(f" cd {target}")
238
+ for step in [*setup, "make dev"]:
239
+ typer.echo(f" {step}")
240
+ typer.echo(" make docker-up # or run the full stack in containers")
215
241
  if "background_tasks" in resolved:
216
- typer.echo("For background jobs, also run: docker compose up -d redis worker beat")
242
+ typer.echo(" docker compose up -d redis worker beat # background jobs")
217
243
 
218
244
 
219
- def _bootstrap_initial_migration(target: Path, host_dir: Path, alembic: list[str]) -> None:
245
+ def _bootstrap_initial_migration(target: Path, host_dir: Path, alembic: list[str]) -> bool:
220
246
  """Autogenerate the baseline migration if the scaffold ships none.
221
247
 
222
248
  Without a real revision, ``alembic upgrade head`` is a silent no-op
223
249
  against an empty schema — the bundled modules' tables never exist.
224
250
 
225
251
  Runs from ``target`` (the project root) — see :func:`_alembic_argv`.
252
+ Returns False when the autogenerate failed.
226
253
  """
227
254
  versions_dir = host_dir / "migrations" / "versions"
228
255
  if any(p.name != "__init__.py" for p in versions_dir.glob("*.py")):
229
- return
230
- subprocess.run(
231
- [*alembic, "revision", "--autogenerate", "-m", "initial schema"],
232
- cwd=target,
233
- check=False,
234
- )
256
+ return True
257
+ return _run_quietly([*alembic, "revision", "--autogenerate", "-m", "initial schema"], target)
@@ -220,13 +220,14 @@ def create_module(
220
220
  simple_module_python monorepo itself (``make new-module``): it overlays
221
221
  ``_optional/framework_repo/`` (a workspace-sourced ``pyproject.toml`` with
222
222
  the metadata ``scripts/check_metadata.py`` requires, a LICENSE and README
223
- that pass ``check_readmes.py``, and i18n-keyed pages) and implies no
224
- ``.github/``. Wiring into the repo's own pyproject files is
225
- :mod:`simple_module_cli.framework_repo`'s job.
223
+ that pass ``check_readmes.py``) and implies no ``.github/``. Wiring into
224
+ the repo's own pyproject files is :mod:`simple_module_cli.framework_repo`'s job.
226
225
 
227
226
  ``standalone=True`` additionally overlays ``_optional/standalone/`` (npm
228
227
  devDependencies + a tsconfig that resolves ``@simple-module-py/ui`` from the
229
- repo's own ``node_modules``) so the module type-checks outside a workspace.
228
+ repo's own ``node_modules``) so the module type-checks outside a workspace,
229
+ and pages with literal English: the base pages use ``t(keys.<package>.…)``
230
+ (GH #918), and a module repo has no host whose ``gen-i18n`` adds its keys.
230
231
  """
231
232
  dest = Path(dest)
232
233
  existed_before = dest.exists()
@@ -15,7 +15,7 @@ The `smpy` command is provided by `simple_module_cli` (installed as a dep of `si
15
15
  |---|---|
16
16
  | `smpy new <name>` | Greenfield: scaffold a complete app (host + selected modules) in one shot, with an interactive wizard for DB / tenancy / module preset |
17
17
  | `smpy create-host <name>` | You want just a bare host project; you'll add modules later by `pip install`-ing them |
18
- | `smpy create-module <name>` | You're authoring a publishable module package (separate repo, distributed via PyPI) |
18
+ | `smpy create-module <name>` | You're adding a module to a `smpy new` app (`--dest modules/<name>`), or authoring a publishable module package in its own repo |
19
19
  | `smpy package-update` | Bump every `simple_module_*` / `simple-module-*` dependency, optional extra and dependency group to its latest non-yanked PyPI release, and `@simple-module-py/*` npm pins to the same core version (workspace/path/git/URL sources are left untouched) |
20
20
  | `smpy migrations prepare <upgrade-id> --head <label>@head` | Write the host-side revision for a framework data upgrade that boot or `make doctor` reported (`mail.settings_namespace_v1`, `users.hashed_bearer_tokens_v1`); it never applies it — run your migrate step afterwards |
21
21
  | `smpy doctor` | Run the module diagnostics (`SM0xx`, including `SM033` data-compatibility findings) against this host's database |
@@ -90,13 +90,15 @@ smpy create-host MyApp --dest ./apps/myapp # custom destination
90
90
 
91
91
  ## `smpy create-module <name>` — module package
92
92
 
93
- For module authors publishing to PyPI. Scaffolds a standalone repo containing one module.
93
+ Scaffolds one module package: inside a `smpy new` app, or as a standalone repo to publish to PyPI.
94
94
 
95
95
  ```bash
96
- smpy create-module orders # writes ./simple_module_orders/
97
- smpy create-module orders --dest ./packages/orders
96
+ smpy create-module orders --dest modules/orders # inside an app: a workspace member
97
+ smpy create-module orders # writes ./simple_module_orders/
98
98
  ```
99
99
 
100
+ Inside an app the printed next steps are the app's: `smpy add ../modules/orders --path host` (which syncs the whole workspace), `make install`, `make migration msg="add orders"`, `make migrate`, `make test`, then restart `make dev`. Never run `uv sync` inside the module directory there: it syncs the module alone and uninstalls the rest of the app from the shared venv. Outside an app it prints the standalone flow (`uv sync --extra dev`, `uv run pytest`, `smpy module verify`).
101
+
100
102
  The result is a complete package: `pyproject.toml` with the entry point declared, `module.py` with `ModuleBase`/`ModuleMeta` skeleton, `models.py`, `contracts/`, `web/endpoints/{api,views}.py`, `pages/`, `locales/en.json`, `core/{constants,settings,services}.py`, `web/{deps,service}.py`, plus nested `tests/<area>/<feature>/test_<module>_*.py` wired up with `simple_module_test` fixtures.
101
103
 
102
104
  `<name>` accepts any case — `orders`, `Orders`, `ORDERS`, `blog_posts` all work. The CLI lowercases it for the directory and PascalCases it for `ModuleMeta.name`.
@@ -193,6 +195,7 @@ smpy settings import-from-env
193
195
  Bootstraps the first admin user, or rotates an existing admin's password.
194
196
 
195
197
  ```bash
198
+ smpy users create-admin -e admin@example.com # prompts for the password
196
199
  smpy users create-admin -e admin@example.com -p hunter2
197
200
  smpy users create-admin -e admin@example.com -p new-password --force # rotate
198
201
  smpy users create-admin -e admin@example.com -p hunter2 --full-name "Admin"
@@ -213,7 +216,8 @@ Don't bake `--password` literals into a script you commit; use a secrets store a
213
216
  - **Ran `smpy new` inside an existing project.** The default `--dest ./<name>` creates a sibling directory. If the directory already exists and is non-empty, the command errors out — pass `--dest` explicitly to disambiguate.
214
217
  - **Ran `smpy host gen-pages` from outside the host directory.** Defaults to `./client_app`; pass `--host-dir` from elsewhere.
215
218
  - **Forgot `smpy host sync-js-deps` after `pip install`-ing a module with pages.** Vite resolves module imports against `client_app/node_modules`; the new module's JS deps won't land until you sync.
216
- - **Used `smpy create-module` to add a module to an existing host.** That command is for **publishable** packages, intended to live in their own repo. To add a module to an existing host: install it (`pip install simple_module_<name>` or add to `pyproject.toml` and `uv sync`), then autogenerate a migration. See **simple-module-creating** + **simple-module-migrations**.
219
+ - **Ran `uv sync` inside a module of a `smpy new` app.** That syncs the module's own project and uninstalls the app's other packages from the shared venv. Run `make install` (`uv sync --all-packages`) at the app root instead; a plain `uv sync` at the root also works, since the root depends on the host.
220
+ - **A module added while `make dev` runs logs "installed but … cannot be imported in this process".** The reload keeps the import path the server started with; restart `make dev`.
217
221
  - **Calling `smpy create-admin` before migrations have run.** The users tables don't exist yet; the command will error. Run `alembic upgrade head` first (or use `smpy new` which does it for you when `--no-install` isn't set).
218
222
  - **Expecting `--with products` (or `keycloak` / `audit_log`) to work on `smpy new`.** Those modules exist in the monorepo but aren't scaffolder-catalog keys, so `smpy new --with products` errors. Either scaffold without them and `pip install simple_module_products` into the host afterward, or use `smpy create-host --with Products` (which doesn't validate against the catalog).
219
223
  - **Port 5050 already taken when starting a scaffolded app.** Set `SM_VITE_DEV_URL` in the project `.env` (e.g. `http://localhost:5310`) — the scaffolded `vite.config.ts` derives the dev server's port and origin from that same value, so it's the only knob to turn.
@@ -114,7 +114,7 @@ Locale-related diagnostics: SM013 (missing file), SM014 (missing keys vs default
114
114
 
115
115
  ### 9. Don't re-enable the silenced ty rules
116
116
 
117
- Projects using the `ty` type checker should globally suppress `unresolved-attribute`, `unsupported-operator`, `unknown-argument`, `no-matching-overload`, `invalid-argument-type`, and `invalid-assignment` in `pyproject.toml`. SQLModel runtime-instruments fields as SQLAlchemy attributes, so the type checker can't see what's there (and `model_config = ConfigDict(...)` clashes with ty's internal `SQLModelConfig` type, which `invalid-assignment` covers). Real bugs surface in tests. Line-level suppressions use ty's rule names, `# ty: ignore[<rule>]`; a mypy-style `# type: ignore[arg-type]` silences nothing under ty.
117
+ Projects using `ty` 0.0.100 should globally suppress `missing-attribute`, `missing-union-attribute`, `unsupported-operator`, `unknown-argument`, `no-matching-overload`, `invalid-argument-type`, and `invalid-assignment` in `pyproject.toml`. SQLModel runtime-instruments fields as SQLAlchemy attributes, so the type checker can't see what's there (and `model_config = ConfigDict(...)` clashes with ty's internal `SQLModelConfig` type, which `invalid-assignment` covers). Real bugs surface in tests. Line-level suppressions use ty's rule names, `# ty: ignore[<rule>]`; a mypy-style `# type: ignore[arg-type]` silences nothing under ty.
118
118
 
119
119
  ### 10. Declare external asset origins with `register_csp_sources`
120
120
 
@@ -27,11 +27,17 @@ make migrate
27
27
  same `create_module` as `smpy create-module`, so both produce the same tree
28
28
  below (permissions, menu item with `label_key`, `core/constants.py`, CRUD sample,
29
29
  `locales/en.json`); the in-repo variant adds workspace-sourced `pyproject.toml`
30
- metadata, `LICENSE`, and i18n-keyed pages. For a **standalone publishable
30
+ metadata and a `LICENSE`. The pages read their text from `locales/en.json`
31
+ through `t(keys.<module>.…)`; the host's `make gen-i18n` (also run by
32
+ `make install` and each dev boot) adds the module to `keys`. A `--standalone`
33
+ module repo gets pages with literal English instead, since it has no host to
34
+ generate `keys`. For a **standalone publishable
31
35
  package** (its own repo, with CI + PyPI `publish.yml`), use
32
36
  `smpy create-module orders`; pass `--standalone` to force the `.github/`
33
37
  workflows, then `uv sync` (or `pip install -e ./orders`) to install it into the
34
- host.
38
+ host. Inside a `smpy new` app, `smpy create-module orders --dest modules/orders`
39
+ makes a workspace member and prints the app's steps (`smpy add … --path host`,
40
+ `make install`, `make migration`); don't run `uv sync` inside the module there.
35
41
 
36
42
  ## What scaffolding produces
37
43
 
@@ -32,8 +32,11 @@ RUN --mount=type=cache,target=/root/.cache/uv \
32
32
  # Flat mode keeps the frontend's own package.json under client_app/.
33
33
  RUN cd client_app && if [ -f package-lock.json ]; then npm ci; else npm install; fi
34
34
 
35
- # Page manifest + generated module imports, then the production bundle.
35
+ # Page manifest + generated module imports, the app's i18n keys (module pages
36
+ # read `keys.<module>`, which the published @simple-module-py/i18n lacks), then
37
+ # the production bundle.
36
38
  RUN uv run python -m simple_module_hosting gen-pages --host-dir=client_app
39
+ RUN uv run python -m simple_module_hosting gen-i18n
37
40
  RUN cd client_app && npm run build
38
41
 
39
42
  # node_modules never ships in the runtime image.
@@ -36,8 +36,11 @@ COPY . .
36
36
  RUN --mount=type=cache,target=/root/.cache/uv \
37
37
  uv sync --all-packages --no-dev
38
38
 
39
- # Page manifest + generated module imports, then the production bundle.
39
+ # Page manifest + generated module imports, the app's i18n keys (module pages
40
+ # read `keys.<module>`, which the published @simple-module-py/i18n lacks), then
41
+ # the production bundle.
40
42
  RUN cd host && uv run python -m simple_module_hosting gen-pages --host-dir=client_app
43
+ RUN cd host && uv run python -m simple_module_hosting gen-i18n
41
44
  RUN npm run build
42
45
 
43
46
  # Re-sync so hatch force-include picks up freshly built module static/dist.
@@ -23,7 +23,9 @@ dev-api:
23
23
  dev-ui:
24
24
  cd client_app && npm run dev
25
25
 
26
- build:
26
+ # Module pages read `keys.<module>` (gen-i18n); a bundle built without them
27
+ # crashes those pages at runtime, and tsc does not catch it.
28
+ build: gen-pages gen-i18n
27
29
  cd client_app && npm run build
28
30
 
29
31
  # Testing
@@ -49,7 +49,8 @@ ignore = [
49
49
  # see through this, so ORM query expressions trip these rules with false
50
50
  # positives — real bugs still surface in tests.
51
51
  [tool.ty.rules]
52
- unresolved-attribute = "ignore"
52
+ missing-attribute = "ignore"
53
+ missing-union-attribute = "ignore"
53
54
  unsupported-operator = "ignore"
54
55
  unknown-argument = "ignore"
55
56
  no-matching-overload = "ignore"
@@ -20,6 +20,13 @@ uv run pytest
20
20
 
21
21
  ## Frontend assets (optional)
22
22
 
23
+ The pages read their text from `{{PACKAGE_NAME}}/locales/en.json`. Inside an
24
+ app they use `t(keys.{{PACKAGE_NAME}}.…)`; the host's `make gen-i18n` (also run
25
+ by `make install`, `make build` and each dev boot) adds this module to `keys`.
26
+ A standalone module repo has no host to generate them, so its scaffolded pages
27
+ use literal English: once the module is installed in an app, switch a string
28
+ to `t(keys.{{PACKAGE_NAME}}.browse.title)` and the like.
29
+
23
30
  If this module ships TSX pages:
24
31
 
25
32
  1. Drop them in `{{PACKAGE_NAME}}/pages/` (the scaffold created the
@@ -1,8 +1,9 @@
1
1
  import { Head, Link, router } from '@inertiajs/react';
2
+ import { keys, useT } from '@simple-module-py/i18n';
2
3
  import { PageShell } from '@simple-module-py/ui/components/PageShell';
4
+ import { useApiErrorToast } from '@simple-module-py/ui/hooks/use-api-error-toast';
3
5
  import { AuthenticatedLayout } from '@simple-module-py/ui/layouts/AuthenticatedLayout';
4
6
  import { apiResult } from '@simple-module-py/ui/lib/api';
5
- import { useState } from 'react';
6
7
  import { api } from './api';
7
8
  import type { components } from './api.generated';
8
9
 
@@ -10,43 +11,48 @@ import type { components } from './api.generated';
10
11
  type Item = components['schemas']['{{SINGULAR_CLASS}}Out'];
11
12
 
12
13
  export default function Browse({ items }: { items: Item[] }) {
13
- const [error, setError] = useState<string | null>(null);
14
+ const { t } = useT();
15
+ const showError = useApiErrorToast(keys.{{PACKAGE_NAME}}.browse.delete_failed);
16
+ const editLabel = t(keys.{{PACKAGE_NAME}}.browse.edit_link);
14
17
 
15
18
  async function remove(item: Item) {
16
- setError(null);
17
19
  const result = await apiResult(
18
20
  api.DELETE('/api/{{MODULE_SLUG}}/{item_id}', { params: { path: { item_id: item.id } } }),
19
21
  );
20
- if (!result.ok) {
21
- setError(result.detail ?? 'Could not delete');
22
- return;
23
- }
24
- router.reload({ only: ['items'] });
22
+ showError(result);
23
+ if (result.ok) router.reload({ only: ['items'] });
25
24
  }
26
25
 
27
26
  return (
28
- <PageShell title="{{MODULE_NAME}}" description="Manage your {{PACKAGE_NAME}}">
29
- <Head title="{{MODULE_NAME}}" />
27
+ <PageShell
28
+ title={t(keys.{{PACKAGE_NAME}}.browse.title)}
29
+ description={t(keys.{{PACKAGE_NAME}}.browse.description)}
30
+ >
31
+ <Head title={t(keys.{{PACKAGE_NAME}}.browse.title)} />
30
32
  <div className="mb-4 flex justify-end">
31
33
  <Link
32
34
  href="/{{MODULE_SLUG}}/create"
33
35
  className="rounded bg-primary px-3 py-1.5 text-primary-foreground"
34
36
  >
35
- New {{SINGULAR_CLASS}}
37
+ {t(keys.{{PACKAGE_NAME}}.browse.new_button)}
36
38
  </Link>
37
39
  </div>
38
- {error && <p className="mb-4 text-sm text-destructive">{error}</p>}
39
40
  {items.length === 0 ? (
40
- <p className="py-12 text-center text-sm text-muted-foreground">No {{PACKAGE_NAME}} yet.</p>
41
+ <div className="py-12 text-center">
42
+ <h2 className="text-lg font-medium">{t(keys.{{PACKAGE_NAME}}.browse.empty_title)}</h2>
43
+ <p className="mt-1 text-sm text-muted-foreground">
44
+ {t(keys.{{PACKAGE_NAME}}.browse.empty_description)}
45
+ </p>
46
+ </div>
41
47
  ) : (
42
48
  <ul className="divide-y">
43
49
  {items.map((item) => (
44
50
  <li key={item.id} className="flex justify-between gap-4 py-2">
45
51
  <span>{item.name}</span>
46
52
  <span className="flex gap-3">
47
- <Link href={`/{{MODULE_SLUG}}/${item.id}/edit`}>Edit</Link>
53
+ <Link href={`/{{MODULE_SLUG}}/${item.id}/edit`}>{editLabel}</Link>
48
54
  <button type="button" onClick={() => remove(item)}>
49
- Delete
55
+ {t(keys.{{PACKAGE_NAME}}.browse.delete_button)}
50
56
  </button>
51
57
  </span>
52
58
  </li>
@@ -1,12 +1,14 @@
1
1
  import { Head, useForm } from '@inertiajs/react';
2
+ import { keys, useT } from '@simple-module-py/i18n';
2
3
  import { PageShell } from '@simple-module-py/ui/components/PageShell';
3
4
  import { AuthenticatedLayout } from '@simple-module-py/ui/layouts/AuthenticatedLayout';
4
5
 
5
6
  export default function Create() {
7
+ const { t } = useT();
6
8
  const form = useForm({ name: '', description: '' });
7
9
  return (
8
- <PageShell title="New {{SINGULAR_CLASS}}">
9
- <Head title="New {{SINGULAR_CLASS}}" />
10
+ <PageShell title={t(keys.{{PACKAGE_NAME}}.create.title)}>
11
+ <Head title={t(keys.{{PACKAGE_NAME}}.create.title)} />
10
12
  <form
11
13
  className="max-w-xl space-y-3"
12
14
  onSubmit={(e) => {
@@ -15,7 +17,7 @@ export default function Create() {
15
17
  }}
16
18
  >
17
19
  <label className="block">
18
- <span className="block text-sm">Name</span>
20
+ <span className="block text-sm">{t(keys.{{PACKAGE_NAME}}.form.name_label)}</span>
19
21
  <input
20
22
  required
21
23
  value={form.data.name}
@@ -24,7 +26,7 @@ export default function Create() {
24
26
  />
25
27
  </label>
26
28
  <label className="block">
27
- <span className="block text-sm">Description</span>
29
+ <span className="block text-sm">{t(keys.{{PACKAGE_NAME}}.form.description_label)}</span>
28
30
  <textarea
29
31
  value={form.data.description}
30
32
  onChange={(e) => form.setData('description', e.target.value)}
@@ -36,7 +38,7 @@ export default function Create() {
36
38
  disabled={form.processing}
37
39
  className="rounded bg-primary px-3 py-1.5 text-primary-foreground"
38
40
  >
39
- Create
41
+ {t(keys.{{PACKAGE_NAME}}.create.submit_button)}
40
42
  </button>
41
43
  </form>
42
44
  </PageShell>
@@ -1,4 +1,5 @@
1
1
  import { Head, useForm } from '@inertiajs/react';
2
+ import { keys, useT } from '@simple-module-py/i18n';
2
3
  import { PageShell } from '@simple-module-py/ui/components/PageShell';
3
4
  import { AuthenticatedLayout } from '@simple-module-py/ui/layouts/AuthenticatedLayout';
4
5
  import type { components } from './api.generated';
@@ -6,10 +7,11 @@ import type { components } from './api.generated';
6
7
  type Item = components['schemas']['{{SINGULAR_CLASS}}Out'];
7
8
 
8
9
  export default function Edit({ item }: { item: Item }) {
10
+ const { t } = useT();
9
11
  const form = useForm({ name: item.name, description: item.description ?? '' });
10
12
  return (
11
- <PageShell title="Edit {{SINGULAR_CLASS}}">
12
- <Head title="Edit {{SINGULAR_CLASS}}" />
13
+ <PageShell title={t(keys.{{PACKAGE_NAME}}.edit.title)}>
14
+ <Head title={t(keys.{{PACKAGE_NAME}}.edit.title)} />
13
15
  <form
14
16
  className="max-w-xl space-y-3"
15
17
  onSubmit={(e) => {
@@ -18,7 +20,7 @@ export default function Edit({ item }: { item: Item }) {
18
20
  }}
19
21
  >
20
22
  <label className="block">
21
- <span className="block text-sm">Name</span>
23
+ <span className="block text-sm">{t(keys.{{PACKAGE_NAME}}.form.name_label)}</span>
22
24
  <input
23
25
  required
24
26
  value={form.data.name}
@@ -27,7 +29,7 @@ export default function Edit({ item }: { item: Item }) {
27
29
  />
28
30
  </label>
29
31
  <label className="block">
30
- <span className="block text-sm">Description</span>
32
+ <span className="block text-sm">{t(keys.{{PACKAGE_NAME}}.form.description_label)}</span>
31
33
  <textarea
32
34
  value={form.data.description}
33
35
  onChange={(e) => form.setData('description', e.target.value)}
@@ -39,7 +41,7 @@ export default function Edit({ item }: { item: Item }) {
39
41
  disabled={form.processing}
40
42
  className="rounded bg-primary px-3 py-1.5 text-primary-foreground"
41
43
  >
42
- Save
44
+ {t(keys.{{PACKAGE_NAME}}.edit.submit_button)}
43
45
  </button>
44
46
  </form>
45
47
  </PageShell>