PyArch-CLI 0.2.1__tar.gz → 0.3.0__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 (104) hide show
  1. {pyarch_cli-0.2.1 → pyarch_cli-0.3.0}/.gitignore +15 -12
  2. {pyarch_cli-0.2.1 → pyarch_cli-0.3.0}/.python-version +1 -1
  3. {pyarch_cli-0.2.1 → pyarch_cli-0.3.0}/PKG-INFO +55 -22
  4. {pyarch_cli-0.2.1 → pyarch_cli-0.3.0}/README.md +339 -304
  5. {pyarch_cli-0.2.1 → pyarch_cli-0.3.0}/assets/Dockerfile.vhs +11 -11
  6. {pyarch_cli-0.2.1 → pyarch_cli-0.3.0}/assets/pyarch-demo.tape +37 -37
  7. {pyarch_cli-0.2.1 → pyarch_cli-0.3.0}/assets/vhs-uv +17 -17
  8. {pyarch_cli-0.2.1 → pyarch_cli-0.3.0}/pyproject.toml +48 -48
  9. pyarch_cli-0.3.0/src/pyarch/__init__.py +1 -0
  10. {pyarch_cli-0.2.1 → pyarch_cli-0.3.0}/src/pyarch/cli/__init__.py +1 -1
  11. {pyarch_cli-0.2.1 → pyarch_cli-0.3.0}/src/pyarch/cli/app.py +36 -36
  12. {pyarch_cli-0.2.1 → pyarch_cli-0.3.0}/src/pyarch/cli/common.py +26 -26
  13. {pyarch_cli-0.2.1 → pyarch_cli-0.3.0}/src/pyarch/cli/db.py +48 -47
  14. pyarch_cli-0.3.0/src/pyarch/cli/init.py +65 -0
  15. {pyarch_cli-0.2.1 → pyarch_cli-0.3.0}/src/pyarch/config/__init__.py +1 -1
  16. {pyarch_cli-0.2.1 → pyarch_cli-0.3.0}/src/pyarch/config/manifest.py +190 -164
  17. pyarch_cli-0.3.0/src/pyarch/config/models.py +93 -0
  18. {pyarch_cli-0.2.1 → pyarch_cli-0.3.0}/src/pyarch/generators/__init__.py +1 -1
  19. {pyarch_cli-0.2.1 → pyarch_cli-0.3.0}/src/pyarch/generators/common/__init__.py +1 -1
  20. {pyarch_cli-0.2.1 → pyarch_cli-0.3.0}/src/pyarch/generators/common/commands.py +6 -6
  21. {pyarch_cli-0.2.1 → pyarch_cli-0.3.0}/src/pyarch/generators/common/filesystem.py +79 -93
  22. {pyarch_cli-0.2.1 → pyarch_cli-0.3.0}/src/pyarch/generators/common/renderer.py +31 -31
  23. pyarch_cli-0.3.0/src/pyarch/generators/common/source_edit.py +322 -0
  24. {pyarch_cli-0.2.1 → pyarch_cli-0.3.0}/src/pyarch/generators/integration/auth.py +72 -25
  25. {pyarch_cli-0.2.1 → pyarch_cli-0.3.0}/src/pyarch/generators/module/__init__.py +1 -1
  26. {pyarch_cli-0.2.1 → pyarch_cli-0.3.0}/src/pyarch/generators/module/layered.py +186 -167
  27. {pyarch_cli-0.2.1 → pyarch_cli-0.3.0}/src/pyarch/generators/project/__init__.py +1 -1
  28. {pyarch_cli-0.2.1 → pyarch_cli-0.3.0}/src/pyarch/generators/project/base.py +52 -11
  29. {pyarch_cli-0.2.1 → pyarch_cli-0.3.0}/src/pyarch/generators/project/layered.py +190 -158
  30. {pyarch_cli-0.2.1 → pyarch_cli-0.3.0}/src/pyarch/main.py +9 -9
  31. {pyarch_cli-0.2.1 → pyarch_cli-0.3.0}/src/pyarch/services/__init__.py +1 -1
  32. {pyarch_cli-0.2.1 → pyarch_cli-0.3.0}/src/pyarch/services/add_integration.py +68 -65
  33. {pyarch_cli-0.2.1 → pyarch_cli-0.3.0}/src/pyarch/services/create_module.py +1 -0
  34. {pyarch_cli-0.2.1 → pyarch_cli-0.3.0}/src/pyarch/services/create_project.py +41 -37
  35. pyarch_cli-0.3.0/src/pyarch/services/database.py +228 -0
  36. {pyarch_cli-0.2.1 → pyarch_cli-0.3.0}/src/pyarch/templates/layered/alembic_env.py.j2 +57 -57
  37. pyarch_cli-0.3.0/src/pyarch/templates/layered/auth/config.py.j2 +13 -0
  38. {pyarch_cli-0.2.1 → pyarch_cli-0.3.0}/src/pyarch/templates/layered/auth/dependencies.py.j2 +5 -5
  39. {pyarch_cli-0.2.1 → pyarch_cli-0.3.0}/src/pyarch/templates/layered/auth/refresh_session_model.py.j2 +6 -1
  40. {pyarch_cli-0.2.1 → pyarch_cli-0.3.0}/src/pyarch/templates/layered/auth/routes.py.j2 +16 -16
  41. pyarch_cli-0.3.0/src/pyarch/templates/layered/auth/schemas.py.j2 +55 -0
  42. {pyarch_cli-0.2.1 → pyarch_cli-0.3.0}/src/pyarch/templates/layered/auth/service.py.j2 +56 -40
  43. {pyarch_cli-0.2.1 → pyarch_cli-0.3.0}/src/pyarch/templates/layered/auth/test_auth.py.j2 +195 -117
  44. {pyarch_cli-0.2.1 → pyarch_cli-0.3.0}/src/pyarch/templates/layered/auth/test_helpers.py.j2 +47 -47
  45. {pyarch_cli-0.2.1 → pyarch_cli-0.3.0}/src/pyarch/templates/layered/auth/tokens.py.j2 +5 -5
  46. {pyarch_cli-0.2.1 → pyarch_cli-0.3.0}/src/pyarch/templates/layered/auth/user_model.py.j2 +3 -3
  47. {pyarch_cli-0.2.1 → pyarch_cli-0.3.0}/src/pyarch/templates/layered/auth/utils.py.j2 +4 -6
  48. {pyarch_cli-0.2.1 → pyarch_cli-0.3.0}/src/pyarch/templates/layered/config.py.j2 +25 -22
  49. {pyarch_cli-0.2.1 → pyarch_cli-0.3.0}/src/pyarch/templates/layered/env.example.j2 +17 -16
  50. {pyarch_cli-0.2.1 → pyarch_cli-0.3.0}/src/pyarch/templates/layered/errors.py.j2 +5 -6
  51. {pyarch_cli-0.2.1 → pyarch_cli-0.3.0}/src/pyarch/templates/layered/exception_handlers.py.j2 +13 -13
  52. {pyarch_cli-0.2.1 → pyarch_cli-0.3.0}/src/pyarch/templates/layered/models_init.py.j2 +5 -4
  53. {pyarch_cli-0.2.1 → pyarch_cli-0.3.0}/src/pyarch/templates/layered/module/module_model.py.j2 +13 -13
  54. {pyarch_cli-0.2.1 → pyarch_cli-0.3.0}/src/pyarch/templates/layered/module/module_repo.py.j2 +63 -57
  55. {pyarch_cli-0.2.1 → pyarch_cli-0.3.0}/src/pyarch/templates/layered/module/module_router.py.j2 +59 -59
  56. {pyarch_cli-0.2.1 → pyarch_cli-0.3.0}/src/pyarch/templates/layered/module/module_router_protected.py.j2 +73 -73
  57. {pyarch_cli-0.2.1 → pyarch_cli-0.3.0}/src/pyarch/templates/layered/module/module_schema.py.j2 +23 -23
  58. {pyarch_cli-0.2.1 → pyarch_cli-0.3.0}/src/pyarch/templates/layered/module/module_service.py.j2 +73 -65
  59. {pyarch_cli-0.2.1 → pyarch_cli-0.3.0}/src/pyarch/templates/layered/module/module_test.py.j2 +43 -43
  60. {pyarch_cli-0.2.1 → pyarch_cli-0.3.0}/src/pyarch/templates/layered/module/module_test_protected.py.j2 +70 -70
  61. {pyarch_cli-0.2.1 → pyarch_cli-0.3.0}/src/pyarch/templates/layered/pagination.py.j2 +22 -22
  62. {pyarch_cli-0.2.1 → pyarch_cli-0.3.0}/src/pyarch/templates/layered/router.py.j2 +7 -7
  63. {pyarch_cli-0.2.1 → pyarch_cli-0.3.0}/src/pyarch/templates/layered/session.py.j2 +33 -33
  64. {pyarch_cli-0.2.1 → pyarch_cli-0.3.0}/src/pyarch/templates/project/base/Dockerfile.j2 +2 -2
  65. {pyarch_cli-0.2.1 → pyarch_cli-0.3.0}/src/pyarch/templates/project/base/README.md.j2 +39 -39
  66. {pyarch_cli-0.2.1 → pyarch_cli-0.3.0}/src/pyarch/templates/project/base/ci.yml.j2 +26 -26
  67. {pyarch_cli-0.2.1 → pyarch_cli-0.3.0}/src/pyarch/templates/project/base/conftest.py.j2 +73 -49
  68. {pyarch_cli-0.2.1 → pyarch_cli-0.3.0}/src/pyarch/templates/project/base/docker-compose.postgres.yml.j2 +44 -43
  69. {pyarch_cli-0.2.1 → pyarch_cli-0.3.0}/src/pyarch/templates/project/base/docker-compose.sqlite.yml.j2 +6 -6
  70. pyarch_cli-0.3.0/src/pyarch/templates/project/base/dockerignore.j2 +14 -0
  71. {pyarch_cli-0.2.1 → pyarch_cli-0.3.0}/src/pyarch/templates/project/base/main.py.j2 +8 -8
  72. pyarch_cli-0.3.0/src/pyarch/templates/project/base/ruff.toml.j2 +16 -0
  73. {pyarch_cli-0.2.1 → pyarch_cli-0.3.0}/tests/integration/test_generated_project.py +77 -68
  74. pyarch_cli-0.3.0/tests/integration/test_project_generation.py +203 -0
  75. pyarch_cli-0.3.0/tests/unit/test_auth_integration.py +172 -0
  76. {pyarch_cli-0.2.1 → pyarch_cli-0.3.0}/tests/unit/test_database_cli.py +57 -57
  77. pyarch_cli-0.3.0/tests/unit/test_database_service.py +380 -0
  78. {pyarch_cli-0.2.1 → pyarch_cli-0.3.0}/tests/unit/test_filesystem.py +30 -30
  79. pyarch_cli-0.3.0/tests/unit/test_manifest.py +153 -0
  80. pyarch_cli-0.3.0/tests/unit/test_module_generator.py +163 -0
  81. pyarch_cli-0.3.0/tests/unit/test_source_edit.py +558 -0
  82. pyarch_cli-0.3.0/tests/unit/test_templates.py +209 -0
  83. {pyarch_cli-0.2.1 → pyarch_cli-0.3.0}/uv.lock +567 -565
  84. pyarch_cli-0.2.1/src/pyarch/__init__.py +0 -1
  85. pyarch_cli-0.2.1/src/pyarch/cli/init.py +0 -34
  86. pyarch_cli-0.2.1/src/pyarch/config/models.py +0 -50
  87. pyarch_cli-0.2.1/src/pyarch/services/database.py +0 -110
  88. pyarch_cli-0.2.1/src/pyarch/templates/layered/auth/config.py.j2 +0 -35
  89. pyarch_cli-0.2.1/src/pyarch/templates/layered/auth/schemas.py.j2 +0 -31
  90. pyarch_cli-0.2.1/src/pyarch/templates/project/base/dockerignore.j2 +0 -12
  91. pyarch_cli-0.2.1/src/pyarch/templates/project/base/ruff.toml.j2 +0 -8
  92. pyarch_cli-0.2.1/tests/integration/test_project_generation.py +0 -97
  93. pyarch_cli-0.2.1/tests/unit/test_database_service.py +0 -162
  94. pyarch_cli-0.2.1/tests/unit/test_manifest.py +0 -29
  95. pyarch_cli-0.2.1/tests/unit/test_module_generator.py +0 -43
  96. pyarch_cli-0.2.1/tests/unit/test_templates.py +0 -79
  97. {pyarch_cli-0.2.1 → pyarch_cli-0.3.0}/.github/workflows/ci.yml +0 -0
  98. {pyarch_cli-0.2.1 → pyarch_cli-0.3.0}/LICENSE +0 -0
  99. {pyarch_cli-0.2.1 → pyarch_cli-0.3.0}/assets/pyarch-demo.gif +0 -0
  100. {pyarch_cli-0.2.1 → pyarch_cli-0.3.0}/src/pyarch/cli/add.py +0 -0
  101. {pyarch_cli-0.2.1 → pyarch_cli-0.3.0}/src/pyarch/cli/generate.py +0 -0
  102. {pyarch_cli-0.2.1 → pyarch_cli-0.3.0}/src/pyarch/cli/info.py +0 -0
  103. {pyarch_cli-0.2.1 → pyarch_cli-0.3.0}/src/pyarch/generators/common/gitignore.py +0 -0
  104. {pyarch_cli-0.2.1 → pyarch_cli-0.3.0}/src/pyarch/generators/integration/__init__.py +0 -0
