simple-module-cli 0.0.46__py3-none-any.whl → 0.0.48__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 (189) hide show
  1. simple_module_cli/_add_install.py +60 -13
  2. simple_module_cli/_app_project_manifests.py +1 -0
  3. simple_module_cli/_generation_cache.py +63 -0
  4. simple_module_cli/_lint_tooling.py +1 -24
  5. simple_module_cli/_migration_support.py +67 -0
  6. simple_module_cli/_module_build.py +1 -1
  7. simple_module_cli/_module_host.py +22 -0
  8. simple_module_cli/_project_cli_check.py +84 -0
  9. simple_module_cli/add_cmd.py +5 -3
  10. simple_module_cli/app_project.py +0 -8
  11. simple_module_cli/cli.py +47 -29
  12. simple_module_cli/dev_cmd.py +174 -0
  13. simple_module_cli/docker_assets.py +3 -6
  14. simple_module_cli/docker_cmd.py +86 -20
  15. simple_module_cli/gen_cmd.py +213 -0
  16. simple_module_cli/migration_recipes/__init__.py +11 -0
  17. simple_module_cli/migrations_cmd.py +120 -24
  18. simple_module_cli/module_cmd.py +4 -4
  19. simple_module_cli/new.py +37 -9
  20. simple_module_cli/openapi_cmd.py +6 -8
  21. simple_module_cli/openapi_types.py +8 -3
  22. simple_module_cli/package_update.py +90 -44
  23. simple_module_cli/package_update_deps.py +15 -5
  24. simple_module_cli/package_update_git.py +84 -0
  25. simple_module_cli/package_update_npm.py +12 -0
  26. simple_module_cli/pins.py +34 -1
  27. simple_module_cli/recipes.py +4 -4
  28. simple_module_cli/scaffolding.py +53 -59
  29. simple_module_cli/skills/simple-module-cli/SKILL.md +115 -83
  30. simple_module_cli/skills/simple-module-conventions/SKILL.md +26 -10
  31. simple_module_cli/skills/simple-module-creating/SKILL.md +81 -25
  32. simple_module_cli/skills/simple-module-doctor/SKILL.md +7 -7
  33. simple_module_cli/skills/simple-module-inertia-pages/SKILL.md +42 -7
  34. simple_module_cli/skills/simple-module-locales/SKILL.md +11 -16
  35. simple_module_cli/skills/simple-module-migrations/SKILL.md +51 -22
  36. simple_module_cli/skills/simple-module-page-perf/SKILL.md +1 -1
  37. simple_module_cli/skills/simple-module-page-perf/scripts/page_audit/audit_server.py +1 -1
  38. simple_module_cli/skills/simple-module-registries/SKILL.md +98 -18
  39. simple_module_cli/skills/simple-module-testing/SKILL.md +9 -3
  40. simple_module_cli/templates/docker/compose-tasks-postgres.yml.tpl +4 -4
  41. simple_module_cli/templates/docker/compose-tasks-sqlite.yml.tpl +4 -4
  42. simple_module_cli/templates/docker/host-flat.Dockerfile +1 -0
  43. simple_module_cli/templates/docker/host.Dockerfile +1 -0
  44. simple_module_cli/templates/host/.env.example +7 -1
  45. simple_module_cli/templates/host/.gitignore +8 -0
  46. simple_module_cli/templates/host/Makefile +23 -27
  47. simple_module_cli/templates/host/README.md.tpl +1 -1
  48. simple_module_cli/templates/host/_optional/background_tasks/Makefile.snippet +1 -1
  49. simple_module_cli/templates/host/client_app/app.tsx +12 -1
  50. simple_module_cli/templates/host/client_app/module-assets.ts +3 -129
  51. simple_module_cli/templates/host/client_app/package.json.tpl +2 -1
  52. simple_module_cli/templates/host/client_app/pages/Landing.tsx +3 -3
  53. simple_module_cli/templates/host/client_app/vite.config.ts +9 -198
  54. simple_module_cli/templates/host/client_app/vite.dev-url.ts +8 -89
  55. simple_module_cli/templates/host/client_app/vite.i18n.ts +2 -0
  56. simple_module_cli/templates/host/main.py +4 -56
  57. simple_module_cli/templates/host/migrations/env.py +3 -111
  58. simple_module_cli/templates/host/pyproject.toml.tpl +3 -3
  59. simple_module_cli/templates/module/.github/workflows/ci.yml +0 -8
  60. simple_module_cli/templates/module/.gitignore +1 -1
  61. simple_module_cli/templates/module/README.md.tpl +13 -20
  62. simple_module_cli/templates/module/__PACKAGE__/core/constants.py.tpl +9 -11
  63. simple_module_cli/templates/module/__PACKAGE__/module.py.tpl +15 -45
  64. simple_module_cli/templates/module/__PACKAGE__/pages/Browse.tsx.tpl +3 -3
  65. simple_module_cli/templates/module/__PACKAGE__/pages/Create.tsx.tpl +2 -1
  66. simple_module_cli/templates/module/__PACKAGE__/pages/Edit.tsx.tpl +2 -1
  67. simple_module_cli/templates/module/__PACKAGE__/pages/api.generated.ts.tpl +4 -0
  68. simple_module_cli/templates/module/__PACKAGE__/pages/i18n.generated.ts.tpl +56 -0
  69. simple_module_cli/templates/module/__PACKAGE__/web/endpoints/api.py.tpl +6 -9
  70. simple_module_cli/templates/module/__PACKAGE__/web/endpoints/views.py.tpl +9 -14
  71. simple_module_cli/templates/module/_optional/framework_repo/README.md.tpl +4 -3
  72. simple_module_cli/templates/module/_optional/framework_repo/pyproject.toml.tpl +0 -5
  73. simple_module_cli/templates/module/_optional/settings-hook.py.tpl +13 -0
  74. simple_module_cli/templates/module/pyproject.toml.tpl +3 -11
  75. simple_module_cli/templates/workspace/.env.example +7 -1
  76. simple_module_cli/templates/workspace/.gitignore +7 -0
  77. simple_module_cli/templates/workspace/Makefile +29 -32
  78. simple_module_cli/templates/workspace/pyproject.toml.tpl +3 -0
  79. simple_module_cli/update_cmd.py +39 -113
  80. {simple_module_cli-0.0.46.data → simple_module_cli-0.0.48.data}/data/simple_module_cli/templates/docker/compose-tasks-postgres.yml.tpl +4 -4
  81. {simple_module_cli-0.0.46.data → simple_module_cli-0.0.48.data}/data/simple_module_cli/templates/docker/compose-tasks-sqlite.yml.tpl +4 -4
  82. {simple_module_cli-0.0.46.data → simple_module_cli-0.0.48.data}/data/simple_module_cli/templates/docker/host-flat.Dockerfile +1 -0
  83. {simple_module_cli-0.0.46.data → simple_module_cli-0.0.48.data}/data/simple_module_cli/templates/docker/host.Dockerfile +1 -0
  84. {simple_module_cli-0.0.46.data → simple_module_cli-0.0.48.data}/data/simple_module_cli/templates/host/.env.example +7 -1
  85. {simple_module_cli-0.0.46.data → simple_module_cli-0.0.48.data}/data/simple_module_cli/templates/host/.gitignore +8 -0
  86. simple_module_cli-0.0.48.data/data/simple_module_cli/templates/host/Makefile +72 -0
  87. {simple_module_cli-0.0.46.data → simple_module_cli-0.0.48.data}/data/simple_module_cli/templates/host/README.md.tpl +1 -1
  88. {simple_module_cli-0.0.46.data → simple_module_cli-0.0.48.data}/data/simple_module_cli/templates/host/_optional/background_tasks/Makefile.snippet +1 -1
  89. {simple_module_cli-0.0.46.data → simple_module_cli-0.0.48.data}/data/simple_module_cli/templates/host/client_app/app.tsx +12 -1
  90. simple_module_cli-0.0.48.data/data/simple_module_cli/templates/host/client_app/module-assets.ts +3 -0
  91. {simple_module_cli-0.0.46.data → simple_module_cli-0.0.48.data}/data/simple_module_cli/templates/host/client_app/package.json.tpl +2 -1
  92. {simple_module_cli-0.0.46.data → simple_module_cli-0.0.48.data}/data/simple_module_cli/templates/host/client_app/pages/Landing.tsx +3 -3
  93. simple_module_cli-0.0.48.data/data/simple_module_cli/templates/host/client_app/vite.config.ts +29 -0
  94. simple_module_cli-0.0.48.data/data/simple_module_cli/templates/host/client_app/vite.dev-url.ts +11 -0
  95. simple_module_cli-0.0.48.data/data/simple_module_cli/templates/host/client_app/vite.i18n.ts +2 -0
  96. simple_module_cli-0.0.48.data/data/simple_module_cli/templates/host/main.py +10 -0
  97. simple_module_cli-0.0.48.data/data/simple_module_cli/templates/host/migrations/env.py +6 -0
  98. {simple_module_cli-0.0.46.data → simple_module_cli-0.0.48.data}/data/simple_module_cli/templates/host/pyproject.toml.tpl +3 -3
  99. {simple_module_cli-0.0.46.data → simple_module_cli-0.0.48.data}/data/simple_module_cli/templates/module/.github/workflows/ci.yml +0 -8
  100. {simple_module_cli-0.0.46.data → simple_module_cli-0.0.48.data}/data/simple_module_cli/templates/module/.gitignore +1 -1
  101. {simple_module_cli-0.0.46.data → simple_module_cli-0.0.48.data}/data/simple_module_cli/templates/module/README.md.tpl +13 -20
  102. {simple_module_cli-0.0.46.data → simple_module_cli-0.0.48.data}/data/simple_module_cli/templates/module/__PACKAGE__/core/constants.py.tpl +9 -11
  103. simple_module_cli-0.0.48.data/data/simple_module_cli/templates/module/__PACKAGE__/module.py.tpl +62 -0
  104. {simple_module_cli-0.0.46.data → simple_module_cli-0.0.48.data}/data/simple_module_cli/templates/module/__PACKAGE__/pages/Browse.tsx.tpl +3 -3
  105. {simple_module_cli-0.0.46.data → simple_module_cli-0.0.48.data}/data/simple_module_cli/templates/module/__PACKAGE__/pages/Create.tsx.tpl +2 -1
  106. {simple_module_cli-0.0.46.data → simple_module_cli-0.0.48.data}/data/simple_module_cli/templates/module/__PACKAGE__/pages/Edit.tsx.tpl +2 -1
  107. {simple_module_cli-0.0.46.data → simple_module_cli-0.0.48.data}/data/simple_module_cli/templates/module/__PACKAGE__/pages/api.generated.ts.tpl +4 -0
  108. simple_module_cli-0.0.48.data/data/simple_module_cli/templates/module/__PACKAGE__/pages/i18n.generated.ts.tpl +56 -0
  109. {simple_module_cli-0.0.46.data → simple_module_cli-0.0.48.data}/data/simple_module_cli/templates/module/__PACKAGE__/web/endpoints/api.py.tpl +6 -9
  110. {simple_module_cli-0.0.46.data → simple_module_cli-0.0.48.data}/data/simple_module_cli/templates/module/__PACKAGE__/web/endpoints/views.py.tpl +9 -14
  111. {simple_module_cli-0.0.46.data → simple_module_cli-0.0.48.data}/data/simple_module_cli/templates/module/_optional/framework_repo/README.md.tpl +4 -3
  112. {simple_module_cli-0.0.46.data → simple_module_cli-0.0.48.data}/data/simple_module_cli/templates/module/_optional/framework_repo/pyproject.toml.tpl +0 -5
  113. simple_module_cli-0.0.48.data/data/simple_module_cli/templates/module/_optional/settings-hook.py.tpl +13 -0
  114. {simple_module_cli-0.0.46.data → simple_module_cli-0.0.48.data}/data/simple_module_cli/templates/module/pyproject.toml.tpl +3 -11
  115. {simple_module_cli-0.0.46.data → simple_module_cli-0.0.48.data}/data/simple_module_cli/templates/workspace/.env.example +7 -1
  116. {simple_module_cli-0.0.46.data → simple_module_cli-0.0.48.data}/data/simple_module_cli/templates/workspace/.gitignore +7 -0
  117. simple_module_cli-0.0.48.data/data/simple_module_cli/templates/workspace/Makefile +86 -0
  118. {simple_module_cli-0.0.46.data → simple_module_cli-0.0.48.data}/data/simple_module_cli/templates/workspace/pyproject.toml.tpl +3 -0
  119. {simple_module_cli-0.0.46.dist-info → simple_module_cli-0.0.48.dist-info}/METADATA +16 -10
  120. simple_module_cli-0.0.48.dist-info/RECORD +225 -0
  121. simple_module_cli-0.0.48.dist-info/entry_points.txt +7 -0
  122. simple_module_cli/templates/module/__PACKAGE__/pages/api.ts.tpl +0 -10
  123. simple_module_cli/templates/module/_optional/standalone/__PACKAGE__/pages/Browse.tsx.tpl +0 -60
  124. simple_module_cli/templates/module/_optional/standalone/__PACKAGE__/pages/Create.tsx.tpl +0 -46
  125. simple_module_cli/templates/module/_optional/standalone/__PACKAGE__/pages/Edit.tsx.tpl +0 -49
  126. simple_module_cli/templates/module/_optional/standalone/package.json.tpl +0 -29
  127. simple_module_cli/templates/module/_optional/standalone/tsconfig.json.tpl +0 -10
  128. simple_module_cli/templates/module/package.json.tpl +0 -16
  129. simple_module_cli/templates/module/tsconfig.json.tpl +0 -10
  130. simple_module_cli-0.0.46.data/data/simple_module_cli/templates/host/Makefile +0 -76
  131. simple_module_cli-0.0.46.data/data/simple_module_cli/templates/host/client_app/module-assets.ts +0 -129
  132. simple_module_cli-0.0.46.data/data/simple_module_cli/templates/host/client_app/vite.config.ts +0 -218
  133. simple_module_cli-0.0.46.data/data/simple_module_cli/templates/host/client_app/vite.dev-url.ts +0 -92
  134. simple_module_cli-0.0.46.data/data/simple_module_cli/templates/host/main.py +0 -62
  135. simple_module_cli-0.0.46.data/data/simple_module_cli/templates/host/migrations/env.py +0 -114
  136. simple_module_cli-0.0.46.data/data/simple_module_cli/templates/module/__PACKAGE__/module.py.tpl +0 -92
  137. simple_module_cli-0.0.46.data/data/simple_module_cli/templates/module/__PACKAGE__/pages/api.ts.tpl +0 -10
  138. simple_module_cli-0.0.46.data/data/simple_module_cli/templates/module/_optional/standalone/__PACKAGE__/pages/Browse.tsx.tpl +0 -60
  139. simple_module_cli-0.0.46.data/data/simple_module_cli/templates/module/_optional/standalone/__PACKAGE__/pages/Create.tsx.tpl +0 -46
  140. simple_module_cli-0.0.46.data/data/simple_module_cli/templates/module/_optional/standalone/__PACKAGE__/pages/Edit.tsx.tpl +0 -49
  141. simple_module_cli-0.0.46.data/data/simple_module_cli/templates/module/_optional/standalone/package.json.tpl +0 -29
  142. simple_module_cli-0.0.46.data/data/simple_module_cli/templates/module/_optional/standalone/tsconfig.json.tpl +0 -10
  143. simple_module_cli-0.0.46.data/data/simple_module_cli/templates/module/package.json.tpl +0 -16
  144. simple_module_cli-0.0.46.data/data/simple_module_cli/templates/module/tsconfig.json.tpl +0 -10
  145. simple_module_cli-0.0.46.data/data/simple_module_cli/templates/workspace/Makefile +0 -89
  146. simple_module_cli-0.0.46.dist-info/RECORD +0 -228
  147. simple_module_cli-0.0.46.dist-info/entry_points.txt +0 -3
  148. /simple_module_cli/templates/module/{__PACKAGE__ → _optional/settings/__PACKAGE__}/core/services.py.tpl +0 -0
  149. /simple_module_cli/templates/module/{__PACKAGE__ → _optional/settings/__PACKAGE__}/core/settings.py.tpl +0 -0
  150. {simple_module_cli-0.0.46.data → simple_module_cli-0.0.48.data}/data/simple_module_cli/templates/docker/Makefile.snippet +0 -0
  151. {simple_module_cli-0.0.46.data → simple_module_cli-0.0.48.data}/data/simple_module_cli/templates/docker/compose-base-postgres.yml.tpl +0 -0
  152. {simple_module_cli-0.0.46.data → simple_module_cli-0.0.48.data}/data/simple_module_cli/templates/docker/compose-base-sqlite.yml.tpl +0 -0
  153. {simple_module_cli-0.0.46.data → simple_module_cli-0.0.48.data}/data/simple_module_cli/templates/docker/compose-worker.yml.tpl +0 -0
  154. {simple_module_cli-0.0.46.data → simple_module_cli-0.0.48.data}/data/simple_module_cli/templates/docker/dockerignore +0 -0
  155. {simple_module_cli-0.0.46.data → simple_module_cli-0.0.48.data}/data/simple_module_cli/templates/docker/worker.Dockerfile.tpl +0 -0
  156. {simple_module_cli-0.0.46.data → simple_module_cli-0.0.48.data}/data/simple_module_cli/templates/host/_optional/background_tasks/run_worker.py +0 -0
  157. {simple_module_cli-0.0.46.data → simple_module_cli-0.0.48.data}/data/simple_module_cli/templates/host/alembic.ini +0 -0
  158. {simple_module_cli-0.0.46.data → simple_module_cli-0.0.48.data}/data/simple_module_cli/templates/host/client_app/main.tsx +0 -0
  159. {simple_module_cli-0.0.46.data → simple_module_cli-0.0.48.data}/data/simple_module_cli/templates/host/client_app/pages/Error.tsx +0 -0
  160. {simple_module_cli-0.0.46.data → simple_module_cli-0.0.48.data}/data/simple_module_cli/templates/host/client_app/pages.ts +0 -0
  161. {simple_module_cli-0.0.46.data → simple_module_cli-0.0.48.data}/data/simple_module_cli/templates/host/client_app/styles.css +0 -0
  162. {simple_module_cli-0.0.46.data → simple_module_cli-0.0.48.data}/data/simple_module_cli/templates/host/client_app/tsconfig.json +0 -0
  163. {simple_module_cli-0.0.46.data → simple_module_cli-0.0.48.data}/data/simple_module_cli/templates/host/migrations/script.py.mako +0 -0
  164. {simple_module_cli-0.0.46.data → simple_module_cli-0.0.48.data}/data/simple_module_cli/templates/host/migrations/versions/.gitkeep +0 -0
  165. {simple_module_cli-0.0.46.data → simple_module_cli-0.0.48.data}/data/simple_module_cli/templates/host/routes.py +0 -0
  166. {simple_module_cli-0.0.46.data → simple_module_cli-0.0.48.data}/data/simple_module_cli/templates/host/templates/index.html +0 -0
  167. {simple_module_cli-0.0.46.data → simple_module_cli-0.0.48.data}/data/simple_module_cli/templates/module/.github/workflows/publish.yml.tpl +0 -0
  168. {simple_module_cli-0.0.46.data → simple_module_cli-0.0.48.data}/data/simple_module_cli/templates/module/__PACKAGE__/__init__.py +0 -0
  169. {simple_module_cli-0.0.46.data → simple_module_cli-0.0.48.data}/data/simple_module_cli/templates/module/__PACKAGE__/contracts/__init__.py.tpl +0 -0
  170. {simple_module_cli-0.0.46.data → simple_module_cli-0.0.48.data}/data/simple_module_cli/templates/module/__PACKAGE__/contracts/schemas.py.tpl +0 -0
  171. {simple_module_cli-0.0.46.data → simple_module_cli-0.0.48.data}/data/simple_module_cli/templates/module/__PACKAGE__/core/__init__.py +0 -0
  172. {simple_module_cli-0.0.46.data → simple_module_cli-0.0.48.data}/data/simple_module_cli/templates/module/__PACKAGE__/locales/en.json.tpl +0 -0
  173. {simple_module_cli-0.0.46.data → simple_module_cli-0.0.48.data}/data/simple_module_cli/templates/module/__PACKAGE__/models.py.tpl +0 -0
  174. {simple_module_cli-0.0.46.data → simple_module_cli-0.0.48.data}/data/simple_module_cli/templates/module/__PACKAGE__/py.typed +0 -0
  175. {simple_module_cli-0.0.46.data → simple_module_cli-0.0.48.data}/data/simple_module_cli/templates/module/__PACKAGE__/web/__init__.py +0 -0
  176. {simple_module_cli-0.0.46.data → simple_module_cli-0.0.48.data}/data/simple_module_cli/templates/module/__PACKAGE__/web/deps.py.tpl +0 -0
  177. {simple_module_cli-0.0.46.data → simple_module_cli-0.0.48.data}/data/simple_module_cli/templates/module/__PACKAGE__/web/endpoints/__init__.py +0 -0
  178. {simple_module_cli-0.0.46.data → simple_module_cli-0.0.48.data}/data/simple_module_cli/templates/module/__PACKAGE__/web/service.py.tpl +0 -0
  179. {simple_module_cli-0.0.46.data → simple_module_cli-0.0.48.data}/data/simple_module_cli/templates/module/_optional/framework_repo/LICENSE +0 -0
  180. {simple_module_cli-0.0.46.data/data/simple_module_cli/templates/module → simple_module_cli-0.0.48.data/data/simple_module_cli/templates/module/_optional/settings}/__PACKAGE__/core/services.py.tpl +0 -0
  181. {simple_module_cli-0.0.46.data/data/simple_module_cli/templates/module → simple_module_cli-0.0.48.data/data/simple_module_cli/templates/module/_optional/settings}/__PACKAGE__/core/settings.py.tpl +0 -0
  182. {simple_module_cli-0.0.46.data → simple_module_cli-0.0.48.data}/data/simple_module_cli/templates/module/tests/conftest.py +0 -0
  183. {simple_module_cli-0.0.46.data → simple_module_cli-0.0.48.data}/data/simple_module_cli/templates/module/tests/core/contracts/test___PACKAGE___schemas.py.tpl +0 -0
  184. {simple_module_cli-0.0.46.data → simple_module_cli-0.0.48.data}/data/simple_module_cli/templates/module/tests/core/module/test___PACKAGE___module.py.tpl +0 -0
  185. {simple_module_cli-0.0.46.data → simple_module_cli-0.0.48.data}/data/simple_module_cli/templates/module/tests/web/crud/test___PACKAGE___crud.py.tpl +0 -0
  186. {simple_module_cli-0.0.46.data → simple_module_cli-0.0.48.data}/data/simple_module_cli/templates/workspace/README.md.tpl +0 -0
  187. {simple_module_cli-0.0.46.data → simple_module_cli-0.0.48.data}/data/simple_module_cli/templates/workspace/package.json.tpl +0 -0
  188. {simple_module_cli-0.0.46.dist-info → simple_module_cli-0.0.48.dist-info}/WHEEL +0 -0
  189. {simple_module_cli-0.0.46.dist-info → simple_module_cli-0.0.48.dist-info}/licenses/LICENSE +0 -0
