simple-module-cli 0.0.49__py3-none-any.whl → 0.0.51__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- simple_module_cli/cli.py +24 -20
- simple_module_cli/commands/__init__.py +1 -0
- simple_module_cli/commands/_new_setup.py +168 -0
- simple_module_cli/commands/add_cli.py +109 -0
- simple_module_cli/{add_cmd.py → commands/add_cmd.py} +19 -6
- simple_module_cli/{dev_cmd.py → commands/dev_cmd.py} +3 -3
- simple_module_cli/{docker_cmd.py → commands/docker_cmd.py} +1 -1
- simple_module_cli/commands/fix_imports_cmd.py +83 -0
- simple_module_cli/{gen_cmd.py → commands/gen_cmd.py} +42 -31
- simple_module_cli/{migrations_cmd.py → commands/migrations_cmd.py} +3 -3
- simple_module_cli/{module_cmd.py → commands/module_cmd.py} +2 -2
- simple_module_cli/commands/new.py +217 -0
- simple_module_cli/commands/openapi_cmd.py +197 -0
- simple_module_cli/{update_cmd.py → commands/update_cmd.py} +9 -4
- simple_module_cli/migrations/__init__.py +1 -0
- simple_module_cli/{_migration_support.py → migrations/_migration_support.py} +4 -1
- simple_module_cli/scaffold/__init__.py +1 -0
- simple_module_cli/{_app_project_manifests.py → scaffold/_app_project_manifests.py} +4 -3
- simple_module_cli/{_lint_tooling.py → scaffold/_lint_tooling.py} +1 -1
- simple_module_cli/{_local_env.py → scaffold/_local_env.py} +1 -1
- simple_module_cli/{_templating.py → scaffold/_templating.py} +1 -1
- simple_module_cli/{app_project.py → scaffold/app_project.py} +22 -9
- simple_module_cli/scaffold/cli_assets.py +272 -0
- simple_module_cli/{docker_assets.py → scaffold/docker_assets.py} +2 -2
- simple_module_cli/{recipes.py → scaffold/recipes.py} +2 -2
- simple_module_cli/{scaffolding.py → scaffold/scaffolding.py} +7 -7
- simple_module_cli/{wizard.py → scaffold/wizard.py} +1 -1
- simple_module_cli/skills/simple-module-cli/SKILL.md +28 -7
- simple_module_cli/skills/simple-module-conventions/SKILL.md +31 -9
- simple_module_cli/skills/simple-module-creating/SKILL.md +3 -3
- simple_module_cli/skills/simple-module-database/SKILL.md +3 -3
- simple_module_cli/skills/simple-module-doctor/SKILL.md +17 -6
- simple_module_cli/skills/simple-module-inertia-pages/SKILL.md +4 -4
- simple_module_cli/skills/simple-module-locales/SKILL.md +2 -2
- simple_module_cli/skills/simple-module-migrations/SKILL.md +10 -5
- simple_module_cli/skills/simple-module-page-perf/SKILL.md +1 -1
- simple_module_cli/skills/simple-module-registries/SKILL.md +11 -11
- simple_module_cli/skills/simple-module-testing/SKILL.md +1 -1
- simple_module_cli/sources/__init__.py +1 -0
- simple_module_cli/{_add_install.py → sources/_add_install.py} +7 -5
- simple_module_cli/{_add_sources.py → sources/_add_sources.py} +4 -4
- simple_module_cli/{_project_cli_check.py → sources/_project_cli_check.py} +3 -3
- simple_module_cli/{_version_check.py → sources/_version_check.py} +2 -2
- simple_module_cli/{catalog.py → sources/catalog.py} +18 -5
- simple_module_cli/{git_source.py → sources/git_source.py} +6 -1
- simple_module_cli/{git_versions.py → sources/git_versions.py} +2 -2
- simple_module_cli/{pins.py → sources/pins.py} +2 -1
- simple_module_cli/{pypi.py → sources/pypi.py} +2 -2
- simple_module_cli/{pyproject_edit.py → sources/pyproject_edit.py} +2 -2
- simple_module_cli/{requirements.py → sources/requirements.py} +1 -1
- simple_module_cli/templates/cli/Makefile.snippet.tpl +17 -0
- simple_module_cli/templates/cli/README.md.tpl +37 -0
- simple_module_cli/templates/cli/ci.yml.tpl +26 -0
- simple_module_cli/templates/cli/defaults.toml +2 -0
- simple_module_cli/templates/cli/init.py.tpl +35 -0
- simple_module_cli/templates/cli/openapi.json.tpl +8 -0
- simple_module_cli/templates/cli/pyproject.toml.tpl +17 -0
- simple_module_cli/templates/cli/release-cli.yml.tpl +35 -0
- simple_module_cli/templates/docker/host-flat.Dockerfile +1 -0
- simple_module_cli/templates/docker/host.Dockerfile +1 -0
- simple_module_cli/templates/host/Makefile +3 -2
- simple_module_cli/templates/host/README.md.tpl +2 -2
- simple_module_cli/templates/host/client_app/package.json.tpl +1 -1
- simple_module_cli/templates/host/client_app/pages/Landing.tsx +1 -1
- simple_module_cli/templates/host/client_app/tsconfig.json +4 -1
- simple_module_cli/templates/host/client_app/vite.config.ts +1 -0
- simple_module_cli/templates/host/main.py.tpl +16 -0
- simple_module_cli/templates/host/migrations/env.py +1 -1
- simple_module_cli/templates/host/pyproject.toml.tpl +1 -0
- simple_module_cli/templates/host/routes.py +1 -1
- simple_module_cli/templates/module/__PACKAGE__/core/constants.py.tpl +1 -1
- simple_module_cli/templates/module/__PACKAGE__/models.py.tpl +2 -2
- simple_module_cli/templates/module/__PACKAGE__/module.py.tpl +2 -2
- simple_module_cli/templates/module/__PACKAGE__/pages/i18n.generated.ts.tpl +1 -1
- simple_module_cli/templates/module/__PACKAGE__/web/deps.py.tpl +1 -1
- simple_module_cli/templates/module/__PACKAGE__/web/endpoints/api.py.tpl +1 -1
- simple_module_cli/templates/module/__PACKAGE__/web/endpoints/views.py.tpl +16 -4
- simple_module_cli/templates/module/_optional/settings/__PACKAGE__/core/settings.py.tpl +1 -1
- simple_module_cli/templates/workspace/Makefile +3 -2
- simple_module_cli/templates/workspace/README.md.tpl +2 -2
- simple_module_cli/templates/workspace/pyproject.toml.tpl +1 -0
- simple_module_cli/tooling/__init__.py +1 -0
- simple_module_cli/{_module_build.py → tooling/_module_build.py} +2 -2
- simple_module_cli/{_module_host.py → tooling/_module_host.py} +1 -1
- simple_module_cli/updates/__init__.py +1 -0
- simple_module_cli/updates/_import_scope.py +252 -0
- simple_module_cli/updates/import_codemod.py +206 -0
- simple_module_cli/updates/import_renames.json +577 -0
- simple_module_cli/{package_update.py → updates/package_update.py} +6 -49
- simple_module_cli/{package_update_deps.py → updates/package_update_deps.py} +4 -4
- simple_module_cli/{package_update_git.py → updates/package_update_git.py} +12 -3
- simple_module_cli/{package_update_npm.py → updates/package_update_npm.py} +2 -2
- simple_module_cli-0.0.51.data/data/simple_module_cli/templates/cli/Makefile.snippet.tpl +17 -0
- simple_module_cli-0.0.51.data/data/simple_module_cli/templates/cli/README.md.tpl +37 -0
- simple_module_cli-0.0.51.data/data/simple_module_cli/templates/cli/ci.yml.tpl +26 -0
- simple_module_cli-0.0.51.data/data/simple_module_cli/templates/cli/defaults.toml +2 -0
- simple_module_cli-0.0.51.data/data/simple_module_cli/templates/cli/init.py.tpl +35 -0
- simple_module_cli-0.0.51.data/data/simple_module_cli/templates/cli/openapi.json.tpl +8 -0
- simple_module_cli-0.0.51.data/data/simple_module_cli/templates/cli/pyproject.toml.tpl +17 -0
- simple_module_cli-0.0.51.data/data/simple_module_cli/templates/cli/release-cli.yml.tpl +35 -0
- {simple_module_cli-0.0.49.data → simple_module_cli-0.0.51.data}/data/simple_module_cli/templates/docker/host-flat.Dockerfile +1 -0
- {simple_module_cli-0.0.49.data → simple_module_cli-0.0.51.data}/data/simple_module_cli/templates/docker/host.Dockerfile +1 -0
- {simple_module_cli-0.0.49.data → simple_module_cli-0.0.51.data}/data/simple_module_cli/templates/host/Makefile +3 -2
- {simple_module_cli-0.0.49.data → simple_module_cli-0.0.51.data}/data/simple_module_cli/templates/host/README.md.tpl +2 -2
- {simple_module_cli-0.0.49.data → simple_module_cli-0.0.51.data}/data/simple_module_cli/templates/host/client_app/package.json.tpl +1 -1
- {simple_module_cli-0.0.49.data → simple_module_cli-0.0.51.data}/data/simple_module_cli/templates/host/client_app/pages/Landing.tsx +1 -1
- {simple_module_cli-0.0.49.data → simple_module_cli-0.0.51.data}/data/simple_module_cli/templates/host/client_app/tsconfig.json +4 -1
- {simple_module_cli-0.0.49.data → simple_module_cli-0.0.51.data}/data/simple_module_cli/templates/host/client_app/vite.config.ts +1 -0
- simple_module_cli-0.0.51.data/data/simple_module_cli/templates/host/main.py.tpl +16 -0
- {simple_module_cli-0.0.49.data → simple_module_cli-0.0.51.data}/data/simple_module_cli/templates/host/migrations/env.py +1 -1
- {simple_module_cli-0.0.49.data → simple_module_cli-0.0.51.data}/data/simple_module_cli/templates/host/pyproject.toml.tpl +1 -0
- {simple_module_cli-0.0.49.data → simple_module_cli-0.0.51.data}/data/simple_module_cli/templates/host/routes.py +1 -1
- {simple_module_cli-0.0.49.data → simple_module_cli-0.0.51.data}/data/simple_module_cli/templates/module/__PACKAGE__/core/constants.py.tpl +1 -1
- {simple_module_cli-0.0.49.data → simple_module_cli-0.0.51.data}/data/simple_module_cli/templates/module/__PACKAGE__/models.py.tpl +2 -2
- {simple_module_cli-0.0.49.data → simple_module_cli-0.0.51.data}/data/simple_module_cli/templates/module/__PACKAGE__/module.py.tpl +2 -2
- {simple_module_cli-0.0.49.data → simple_module_cli-0.0.51.data}/data/simple_module_cli/templates/module/__PACKAGE__/pages/i18n.generated.ts.tpl +1 -1
- {simple_module_cli-0.0.49.data → simple_module_cli-0.0.51.data}/data/simple_module_cli/templates/module/__PACKAGE__/web/deps.py.tpl +1 -1
- {simple_module_cli-0.0.49.data → simple_module_cli-0.0.51.data}/data/simple_module_cli/templates/module/__PACKAGE__/web/endpoints/api.py.tpl +1 -1
- {simple_module_cli-0.0.49.data → simple_module_cli-0.0.51.data}/data/simple_module_cli/templates/module/__PACKAGE__/web/endpoints/views.py.tpl +16 -4
- {simple_module_cli-0.0.49.data → simple_module_cli-0.0.51.data}/data/simple_module_cli/templates/module/_optional/settings/__PACKAGE__/core/settings.py.tpl +1 -1
- {simple_module_cli-0.0.49.data → simple_module_cli-0.0.51.data}/data/simple_module_cli/templates/workspace/Makefile +3 -2
- {simple_module_cli-0.0.49.data → simple_module_cli-0.0.51.data}/data/simple_module_cli/templates/workspace/README.md.tpl +2 -2
- {simple_module_cli-0.0.49.data → simple_module_cli-0.0.51.data}/data/simple_module_cli/templates/workspace/pyproject.toml.tpl +1 -0
- {simple_module_cli-0.0.49.dist-info → simple_module_cli-0.0.51.dist-info}/METADATA +2 -2
- simple_module_cli-0.0.51.dist-info/RECORD +254 -0
- simple_module_cli/new.py +0 -285
- simple_module_cli/openapi_cmd.py +0 -103
- simple_module_cli/templates/host/main.py +0 -10
- simple_module_cli-0.0.49.data/data/simple_module_cli/templates/host/main.py +0 -10
- simple_module_cli-0.0.49.dist-info/RECORD +0 -225
- /simple_module_cli/{plugins.py → commands/plugins.py} +0 -0
- /simple_module_cli/{skills_cmd.py → commands/skills_cmd.py} +0 -0
- /simple_module_cli/{_env.py → scaffold/_env.py} +0 -0
- /simple_module_cli/{case.py → scaffold/case.py} +0 -0
- /simple_module_cli/{framework_repo.py → scaffold/framework_repo.py} +0 -0
- /simple_module_cli/{uv_workspace.py → sources/uv_workspace.py} +0 -0
- /simple_module_cli/{_generation_cache.py → tooling/_generation_cache.py} +0 -0
- /simple_module_cli/{openapi_types.py → tooling/openapi_types.py} +0 -0
- {simple_module_cli-0.0.49.data → simple_module_cli-0.0.51.data}/data/simple_module_cli/templates/docker/Makefile.snippet +0 -0
- {simple_module_cli-0.0.49.data → simple_module_cli-0.0.51.data}/data/simple_module_cli/templates/docker/compose-base-postgres.yml.tpl +0 -0
- {simple_module_cli-0.0.49.data → simple_module_cli-0.0.51.data}/data/simple_module_cli/templates/docker/compose-base-sqlite.yml.tpl +0 -0
- {simple_module_cli-0.0.49.data → simple_module_cli-0.0.51.data}/data/simple_module_cli/templates/docker/compose-tasks-postgres.yml.tpl +0 -0
- {simple_module_cli-0.0.49.data → simple_module_cli-0.0.51.data}/data/simple_module_cli/templates/docker/compose-tasks-sqlite.yml.tpl +0 -0
- {simple_module_cli-0.0.49.data → simple_module_cli-0.0.51.data}/data/simple_module_cli/templates/docker/compose-worker.yml.tpl +0 -0
- {simple_module_cli-0.0.49.data → simple_module_cli-0.0.51.data}/data/simple_module_cli/templates/docker/dockerignore +0 -0
- {simple_module_cli-0.0.49.data → simple_module_cli-0.0.51.data}/data/simple_module_cli/templates/docker/worker.Dockerfile.tpl +0 -0
- {simple_module_cli-0.0.49.data → simple_module_cli-0.0.51.data}/data/simple_module_cli/templates/host/.env.example +0 -0
- {simple_module_cli-0.0.49.data → simple_module_cli-0.0.51.data}/data/simple_module_cli/templates/host/.gitignore +0 -0
- {simple_module_cli-0.0.49.data → simple_module_cli-0.0.51.data}/data/simple_module_cli/templates/host/_optional/background_tasks/Makefile.snippet +0 -0
- {simple_module_cli-0.0.49.data → simple_module_cli-0.0.51.data}/data/simple_module_cli/templates/host/_optional/background_tasks/run_worker.py +0 -0
- {simple_module_cli-0.0.49.data → simple_module_cli-0.0.51.data}/data/simple_module_cli/templates/host/alembic.ini +0 -0
- {simple_module_cli-0.0.49.data → simple_module_cli-0.0.51.data}/data/simple_module_cli/templates/host/client_app/app.tsx +0 -0
- {simple_module_cli-0.0.49.data → simple_module_cli-0.0.51.data}/data/simple_module_cli/templates/host/client_app/main.tsx +0 -0
- {simple_module_cli-0.0.49.data → simple_module_cli-0.0.51.data}/data/simple_module_cli/templates/host/client_app/module-assets.ts +0 -0
- {simple_module_cli-0.0.49.data → simple_module_cli-0.0.51.data}/data/simple_module_cli/templates/host/client_app/pages/Error.tsx +0 -0
- {simple_module_cli-0.0.49.data → simple_module_cli-0.0.51.data}/data/simple_module_cli/templates/host/client_app/pages.ts +0 -0
- {simple_module_cli-0.0.49.data → simple_module_cli-0.0.51.data}/data/simple_module_cli/templates/host/client_app/styles.css +0 -0
- {simple_module_cli-0.0.49.data → simple_module_cli-0.0.51.data}/data/simple_module_cli/templates/host/client_app/vite.dev-url.ts +0 -0
- {simple_module_cli-0.0.49.data → simple_module_cli-0.0.51.data}/data/simple_module_cli/templates/host/client_app/vite.i18n.ts +0 -0
- {simple_module_cli-0.0.49.data → simple_module_cli-0.0.51.data}/data/simple_module_cli/templates/host/migrations/script.py.mako +0 -0
- {simple_module_cli-0.0.49.data → simple_module_cli-0.0.51.data}/data/simple_module_cli/templates/host/migrations/versions/.gitkeep +0 -0
- {simple_module_cli-0.0.49.data → simple_module_cli-0.0.51.data}/data/simple_module_cli/templates/host/templates/index.html +0 -0
- {simple_module_cli-0.0.49.data → simple_module_cli-0.0.51.data}/data/simple_module_cli/templates/module/.github/workflows/ci.yml +0 -0
- {simple_module_cli-0.0.49.data → simple_module_cli-0.0.51.data}/data/simple_module_cli/templates/module/.github/workflows/publish.yml.tpl +0 -0
- {simple_module_cli-0.0.49.data → simple_module_cli-0.0.51.data}/data/simple_module_cli/templates/module/.gitignore +0 -0
- {simple_module_cli-0.0.49.data → simple_module_cli-0.0.51.data}/data/simple_module_cli/templates/module/README.md.tpl +0 -0
- {simple_module_cli-0.0.49.data → simple_module_cli-0.0.51.data}/data/simple_module_cli/templates/module/__PACKAGE__/__init__.py +0 -0
- {simple_module_cli-0.0.49.data → simple_module_cli-0.0.51.data}/data/simple_module_cli/templates/module/__PACKAGE__/contracts/__init__.py.tpl +0 -0
- {simple_module_cli-0.0.49.data → simple_module_cli-0.0.51.data}/data/simple_module_cli/templates/module/__PACKAGE__/contracts/schemas.py.tpl +0 -0
- {simple_module_cli-0.0.49.data → simple_module_cli-0.0.51.data}/data/simple_module_cli/templates/module/__PACKAGE__/core/__init__.py +0 -0
- {simple_module_cli-0.0.49.data → simple_module_cli-0.0.51.data}/data/simple_module_cli/templates/module/__PACKAGE__/locales/en.json.tpl +0 -0
- {simple_module_cli-0.0.49.data → simple_module_cli-0.0.51.data}/data/simple_module_cli/templates/module/__PACKAGE__/pages/Browse.tsx.tpl +0 -0
- {simple_module_cli-0.0.49.data → simple_module_cli-0.0.51.data}/data/simple_module_cli/templates/module/__PACKAGE__/pages/Create.tsx.tpl +0 -0
- {simple_module_cli-0.0.49.data → simple_module_cli-0.0.51.data}/data/simple_module_cli/templates/module/__PACKAGE__/pages/Edit.tsx.tpl +0 -0
- {simple_module_cli-0.0.49.data → simple_module_cli-0.0.51.data}/data/simple_module_cli/templates/module/__PACKAGE__/pages/api.generated.ts.tpl +0 -0
- {simple_module_cli-0.0.49.data → simple_module_cli-0.0.51.data}/data/simple_module_cli/templates/module/__PACKAGE__/py.typed +0 -0
- {simple_module_cli-0.0.49.data → simple_module_cli-0.0.51.data}/data/simple_module_cli/templates/module/__PACKAGE__/web/__init__.py +0 -0
- {simple_module_cli-0.0.49.data → simple_module_cli-0.0.51.data}/data/simple_module_cli/templates/module/__PACKAGE__/web/endpoints/__init__.py +0 -0
- {simple_module_cli-0.0.49.data → simple_module_cli-0.0.51.data}/data/simple_module_cli/templates/module/__PACKAGE__/web/service.py.tpl +0 -0
- {simple_module_cli-0.0.49.data → simple_module_cli-0.0.51.data}/data/simple_module_cli/templates/module/_optional/framework_repo/LICENSE +0 -0
- {simple_module_cli-0.0.49.data → simple_module_cli-0.0.51.data}/data/simple_module_cli/templates/module/_optional/framework_repo/README.md.tpl +0 -0
- {simple_module_cli-0.0.49.data → simple_module_cli-0.0.51.data}/data/simple_module_cli/templates/module/_optional/framework_repo/pyproject.toml.tpl +0 -0
- {simple_module_cli-0.0.49.data → simple_module_cli-0.0.51.data}/data/simple_module_cli/templates/module/_optional/settings/__PACKAGE__/core/services.py.tpl +0 -0
- {simple_module_cli-0.0.49.data → simple_module_cli-0.0.51.data}/data/simple_module_cli/templates/module/_optional/settings-hook.py.tpl +0 -0
- {simple_module_cli-0.0.49.data → simple_module_cli-0.0.51.data}/data/simple_module_cli/templates/module/pyproject.toml.tpl +0 -0
- {simple_module_cli-0.0.49.data → simple_module_cli-0.0.51.data}/data/simple_module_cli/templates/module/tests/conftest.py +0 -0
- {simple_module_cli-0.0.49.data → simple_module_cli-0.0.51.data}/data/simple_module_cli/templates/module/tests/core/contracts/test___PACKAGE___schemas.py.tpl +0 -0
- {simple_module_cli-0.0.49.data → simple_module_cli-0.0.51.data}/data/simple_module_cli/templates/module/tests/core/module/test___PACKAGE___module.py.tpl +0 -0
- {simple_module_cli-0.0.49.data → simple_module_cli-0.0.51.data}/data/simple_module_cli/templates/module/tests/web/crud/test___PACKAGE___crud.py.tpl +0 -0
- {simple_module_cli-0.0.49.data → simple_module_cli-0.0.51.data}/data/simple_module_cli/templates/workspace/.env.example +0 -0
- {simple_module_cli-0.0.49.data → simple_module_cli-0.0.51.data}/data/simple_module_cli/templates/workspace/.gitignore +0 -0
- {simple_module_cli-0.0.49.data → simple_module_cli-0.0.51.data}/data/simple_module_cli/templates/workspace/package.json.tpl +0 -0
- {simple_module_cli-0.0.49.dist-info → simple_module_cli-0.0.51.dist-info}/WHEEL +0 -0
- {simple_module_cli-0.0.49.dist-info → simple_module_cli-0.0.51.dist-info}/entry_points.txt +0 -0
- {simple_module_cli-0.0.49.dist-info → simple_module_cli-0.0.51.dist-info}/licenses/LICENSE +0 -0
simple_module_cli/cli.py
CHANGED
|
@@ -4,6 +4,7 @@ Built-in commands:
|
|
|
4
4
|
smpy new
|
|
5
5
|
smpy add
|
|
6
6
|
smpy update
|
|
7
|
+
smpy fix-imports
|
|
7
8
|
smpy create-host
|
|
8
9
|
smpy create-module
|
|
9
10
|
smpy skills add / list / update
|
|
@@ -19,29 +20,32 @@ from typing import Annotated
|
|
|
19
20
|
|
|
20
21
|
import typer
|
|
21
22
|
|
|
22
|
-
from simple_module_cli import
|
|
23
|
-
from simple_module_cli.
|
|
23
|
+
from simple_module_cli.commands.add_cmd import add_module, run_add
|
|
24
|
+
from simple_module_cli.commands.dev_cmd import dev_command
|
|
25
|
+
from simple_module_cli.commands.docker_cmd import docker_app
|
|
26
|
+
from simple_module_cli.commands.fix_imports_cmd import fix_imports
|
|
27
|
+
from simple_module_cli.commands.gen_cmd import gen_command
|
|
28
|
+
from simple_module_cli.commands.migrations_cmd import migrations_app
|
|
29
|
+
from simple_module_cli.commands.module_cmd import module_app
|
|
30
|
+
from simple_module_cli.commands.new import new_project
|
|
31
|
+
from simple_module_cli.commands.openapi_cmd import openapi_app
|
|
32
|
+
from simple_module_cli.commands.plugins import discover_and_mount
|
|
33
|
+
from simple_module_cli.commands.skills_cmd import app as skills_app
|
|
34
|
+
from simple_module_cli.commands.update_cmd import update_modules
|
|
35
|
+
from simple_module_cli.scaffold.case import to_kebab_case
|
|
36
|
+
from simple_module_cli.scaffold.scaffolding import create_host as _create_host
|
|
37
|
+
from simple_module_cli.scaffold.scaffolding import create_module as _create_module
|
|
38
|
+
from simple_module_cli.scaffold.scaffolding import (
|
|
39
|
+
is_inside_existing_repo,
|
|
40
|
+
resolve_framework_version,
|
|
41
|
+
)
|
|
42
|
+
from simple_module_cli.sources import _add_install
|
|
43
|
+
from simple_module_cli.sources._project_cli_check import (
|
|
24
44
|
app_framework_pin,
|
|
25
45
|
running_cli,
|
|
26
46
|
warn_if_not_the_apps_cli,
|
|
27
47
|
)
|
|
28
|
-
from simple_module_cli.
|
|
29
|
-
from simple_module_cli.case import to_kebab_case
|
|
30
|
-
from simple_module_cli.dev_cmd import dev_command
|
|
31
|
-
from simple_module_cli.docker_cmd import docker_app
|
|
32
|
-
from simple_module_cli.gen_cmd import gen_command
|
|
33
|
-
from simple_module_cli.migrations_cmd import migrations_app
|
|
34
|
-
from simple_module_cli.module_cmd import module_app
|
|
35
|
-
from simple_module_cli.new import new_project
|
|
36
|
-
from simple_module_cli.openapi_cmd import openapi_app
|
|
37
|
-
from simple_module_cli.package_update import package_update
|
|
38
|
-
from simple_module_cli.plugins import discover_and_mount
|
|
39
|
-
from simple_module_cli.scaffolding import create_host as _create_host
|
|
40
|
-
from simple_module_cli.scaffolding import create_module as _create_module
|
|
41
|
-
from simple_module_cli.scaffolding import is_inside_existing_repo, resolve_framework_version
|
|
42
|
-
from simple_module_cli.skills_cmd import app as skills_app
|
|
43
|
-
from simple_module_cli.update_cmd import update_modules
|
|
44
|
-
from simple_module_cli.uv_workspace import find_workspace_root, is_workspace_member
|
|
48
|
+
from simple_module_cli.sources.uv_workspace import find_workspace_root, is_workspace_member
|
|
45
49
|
|
|
46
50
|
app = typer.Typer(
|
|
47
51
|
help="SimpleModule developer CLI.",
|
|
@@ -60,7 +64,7 @@ app.command("gen")(gen_command)
|
|
|
60
64
|
app.command("dev")(dev_command)
|
|
61
65
|
app.command("add")(add_module)
|
|
62
66
|
app.command("update")(update_modules)
|
|
63
|
-
app.command("
|
|
67
|
+
app.command("fix-imports")(fix_imports)
|
|
64
68
|
app.add_typer(docker_app, name="docker")
|
|
65
69
|
app.add_typer(skills_app, name="skills")
|
|
66
70
|
app.add_typer(module_app, name="module")
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""CLI commands area."""
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
"""Post-scaffold installation and migration helpers for ``smpy new``."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import shutil
|
|
6
|
+
import subprocess
|
|
7
|
+
from collections.abc import Callable, Sequence
|
|
8
|
+
from pathlib import Path
|
|
9
|
+
from typing import Any
|
|
10
|
+
|
|
11
|
+
import typer
|
|
12
|
+
|
|
13
|
+
from simple_module_cli.migrations._migration_support import NO_ALEMBIC_CONFIG, resolve_alembic_ini
|
|
14
|
+
|
|
15
|
+
__all__ = [
|
|
16
|
+
"alembic_argv",
|
|
17
|
+
"bootstrap_initial_migration",
|
|
18
|
+
"echo_next_steps",
|
|
19
|
+
"run_post_scaffold_install",
|
|
20
|
+
]
|
|
21
|
+
|
|
22
|
+
_ALEMBIC = ("uv", "run", "alembic")
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def alembic_argv(target: Path, host_dir: Path) -> list[str]:
|
|
26
|
+
"""Alembic argv to run **from the project root** (``target``)."""
|
|
27
|
+
ini = resolve_alembic_ini(target)
|
|
28
|
+
if ini is None:
|
|
29
|
+
raise typer.BadParameter(NO_ALEMBIC_CONFIG)
|
|
30
|
+
alembic = _ALEMBIC if host_dir == target else ("uv", "run", "--project", "host", "alembic")
|
|
31
|
+
return [*alembic, "-c", str(ini.relative_to(target))]
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def _run_quietly(
|
|
35
|
+
cmd: list[str],
|
|
36
|
+
cwd: Path,
|
|
37
|
+
*,
|
|
38
|
+
report: bool = True,
|
|
39
|
+
run_proc: Callable[..., Any] = subprocess.run,
|
|
40
|
+
) -> bool:
|
|
41
|
+
"""Run a setup step, showing its output only when it fails (GH #917)."""
|
|
42
|
+
try:
|
|
43
|
+
result = run_proc(
|
|
44
|
+
cmd, cwd=cwd, check=False, capture_output=True, text=True, errors="replace"
|
|
45
|
+
)
|
|
46
|
+
except OSError as exc:
|
|
47
|
+
if report:
|
|
48
|
+
typer.echo(
|
|
49
|
+
f"WARNING: {' '.join(cmd)} could not run ({exc}); finish setup manually.", err=True
|
|
50
|
+
)
|
|
51
|
+
return False
|
|
52
|
+
if result.returncode == 0:
|
|
53
|
+
return True
|
|
54
|
+
if not report:
|
|
55
|
+
return False
|
|
56
|
+
typer.echo(f"{result.stdout}{result.stderr}", err=True)
|
|
57
|
+
typer.echo(
|
|
58
|
+
f"WARNING: {' '.join(cmd)} failed (exit {result.returncode}); finish setup manually.",
|
|
59
|
+
err=True,
|
|
60
|
+
)
|
|
61
|
+
return False
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
def _sync_retrying_with_refresh(
|
|
65
|
+
cmd: list[str], cwd: Path, *, run_proc: Callable[..., Any] = subprocess.run
|
|
66
|
+
) -> bool:
|
|
67
|
+
"""``uv sync``, retried once with ``--refresh`` when it fails (GH #932)."""
|
|
68
|
+
if _run_quietly(cmd, cwd, report=False, run_proc=run_proc):
|
|
69
|
+
return True
|
|
70
|
+
typer.echo("uv's cached PyPI index may predate this release; retrying with --refresh...")
|
|
71
|
+
return _run_quietly([*cmd, "--refresh"], cwd, run_proc=run_proc)
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
def bootstrap_initial_migration(
|
|
75
|
+
target: Path,
|
|
76
|
+
host_dir: Path,
|
|
77
|
+
alembic: list[str],
|
|
78
|
+
*,
|
|
79
|
+
run_proc: Callable[..., Any] = subprocess.run,
|
|
80
|
+
) -> bool:
|
|
81
|
+
"""Autogenerate the baseline migration if the scaffold ships none."""
|
|
82
|
+
versions_dir = host_dir / "migrations" / "versions"
|
|
83
|
+
if any(p.name != "__init__.py" for p in versions_dir.glob("*.py")):
|
|
84
|
+
return True
|
|
85
|
+
rev = [*alembic, "revision", "--autogenerate", "-m", "initial schema"]
|
|
86
|
+
return _run_quietly([*rev, "--branch-label", "initial"], target, run_proc=run_proc)
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
def echo_next_steps(
|
|
90
|
+
target: Path,
|
|
91
|
+
setup: list[str],
|
|
92
|
+
resolved: Sequence[str],
|
|
93
|
+
*,
|
|
94
|
+
cli_name: str | None = None,
|
|
95
|
+
flat: bool = False,
|
|
96
|
+
) -> None:
|
|
97
|
+
typer.echo("\nNext steps:")
|
|
98
|
+
typer.echo(f" cd {target}")
|
|
99
|
+
for step in [*setup, "make dev"]:
|
|
100
|
+
typer.echo(f" {step}")
|
|
101
|
+
typer.echo(" make docker-up # or run the full stack in containers")
|
|
102
|
+
if "background_tasks" in resolved:
|
|
103
|
+
typer.echo(" docker compose up -d redis worker beat # background jobs")
|
|
104
|
+
if cli_name:
|
|
105
|
+
run_cmd = f"uv run --project cli {cli_name} --help" if flat else f"uv run {cli_name} --help"
|
|
106
|
+
typer.echo(f" {run_cmd} # project CLI (refresh with `make cli-schema`)")
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
def run_post_scaffold_install(
|
|
110
|
+
target: Path,
|
|
111
|
+
host_dir: Path,
|
|
112
|
+
*,
|
|
113
|
+
flat: bool,
|
|
114
|
+
resolved: Sequence[str],
|
|
115
|
+
cli_name: str | None = None,
|
|
116
|
+
cli_package: str | None = None,
|
|
117
|
+
which: Callable[[str], str | None] = shutil.which,
|
|
118
|
+
run_proc: Callable[..., Any] = subprocess.run,
|
|
119
|
+
) -> None:
|
|
120
|
+
manual_setup = [
|
|
121
|
+
"make install",
|
|
122
|
+
'uv run smpy migrations new initial -m "initial schema"',
|
|
123
|
+
"make migrate",
|
|
124
|
+
]
|
|
125
|
+
typer.echo("\nInstalling dependencies...")
|
|
126
|
+
uv_sync = ["uv", "sync"] if flat else ["uv", "sync", "--all-packages"]
|
|
127
|
+
for cmd in (uv_sync, ["npm", "install"]):
|
|
128
|
+
if which(cmd[0]) is None:
|
|
129
|
+
typer.echo(
|
|
130
|
+
f"WARNING: '{cmd[0]}' not found on PATH; skipping `{' '.join(cmd)}`. "
|
|
131
|
+
"Install it and finish setup manually.",
|
|
132
|
+
err=True,
|
|
133
|
+
)
|
|
134
|
+
echo_next_steps(target, manual_setup, resolved, cli_name=cli_name, flat=flat)
|
|
135
|
+
return
|
|
136
|
+
ok = (
|
|
137
|
+
_sync_retrying_with_refresh(cmd, target, run_proc=run_proc)
|
|
138
|
+
if cmd is uv_sync
|
|
139
|
+
else _run_quietly(cmd, target, run_proc=run_proc)
|
|
140
|
+
)
|
|
141
|
+
if not ok:
|
|
142
|
+
echo_next_steps(target, manual_setup, resolved, cli_name=cli_name, flat=flat)
|
|
143
|
+
if cmd is uv_sync:
|
|
144
|
+
typer.echo(
|
|
145
|
+
f"`{' '.join(cmd)}` was already retried with --refresh. If uv still cannot "
|
|
146
|
+
"find this release's packages, PyPI may not list them yet: wait a few "
|
|
147
|
+
"minutes, then run `make install`."
|
|
148
|
+
)
|
|
149
|
+
return
|
|
150
|
+
|
|
151
|
+
alembic = alembic_argv(target, host_dir)
|
|
152
|
+
typer.echo("Creating the database...")
|
|
153
|
+
if not bootstrap_initial_migration(target, host_dir, alembic, run_proc=run_proc):
|
|
154
|
+
echo_next_steps(target, manual_setup[1:], resolved, cli_name=cli_name, flat=flat)
|
|
155
|
+
return
|
|
156
|
+
if not _run_quietly([*alembic, "upgrade", "heads"], target, run_proc=run_proc):
|
|
157
|
+
echo_next_steps(target, manual_setup[2:], resolved, cli_name=cli_name, flat=flat)
|
|
158
|
+
return
|
|
159
|
+
if cli_package:
|
|
160
|
+
app_factory = "main:create_app" if flat else "host.main:create_app"
|
|
161
|
+
schema_out = f"cli/{cli_package}/openapi.json"
|
|
162
|
+
_run_quietly(
|
|
163
|
+
["uv", "run", "smpy", "openapi", "export", "--app", app_factory, "--out", schema_out],
|
|
164
|
+
target,
|
|
165
|
+
run_proc=run_proc,
|
|
166
|
+
)
|
|
167
|
+
typer.echo("\nSetup complete.")
|
|
168
|
+
echo_next_steps(target, [], resolved, cli_name=cli_name, flat=flat)
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
"""``smpy add cli`` — add the project CLI package to an existing app idempotently."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import tomllib
|
|
6
|
+
from pathlib import Path
|
|
7
|
+
|
|
8
|
+
import typer
|
|
9
|
+
|
|
10
|
+
from simple_module_cli.scaffold.case import InvalidScaffoldNameError
|
|
11
|
+
from simple_module_cli.scaffold.cli_assets import CliScaffoldResult, scaffold_cli_package
|
|
12
|
+
from simple_module_cli.sources._add_install import _fail
|
|
13
|
+
from simple_module_cli.sources.pins import resolve_framework_version
|
|
14
|
+
from simple_module_cli.sources.uv_workspace import find_workspace_root
|
|
15
|
+
|
|
16
|
+
__all__ = ["run_add_cli"]
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def _resolve_project_layout(path: Path) -> tuple[Path, Path, bool]:
|
|
20
|
+
"""Return ``(project_root, host_dir, flat)`` for ``path``."""
|
|
21
|
+
base = path.parent if path.name == "pyproject.toml" else path
|
|
22
|
+
base = base.resolve()
|
|
23
|
+
ws_root = find_workspace_root(base)
|
|
24
|
+
if ws_root is not None and (ws_root / "host" / "pyproject.toml").is_file():
|
|
25
|
+
return ws_root, ws_root / "host", False
|
|
26
|
+
if (base / "pyproject.toml").is_file():
|
|
27
|
+
return base, base, True
|
|
28
|
+
raise _fail(f"no SimpleModule project found at {base} (missing pyproject.toml)")
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def _read_app_name(root_pyproject: Path, fallback: str) -> str:
|
|
32
|
+
try:
|
|
33
|
+
data = tomllib.loads(root_pyproject.read_text(encoding="utf-8"))
|
|
34
|
+
except (OSError, tomllib.TOMLDecodeError):
|
|
35
|
+
return fallback
|
|
36
|
+
name = data.get("project", {}).get("name")
|
|
37
|
+
return str(name).strip() if isinstance(name, str) and name.strip() else fallback
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def run_add_cli(
|
|
41
|
+
*,
|
|
42
|
+
path: Path,
|
|
43
|
+
cli_name: str | None = None,
|
|
44
|
+
no_sync: bool = False,
|
|
45
|
+
) -> CliScaffoldResult:
|
|
46
|
+
"""Add ``cli/`` + Makefile/CI/workspace wiring to an existing app without overwriting files."""
|
|
47
|
+
project_root, host_dir, flat = _resolve_project_layout(path)
|
|
48
|
+
app_name = _read_app_name(project_root / "pyproject.toml", project_root.name)
|
|
49
|
+
framework_version = resolve_framework_version()
|
|
50
|
+
|
|
51
|
+
try:
|
|
52
|
+
result = scaffold_cli_package(
|
|
53
|
+
project_root,
|
|
54
|
+
app_name=app_name,
|
|
55
|
+
framework_version=framework_version,
|
|
56
|
+
cli_name=cli_name,
|
|
57
|
+
flat=flat,
|
|
58
|
+
)
|
|
59
|
+
except InvalidScaffoldNameError as exc:
|
|
60
|
+
raise _fail(str(exc)) from exc
|
|
61
|
+
|
|
62
|
+
if result.created:
|
|
63
|
+
typer.echo(f"Added project CLI '{result.cli_name}' under {project_root / 'cli'}:")
|
|
64
|
+
for created in result.created:
|
|
65
|
+
typer.echo(f" created {created.relative_to(project_root)}")
|
|
66
|
+
else:
|
|
67
|
+
typer.echo(f"Project CLI '{result.cli_name}' is already present; no files overwritten.")
|
|
68
|
+
|
|
69
|
+
if result.skipped:
|
|
70
|
+
typer.echo("Preserved existing files:")
|
|
71
|
+
for skipped in result.skipped:
|
|
72
|
+
typer.echo(f" skipped {skipped.relative_to(project_root)}")
|
|
73
|
+
|
|
74
|
+
if result.workspace_updated:
|
|
75
|
+
typer.echo("Updated pyproject.toml workspace membership for cli/.")
|
|
76
|
+
if result.makefile_updated:
|
|
77
|
+
typer.echo("Added cli-schema and ci-cli-schema-fresh targets to Makefile.")
|
|
78
|
+
|
|
79
|
+
if not result.has_api_tokens:
|
|
80
|
+
host_flag = "--path ." if flat else "--path host"
|
|
81
|
+
host_toml = (
|
|
82
|
+
"pyproject.toml" if flat else str(host_dir.relative_to(project_root) / "pyproject.toml")
|
|
83
|
+
)
|
|
84
|
+
typer.echo(
|
|
85
|
+
f"\nNote: simple_module_api_tokens is not declared in {host_toml}."
|
|
86
|
+
"\nTo mint API tokens for the CLI, complete these steps:"
|
|
87
|
+
)
|
|
88
|
+
typer.echo(
|
|
89
|
+
" 1. Add the dependency: "
|
|
90
|
+
f"uv run smpy add simple_module_api_tokens=={framework_version} {host_flag}"
|
|
91
|
+
)
|
|
92
|
+
typer.echo(' 2. If SM_MODULES_ENABLED is set, include "ApiTokens" in it.')
|
|
93
|
+
typer.echo(
|
|
94
|
+
" 3. Generate and apply its migration:\n"
|
|
95
|
+
' uv run smpy migrations new api_tokens -m "add api_tokens"\n'
|
|
96
|
+
" make migrate"
|
|
97
|
+
)
|
|
98
|
+
|
|
99
|
+
typer.echo("\nNext steps:")
|
|
100
|
+
if not no_sync:
|
|
101
|
+
typer.echo(" make install")
|
|
102
|
+
typer.echo(" make cli-schema")
|
|
103
|
+
run_cmd = (
|
|
104
|
+
f"uv run --project cli {result.cli_name} --help"
|
|
105
|
+
if flat
|
|
106
|
+
else f"uv run {result.cli_name} --help"
|
|
107
|
+
)
|
|
108
|
+
typer.echo(f" {run_cmd}")
|
|
109
|
+
return result
|
|
@@ -19,14 +19,15 @@ from typing import Annotated
|
|
|
19
19
|
|
|
20
20
|
import typer
|
|
21
21
|
|
|
22
|
-
from simple_module_cli.
|
|
22
|
+
from simple_module_cli.commands.add_cli import run_add_cli
|
|
23
|
+
from simple_module_cli.sources._add_install import (
|
|
23
24
|
ExecRunner,
|
|
24
25
|
_default_exec_runner,
|
|
25
26
|
_fail,
|
|
26
27
|
post_install,
|
|
27
28
|
)
|
|
28
|
-
from simple_module_cli._add_sources import _add_path, _add_pypi
|
|
29
|
-
from simple_module_cli.git_source import (
|
|
29
|
+
from simple_module_cli.sources._add_sources import _add_path, _add_pypi
|
|
30
|
+
from simple_module_cli.sources.git_source import (
|
|
30
31
|
FoundModule,
|
|
31
32
|
SpecError,
|
|
32
33
|
classify_ref,
|
|
@@ -35,7 +36,7 @@ from simple_module_cli.git_source import (
|
|
|
35
36
|
scan_modules,
|
|
36
37
|
shallow_clone,
|
|
37
38
|
)
|
|
38
|
-
from simple_module_cli.pyproject_edit import (
|
|
39
|
+
from simple_module_cli.sources.pyproject_edit import (
|
|
39
40
|
has_git_sources,
|
|
40
41
|
load_pyproject,
|
|
41
42
|
save_pyproject,
|
|
@@ -155,7 +156,9 @@ def run_add(
|
|
|
155
156
|
def add_module(
|
|
156
157
|
spec: Annotated[
|
|
157
158
|
str,
|
|
158
|
-
typer.Argument(
|
|
159
|
+
typer.Argument(
|
|
160
|
+
help="PyPI requirement, git+URL[@ref][#subdirectory=dir], local path, or 'cli'."
|
|
161
|
+
),
|
|
159
162
|
],
|
|
160
163
|
module: Annotated[
|
|
161
164
|
str,
|
|
@@ -173,8 +176,18 @@ def add_module(
|
|
|
173
176
|
typer.Option("--no-sync", help="Write pyproject only; skip post-install steps."),
|
|
174
177
|
] = False,
|
|
175
178
|
yes: Annotated[bool, typer.Option("--yes", "-y", help="Never prompt (fail instead).")] = False,
|
|
179
|
+
cli_name: Annotated[
|
|
180
|
+
str | None,
|
|
181
|
+
typer.Option(
|
|
182
|
+
"--cli-name",
|
|
183
|
+
help="Override the project CLI command name (used with `smpy add cli`).",
|
|
184
|
+
),
|
|
185
|
+
] = None,
|
|
176
186
|
) -> None:
|
|
177
|
-
"""Add a module dependency
|
|
187
|
+
"""Add a module dependency (PyPI, git, local path) or scaffold the project CLI (`cli`)."""
|
|
188
|
+
if spec.strip() == "cli":
|
|
189
|
+
run_add_cli(path=path, cli_name=cli_name, no_sync=no_sync)
|
|
190
|
+
return
|
|
178
191
|
pyproject = path if path.name == "pyproject.toml" else path / "pyproject.toml"
|
|
179
192
|
select = [m.strip() for m in module.split(",") if m.strip()]
|
|
180
193
|
run_add(
|
|
@@ -15,8 +15,8 @@ from typing import Annotated
|
|
|
15
15
|
|
|
16
16
|
import typer
|
|
17
17
|
|
|
18
|
-
from simple_module_cli.
|
|
19
|
-
from simple_module_cli.
|
|
18
|
+
from simple_module_cli.commands.gen_cmd import client_app_dir, run_generation
|
|
19
|
+
from simple_module_cli.migrations._migration_support import resolve_project_root
|
|
20
20
|
|
|
21
21
|
|
|
22
22
|
def check_port(port: int) -> None:
|
|
@@ -82,7 +82,7 @@ def stop_children(children: list[subprocess.Popen]) -> None:
|
|
|
82
82
|
|
|
83
83
|
|
|
84
84
|
def run_dev(root: Path, *, port: int = 8000, vite_port: int | None = None) -> int:
|
|
85
|
-
from simple_module_core.dotenv import load_dotenv_into_environ
|
|
85
|
+
from simple_module_core.settings.dotenv import load_dotenv_into_environ
|
|
86
86
|
|
|
87
87
|
root = root.resolve()
|
|
88
88
|
client = client_app_dir(root)
|
|
@@ -8,7 +8,7 @@ import typer
|
|
|
8
8
|
import yaml
|
|
9
9
|
from yaml.nodes import MappingNode, ScalarNode
|
|
10
10
|
|
|
11
|
-
from simple_module_cli.docker_assets import _read, _template_root
|
|
11
|
+
from simple_module_cli.scaffold.docker_assets import _read, _template_root
|
|
12
12
|
|
|
13
13
|
_GROUP = "docker"
|
|
14
14
|
_COMMAND = "add-worker"
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"""``smpy fix-imports``: move an app off deprecated framework import paths."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import difflib
|
|
6
|
+
from collections.abc import Iterator
|
|
7
|
+
from pathlib import Path
|
|
8
|
+
from typing import Annotated
|
|
9
|
+
|
|
10
|
+
import typer
|
|
11
|
+
|
|
12
|
+
from simple_module_cli.updates.import_codemod import load_renames, rewrite_source
|
|
13
|
+
|
|
14
|
+
_SKIP_DIRS = frozenset(
|
|
15
|
+
{".git", ".venv", "venv", "node_modules", "__pycache__", "build", "dist", ".tox", ".smpy"}
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def iter_python_files(paths: list[Path]) -> Iterator[Path]:
|
|
20
|
+
"""Every ``.py`` file under ``paths``, skipping virtualenvs and build output."""
|
|
21
|
+
for path in paths:
|
|
22
|
+
if path.is_file():
|
|
23
|
+
if path.suffix == ".py":
|
|
24
|
+
yield path
|
|
25
|
+
continue
|
|
26
|
+
for candidate in sorted(path.rglob("*.py")):
|
|
27
|
+
if not _SKIP_DIRS.intersection(candidate.relative_to(path).parts[:-1]):
|
|
28
|
+
yield candidate
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def fix_imports(
|
|
32
|
+
paths: Annotated[
|
|
33
|
+
list[Path] | None,
|
|
34
|
+
typer.Argument(help="Files or directories to rewrite. Defaults to the current directory."),
|
|
35
|
+
] = None,
|
|
36
|
+
check: Annotated[
|
|
37
|
+
bool,
|
|
38
|
+
typer.Option(
|
|
39
|
+
"--check",
|
|
40
|
+
help="Write nothing; exit 1 if any file would change or needs manual review.",
|
|
41
|
+
),
|
|
42
|
+
] = False,
|
|
43
|
+
diff: Annotated[
|
|
44
|
+
bool, typer.Option("--diff", help="Print a unified diff instead of writing.")
|
|
45
|
+
] = False,
|
|
46
|
+
) -> None:
|
|
47
|
+
"""Rewrite imports of deprecated framework paths to their new area paths.
|
|
48
|
+
|
|
49
|
+
Covers ``import x``, ``from x import y``, ``from pkg import moved_module``,
|
|
50
|
+
attribute chains after a bare ``import x`` and dotted strings such as
|
|
51
|
+
``mock.patch("x.y")``. Run your formatter afterwards to re-sort imports.
|
|
52
|
+
"""
|
|
53
|
+
renames = load_renames()
|
|
54
|
+
changed_files = 0
|
|
55
|
+
manual_total = 0
|
|
56
|
+
for file in iter_python_files(paths or [Path()]):
|
|
57
|
+
original = file.read_text(encoding="utf-8")
|
|
58
|
+
result = rewrite_source(original, renames)
|
|
59
|
+
for note in result.manual:
|
|
60
|
+
typer.echo(f"{file}: manual: {note}", err=True)
|
|
61
|
+
manual_total += len(result.manual)
|
|
62
|
+
if not result.changed:
|
|
63
|
+
continue
|
|
64
|
+
changed_files += 1
|
|
65
|
+
if diff:
|
|
66
|
+
typer.echo(
|
|
67
|
+
"".join(
|
|
68
|
+
difflib.unified_diff(
|
|
69
|
+
original.splitlines(keepends=True),
|
|
70
|
+
result.source.splitlines(keepends=True),
|
|
71
|
+
fromfile=str(file),
|
|
72
|
+
tofile=str(file),
|
|
73
|
+
)
|
|
74
|
+
),
|
|
75
|
+
nl=False,
|
|
76
|
+
)
|
|
77
|
+
elif not check:
|
|
78
|
+
file.write_text(result.source, encoding="utf-8")
|
|
79
|
+
typer.echo(f"{file}: {len(result.changes)} rewrite(s)")
|
|
80
|
+
verb = "would change" if (check or diff) else "changed"
|
|
81
|
+
typer.echo(f"{changed_files} file(s) {verb}; {manual_total} need manual review.")
|
|
82
|
+
if check and (changed_files or manual_total):
|
|
83
|
+
raise typer.Exit(1)
|
|
@@ -8,8 +8,9 @@ from pathlib import Path
|
|
|
8
8
|
|
|
9
9
|
import typer
|
|
10
10
|
|
|
11
|
-
from simple_module_cli.
|
|
12
|
-
from simple_module_cli.
|
|
11
|
+
from simple_module_cli.migrations._migration_support import resolve_project_root
|
|
12
|
+
from simple_module_cli.tooling import _generation_cache
|
|
13
|
+
from simple_module_cli.tooling._generation_cache import GenerationCache, file_hashes, source_files
|
|
13
14
|
|
|
14
15
|
|
|
15
16
|
def client_app_dir(root: Path) -> Path:
|
|
@@ -38,40 +39,41 @@ def _sync_deps(client: Path, deps: dict[str, dict[str, str]]) -> None:
|
|
|
38
39
|
|
|
39
40
|
|
|
40
41
|
def run_generation(project_root: Path | None = None) -> list[str]:
|
|
41
|
-
from simple_module_core import get_module_package_name, select_auth_provider
|
|
42
|
-
from simple_module_core.dotenv import load_dotenv_into_environ
|
|
43
|
-
from simple_module_hosting.
|
|
44
|
-
from simple_module_hosting.
|
|
45
|
-
from simple_module_hosting.admin_surfaces import render_admin_surfaces
|
|
46
|
-
from simple_module_hosting.assets import (
|
|
42
|
+
from simple_module_core import discover_modules, get_module_package_name, select_auth_provider
|
|
43
|
+
from simple_module_core.settings.dotenv import load_dotenv_into_environ
|
|
44
|
+
from simple_module_hosting.frontend.admin_surfaces import render_admin_surfaces
|
|
45
|
+
from simple_module_hosting.frontend.assets import (
|
|
47
46
|
compute_module_assets,
|
|
48
47
|
framework_assets,
|
|
49
48
|
render_assets_json,
|
|
50
49
|
)
|
|
50
|
+
from simple_module_hosting.frontend.manifest import (
|
|
51
|
+
collect_module_js_deps,
|
|
52
|
+
write_module_pages_manifest,
|
|
53
|
+
)
|
|
51
54
|
from simple_module_hosting.host_cli import _declares_workspaces
|
|
52
|
-
from simple_module_hosting.
|
|
53
|
-
from simple_module_hosting.
|
|
55
|
+
from simple_module_hosting.i18n._i18n_modules import module_key_outputs
|
|
56
|
+
from simple_module_hosting.i18n._i18n_target import app_i18n_dir, resolve_i18n_types_dir
|
|
57
|
+
from simple_module_hosting.i18n.i18n_manifest import emit_frontend_types_for_modules
|
|
54
58
|
|
|
55
|
-
from simple_module_cli.
|
|
56
|
-
from simple_module_cli.
|
|
59
|
+
from simple_module_cli.commands import openapi_cmd
|
|
60
|
+
from simple_module_cli.commands.openapi_cmd import _build_app
|
|
61
|
+
from simple_module_cli.tooling import openapi_types
|
|
62
|
+
from simple_module_cli.tooling.openapi_types import generate, module_targets
|
|
57
63
|
|
|
58
64
|
root = (project_root or resolve_project_root()).resolve()
|
|
59
65
|
client = client_app_dir(root)
|
|
60
66
|
load_dotenv_into_environ(root / ".env")
|
|
61
67
|
settings, installed = _settings_and_modules()
|
|
62
68
|
enabled = settings.modules_enabled
|
|
63
|
-
active = (
|
|
64
|
-
installed
|
|
65
|
-
if enabled is None
|
|
66
|
-
else [m for m in installed if m.meta.name.lower() in {name.lower() for name in enabled}]
|
|
67
|
-
)
|
|
69
|
+
active = installed if enabled is None else discover_modules(enabled=enabled, strict=True)
|
|
68
70
|
modules = select_auth_provider(active, settings.auth_provider)
|
|
69
71
|
roots = [Path(str(importlib.resources.files(get_module_package_name(m)))) for m in installed]
|
|
70
72
|
hosting = Path(str(importlib.resources.files("simple_module_hosting")))
|
|
71
73
|
cache = GenerationCache(root / ".smpy/gen.json")
|
|
72
74
|
changed = []
|
|
73
75
|
# Code changes in the pipeline itself invalidate old cache formats and decisions.
|
|
74
|
-
version = file_hashes([Path(
|
|
76
|
+
version = file_hashes([Path(p) for p in (__file__, _generation_cache.__file__) if p])
|
|
75
77
|
|
|
76
78
|
def run(name, inputs, outputs, action):
|
|
77
79
|
if cache.run(name, lambda: {"version": version, "data": inputs()}, outputs, action):
|
|
@@ -96,10 +98,10 @@ def run_generation(project_root: Path | None = None) -> list[str]:
|
|
|
96
98
|
"locales": [settings.i18n_default_locale, settings.i18n_supported_locales],
|
|
97
99
|
"generator": file_hashes(
|
|
98
100
|
[
|
|
99
|
-
hosting / "i18n_manifest.py",
|
|
100
|
-
hosting / "_i18n_build.py",
|
|
101
|
-
hosting / "_i18n_target.py",
|
|
102
|
-
hosting / "_i18n_modules.py",
|
|
101
|
+
hosting / "i18n/i18n_manifest.py",
|
|
102
|
+
hosting / "i18n/_i18n_build.py",
|
|
103
|
+
hosting / "i18n/_i18n_target.py",
|
|
104
|
+
hosting / "i18n/_i18n_modules.py",
|
|
103
105
|
]
|
|
104
106
|
),
|
|
105
107
|
},
|
|
@@ -119,26 +121,36 @@ def run_generation(project_root: Path | None = None) -> list[str]:
|
|
|
119
121
|
for p in source_files(a.package_dir, {".ts", ".tsx"})
|
|
120
122
|
if p.name != "i18n.generated.ts"
|
|
121
123
|
]
|
|
124
|
+
from simple_module_hosting.frontend.module_tsconfig import (
|
|
125
|
+
expected_module_tsconfig_outputs,
|
|
126
|
+
host_tsconfig_chain,
|
|
127
|
+
)
|
|
128
|
+
|
|
122
129
|
run(
|
|
123
130
|
"pages",
|
|
124
131
|
lambda: {
|
|
125
132
|
"assets": render_assets_json(assets),
|
|
126
133
|
"admin_surfaces": render_admin_surfaces(modules),
|
|
127
134
|
"sources": sorted(str(p) for p in page_sources),
|
|
135
|
+
"tsconfig": file_hashes(host_tsconfig_chain(client)),
|
|
128
136
|
"generator": file_hashes(
|
|
129
137
|
[
|
|
130
|
-
hosting / "manifest.py",
|
|
131
|
-
hosting / "assets.py",
|
|
132
|
-
hosting / "
|
|
133
|
-
hosting / "
|
|
134
|
-
hosting / "
|
|
138
|
+
hosting / "frontend/manifest.py",
|
|
139
|
+
hosting / "frontend/assets.py",
|
|
140
|
+
hosting / "frontend/_asset_sources.py",
|
|
141
|
+
hosting / "frontend/page_globs.py",
|
|
142
|
+
hosting / "frontend/admin_surfaces.py",
|
|
143
|
+
hosting / "frontend/frontend_extensions.py",
|
|
144
|
+
hosting / "frontend/module_tsconfig.py",
|
|
145
|
+
hosting / "frontend/_tsconfig_paths.py",
|
|
135
146
|
]
|
|
136
147
|
),
|
|
137
148
|
},
|
|
138
149
|
[
|
|
139
150
|
client / f"modules.{n}"
|
|
140
151
|
for n in ("manifest.json", "generated.ts", "generated.css", "assets.json")
|
|
141
|
-
]
|
|
152
|
+
]
|
|
153
|
+
+ expected_module_tsconfig_outputs(assets, client),
|
|
142
154
|
lambda: write_module_pages_manifest(modules, client),
|
|
143
155
|
)
|
|
144
156
|
|
|
@@ -156,7 +168,7 @@ def run_generation(project_root: Path | None = None) -> list[str]:
|
|
|
156
168
|
lambda: {
|
|
157
169
|
"dependencies": deps,
|
|
158
170
|
"manifests": file_hashes(manifests),
|
|
159
|
-
"generator": file_hashes([hosting / "host_cli.py", hosting / "manifest.py"]),
|
|
171
|
+
"generator": file_hashes([hosting / "host_cli.py", hosting / "frontend/manifest.py"]),
|
|
160
172
|
},
|
|
161
173
|
dep_files,
|
|
162
174
|
lambda: _sync_deps(client, deps),
|
|
@@ -177,9 +189,8 @@ def run_generation(project_root: Path | None = None) -> list[str]:
|
|
|
177
189
|
api_files += [
|
|
178
190
|
root / "pyproject.toml",
|
|
179
191
|
root / "uv.lock",
|
|
180
|
-
Path(__file__).with_name("openapi_cmd.py"),
|
|
181
|
-
Path(__file__).with_name("openapi_types.py"),
|
|
182
192
|
]
|
|
193
|
+
api_files += [Path(p) for p in (openapi_cmd.__file__, openapi_types.__file__) if p]
|
|
183
194
|
|
|
184
195
|
def api():
|
|
185
196
|
if targets:
|