codefortify-starter 1.0.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 (69) hide show
  1. codefortify_starter-1.0.0/LICENSE +22 -0
  2. codefortify_starter-1.0.0/MANIFEST.in +4 -0
  3. codefortify_starter-1.0.0/PKG-INFO +276 -0
  4. codefortify_starter-1.0.0/README.md +245 -0
  5. codefortify_starter-1.0.0/codefortify_starter/__init__.py +7 -0
  6. codefortify_starter-1.0.0/codefortify_starter/__main__.py +6 -0
  7. codefortify_starter-1.0.0/codefortify_starter/cli.py +103 -0
  8. codefortify_starter-1.0.0/codefortify_starter/constants.py +48 -0
  9. codefortify_starter-1.0.0/codefortify_starter/generator.py +246 -0
  10. codefortify_starter-1.0.0/codefortify_starter/template_engine.py +63 -0
  11. codefortify_starter-1.0.0/codefortify_starter/templates/base_project/README.md.jinja +87 -0
  12. codefortify_starter-1.0.0/codefortify_starter/templates/base_project/apps/__init__.py +1 -0
  13. codefortify_starter-1.0.0/codefortify_starter/templates/base_project/apps/home/__init__.py +1 -0
  14. codefortify_starter-1.0.0/codefortify_starter/templates/base_project/apps/home/apps.py.jinja +7 -0
  15. codefortify_starter-1.0.0/codefortify_starter/templates/base_project/apps/home/templates/home/index.html.jinja +25 -0
  16. codefortify_starter-1.0.0/codefortify_starter/templates/base_project/apps/home/tests.py.jinja +17 -0
  17. codefortify_starter-1.0.0/codefortify_starter/templates/base_project/apps/home/urls.py.jinja +14 -0
  18. codefortify_starter-1.0.0/codefortify_starter/templates/base_project/apps/home/views.py.jinja +13 -0
  19. codefortify_starter-1.0.0/codefortify_starter/templates/base_project/core/__init__.py.jinja +7 -0
  20. codefortify_starter-1.0.0/codefortify_starter/templates/base_project/core/asgi.py.jinja +10 -0
  21. codefortify_starter-1.0.0/codefortify_starter/templates/base_project/core/env.py.jinja +46 -0
  22. codefortify_starter-1.0.0/codefortify_starter/templates/base_project/core/middleware/__init__.py +1 -0
  23. codefortify_starter-1.0.0/codefortify_starter/templates/base_project/core/middleware/exceptions.py +26 -0
  24. codefortify_starter-1.0.0/codefortify_starter/templates/base_project/core/middleware/security.py +12 -0
  25. codefortify_starter-1.0.0/codefortify_starter/templates/base_project/core/settings/__init__.py +1 -0
  26. codefortify_starter-1.0.0/codefortify_starter/templates/base_project/core/settings/base.py.jinja +160 -0
  27. codefortify_starter-1.0.0/codefortify_starter/templates/base_project/core/settings/dev.py.jinja +8 -0
  28. codefortify_starter-1.0.0/codefortify_starter/templates/base_project/core/settings/production.py.jinja +21 -0
  29. codefortify_starter-1.0.0/codefortify_starter/templates/base_project/core/templates/errors/400.html +8 -0
  30. codefortify_starter-1.0.0/codefortify_starter/templates/base_project/core/templates/errors/403.html +8 -0
  31. codefortify_starter-1.0.0/codefortify_starter/templates/base_project/core/templates/errors/404.html +8 -0
  32. codefortify_starter-1.0.0/codefortify_starter/templates/base_project/core/templates/errors/405.html +8 -0
  33. codefortify_starter-1.0.0/codefortify_starter/templates/base_project/core/templates/errors/500.html +8 -0
  34. codefortify_starter-1.0.0/codefortify_starter/templates/base_project/core/urls.py.jinja +23 -0
  35. codefortify_starter-1.0.0/codefortify_starter/templates/base_project/core/views.py.jinja +56 -0
  36. codefortify_starter-1.0.0/codefortify_starter/templates/base_project/core/wsgi.py.jinja +10 -0
  37. codefortify_starter-1.0.0/codefortify_starter/templates/base_project/dot-env.example.jinja +66 -0
  38. codefortify_starter-1.0.0/codefortify_starter/templates/base_project/dot-gitignore +34 -0
  39. codefortify_starter-1.0.0/codefortify_starter/templates/base_project/manage.py.jinja +16 -0
  40. codefortify_starter-1.0.0/codefortify_starter/templates/base_project/static/css/main.css +19 -0
  41. codefortify_starter-1.0.0/codefortify_starter/templates/base_project/templates/base.html.jinja +19 -0
  42. codefortify_starter-1.0.0/codefortify_starter/templates/features/celery/apps/home/tasks.py.jinja +7 -0
  43. codefortify_starter-1.0.0/codefortify_starter/templates/features/celery/core/celery.py.jinja +16 -0
  44. codefortify_starter-1.0.0/codefortify_starter/templates/features/docker/DOCKER_README.md.jinja +67 -0
  45. codefortify_starter-1.0.0/codefortify_starter/templates/features/docker/Dockerfile.jinja +20 -0
  46. codefortify_starter-1.0.0/codefortify_starter/templates/features/docker/docker-compose.prod.yml.jinja +158 -0
  47. codefortify_starter-1.0.0/codefortify_starter/templates/features/docker/docker-compose.yml.jinja +208 -0
  48. codefortify_starter-1.0.0/codefortify_starter/templates/features/docker/docker_deploy.sh.jinja +132 -0
  49. codefortify_starter-1.0.0/codefortify_starter/templates/features/docker/dot-dockerignore +12 -0
  50. codefortify_starter-1.0.0/codefortify_starter/templates/features/docker/entrypoint.sh.jinja +95 -0
  51. codefortify_starter-1.0.0/codefortify_starter/templates/features/drf/apps/api/__init__.py +1 -0
  52. codefortify_starter-1.0.0/codefortify_starter/templates/features/drf/apps/api/apps.py.jinja +7 -0
  53. codefortify_starter-1.0.0/codefortify_starter/templates/features/drf/apps/api/serializers.py +7 -0
  54. codefortify_starter-1.0.0/codefortify_starter/templates/features/drf/apps/api/tests.py +11 -0
  55. codefortify_starter-1.0.0/codefortify_starter/templates/features/drf/apps/api/urls.py +11 -0
  56. codefortify_starter-1.0.0/codefortify_starter/templates/features/drf/apps/api/views.py +16 -0
  57. codefortify_starter-1.0.0/codefortify_starter/templates/features/htmx/templates/partials/example.html.jinja +5 -0
  58. codefortify_starter-1.0.0/codefortify_starter/validators.py +70 -0
  59. codefortify_starter-1.0.0/codefortify_starter.egg-info/PKG-INFO +276 -0
  60. codefortify_starter-1.0.0/codefortify_starter.egg-info/SOURCES.txt +67 -0
  61. codefortify_starter-1.0.0/codefortify_starter.egg-info/dependency_links.txt +1 -0
  62. codefortify_starter-1.0.0/codefortify_starter.egg-info/entry_points.txt +2 -0
  63. codefortify_starter-1.0.0/codefortify_starter.egg-info/requires.txt +3 -0
  64. codefortify_starter-1.0.0/codefortify_starter.egg-info/top_level.txt +1 -0
  65. codefortify_starter-1.0.0/pyproject.toml +71 -0
  66. codefortify_starter-1.0.0/setup.cfg +4 -0
  67. codefortify_starter-1.0.0/tests/test_cli.py +63 -0
  68. codefortify_starter-1.0.0/tests/test_generated_projects.py +168 -0
  69. codefortify_starter-1.0.0/tests/test_generator.py +256 -0
