django-spire 0.16.13__py3-none-any.whl → 0.17.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (79) hide show
  1. django_spire/consts.py +1 -1
  2. django_spire/core/management/commands/spire_startapp.py +84 -46
  3. django_spire/core/management/commands/spire_startapp_pkg/__init__.py +60 -0
  4. django_spire/core/management/commands/spire_startapp_pkg/builder.py +91 -0
  5. django_spire/core/management/commands/spire_startapp_pkg/config.py +115 -0
  6. django_spire/core/management/commands/spire_startapp_pkg/filesystem.py +125 -0
  7. django_spire/core/management/commands/spire_startapp_pkg/generator.py +167 -0
  8. django_spire/core/management/commands/spire_startapp_pkg/maps.py +783 -25
  9. django_spire/core/management/commands/spire_startapp_pkg/permissions.py +147 -0
  10. django_spire/core/management/commands/spire_startapp_pkg/processor.py +144 -57
  11. django_spire/core/management/commands/spire_startapp_pkg/registry.py +89 -0
  12. django_spire/core/management/commands/spire_startapp_pkg/reporter.py +245 -108
  13. django_spire/core/management/commands/spire_startapp_pkg/resolver.py +86 -0
  14. django_spire/core/management/commands/spire_startapp_pkg/template/app/__init__.py.template +0 -0
  15. django_spire/core/management/commands/spire_startapp_pkg/template/app/apps.py.template +15 -0
  16. django_spire/core/management/commands/spire_startapp_pkg/template/app/forms.py.template +18 -0
  17. django_spire/core/management/commands/spire_startapp_pkg/template/app/intelligence/__init__.py.template +0 -0
  18. django_spire/core/management/commands/spire_startapp_pkg/template/app/intelligence/bots.py.template +18 -0
  19. django_spire/core/management/commands/spire_startapp_pkg/template/app/intelligence/intel.py.template +7 -0
  20. django_spire/core/management/commands/spire_startapp_pkg/template/app/intelligence/prompts.py.template +32 -0
  21. django_spire/core/management/commands/spire_startapp_pkg/template/app/migrations/__init__.py.template +0 -0
  22. django_spire/core/management/commands/spire_startapp_pkg/template/app/models.py.template +52 -0
  23. django_spire/core/management/commands/spire_startapp_pkg/template/app/querysets.py.template +20 -0
  24. django_spire/core/management/commands/spire_startapp_pkg/template/app/seeding/__init__.py.template +0 -0
  25. django_spire/core/management/commands/spire_startapp_pkg/template/app/seeding/seed.py.template +6 -0
  26. django_spire/core/management/commands/spire_startapp_pkg/template/app/seeding/seeder.py.template +26 -0
  27. django_spire/core/management/commands/spire_startapp_pkg/template/app/services/__init__.py.template +0 -0
  28. django_spire/core/management/commands/spire_startapp_pkg/template/app/services/factory_service.py.template +12 -0
  29. django_spire/core/management/commands/spire_startapp_pkg/template/app/services/intelligence_service.py.template +12 -0
  30. django_spire/core/management/commands/spire_startapp_pkg/template/app/services/processor_service.py.template +12 -0
  31. django_spire/core/management/commands/spire_startapp_pkg/template/app/services/service.py.template +22 -0
  32. django_spire/core/management/commands/spire_startapp_pkg/template/app/services/transformation_service.py.template +12 -0
  33. django_spire/core/management/commands/spire_startapp_pkg/template/app/tests/__init__.py.template +0 -0
  34. django_spire/core/management/commands/spire_startapp_pkg/template/app/tests/test_intelligence/__init__.py.template +0 -0
  35. django_spire/core/management/commands/spire_startapp_pkg/template/app/tests/test_intelligence/test_bots.py.template +8 -0
  36. django_spire/core/management/commands/spire_startapp_pkg/template/app/tests/test_models.py.template +8 -0
  37. django_spire/core/management/commands/spire_startapp_pkg/template/app/tests/test_services/__init__.py.template +0 -0
  38. django_spire/core/management/commands/spire_startapp_pkg/template/app/tests/test_services/test_factory_service.py.template +8 -0
  39. django_spire/core/management/commands/spire_startapp_pkg/template/app/tests/test_services/test_intelligence_service.py.template +8 -0
  40. django_spire/core/management/commands/spire_startapp_pkg/template/app/tests/test_services/test_processor_service.py.template +8 -0
  41. django_spire/core/management/commands/spire_startapp_pkg/template/app/tests/test_services/test_service.py.template +8 -0
  42. django_spire/core/management/commands/spire_startapp_pkg/template/app/tests/test_services/test_transformation_service.py.template +8 -0
  43. django_spire/core/management/commands/spire_startapp_pkg/template/app/tests/test_urls/__init__.py.template +0 -0
  44. django_spire/core/management/commands/spire_startapp_pkg/template/app/tests/test_urls/test_form_urls.py.template +8 -0
  45. django_spire/core/management/commands/spire_startapp_pkg/template/app/tests/test_urls/test_page_urls.py.template +8 -0
  46. django_spire/core/management/commands/spire_startapp_pkg/template/app/tests/test_views/__init__.py.template +0 -0
  47. django_spire/core/management/commands/spire_startapp_pkg/template/app/tests/test_views/test_form_views.py.template +8 -0
  48. django_spire/core/management/commands/spire_startapp_pkg/template/app/tests/test_views/test_page_views.py.template +8 -0
  49. django_spire/core/management/commands/spire_startapp_pkg/template/app/urls/__init__.py.template +9 -0
  50. django_spire/core/management/commands/spire_startapp_pkg/template/app/urls/form_urls.py.template +15 -0
  51. django_spire/core/management/commands/spire_startapp_pkg/template/app/urls/page_urls.py.template +11 -0
  52. django_spire/core/management/commands/spire_startapp_pkg/template/app/views/__init__.py.template +0 -0
  53. django_spire/core/management/commands/spire_startapp_pkg/template/app/views/form_views.py.template +134 -0
  54. django_spire/core/management/commands/spire_startapp_pkg/template/app/views/page_views.py.template +44 -0
  55. django_spire/core/management/commands/spire_startapp_pkg/template/templates/card/{spirechildapp_detail_card.html → ${detail_card_template_name}.html.template} +7 -7
  56. django_spire/core/management/commands/spire_startapp_pkg/template/templates/card/{spirechildapp_form_card.html → ${form_card_template_name}.html.template} +2 -2
  57. django_spire/core/management/commands/spire_startapp_pkg/template/templates/card/${list_card_template_name}.html.template +18 -0
  58. django_spire/core/management/commands/spire_startapp_pkg/template/templates/form/{spirechildapp_form.html → ${form_template_name}.html.template} +4 -4
  59. django_spire/core/management/commands/spire_startapp_pkg/template/templates/item/${item_template_name}.html.template +24 -0
  60. django_spire/core/management/commands/spire_startapp_pkg/template/templates/page/{spirechildapp_detail_page.html → ${detail_page_template_name}.html.template} +3 -3
  61. django_spire/core/management/commands/spire_startapp_pkg/template/templates/page/{spirechildapp_form_page.html → ${form_page_template_name}.html.template} +1 -1
  62. django_spire/core/management/commands/spire_startapp_pkg/template/templates/page/{spirechildapp_list_page.html → ${list_page_template_name}.html.template} +2 -2
  63. django_spire/core/management/commands/spire_startapp_pkg/user_input.py +252 -0
  64. django_spire/core/management/commands/spire_startapp_pkg/validator.py +96 -0
  65. django_spire/core/middleware/__init__.py +1 -2
  66. django_spire/profiling/__init__.py +13 -0
  67. django_spire/profiling/middleware/__init__.py +6 -0
  68. django_spire/{core → profiling}/middleware/profiling.py +63 -58
  69. django_spire/profiling/panel.py +345 -0
  70. django_spire/profiling/templates/panel.html +166 -0
  71. {django_spire-0.16.13.dist-info → django_spire-0.17.1.dist-info}/METADATA +1 -1
  72. {django_spire-0.16.13.dist-info → django_spire-0.17.1.dist-info}/RECORD +75 -23
  73. django_spire/core/management/commands/spire_startapp_pkg/constants.py +0 -4
  74. django_spire/core/management/commands/spire_startapp_pkg/manager.py +0 -176
  75. django_spire/core/management/commands/spire_startapp_pkg/template/templates/card/spirechildapp_list_card.html +0 -18
  76. django_spire/core/management/commands/spire_startapp_pkg/template/templates/item/spirechildapp_item.html +0 -24
  77. {django_spire-0.16.13.dist-info → django_spire-0.17.1.dist-info}/WHEEL +0 -0
  78. {django_spire-0.16.13.dist-info → django_spire-0.17.1.dist-info}/licenses/LICENSE.md +0 -0
  79. {django_spire-0.16.13.dist-info → django_spire-0.17.1.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,167 @@
1
+ from __future__ import annotations
2
+
3
+ from typing import TYPE_CHECKING
4
+
5
+ from django.core.management.base import CommandError
6
+
7
+ if TYPE_CHECKING:
8
+ from pathlib import Path
9
+
10
+ from django_spire.core.management.commands.spire_startapp_pkg.config import AppConfig, PathConfig
11
+ from django_spire.core.management.commands.spire_startapp_pkg.filesystem import FileSystemInterface
12
+ from django_spire.core.management.commands.spire_startapp_pkg.processor import TemplateProcessor
13
+ from django_spire.core.management.commands.spire_startapp_pkg.reporter import ReporterInterface
14
+
15
+
16
+ class AppGenerator:
17
+ """
18
+ Generates Django app structures from templates.
19
+
20
+ This class handles the creation of new Django apps by copying template
21
+ files and processing them with user-provided configuration.
22
+ """
23
+
24
+ def __init__(
25
+ self,
26
+ filesystem: FileSystemInterface,
27
+ processor: TemplateProcessor,
28
+ reporter: ReporterInterface,
29
+ path_config: PathConfig
30
+ ):
31
+ """
32
+ Initializes the AppGenerator with required dependencies.
33
+
34
+ :param filesystem: File system interface for file operations.
35
+ :param processor: Template processor for replacing placeholders.
36
+ :param reporter: Reporter for user feedback and output.
37
+ :param path_config: Configuration containing template paths.
38
+ """
39
+
40
+ self._filesystem = filesystem
41
+ self._path_config = path_config
42
+ self._processor = processor
43
+ self._reporter = reporter
44
+
45
+ def generate(self, config: AppConfig) -> None:
46
+ """
47
+ Generates a new Django app from templates.
48
+
49
+ Creates the app directory, copies template files, and processes
50
+ them with user configuration. Skips generation if the app already exists.
51
+
52
+ :param config: Configuration for the app to generate.
53
+ """
54
+
55
+ if self._filesystem.has_content(config.destination):
56
+ self._reporter.report_app_exists(config.app_path, config.destination)
57
+ return
58
+
59
+ self._validate_template_exists(self._path_config.app_template, 'app template')
60
+ self._reporter.report_creating_app(config.app_path, config.destination)
61
+
62
+ self._filesystem.create_directory(config.destination)
63
+ self._filesystem.copy_tree(self._path_config.app_template, config.destination)
64
+
65
+ self._processor.process_app_templates(
66
+ config.destination,
67
+ config.components,
68
+ config.user_inputs
69
+ )
70
+
71
+ self._reporter.report_app_creation_success(config.app_path)
72
+
73
+ def _validate_template_exists(self, path: Path, template_type: str) -> None:
74
+ """
75
+ Validates that a template directory exists.
76
+
77
+ :param path: Path to the template directory.
78
+ :param template_type: Description of the template type for error messages.
79
+ :raises CommandError: If the template directory does not exist.
80
+ """
81
+
82
+ if not self._filesystem.exists(path):
83
+ self._reporter.write('\n', self._reporter.style_notice)
84
+
85
+ message = (
86
+ f'Template directory "{path}" is missing. '
87
+ f'Ensure you have a valid {template_type}.'
88
+ )
89
+
90
+ raise CommandError(message)
91
+
92
+
93
+ class TemplateGenerator:
94
+ """
95
+ Generates HTML templates for Django apps.
96
+
97
+ This class handles the creation of HTML template files including
98
+ forms, cards, pages, and items for new Django apps.
99
+ """
100
+
101
+ def __init__(
102
+ self,
103
+ filesystem: FileSystemInterface,
104
+ processor: TemplateProcessor,
105
+ reporter: ReporterInterface,
106
+ path_config: PathConfig
107
+ ):
108
+ """
109
+ Initializes the TemplateGenerator with required dependencies.
110
+
111
+ :param filesystem: File system interface for file operations.
112
+ :param processor: Template processor for replacing placeholders.
113
+ :param reporter: Reporter for user feedback and output.
114
+ :param path_config: Configuration containing template paths.
115
+ """
116
+
117
+ self._filesystem = filesystem
118
+ self._path_config = path_config
119
+ self._processor = processor
120
+ self._reporter = reporter
121
+
122
+ def generate(self, config: AppConfig) -> None:
123
+ """
124
+ Generates HTML templates for a new Django app.
125
+
126
+ Creates the template directory, copies template files, and processes
127
+ them with user configuration. Skips generation if templates already exist.
128
+
129
+ :param config: Configuration for the templates to generate.
130
+ """
131
+
132
+ if self._filesystem.has_content(config.template_destination):
133
+ self._reporter.report_templates_exist(config.app_path, config.template_destination)
134
+ return
135
+
136
+ self._validate_template_exists(self._path_config.html_template, 'templates template')
137
+ self._reporter.report_creating_templates(config.app_path, config.template_destination)
138
+
139
+ self._filesystem.create_directory(config.template_destination)
140
+ self._filesystem.copy_tree(self._path_config.html_template, config.template_destination)
141
+
142
+ self._processor.process_html_templates(
143
+ config.template_destination,
144
+ config.components,
145
+ config.user_inputs
146
+ )
147
+
148
+ self._reporter.report_templates_creation_success(config.app_path)
149
+
150
+ def _validate_template_exists(self, path: Path, template_type: str) -> None:
151
+ """
152
+ Validates that a template directory exists.
153
+
154
+ :param path: Path to the template directory.
155
+ :param template_type: Description of the template type for error messages.
156
+ :raises CommandError: If the template directory does not exist.
157
+ """
158
+
159
+ if not self._filesystem.exists(path):
160
+ self._reporter.write('\n', self._reporter.style_notice)
161
+
162
+ message = (
163
+ f'Template directory "{path}" is missing. '
164
+ f'Ensure you have a valid {template_type}.'
165
+ )
166
+
167
+ raise CommandError(message)