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,494 @@
1
+ #!/usr/bin/env python3
2
+ # ///////////////////////////////////////////////////////////////
3
+ # PROJECT FILE UTILS - Project File Creation Utilities
4
+ # Project: works-on-my-machine
5
+ # ///////////////////////////////////////////////////////////////
6
+
7
+ """
8
+ Pure utility functions for creating project source files.
9
+
10
+ This module provides stateless functions for:
11
+ - Creating Python source files (main.py, __init__.py, test files)
12
+ - Creating JavaScript source files (main.js, components, etc.)
13
+ - File content generation
14
+ """
15
+
16
+ from __future__ import annotations
17
+
18
+ # ///////////////////////////////////////////////////////////////
19
+ # IMPORTS
20
+ # ///////////////////////////////////////////////////////////////
21
+ # Standard library imports
22
+ import logging
23
+ from pathlib import Path
24
+
25
+ # Local imports
26
+ from ...shared.configs.project import ProjectStructureConfig
27
+
28
+ # ///////////////////////////////////////////////////////////////
29
+ # LOGGER SETUP
30
+ # ///////////////////////////////////////////////////////////////
31
+
32
+ logger = logging.getLogger(__name__)
33
+
34
+ # ///////////////////////////////////////////////////////////////
35
+ # PYTHON FILE CREATION
36
+ # ///////////////////////////////////////////////////////////////
37
+
38
+
39
+ def create_python_main_files(project_path: Path, project_name: str) -> list[str]:
40
+ """Create Python main source files.
41
+
42
+ Args:
43
+ project_path: Path to the project
44
+ project_name: Name of the project
45
+
46
+ Returns:
47
+ list[str]: List of created file paths (relative to project_path)
48
+
49
+ Raises:
50
+ OSError: If file creation fails
51
+ """
52
+ # Create src directory structure
53
+ src_dir = project_path / ProjectStructureConfig.SOURCE_DIR
54
+ package_dir = src_dir / project_name.replace("-", "_")
55
+ package_dir.mkdir(parents=True, exist_ok=True)
56
+
57
+ created_files = []
58
+
59
+ # Create __init__.py
60
+ init_file = package_dir / "__init__.py"
61
+ init_content = f'"""Main package for {project_name}."""\n\n__version__ = "0.1.0"\n'
62
+ init_file.write_text(init_content, encoding="utf-8")
63
+ created_files.append(str(init_file.relative_to(project_path)))
64
+
65
+ # Create main.py
66
+ main_file = package_dir / "main.py"
67
+ main_content = f'''#!/usr/bin/env python3
68
+ """
69
+ Main entry point for {project_name}.
70
+
71
+ This module serves as the main entry point for the application.
72
+ """
73
+
74
+ import sys
75
+ from pathlib import Path
76
+
77
+ # Add src to Python path
78
+ src_path = Path(__file__).parent.parent
79
+ sys.path.insert(0, str(src_path))
80
+
81
+ from {project_name.replace("-", "_")} import __version__
82
+
83
+
84
+ def main():
85
+ """Main function."""
86
+ print(f"Hello from {project_name} v{{__version__}}!")
87
+ print("This is a Python project created with WOMM CLI.")
88
+
89
+ # Add your application logic here
90
+ return 0
91
+
92
+
93
+ if __name__ == "__main__":
94
+ sys.exit(main())
95
+ '''
96
+ main_file.write_text(main_content, encoding="utf-8")
97
+ main_file.chmod(0o755) # Make executable
98
+ created_files.append(str(main_file.relative_to(project_path)))
99
+
100
+ logger.debug(f"Created Python main files: {created_files}")
101
+ return created_files
102
+
103
+
104
+ def create_python_test_file(project_path: Path, project_name: str) -> list[str]:
105
+ """Create Python test file.
106
+
107
+ Args:
108
+ project_path: Path to the project
109
+ project_name: Name of the project
110
+
111
+ Returns:
112
+ list[str]: List of created file paths (relative to project_path)
113
+
114
+ Raises:
115
+ OSError: If file creation fails
116
+ """
117
+ test_dir = project_path / ProjectStructureConfig.TESTS_DIR
118
+ test_file = test_dir / f"test_{project_name.replace('-', '_')}.py"
119
+
120
+ test_content = f'''"""
121
+ Tests for {project_name}.
122
+
123
+ This module contains tests for the main functionality.
124
+ """
125
+
126
+ import pytest
127
+ from pathlib import Path
128
+
129
+ # Add src to Python path
130
+ src_path = Path(__file__).parent.parent / "src"
131
+ import sys
132
+ sys.path.insert(0, str(src_path))
133
+
134
+ from {project_name.replace("-", "_")} import __version__
135
+
136
+
137
+ def test_version():
138
+ """Test that version is defined."""
139
+ assert __version__ is not None
140
+ assert isinstance(__version__, str)
141
+
142
+
143
+ def test_import():
144
+ """Test that the package can be imported."""
145
+ import {project_name.replace("-", "_")}
146
+ assert {project_name.replace("-", "_")} is not None
147
+ '''
148
+ test_file.write_text(test_content, encoding="utf-8")
149
+
150
+ logger.debug(f"Created Python test file: {test_file.name}")
151
+ return [str(test_file.relative_to(project_path))]
152
+
153
+
154
+ # ///////////////////////////////////////////////////////////////
155
+ # JAVASCRIPT FILE CREATION
156
+ # ///////////////////////////////////////////////////////////////
157
+
158
+
159
+ def create_node_main_files(project_path: Path, project_name: str) -> list[str]:
160
+ """Create Node.js main source files.
161
+
162
+ Args:
163
+ project_path: Path to the project
164
+ project_name: Name of the project
165
+
166
+ Returns:
167
+ list[str]: List of created file paths (relative to project_path)
168
+
169
+ Raises:
170
+ OSError: If file creation fails
171
+ """
172
+ src_dir = project_path / ProjectStructureConfig.SOURCE_DIR
173
+ src_dir.mkdir(exist_ok=True)
174
+ created_files = []
175
+
176
+ # Create main.js
177
+ main_file = src_dir / "main.js"
178
+ main_content = f"""#!/usr/bin/env node
179
+ /**
180
+ * Main entry point for {project_name}.
181
+ *
182
+ * This module serves as the main entry point for the Node.js application.
183
+ */
184
+
185
+ const path = require('path');
186
+ const fs = require('fs');
187
+
188
+ // Read package.json for version info
189
+ const packageJson = JSON.parse(fs.readFileSync(path.join(__dirname, '..', 'package.json'), 'utf8'));
190
+
191
+ function main() {{
192
+ console.log(`Hello from ${{packageJson.name}} v${{packageJson.version}}!`);
193
+ console.log('This is a Node.js project created with WOMM CLI.');
194
+
195
+ // Add your application logic here
196
+ return 0;
197
+ }}
198
+
199
+ if (require.main === module) {{
200
+ process.exit(main());
201
+ }}
202
+
203
+ module.exports = {{ main }};
204
+ """
205
+ main_file.write_text(main_content, encoding="utf-8")
206
+ main_file.chmod(0o755) # Make executable
207
+ created_files.append(str(main_file.relative_to(project_path)))
208
+
209
+ # Create index.js
210
+ index_file = src_dir / "index.js"
211
+ index_content = f"""/**
212
+ * Entry point for {project_name}.
213
+ *
214
+ * This file exports the main functionality of the application.
215
+ */
216
+
217
+ const {{ main }} = require('./main');
218
+
219
+ module.exports = {{
220
+ main,
221
+ // Add other exports here
222
+ }};
223
+ """
224
+ index_file.write_text(index_content, encoding="utf-8")
225
+ created_files.append(str(index_file.relative_to(project_path)))
226
+
227
+ logger.debug(f"Created Node.js main files: {created_files}")
228
+ return created_files
229
+
230
+
231
+ def create_react_main_files(project_path: Path, project_name: str) -> list[str]:
232
+ """Create React main source files.
233
+
234
+ Args:
235
+ project_path: Path to the project
236
+ project_name: Name of the project
237
+
238
+ Returns:
239
+ list[str]: List of created file paths (relative to project_path)
240
+
241
+ Raises:
242
+ OSError: If file creation fails
243
+ """
244
+ src_dir = project_path / ProjectStructureConfig.SOURCE_DIR
245
+ src_dir.mkdir(exist_ok=True)
246
+ public_dir = project_path / "public"
247
+ public_dir.mkdir(exist_ok=True)
248
+ created_files = []
249
+
250
+ # Create App.jsx
251
+ app_file = src_dir / "App.jsx"
252
+ app_content = f"""import React from 'react';
253
+ import './App.css';
254
+
255
+ function App() {{
256
+ return (
257
+ <div className="App">
258
+ <header className="App-header">
259
+ <h1>Welcome to {project_name}</h1>
260
+ <p>This is a React project created with WOMM CLI.</p>
261
+ </header>
262
+ </div>
263
+ );
264
+ }}
265
+
266
+ export default App;
267
+ """
268
+ app_file.write_text(app_content, encoding="utf-8")
269
+ created_files.append(str(app_file.relative_to(project_path)))
270
+
271
+ # Create App.css
272
+ css_file = src_dir / "App.css"
273
+ css_content = """.App {
274
+ text-align: center;
275
+ }
276
+
277
+ .App-header {
278
+ background-color: #282c34;
279
+ padding: 20px;
280
+ color: white;
281
+ min-height: 100vh;
282
+ display: flex;
283
+ flex-direction: column;
284
+ align-items: center;
285
+ justify-content: center;
286
+ font-size: calc(10px + 2vmin);
287
+ }
288
+
289
+ .App-link {
290
+ color: #61dafb;
291
+ }
292
+ """
293
+ css_file.write_text(css_content, encoding="utf-8")
294
+ created_files.append(str(css_file.relative_to(project_path)))
295
+
296
+ # Create index.jsx
297
+ index_file = src_dir / "index.jsx"
298
+ index_content = """import React from 'react';
299
+ import ReactDOM from 'react-dom/client';
300
+ import './index.css';
301
+ import App from './App';
302
+
303
+ const root = ReactDOM.createRoot(document.getElementById('root'));
304
+ root.render(
305
+ <React.StrictMode>
306
+ <App />
307
+ </React.StrictMode>
308
+ );
309
+ """
310
+ index_file.write_text(index_content, encoding="utf-8")
311
+ created_files.append(str(index_file.relative_to(project_path)))
312
+
313
+ # Create index.css
314
+ index_css_file = src_dir / "index.css"
315
+ index_css_content = """body {
316
+ margin: 0;
317
+ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
318
+ 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
319
+ sans-serif;
320
+ -webkit-font-smoothing: antialiased;
321
+ -moz-osx-font-smoothing: grayscale;
322
+ }
323
+
324
+ code {
325
+ font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
326
+ monospace;
327
+ }
328
+ """
329
+ index_css_file.write_text(index_css_content, encoding="utf-8")
330
+ created_files.append(str(index_css_file.relative_to(project_path)))
331
+
332
+ # Create public/index.html
333
+ html_file = public_dir / "index.html"
334
+ html_content = f"""<!DOCTYPE html>
335
+ <html lang="en">
336
+ <head>
337
+ <meta charset="utf-8" />
338
+ <link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
339
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
340
+ <meta name="theme-color" content="#000000" />
341
+ <meta
342
+ name="description"
343
+ content="{project_name} - A React project created with WOMM CLI"
344
+ />
345
+ <title>{project_name}</title>
346
+ </head>
347
+ <body>
348
+ <noscript>You need to enable JavaScript to run this app.</noscript>
349
+ <div id="root"></div>
350
+ </body>
351
+ </html>
352
+ """
353
+ html_file.write_text(html_content, encoding="utf-8")
354
+ created_files.append(str(html_file.relative_to(project_path)))
355
+
356
+ logger.debug(f"Created React main files: {created_files}")
357
+ return created_files
358
+
359
+
360
+ def create_vue_main_files(project_path: Path, project_name: str) -> list[str]:
361
+ """Create Vue main source files.
362
+
363
+ Args:
364
+ project_path: Path to the project
365
+ project_name: Name of the project
366
+
367
+ Returns:
368
+ list[str]: List of created file paths (relative to project_path)
369
+
370
+ Raises:
371
+ OSError: If file creation fails
372
+ """
373
+ src_dir = project_path / ProjectStructureConfig.SOURCE_DIR
374
+ src_dir.mkdir(exist_ok=True)
375
+ public_dir = project_path / "public"
376
+ public_dir.mkdir(exist_ok=True)
377
+ created_files = []
378
+
379
+ # Create App.vue
380
+ app_file = src_dir / "App.vue"
381
+ app_content = f"""<template>
382
+ <div id="app">
383
+ <header>
384
+ <h1>Welcome to {{ projectName }}</h1>
385
+ <p>This is a Vue project created with WOMM CLI.</p>
386
+ </header>
387
+ </div>
388
+ </template>
389
+
390
+ <script>
391
+ export default {{
392
+ name: 'App',
393
+ data() {{
394
+ return {{
395
+ projectName: '{project_name}'
396
+ }}
397
+ }}
398
+ }}
399
+ </script>
400
+
401
+ <style>
402
+ #app {{
403
+ font-family: Avenir, Helvetica, Arial, sans-serif;
404
+ -webkit-font-smoothing: antialiased;
405
+ -moz-osx-font-smoothing: grayscale;
406
+ text-align: center;
407
+ color: #2c3e50;
408
+ margin-top: 60px;
409
+ }}
410
+
411
+ header {{
412
+ background-color: #f8f9fa;
413
+ padding: 20px;
414
+ border-radius: 8px;
415
+ }}
416
+ </style>
417
+ """
418
+ app_file.write_text(app_content, encoding="utf-8")
419
+ created_files.append(str(app_file.relative_to(project_path)))
420
+
421
+ # Create main.js
422
+ main_file = src_dir / "main.js"
423
+ main_content = """import { createApp } from 'vue'
424
+ import App from './App.vue'
425
+
426
+ createApp(App).mount('#app')
427
+ """
428
+ main_file.write_text(main_content, encoding="utf-8")
429
+ created_files.append(str(main_file.relative_to(project_path)))
430
+
431
+ # Create public/index.html
432
+ html_file = public_dir / "index.html"
433
+ html_content = f"""<!DOCTYPE html>
434
+ <html lang="en">
435
+ <head>
436
+ <meta charset="utf-8">
437
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
438
+ <meta name="viewport" content="width=device-width,initial-scale=1.0">
439
+ <link rel="icon" href="<%= BASE_URL %>favicon.ico">
440
+ <title>{project_name}</title>
441
+ </head>
442
+ <body>
443
+ <noscript>
444
+ <strong>We're sorry but {project_name} doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
445
+ </noscript>
446
+ <div id="app"></div>
447
+ <!-- built files will be auto injected -->
448
+ </body>
449
+ </html>
450
+ """
451
+ html_file.write_text(html_content, encoding="utf-8")
452
+ created_files.append(str(html_file.relative_to(project_path)))
453
+
454
+ logger.debug(f"Created Vue main files: {created_files}")
455
+ return created_files
456
+
457
+
458
+ def create_javascript_source_files(
459
+ project_path: Path, project_name: str, project_type: str
460
+ ) -> list[str]:
461
+ """Create JavaScript source files based on project type.
462
+
463
+ Args:
464
+ project_path: Path to the project
465
+ project_name: Name of the project
466
+ project_type: Type of JavaScript project (node, react, vue)
467
+
468
+ Returns:
469
+ list[str]: List of created file paths (relative to project_path)
470
+
471
+ Raises:
472
+ OSError: If file creation fails
473
+ """
474
+ if project_type == "react":
475
+ return create_react_main_files(project_path, project_name)
476
+ elif project_type == "vue":
477
+ return create_vue_main_files(project_path, project_name)
478
+ else: # node
479
+ return create_node_main_files(project_path, project_name)
480
+
481
+
482
+ # ///////////////////////////////////////////////////////////////
483
+ # PUBLIC API
484
+ # ///////////////////////////////////////////////////////////////
485
+
486
+ __all__ = [
487
+ # File creation functions
488
+ "create_javascript_source_files",
489
+ "create_node_main_files",
490
+ "create_python_main_files",
491
+ "create_python_test_file",
492
+ "create_react_main_files",
493
+ "create_vue_main_files",
494
+ ]
@@ -0,0 +1,170 @@
1
+ #!/usr/bin/env python3
2
+ # ///////////////////////////////////////////////////////////////
3
+ # PLATFORM UTILS - Platform-Specific Utility Functions
4
+ # Project: works-on-my-machine
5
+ # ///////////////////////////////////////////////////////////////
6
+
7
+ """
8
+ Pure utility functions for platform-specific operations.
9
+
10
+ This module provides stateless functions for:
11
+ - Getting platform information (OS, paths, etc.)
12
+ - Getting Python paths according to OS
13
+ - Getting Node.js paths according to OS
14
+ - Getting shell commands according to OS
15
+ """
16
+
17
+ from __future__ import annotations
18
+
19
+ # ///////////////////////////////////////////////////////////////
20
+ # IMPORTS
21
+ # ///////////////////////////////////////////////////////////////
22
+ # Standard library imports
23
+ import os
24
+ import platform
25
+
26
+ # ///////////////////////////////////////////////////////////////
27
+ # PLATFORM INFORMATION
28
+ # ///////////////////////////////////////////////////////////////
29
+
30
+
31
+ def get_platform_info() -> dict[str, str | bool]:
32
+ """Get platform information.
33
+
34
+ Returns:
35
+ dict[str, str | bool]: Dictionary containing:
36
+ - system: Platform system name (Windows, Linux, Darwin)
37
+ - system_lower: Lowercase platform system name
38
+ - is_windows: True if Windows
39
+ - is_linux: True if Linux
40
+ - is_macos: True if macOS
41
+ - path_separator: Path separator for the platform
42
+ - line_ending: Line ending for the platform
43
+ """
44
+ system = platform.system()
45
+ return {
46
+ "system": system,
47
+ "system_lower": system.lower(),
48
+ "is_windows": system == "Windows",
49
+ "is_linux": system == "Linux",
50
+ "is_macos": system == "Darwin",
51
+ "path_separator": os.sep,
52
+ "line_ending": "\r\n" if system == "Windows" else "\n",
53
+ }
54
+
55
+
56
+ # ///////////////////////////////////////////////////////////////
57
+ # PYTHON PATHS
58
+ # ///////////////////////////////////////////////////////////////
59
+
60
+
61
+ def get_python_paths() -> dict[str, str]:
62
+ """Get Python paths according to OS.
63
+
64
+ Returns:
65
+ dict[str, str]: Dictionary containing:
66
+ - venv_python: Path to Python in virtual environment
67
+ - venv_activate: Command to activate virtual environment
68
+ - venv_pip: Path to pip in virtual environment
69
+ - python_executable: Python executable name
70
+ """
71
+ platform_info = get_platform_info()
72
+
73
+ if platform_info["is_windows"]:
74
+ return {
75
+ "venv_python": "./venv/Scripts/python.exe",
76
+ "venv_activate": "./venv/Scripts/activate.bat",
77
+ "venv_pip": "./venv/Scripts/pip.exe",
78
+ "python_executable": "python.exe",
79
+ }
80
+ else: # Linux/macOS
81
+ return {
82
+ "venv_python": "./venv/bin/python",
83
+ "venv_activate": "source ./venv/bin/activate",
84
+ "venv_pip": "./venv/bin/pip",
85
+ "python_executable": "python3",
86
+ }
87
+
88
+
89
+ # ///////////////////////////////////////////////////////////////
90
+ # NODE.JS PATHS
91
+ # ///////////////////////////////////////////////////////////////
92
+
93
+
94
+ def get_node_paths() -> dict[str, str]:
95
+ """Get Node.js paths according to OS.
96
+
97
+ Returns:
98
+ dict[str, str]: Dictionary containing:
99
+ - npm_executable: npm executable name
100
+ - node_executable: node executable name
101
+ - npx_executable: npx executable name
102
+ """
103
+ platform_info = get_platform_info()
104
+
105
+ if platform_info["is_windows"]:
106
+ return {
107
+ "npm_executable": "npm.cmd",
108
+ "node_executable": "node.exe",
109
+ "npx_executable": "npx.cmd",
110
+ }
111
+ else: # Linux/macOS
112
+ return {
113
+ "npm_executable": "npm",
114
+ "node_executable": "node",
115
+ "npx_executable": "npx",
116
+ }
117
+
118
+
119
+ # ///////////////////////////////////////////////////////////////
120
+ # SHELL COMMANDS
121
+ # ///////////////////////////////////////////////////////////////
122
+
123
+
124
+ def get_shell_commands() -> dict[str, str]:
125
+ """Get shell commands according to OS.
126
+
127
+ Returns:
128
+ dict[str, str]: Dictionary containing:
129
+ - shell: Shell name (cmd or bash)
130
+ - shell_extension: Shell script extension (.bat or .sh)
131
+ - remove_dir: Command to remove a directory
132
+ - copy_file: Command to copy a file
133
+ - move_file: Command to move a file
134
+ - make_executable: Command to make a file executable
135
+ - which: Command to find executable location
136
+ """
137
+ platform_info = get_platform_info()
138
+
139
+ if platform_info["is_windows"]:
140
+ return {
141
+ "shell": "cmd",
142
+ "shell_extension": ".bat",
143
+ "remove_dir": "rmdir /s /q",
144
+ "copy_file": "copy",
145
+ "move_file": "move",
146
+ "make_executable": "rem", # Not needed on Windows
147
+ "which": "where",
148
+ }
149
+ else: # Linux/macOS
150
+ return {
151
+ "shell": "bash",
152
+ "shell_extension": ".sh",
153
+ "remove_dir": "rm -rf",
154
+ "copy_file": "cp",
155
+ "move_file": "mv",
156
+ "make_executable": "chmod +x",
157
+ "which": "which",
158
+ }
159
+
160
+
161
+ # ///////////////////////////////////////////////////////////////
162
+ # PUBLIC API
163
+ # ///////////////////////////////////////////////////////////////
164
+
165
+ __all__ = [
166
+ "get_node_paths",
167
+ "get_platform_info",
168
+ "get_python_paths",
169
+ "get_shell_commands",
170
+ ]