@@ -2,16 +2,25 @@
2
2
 
3
3
  from __future__ import annotations
4
4
 
5
+ import re
5
6
  import subprocess
6
7
  from collections.abc import Callable
7
8
  from pathlib import Path
8
9
 
9
10
  import typer
10
11
 
12
+ from simple_module_cli.package_update_deps import workspace_member_dirs
13
+ from simple_module_cli.package_update_npm import install_roots, load_manifests
14
+ from simple_module_cli.pyproject_edit import load_pyproject
11
15
  from simple_module_cli.uv_workspace import find_workspace_root, is_workspace_member
12
16
 
13
17
  ExecRunner = Callable[[list[str], Path], int]
14
18
 
19
+ _DIST_PREFIX = re.compile(r"^simple[-_]module[-_]", re.IGNORECASE)
20
+ _SKIP_IF_MISSING = "--skip-if-missing"
21
+ #: Click's exit code for an unknown option.
22
+ _USAGE_ERROR = 2
23
+
15
24
 
16
25
  _ENTRYPOINT_CHECK = (
17
26
  "import sys\n"
@@ -39,15 +48,36 @@ def _sync_command(project_dir: Path) -> tuple[list[str], Path]:
39
48
  root, as ``make install`` does.
40
49
  """
41
50
  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)
51
+ if root is not None and (
52
+ root == project_dir.resolve() or is_workspace_member(project_dir, project_dir)
46
53
  ):
47
54
  return ["uv", "sync", "--all-packages"], root
48
55
  return ["uv", "sync"], project_dir
49
56
 
50
57
 
58
+ def sync_project(
59
+ project_dir: Path, exec_runner: ExecRunner, *, upgrade: list[str] | None = None
60
+ ) -> None:
61
+ """Finish manifest changes using the app's installation and generation flow."""
62
+ sync_cmd, root = _sync_command(project_dir)
63
+ for name in upgrade or []:
64
+ sync_cmd.extend(["--upgrade-package", name])
65
+ commands = [(sync_cmd, root)]
66
+ client = next((p for p in (root / "host/client_app", root / "client_app") if p.is_dir()), None)
67
+ if client is not None:
68
+ pyproject = root / "pyproject.toml"
69
+ files = [pyproject, *workspace_member_dirs(pyproject, load_pyproject(pyproject))]
70
+ manifests = load_manifests([file.parent for file in files])
71
+ commands.extend((["npm", "install"], directory) for directory in install_roots(manifests))
72
+ commands.append((["uv", "run", "smpy", "gen"], root))
73
+ for cmd, cwd in commands:
74
+ if exec_runner(cmd, cwd) != 0:
75
+ raise _fail(
76
+ f"`{' '.join(cmd)}` failed — manifests are already updated. "
77
+ f"Fix the error, then run `make install` from {root} to finish installation."
78
+ )
79
+
80
+
51
81
  def _fail(message: str) -> typer.Exit:
52
82
  typer.echo(f"ERROR: {message}", err=True)
53
83
  return typer.Exit(code=1)
@@ -59,16 +89,25 @@ def post_install(
59
89
  models_dists: list[str],
60
90
  exec_runner: ExecRunner,
61
91
  ) -> None:
62
- """uv sync → gen-pages → sync-js-deps → entry-point check → reminders."""
92
+ """Sync dependencies, regenerate frontend files, and check entry points."""
63
93
  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}."
