PyArch-CLI 0.2.0__tar.gz → 0.2.1__tar.gz

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 (93) hide show
  1. pyarch_cli-0.2.1/.github/workflows/ci.yml +34 -0
  2. {pyarch_cli-0.2.0 → pyarch_cli-0.2.1}/.gitignore +1 -0
  3. {pyarch_cli-0.2.0 → pyarch_cli-0.2.1}/PKG-INFO +42 -20
  4. {pyarch_cli-0.2.0 → pyarch_cli-0.2.1}/README.md +41 -19
  5. {pyarch_cli-0.2.0 → pyarch_cli-0.2.1}/pyproject.toml +1 -1
  6. pyarch_cli-0.2.1/src/pyarch/__init__.py +1 -0
  7. {pyarch_cli-0.2.0 → pyarch_cli-0.2.1}/src/pyarch/cli/app.py +7 -0
  8. {pyarch_cli-0.2.0 → pyarch_cli-0.2.1}/src/pyarch/cli/common.py +2 -0
  9. pyarch_cli-0.2.1/src/pyarch/cli/db.py +47 -0
  10. {pyarch_cli-0.2.0 → pyarch_cli-0.2.1}/src/pyarch/config/manifest.py +1 -1
  11. {pyarch_cli-0.2.0 → pyarch_cli-0.2.1}/src/pyarch/generators/common/filesystem.py +54 -52
  12. {pyarch_cli-0.2.0 → pyarch_cli-0.2.1}/src/pyarch/generators/module/layered.py +158 -158
  13. {pyarch_cli-0.2.0 → pyarch_cli-0.2.1}/src/pyarch/generators/project/base.py +56 -37
  14. {pyarch_cli-0.2.0 → pyarch_cli-0.2.1}/src/pyarch/generators/project/layered.py +4 -5
  15. {pyarch_cli-0.2.0 → pyarch_cli-0.2.1}/src/pyarch/services/add_integration.py +21 -21
  16. {pyarch_cli-0.2.0 → pyarch_cli-0.2.1}/src/pyarch/services/create_module.py +28 -28
  17. {pyarch_cli-0.2.0 → pyarch_cli-0.2.1}/src/pyarch/services/create_project.py +6 -6
  18. pyarch_cli-0.2.1/src/pyarch/services/database.py +110 -0
  19. {pyarch_cli-0.2.0 → pyarch_cli-0.2.1}/src/pyarch/templates/layered/alembic_env.py.j2 +2 -3
  20. {pyarch_cli-0.2.0 → pyarch_cli-0.2.1}/src/pyarch/templates/layered/auth/config.py.j2 +4 -5
  21. {pyarch_cli-0.2.0 → pyarch_cli-0.2.1}/src/pyarch/templates/layered/auth/dependencies.py.j2 +4 -5
  22. {pyarch_cli-0.2.0 → pyarch_cli-0.2.1}/src/pyarch/templates/layered/auth/routes.py.j2 +3 -4
  23. {pyarch_cli-0.2.0 → pyarch_cli-0.2.1}/src/pyarch/templates/layered/auth/service.py.j2 +5 -5
  24. {pyarch_cli-0.2.0 → pyarch_cli-0.2.1}/src/pyarch/templates/layered/auth/tokens.py.j2 +2 -2
  25. {pyarch_cli-0.2.0 → pyarch_cli-0.2.1}/src/pyarch/templates/layered/auth/user_model.py.j2 +2 -1
  26. {pyarch_cli-0.2.0 → pyarch_cli-0.2.1}/src/pyarch/templates/layered/auth/utils.py.j2 +2 -2
  27. {pyarch_cli-0.2.0 → pyarch_cli-0.2.1}/src/pyarch/templates/layered/env.example.j2 +2 -2
  28. {pyarch_cli-0.2.0 → pyarch_cli-0.2.1}/src/pyarch/templates/layered/models_init.py.j2 +0 -1
  29. {pyarch_cli-0.2.0 → pyarch_cli-0.2.1}/src/pyarch/templates/layered/module/module_router.py.j2 +0 -1
  30. {pyarch_cli-0.2.0 → pyarch_cli-0.2.1}/src/pyarch/templates/layered/module/module_router_protected.py.j2 +0 -1
  31. {pyarch_cli-0.2.0 → pyarch_cli-0.2.1}/src/pyarch/templates/layered/module/module_service.py.j2 +0 -2
  32. {pyarch_cli-0.2.0 → pyarch_cli-0.2.1}/src/pyarch/templates/layered/module/module_test_protected.py.j2 +0 -1
  33. {pyarch_cli-0.2.0 → pyarch_cli-0.2.1}/src/pyarch/templates/layered/router.py.j2 +0 -1
  34. {pyarch_cli-0.2.0 → pyarch_cli-0.2.1}/src/pyarch/templates/layered/session.py.j2 +1 -1
  35. {pyarch_cli-0.2.0 → pyarch_cli-0.2.1}/src/pyarch/templates/project/base/Dockerfile.j2 +1 -1
  36. pyarch_cli-0.2.1/src/pyarch/templates/project/base/README.md.j2 +39 -0
  37. pyarch_cli-0.2.1/src/pyarch/templates/project/base/ci.yml.j2 +26 -0
  38. {pyarch_cli-0.2.0 → pyarch_cli-0.2.1}/src/pyarch/templates/project/base/conftest.py.j2 +8 -9
  39. {pyarch_cli-0.2.0 → pyarch_cli-0.2.1}/src/pyarch/templates/project/base/docker-compose.postgres.yml.j2 +17 -27
  40. pyarch_cli-0.2.1/src/pyarch/templates/project/base/docker-compose.sqlite.yml.j2 +6 -0
  41. pyarch_cli-0.2.1/src/pyarch/templates/project/base/dockerignore.j2 +12 -0
  42. {pyarch_cli-0.2.0 → pyarch_cli-0.2.1}/src/pyarch/templates/project/base/main.py.j2 +0 -1
  43. pyarch_cli-0.2.1/src/pyarch/templates/project/base/ruff.toml.j2 +8 -0
  44. {pyarch_cli-0.2.0 → pyarch_cli-0.2.1}/tests/integration/test_generated_project.py +13 -3
  45. {pyarch_cli-0.2.0 → pyarch_cli-0.2.1}/tests/integration/test_project_generation.py +3 -1
  46. pyarch_cli-0.2.1/tests/unit/test_database_cli.py +57 -0
  47. pyarch_cli-0.2.1/tests/unit/test_database_service.py +162 -0
  48. {pyarch_cli-0.2.0 → pyarch_cli-0.2.1}/tests/unit/test_filesystem.py +6 -3
  49. pyarch_cli-0.2.1/tests/unit/test_templates.py +79 -0
  50. {pyarch_cli-0.2.0 → pyarch_cli-0.2.1}/uv.lock +1 -1
  51. pyarch_cli-0.2.0/.release-dist/.gitignore +0 -1
  52. pyarch_cli-0.2.0/src/pyarch/__init__.py +0 -1
  53. pyarch_cli-0.2.0/src/pyarch/templates/project/base/README.md.j2 +0 -13
  54. pyarch_cli-0.2.0/src/pyarch/templates/project/base/docker-compose.sqlite.yml.j2 +0 -14
  55. pyarch_cli-0.2.0/tests/unit/test_templates.py +0 -65
  56. {pyarch_cli-0.2.0 → pyarch_cli-0.2.1}/.python-version +0 -0
  57. {pyarch_cli-0.2.0 → pyarch_cli-0.2.1}/LICENSE +0 -0
  58. {pyarch_cli-0.2.0 → pyarch_cli-0.2.1}/assets/Dockerfile.vhs +0 -0
  59. {pyarch_cli-0.2.0 → pyarch_cli-0.2.1}/assets/pyarch-demo.gif +0 -0
  60. {pyarch_cli-0.2.0 → pyarch_cli-0.2.1}/assets/pyarch-demo.tape +0 -0
  61. {pyarch_cli-0.2.0 → pyarch_cli-0.2.1}/assets/vhs-uv +0 -0
  62. {pyarch_cli-0.2.0 → pyarch_cli-0.2.1}/src/pyarch/cli/__init__.py +0 -0
  63. {pyarch_cli-0.2.0 → pyarch_cli-0.2.1}/src/pyarch/cli/add.py +0 -0
  64. {pyarch_cli-0.2.0 → pyarch_cli-0.2.1}/src/pyarch/cli/generate.py +0 -0
  65. {pyarch_cli-0.2.0 → pyarch_cli-0.2.1}/src/pyarch/cli/info.py +0 -0
  66. {pyarch_cli-0.2.0 → pyarch_cli-0.2.1}/src/pyarch/cli/init.py +0 -0
  67. {pyarch_cli-0.2.0 → pyarch_cli-0.2.1}/src/pyarch/config/__init__.py +0 -0
  68. {pyarch_cli-0.2.0 → pyarch_cli-0.2.1}/src/pyarch/config/models.py +0 -0
  69. {pyarch_cli-0.2.0 → pyarch_cli-0.2.1}/src/pyarch/generators/__init__.py +0 -0
  70. {pyarch_cli-0.2.0 → pyarch_cli-0.2.1}/src/pyarch/generators/common/__init__.py +0 -0
  71. {pyarch_cli-0.2.0 → pyarch_cli-0.2.1}/src/pyarch/generators/common/commands.py +0 -0
  72. {pyarch_cli-0.2.0 → pyarch_cli-0.2.1}/src/pyarch/generators/common/gitignore.py +0 -0
  73. {pyarch_cli-0.2.0 → pyarch_cli-0.2.1}/src/pyarch/generators/common/renderer.py +0 -0
  74. {pyarch_cli-0.2.0 → pyarch_cli-0.2.1}/src/pyarch/generators/integration/__init__.py +0 -0
  75. {pyarch_cli-0.2.0 → pyarch_cli-0.2.1}/src/pyarch/generators/integration/auth.py +0 -0
  76. {pyarch_cli-0.2.0 → pyarch_cli-0.2.1}/src/pyarch/generators/module/__init__.py +0 -0
  77. {pyarch_cli-0.2.0 → pyarch_cli-0.2.1}/src/pyarch/generators/project/__init__.py +0 -0
  78. {pyarch_cli-0.2.0 → pyarch_cli-0.2.1}/src/pyarch/main.py +0 -0
  79. {pyarch_cli-0.2.0 → pyarch_cli-0.2.1}/src/pyarch/services/__init__.py +0 -0
  80. {pyarch_cli-0.2.0 → pyarch_cli-0.2.1}/src/pyarch/templates/layered/auth/refresh_session_model.py.j2 +0 -0
  81. {pyarch_cli-0.2.0 → pyarch_cli-0.2.1}/src/pyarch/templates/layered/auth/schemas.py.j2 +0 -0
  82. {pyarch_cli-0.2.0 → pyarch_cli-0.2.1}/src/pyarch/templates/layered/auth/test_auth.py.j2 +0 -0
  83. {pyarch_cli-0.2.0 → pyarch_cli-0.2.1}/src/pyarch/templates/layered/auth/test_helpers.py.j2 +0 -0
  84. {pyarch_cli-0.2.0 → pyarch_cli-0.2.1}/src/pyarch/templates/layered/config.py.j2 +0 -0
  85. {pyarch_cli-0.2.0 → pyarch_cli-0.2.1}/src/pyarch/templates/layered/errors.py.j2 +0 -0
  86. {pyarch_cli-0.2.0 → pyarch_cli-0.2.1}/src/pyarch/templates/layered/exception_handlers.py.j2 +0 -0
  87. {pyarch_cli-0.2.0 → pyarch_cli-0.2.1}/src/pyarch/templates/layered/module/module_model.py.j2 +0 -0
  88. {pyarch_cli-0.2.0 → pyarch_cli-0.2.1}/src/pyarch/templates/layered/module/module_repo.py.j2 +0 -0
  89. {pyarch_cli-0.2.0 → pyarch_cli-0.2.1}/src/pyarch/templates/layered/module/module_schema.py.j2 +0 -0
  90. {pyarch_cli-0.2.0 → pyarch_cli-0.2.1}/src/pyarch/templates/layered/module/module_test.py.j2 +0 -0
  91. {pyarch_cli-0.2.0 → pyarch_cli-0.2.1}/src/pyarch/templates/layered/pagination.py.j2 +0 -0
  92. {pyarch_cli-0.2.0 → pyarch_cli-0.2.1}/tests/unit/test_manifest.py +0 -0
  93. {pyarch_cli-0.2.0 → pyarch_cli-0.2.1}/tests/unit/test_module_generator.py +0 -0
