djrocket 1.0.0a2__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.
- djrocket-1.0.0a2/LICENSE.md +201 -0
- djrocket-1.0.0a2/MANIFEST.in +5 -0
- djrocket-1.0.0a2/PKG-INFO +114 -0
- djrocket-1.0.0a2/README.md +74 -0
- djrocket-1.0.0a2/djangorocket/__init__.py +0 -0
- djrocket-1.0.0a2/djangorocket/__main__.py +4 -0
- djrocket-1.0.0a2/djangorocket/cli.py +212 -0
- djrocket-1.0.0a2/djangorocket/components.py +39 -0
- djrocket-1.0.0a2/djangorocket/django.py +344 -0
- djrocket-1.0.0a2/djangorocket/templates/__init__.py +0 -0
- djrocket-1.0.0a2/djangorocket/templates/projects/__init__.py +0 -0
- djrocket-1.0.0a2/djangorocket/templates/projects/base/cookiecutter.json +7 -0
- djrocket-1.0.0a2/djangorocket/templates/projects/base/hooks/post_gen_project.py +84 -0
- djrocket-1.0.0a2/djangorocket/templates/projects/base/{{ cookiecutter.project_dirname }}/.coveragerc +10 -0
- djrocket-1.0.0a2/djangorocket/templates/projects/base/{{ cookiecutter.project_dirname }}/.env.example +43 -0
- djrocket-1.0.0a2/djangorocket/templates/projects/base/{{ cookiecutter.project_dirname }}/.flake8 +19 -0
- djrocket-1.0.0a2/djangorocket/templates/projects/base/{{ cookiecutter.project_dirname }}/.gitignore +58 -0
- djrocket-1.0.0a2/djangorocket/templates/projects/base/{{ cookiecutter.project_dirname }}/.isort.cfg +9 -0
- djrocket-1.0.0a2/djangorocket/templates/projects/base/{{ cookiecutter.project_dirname }}/Makefile +107 -0
- djrocket-1.0.0a2/djangorocket/templates/projects/base/{{ cookiecutter.project_dirname }}/README.md +131 -0
- djrocket-1.0.0a2/djangorocket/templates/projects/base/{{ cookiecutter.project_dirname }}/docker-compose.yml +57 -0
- djrocket-1.0.0a2/djangorocket/templates/projects/base/{{ cookiecutter.project_dirname }}/pyproject.toml +27 -0
- djrocket-1.0.0a2/djangorocket/templates/projects/base/{{ cookiecutter.project_dirname }}/pytest.ini +5 -0
- djrocket-1.0.0a2/djangorocket/templates/projects/base/{{ cookiecutter.project_dirname }}/requirements/requirements-dev.txt +1 -0
- djrocket-1.0.0a2/djangorocket/templates/projects/base/{{ cookiecutter.project_dirname }}/requirements/requirements-docs.txt +1 -0
- djrocket-1.0.0a2/djangorocket/templates/projects/base/{{ cookiecutter.project_dirname }}/requirements/requirements-linting.txt +4 -0
- djrocket-1.0.0a2/djangorocket/templates/projects/base/{{ cookiecutter.project_dirname }}/requirements/requirements-testing.txt +8 -0
- djrocket-1.0.0a2/djangorocket/templates/projects/base/{{ cookiecutter.project_dirname }}/requirements/requirements.txt +32 -0
- djrocket-1.0.0a2/djangorocket/templates/projects/base/{{ cookiecutter.project_dirname }}/requirements.txt +5 -0
- djrocket-1.0.0a2/djangorocket/templates/projects/base/{{ cookiecutter.project_dirname }}/runtime.txt +1 -0
- djrocket-1.0.0a2/djangorocket/templates/projects/base/{{ cookiecutter.project_dirname }}/src/manage.py +22 -0
- djrocket-1.0.0a2/djangorocket/templates/projects/base/{{ cookiecutter.project_dirname }}/src/static/CACHE/manifest.json +0 -0
- djrocket-1.0.0a2/djangorocket/templates/projects/base/{{ cookiecutter.project_dirname }}/src/static/img/favicon/favicon.png +0 -0
- djrocket-1.0.0a2/djangorocket/templates/projects/base/{{ cookiecutter.project_dirname }}/src/static/img/favicon/favicon.svg +46 -0
- djrocket-1.0.0a2/djangorocket/templates/projects/base/{{ cookiecutter.project_dirname }}/src/tailwind_theme/__init__.py +0 -0
- djrocket-1.0.0a2/djangorocket/templates/projects/base/{{ cookiecutter.project_dirname }}/src/tailwind_theme/apps.py +5 -0
- djrocket-1.0.0a2/djangorocket/templates/projects/base/{{ cookiecutter.project_dirname }}/src/tailwind_theme/static/css/dist/styles.css +2765 -0
- djrocket-1.0.0a2/djangorocket/templates/projects/base/{{ cookiecutter.project_dirname }}/src/tailwind_theme/static_src/.gitignore +1 -0
- djrocket-1.0.0a2/djangorocket/templates/projects/base/{{ cookiecutter.project_dirname }}/src/tailwind_theme/static_src/package-lock.json +1880 -0
- djrocket-1.0.0a2/djangorocket/templates/projects/base/{{ cookiecutter.project_dirname }}/src/tailwind_theme/static_src/package.json +29 -0
- djrocket-1.0.0a2/djangorocket/templates/projects/base/{{ cookiecutter.project_dirname }}/src/tailwind_theme/static_src/postcss.config.js +7 -0
- djrocket-1.0.0a2/djangorocket/templates/projects/base/{{ cookiecutter.project_dirname }}/src/tailwind_theme/static_src/src/styles.css +41 -0
- djrocket-1.0.0a2/djangorocket/templates/projects/base/{{ cookiecutter.project_dirname }}/src/tailwind_theme/static_src/tailwind.config.js +53 -0
- djrocket-1.0.0a2/djangorocket/templates/projects/base/{{ cookiecutter.project_dirname }}/src/tailwind_theme/templates/base.html +20 -0
- djrocket-1.0.0a2/djangorocket/templates/projects/base/{{ cookiecutter.project_dirname }}/src/templates/base.html +27 -0
- djrocket-1.0.0a2/djangorocket/templates/projects/base/{{ cookiecutter.project_dirname }}/src/templates/base_settings.html +21 -0
- djrocket-1.0.0a2/djangorocket/templates/projects/base/{{ cookiecutter.project_dirname }}/src/templates/components/app_header.html +85 -0
- djrocket-1.0.0a2/djangorocket/templates/projects/base/{{ cookiecutter.project_dirname }}/src/templates/components/footer.html +59 -0
- djrocket-1.0.0a2/djangorocket/templates/projects/base/{{ cookiecutter.project_dirname }}/src/templates/components/header.html +30 -0
- djrocket-1.0.0a2/djangorocket/templates/projects/base/{{ cookiecutter.project_dirname }}/src/templates/components/settings_desktop_sidebar.html +127 -0
- djrocket-1.0.0a2/djangorocket/templates/projects/base/{{ cookiecutter.project_dirname }}/src/templates/pages/index.html +40 -0
- djrocket-1.0.0a2/djangorocket/templates/projects/base/{{ cookiecutter.project_dirname }}/src/{{ cookiecutter.project_slug }}/__init__.py +3 -0
- djrocket-1.0.0a2/djangorocket/templates/projects/base/{{ cookiecutter.project_dirname }}/src/{{ cookiecutter.project_slug }}/asgi.py +9 -0
- djrocket-1.0.0a2/djangorocket/templates/projects/base/{{ cookiecutter.project_dirname }}/src/{{ cookiecutter.project_slug }}/auth/__init__.py +0 -0
- djrocket-1.0.0a2/djangorocket/templates/projects/base/{{ cookiecutter.project_dirname }}/src/{{ cookiecutter.project_slug }}/auth/admin.py +1 -0
- djrocket-1.0.0a2/djangorocket/templates/projects/base/{{ cookiecutter.project_dirname }}/src/{{ cookiecutter.project_slug }}/auth/apps.py +7 -0
- djrocket-1.0.0a2/djangorocket/templates/projects/base/{{ cookiecutter.project_dirname }}/src/{{ cookiecutter.project_slug }}/auth/factories.py +11 -0
- djrocket-1.0.0a2/djangorocket/templates/projects/base/{{ cookiecutter.project_dirname }}/src/{{ cookiecutter.project_slug }}/auth/forms.py +91 -0
- djrocket-1.0.0a2/djangorocket/templates/projects/base/{{ cookiecutter.project_dirname }}/src/{{ cookiecutter.project_slug }}/auth/migrations/0001_initial.py +116 -0
- djrocket-1.0.0a2/djangorocket/templates/projects/base/{{ cookiecutter.project_dirname }}/src/{{ cookiecutter.project_slug }}/auth/migrations/__init__.py +0 -0
- djrocket-1.0.0a2/djangorocket/templates/projects/base/{{ cookiecutter.project_dirname }}/src/{{ cookiecutter.project_slug }}/auth/models.py +81 -0
- djrocket-1.0.0a2/djangorocket/templates/projects/base/{{ cookiecutter.project_dirname }}/src/{{ cookiecutter.project_slug }}/auth/templates/auth/forms/login_form.html +42 -0
- djrocket-1.0.0a2/djangorocket/templates/projects/base/{{ cookiecutter.project_dirname }}/src/{{ cookiecutter.project_slug }}/auth/templates/auth/forms/register_form.html +80 -0
- djrocket-1.0.0a2/djangorocket/templates/projects/base/{{ cookiecutter.project_dirname }}/src/{{ cookiecutter.project_slug }}/auth/templates/auth/forms/update_password_form.html +57 -0
- djrocket-1.0.0a2/djangorocket/templates/projects/base/{{ cookiecutter.project_dirname }}/src/{{ cookiecutter.project_slug }}/auth/templates/auth/forms/update_user_form.html +24 -0
- djrocket-1.0.0a2/djangorocket/templates/projects/base/{{ cookiecutter.project_dirname }}/src/{{ cookiecutter.project_slug }}/auth/templates/auth/pages/account_settings.html +33 -0
- djrocket-1.0.0a2/djangorocket/templates/projects/base/{{ cookiecutter.project_dirname }}/src/{{ cookiecutter.project_slug }}/auth/templates/auth/pages/email_settings.html +31 -0
- djrocket-1.0.0a2/djangorocket/templates/projects/base/{{ cookiecutter.project_dirname }}/src/{{ cookiecutter.project_slug }}/auth/templates/auth/pages/login.html +60 -0
- djrocket-1.0.0a2/djangorocket/templates/projects/base/{{ cookiecutter.project_dirname }}/src/{{ cookiecutter.project_slug }}/auth/templates/auth/pages/register.html +59 -0
- djrocket-1.0.0a2/djangorocket/templates/projects/base/{{ cookiecutter.project_dirname }}/src/{{ cookiecutter.project_slug }}/auth/templates/auth/pages/security_settings.html +35 -0
- djrocket-1.0.0a2/djangorocket/templates/projects/base/{{ cookiecutter.project_dirname }}/src/{{ cookiecutter.project_slug }}/auth/tests/__init__.py +0 -0
- djrocket-1.0.0a2/djangorocket/templates/projects/base/{{ cookiecutter.project_dirname }}/src/{{ cookiecutter.project_slug }}/auth/tests/views/__init__.py +0 -0
- djrocket-1.0.0a2/djangorocket/templates/projects/base/{{ cookiecutter.project_dirname }}/src/{{ cookiecutter.project_slug }}/auth/tests/views/login_view/__init__.py +0 -0
- djrocket-1.0.0a2/djangorocket/templates/projects/base/{{ cookiecutter.project_dirname }}/src/{{ cookiecutter.project_slug }}/auth/tests/views/login_view/tests.py +110 -0
- djrocket-1.0.0a2/djangorocket/templates/projects/base/{{ cookiecutter.project_dirname }}/src/{{ cookiecutter.project_slug }}/auth/tests/views/logout_view/__init__.py +0 -0
- djrocket-1.0.0a2/djangorocket/templates/projects/base/{{ cookiecutter.project_dirname }}/src/{{ cookiecutter.project_slug }}/auth/tests/views/logout_view/tests.py +74 -0
- djrocket-1.0.0a2/djangorocket/templates/projects/base/{{ cookiecutter.project_dirname }}/src/{{ cookiecutter.project_slug }}/auth/tests/views/register_view/__init__.py +0 -0
- djrocket-1.0.0a2/djangorocket/templates/projects/base/{{ cookiecutter.project_dirname }}/src/{{ cookiecutter.project_slug }}/auth/tests/views/register_view/tests.py +170 -0
- djrocket-1.0.0a2/djangorocket/templates/projects/base/{{ cookiecutter.project_dirname }}/src/{{ cookiecutter.project_slug }}/auth/urls.py +14 -0
- djrocket-1.0.0a2/djangorocket/templates/projects/base/{{ cookiecutter.project_dirname }}/src/{{ cookiecutter.project_slug }}/auth/utils.py +25 -0
- djrocket-1.0.0a2/djangorocket/templates/projects/base/{{ cookiecutter.project_dirname }}/src/{{ cookiecutter.project_slug }}/auth/views.py +180 -0
- djrocket-1.0.0a2/djangorocket/templates/projects/base/{{ cookiecutter.project_dirname }}/src/{{ cookiecutter.project_slug }}/billing/__init__.py +0 -0
- djrocket-1.0.0a2/djangorocket/templates/projects/base/{{ cookiecutter.project_dirname }}/src/{{ cookiecutter.project_slug }}/billing/admin.py +4 -0
- djrocket-1.0.0a2/djangorocket/templates/projects/base/{{ cookiecutter.project_dirname }}/src/{{ cookiecutter.project_slug }}/billing/apps.py +7 -0
- djrocket-1.0.0a2/djangorocket/templates/projects/base/{{ cookiecutter.project_dirname }}/src/{{ cookiecutter.project_slug }}/billing/forms.py +39 -0
- djrocket-1.0.0a2/djangorocket/templates/projects/base/{{ cookiecutter.project_dirname }}/src/{{ cookiecutter.project_slug }}/billing/migrations/0001_initial.py +41 -0
- djrocket-1.0.0a2/djangorocket/templates/projects/base/{{ cookiecutter.project_dirname }}/src/{{ cookiecutter.project_slug }}/billing/migrations/__init__.py +0 -0
- djrocket-1.0.0a2/djangorocket/templates/projects/base/{{ cookiecutter.project_dirname }}/src/{{ cookiecutter.project_slug }}/billing/models.py +11 -0
- djrocket-1.0.0a2/djangorocket/templates/projects/base/{{ cookiecutter.project_dirname }}/src/{{ cookiecutter.project_slug }}/billing/templates/billing/forms/update_billing_information_form.html +117 -0
- djrocket-1.0.0a2/djangorocket/templates/projects/base/{{ cookiecutter.project_dirname }}/src/{{ cookiecutter.project_slug }}/billing/templates/billing/pages/billing_settings.html +141 -0
- djrocket-1.0.0a2/djangorocket/templates/projects/base/{{ cookiecutter.project_dirname }}/src/{{ cookiecutter.project_slug }}/billing/urls.py +24 -0
- djrocket-1.0.0a2/djangorocket/templates/projects/base/{{ cookiecutter.project_dirname }}/src/{{ cookiecutter.project_slug }}/billing/utils.py +30 -0
- djrocket-1.0.0a2/djangorocket/templates/projects/base/{{ cookiecutter.project_dirname }}/src/{{ cookiecutter.project_slug }}/billing/views.py +182 -0
- djrocket-1.0.0a2/djangorocket/templates/projects/base/{{ cookiecutter.project_dirname }}/src/{{ cookiecutter.project_slug }}/celery.py +14 -0
- djrocket-1.0.0a2/djangorocket/templates/projects/base/{{ cookiecutter.project_dirname }}/src/{{ cookiecutter.project_slug }}/context_processors.py +9 -0
- djrocket-1.0.0a2/djangorocket/templates/projects/base/{{ cookiecutter.project_dirname }}/src/{{ cookiecutter.project_slug }}/model_loaders.py +5 -0
- djrocket-1.0.0a2/djangorocket/templates/projects/base/{{ cookiecutter.project_dirname }}/src/{{ cookiecutter.project_slug }}/permissions.py +23 -0
- djrocket-1.0.0a2/djangorocket/templates/projects/base/{{ cookiecutter.project_dirname }}/src/{{ cookiecutter.project_slug }}/search/__init__.py +0 -0
- djrocket-1.0.0a2/djangorocket/templates/projects/base/{{ cookiecutter.project_dirname }}/src/{{ cookiecutter.project_slug }}/search/api_urls.py +13 -0
- djrocket-1.0.0a2/djangorocket/templates/projects/base/{{ cookiecutter.project_dirname }}/src/{{ cookiecutter.project_slug }}/search/api_views.py +27 -0
- djrocket-1.0.0a2/djangorocket/templates/projects/base/{{ cookiecutter.project_dirname }}/src/{{ cookiecutter.project_slug }}/search/apps.py +7 -0
- djrocket-1.0.0a2/djangorocket/templates/projects/base/{{ cookiecutter.project_dirname }}/src/{{ cookiecutter.project_slug }}/search/serializers.py +26 -0
- djrocket-1.0.0a2/djangorocket/templates/projects/base/{{ cookiecutter.project_dirname }}/src/{{ cookiecutter.project_slug }}/search/utils.py +20 -0
- djrocket-1.0.0a2/djangorocket/templates/projects/base/{{ cookiecutter.project_dirname }}/src/{{ cookiecutter.project_slug }}/serializers.py +23 -0
- djrocket-1.0.0a2/djangorocket/templates/projects/base/{{ cookiecutter.project_dirname }}/src/{{ cookiecutter.project_slug }}/settings.py +418 -0
- djrocket-1.0.0a2/djangorocket/templates/projects/base/{{ cookiecutter.project_dirname }}/src/{{ cookiecutter.project_slug }}/urls.py +27 -0
- djrocket-1.0.0a2/djangorocket/templates/projects/base/{{ cookiecutter.project_dirname }}/src/{{ cookiecutter.project_slug }}/utils/__init__.py +5 -0
- djrocket-1.0.0a2/djangorocket/templates/projects/base/{{ cookiecutter.project_dirname }}/src/{{ cookiecutter.project_slug }}/utils/apps.py +7 -0
- djrocket-1.0.0a2/djangorocket/templates/projects/base/{{ cookiecutter.project_dirname }}/src/{{ cookiecutter.project_slug }}/utils/templatetags/__init__.py +0 -0
- djrocket-1.0.0a2/djangorocket/templates/projects/base/{{ cookiecutter.project_dirname }}/src/{{ cookiecutter.project_slug }}/utils/templatetags/{{ cookiecutter.project_slug }}_utils_math.py +51 -0
- djrocket-1.0.0a2/djangorocket/templates/projects/base/{{ cookiecutter.project_dirname }}/src/{{ cookiecutter.project_slug }}/utils/templatetags/{{ cookiecutter.project_slug }}_utils_timestamp.py +10 -0
- djrocket-1.0.0a2/djangorocket/templates/projects/base/{{ cookiecutter.project_dirname }}/src/{{ cookiecutter.project_slug }}/utils/timezone/__init__.py +5 -0
- djrocket-1.0.0a2/djangorocket/templates/projects/base/{{ cookiecutter.project_dirname }}/src/{{ cookiecutter.project_slug }}/views.py +7 -0
- djrocket-1.0.0a2/djangorocket/templates/projects/base/{{ cookiecutter.project_dirname }}/src/{{ cookiecutter.project_slug }}/wsgi.py +9 -0
- djrocket-1.0.0a2/djangorocket/templates/ui/__init__.py +0 -0
- djrocket-1.0.0a2/djangorocket/templates/ui/accordion/README.md +0 -0
- djrocket-1.0.0a2/djangorocket/templates/ui/accordion/cookiecutter.json +3 -0
- djrocket-1.0.0a2/djangorocket/templates/ui/accordion/{{ cookiecutter.project_slug }}/accordion.html +3 -0
- djrocket-1.0.0a2/djrocket.egg-info/PKG-INFO +114 -0
- djrocket-1.0.0a2/djrocket.egg-info/SOURCES.txt +125 -0
- djrocket-1.0.0a2/djrocket.egg-info/dependency_links.txt +1 -0
- djrocket-1.0.0a2/djrocket.egg-info/entry_points.txt +2 -0
- djrocket-1.0.0a2/djrocket.egg-info/requires.txt +3 -0
- djrocket-1.0.0a2/djrocket.egg-info/top_level.txt +1 -0
- djrocket-1.0.0a2/setup.cfg +4 -0
- djrocket-1.0.0a2/setup.py +81 -0
- djrocket-1.0.0a2/tools/zip_templates.py +48 -0
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright (c) 2023 Ernesto González
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: djrocket
|
|
3
|
+
Version: 1.0.0a2
|
|
4
|
+
Summary: CLI tool to add applications and UI templates to any Django website.
|
|
5
|
+
Home-page: https://github.com/ernestofgonzalez/djangorocket
|
|
6
|
+
Author: Ernesto González
|
|
7
|
+
License: Apache License, Version 2.0
|
|
8
|
+
Project-URL: Documentation, https://djangorocket.com/
|
|
9
|
+
Project-URL: Changelog, https://djangorocket.com/changelog.html
|
|
10
|
+
Project-URL: Source code, https://github.com/ernestofgonzalez/djangorocket
|
|
11
|
+
Project-URL: Issues, https://github.com/ernestofgonzalez/djangorocket/issues
|
|
12
|
+
Project-URL: CI, https://github.com/ernestofgonzalez/djangorocket/actions
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: Topic :: Software Development :: Libraries
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
20
|
+
Classifier: Framework :: Django :: 5.0
|
|
21
|
+
Classifier: Framework :: Django :: 5.1
|
|
22
|
+
Classifier: Framework :: Django :: 5.2
|
|
23
|
+
Requires-Python: >=3.10
|
|
24
|
+
Description-Content-Type: text/markdown
|
|
25
|
+
License-File: LICENSE.md
|
|
26
|
+
Requires-Dist: click
|
|
27
|
+
Requires-Dist: click-default-group>=1.2.3
|
|
28
|
+
Requires-Dist: cookiecutter
|
|
29
|
+
Dynamic: author
|
|
30
|
+
Dynamic: classifier
|
|
31
|
+
Dynamic: description
|
|
32
|
+
Dynamic: description-content-type
|
|
33
|
+
Dynamic: home-page
|
|
34
|
+
Dynamic: license
|
|
35
|
+
Dynamic: license-file
|
|
36
|
+
Dynamic: project-url
|
|
37
|
+
Dynamic: requires-dist
|
|
38
|
+
Dynamic: requires-python
|
|
39
|
+
Dynamic: summary
|
|
40
|
+
|
|
41
|
+
# djangorocket
|
|
42
|
+
|
|
43
|
+
[](https://github.com/ErnestoFGonzalez/djangorocket)
|
|
44
|
+
[](https://github.com/ErnestoFGonzalez/djangorocket/releases)
|
|
45
|
+
[](https://github.com/ErnestoFGonzalez/djangorocket/blob/main/LICENSE.md)
|
|
46
|
+
|
|
47
|
+
_Django Rocket is a powerful Django SaaS boilerplate designed for indie hackers and SaaS companies that need to quickly launch their paywalled software. It leverages the [Cookiecutter](https://github.com/cookiecutter/cookiecutter) templating engine to generate a project structure with commonly used features such as authentication and billing, saving you time and effort_.
|
|
48
|
+
|
|
49
|
+
For detailed information on usage and third-party integrations, please refer to the [full documentation](https://djangorocket.com).
|
|
50
|
+
|
|
51
|
+
## Features
|
|
52
|
+
|
|
53
|
+
- Custom user model with login, registration, and account, email and security settings pages
|
|
54
|
+
- Stripe subscriptions via [stripe-python](https://github.com/stripe/stripe-python), with checkout, cancel and reactivate flows and a webhook endpoint
|
|
55
|
+
- Customizable templates with [Tailwind CSS](https://github.com/tailwindlabs/tailwindcss) (powered by [django-tailwind](https://github.com/timonweb/django-tailwind))
|
|
56
|
+
- A REST API with token and API-key authentication, via [djangorestframework](https://github.com/encode/django-rest-framework)
|
|
57
|
+
- Search backed by OpenSearch, and background work with [celery](https://github.com/celery/celery) on Redis
|
|
58
|
+
- Postgres and Redis defined in `docker-compose.yml`, on host ports picked free on your machine
|
|
59
|
+
- Static file serving with [whitenoise](https://github.com/evansd/whitenoise)
|
|
60
|
+
|
|
61
|
+
## Installation
|
|
62
|
+
|
|
63
|
+
Install the CLI with [pip](https://github.com/pypa/pip):
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
$ pip install djrocket
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
> **_NOTE:_** The package is published as `djrocket`; the command it installs is `djangorocket`.
|
|
70
|
+
|
|
71
|
+
Generating and running a project needs:
|
|
72
|
+
|
|
73
|
+
- **Python 3.10 - 3.14**
|
|
74
|
+
- **Docker**, to run the Postgres and Redis services the generated project comes with
|
|
75
|
+
|
|
76
|
+
## Usage
|
|
77
|
+
|
|
78
|
+
To create a new Django Rocket project, run the following command in your terminal:
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
$ djangorocket init
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
You will be prompted for your project name, after which the project structure will be generated. Scaffolding writes a working `.env` for you — a fresh `SECRET_KEY`, throwaway Postgres credentials and free host ports — so there is nothing to fill in before booting locally.
|
|
85
|
+
|
|
86
|
+
One command then takes the new project to a running app, creating a virtualenv, installing the dependencies, starting Postgres and Redis, and applying the migrations:
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
$ make bootstrap
|
|
90
|
+
$ make runserver
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
Each generated project ships a README covering its layout, every `make` target, the Tailwind workflow and what to set when deploying.
|
|
94
|
+
|
|
95
|
+
### Adding UI templates
|
|
96
|
+
|
|
97
|
+
To add a UI component to an existing Django Rocket project, run `add` from the project root:
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
$ djangorocket add accordion
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
### Using cookiecutter directly
|
|
104
|
+
|
|
105
|
+
Django Rocket is also usable as a plain Cookiecutter template, without installing the CLI:
|
|
106
|
+
|
|
107
|
+
```bash
|
|
108
|
+
$ pip install cookiecutter==2.1.1
|
|
109
|
+
$ cookiecutter gh:ErnestoFGonzalez/djangorocket --directory="djangorocket/templates/projects/base"
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
> **_NOTE:_** Although Django Rocket works with other versions of Cookiecutter, we recommend the version mentioned above, as it is the one that's well-tested.
|
|
113
|
+
|
|
114
|
+
For comprehensive coverage of features and integrations, check out the [full documentation](https://djangorocket.com).
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# djangorocket
|
|
2
|
+
|
|
3
|
+
[](https://github.com/ErnestoFGonzalez/djangorocket)
|
|
4
|
+
[](https://github.com/ErnestoFGonzalez/djangorocket/releases)
|
|
5
|
+
[](https://github.com/ErnestoFGonzalez/djangorocket/blob/main/LICENSE.md)
|
|
6
|
+
|
|
7
|
+
_Django Rocket is a powerful Django SaaS boilerplate designed for indie hackers and SaaS companies that need to quickly launch their paywalled software. It leverages the [Cookiecutter](https://github.com/cookiecutter/cookiecutter) templating engine to generate a project structure with commonly used features such as authentication and billing, saving you time and effort_.
|
|
8
|
+
|
|
9
|
+
For detailed information on usage and third-party integrations, please refer to the [full documentation](https://djangorocket.com).
|
|
10
|
+
|
|
11
|
+
## Features
|
|
12
|
+
|
|
13
|
+
- Custom user model with login, registration, and account, email and security settings pages
|
|
14
|
+
- Stripe subscriptions via [stripe-python](https://github.com/stripe/stripe-python), with checkout, cancel and reactivate flows and a webhook endpoint
|
|
15
|
+
- Customizable templates with [Tailwind CSS](https://github.com/tailwindlabs/tailwindcss) (powered by [django-tailwind](https://github.com/timonweb/django-tailwind))
|
|
16
|
+
- A REST API with token and API-key authentication, via [djangorestframework](https://github.com/encode/django-rest-framework)
|
|
17
|
+
- Search backed by OpenSearch, and background work with [celery](https://github.com/celery/celery) on Redis
|
|
18
|
+
- Postgres and Redis defined in `docker-compose.yml`, on host ports picked free on your machine
|
|
19
|
+
- Static file serving with [whitenoise](https://github.com/evansd/whitenoise)
|
|
20
|
+
|
|
21
|
+
## Installation
|
|
22
|
+
|
|
23
|
+
Install the CLI with [pip](https://github.com/pypa/pip):
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
$ pip install djrocket
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
> **_NOTE:_** The package is published as `djrocket`; the command it installs is `djangorocket`.
|
|
30
|
+
|
|
31
|
+
Generating and running a project needs:
|
|
32
|
+
|
|
33
|
+
- **Python 3.10 - 3.14**
|
|
34
|
+
- **Docker**, to run the Postgres and Redis services the generated project comes with
|
|
35
|
+
|
|
36
|
+
## Usage
|
|
37
|
+
|
|
38
|
+
To create a new Django Rocket project, run the following command in your terminal:
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
$ djangorocket init
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
You will be prompted for your project name, after which the project structure will be generated. Scaffolding writes a working `.env` for you — a fresh `SECRET_KEY`, throwaway Postgres credentials and free host ports — so there is nothing to fill in before booting locally.
|
|
45
|
+
|
|
46
|
+
One command then takes the new project to a running app, creating a virtualenv, installing the dependencies, starting Postgres and Redis, and applying the migrations:
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
$ make bootstrap
|
|
50
|
+
$ make runserver
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Each generated project ships a README covering its layout, every `make` target, the Tailwind workflow and what to set when deploying.
|
|
54
|
+
|
|
55
|
+
### Adding UI templates
|
|
56
|
+
|
|
57
|
+
To add a UI component to an existing Django Rocket project, run `add` from the project root:
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
$ djangorocket add accordion
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### Using cookiecutter directly
|
|
64
|
+
|
|
65
|
+
Django Rocket is also usable as a plain Cookiecutter template, without installing the CLI:
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
$ pip install cookiecutter==2.1.1
|
|
69
|
+
$ cookiecutter gh:ErnestoFGonzalez/djangorocket --directory="djangorocket/templates/projects/base"
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
> **_NOTE:_** Although Django Rocket works with other versions of Cookiecutter, we recommend the version mentioned above, as it is the one that's well-tested.
|
|
73
|
+
|
|
74
|
+
For comprehensive coverage of features and integrations, check out the [full documentation](https://djangorocket.com).
|
|
File without changes
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
import contextlib
|
|
2
|
+
import importlib.resources
|
|
3
|
+
import itertools
|
|
4
|
+
import os
|
|
5
|
+
import re
|
|
6
|
+
import socket
|
|
7
|
+
import subprocess
|
|
8
|
+
import sys
|
|
9
|
+
import threading
|
|
10
|
+
import time
|
|
11
|
+
|
|
12
|
+
import click
|
|
13
|
+
from cookiecutter.main import cookiecutter
|
|
14
|
+
from cookiecutter.exceptions import OutputDirExistsException
|
|
15
|
+
|
|
16
|
+
from djangorocket.components import add_components
|
|
17
|
+
from djangorocket.django import DjangoSettingsManager
|
|
18
|
+
|
|
19
|
+
@click.group()
|
|
20
|
+
def main():
|
|
21
|
+
pass
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
@contextlib.contextmanager
|
|
25
|
+
def _spinner(message):
|
|
26
|
+
"""Show an animated 'working' indicator while a slow step runs.
|
|
27
|
+
|
|
28
|
+
Generating a project renders well over a hundred files with no output of its
|
|
29
|
+
own, which makes the command look hung. This keeps the terminal alive with a
|
|
30
|
+
spinner on a TTY, and falls back to a single plain line otherwise (e.g. when
|
|
31
|
+
output is piped or running in CI).
|
|
32
|
+
"""
|
|
33
|
+
if not sys.stderr.isatty():
|
|
34
|
+
click.echo(message, err=True)
|
|
35
|
+
yield
|
|
36
|
+
return
|
|
37
|
+
|
|
38
|
+
done = threading.Event()
|
|
39
|
+
|
|
40
|
+
def spin():
|
|
41
|
+
for frame in itertools.cycle("|/-\\"):
|
|
42
|
+
if done.is_set():
|
|
43
|
+
break
|
|
44
|
+
click.echo(f"\r{frame} {message}", nl=False, err=True)
|
|
45
|
+
time.sleep(0.1)
|
|
46
|
+
click.echo("\r\033[K", nl=False, err=True) # clear the spinner line
|
|
47
|
+
|
|
48
|
+
thread = threading.Thread(target=spin)
|
|
49
|
+
thread.start()
|
|
50
|
+
try:
|
|
51
|
+
yield
|
|
52
|
+
finally:
|
|
53
|
+
done.set()
|
|
54
|
+
thread.join()
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
def _slugify_dirname(project_name):
|
|
58
|
+
"""Kebab-case a project name for use as a directory / docker identifier."""
|
|
59
|
+
slug = re.sub(r"[^a-z0-9]+", "-", project_name.lower()).strip("-")
|
|
60
|
+
return slug or "project"
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
def _existing_docker_volume_names():
|
|
64
|
+
"""Names of existing docker volumes, or empty set when docker is unavailable."""
|
|
65
|
+
try:
|
|
66
|
+
result = subprocess.run(
|
|
67
|
+
["docker", "volume", "ls", "--format", "{{.Name}}"],
|
|
68
|
+
capture_output=True,
|
|
69
|
+
text=True,
|
|
70
|
+
timeout=10,
|
|
71
|
+
check=True,
|
|
72
|
+
)
|
|
73
|
+
except (OSError, subprocess.SubprocessError):
|
|
74
|
+
return set()
|
|
75
|
+
return set(result.stdout.split())
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
def _available_project_dirname(base, output_dir, taken_volumes):
|
|
79
|
+
"""First of ``base``, ``base-1``, ``base-2``, ... free on disk and in docker.
|
|
80
|
+
|
|
81
|
+
A generated project's docker-compose names its volumes ``<dirname>_postgres_data``
|
|
82
|
+
and ``<dirname>_redis_data``, so we also skip a name whose volumes already exist
|
|
83
|
+
even when the directory does not (e.g. a previous project was removed but its
|
|
84
|
+
data volumes lingered).
|
|
85
|
+
"""
|
|
86
|
+
|
|
87
|
+
def is_taken(name):
|
|
88
|
+
if os.path.exists(os.path.join(output_dir, name)):
|
|
89
|
+
return True
|
|
90
|
+
return any(
|
|
91
|
+
"{0}_{1}".format(name, suffix) in taken_volumes
|
|
92
|
+
for suffix in ("postgres_data", "redis_data")
|
|
93
|
+
)
|
|
94
|
+
|
|
95
|
+
candidate = base
|
|
96
|
+
counter = 0
|
|
97
|
+
while is_taken(candidate):
|
|
98
|
+
counter += 1
|
|
99
|
+
candidate = "{0}-{1}".format(base, counter)
|
|
100
|
+
return candidate
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
def _port_is_free(port):
|
|
104
|
+
"""True if ``port`` can be bound on this host right now."""
|
|
105
|
+
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as sock:
|
|
106
|
+
try:
|
|
107
|
+
sock.bind(("", port))
|
|
108
|
+
return True
|
|
109
|
+
except OSError:
|
|
110
|
+
return False
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
def _reserved_sibling_ports(output_dir):
|
|
114
|
+
"""Host ports already assigned to sibling projects' ``.env`` files.
|
|
115
|
+
|
|
116
|
+
``init`` picks ports that are free *now*, but a project created a moment ago
|
|
117
|
+
may not have its containers up yet, so its port would still look free. Reading
|
|
118
|
+
the ports it reserved in ``.env`` lets us hand out distinct ones to each
|
|
119
|
+
project generated in the same directory.
|
|
120
|
+
"""
|
|
121
|
+
reserved = set()
|
|
122
|
+
try:
|
|
123
|
+
entries = os.listdir(output_dir)
|
|
124
|
+
except OSError:
|
|
125
|
+
return reserved
|
|
126
|
+
for entry in entries:
|
|
127
|
+
env_path = os.path.join(output_dir, entry, ".env")
|
|
128
|
+
if not os.path.isfile(env_path):
|
|
129
|
+
continue
|
|
130
|
+
try:
|
|
131
|
+
with open(env_path) as env_file:
|
|
132
|
+
for line in env_file:
|
|
133
|
+
match = re.match(r"(?:POSTGRES_PORT|REDIS_PORT)=(\d+)\s*$", line)
|
|
134
|
+
if match:
|
|
135
|
+
reserved.add(int(match.group(1)))
|
|
136
|
+
except OSError:
|
|
137
|
+
continue
|
|
138
|
+
return reserved
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
def _pick_host_port(preferred, reserved):
|
|
142
|
+
"""First port from ``preferred`` up that is free and not already reserved.
|
|
143
|
+
|
|
144
|
+
Mutates ``reserved`` so the same call site can pick several distinct ports
|
|
145
|
+
(e.g. Postgres then Redis) without handing out a duplicate.
|
|
146
|
+
"""
|
|
147
|
+
port = preferred
|
|
148
|
+
while port in reserved or not _port_is_free(port):
|
|
149
|
+
port += 1
|
|
150
|
+
reserved.add(port)
|
|
151
|
+
return port
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
@main.command()
|
|
155
|
+
def init():
|
|
156
|
+
"""Scaffold a new DjangoRocket project in the current directory."""
|
|
157
|
+
project_name = click.prompt("Project name", default="My Project")
|
|
158
|
+
base_template = importlib.resources.files("djangorocket.templates.projects").joinpath("base")
|
|
159
|
+
|
|
160
|
+
output_dir = os.getcwd()
|
|
161
|
+
|
|
162
|
+
# Pick a project directory name that is free both on disk and as a docker
|
|
163
|
+
# volume prefix, so several generated projects can coexist on one machine.
|
|
164
|
+
project_dirname = _available_project_dirname(
|
|
165
|
+
_slugify_dirname(project_name),
|
|
166
|
+
output_dir,
|
|
167
|
+
_existing_docker_volume_names(),
|
|
168
|
+
)
|
|
169
|
+
|
|
170
|
+
# Pick free host ports so several projects' Postgres/Redis can run at once.
|
|
171
|
+
reserved_ports = _reserved_sibling_ports(output_dir)
|
|
172
|
+
postgres_host_port = _pick_host_port(5432, reserved_ports)
|
|
173
|
+
redis_host_port = _pick_host_port(6379, reserved_ports)
|
|
174
|
+
|
|
175
|
+
try:
|
|
176
|
+
with _spinner("Creating your project..."):
|
|
177
|
+
project_dir = cookiecutter(
|
|
178
|
+
str(base_template),
|
|
179
|
+
no_input=True,
|
|
180
|
+
extra_context={
|
|
181
|
+
"project_name": project_name,
|
|
182
|
+
"project_dirname": project_dirname,
|
|
183
|
+
"postgres_host_port": str(postgres_host_port),
|
|
184
|
+
"redis_host_port": str(redis_host_port),
|
|
185
|
+
},
|
|
186
|
+
)
|
|
187
|
+
except OutputDirExistsException as e:
|
|
188
|
+
detail = str(e).removeprefix("Error: ")
|
|
189
|
+
raise click.ClickException(
|
|
190
|
+
f"{detail}. Remove it or pick a different project name and try again."
|
|
191
|
+
)
|
|
192
|
+
|
|
193
|
+
click.echo(click.style(f"✓ Created {os.path.relpath(project_dir)}", fg="green"))
|
|
194
|
+
# Point at the absolute path: `init` may have been run from anywhere (e.g.
|
|
195
|
+
# `make playground` runs it in $PLAYGROUND_BASE_DIR), and the next step is
|
|
196
|
+
# opening the project in an editor, not cd-ing in this shell.
|
|
197
|
+
click.echo(f" Open the project in your editor: {os.path.abspath(project_dir)}")
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
@main.command()
|
|
201
|
+
@click.argument("components", nargs=-1)
|
|
202
|
+
@click.option("--templates-dir", default=None, help="Directory where the new template source file should be added to.")
|
|
203
|
+
def add(components, templates_dir):
|
|
204
|
+
"""Add a UI cookiecutter template to an existing DjangoRocket project."""
|
|
205
|
+
try:
|
|
206
|
+
if templates_dir is None:
|
|
207
|
+
django_settings = DjangoSettingsManager()
|
|
208
|
+
templates_dir = django_settings.get_templates_dir()
|
|
209
|
+
|
|
210
|
+
add_components(components, templates_dir)
|
|
211
|
+
except Exception as e:
|
|
212
|
+
click.echo(f"Error: {e}")
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import importlib.resources
|
|
2
|
+
|
|
3
|
+
from cookiecutter.main import cookiecutter
|
|
4
|
+
|
|
5
|
+
UI_TEMPLATES_PACKAGE = "djangorocket.templates.ui"
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def available_components():
|
|
9
|
+
"""Names of the UI templates packaged with this install.
|
|
10
|
+
|
|
11
|
+
Templates ship as ``<name>.zip`` built from ``templates/ui/<name>/`` by
|
|
12
|
+
``setup.py`` (see ``tools/zip_templates.py``), so the packaged zips are the
|
|
13
|
+
source of truth for what ``add`` can install.
|
|
14
|
+
"""
|
|
15
|
+
return sorted(
|
|
16
|
+
resource.name.removesuffix(".zip")
|
|
17
|
+
for resource in importlib.resources.files(UI_TEMPLATES_PACKAGE).iterdir()
|
|
18
|
+
if resource.name.endswith(".zip")
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def add_components(components, templates_dir=None):
|
|
23
|
+
for component_name in components:
|
|
24
|
+
add_component(component_name, templates_dir)
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def add_component(component_name, templates_dir=None):
|
|
28
|
+
"""Render the ``component_name`` UI template into ``templates_dir``."""
|
|
29
|
+
resource = importlib.resources.files(UI_TEMPLATES_PACKAGE).joinpath(f"{component_name}.zip")
|
|
30
|
+
if not resource.is_file():
|
|
31
|
+
raise ValueError(
|
|
32
|
+
f"unknown component '{component_name}'. "
|
|
33
|
+
f"Available components: {', '.join(available_components()) or 'none'}."
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
# cookiecutter needs a real filesystem path, which a zipped install does not
|
|
37
|
+
# expose directly; ``as_file`` materialises one for the duration of the block.
|
|
38
|
+
with importlib.resources.as_file(resource) as template_path:
|
|
39
|
+
cookiecutter(str(template_path), output_dir=templates_dir)
|