@@ -1,12 +1,15 @@
1
- # Python-generated files
2
- __pycache__/
3
- *.py[oc]
4
- build/
5
- *dist
6
- dist/
7
- wheels/
8
- *.egg-info
9
- *_cache
10
-
11
- # Virtual environments
12
- .venv
1
+ # Python-generated files
2
+ __pycache__/
3
+ *.py[oc]
4
+ build/
5
+ *dist
6
+ dist/
7
+ wheels/
8
+ *.egg-info
9
+ *_cache
10
+
11
+ # Virtual environments
12
+ .venv
13
+
14
+ # OMP agent workspace
15
+ .omp/
@@ -1 +1 @@
1
- 3.13
1
+ 3.13
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: PyArch-CLI
3
- Version: 0.2.1
3
+ Version: 0.3.0
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
@@ -19,9 +19,7 @@ Classifier: Topic :: Software Development :: Code Generators
19
19
  Requires-Python: >=3.13
20
20
  Requires-Dist: cryptography>=46.0.3
21
21
  Requires-Dist: jinja2>=3.1.6
22
- Requires-Dist: mypy>=2.3.0
23
22
  Requires-Dist: rich>=15.0.0
24
- Requires-Dist: ruff>=0.16.1
25
23
  Requires-Dist: tomlkit>=0.15.0