94
+ has_frontend = (project_dir / "client_app").is_dir()
95
+ commands = [(sync_cmd, sync_dir)]
96
+ if has_frontend:
97
+ commands.extend(
98
+ (["uv", "run", "smpy", "host", *step], project_dir)
99
+ for step in (("gen-pages",), ("sync-js-deps",), ("gen-i18n", _SKIP_IF_MISSING))
68
100
  )
69
- if (project_dir / "client_app").is_dir():
70
- exec_runner(["uv", "run", "smpy", "host", "gen-pages"], project_dir)
71
- exec_runner(["uv", "run", "smpy", "host", "sync-js-deps"], project_dir)
101
+ for cmd, cwd in commands:
102
+ code = exec_runner(cmd, cwd)
103
+ if code == _USAGE_ERROR and _SKIP_IF_MISSING in cmd:
104
+ # A hosting plugin older than the global smpy has no --skip-if-missing.
105
+ code = exec_runner([part for part in cmd if part != _SKIP_IF_MISSING], cwd)
106
+ if code != 0:
107
+ raise _fail(
108
+ f"`{' '.join(cmd)}` failed — dependencies are already recorded in pyproject.toml. "
109
+ "Fix the error, then rerun the original `smpy add` command."
110
+ )
72
111
  for dist in dists:
73
112
  code = exec_runner(["uv", "run", "python", "-c", _ENTRYPOINT_CHECK, dist], project_dir)
74
113
  if code != 0:
@@ -77,7 +116,15 @@ def post_install(
77
116
  "entry point — it is not a SimpleModule module."
78
117
  )
79
118
  for dist in models_dists:
119
+ # The same message `smpy create-module`'s next steps suggest (GH #931).
120
+ slug = _DIST_PREFIX.sub("", dist)
80
121
  typer.echo(
81
122
  f"{dist} ships database models — generate and apply the migration:\n"
82
- f' make migration msg="add {dist}"\n make migrate'
123
+ f' make migration msg="add {slug}"\n make migrate'
83
124
  )
125
+ # Only `pyproject.toml` changed, which the dev reloader does not watch; and a
126
+ # reload still logs the new module as not importable in that process (GH #915,
127
+ # #931), so only a restart serves it.
128
+ if has_frontend:
129
+ typer.echo("Run `make install` from the app root to link pages and generate i18n keys.")
130
+ typer.echo("If `make dev` is running, restart it to discover the installed modules.")
@@ -41,6 +41,7 @@ _APP_NPM_DEPS = {
41
41
  # with templates/host/client_app/package.json.tpl.
42
42
  _APP_NPM_DEV_DEPS = {
43
43
  "@simple-module-py/tsconfig": _FRAMEWORK_VERSION,
44
+ "@simple-module-py/vite-plugin": _FRAMEWORK_VERSION,
44
45
  "@tailwindcss/vite": "^4.0.0",
45
46
  "@types/node": "^26.5.0",
46
47
  "@types/react": "^19.0.0",
@@ -0,0 +1,63 @@
1
+ """Content fingerprints for the generation pipeline (never cache a failed stage)."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import hashlib
6
+ import json
7
+ import os
8
+ from collections.abc import Callable, Iterable
9
+ from pathlib import Path
10
+
11
+
12
+ def file_hashes(paths: Iterable[Path]) -> dict[str, str | None]:
13
+ result = {}
14
+ for path in sorted(set(paths)):
15
+ result[str(path)] = (
16
+ hashlib.sha256(path.read_bytes()).hexdigest() if path.is_file() else None
17
+ )
18
+ return result
19
+
20
+
21
+ def source_files(root: Path, suffixes: set[str]) -> list[Path]:
22
+ files = []
23
+ for directory, dirs, names in os.walk(root):
24
+ dirs[:] = [
25
+ d
26
+ for d in dirs
27
+ if not d.startswith(".")
28
+ and d not in {"node_modules", "__pycache__", "tests", "tests-js", "static"}
29
+ ]
30
+ files.extend(Path(directory) / n for n in names if Path(n).suffix in suffixes)
31
+ return files
32
+
33
+
34
+ class GenerationCache:
35
+ def __init__(self, path: Path):
36
+ self.path = path
37
+ try:
38
+ self.state = json.loads(path.read_text(encoding="utf-8"))
39
+ if not isinstance(self.state, dict):
40
+ self.state = {}
41
+ except (OSError, ValueError):
42
+ self.state = {}
43
+
44
+ def run(
45
+ self,
46
+ name: str,
47
+ inputs: Callable[[], object],
48
+ outputs: list[Path],
49
+ generate: Callable[[], object],
50
+ ) -> bool:
51
+ def stamp():
52
+ return {"inputs": inputs(), "outputs": file_hashes(outputs)}
53
+
54
+ if self.state.get(name) == stamp():
55
+ return False
56
+ generate()
57
+ self.state[name] = stamp()
58
+ self.path.parent.mkdir(parents=True, exist_ok=True)
59
+ # Replace atomically: an interrupted generation must leave a readable cache.
60
+ temporary = self.path.with_suffix(f".{os.getpid()}.tmp")
61
+ temporary.write_text(json.dumps(self.state, sort_keys=True), encoding="utf-8")
62
+ temporary.replace(self.path)
63
+ return True
@@ -5,32 +5,9 @@ from __future__ import annotations
5
5
  # ty is pre-1.0 and renames rules between releases, so
6
6
  # new apps get the range this repo is tested on, not the newest ty.
7
7
  # ``test_scaffold_lint_tooling.py`` fails once ``uv.lock`` moves past it.
8
- TY_REQUIREMENT = "ty>=0.0.100,<0.0.101"
8
+ TY_REQUIREMENT = "ty>=0.0.104,<0.0.105"
9
9
 
10
10
  # Apps turn ty's ``invalid-assignment`` off, so this ignore would be reported as
11
11
  # unused there; only a module inside the framework repo, which checks the rule,
12
12
  # gets it.
13
13
  MODEL_CONFIG_TY_IGNORE = " # ty: ignore[invalid-assignment]"
14
-
15
- _MODULE_CONSTANTS = (
16
- "API_PREFIX",
17
- "LOCALE_NAMESPACE",
18
- "MENU_ICON",
19
- "MENU_LABEL",
20
- "MENU_LABEL_KEY",
21
- "MENU_ORDER",
22
- "MENU_URL",
23
- "PERM_GROUP",
24
- "VIEW_PREFIX",
25
- )
26
- _MODULE_PERMISSIONS = ("CREATE", "DELETE", "EDIT", "VIEW")
27
-
28
-
29
- def module_constants_import(package_upper: str) -> str:
30
- """The ``module.py`` constants import list, in the order ruff's isort wants.
31
-
32
- Where ``PERM_GROUP`` falls among ``PERM_<PACKAGE>_*`` depends on the package
33
- name, so a fixed template order is unsorted for half of all names.
34
- """
35
- names = [*_MODULE_CONSTANTS, *(f"PERM_{package_upper}_{p}" for p in _MODULE_PERMISSIONS)]
36
- return "\n".join(f" {name}," for name in sorted(names, key=str.lower))
@@ -0,0 +1,67 @@
1
+ """Migration discovery. Keep core and the standalone CLI's vendored copy identical."""
2
+
3
+ import os
4
+ from importlib.metadata import EntryPoints, entry_points
5
+ from pathlib import Path
6
+
7
+ NO_ALEMBIC_CONFIG = "No Alembic config found. Provide alembic.ini or host/alembic.ini."
8
+ _PROJECT_WALK_LIMIT = 4
9
+ _PROJECT_MARKERS = (".git", ".env.example", ".env")
10
+
11
+
12
+ def resolve_project_root(*, fallback: Path | None = None) -> Path:
13
+ """Find the host project from cwd, including from an inner workspace package."""
14
+ override = os.environ.get("SM_PROJECT_ROOT")
15
+ if override:
16
+ return Path(override)
17
+
18
+ cwd = Path.cwd()
19
+ package_root = None
20
+ try:
21
+ home = Path.home()
22
+ except RuntimeError:
23
+ home = None
24
+ for depth, root in enumerate((cwd, *cwd.parents[:_PROJECT_WALK_LIMIT])):
25
+ if root == home or (root != cwd and root.stat().st_mode & 0o002):
26
+ break
27
+ if any((root / marker).exists() for marker in _PROJECT_MARKERS):
28
+ return root
29
+ if (root / "alembic.ini").is_file():
30
+ # A workspace root may also have a flat config, which takes precedence.
31
+ parent = root.parent
32
+ if (
33
+ root.name == "host"
34
+ and depth < _PROJECT_WALK_LIMIT
35
+ and parent != home
36
+ and not parent.stat().st_mode & 0o002
37
+ and any(
38
+ (parent / marker).exists()
39
+ for marker in (*_PROJECT_MARKERS, "pyproject.toml", "alembic.ini")
40
+ )
41
+ ):
42
+ return parent
43
+ return root
44
+ if (root / "host/alembic.ini").is_file():
45
+ return root
46
+ if package_root is None and (root / "pyproject.toml").is_file():
47
+ package_root = root
48
+ return package_root or fallback or cwd
49
+
50
+
51
+ def resolve_alembic_ini(
52
+ project_root: str | Path | None = None, *, override: str | Path | None = None
53
+ ) -> Path | None:
54
+ """Find the host's ini. An explicit path is cwd-relative and disables fallback."""
55
+ if override is not None:
56
+ candidate = Path(override)
57
+ return candidate if candidate.is_file() else None
58
+ root = Path(project_root) if project_root is not None else resolve_project_root()
59
+ for candidate in (root / "alembic.ini", root / "host" / "alembic.ini"):
60
+ if candidate.is_file():
61
+ return candidate
62
+ return None
63
+
64
+
65
+ def data_upgrade_entry_points() -> EntryPoints:
66
+ """Find registered recipes without importing any recipe code."""
67
+ return entry_points(group="simple_module.data_upgrades")
@@ -44,7 +44,7 @@ def run_build(info: ModuleInfo, *, fresh: bool = False, runner=subprocess.run) -
44
44
  raise typer.Exit(code=1)
45
45
 
46
46
  out_dir = info.root / info.package_name / "static" / "dist"
47
- config_path = info.root / ".smpy" / "module-build.config.mjs"
47
+ config_path = client_app / "module-build.config.mjs"
48
48
  config_path.parent.mkdir(parents=True, exist_ok=True)
49
49
  config_path.write_text(
50
50
  _vite_lib_config(entry, out_dir, global_name=to_pascal_case(info.package_name)),
@@ -12,7 +12,10 @@ import tomllib
12
12
  from dataclasses import dataclass
13
13
  from pathlib import Path
14
14
 
15
+ import tomlkit
15
16
  import typer
17
+ from packaging.requirements import Requirement
18
+ from packaging.utils import canonicalize_name
16
19
 
17
20
  from simple_module_cli.scaffolding import create_host, resolve_framework_version
18
21
 
@@ -71,9 +74,28 @@ def ensure_verify_host(info: ModuleInfo, *, fresh: bool = False) -> Path:
71
74
  framework_version=resolve_framework_version(),
72
75
  )
73
76
  _wire_module_dep(host_dir / "pyproject.toml", info.pypi_name)
77
+ _ensure_host_cli(host_dir / "pyproject.toml")
74
78
  return host_dir
75
79
 
76
80
 
81
+ def _ensure_host_cli(path: Path) -> None:
82
+ """Cached hosts predating smpy gen also need the CLI in their own venv."""
83
+ doc = tomlkit.parse(path.read_text(encoding="utf-8"))
84
+ groups = doc.setdefault("dependency-groups", {})
85
+ current = groups.get("dev", [])
86
+ wanted = [
87
+ dep
88
+ for dep in current
89
+ if not (
90
+ isinstance(dep, str) and canonicalize_name(Requirement(dep).name) == "simple-module-cli"
91
+ )
92
+ ]
93
+ wanted.append(f"simple_module_cli=={resolve_framework_version()}")
94
+ if list(current) != wanted:
95
+ groups["dev"] = wanted
96
+ path.write_text(tomlkit.dumps(doc), encoding="utf-8")
97
+
98
+
77
99
  def _wire_module_dep(pyproject_path: Path, pypi_name: str) -> None:
78
100
  """Add the module as an editable path dependency of the verify host."""
79
101
  text = pyproject_path.read_text(encoding="utf-8")
@@ -0,0 +1,84 @@
1
+ """Notice when ``smpy`` is not the CLI of the app it runs in (GH #929).
2
+
3
+ ``uv run smpy`` falls through to whatever ``smpy`` is on ``PATH`` once the
4
+ project venv lost ``simple_module_cli`` (a plain ``uv sync`` used to drop it).
5
+ That is often an older ``uv tool install``-ed copy, which then scaffolds modules
6
+ pinned to its own version inside a newer app, or fails with errors that make no
7
+ sense inside the project. Reading the app's pins is cheap and local.
8
+ """
9
+
10
+ from __future__ import annotations
11
+
12
+ import re
13
+ import sys
14
+ import tomllib
15
+ from collections.abc import Iterator
16
+ from pathlib import Path
17
+
18
+ import typer
19
+
20
+ from simple_module_cli.pins import PLACEHOLDER_VERSION
21
+
22
+ _FRAMEWORK_PIN = re.compile(r"^\s*simple[-_]module[-_][a-z0-9_-]+\s*==\s*([^\s;,\[]+)", re.I)
23
+
24
+ # Commands that legitimately run a CLI of another version than the app's:
25
+ # `new` makes an app, `update`/`package-update` change its pins.
26
+ _EXEMPT_COMMANDS = frozenset({"new", "update", "package-update"})
27
+
28
+
29
+ def _requirements(doc: dict) -> Iterator[str]:
30
+ project = doc.get("project", {})
31
+ yield from project.get("dependencies", [])
32
+ for extra in project.get("optional-dependencies", {}).values():
33
+ yield from extra
34
+ for group in doc.get("dependency-groups", {}).values():
35
+ yield from group
36
+
37
+
38
+ def _pinned_version(pyproject: Path) -> str | None:
39
+ try:
40
+ doc = tomllib.loads(pyproject.read_text(encoding="utf-8"))
41
+ except (OSError, tomllib.TOMLDecodeError):
42
+ return None
43
+ for requirement in _requirements(doc):
44
+ match = _FRAMEWORK_PIN.match(requirement) if isinstance(requirement, str) else None
45
+ if match:
46
+ return match.group(1)
47
+ return None
48
+
49
+
50
+ def app_framework_pin(start: Path) -> tuple[Path, str] | None:
51
+ """``(project root, version)`` of the nearest project pinning the framework with ``==``.
52
+
53
+ A ``smpy new`` app pins every ``simple_module_*`` package to one version, in
54
+ the root ``pyproject.toml`` and (workspace mode) ``host/pyproject.toml``.
55
+ Range requirements, such as this repository's own, are not pins.
56
+ """
57
+ current = start.resolve()
58
+ for candidate in (current, *current.parents):
59
+ for pyproject in (candidate / "pyproject.toml", candidate / "host" / "pyproject.toml"):
60
+ version = _pinned_version(pyproject) if pyproject.is_file() else None
61
+ if version is not None:
62
+ return candidate, version
63
+ return None
64
+
65
+
66
+ def running_cli() -> str:
67
+ """Where the running ``smpy`` lives, for messages."""
68
+ return str(Path(sys.argv[0]).resolve()) if sys.argv and sys.argv[0] else sys.executable
69
+
70
+
71
+ def warn_if_not_the_apps_cli(command: str | None, current: str, start: Path) -> None:
72
+ """One stderr warning when the project pins another framework version than this CLI's."""
73
+ if command in _EXEMPT_COMMANDS or current == PLACEHOLDER_VERSION:
74
+ return
75
+ found = app_framework_pin(start)
76
+ if found is None or found[1] == current:
77
+ return
78
+ root, pinned = found
79
+ typer.echo(
80
+ f"WARNING: this project ({root}) pins the framework to {pinned}, but this smpy is "
81
+ f"{current} ({running_cli()}).\n"
82
+ " Use the project's own CLI: `uv sync --all-packages`, then `uv run smpy ...`.",
83
+ err=True,
84
+ )
@@ -5,8 +5,10 @@ is resolved first (ls-remote + shallow clone + entry-point scan); the host
5
5
  pyproject is written only after resolution succeeds. A git spec without
6
6
  ``#subdirectory`` is scanned for module packages — one match is added
7
7
  directly, several go through ``--module``/``--all`` or an interactive
8
- picker. Then: ``uv sync`` → ``smpy host gen-pages`` → ``smpy host
9
- sync-js-deps`` → entry-point verification, unless ``--no-sync``.
8
+ picker. Unless ``--no-sync`` is set, run ``uv sync`` and verify entry points.
9
+ Before verification, a host with a ``client_app`` runs ``smpy host gen-pages``
10
+ and ``smpy host sync-js-deps``, followed by ``smpy host gen-i18n`` if the
11
+ i18n package is installed.
10
12
  """
11
13
 
12
14
  from __future__ import annotations
@@ -168,7 +170,7 @@ def add_module(
168
170
  ] = Path(),
169
171
  no_sync: Annotated[
170
172
  bool,
171
- typer.Option("--no-sync", help="Write pyproject only; skip uv sync / gen-pages."),
173
+ typer.Option("--no-sync", help="Write pyproject only; skip post-install steps."),
172
174
  ] = False,
173
175
  yes: Annotated[bool, typer.Option("--yes", "-y", help="Never prompt (fail instead).")] = False,
174
176
  ) -> None:
@@ -123,14 +123,6 @@ def create_app_project(
123
123
  # Generated secrets go to the gitignored .env, never the committed
124
124
  # .env.example (GH #441) — see write_local_env below.
125
125
  secret_keys = ["SM_SECRET_KEY"]
126
- if "users" in resolved:
127
- # UsersSettings refuses its placeholder token secrets when
128
- # SM_ENVIRONMENT=production — the mode the compose containers run
129
- # in — so generate real ones, same as SM_SECRET_KEY.
130
- secret_keys += [
131
- "SM_USERS_RESET_PASSWORD_TOKEN_SECRET",
132
- "SM_USERS_VERIFICATION_TOKEN_SECRET",
133
- ]
134
126
  db_name = to_snake_case(name)
135
127
  env_path = target / ".env.example"
136
128
  env_text = env_path.read_text(encoding="utf-8") if env_path.exists() else ""
simple_module_cli/cli.py CHANGED
@@ -14,15 +14,22 @@ group are mounted as named subgroups (e.g. ``smpy host gen-pages``).
14
14
 
15
15
  from __future__ import annotations
16
16
 
17
- import os
18
17
  from pathlib import Path
19
18
  from typing import Annotated
20
19
 
21
20
  import typer
22
21
 
22
+ from simple_module_cli import _add_install
23
+ from simple_module_cli._project_cli_check import (
24
+ app_framework_pin,
25
+ running_cli,
26
+ warn_if_not_the_apps_cli,
27
+ )
23
28
  from simple_module_cli.add_cmd import add_module, run_add
24
29
  from simple_module_cli.case import to_kebab_case
30
+ from simple_module_cli.dev_cmd import dev_command
25
31
  from simple_module_cli.docker_cmd import docker_app
32
+ from simple_module_cli.gen_cmd import gen_command
26
33
  from simple_module_cli.migrations_cmd import migrations_app
27
34
  from simple_module_cli.module_cmd import module_app
28
35
  from simple_module_cli.new import new_project
@@ -42,7 +49,15 @@ app = typer.Typer(
42
49
  add_completion=False,
43
50
  )
44
51
 
52
+
53
+ @app.callback()
54
+ def _check_project_cli(ctx: typer.Context) -> None:
55
+ warn_if_not_the_apps_cli(ctx.invoked_subcommand, resolve_framework_version(), Path.cwd())
56
+
57
+
45
58
  app.command("new")(new_project)
59
+ app.command("gen")(gen_command)
60
+ app.command("dev")(dev_command)
46
61
  app.command("add")(add_module)
47
62
  app.command("update")(update_modules)
48
63
  app.command("package-update")(package_update)
@@ -60,9 +75,16 @@ def doctor() -> None:
60
75
  from simple_module_core.__main__ import main as run_doctor
61
76
  except ImportError:
62
77
  # The CLI installs on its own (to scaffold); doctor needs a project's framework.
63
- typer.echo(
64
- "ERROR: smpy doctor needs simple_module_core; run it inside a project.", err=True
65
- )
78
+ if app_framework_pin(Path.cwd()) is None:
79
+ message = "smpy doctor needs simple_module_core; run it inside a project."
80
+ else:
81
+ # Inside an app, this is a global smpy outside the app's venv (GH #929).
82
+ message = (
83
+ f"this smpy ({running_cli()}) is not installed in this project's venv, "
84
+ "so it cannot see the app's modules. Run `uv sync --all-packages`, "
85
+ "then `uv run smpy doctor`."
86
+ )
87
+ typer.echo(f"ERROR: {message}", err=True)
66
88
  raise typer.Exit(1) from None
67
89
 
68
90
  raise typer.Exit(run_doctor())
@@ -126,34 +148,26 @@ def create_host(
126
148
  typer.echo(" python main.py")
127
149
 
128
150
 
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)."""
151
+ def _app_host(target: Path) -> Path | None:
152
+ """Host owning a newly scaffolded workspace member, or None outside an app."""
131
153
  root = find_workspace_root(target.parent)
132
154
  if root is None:
133
155
  return None
134
156
  host = root / "host"
135
157
  if not (host / "pyproject.toml").is_file() or not is_workspace_member(host, target):
136
158
  return None
137
- rel = os.path.relpath(target.resolve(), host.resolve())
138
- if not rel.startswith("."):
139
- rel = f"./{rel}" # parse_add_spec reads a bare "a/b" as a PyPI requirement
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}"
159
+ return host
143
160
 
144
161
 
145
- def _echo_app_next_steps(add_command: str, slug: str) -> None:
162
+ def _echo_app_next_steps(package: str) -> None:
146
163
  """The module lives in an app's workspace: wire it in with the app's own commands.
147
164
 
148
165
  Never ``uv sync`` inside the module: that syncs the module alone and
149
166
  uninstalls the rest of the app from the shared venv (GH #916).
150
167
  """
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}"')
168
+ typer.echo("\nNext step (from the app root): generate and review the migration, then apply it:")
169
+ typer.echo(f' uv run smpy migrations new {package} -m "init"')
155
170
  typer.echo(" make migrate")
