womm-cli 4.0.0__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 (218) hide show
  1. womm/__init__.py +53 -0
  2. womm/__main__.py +48 -0
  3. womm/_version.py +10 -0
  4. womm/assets/copier/meta/copier.yml +15 -0
  5. womm/assets/copier/meta/template/README.md.jinja +32 -0
  6. womm/assets/copier/meta/template/copier.yml.jinja +13 -0
  7. womm/assets/copier/meta/template/template/.gitkeep +0 -0
  8. womm/assets/copier/official/javascript/copier.yml +104 -0
  9. womm/assets/copier/official/javascript/template/.gitignore.jinja +35 -0
  10. womm/assets/copier/official/javascript/template/.nvmrc.jinja +1 -0
  11. womm/assets/copier/official/javascript/template/.prettierignore.jinja +10 -0
  12. womm/assets/copier/official/javascript/template/README.md.jinja +81 -0
  13. womm/assets/copier/official/javascript/template/biome.json.jinja +54 -0
  14. womm/assets/copier/official/javascript/template/eslint.config.mjs.jinja +51 -0
  15. womm/assets/copier/official/javascript/template/index.html.jinja +12 -0
  16. womm/assets/copier/official/javascript/template/package.json.jinja +88 -0
  17. womm/assets/copier/official/javascript/template/prettier.config.mjs.jinja +8 -0
  18. womm/assets/copier/official/javascript/template/src/App.jsx.jinja +10 -0
  19. womm/assets/copier/official/javascript/template/src/App.tsx.jinja +10 -0
  20. womm/assets/copier/official/javascript/template/src/App.vue.jinja +18 -0
  21. womm/assets/copier/official/javascript/template/src/index.jsx.jinja +10 -0
  22. womm/assets/copier/official/javascript/template/src/index.tsx.jinja +11 -0
  23. womm/assets/copier/official/javascript/template/src/main.js.jinja +21 -0
  24. womm/assets/copier/official/javascript/template/src/main.ts.jinja +21 -0
  25. womm/assets/copier/official/javascript/template/tsconfig.json.jinja +35 -0
  26. womm/assets/copier/official/javascript/template/vite.config.mjs.jinja +10 -0
  27. womm/assets/copier/official/javascript/template/{% if with_ci %}.github{% endif %}/workflows/ci.yml.jinja +63 -0
  28. womm/assets/copier/official/javascript/template/{% if with_tests %}tests{% endif %}/smoke.test.js.jinja +12 -0
  29. womm/assets/copier/official/javascript/template/{% if with_tests %}tests{% endif %}/smoke.test.ts.jinja +12 -0
  30. womm/assets/copier/official/javascript/template/{% if with_vscode %}.vscode{% endif %}/extensions.json.jinja +4 -0
  31. womm/assets/copier/official/javascript/template/{% if with_vscode %}.vscode{% endif %}/settings.json.jinja +27 -0
  32. womm/assets/copier/official/python/copier.yml +107 -0
  33. womm/assets/copier/official/python/template/.gitignore.jinja +40 -0
  34. womm/assets/copier/official/python/template/.pre-commit-config.yaml.jinja +19 -0
  35. womm/assets/copier/official/python/template/.python-version.jinja +1 -0
  36. womm/assets/copier/official/python/template/README.md.jinja +83 -0
  37. womm/assets/copier/official/python/template/pyproject.toml.jinja +114 -0
  38. womm/assets/copier/official/python/template/{% if framework == 'django' %}manage.py{% endif %}.jinja +23 -0
  39. womm/assets/copier/official/python/template/{% if not use_src_layout %}{{ package_name }}{% endif %}/__init__.py.jinja +3 -0
  40. womm/assets/copier/official/python/template/{% if not use_src_layout %}{{ package_name }}{% endif %}/asgi.py.jinja +9 -0
  41. womm/assets/copier/official/python/template/{% if not use_src_layout %}{{ package_name }}{% endif %}/core/__init__.py.jinja +0 -0
  42. womm/assets/copier/official/python/template/{% if not use_src_layout %}{{ package_name }}{% endif %}/core/apps.py.jinja +10 -0
  43. womm/assets/copier/official/python/template/{% if not use_src_layout %}{{ package_name }}{% endif %}/core/models.py.jinja +1 -0
  44. womm/assets/copier/official/python/template/{% if not use_src_layout %}{{ package_name }}{% endif %}/core/views.py.jinja +8 -0
  45. womm/assets/copier/official/python/template/{% if not use_src_layout %}{{ package_name }}{% endif %}/py.typed +0 -0
  46. womm/assets/copier/official/python/template/{% if not use_src_layout %}{{ package_name }}{% endif %}/settings.py.jinja +81 -0
  47. womm/assets/copier/official/python/template/{% if not use_src_layout %}{{ package_name }}{% endif %}/urls.py.jinja +11 -0
  48. womm/assets/copier/official/python/template/{% if not use_src_layout %}{{ package_name }}{% endif %}/wsgi.py.jinja +9 -0
  49. womm/assets/copier/official/python/template/{% if use_src_layout %}src{% endif %}/{{ package_name }}/__init__.py.jinja +3 -0
  50. womm/assets/copier/official/python/template/{% if use_src_layout %}src{% endif %}/{{ package_name }}/asgi.py.jinja +9 -0
  51. womm/assets/copier/official/python/template/{% if use_src_layout %}src{% endif %}/{{ package_name }}/core/__init__.py.jinja +0 -0
  52. womm/assets/copier/official/python/template/{% if use_src_layout %}src{% endif %}/{{ package_name }}/core/apps.py.jinja +10 -0
  53. womm/assets/copier/official/python/template/{% if use_src_layout %}src{% endif %}/{{ package_name }}/core/models.py.jinja +1 -0
  54. womm/assets/copier/official/python/template/{% if use_src_layout %}src{% endif %}/{{ package_name }}/core/views.py.jinja +8 -0
  55. womm/assets/copier/official/python/template/{% if use_src_layout %}src{% endif %}/{{ package_name }}/py.typed +0 -0
  56. womm/assets/copier/official/python/template/{% if use_src_layout %}src{% endif %}/{{ package_name }}/settings.py.jinja +81 -0
  57. womm/assets/copier/official/python/template/{% if use_src_layout %}src{% endif %}/{{ package_name }}/urls.py.jinja +11 -0
  58. womm/assets/copier/official/python/template/{% if use_src_layout %}src{% endif %}/{{ package_name }}/wsgi.py.jinja +9 -0
  59. womm/assets/copier/official/python/template/{% if with_ci %}.github{% endif %}/workflows/ci.yml.jinja +78 -0
  60. womm/assets/copier/official/python/template/{% if with_tests %}tests{% endif %}/test_smoke.py.jinja +16 -0
  61. womm/assets/copier/official/python/template/{% if with_vscode %}.vscode{% endif %}/extensions.json.jinja +8 -0
  62. womm/assets/copier/official/python/template/{% if with_vscode %}.vscode{% endif %}/settings.json.jinja +28 -0
  63. womm/bin/refresh_env.cmd +130 -0
  64. womm/cli.py +111 -0
  65. womm/commands/__init__.py +30 -0
  66. womm/commands/core/__init__.py +29 -0
  67. womm/commands/core/doctor.py +52 -0
  68. womm/commands/core/path.py +337 -0
  69. womm/commands/project/__init__.py +31 -0
  70. womm/commands/project/create.py +128 -0
  71. womm/commands/project/setup.py +438 -0
  72. womm/commands/project/template.py +160 -0
  73. womm/commands/system/__init__.py +31 -0
  74. womm/commands/system/context/__init__.py +82 -0
  75. womm/commands/system/context/backup.py +344 -0
  76. womm/commands/system/context/inventory.py +111 -0
  77. womm/commands/system/context/registration.py +290 -0
  78. womm/commands/system/deps.py +165 -0
  79. womm/commands/system/system.py +130 -0
  80. womm/exceptions/__init__.py +69 -0
  81. womm/exceptions/common/__init__.py +55 -0
  82. womm/exceptions/common/command_service.py +91 -0
  83. womm/exceptions/common/file_service.py +60 -0
  84. womm/exceptions/common/security_service.py +44 -0
  85. womm/exceptions/common/validation_service.py +70 -0
  86. womm/exceptions/context/__init__.py +27 -0
  87. womm/exceptions/context/context_service.py +55 -0
  88. womm/exceptions/project/__init__.py +29 -0
  89. womm/exceptions/project/project_service.py +59 -0
  90. womm/exceptions/system/__init__.py +25 -0
  91. womm/exceptions/system/system_service.py +53 -0
  92. womm/interfaces/__init__.py +71 -0
  93. womm/interfaces/context/__init__.py +34 -0
  94. womm/interfaces/context/menu_interface.py +686 -0
  95. womm/interfaces/context/registry_interface.py +562 -0
  96. womm/interfaces/context/script_detector_interface.py +208 -0
  97. womm/interfaces/context/script_registrar.py +264 -0
  98. womm/interfaces/core/__init__.py +26 -0
  99. womm/interfaces/core/doctor_interface.py +102 -0
  100. womm/interfaces/dependencies/__init__.py +28 -0
  101. womm/interfaces/dependencies/deps_interface.py +160 -0
  102. womm/interfaces/project/__init__.py +36 -0
  103. womm/interfaces/project/create_interface.py +162 -0
  104. womm/interfaces/project/detection_interface.py +181 -0
  105. womm/interfaces/project/manager_interface.py +99 -0
  106. womm/interfaces/project/setup_interface.py +477 -0
  107. womm/interfaces/project/template_store_interface.py +196 -0
  108. womm/interfaces/system/__init__.py +32 -0
  109. womm/interfaces/system/detector_interface.py +84 -0
  110. womm/interfaces/system/environment_interface.py +110 -0
  111. womm/interfaces/system/path_interface.py +570 -0
  112. womm/services/__init__.py +70 -0
  113. womm/services/common/__init__.py +33 -0
  114. womm/services/common/base_validation_service.py +450 -0
  115. womm/services/common/command_runner_service.py +647 -0
  116. womm/services/common/file_scanner_service.py +483 -0
  117. womm/services/common/security_validator_service.py +348 -0
  118. womm/services/context/__init__.py +37 -0
  119. womm/services/context/backup_entries.py +148 -0
  120. womm/services/context/parameters.py +515 -0
  121. womm/services/context/registry_paths.py +56 -0
  122. womm/services/context/registry_service.py +573 -0
  123. womm/services/context/validation_service.py +691 -0
  124. womm/services/dependencies/__init__.py +29 -0
  125. womm/services/dependencies/probe.py +102 -0
  126. womm/services/project/__init__.py +48 -0
  127. womm/services/project/copier_project_creation_service.py +111 -0
  128. womm/services/project/destination_guard.py +96 -0
  129. womm/services/project/detection_service.py +354 -0
  130. womm/services/project/env_utils.py +333 -0
  131. womm/services/project/javascript_environment_service.py +348 -0
  132. womm/services/project/python_environment_service.py +245 -0
  133. womm/services/project/setup_profile_resolver.py +146 -0
  134. womm/services/project/template_store_service.py +344 -0
  135. womm/services/project/validation_service.py +418 -0
  136. womm/services/system/__init__.py +32 -0
  137. womm/services/system/detector_service.py +704 -0
  138. womm/services/system/environment_service.py +494 -0
  139. womm/services/system/path_service.py +642 -0
  140. womm/shared/__init__.py +30 -0
  141. womm/shared/configs/__init__.py +51 -0
  142. womm/shared/configs/context/__init__.py +43 -0
  143. womm/shared/configs/context/context_config.py +125 -0
  144. womm/shared/configs/context/context_file_types_config.py +159 -0
  145. womm/shared/configs/context/context_limits_config.py +187 -0
  146. womm/shared/configs/context/context_paths_config.py +115 -0
  147. womm/shared/configs/context/context_types_config.py +65 -0
  148. womm/shared/configs/context/script_config.py +219 -0
  149. womm/shared/configs/dependencies/__init__.py +32 -0
  150. womm/shared/configs/dependencies/runtime_config.py +46 -0
  151. womm/shared/configs/dependencies/runtime_package_manager_config.py +48 -0
  152. womm/shared/configs/logging_config.py +89 -0
  153. womm/shared/configs/project/__init__.py +33 -0
  154. womm/shared/configs/project/project_config.py +109 -0
  155. womm/shared/configs/project/project_structure_config.py +88 -0
  156. womm/shared/configs/project/python_project_config.py +165 -0
  157. womm/shared/configs/security/__init__.py +26 -0
  158. womm/shared/configs/security/security_patterns_config.py +242 -0
  159. womm/shared/configs/system/__init__.py +28 -0
  160. womm/shared/configs/system/system_detector_config.py +210 -0
  161. womm/shared/configs/system/system_environment_config.py +101 -0
  162. womm/shared/models/__init__.py +13 -0
  163. womm/shared/models/template_source.py +65 -0
  164. womm/shared/paths.py +192 -0
  165. womm/shared/results/__init__.py +138 -0
  166. womm/shared/results/base.py +85 -0
  167. womm/shared/results/command_results.py +61 -0
  168. womm/shared/results/context_results.py +345 -0
  169. womm/shared/results/dependency_results.py +110 -0
  170. womm/shared/results/doctor_results.py +41 -0
  171. womm/shared/results/file_results.py +97 -0
  172. womm/shared/results/project_results.py +163 -0
  173. womm/shared/results/security_results.py +128 -0
  174. womm/shared/results/system_results.py +268 -0
  175. womm/shared/results/template_results.py +43 -0
  176. womm/shared/runtime.py +36 -0
  177. womm/ui/__init__.py +31 -0
  178. womm/ui/common/__init__.py +39 -0
  179. womm/ui/common/interactive_menu.py +246 -0
  180. womm/ui/common/logging.py +184 -0
  181. womm/ui/common/prompts.py +93 -0
  182. womm/ui/context/__init__.py +31 -0
  183. womm/ui/context/display.py +485 -0
  184. womm/ui/context/menu_display.py +189 -0
  185. womm/ui/context/wizard.py +557 -0
  186. womm/ui/project/__init__.py +42 -0
  187. womm/ui/project/create/create_completion_summaries.py +55 -0
  188. womm/ui/project/project_wizard.py +174 -0
  189. womm/ui/project/setup/setup_completion_summaries.py +111 -0
  190. womm/ui/project/templates/template_store_display.py +128 -0
  191. womm/ui/system/__init__.py +60 -0
  192. womm/ui/system/display.py +531 -0
  193. womm/ui/system/path_display.py +387 -0
  194. womm/utils/__init__.py +23 -0
  195. womm/utils/common/__init__.py +49 -0
  196. womm/utils/common/file_scanner_utils.py +110 -0
  197. womm/utils/common/path_resolver_utils.py +127 -0
  198. womm/utils/common/safe_fs_utils.py +135 -0
  199. womm/utils/context/__init__.py +54 -0
  200. womm/utils/context/core_utils.py +345 -0
  201. womm/utils/context/icon_utils.py +259 -0
  202. womm/utils/project/__init__.py +106 -0
  203. womm/utils/project/asset_utils.py +154 -0
  204. womm/utils/project/core_utils.py +391 -0
  205. womm/utils/project/file_utils.py +494 -0
  206. womm/utils/project/platform_utils.py +170 -0
  207. womm/utils/project/validation_utils.py +273 -0
  208. womm/utils/security/__init__.py +46 -0
  209. womm/utils/security/security_validation_utils.py +258 -0
  210. womm/utils/system/__init__.py +69 -0
  211. womm/utils/system/detector_utils.py +299 -0
  212. womm/utils/system/environment_utils.py +172 -0
  213. womm/utils/system/path_utils.py +101 -0
  214. womm_cli-4.0.0.dist-info/METADATA +203 -0
  215. womm_cli-4.0.0.dist-info/RECORD +218 -0
  216. womm_cli-4.0.0.dist-info/WHEEL +4 -0
  217. womm_cli-4.0.0.dist-info/entry_points.txt +2 -0
  218. womm_cli-4.0.0.dist-info/licenses/LICENSE +21 -0