@@ -0,0 +1,22 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Codefortify
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
@@ -0,0 +1,4 @@
1
+ include README.md
2
+ include LICENSE
3
+ recursive-include codefortify_starter/templates *
4
+
@@ -0,0 +1,276 @@
1
+ Metadata-Version: 2.4
2
+ Name: codefortify-starter
3
+ Version: 1.0.0
4
+ Summary: A production-ready Django project generator with optional HTMX, DRF, Docker, Celery, Redis, PostgreSQL, and MySQL support.
5
+ Author-email: Codefortify <maintainers@codefortify.dev>
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/codefortify/codefortify-starter
8
+ Project-URL: Source, https://github.com/codefortify/codefortify-starter
9
+ Keywords: django,django-starter,django-boilerplate,project-generator,python,codefortify,htmx,drf,docker,celery,redis,postgresql,mysql,cookiecutter-alternative,backend
10
+ Classifier: Development Status :: 3 - Alpha
11
+ Classifier: Environment :: Console
12
+ Classifier: Framework :: Django
13
+ Classifier: Framework :: Django :: 5.2
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: License :: OSI Approved :: MIT License
16
+ Classifier: Operating System :: OS Independent
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3 :: Only
19
+ Classifier: Programming Language :: Python :: 3.10
20
+ Classifier: Programming Language :: Python :: 3.11
21
+ Classifier: Programming Language :: Python :: 3.12
22
+ Classifier: Topic :: Software Development :: Code Generators
23
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
24
+ Requires-Python: >=3.10
25
+ Description-Content-Type: text/markdown
26
+ License-File: LICENSE
27
+ Requires-Dist: typer<1.0.0,>=0.12.0
28
+ Requires-Dist: rich<14.0.0,>=13.7.0
29
+ Requires-Dist: Jinja2<4.0.0,>=3.1.0
30
+ Dynamic: license-file
31
+
32
+ # codefortify-starter
33
+
34
+ `codefortify-starter` is a professional Django project starter generator for building clean, scalable, and production-ready Django applications faster.
35
+
36
+ It creates a modern Django architecture with a structured settings layout, reusable app organization, environment-based configuration, templates, static/media setup, and optional support for HTMX, Django REST Framework, Docker, Celery, Redis, PostgreSQL, and MySQL.
37
+
38
+ Whether you need a simple Django MVT project or a full API-ready Dockerized architecture with background workers, `codefortify-starter` gives you a consistent foundation for starting new projects.
39
+
40
+ ## What It Is
41
+
42
+ `codefortify-starter` is a PyPI-installable Django project generator that helps developers quickly scaffold clean, maintainable, production-ready Django architectures.
43
+
44
+ By default, it generates a simple Django MVT project. With flags, it can add HTMX, DRF, Docker, Celery, Redis, PostgreSQL, and MySQL.
45
+
46
+ ## Why It Exists
47
+
48
+ Most Django projects repeat the same setup work: project layout, settings split, dependency wiring, env bootstrapping, and deployment scaffolding. `codefortify-starter` reduces that repeated effort and standardizes project initialization.
49
+
50
+ ## Who Should Use It
51
+
52
+ - Django developers starting new applications
53
+ - Teams that want a consistent starter architecture
54
+ - Backend/API engineers who need optional DRF, Docker, and Celery setup
55
+ - Developers who want a lightweight alternative to larger templating frameworks
56
+
57
+ ## Installation
58
+
59
+ Install from PyPI:
60
+
61
+ ```bash
62
+ pip install codefortify-starter
63
+ ```
64
+
65
+ Install an exact version:
66
+
67
+ ```bash
68
+ pip install codefortify-starter==1.0.0
69
+ ```
70
+
71
+ Verify the CLI:
72
+
73
+ ```bash
74
+ codefortify-startproject --help
75
+ ```
76
+
77
+ ## Quick Start
78
+
79
+ Create a basic Django MVT project:
80
+
81
+ ```bash
82
+ codefortify-startproject myproject
83
+ cd myproject
84
+ python -m venv .venv
85
+ source .venv/bin/activate
86
+ pip install -r requirements.txt
87
+ cp .env.example .env
88
+ python manage.py migrate
89
+ python manage.py runserver
90
+ ```
91
+
92
+ ## Supported CLI Flags
93
+
94
+ - `--htmx`
95
+ - `--drf`
96
+ - `--docker`
97
+ - `--celery`
98
+ - `--database [sqlite|postgres|mysql]`
99
+ - `--no-git`
100
+ - `--force`
101
+ - `--directory PATH`
102
+ - `--all`
103
+
104
+ ## Command Examples
105
+
106
+ ```bash
107
+ codefortify-startproject myproject
108
+ codefortify-startproject myproject --htmx
109
+ codefortify-startproject myproject --drf
110
+ codefortify-startproject myproject --docker
111
+ codefortify-startproject myproject --celery
112
+ codefortify-startproject myproject --docker --celery
113
+ codefortify-startproject myproject --drf --docker --celery
114
+ codefortify-startproject myproject --database postgres
115
+ codefortify-startproject myproject --database mysql
116
+ codefortify-startproject myproject --no-git
117
+ codefortify-startproject myproject --force
118
+ codefortify-startproject myproject --directory /path/to/projects
119
+ codefortify-startproject myproject --all
120
+ ```
121
+
122
+ `--all` is equivalent to:
123
+
124
+ ```bash
125
+ codefortify-startproject myproject --htmx --drf --docker --celery --database postgres
126
+ ```
127
+
128
+ ## Feature Matrix
129
+
130
+ | Feature | Flag | Description |
131
+ |---|---|---|
132
+ | Django MVT | default | Clean Django project with settings, templates, static/media, and home app |
133
+ | HTMX | `--htmx` | Adds `django-htmx`, middleware, and example partial views |
134
+ | Django REST Framework | `--drf` | Adds DRF, API app, API routes, serializers, and tests |
135
+ | Docker | `--docker` | Adds Dockerfile, docker-compose, entrypoint, deployment script, and Docker docs |
136
+ | Celery + Redis | `--celery` | Adds Celery config, Redis broker settings, and example task |
137
+ | PostgreSQL | `--database postgres` | Adds PostgreSQL-ready configuration |
138
+ | MySQL | `--database mysql` | Adds MySQL-ready configuration |
139
+ | Full stack | `--all` | Adds HTMX, DRF, Docker, Celery, Redis, and PostgreSQL |
140
+
141
+ ## Generated Architecture
142
+
143
+ ```text
144
+ myproject/
145
+ ├── apps/
146
+ │ └── home/
147
+ ├── core/
148
+ │ ├── settings/
149
+ │ │ ├── base.py
150
+ │ │ ├── dev.py
151
+ │ │ └── production.py
152
+ │ ├── urls.py
153
+ │ ├── asgi.py
154
+ │ └── wsgi.py
155
+ ├── templates/
156
+ ├── static/
157
+ ├── media/
158
+ ├── manage.py
159
+ ├── requirements.txt
160
+ ├── .env.example
161
+ └── README.md
162
+ ```
163
+
164
+ Feature-specific files are added only when their flags are selected (for example `apps/api`, `core/celery.py`, `Dockerfile`, compose files, and task modules).
165
+
166
+ ## Database Options
167
+
168
+ - Default without `--docker`: SQLite
169
+ - Default with `--docker`: PostgreSQL
170
+ - Explicit: `--database postgres`, `--database mysql`, or `--database sqlite`
171
+
172
+ Generated settings safely handle an empty `DATABASE_URL` and support local fallback behavior for development.
173
+
174
+ ## HTMX Usage
175
+
176
+ Generate with HTMX:
177
+
178
+ ```bash
179
+ codefortify-startproject myproject --htmx
180
+ ```
181
+
182
+ The generated project includes HTMX middleware and an example partial endpoint.
183
+
184
+ ## DRF Usage
185
+
186
+ Generate with DRF:
187
+
188
+ ```bash
189
+ codefortify-startproject myproject --drf
190
+ ```
191
+
192
+ The generated API app includes a health endpoint:
193
+
194
+ - `GET /api/health/`
195
+
196
+ ## Docker Usage
197
+
198
+ ```bash
199
+ codefortify-startproject myproject --docker
200
+ cd myproject
201
+ cp .env.example .env
202
+ docker compose build
203
+ docker compose up -d
204
+ docker compose exec web python manage.py migrate
205
+ ```
206
+
207
+ ## Celery Usage
208
+
209
+ Generate with Celery support:
210
+
211
+ ```bash
212
+ codefortify-startproject myproject --celery
213
+ ```
214
+
215
+ Run worker locally:
216
+
217
+ ```bash
218
+ celery -A core worker -l info
219
+ ```
220
+
221
+ ## Full Stack Usage
222
+
223
+ ```bash
224
+ codefortify-startproject myproject --all
225
+ cd myproject
226
+ cp .env.example .env
227
+ docker compose build
228
+ docker compose up -d
229
+ docker compose ps
230
+ ```
231
+
232
+ ## Local Development (This Package)
233
+
234
+ ```bash
235
+ python -m venv .pkgvenv
236
+ source .pkgvenv/bin/activate
237
+ pip install -r requirements.txt
238
+ pip install -e .
239
+ python -m pytest -q tests
240
+ ```
241
+
242
+ ## Build and Publish
243
+
244
+ Build and validate:
245
+
246
+ ```bash
247
+ rm -rf dist build *.egg-info
248
+ python -m build
249
+ twine check dist/*
250
+ ```
251
+
252
+ Publish to TestPyPI:
253
+
254
+ ```bash
255
+ twine upload --repository testpypi dist/*
256
+ ```
257
+
258
+ Publish to PyPI:
259
+
260
+ ```bash
261
+ twine upload dist/*
262
+ ```
263
+
264
+ ## Testing from TestPyPI
265
+
266
+ Use this only for testing pre-release package builds:
267
+
268
+ ```bash
269
+ pip install --index-url https://test.pypi.org/simple/ \
270
+ --extra-index-url https://pypi.org/simple \
271
+ codefortify-starter==1.0.0
272
+ ```
273
+
274
+ ## License
275
+
276
+ MIT License. See [LICENSE](LICENSE).
@@ -0,0 +1,245 @@
1
+ # codefortify-starter
2
+
3
+ `codefortify-starter` is a professional Django project starter generator for building clean, scalable, and production-ready Django applications faster.
4
+
5
+ It creates a modern Django architecture with a structured settings layout, reusable app organization, environment-based configuration, templates, static/media setup, and optional support for HTMX, Django REST Framework, Docker, Celery, Redis, PostgreSQL, and MySQL.
6
+
7
+ Whether you need a simple Django MVT project or a full API-ready Dockerized architecture with background workers, `codefortify-starter` gives you a consistent foundation for starting new projects.
8
+
9
+ ## What It Is
10
+
11
+ `codefortify-starter` is a PyPI-installable Django project generator that helps developers quickly scaffold clean, maintainable, production-ready Django architectures.
12
+
13
+ By default, it generates a simple Django MVT project. With flags, it can add HTMX, DRF, Docker, Celery, Redis, PostgreSQL, and MySQL.
14
+
15
+ ## Why It Exists
16
+
17
+ Most Django projects repeat the same setup work: project layout, settings split, dependency wiring, env bootstrapping, and deployment scaffolding. `codefortify-starter` reduces that repeated effort and standardizes project initialization.
18
+
19
+ ## Who Should Use It
20
+
21
+ - Django developers starting new applications
22
+ - Teams that want a consistent starter architecture
23
+ - Backend/API engineers who need optional DRF, Docker, and Celery setup
24
+ - Developers who want a lightweight alternative to larger templating frameworks
25
+
26
+ ## Installation
27
+
28
+ Install from PyPI:
29
+
30
+ ```bash
31
+ pip install codefortify-starter
32
+ ```
33
+
34
+ Install an exact version:
35
+
36
+ ```bash
37
+ pip install codefortify-starter==1.0.0
38
+ ```
39
+
40
+ Verify the CLI:
41
+
42
+ ```bash
43
+ codefortify-startproject --help
44
+ ```
45
+
46
+ ## Quick Start
47
+
48
+ Create a basic Django MVT project:
49
+
50
+ ```bash
51
+ codefortify-startproject myproject
52
+ cd myproject
53
+ python -m venv .venv
54
+ source .venv/bin/activate
55
+ pip install -r requirements.txt
56
+ cp .env.example .env
57
+ python manage.py migrate
58
+ python manage.py runserver
59
+ ```
60
+
61
+ ## Supported CLI Flags
62
+
63
+ - `--htmx`
64
+ - `--drf`
65
+ - `--docker`
66
+ - `--celery`
67
+ - `--database [sqlite|postgres|mysql]`
68
+ - `--no-git`
69
+ - `--force`
70
+ - `--directory PATH`
71
+ - `--all`
72
+
73
+ ## Command Examples
74
+
75
+ ```bash
76
+ codefortify-startproject myproject
77
+ codefortify-startproject myproject --htmx
78
+ codefortify-startproject myproject --drf
79
+ codefortify-startproject myproject --docker
80
+ codefortify-startproject myproject --celery
81
+ codefortify-startproject myproject --docker --celery
82
+ codefortify-startproject myproject --drf --docker --celery
83
+ codefortify-startproject myproject --database postgres
84
+ codefortify-startproject myproject --database mysql
85
+ codefortify-startproject myproject --no-git
86
+ codefortify-startproject myproject --force
87
+ codefortify-startproject myproject --directory /path/to/projects
88
+ codefortify-startproject myproject --all
89
+ ```
90
+
91
+ `--all` is equivalent to:
92
+
93
+ ```bash
94
+ codefortify-startproject myproject --htmx --drf --docker --celery --database postgres
95
+ ```
96
+
97
+ ## Feature Matrix
98
+
99
+ | Feature | Flag | Description |
100
+ |---|---|---|
101
+ | Django MVT | default | Clean Django project with settings, templates, static/media, and home app |
102
+ | HTMX | `--htmx` | Adds `django-htmx`, middleware, and example partial views |
103
+ | Django REST Framework | `--drf` | Adds DRF, API app, API routes, serializers, and tests |
104
+ | Docker | `--docker` | Adds Dockerfile, docker-compose, entrypoint, deployment script, and Docker docs |
105
+ | Celery + Redis | `--celery` | Adds Celery config, Redis broker settings, and example task |
106
+ | PostgreSQL | `--database postgres` | Adds PostgreSQL-ready configuration |
107
+ | MySQL | `--database mysql` | Adds MySQL-ready configuration |
108
+ | Full stack | `--all` | Adds HTMX, DRF, Docker, Celery, Redis, and PostgreSQL |
109
+
110
+ ## Generated Architecture
111
+
112
+ ```text
113
+ myproject/
114
+ ├── apps/
115
+ │ └── home/
116
+ ├── core/
117
+ │ ├── settings/
118
+ │ │ ├── base.py
119
+ │ │ ├── dev.py
120
+ │ │ └── production.py
121
+ │ ├── urls.py
122
+ │ ├── asgi.py
123
+ │ └── wsgi.py
124
+ ├── templates/
125
+ ├── static/
126
+ ├── media/
127
+ ├── manage.py
128
+ ├── requirements.txt
129
+ ├── .env.example
130
+ └── README.md
131
+ ```
132
+
133
+ Feature-specific files are added only when their flags are selected (for example `apps/api`, `core/celery.py`, `Dockerfile`, compose files, and task modules).
134
+
135
+ ## Database Options
136
+
137
+ - Default without `--docker`: SQLite
138
+ - Default with `--docker`: PostgreSQL
139
+ - Explicit: `--database postgres`, `--database mysql`, or `--database sqlite`
140
+
141
+ Generated settings safely handle an empty `DATABASE_URL` and support local fallback behavior for development.
142
+
143
+ ## HTMX Usage
144
+
145
+ Generate with HTMX:
146
+
147
+ ```bash
148
+ codefortify-startproject myproject --htmx
149
+ ```
150
+
151
+ The generated project includes HTMX middleware and an example partial endpoint.
152
+
153
+ ## DRF Usage
154
+
155
+ Generate with DRF:
156
+
157
+ ```bash
158
+ codefortify-startproject myproject --drf
159
+ ```
160
+
161
+ The generated API app includes a health endpoint:
162
+
163
+ - `GET /api/health/`
164
+
165
+ ## Docker Usage
166
+
167
+ ```bash
168
+ codefortify-startproject myproject --docker
169
+ cd myproject
170
+ cp .env.example .env
171
+ docker compose build
172
+ docker compose up -d
173
+ docker compose exec web python manage.py migrate
174
+ ```
175
+
176
+ ## Celery Usage
177
+
178
+ Generate with Celery support:
179
+
180
+ ```bash
181
+ codefortify-startproject myproject --celery
182
+ ```
183
+
184
+ Run worker locally:
185
+
186
+ ```bash
187
+ celery -A core worker -l info
188
+ ```
189
+
190
+ ## Full Stack Usage
191
+
192
+ ```bash
193
+ codefortify-startproject myproject --all
194
+ cd myproject
195
+ cp .env.example .env
196
+ docker compose build
197
+ docker compose up -d
198
+ docker compose ps
199
+ ```
200
+
201
+ ## Local Development (This Package)
202
+
203
+ ```bash
204
+ python -m venv .pkgvenv
205
+ source .pkgvenv/bin/activate
206
+ pip install -r requirements.txt
207
+ pip install -e .
208
+ python -m pytest -q tests
209
+ ```
210
+
211
+ ## Build and Publish
212
+
213
+ Build and validate:
214
+
215
+ ```bash
216
+ rm -rf dist build *.egg-info
217
+ python -m build
218
+ twine check dist/*
219
+ ```
220
+
221
+ Publish to TestPyPI:
222
+
223
+ ```bash
224
+ twine upload --repository testpypi dist/*
225
+ ```
226
+
227
+ Publish to PyPI:
228
+
229
+ ```bash
230
+ twine upload dist/*
231
+ ```
232
+
233
+ ## Testing from TestPyPI
234
+
235
+ Use this only for testing pre-release package builds:
236
+
237
+ ```bash
238
+ pip install --index-url https://test.pypi.org/simple/ \
239
+ --extra-index-url https://pypi.org/simple \
240
+ codefortify-starter==1.0.0
241
+ ```
242
+
243
+ ## License
244
+
245
+ MIT License. See [LICENSE](LICENSE).
@@ -0,0 +1,7 @@
1
+ """Codefortify starter project generator package."""
2
+
3
+ from codefortify_starter.constants import PACKAGE_VERSION
4
+
5
+ __all__ = ["PACKAGE_VERSION", "__version__"]
6
+
7
+ __version__ = PACKAGE_VERSION
@@ -0,0 +1,6 @@
1
+ from codefortify_starter.cli import main
2
+
3
+
4
+ if __name__ == "__main__":
5
+ main()
6
+
@@ -0,0 +1,103 @@
1
+ """CLI entry point for project generation."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from pathlib import Path
6
+
7
+ import typer
8
+ from rich.console import Console
9
+
10
+ from codefortify_starter.generator import StarterProjectGenerator, build_generation_options
11
+ from codefortify_starter.validators import ValidationError, build_project_identity, normalize_database
12
+
13
+
14
+ console = Console()
15
+
16
+
17
+ def run(
18
+ project_name: str = typer.Argument(..., help="Project directory name to create."),
19
+ htmx: bool = typer.Option(False, "--htmx", help="Include HTMX integration."),
20
+ drf: bool = typer.Option(False, "--drf", help="Include Django REST Framework starter API."),
21
+ docker: bool = typer.Option(False, "--docker", help="Include Docker and Compose files."),
22
+ celery: bool = typer.Option(False, "--celery", help="Include Celery + Redis task setup."),
23
+ database: str | None = typer.Option(
24
+ None,
25
+ "--database",
26
+ help="Database backend to configure: sqlite, postgres, or mysql.",
27
+ ),
28
+ no_git: bool = typer.Option(False, "--no-git", help="Skip git repository initialization."),
29
+ force: bool = typer.Option(False, "--force", help="Allow generation into an existing directory."),
30
+ directory: Path = typer.Option(Path("."), "--directory", help="Parent directory for the generated project."),
31
+ all_features: bool = typer.Option(
32
+ False,
33
+ "--all",
34
+ help="Enable full-stack preset: --htmx --drf --docker --celery --database postgres.",
35
+ ),
36
+ ) -> None:
37
+ """Generate a Django starter project."""
38
+ try:
39
+ if all_features:
40
+ htmx = True
41
+ drf = True
42
+ docker = True
43
+ celery = True
44
+ if database is None:
45
+ database = "postgres"
46
+
47
+ resolved_database = normalize_database(database, use_docker=docker)
48
+ identity = build_project_identity(project_name)
49
+
50
+ options = build_generation_options(
51
+ project_name=identity.project_name,
52
+ project_slug=identity.project_slug,
53
+ project_title=identity.project_title,
54
+ project_package=identity.project_package,
55
+ project_class_name=identity.project_class_name,
56
+ directory=directory.resolve(),
57
+ database=resolved_database,
58
+ use_htmx=htmx,
59
+ use_drf=drf,
60
+ use_docker=docker,
61
+ use_celery=celery,
62
+ no_git=no_git,
63
+ force=force,
64
+ )
65
+ generator = StarterProjectGenerator()
66
+ result = generator.generate(options)
67
+ except (ValidationError, FileExistsError, NotADirectoryError, RuntimeError) as exc:
68
+ console.print(f"[bold red]Error:[/bold red] {exc}")
69
+ raise typer.Exit(code=1) from exc
70
+
71
+ selected_features = []
72
+ if htmx:
73
+ selected_features.append("htmx")
74
+ if drf:
75
+ selected_features.append("drf")
76
+ if docker:
77
+ selected_features.append("docker")
78
+ if celery:
79
+ selected_features.append("celery")
80
+ features_text = ", ".join(selected_features) if selected_features else "base"
81
+
82
+ console.print(
83
+ f"[bold green]Created[/bold green] {result.project_path} "
84
+ f"(database={resolved_database}, features={features_text})"
85
+ )
86
+ if result.warnings:
87
+ for warning in result.warnings:
88
+ console.print(f"[yellow]Warning:[/yellow] {warning}")
89
+
90
+ console.print("Next steps:")
91
+ console.print(f" 1. cd {result.project_path}")
92
+ console.print(" 2. python -m venv .venv && source .venv/bin/activate")
93
+ console.print(" 3. pip install -r requirements.txt")
94
+ console.print(" 4. cp .env.example .env")
95
+ console.print(" 5. python manage.py migrate && python manage.py runserver")
96
+
97
+
98
+ def main() -> None:
99
+ typer.run(run)
100
+
101
+
102
+ if __name__ == "__main__":
103
+ main()