@@ -0,0 +1,34 @@
1
+ name: pyarch-ci
2
+
3
+ on:
4
+ push:
5
+ pull_request:
6
+
7
+ jobs:
8
+ checks:
9
+ runs-on: ubuntu-latest
10
+ steps:
11
+ - uses: actions/checkout@v5
12
+
13
+ - uses: actions/setup-python@v5
14
+ with:
15
+ python-version: "3.13"
16
+
17
+ - name: Install dependencies
18
+ run: |
19
+ pip install uv
20
+ uv sync
21
+
22
+ - name: linter
23
+ run: |
24
+ uv run ruff check .
25
+ uv run ruff format --check .
26
+
27
+ - name: run tests
28
+ run: uv run pytest
29
+
30
+ - name: type check
31
+ run: uv run mypy src tests
32
+
33
+ - name: build package
34
+ run: uv build
@@ -2,6 +2,7 @@
2
2
  __pycache__/
3
3
  *.py[oc]
4
4
  build/
5
+ *dist
5
6
  dist/
6
7
  wheels/
7
8
  *.egg-info
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: PyArch-CLI
3
- Version: 0.2.0
3
+ Version: 0.2.1
4
4
  Summary: Stateful CLI generator for Layered FastAPI projects
5
5
  Project-URL: Homepage, https://github.com/Allcode-1/PyArch