156
- typer.echo(" make test")
157
171
  typer.echo("Then restart `make dev`: modules are discovered at start-up, not on reload.")
158
172
 
159
173
 
@@ -173,13 +187,16 @@ def create_module(
173
187
  "existing repo/host (nested workflows never run there).",
174
188
  ),
175
189
  ] = False,
190
+ with_settings: Annotated[
191
+ bool, typer.Option("--with-settings", help="Include DB-backed settings and services.")
192
+ ] = False,
176
193
  ) -> None:
177
194
  """Scaffold a publishable SimpleModule module package."""
178
195
  slug = to_kebab_case(name)
179
196
  package = slug.replace("-", "_")
180
197
  target = dest or Path.cwd() / f"simple_module_{package}"
181
198
  # An in-repo module (the documented modules/* layout) gets no .github/ and
182
- # keeps the workspace JS configs: nested workflows never run and publish.yml
199
+ # uses host-generated JS configs: nested workflows never run and publish.yml
183
200
  # is a PyPI footgun. --standalone forces the standalone layout for a module
184
201
  # that lives in its own repo. See GH #210.
185
202
  standalone_mode = standalone or not is_inside_existing_repo(target)
@@ -192,6 +209,7 @@ def create_module(
192
209
  name=name,
193
210
  framework_version=resolve_framework_version(),
194
211
  standalone=standalone_mode,
212
+ with_settings=with_settings,
195
213
  )