26
24
  Requires-Dist: typer>=0.24.2
27
25
  Description-Content-Type: text/markdown
@@ -34,7 +32,7 @@ Description-Content-Type: text/markdown
34
32
  ![Typer](https://img.shields.io/badge/Typer-CLI-purple)
35
33
  ![Jinja2](https://img.shields.io/badge/Jinja2-templates-orange)
36
34
  ![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)
37
- ![Status](https://img.shields.io/badge/status-v0.2.1-blue)
35
+ ![Status](https://img.shields.io/badge/status-v0.3.0-blue)
38
36
 
39
37
  PyArch is a CLI for creating and extending Layered FastAPI projects. It sets up
40
38
  the application structure, database, tests and Alembic, then lets you add CRUD
@@ -65,13 +63,25 @@ ready to change.
65
63
  - Project-aware generation through `pyarch.toml`
66
64
  - Atomic project creation and rollback for failed extensions
67
65
 
68
- ## v0.2.1 Highlights
69
-
70
- - Atomic project creation through a staging directory, with cleanup on failure
71
- - Rollback for failed module and auth generation
72
- - Docker Compose support for PostgreSQL projects
73
- - Refresh-token rotation protected against concurrent reuse on PostgreSQL
74
- - Self-tests for PyArch and an end-to-end generated-project workflow
66
+ ## v0.3.0 Highlights
67
+
68
+ - `ruff` and `mypy` moved to dev dependencies, keeping the installed CLI lean
69
+ - Auth settings live in `app/auth/config.py` and are registered in
70
+ `app/core/config.py` instead of overwriting the core config file
71
+ - Registration works without `# pyarch:*` markers: when a marker is missing
72
+ (older projects or user edits), PyArch finds the insertion point in the
73
+ Python syntax tree, so no manual edits are needed
74
+ - Password policy for auth users: at least 8 characters with uppercase,
75
+ lowercase, digit and special characters, limited to 72 bytes
76
+ - Refresh-token reuse detection revokes the whole token family
77
+ - Configurable application, tests and migrations directories
78
+ (`--app-dir`, `--tests-dir`, `--migrations-dir`), honored by every generator
79
+ - `pyarch db upgrade` restarts only the API service, waits until it is healthy,
80
+ and detects Compose service names automatically
81
+ - Zero manual setup: `.env` is created with working local defaults, host ports
82
+ are configurable via `POSTGRES_PORT` / `API_PORT`, the test database is
83
+ created automatically, and the project is pinned to Python 3.13 to match the
84
+ Docker image and CI
75
85
 
76
86
  ## Quick Start
77
87
 
@@ -91,8 +101,12 @@ pyarch init my_project --database postgres
91
101
  cd my_project
92
102
  ```
93
103
 
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:
104
+ `pyarch init` creates a ready-to-run `.env` from `.env.example` (local
105
+ PostgreSQL credentials `postgres`/`postgres`, database `app`). If host ports
106
+ 5432 or 8000 are taken, change `POSTGRES_PORT` / `API_PORT` in `.env` (and the
107
+ port in `DATABASE_URL` / `TEST_DATABASE_URL`). The test suite creates the
108
+ `app_test` database on the same server automatically. For a PostgreSQL
109
+ project, initialize the database schema before starting the app:
96
110
 
97
111
  ```bash
98
112
  pyarch db init
@@ -111,10 +125,15 @@ revision and restart the application with:
111
125
  pyarch db upgrade --message "describe schema change"
112
126
  ```
113
127
 
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.
128
+ Without `--message`, PyArch prompts for one. Only the API service is stopped
129
+ and rebuilt; the database service keeps running. PyArch detects both Compose
130
+ service names from `docker compose config` (the service with a `build` key and
131
+ the one running a `postgres` image), so renaming them is fine; when detection
132
+ is ambiguous, pin the names in `pyarch.toml` with
133
+ `[compose] api_service = "..."` / `db_service = "..."`. When Alembic finds no
134
+ metadata changes, `db upgrade` restarts the API service but creates no empty
135
+ revision. Compose never runs migrations implicitly; migration files remain
136
+ source code and should be reviewed and committed.
118
137
 
119
138
  ## Safe Generation
120
139
 
@@ -158,6 +177,7 @@ my_project/
158
177
  │ └── main.py
159
178
  ├── tests/
160
179
  ├── alembic/ # PostgreSQL and SQLite only
180
+ ├── .env # created from .env.example, git-ignored
161
181
  ├── .env.example
162
182
  ├── pyarch.toml
163
183
  └── pyproject.toml
@@ -178,6 +198,7 @@ Each generated CRUD module adds:
178
198
  | ------------------------------------------- | ------------------------------------------------ |
179
199
  | `pyarch init <name>` | Create a Layered FastAPI project |
180
200
  | `pyarch init <name> --database <engine>` | Select PostgreSQL or SQLite |
201
+ | `pyarch init <name> --app-dir <pkg> --tests-dir <pkg> --migrations-dir <path>` | Custom application package, tests package and Alembic directory |
181
202
  | `pyarch generate module <singular-name>` | Add a CRUD module to the current project |
182
203
  | `pyarch add integration auth` | Add JWT authentication and user management |
183
204
  | `pyarch generate module <singular-name> --protected` | Generate protected CRUD routes |
@@ -283,8 +304,10 @@ not have to guess the architecture, database or enabled features.
283
304
  <summary>Why marker-based registration?</summary>
284
305
 
285
306
  PyArch modifies files it generated itself. Explicit markers provide stable and
286
- readable insertion points for model and router imports without requiring a full
287
- AST rewriting pipeline.
307
+ readable insertion points for model, router and settings registration. When a
308
+ marker is missing, PyArch falls back to the Python syntax tree: imports go after
309
+ the last import, settings fields into the `Settings` class, model names into
310
+ `__all__` and router includes to the end of the router module.
288
311
 
289
312
  </details>
290
313
 
@@ -299,7 +322,17 @@ instead of producing incomplete files.
299
322
 
300
323
  ## Roadmap
301
324
 
302
- ### v0.2.1 (current)
325
+ ### v0.3.0 (current)
326
+
327
+ - dev-only linting and type-checking dependencies for the CLI itself;
328
+ - auth settings registration that preserves the core config;
329
+ - marker-free fallback registration via the Python syntax tree;
330
+ - password policy and refresh-token family revocation on reuse;
331
+ - configurable project paths honored by every generator;
332
+ - API-only restart with auto-detected Compose service names;
333
+ - ready-to-run `.env`, configurable host ports, auto-created test database.
334
+
335
+ ### v0.2.1
303
336
 
304
337
  - singular module-name contract and corrected SQLite workflow documentation;
305
338
  - generated GitHub Actions workflow for linting and tests;
@@ -312,7 +345,7 @@ instead of producing incomplete files.
312
345
  - PostgreSQL Compose template and SQLite local setup;
313
346
  - self-test suite and generated-project integration coverage.
314
347
 
315
- ### v0.3
348
+ ### v0.4
316
349
 
317
350
  - Redis integration foundation;
318
351
  - opt-in cache-aside generation for CRUD modules;
@@ -327,6 +360,6 @@ instead of producing incomplete files.
327
360
 
328
361
  ## Status
329
362
 
330
- PyArch v0.2.1 is an early alpha release. The main workflow is usable, but
363
+ PyArch v0.3.0 is an early alpha release. The main workflow is usable, but
331
364
  commands, templates, generated code and the manifest may still change before a
332
365
  stable release.