@@ -0,0 +1,438 @@
1
+ #!/usr/bin/env python3
2
+ # ///////////////////////////////////////////////////////////////
3
+ # SETUP - Setup Commands
4
+ # Project: works-on-my-machine
5
+ # ///////////////////////////////////////////////////////////////
6
+
7
+ """
8
+ Setup commands for WOMM CLI.
9
+
10
+ This module handles configuration of existing projects using the modular architecture.
11
+ Provides commands for setting up development environments in existing projects.
12
+ """
13
+
14
+ from __future__ import annotations
15
+
16
+ # ///////////////////////////////////////////////////////////////
17
+ # IMPORTS
18
+ # ///////////////////////////////////////////////////////////////
19
+ # Standard library imports
20
+ import sys
21
+ from pathlib import Path
22
+ from typing import Any, cast
23
+
24
+ # Third-party imports
25
+ import click
26
+ from ezplog import LogLevel
27
+
28
+ # Local imports
29
+ from ...interfaces import ProjectManagerInterface
30
+ from ...services.project.setup_profile_resolver import list_setup_identifiers
31
+ from ...ui.common import ezpl, ezprinter
32
+ from ...ui.project import ProjectWizard, print_project_setup_result
33
+
34
+ # ///////////////////////////////////////////////////////////////
35
+ # COMMAND GROUPS
36
+ # ///////////////////////////////////////////////////////////////
37
+
38
+
39
+ @click.group(invoke_without_command=True)
40
+ @click.help_option("-h", "--help")
41
+ @click.option(
42
+ "-v",
43
+ "--verbose",
44
+ is_flag=True,
45
+ help="Enable verbose output (DEBUG level)",
46
+ )
47
+ @click.pass_context
48
+ def setup_group(ctx: click.Context, verbose: bool) -> None:
49
+ """🔧 Configure existing projects with development tools."""
50
+ # Configure verbose mode if requested
51
+ if verbose:
52
+ ezpl.set_level(LogLevel.DEBUG.label)
53
+
54
+ if ctx.invoked_subcommand is None:
55
+ click.echo(ctx.get_help())
56
+
57
+
58
+ # ///////////////////////////////////////////////////////////////
59
+ # AUTO-DETECTION COMMANDS
60
+ # ///////////////////////////////////////////////////////////////
61
+
62
+
63
+ @setup_group.command("detect")
64
+ @click.help_option("-h", "--help")
65
+ @click.option(
66
+ "-p",
67
+ "--path",
68
+ "project_path",
69
+ type=click.Path(exists=True, file_okay=False, dir_okay=True, path_type=Path),
70
+ default=".",
71
+ help="Path to the project directory",
72
+ )
73
+ @click.option(
74
+ "-I",
75
+ "--interactive",
76
+ is_flag=True,
77
+ help="Run in interactive mode with guided setup",
78
+ )
79
+ @click.option(
80
+ "-v",
81
+ "--verbose",
82
+ is_flag=True,
83
+ help="Enable verbose output (DEBUG level)",
84
+ )
85
+ def setup_detect(
86
+ project_path: Path,
87
+ interactive: bool,
88
+ verbose: bool,
89
+ ) -> None:
90
+ """🔍 Auto-detect project type and configure development environment."""
91
+ # Configure verbose mode if requested
92
+ if verbose:
93
+ ezpl.set_level(LogLevel.DEBUG.label)
94
+
95
+ # Initialize project manager (lazy loading)
96
+ project_manager = ProjectManagerInterface()
97
+
98
+ try:
99
+ # Detect project type using ProjectManagerInterface
100
+ detection_result = project_manager.detect_project_type(project_path)
101
+ detected_type = detection_result.project_type
102
+ confidence = detection_result.confidence
103
+
104
+ if detected_type == "unknown" or not detected_type:
105
+ if not detection_result.success and detection_result.error:
106
+ ezprinter.error(
107
+ f"Error detecting project type: {detection_result.error}"
108
+ )
109
+ else:
110
+ ezprinter.error(
111
+ "No suitable project type detected in the specified directory"
112
+ )
113
+ known = ", ".join(
114
+ identifier for identifier, _description in list_setup_identifiers()
115
+ )
116
+ ezprinter.info(f"Supported project types: {known}")
117
+ sys.exit(1)
118
+
119
+ ezprinter.success(
120
+ f"Detected project type: {detected_type} (confidence: {confidence}%)"
121
+ )
122
+
123
+ # Interactive mode
124
+ if interactive:
125
+ success = _run_interactive_setup(
126
+ project_manager, detected_type, project_path
127
+ )
128
+ if not success:
129
+ sys.exit(1)
130
+ return
131
+
132
+ # Non-interactive mode
133
+ options: dict[str, Any] = {}
134
+ success = _run_direct_setup(
135
+ project_manager, detected_type, project_path, options
136
+ )
137
+ if not success:
138
+ sys.exit(1)
139
+ return
140
+
141
+ except Exception as e:
142
+ ezprinter.error(f"Error detecting project type: {e}")
143
+ sys.exit(1)
144
+
145
+
146
+ # ///////////////////////////////////////////////////////////////
147
+ # PYTHON PROJECT COMMANDS
148
+ # ///////////////////////////////////////////////////////////////
149
+
150
+
151
+ @setup_group.command("python")
152
+ @click.help_option("-h", "--help")
153
+ @click.option(
154
+ "-p",
155
+ "--path",
156
+ "project_path",
157
+ type=click.Path(exists=True, file_okay=False, dir_okay=True, path_type=Path),
158
+ default=".",
159
+ help="Path to the Python project directory",
160
+ )
161
+ @click.option(
162
+ "-I",
163
+ "--interactive",
164
+ is_flag=True,
165
+ help="Run in interactive mode with guided setup",
166
+ )
167
+ @click.option(
168
+ "--virtual-env",
169
+ is_flag=True,
170
+ help="Create virtual environment",
171
+ )
172
+ @click.option(
173
+ "--install-deps",
174
+ is_flag=True,
175
+ help="Install dependencies",
176
+ )
177
+ @click.option(
178
+ "--setup-dev-tools",
179
+ is_flag=True,
180
+ help="Setup development tools (linting, formatting, etc.)",
181
+ )
182
+ @click.option(
183
+ "--setup-git-hooks",
184
+ is_flag=True,
185
+ help="Setup Git hooks",
186
+ )
187
+ @click.option(
188
+ "-v",
189
+ "--verbose",
190
+ is_flag=True,
191
+ help="Enable verbose output (DEBUG level)",
192
+ )
193
+ def setup_python(
194
+ project_path: Path,
195
+ interactive: bool,
196
+ virtual_env: bool,
197
+ install_deps: bool,
198
+ setup_dev_tools: bool,
199
+ setup_git_hooks: bool,
200
+ verbose: bool,
201
+ ) -> None:
202
+ """🐍 Configure existing Python project with development environment."""
203
+ # Configure verbose mode if requested
204
+ if verbose:
205
+ ezpl.set_level(LogLevel.DEBUG.label)
206
+
207
+ # Initialize project manager
208
+ project_manager = ProjectManagerInterface()
209
+
210
+ try:
211
+ # Interactive mode
212
+ if interactive:
213
+ success = _run_interactive_setup(project_manager, "python", project_path)
214
+ if not success:
215
+ sys.exit(1)
216
+ return
217
+
218
+ # Non-interactive mode
219
+ options = {
220
+ "virtual_env": virtual_env,
221
+ "install_deps": install_deps,
222
+ "setup_dev_tools": setup_dev_tools,
223
+ "setup_git_hooks": setup_git_hooks,
224
+ }
225
+ success = _run_direct_setup(project_manager, "python", project_path, options)
226
+ if not success:
227
+ sys.exit(1)
228
+ return
229
+
230
+ except Exception as e:
231
+ ezprinter.error(f"Error configuring Python project: {e}")
232
+ sys.exit(1)
233
+
234
+
235
+ # ///////////////////////////////////////////////////////////////
236
+ # JAVASCRIPT PROJECT COMMANDS
237
+ # ///////////////////////////////////////////////////////////////
238
+
239
+
240
+ @setup_group.command("javascript")
241
+ @click.help_option("-h", "--help")
242
+ @click.option(
243
+ "-p",
244
+ "--path",
245
+ "project_path",
246
+ type=click.Path(exists=True, file_okay=False, dir_okay=True, path_type=Path),
247
+ default=".",
248
+ help="Path to the JavaScript project directory",
249
+ )
250
+ @click.option(
251
+ "-t",
252
+ "--type",
253
+ "project_type",
254
+ type=click.Choice(["javascript", "react", "vue"]),
255
+ help="JavaScript project type (auto-detected if not specified)",
256
+ )
257
+ @click.option(
258
+ "-I",
259
+ "--interactive",
260
+ is_flag=True,
261
+ help="Run in interactive mode with guided setup",
262
+ )
263
+ @click.option(
264
+ "--install-deps",
265
+ is_flag=True,
266
+ help="Install dependencies",
267
+ )
268
+ @click.option(
269
+ "--setup-dev-tools",
270
+ is_flag=True,
271
+ help="Setup development tools (linting, formatting, etc.)",
272
+ )
273
+ @click.option(
274
+ "--setup-git-hooks",
275
+ is_flag=True,
276
+ help="Setup Git hooks",
277
+ )
278
+ @click.option(
279
+ "-v",
280
+ "--verbose",
281
+ is_flag=True,
282
+ help="Enable verbose output (DEBUG level)",
283
+ )
284
+ def setup_javascript(
285
+ project_path: Path,
286
+ project_type: str | None,
287
+ interactive: bool,
288
+ install_deps: bool,
289
+ setup_dev_tools: bool,
290
+ setup_git_hooks: bool,
291
+ verbose: bool,
292
+ ) -> None:
293
+ """🟨 Configure existing JavaScript project with development environment."""
294
+ # Configure verbose mode if requested
295
+ if verbose:
296
+ ezpl.set_level(LogLevel.DEBUG.label)
297
+
298
+ # Initialize project manager
299
+ project_manager = ProjectManagerInterface()
300
+
301
+ try:
302
+ # Auto-detect type if not specified
303
+ if not project_type:
304
+ detection_result = project_manager.detect_project_type(project_path)
305
+ detected_type = detection_result.project_type
306
+ confidence = detection_result.confidence
307
+ if detected_type in ["javascript", "react", "vue"]:
308
+ project_type = detected_type
309
+ ezprinter.info(
310
+ f"Auto-detected project type: {project_type} (confidence: {confidence}%)"
311
+ )
312
+ else:
313
+ ezprinter.error("Could not auto-detect JavaScript project type")
314
+ ezprinter.info("Please specify --type (javascript, react, vue)")
315
+ sys.exit(1)
316
+
317
+ if not project_type:
318
+ ezprinter.error("Project type is required for setup")
319
+ sys.exit(1)
320
+ project_type_value = cast(str, project_type)
321
+
322
+ # Interactive mode
323
+ if interactive:
324
+ success = _run_interactive_setup(
325
+ project_manager, project_type_value, project_path
326
+ )
327
+ if not success:
328
+ sys.exit(1)
329
+ return
330
+
331
+ # Non-interactive mode
332
+ options = {
333
+ "install_deps": install_deps,
334
+ "setup_dev_tools": setup_dev_tools,
335
+ "setup_git_hooks": setup_git_hooks,
336
+ }
337
+ success = _run_direct_setup(
338
+ project_manager, project_type_value, project_path, options
339
+ )
340
+ if not success:
341
+ sys.exit(1)
342
+ return
343
+
344
+ except Exception as e:
345
+ ezprinter.error(f"Error configuring JavaScript project: {e}")
346
+ sys.exit(1)
347
+
348
+
349
+ # ///////////////////////////////////////////////////////////////
350
+ # HELPER FUNCTIONS - INTERACTIVE MODES
351
+ # ///////////////////////////////////////////////////////////////
352
+
353
+
354
+ def _run_interactive_setup(
355
+ project_manager: ProjectManagerInterface, project_type: str, project_path: Path
356
+ ) -> bool:
357
+ """Run interactive project setup."""
358
+ # Get setup configuration
359
+ config = ProjectWizard.run_interactive_setup_for_existing_project(
360
+ project_type, project_path
361
+ )
362
+ if not config:
363
+ ezprinter.error("Project setup cancelled")
364
+ return False
365
+
366
+ # Configure project
367
+ options = config.get("options", {})
368
+ if not isinstance(options, dict):
369
+ ezprinter.error("Invalid options returned by wizard")
370
+ return False
371
+
372
+ def _coerce_bool(value: object) -> bool:
373
+ if isinstance(value, str):
374
+ return value.strip().lower() in {"1", "true", "yes", "y", "on"}
375
+ return bool(value)
376
+
377
+ virtual_env = _coerce_bool(options.get("virtual_env", False))
378
+ install_deps = _coerce_bool(options.get("install_deps", False))
379
+ setup_dev_tools = _coerce_bool(options.get("setup_dev_tools", False))
380
+ setup_git_hooks = _coerce_bool(options.get("setup_git_hooks", False))
381
+
382
+ result = project_manager.setup_project(
383
+ project_type=project_type,
384
+ project_path=project_path,
385
+ virtual_env=virtual_env,
386
+ install_deps=install_deps,
387
+ setup_dev_tools=setup_dev_tools,
388
+ setup_git_hooks=setup_git_hooks,
389
+ )
390
+
391
+ if result.success:
392
+ print_project_setup_result(result)
393
+ return True
394
+ ezprinter.error(f"Failed to configure {project_type} project: {result.error}")
395
+ return False
396
+
397
+
398
+ # ///////////////////////////////////////////////////////////////
399
+ # HELPER FUNCTIONS - DIRECT MODES
400
+ # ///////////////////////////////////////////////////////////////
401
+
402
+
403
+ def _run_direct_setup(
404
+ project_manager: ProjectManagerInterface,
405
+ project_type: str,
406
+ project_path: Path,
407
+ options: dict[str, Any] | None = None,
408
+ ) -> bool:
409
+ """Run direct project setup."""
410
+
411
+ if options is None:
412
+ options = {}
413
+
414
+ def _coerce_bool(value: object) -> bool:
415
+ if isinstance(value, str):
416
+ return value.strip().lower() in {"1", "true", "yes", "y", "on"}
417
+ return bool(value)
418
+
419
+ virtual_env = _coerce_bool(options.get("virtual_env", False))
420
+ install_deps = _coerce_bool(options.get("install_deps", False))
421
+ setup_dev_tools = _coerce_bool(options.get("setup_dev_tools", False))
422
+ setup_git_hooks = _coerce_bool(options.get("setup_git_hooks", False))
423
+
424
+ # Configure project
425
+ result = project_manager.setup_project(
426
+ project_type=project_type,
427
+ project_path=project_path,
428
+ virtual_env=virtual_env,
429
+ install_deps=install_deps,
430
+ setup_dev_tools=setup_dev_tools,
431
+ setup_git_hooks=setup_git_hooks,
432
+ )
433
+
434
+ if result.success:
435
+ print_project_setup_result(result)
436
+ return True
437
+ ezprinter.error(f"Failed to configure {project_type} project: {result.error}")
438
+ return False
@@ -0,0 +1,160 @@
1
+ #!/usr/bin/env python3
2
+ # ///////////////////////////////////////////////////////////////
3
+ # TEMPLATE - Template Catalog Commands
4
+ # Project: works-on-my-machine
5
+ # ///////////////////////////////////////////////////////////////
6
+
7
+ """
8
+ Template catalog commands for WOMM CLI.
9
+
10
+ This module manages the Copier template catalog: listing, showing, adding,
11
+ removing and updating entries. Rendering is delegated to Copier itself
12
+ (see ``womm create``) — this vertical is catalog CRUD only.
13
+ """
14
+
15
+ from __future__ import annotations
16
+
17
+ # ///////////////////////////////////////////////////////////////
18
+ # IMPORTS
19
+ # ///////////////////////////////////////////////////////////////
20
+ # Standard library imports
21
+ from pathlib import Path
22
+
23
+ # Third-party imports
24
+ import click
25
+
26
+ # Local imports
27
+ from ...interfaces.project.template_store_interface import TemplateStoreInterface
28
+ from ...ui.project import (
29
+ render_project_creation_result,
30
+ render_template_list,
31
+ render_template_result,
32
+ )
33
+ from .create import parse_data_options
34
+
35
+ # ///////////////////////////////////////////////////////////////
36
+ # COMMAND GROUP
37
+ # ///////////////////////////////////////////////////////////////
38
+
39
+
40
+ @click.group(invoke_without_command=True)
41
+ @click.help_option("-h", "--help")
42
+ @click.pass_context
43
+ def template_group(ctx: click.Context) -> None:
44
+ """Manage the Copier template catalog."""
45
+ if ctx.invoked_subcommand is None:
46
+ click.echo(ctx.get_help())
47
+
48
+
49
+ # ///////////////////////////////////////////////////////////////
50
+ # COMMANDS
51
+ # ///////////////////////////////////////////////////////////////
52
+
53
+
54
+ @template_group.command("list")
55
+ @click.help_option("-h", "--help")
56
+ @click.option("-v", "--verbose", is_flag=True, help="Show detailed output.")
57
+ def template_list(verbose: bool) -> None:
58
+ """List every known template."""
59
+ result = TemplateStoreInterface().list_templates()
60
+ render_template_list(result, verbose=verbose)
61
+ if not result.success:
62
+ raise SystemExit(1)
63
+
64
+
65
+ @template_group.command("show")
66
+ @click.help_option("-h", "--help")
67
+ @click.argument("identifier")
68
+ @click.option("-v", "--verbose", is_flag=True, help="Show detailed output.")
69
+ def template_show(identifier: str, verbose: bool) -> None:
70
+ """Show a single catalog entry."""
71
+ result = TemplateStoreInterface().show_template(identifier)
72
+ render_template_result(result, verbose=verbose)
73
+ if not result.success:
74
+ raise SystemExit(1)
75
+
76
+
77
+ @template_group.command("add")
78
+ @click.help_option("-h", "--help")
79
+ @click.argument("identifier")
80
+ @click.argument("source", type=click.Path(path_type=Path))
81
+ @click.option("-v", "--verbose", is_flag=True, help="Show detailed output.")
82
+ def template_add(identifier: str, source: Path, verbose: bool) -> None:
83
+ """Register a local template under the user namespace."""
84
+ result = TemplateStoreInterface().add_template(identifier, source)
85
+ render_template_result(result, verbose=verbose)
86
+ if not result.success:
87
+ raise SystemExit(1)
88
+
89
+
90
+ @template_group.command("remove")
91
+ @click.help_option("-h", "--help")
92
+ @click.argument("identifier")
93
+ @click.option("-v", "--verbose", is_flag=True, help="Show detailed output.")
94
+ def template_remove(identifier: str, verbose: bool) -> None:
95
+ """Unregister a user template."""
96
+ result = TemplateStoreInterface().remove_template(identifier)
97
+ render_template_result(result, verbose=verbose)
98
+ if not result.success:
99
+ raise SystemExit(1)
100
+
101
+
102
+ @template_group.command("update")
103
+ @click.help_option("-h", "--help")
104
+ @click.argument("identifier")
105
+ @click.argument("source", type=click.Path(path_type=Path))
106
+ @click.option("-v", "--verbose", is_flag=True, help="Show detailed output.")
107
+ def template_update(identifier: str, source: Path, verbose: bool) -> None:
108
+ """Point an existing user template at a new source."""
109
+ result = TemplateStoreInterface().update_template(identifier, source)
110
+ render_template_result(result, verbose=verbose)
111
+ if not result.success:
112
+ raise SystemExit(1)
113
+
114
+
115
+ @template_group.command("init")
116
+ @click.help_option("-h", "--help")
117
+ @click.argument("destination", type=click.Path(path_type=Path))
118
+ @click.option(
119
+ "--data",
120
+ "data",
121
+ multiple=True,
122
+ metavar="KEY=VALUE",
123
+ help="Pre-fill a meta-template answer. Repeatable.",
124
+ )
125
+ @click.option(
126
+ "--defaults",
127
+ is_flag=True,
128
+ help="Use meta-template defaults instead of prompting.",
129
+ )
130
+ @click.option(
131
+ "--force",
132
+ is_flag=True,
133
+ help="Scaffold into a non-empty destination.",
134
+ )
135
+ @click.option("-v", "--verbose", is_flag=True, help="Show detailed output.")
136
+ def template_init(
137
+ destination: Path,
138
+ data: tuple[str, ...],
139
+ defaults: bool,
140
+ force: bool,
141
+ verbose: bool,
142
+ ) -> None:
143
+ """Scaffold a new Copier template skeleton."""
144
+ answers = parse_data_options(data)
145
+ result = TemplateStoreInterface().init_template(
146
+ destination,
147
+ answers=answers,
148
+ force=force,
149
+ defaults=defaults,
150
+ )
151
+ render_project_creation_result(result, verbose=verbose)
152
+ if not result.success:
153
+ raise SystemExit(1)
154
+
155
+
156
+ # ///////////////////////////////////////////////////////////////
157
+ # PUBLIC API
158
+ # ///////////////////////////////////////////////////////////////
159
+
160
+ __all__ = ["template_group"]
@@ -0,0 +1,31 @@
1
+ #!/usr/bin/env python3
2
+ # ///////////////////////////////////////////////////////////////
3
+ # COMMANDS SYSTEM - System CLI Commands Package
4
+ # Project: works-on-my-machine
5
+ # ///////////////////////////////////////////////////////////////
6
+
7
+ """
8
+ System WOMM CLI Commands Package.
9
+
10
+ This package contains system-related command modules for WOMM.
11
+ """
12
+
13
+ from __future__ import annotations
14
+
15
+ # ///////////////////////////////////////////////////////////////
16
+ # IMPORTS
17
+ # ///////////////////////////////////////////////////////////////
18
+ # Local imports
19
+ from .context import context_group
20
+ from .deps import deps_group
21
+ from .system import system_group
22
+
23
+ # ///////////////////////////////////////////////////////////////
24
+ # PUBLIC API
25
+ # ///////////////////////////////////////////////////////////////
26
+
27
+ __all__ = [
28
+ "context_group",
29
+ "deps_group",
30
+ "system_group",
31
+ ]