196
214
  except FileExistsError as exc:
197
215
  typer.echo(f"ERROR: {exc}", err=True)
@@ -203,22 +221,22 @@ def create_module(
203
221
  "Skipped .github/ workflows: this module is inside an existing repo, "
204
222
  "where nested workflows never run. Use --standalone to emit them."
205
223
  )
206
- add_command = _app_add_command(target)
207
- if add_command is not None:
208
- _echo_app_next_steps(add_command, slug)
224
+ host = _app_host(target)
225
+ if host is not None:
226
+ run_add(str(target.resolve()), pyproject=host / "pyproject.toml", no_sync=True)
227
+ _add_install.sync_project(host, _add_install._default_exec_runner)
228
+ _echo_app_next_steps(package)
209
229
  else:
210
230
  typer.echo("\nNext steps:")
211
231
  typer.echo(f" cd {target}")
212
232
  typer.echo(" uv sync --extra dev")
213
233
  typer.echo(" uv run pytest")
214
- typer.echo(" npm install")
215
- typer.echo(" npm run typecheck")
216
234
  typer.echo(" uv run smpy module verify")
217
- typer.echo(
218
- "\nThe pages ship sample API types (pages/api.generated.ts). Once the host serves "
219
- "the module, refresh them after any endpoint change:\n"
220
- f" uv run smpy openapi gen-types --module {package}"
221
- )
235
+ typer.echo(
236
+ "\nThe pages ship sample API types (pages/api.generated.ts). Once the host serves "
237
+ "the module, refresh them after any endpoint change:\n"
238
+ f" uv run smpy openapi gen-types --module {package}"
239
+ )
222
240
 
223
241
 
224
242
  discover_and_mount(app)