6
6
  Project-URL: Repository, https://github.com/Allcode-1/PyArch
@@ -34,7 +34,7 @@ Description-Content-Type: text/markdown
34
34
  ![Typer](https://img.shields.io/badge/Typer-CLI-purple)
35
35
  ![Jinja2](https://img.shields.io/badge/Jinja2-templates-orange)
36
36
  ![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)
37
- ![Status](https://img.shields.io/badge/status-v0.2.0-blue)
37
+ ![Status](https://img.shields.io/badge/status-v0.2.1-blue)
38
38
 
39
39
  PyArch is a CLI for creating and extending Layered FastAPI projects. It sets up
40
40
  the application structure, database, tests and Alembic, then lets you add CRUD
@@ -56,6 +56,7 @@ ready to change.
56
56
  - Layered FastAPI project structure
57
57
  - PostgreSQL and SQLite support
58
58
  - Complete CRUD modules with models, schemas, repositories, services and routes
59
+ - GitHub Actions workflow for generated-project linting and tests
59
60
  - Automatic model and router registration
60
61
  - JWT auth integration with generated RSA keys
61
62
  - Protected CRUD routes
@@ -64,11 +65,11 @@ ready to change.
64
65
  - Project-aware generation through `pyarch.toml`
65
66
  - Atomic project creation and rollback for failed extensions
66
67
 
67
- ## v0.2.0 Highlights
68
+ ## v0.2.1 Highlights
68
69
 
69
70
  - Atomic project creation through a staging directory, with cleanup on failure
70
71
  - Rollback for failed module and auth generation
71
- - Database-specific Docker Compose files for PostgreSQL and SQLite
72
+ - Docker Compose support for PostgreSQL projects
72
73
  - Refresh-token rotation protected against concurrent reuse on PostgreSQL
73
74
  - Self-tests for PyArch and an end-to-end generated-project workflow
74
75
 
@@ -90,9 +91,12 @@ pyarch init my_project --database postgres
90
91
  cd my_project
91
92
  ```
92
93
 
93
- Copy `.env.example` to `.env` and set the database connection values. The
94
- generated Compose file matches the selected database: PostgreSQL projects get
95
- database services; SQLite projects get only migration and API services.
94
+ Copy `.env.example` to `.env` and set the database connection values. For a
95
+ PostgreSQL project, initialize the database schema before starting the app:
96
+
97
+ ```bash
98
+ pyarch db init
99
+ ```
96
100
 
97
101
  Start the generated application:
98
102
 
@@ -100,12 +104,17 @@ Start the generated application:
100
104
  docker compose up -d
101
105
  ```
102
106
 
103
- After adding a generated module or integration that changes the database
104
- schema, create a revision with
105
- `uv run alembic revision --autogenerate -m "describe schema change"`. Then
106
- apply it with `uv run alembic upgrade head`.
107
- PyArch never autogenerates revisions during container startup: migration files
108
- are source code and should be reviewed and committed.
107
+ After a model change in a PostgreSQL project, generate and apply a reviewed
108
+ revision and restart the application with:
109
+
110
+ ```bash
111
+ pyarch db upgrade --message "describe schema change"
112
+ ```
113
+
114
+ Without `--message`, PyArch prompts for one. When Alembic finds no metadata
115
+ changes, `db upgrade` restarts Compose but creates no empty revision. Compose
116
+ never runs migrations implicitly; migration files remain source code and should
117
+ be reviewed and committed.
109
118
 
110
119
  ## Safe Generation
111
120
 
@@ -120,12 +129,16 @@ Open `http://127.0.0.1:8000/docs` to use the generated Swagger UI.
120
129
  You can now extend the project:
121
130
 
122
131
  ```bash
123
- pyarch generate module users
132
+ pyarch generate module user
124
133
  pyarch add integration auth
125
- pyarch generate module tasks --protected
134
+ pyarch generate module task --protected
126
135
  pyarch info
127
136
  ```
128
137
 
138
+ Module names must be singular identifiers. PyArch derives the plural table and
139
+ route names from them: use `user` to generate `/users` and the `users` table,
140
+ not `users`.
141
+
129
142
  ## What Gets Generated
130
143
 
131
144
  A new project includes the application layers, database configuration, test
@@ -165,9 +178,9 @@ Each generated CRUD module adds:
165
178
  | ------------------------------------------- | ------------------------------------------------ |
166
179
  | `pyarch init <name>` | Create a Layered FastAPI project |
167
180
  | `pyarch init <name> --database <engine>` | Select PostgreSQL or SQLite |
168
- | `pyarch generate module <name>` | Add a CRUD module to the current project |
181
+ | `pyarch generate module <singular-name>` | Add a CRUD module to the current project |
169
182
  | `pyarch add integration auth` | Add JWT authentication and user management |
170
- | `pyarch generate module <name> --protected` | Generate CRUD routes that require authentication |
183
+ | `pyarch generate module <singular-name> --protected` | Generate protected CRUD routes |
171
184
  | `pyarch info` | Show the current project configuration |
172
185
  | `pyarch --help` | Show CLI help |
173
186
 
@@ -184,6 +197,9 @@ Current limitations:
184
197
 
185
198
  - only Layered Architecture is supported;
186
199
  - generated applications use synchronous database access;
200
+ - SQLite projects run locally and do not include Docker Compose; `pyarch db`
201
+ lifecycle commands are PostgreSQL-only. SQLite migrations can be run with
202
+ Alembic directly;
187
203
  - generated projects are starter scaffolds and still require
188
204
  application-specific configuration and code;
189
205
  - the manifest format may change before a stable release.
@@ -283,11 +299,17 @@ instead of producing incomplete files.
283
299
 
284
300
  ## Roadmap
285
301
 
286
- ### v0.2.0 (current)
302
+ ### v0.2.1 (current)
303
+
304
+ - singular module-name contract and corrected SQLite workflow documentation;
305
+ - generated GitHub Actions workflow for linting and tests;
306
+ - package and generated-manifest versions kept in sync.
307
+
308
+ ### v0.2.0
287
309
 
288
310
  - atomic project creation and cleanup on failure;
289
311
  - rollback for failed module and auth generation;
290
- - PostgreSQL- and SQLite-specific Compose templates;
312
+ - PostgreSQL Compose template and SQLite local setup;
291
313
  - self-test suite and generated-project integration coverage.
292
314
 
293
315
  ### v0.3
@@ -305,6 +327,6 @@ instead of producing incomplete files.
305
327
 
306
328
  ## Status
307
329
 
308
- PyArch v0.2.0 is an early alpha release. The main workflow is usable, but
330
+ PyArch v0.2.1 is an early alpha release. The main workflow is usable, but
309
331
  commands, templates, generated code and the manifest may still change before a
310
332
  stable release.
@@ -6,7 +6,7 @@
6
6
  ![Typer](https://img.shields.io/badge/Typer-CLI-purple)
7
7
  ![Jinja2](https://img.shields.io/badge/Jinja2-templates-orange)
8
8
  ![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)
9
- ![Status](https://img.shields.io/badge/status-v0.2.0-blue)
9
+ ![Status](https://img.shields.io/badge/status-v0.2.1-blue)
10
10
 
11
11
  PyArch is a CLI for creating and extending Layered FastAPI projects. It sets up
12
12
  the application structure, database, tests and Alembic, then lets you add CRUD
@@ -28,6 +28,7 @@ ready to change.
28
28
  - Layered FastAPI project structure
29
29
  - PostgreSQL and SQLite support
30
30
  - Complete CRUD modules with models, schemas, repositories, services and routes
31
+ - GitHub Actions workflow for generated-project linting and tests
31
32
  - Automatic model and router registration
32
33
  - JWT auth integration with generated RSA keys
33
34
  - Protected CRUD routes
@@ -36,11 +37,11 @@ ready to change.
36
37
  - Project-aware generation through `pyarch.toml`
37
38
  - Atomic project creation and rollback for failed extensions
38
39
 
39
- ## v0.2.0 Highlights
40
+ ## v0.2.1 Highlights
40
41
 
41
42
  - Atomic project creation through a staging directory, with cleanup on failure
42
43
  - Rollback for failed module and auth generation
43
- - Database-specific Docker Compose files for PostgreSQL and SQLite
44
+ - Docker Compose support for PostgreSQL projects
44
45
  - Refresh-token rotation protected against concurrent reuse on PostgreSQL
45
46
  - Self-tests for PyArch and an end-to-end generated-project workflow
46
47
 
@@ -62,9 +63,12 @@ pyarch init my_project --database postgres
62
63
  cd my_project
63
64
  ```
64
65
 
65
- Copy `.env.example` to `.env` and set the database connection values. The
66
- generated Compose file matches the selected database: PostgreSQL projects get
67
- database services; SQLite projects get only migration and API services.
66
+ Copy `.env.example` to `.env` and set the database connection values. For a
67
+ PostgreSQL project, initialize the database schema before starting the app:
68
+
69
+ ```bash
70
+ pyarch db init
71
+ ```
68
72
 
69
73
  Start the generated application:
70
74
 
@@ -72,12 +76,17 @@ Start the generated application:
72
76
  docker compose up -d
73
77
  ```
74
78
 
75
- After adding a generated module or integration that changes the database
76
- schema, create a revision with
77
- `uv run alembic revision --autogenerate -m "describe schema change"`. Then
78
- apply it with `uv run alembic upgrade head`.
79
- PyArch never autogenerates revisions during container startup: migration files
80
- are source code and should be reviewed and committed.
79
+ After a model change in a PostgreSQL project, generate and apply a reviewed
80
+ revision and restart the application with:
81
+
82
+ ```bash
83
+ pyarch db upgrade --message "describe schema change"
84
+ ```
85
+
86
+ Without `--message`, PyArch prompts for one. When Alembic finds no metadata
87
+ changes, `db upgrade` restarts Compose but creates no empty revision. Compose
88
+ never runs migrations implicitly; migration files remain source code and should
89
+ be reviewed and committed.
81
90
 
82
91
  ## Safe Generation
83
92
 
@@ -92,12 +101,16 @@ Open `http://127.0.0.1:8000/docs` to use the generated Swagger UI.
92
101
  You can now extend the project:
93
102
 
94
103
  ```bash
95
- pyarch generate module users
104
+ pyarch generate module user
96
105
  pyarch add integration auth
97
- pyarch generate module tasks --protected
106
+ pyarch generate module task --protected
98
107
  pyarch info
99
108
  ```
100
109
 
110
+ Module names must be singular identifiers. PyArch derives the plural table and
111
+ route names from them: use `user` to generate `/users` and the `users` table,
112
+ not `users`.
113
+
101
114
  ## What Gets Generated
102
115
 
103
116
  A new project includes the application layers, database configuration, test
@@ -137,9 +150,9 @@ Each generated CRUD module adds:
137
150
  | ------------------------------------------- | ------------------------------------------------ |
138
151
  | `pyarch init <name>` | Create a Layered FastAPI project |
139
152
  | `pyarch init <name> --database <engine>` | Select PostgreSQL or SQLite |
140
- | `pyarch generate module <name>` | Add a CRUD module to the current project |
153
+ | `pyarch generate module <singular-name>` | Add a CRUD module to the current project |
141
154
  | `pyarch add integration auth` | Add JWT authentication and user management |
142
- | `pyarch generate module <name> --protected` | Generate CRUD routes that require authentication |
155
+ | `pyarch generate module <singular-name> --protected` | Generate protected CRUD routes |
143
156
  | `pyarch info` | Show the current project configuration |
144
157
  | `pyarch --help` | Show CLI help |
145
158
 
@@ -156,6 +169,9 @@ Current limitations:
156
169
 
157
170
  - only Layered Architecture is supported;
158
171
  - generated applications use synchronous database access;
172
+ - SQLite projects run locally and do not include Docker Compose; `pyarch db`
173
+ lifecycle commands are PostgreSQL-only. SQLite migrations can be run with
174
+ Alembic directly;
159
175
  - generated projects are starter scaffolds and still require
160
176
  application-specific configuration and code;
161
177
  - the manifest format may change before a stable release.
@@ -255,11 +271,17 @@ instead of producing incomplete files.
255
271
 
256
272
  ## Roadmap
257
273
 
258
- ### v0.2.0 (current)
274
+ ### v0.2.1 (current)
275
+
276
+ - singular module-name contract and corrected SQLite workflow documentation;
277
+ - generated GitHub Actions workflow for linting and tests;
278
+ - package and generated-manifest versions kept in sync.
279
+
280
+ ### v0.2.0
259
281
 
260
282
  - atomic project creation and cleanup on failure;
261
283
  - rollback for failed module and auth generation;
262
- - PostgreSQL- and SQLite-specific Compose templates;
284
+ - PostgreSQL Compose template and SQLite local setup;
263
285
  - self-test suite and generated-project integration coverage.
264
286
 
265
287
  ### v0.3
@@ -277,6 +299,6 @@ instead of producing incomplete files.
277
299
 
278
300
  ## Status
279
301
 
280
- PyArch v0.2.0 is an early alpha release. The main workflow is usable, but
302
+ PyArch v0.2.1 is an early alpha release. The main workflow is usable, but
281
303
  commands, templates, generated code and the manifest may still change before a
282
304
  stable release.
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "PyArch-CLI"
3
- version = "0.2.0"
3
+ version = "0.2.1"
4
4
  description = "Stateful CLI generator for Layered FastAPI projects"
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.13"
@@ -0,0 +1 @@
1
+ __version__ = "0.2.1"
@@ -1,6 +1,7 @@
1
1
  import typer
2
2
 
3
3
  from pyarch.cli.add import app as add_app
4
+ from pyarch.cli.db import app as db_app
4
5
  from pyarch.cli.generate import app as generate_app
5
6
  from pyarch.cli.info import show_info
6
7
  from pyarch.cli.init import init_project
@@ -27,3 +28,9 @@ app.add_typer(
27
28
  name="add",
28
29
  help="Add project integrations.",
29
30
  )
31
+
32
+ app.add_typer(
33
+ db_app,
34
+ name="db",
35
+ help="Create and apply database migrations.",
36
+ )
@@ -6,6 +6,8 @@ import typer
6
6
  from rich.console import Console
7
7
 
8
8
  console = Console()
9
+
10
+
9
11
  def execute_or_exit[ResultT](action: Callable[[], ResultT]) -> ResultT:
10
12
  try:
11
13
  return action()
@@ -0,0 +1,47 @@
1
+ from typing import Annotated
2
+
3
+ import typer
4
+
5
+ from pyarch.cli.common import console, execute_or_exit
6
+ from pyarch.services.database import initialize_database, upgrade_database
7
+
8
+ app = typer.Typer(no_args_is_help=True)
9
+
10
+
11
+ @app.command("init")
12
+ def initialize_database_command() -> None:
13
+ """Create and apply the initial database revision without starting the app."""
14
+
15
+ project_root = execute_or_exit(initialize_database)
16
+ console.print(
17
+ f"[green]Database initialized[/green] in [bold]{project_root}[/bold]. "
18
+ "The application was not started."
19
+ )
20
+
21
+
22
+ @app.command("upgrade")
23
+ def upgrade_database_command(
24
+ message: Annotated[
25
+ str | None,
26
+ typer.Option("--message", "-m", help="Message for the Alembic revision."),
27
+ ] = None,
28
+ ) -> None:
29
+ """Generate, apply, and restart the application with a schema revision."""
30
+
31
+ migration_message = message
32
+ if migration_message is None:
33
+ migration_message = typer.prompt("Migration message")
34
+
35
+ project_root, schema_changed = execute_or_exit(
36
+ lambda: upgrade_database(migration_message)
37
+ )
38
+ if not schema_changed:
39
+ console.print(
40
+ "[yellow]No schema changes detected; Compose was restarted without a migration.[/yellow]"
41
+ )
42
+ return
43
+
44
+ console.print(
45
+ f"[green]Database upgraded and Compose restarted[/green] in "
46
+ f"[bold]{project_root}[/bold]"
47
+ )
@@ -114,7 +114,7 @@ def load_manifest(project_dir: Path) -> ProjectManifest:
114
114
 
115
115
 
116
116
  def save_manifest(project_dir: Path, manifest: ProjectManifest) -> Path:
117
-
117
+
118
118
  manifest_path = project_dir / MANIFEST_NAME
119
119
  temporary_path = manifest_path.with_suffix(".toml.tmp")
120
120
 
@@ -1,58 +1,58 @@
1
1
  from collections.abc import Iterator
2
2
  from contextlib import contextmanager
3
3
  from pathlib import Path
4
-
5
-
6
- def create_empty_dir(directory: Path) -> Path:
7
- directory.mkdir(parents=True, exist_ok=True)
8
- return directory
9
-
10
-
11
- def create_empty_file(file: Path) -> Path:
12
- file.parent.mkdir(parents=True, exist_ok=True)
13
- file.touch(exist_ok=True)
14
- return file
15
-
16
-
17
- def init_py_module(directory: Path) -> Path:
18
- directory.mkdir(parents=True, exist_ok=True)
19
- init = directory / "__init__.py"
20
- init.touch(exist_ok=True)
21
- return init
22
-
23
-
24
- def create_module_path(directory: Path) -> Path:
25
- create_empty_dir(directory)
26
- init_py_module(directory)
27
- return directory
28
-
29
-
30
- def insert_line_before_marker(
31
- file_path: Path,
32
- marker: str,
33
- line: str,
34
- ) -> bool:
35
- content = file_path.read_text(encoding="utf-8")
36
-
37
- if line in content.splitlines():
38
- return False
39
-
40
- if marker not in content:
41
- raise ValueError(f"Marker {marker!r} was not found in {file_path}")
42
-
43
- updated_content = content.replace(marker, f"{line}\n{marker}", 1)
44
- file_path.write_text(updated_content, encoding="utf-8")
45
- return True
46
-
47
-
4
+
5
+
6
+ def create_empty_dir(directory: Path) -> Path:
7
+ directory.mkdir(parents=True, exist_ok=True)
8
+ return directory
9
+
10
+
11
+ def create_empty_file(file: Path) -> Path:
12
+ file.parent.mkdir(parents=True, exist_ok=True)
13
+ file.touch(exist_ok=True)
14
+ return file
15
+
16
+
17
+ def init_py_module(directory: Path) -> Path:
18
+ directory.mkdir(parents=True, exist_ok=True)
19
+ init = directory / "__init__.py"
20
+ init.touch(exist_ok=True)
21
+ return init
22
+
23
+
24
+ def create_module_path(directory: Path) -> Path:
25
+ create_empty_dir(directory)
26
+ init_py_module(directory)
27
+ return directory
28
+
29
+
30
+ def insert_line_before_marker(
31
+ file_path: Path,
32
+ marker: str,
33
+ line: str,
34
+ ) -> bool:
35
+ content = file_path.read_text(encoding="utf-8")
36
+
37
+ if line in content.splitlines():
38
+ return False
39
+
40
+ if marker not in content:
41
+ raise ValueError(f"Marker {marker!r} was not found in {file_path}")
42
+
43
+ updated_content = content.replace(marker, f"{line}\n{marker}", 1)
44
+ file_path.write_text(updated_content, encoding="utf-8")
45
+ return True
46
+
47
+
48
48
  def append_text_once(file_path: Path, marker: str, text: str) -> bool:
49
- content = file_path.read_text(encoding="utf-8") if file_path.exists() else ""
50
-
51
- if marker in content:
52
- return False
53
-
54
- separator = "" if not content or content.endswith("\n") else "\n"
55
- file_path.parent.mkdir(parents=True, exist_ok=True)
49
+ content = file_path.read_text(encoding="utf-8") if file_path.exists() else ""
50
+
51
+ if marker in content:
52
+ return False
53
+
54
+ separator = "" if not content or content.endswith("\n") else "\n"
55
+ file_path.parent.mkdir(parents=True, exist_ok=True)
56
56
  file_path.write_text(f"{content}{separator}{text}", encoding="utf-8")
57
57
  return True
58
58
 
@@ -82,7 +82,9 @@ def rollback_file_changes(
82
82
  file_path.parent.mkdir(parents=True, exist_ok=True)
83
83
  file_path.write_bytes(content)
84
84
 
85
- for directory in sorted(created_directories, key=lambda path: len(path.parts), reverse=True):
85
+ for directory in sorted(
86
+ created_directories, key=lambda path: len(path.parts), reverse=True
87
+ ):
86
88
  try:
87
89
  directory.rmdir()
88
90
  except OSError: