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.
- womm/__init__.py +53 -0
- womm/__main__.py +48 -0
- womm/_version.py +10 -0
- womm/assets/copier/meta/copier.yml +15 -0
- womm/assets/copier/meta/template/README.md.jinja +32 -0
- womm/assets/copier/meta/template/copier.yml.jinja +13 -0
- womm/assets/copier/meta/template/template/.gitkeep +0 -0
- womm/assets/copier/official/javascript/copier.yml +104 -0
- womm/assets/copier/official/javascript/template/.gitignore.jinja +35 -0
- womm/assets/copier/official/javascript/template/.nvmrc.jinja +1 -0
- womm/assets/copier/official/javascript/template/.prettierignore.jinja +10 -0
- womm/assets/copier/official/javascript/template/README.md.jinja +81 -0
- womm/assets/copier/official/javascript/template/biome.json.jinja +54 -0
- womm/assets/copier/official/javascript/template/eslint.config.mjs.jinja +51 -0
- womm/assets/copier/official/javascript/template/index.html.jinja +12 -0
- womm/assets/copier/official/javascript/template/package.json.jinja +88 -0
- womm/assets/copier/official/javascript/template/prettier.config.mjs.jinja +8 -0
- womm/assets/copier/official/javascript/template/src/App.jsx.jinja +10 -0
- womm/assets/copier/official/javascript/template/src/App.tsx.jinja +10 -0
- womm/assets/copier/official/javascript/template/src/App.vue.jinja +18 -0
- womm/assets/copier/official/javascript/template/src/index.jsx.jinja +10 -0
- womm/assets/copier/official/javascript/template/src/index.tsx.jinja +11 -0
- womm/assets/copier/official/javascript/template/src/main.js.jinja +21 -0
- womm/assets/copier/official/javascript/template/src/main.ts.jinja +21 -0
- womm/assets/copier/official/javascript/template/tsconfig.json.jinja +35 -0
- womm/assets/copier/official/javascript/template/vite.config.mjs.jinja +10 -0
- womm/assets/copier/official/javascript/template/{% if with_ci %}.github{% endif %}/workflows/ci.yml.jinja +63 -0
- womm/assets/copier/official/javascript/template/{% if with_tests %}tests{% endif %}/smoke.test.js.jinja +12 -0
- womm/assets/copier/official/javascript/template/{% if with_tests %}tests{% endif %}/smoke.test.ts.jinja +12 -0
- womm/assets/copier/official/javascript/template/{% if with_vscode %}.vscode{% endif %}/extensions.json.jinja +4 -0
- womm/assets/copier/official/javascript/template/{% if with_vscode %}.vscode{% endif %}/settings.json.jinja +27 -0
- womm/assets/copier/official/python/copier.yml +107 -0
- womm/assets/copier/official/python/template/.gitignore.jinja +40 -0
- womm/assets/copier/official/python/template/.pre-commit-config.yaml.jinja +19 -0
- womm/assets/copier/official/python/template/.python-version.jinja +1 -0
- womm/assets/copier/official/python/template/README.md.jinja +83 -0
- womm/assets/copier/official/python/template/pyproject.toml.jinja +114 -0
- womm/assets/copier/official/python/template/{% if framework == 'django' %}manage.py{% endif %}.jinja +23 -0
- womm/assets/copier/official/python/template/{% if not use_src_layout %}{{ package_name }}{% endif %}/__init__.py.jinja +3 -0
- womm/assets/copier/official/python/template/{% if not use_src_layout %}{{ package_name }}{% endif %}/asgi.py.jinja +9 -0
- womm/assets/copier/official/python/template/{% if not use_src_layout %}{{ package_name }}{% endif %}/core/__init__.py.jinja +0 -0
- womm/assets/copier/official/python/template/{% if not use_src_layout %}{{ package_name }}{% endif %}/core/apps.py.jinja +10 -0
- womm/assets/copier/official/python/template/{% if not use_src_layout %}{{ package_name }}{% endif %}/core/models.py.jinja +1 -0
- womm/assets/copier/official/python/template/{% if not use_src_layout %}{{ package_name }}{% endif %}/core/views.py.jinja +8 -0
- womm/assets/copier/official/python/template/{% if not use_src_layout %}{{ package_name }}{% endif %}/py.typed +0 -0
- womm/assets/copier/official/python/template/{% if not use_src_layout %}{{ package_name }}{% endif %}/settings.py.jinja +81 -0
- womm/assets/copier/official/python/template/{% if not use_src_layout %}{{ package_name }}{% endif %}/urls.py.jinja +11 -0
- womm/assets/copier/official/python/template/{% if not use_src_layout %}{{ package_name }}{% endif %}/wsgi.py.jinja +9 -0
- womm/assets/copier/official/python/template/{% if use_src_layout %}src{% endif %}/{{ package_name }}/__init__.py.jinja +3 -0
- womm/assets/copier/official/python/template/{% if use_src_layout %}src{% endif %}/{{ package_name }}/asgi.py.jinja +9 -0
- womm/assets/copier/official/python/template/{% if use_src_layout %}src{% endif %}/{{ package_name }}/core/__init__.py.jinja +0 -0
- womm/assets/copier/official/python/template/{% if use_src_layout %}src{% endif %}/{{ package_name }}/core/apps.py.jinja +10 -0
- womm/assets/copier/official/python/template/{% if use_src_layout %}src{% endif %}/{{ package_name }}/core/models.py.jinja +1 -0
- womm/assets/copier/official/python/template/{% if use_src_layout %}src{% endif %}/{{ package_name }}/core/views.py.jinja +8 -0
- womm/assets/copier/official/python/template/{% if use_src_layout %}src{% endif %}/{{ package_name }}/py.typed +0 -0
- womm/assets/copier/official/python/template/{% if use_src_layout %}src{% endif %}/{{ package_name }}/settings.py.jinja +81 -0
- womm/assets/copier/official/python/template/{% if use_src_layout %}src{% endif %}/{{ package_name }}/urls.py.jinja +11 -0
- womm/assets/copier/official/python/template/{% if use_src_layout %}src{% endif %}/{{ package_name }}/wsgi.py.jinja +9 -0
- womm/assets/copier/official/python/template/{% if with_ci %}.github{% endif %}/workflows/ci.yml.jinja +78 -0
- womm/assets/copier/official/python/template/{% if with_tests %}tests{% endif %}/test_smoke.py.jinja +16 -0
- womm/assets/copier/official/python/template/{% if with_vscode %}.vscode{% endif %}/extensions.json.jinja +8 -0
- womm/assets/copier/official/python/template/{% if with_vscode %}.vscode{% endif %}/settings.json.jinja +28 -0
- womm/bin/refresh_env.cmd +130 -0
- womm/cli.py +111 -0
- womm/commands/__init__.py +30 -0
- womm/commands/core/__init__.py +29 -0
- womm/commands/core/doctor.py +52 -0
- womm/commands/core/path.py +337 -0
- womm/commands/project/__init__.py +31 -0
- womm/commands/project/create.py +128 -0
- womm/commands/project/setup.py +438 -0
- womm/commands/project/template.py +160 -0
- womm/commands/system/__init__.py +31 -0
- womm/commands/system/context/__init__.py +82 -0
- womm/commands/system/context/backup.py +344 -0
- womm/commands/system/context/inventory.py +111 -0
- womm/commands/system/context/registration.py +290 -0
- womm/commands/system/deps.py +165 -0
- womm/commands/system/system.py +130 -0
- womm/exceptions/__init__.py +69 -0
- womm/exceptions/common/__init__.py +55 -0
- womm/exceptions/common/command_service.py +91 -0
- womm/exceptions/common/file_service.py +60 -0
- womm/exceptions/common/security_service.py +44 -0
- womm/exceptions/common/validation_service.py +70 -0
- womm/exceptions/context/__init__.py +27 -0
- womm/exceptions/context/context_service.py +55 -0
- womm/exceptions/project/__init__.py +29 -0
- womm/exceptions/project/project_service.py +59 -0
- womm/exceptions/system/__init__.py +25 -0
- womm/exceptions/system/system_service.py +53 -0
- womm/interfaces/__init__.py +71 -0
- womm/interfaces/context/__init__.py +34 -0
- womm/interfaces/context/menu_interface.py +686 -0
- womm/interfaces/context/registry_interface.py +562 -0
- womm/interfaces/context/script_detector_interface.py +208 -0
- womm/interfaces/context/script_registrar.py +264 -0
- womm/interfaces/core/__init__.py +26 -0
- womm/interfaces/core/doctor_interface.py +102 -0
- womm/interfaces/dependencies/__init__.py +28 -0
- womm/interfaces/dependencies/deps_interface.py +160 -0
- womm/interfaces/project/__init__.py +36 -0
- womm/interfaces/project/create_interface.py +162 -0
- womm/interfaces/project/detection_interface.py +181 -0
- womm/interfaces/project/manager_interface.py +99 -0
- womm/interfaces/project/setup_interface.py +477 -0
- womm/interfaces/project/template_store_interface.py +196 -0
- womm/interfaces/system/__init__.py +32 -0
- womm/interfaces/system/detector_interface.py +84 -0
- womm/interfaces/system/environment_interface.py +110 -0
- womm/interfaces/system/path_interface.py +570 -0
- womm/services/__init__.py +70 -0
- womm/services/common/__init__.py +33 -0
- womm/services/common/base_validation_service.py +450 -0
- womm/services/common/command_runner_service.py +647 -0
- womm/services/common/file_scanner_service.py +483 -0
- womm/services/common/security_validator_service.py +348 -0
- womm/services/context/__init__.py +37 -0
- womm/services/context/backup_entries.py +148 -0
- womm/services/context/parameters.py +515 -0
- womm/services/context/registry_paths.py +56 -0
- womm/services/context/registry_service.py +573 -0
- womm/services/context/validation_service.py +691 -0
- womm/services/dependencies/__init__.py +29 -0
- womm/services/dependencies/probe.py +102 -0
- womm/services/project/__init__.py +48 -0
- womm/services/project/copier_project_creation_service.py +111 -0
- womm/services/project/destination_guard.py +96 -0
- womm/services/project/detection_service.py +354 -0
- womm/services/project/env_utils.py +333 -0
- womm/services/project/javascript_environment_service.py +348 -0
- womm/services/project/python_environment_service.py +245 -0
- womm/services/project/setup_profile_resolver.py +146 -0
- womm/services/project/template_store_service.py +344 -0
- womm/services/project/validation_service.py +418 -0
- womm/services/system/__init__.py +32 -0
- womm/services/system/detector_service.py +704 -0
- womm/services/system/environment_service.py +494 -0
- womm/services/system/path_service.py +642 -0
- womm/shared/__init__.py +30 -0
- womm/shared/configs/__init__.py +51 -0
- womm/shared/configs/context/__init__.py +43 -0
- womm/shared/configs/context/context_config.py +125 -0
- womm/shared/configs/context/context_file_types_config.py +159 -0
- womm/shared/configs/context/context_limits_config.py +187 -0
- womm/shared/configs/context/context_paths_config.py +115 -0
- womm/shared/configs/context/context_types_config.py +65 -0
- womm/shared/configs/context/script_config.py +219 -0
- womm/shared/configs/dependencies/__init__.py +32 -0
- womm/shared/configs/dependencies/runtime_config.py +46 -0
- womm/shared/configs/dependencies/runtime_package_manager_config.py +48 -0
- womm/shared/configs/logging_config.py +89 -0
- womm/shared/configs/project/__init__.py +33 -0
- womm/shared/configs/project/project_config.py +109 -0
- womm/shared/configs/project/project_structure_config.py +88 -0
- womm/shared/configs/project/python_project_config.py +165 -0
- womm/shared/configs/security/__init__.py +26 -0
- womm/shared/configs/security/security_patterns_config.py +242 -0
- womm/shared/configs/system/__init__.py +28 -0
- womm/shared/configs/system/system_detector_config.py +210 -0
- womm/shared/configs/system/system_environment_config.py +101 -0
- womm/shared/models/__init__.py +13 -0
- womm/shared/models/template_source.py +65 -0
- womm/shared/paths.py +192 -0
- womm/shared/results/__init__.py +138 -0
- womm/shared/results/base.py +85 -0
- womm/shared/results/command_results.py +61 -0
- womm/shared/results/context_results.py +345 -0
- womm/shared/results/dependency_results.py +110 -0
- womm/shared/results/doctor_results.py +41 -0
- womm/shared/results/file_results.py +97 -0
- womm/shared/results/project_results.py +163 -0
- womm/shared/results/security_results.py +128 -0
- womm/shared/results/system_results.py +268 -0
- womm/shared/results/template_results.py +43 -0
- womm/shared/runtime.py +36 -0
- womm/ui/__init__.py +31 -0
- womm/ui/common/__init__.py +39 -0
- womm/ui/common/interactive_menu.py +246 -0
- womm/ui/common/logging.py +184 -0
- womm/ui/common/prompts.py +93 -0
- womm/ui/context/__init__.py +31 -0
- womm/ui/context/display.py +485 -0
- womm/ui/context/menu_display.py +189 -0
- womm/ui/context/wizard.py +557 -0
- womm/ui/project/__init__.py +42 -0
- womm/ui/project/create/create_completion_summaries.py +55 -0
- womm/ui/project/project_wizard.py +174 -0
- womm/ui/project/setup/setup_completion_summaries.py +111 -0
- womm/ui/project/templates/template_store_display.py +128 -0
- womm/ui/system/__init__.py +60 -0
- womm/ui/system/display.py +531 -0
- womm/ui/system/path_display.py +387 -0
- womm/utils/__init__.py +23 -0
- womm/utils/common/__init__.py +49 -0
- womm/utils/common/file_scanner_utils.py +110 -0
- womm/utils/common/path_resolver_utils.py +127 -0
- womm/utils/common/safe_fs_utils.py +135 -0
- womm/utils/context/__init__.py +54 -0
- womm/utils/context/core_utils.py +345 -0
- womm/utils/context/icon_utils.py +259 -0
- womm/utils/project/__init__.py +106 -0
- womm/utils/project/asset_utils.py +154 -0
- womm/utils/project/core_utils.py +391 -0
- womm/utils/project/file_utils.py +494 -0
- womm/utils/project/platform_utils.py +170 -0
- womm/utils/project/validation_utils.py +273 -0
- womm/utils/security/__init__.py +46 -0
- womm/utils/security/security_validation_utils.py +258 -0
- womm/utils/system/__init__.py +69 -0
- womm/utils/system/detector_utils.py +299 -0
- womm/utils/system/environment_utils.py +172 -0
- womm/utils/system/path_utils.py +101 -0
- womm_cli-4.0.0.dist-info/METADATA +203 -0
- womm_cli-4.0.0.dist-info/RECORD +218 -0
- womm_cli-4.0.0.dist-info/WHEEL +4 -0
- womm_cli-4.0.0.dist-info/entry_points.txt +2 -0
- womm_cli-4.0.0.dist-info/licenses/LICENSE +21 -0
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
# ///////////////////////////////////////////////////////////////
|
|
3
|
+
# DEPS INTERFACE - Global Dependencies Diagnostic
|
|
4
|
+
# Project: works-on-my-machine
|
|
5
|
+
# ///////////////////////////////////////////////////////////////
|
|
6
|
+
|
|
7
|
+
"""
|
|
8
|
+
Global dependencies interface for Works On My Machine.
|
|
9
|
+
|
|
10
|
+
Provides read-only diagnostic operations across the two dependency strata WOMM
|
|
11
|
+
actually depends on: runtimes (python, node, git) and runtime package managers
|
|
12
|
+
(pip, uv, npm, yarn). Backed by the lightweight :func:`probe` primitive — no
|
|
13
|
+
installation, resolution, or god-object machinery.
|
|
14
|
+
|
|
15
|
+
Deliberately out of scope: system package managers (winget, homebrew, apt) and
|
|
16
|
+
the packages a project chooses to use. WOMM reports; the user installs.
|
|
17
|
+
|
|
18
|
+
This interface never raises and never renders: every public method returns a
|
|
19
|
+
typed Result, and presentation is left to the ``ui`` layer.
|
|
20
|
+
"""
|
|
21
|
+
|
|
22
|
+
from __future__ import annotations
|
|
23
|
+
|
|
24
|
+
# ///////////////////////////////////////////////////////////////
|
|
25
|
+
# IMPORTS
|
|
26
|
+
# ///////////////////////////////////////////////////////////////
|
|
27
|
+
# Standard library imports
|
|
28
|
+
import logging
|
|
29
|
+
|
|
30
|
+
from ...services.dependencies import ProbeResult, probe
|
|
31
|
+
|
|
32
|
+
# Local imports
|
|
33
|
+
from ...shared.configs.dependencies import (
|
|
34
|
+
RuntimeConfig,
|
|
35
|
+
RuntimePackageManagerConfig,
|
|
36
|
+
)
|
|
37
|
+
from ...shared.results import (
|
|
38
|
+
DependencyCheckResult,
|
|
39
|
+
DependencyInventoryEntry,
|
|
40
|
+
DependencyInventoryResult,
|
|
41
|
+
DependencyProbe,
|
|
42
|
+
DependencyStatusResult,
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
# ///////////////////////////////////////////////////////////////
|
|
46
|
+
# LOGGER SETUP
|
|
47
|
+
# ///////////////////////////////////////////////////////////////
|
|
48
|
+
|
|
49
|
+
logger = logging.getLogger(__name__)
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
# ///////////////////////////////////////////////////////////////
|
|
53
|
+
# HELPER FUNCTIONS
|
|
54
|
+
# ///////////////////////////////////////////////////////////////
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
def _as_entry(name: str, result: ProbeResult) -> DependencyProbe:
|
|
58
|
+
"""Adapt a :class:`ProbeResult` to the transport-level record."""
|
|
59
|
+
return DependencyProbe(
|
|
60
|
+
name=name,
|
|
61
|
+
available=result.available,
|
|
62
|
+
path=result.path,
|
|
63
|
+
version=result.version,
|
|
64
|
+
)
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
def _probe_runtimes(detect_version: bool = True) -> list[DependencyProbe]:
|
|
68
|
+
"""Probe every configured runtime (python, node, git)."""
|
|
69
|
+
return [
|
|
70
|
+
_as_entry(runtime, probe(runtime, detect_version=detect_version))
|
|
71
|
+
for runtime in RuntimeConfig.RUNTIMES
|
|
72
|
+
]
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
def _probe_package_managers(detect_version: bool = True) -> list[DependencyProbe]:
|
|
76
|
+
"""Probe every configured runtime package manager (pip, uv, npm, yarn)."""
|
|
77
|
+
return [
|
|
78
|
+
_as_entry(manager, probe(manager, detect_version=detect_version))
|
|
79
|
+
for manager in RuntimePackageManagerConfig.RUNTIME_PACKAGE_MANAGERS
|
|
80
|
+
]
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
# ///////////////////////////////////////////////////////////////
|
|
84
|
+
# MAIN CLASS
|
|
85
|
+
# ///////////////////////////////////////////////////////////////
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
class DepsInterface:
|
|
89
|
+
"""Read-only diagnostic across both dependency strata (probe-based)."""
|
|
90
|
+
|
|
91
|
+
# ///////////////////////////////////////////////////////////////
|
|
92
|
+
# PUBLIC METHODS
|
|
93
|
+
# ///////////////////////////////////////////////////////////////
|
|
94
|
+
|
|
95
|
+
def check_all(self, detect_versions: bool = False) -> DependencyCheckResult:
|
|
96
|
+
"""
|
|
97
|
+
Check availability of every dependency across both strata.
|
|
98
|
+
|
|
99
|
+
Args:
|
|
100
|
+
detect_versions: Whether to resolve per-component version strings.
|
|
101
|
+
|
|
102
|
+
Returns:
|
|
103
|
+
DependencyCheckResult: Probe results per strata. Always successful —
|
|
104
|
+
a missing dependency is data, not a failure of the check itself.
|
|
105
|
+
"""
|
|
106
|
+
return DependencyCheckResult(
|
|
107
|
+
success=True,
|
|
108
|
+
message="Dependency check completed",
|
|
109
|
+
runtime=_probe_runtimes(detect_version=detect_versions),
|
|
110
|
+
package_managers=_probe_package_managers(detect_version=detect_versions),
|
|
111
|
+
)
|
|
112
|
+
|
|
113
|
+
def show_status(self, detect_versions: bool = False) -> DependencyStatusResult:
|
|
114
|
+
"""
|
|
115
|
+
Collect a comprehensive status report across both strata.
|
|
116
|
+
|
|
117
|
+
Args:
|
|
118
|
+
detect_versions: Whether to resolve per-component version strings.
|
|
119
|
+
|
|
120
|
+
Returns:
|
|
121
|
+
DependencyStatusResult: Status data per strata.
|
|
122
|
+
"""
|
|
123
|
+
return DependencyStatusResult(
|
|
124
|
+
success=True,
|
|
125
|
+
message="Dependency status collected",
|
|
126
|
+
runtime=_probe_runtimes(detect_version=detect_versions),
|
|
127
|
+
package_managers=_probe_package_managers(detect_version=detect_versions),
|
|
128
|
+
)
|
|
129
|
+
|
|
130
|
+
def list_all(self) -> DependencyInventoryResult:
|
|
131
|
+
"""
|
|
132
|
+
List the dependencies WOMM knows about (static inventory, no probing).
|
|
133
|
+
|
|
134
|
+
Returns:
|
|
135
|
+
DependencyInventoryResult: Configured dependencies per strata.
|
|
136
|
+
"""
|
|
137
|
+
runtime = [
|
|
138
|
+
DependencyInventoryEntry(name=name, detail=version)
|
|
139
|
+
for name, version in RuntimeConfig.RUNTIMES.items()
|
|
140
|
+
]
|
|
141
|
+
package_managers = [
|
|
142
|
+
DependencyInventoryEntry(name=name, detail=f"requires {runtime_name}")
|
|
143
|
+
for name, runtime_name in (
|
|
144
|
+
RuntimePackageManagerConfig.RUNTIME_PACKAGE_MANAGERS.items()
|
|
145
|
+
)
|
|
146
|
+
]
|
|
147
|
+
|
|
148
|
+
return DependencyInventoryResult(
|
|
149
|
+
success=True,
|
|
150
|
+
message="Dependency inventory collected",
|
|
151
|
+
runtime=runtime,
|
|
152
|
+
package_managers=package_managers,
|
|
153
|
+
)
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
# ///////////////////////////////////////////////////////////////
|
|
157
|
+
# PUBLIC API
|
|
158
|
+
# ///////////////////////////////////////////////////////////////
|
|
159
|
+
|
|
160
|
+
__all__ = ["DepsInterface"]
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
# ///////////////////////////////////////////////////////////////
|
|
3
|
+
# INTERFACES PROJECT - Project Interfaces
|
|
4
|
+
# Project: works-on-my-machine
|
|
5
|
+
# ///////////////////////////////////////////////////////////////
|
|
6
|
+
|
|
7
|
+
"""
|
|
8
|
+
Project interfaces for Works On My Machine.
|
|
9
|
+
|
|
10
|
+
This package contains project interface modules that orchestrate services
|
|
11
|
+
for project creation, language-specific operations, and template management.
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
from __future__ import annotations
|
|
15
|
+
|
|
16
|
+
# ///////////////////////////////////////////////////////////////
|
|
17
|
+
# IMPORTS
|
|
18
|
+
# ///////////////////////////////////////////////////////////////
|
|
19
|
+
# Local imports
|
|
20
|
+
from .create_interface import ProjectCreateInterface
|
|
21
|
+
from .detection_interface import ProjectDetectionInterface
|
|
22
|
+
from .manager_interface import ProjectManagerInterface
|
|
23
|
+
from .setup_interface import ProjectSetupInterface
|
|
24
|
+
from .template_store_interface import TemplateStoreInterface
|
|
25
|
+
|
|
26
|
+
# ///////////////////////////////////////////////////////////////
|
|
27
|
+
# PUBLIC API
|
|
28
|
+
# ///////////////////////////////////////////////////////////////
|
|
29
|
+
|
|
30
|
+
__all__ = [
|
|
31
|
+
"ProjectCreateInterface",
|
|
32
|
+
"ProjectDetectionInterface",
|
|
33
|
+
"ProjectManagerInterface",
|
|
34
|
+
"ProjectSetupInterface",
|
|
35
|
+
"TemplateStoreInterface",
|
|
36
|
+
]
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
# ///////////////////////////////////////////////////////////////
|
|
3
|
+
# PROJECT CREATION INTERFACE - Project Creation Interface
|
|
4
|
+
# Project: works-on-my-machine
|
|
5
|
+
# ///////////////////////////////////////////////////////////////
|
|
6
|
+
|
|
7
|
+
"""
|
|
8
|
+
Project creation interface for WOMM CLI.
|
|
9
|
+
|
|
10
|
+
Orchestrates Copier template resolution, rendering, and optional environment
|
|
11
|
+
setup. This interface never raises: service exceptions are converted into a
|
|
12
|
+
typed ``ProjectCreationResult``.
|
|
13
|
+
"""
|
|
14
|
+
|
|
15
|
+
from __future__ import annotations
|
|
16
|
+
|
|
17
|
+
# ///////////////////////////////////////////////////////////////
|
|
18
|
+
# IMPORTS
|
|
19
|
+
# ///////////////////////////////////////////////////////////////
|
|
20
|
+
# Standard library imports
|
|
21
|
+
import logging
|
|
22
|
+
from collections.abc import Mapping
|
|
23
|
+
from pathlib import Path
|
|
24
|
+
|
|
25
|
+
# Local imports
|
|
26
|
+
from ...exceptions.project import ProjectServiceError
|
|
27
|
+
from ...services.project.copier_project_creation_service import (
|
|
28
|
+
CopierProjectCreationService,
|
|
29
|
+
ProjectCreationRequest,
|
|
30
|
+
)
|
|
31
|
+
from ...services.project.template_store_service import TemplateStoreService
|
|
32
|
+
from ...shared.results import ProjectCreationResult
|
|
33
|
+
|
|
34
|
+
# ///////////////////////////////////////////////////////////////
|
|
35
|
+
# LOGGER SETUP
|
|
36
|
+
# ///////////////////////////////////////////////////////////////
|
|
37
|
+
|
|
38
|
+
logger = logging.getLogger(__name__)
|
|
39
|
+
|
|
40
|
+
# ///////////////////////////////////////////////////////////////
|
|
41
|
+
# MAIN CLASS
|
|
42
|
+
# ///////////////////////////////////////////////////////////////
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
class ProjectCreateInterface:
|
|
46
|
+
"""Orchestrate template resolution, rendering and optional setup."""
|
|
47
|
+
|
|
48
|
+
def __init__(self) -> None:
|
|
49
|
+
"""Initialize the project creation interface."""
|
|
50
|
+
self._store = TemplateStoreService()
|
|
51
|
+
self._creator = CopierProjectCreationService()
|
|
52
|
+
|
|
53
|
+
# ///////////////////////////////////////////////////////////////
|
|
54
|
+
# PUBLIC METHODS
|
|
55
|
+
# ///////////////////////////////////////////////////////////////
|
|
56
|
+
|
|
57
|
+
def create_project(
|
|
58
|
+
self,
|
|
59
|
+
template: str,
|
|
60
|
+
destination: Path,
|
|
61
|
+
*,
|
|
62
|
+
answers: Mapping[str, str],
|
|
63
|
+
force: bool = False,
|
|
64
|
+
pretend: bool = False,
|
|
65
|
+
defaults: bool = False,
|
|
66
|
+
setup: bool = False,
|
|
67
|
+
) -> ProjectCreationResult:
|
|
68
|
+
"""Create a project from a catalog template.
|
|
69
|
+
|
|
70
|
+
Args:
|
|
71
|
+
template: Qualified or short template identifier.
|
|
72
|
+
destination: Directory to render into.
|
|
73
|
+
answers: Pre-filled Copier answers, values as raw strings.
|
|
74
|
+
force: Allow a non-empty destination.
|
|
75
|
+
pretend: Simulate without writing.
|
|
76
|
+
defaults: Use template defaults instead of prompting.
|
|
77
|
+
setup: Run the setup vertical after a successful render.
|
|
78
|
+
|
|
79
|
+
Returns:
|
|
80
|
+
ProjectCreationResult: Typed outcome, never raises.
|
|
81
|
+
"""
|
|
82
|
+
try:
|
|
83
|
+
entry = self._store.resolve(template)
|
|
84
|
+
self._creator.create(
|
|
85
|
+
ProjectCreationRequest(
|
|
86
|
+
template_source=entry.source,
|
|
87
|
+
destination=destination,
|
|
88
|
+
answers=dict(answers),
|
|
89
|
+
force=force,
|
|
90
|
+
pretend=pretend,
|
|
91
|
+
defaults=defaults,
|
|
92
|
+
)
|
|
93
|
+
)
|
|
94
|
+
except ProjectServiceError as exc:
|
|
95
|
+
return ProjectCreationResult(
|
|
96
|
+
success=False,
|
|
97
|
+
error=str(exc),
|
|
98
|
+
project_path=destination,
|
|
99
|
+
project_name=destination.name,
|
|
100
|
+
)
|
|
101
|
+
|
|
102
|
+
warnings: list[str] = []
|
|
103
|
+
if setup and not pretend:
|
|
104
|
+
warnings = self._run_setup(destination, entry.id, answers)
|
|
105
|
+
|
|
106
|
+
return ProjectCreationResult(
|
|
107
|
+
success=True,
|
|
108
|
+
message=f"Project created from {entry.qualified_id}",
|
|
109
|
+
project_path=destination,
|
|
110
|
+
project_name=destination.name,
|
|
111
|
+
project_type=entry.qualified_id,
|
|
112
|
+
warnings=warnings or None,
|
|
113
|
+
)
|
|
114
|
+
|
|
115
|
+
# ///////////////////////////////////////////////////////////////
|
|
116
|
+
# PRIVATE METHODS
|
|
117
|
+
# ///////////////////////////////////////////////////////////////
|
|
118
|
+
|
|
119
|
+
def _run_setup(
|
|
120
|
+
self,
|
|
121
|
+
destination: Path,
|
|
122
|
+
project_type: str,
|
|
123
|
+
template_answers: Mapping[str, object],
|
|
124
|
+
) -> list[str]:
|
|
125
|
+
"""Delegate environment setup to the setup vertical.
|
|
126
|
+
|
|
127
|
+
Setup failures never fail the creation: the project is rendered, and
|
|
128
|
+
the user is told what could not be prepared.
|
|
129
|
+
|
|
130
|
+
Args:
|
|
131
|
+
destination: Path to the rendered project.
|
|
132
|
+
project_type: Template id, used to select the setup path
|
|
133
|
+
(e.g. "python").
|
|
134
|
+
template_answers: Answers used to render the project.
|
|
135
|
+
|
|
136
|
+
Returns:
|
|
137
|
+
list[str]: Warnings to surface, empty when setup succeeded.
|
|
138
|
+
"""
|
|
139
|
+
from ...interfaces.project.setup_interface import ProjectSetupInterface
|
|
140
|
+
|
|
141
|
+
result = ProjectSetupInterface().setup_project(
|
|
142
|
+
destination,
|
|
143
|
+
project_type=project_type,
|
|
144
|
+
template_answers=template_answers,
|
|
145
|
+
virtual_env=True,
|
|
146
|
+
install_deps=True,
|
|
147
|
+
setup_dev_tools=True,
|
|
148
|
+
setup_git_hooks=True,
|
|
149
|
+
)
|
|
150
|
+
if result and result.success:
|
|
151
|
+
return list(result.warnings or [])
|
|
152
|
+
return [
|
|
153
|
+
*(result.warnings or []),
|
|
154
|
+
f"Setup step failed: {result.error or 'unknown error'}",
|
|
155
|
+
]
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
# ///////////////////////////////////////////////////////////////
|
|
159
|
+
# PUBLIC API
|
|
160
|
+
# ///////////////////////////////////////////////////////////////
|
|
161
|
+
|
|
162
|
+
__all__ = ["ProjectCreateInterface"]
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
# ///////////////////////////////////////////////////////////////
|
|
3
|
+
# PROJECT DETECTION INTERFACE - Project Detection Interface
|
|
4
|
+
# Project: works-on-my-machine
|
|
5
|
+
# ///////////////////////////////////////////////////////////////
|
|
6
|
+
|
|
7
|
+
"""
|
|
8
|
+
Project detection interface for WOMM CLI.
|
|
9
|
+
|
|
10
|
+
Handles project type detection operations following the MEF pattern.
|
|
11
|
+
Provides unified interface for detecting project types and configurations.
|
|
12
|
+
|
|
13
|
+
This interface orchestrates ProjectDetectionService and converts service
|
|
14
|
+
exceptions into a typed ``ProjectDetectionResult`` — it never raises.
|
|
15
|
+
"""
|
|
16
|
+
|
|
17
|
+
from __future__ import annotations
|
|
18
|
+
|
|
19
|
+
# ///////////////////////////////////////////////////////////////
|
|
20
|
+
# IMPORTS
|
|
21
|
+
# ///////////////////////////////////////////////////////////////
|
|
22
|
+
# Standard library imports
|
|
23
|
+
import logging
|
|
24
|
+
from pathlib import Path
|
|
25
|
+
|
|
26
|
+
# Local imports
|
|
27
|
+
from ...exceptions.project import ProjectServiceError
|
|
28
|
+
from ...services import ProjectDetectionService
|
|
29
|
+
from ...shared.results import ProjectDetectionResult
|
|
30
|
+
|
|
31
|
+
# ///////////////////////////////////////////////////////////////
|
|
32
|
+
# LOGGER SETUP
|
|
33
|
+
# ///////////////////////////////////////////////////////////////
|
|
34
|
+
|
|
35
|
+
logger = logging.getLogger(__name__)
|
|
36
|
+
|
|
37
|
+
# ///////////////////////////////////////////////////////////////
|
|
38
|
+
# MAIN CLASS
|
|
39
|
+
# ///////////////////////////////////////////////////////////////
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
class ProjectDetectionInterface:
|
|
43
|
+
"""
|
|
44
|
+
Interface for project type detection operations.
|
|
45
|
+
|
|
46
|
+
This class provides a high-level interface for project detection operations,
|
|
47
|
+
orchestrating project detection services and returning typed results.
|
|
48
|
+
"""
|
|
49
|
+
|
|
50
|
+
def __init__(self):
|
|
51
|
+
"""Initialize the project detection interface."""
|
|
52
|
+
self._detection_service = ProjectDetectionService()
|
|
53
|
+
self.logger = logging.getLogger(__name__)
|
|
54
|
+
|
|
55
|
+
# ///////////////////////////////////////////////////////////////
|
|
56
|
+
# PUBLIC METHODS
|
|
57
|
+
# ///////////////////////////////////////////////////////////////
|
|
58
|
+
|
|
59
|
+
def detect_project_type(
|
|
60
|
+
self, project_path: Path | None = None
|
|
61
|
+
) -> ProjectDetectionResult:
|
|
62
|
+
"""Detect the type of project at the given path.
|
|
63
|
+
|
|
64
|
+
Args:
|
|
65
|
+
project_path: Path to the project directory (defaults to current directory)
|
|
66
|
+
|
|
67
|
+
Returns:
|
|
68
|
+
ProjectDetectionResult: Result containing detected project type and metadata
|
|
69
|
+
"""
|
|
70
|
+
try:
|
|
71
|
+
# Use current directory if no path provided
|
|
72
|
+
resolved_path = (project_path or Path.cwd()).resolve()
|
|
73
|
+
|
|
74
|
+
# Call service to detect project type
|
|
75
|
+
type_result = self._detection_service.detect_project_type(resolved_path)
|
|
76
|
+
detected_type = (
|
|
77
|
+
type_result.project_type
|
|
78
|
+
if isinstance(type_result, ProjectDetectionResult)
|
|
79
|
+
else ""
|
|
80
|
+
)
|
|
81
|
+
|
|
82
|
+
# Get additional configuration information
|
|
83
|
+
config_files: dict[str, str] = {}
|
|
84
|
+
detected_files: list[str] = []
|
|
85
|
+
confidence = 0.0
|
|
86
|
+
|
|
87
|
+
if detected_type and detected_type != "unknown":
|
|
88
|
+
try:
|
|
89
|
+
config_result = self._detection_service.detect_project_config(
|
|
90
|
+
resolved_path
|
|
91
|
+
)
|
|
92
|
+
if isinstance(config_result, ProjectDetectionResult):
|
|
93
|
+
config_files = config_result.configuration_files or {}
|
|
94
|
+
detected_files = config_result.detected_files or []
|
|
95
|
+
confidence = 100.0 # High confidence when type is detected
|
|
96
|
+
except ProjectServiceError:
|
|
97
|
+
# If config detection fails, we still have the type
|
|
98
|
+
logger.warning(
|
|
99
|
+
f"Could not detect full configuration for {detected_type} project"
|
|
100
|
+
)
|
|
101
|
+
confidence = 75.0 # Lower confidence without full config
|
|
102
|
+
else:
|
|
103
|
+
confidence = 0.0
|
|
104
|
+
|
|
105
|
+
return ProjectDetectionResult(
|
|
106
|
+
success=True,
|
|
107
|
+
project_type=detected_type or "unknown",
|
|
108
|
+
confidence=confidence,
|
|
109
|
+
detected_files=detected_files,
|
|
110
|
+
configuration_files=config_files,
|
|
111
|
+
)
|
|
112
|
+
|
|
113
|
+
except ProjectServiceError as e:
|
|
114
|
+
return ProjectDetectionResult(
|
|
115
|
+
success=False,
|
|
116
|
+
error=f"Failed to detect project type: {e.reason}",
|
|
117
|
+
)
|
|
118
|
+
except Exception as e:
|
|
119
|
+
logger.error(
|
|
120
|
+
f"Unexpected error during project detection: {e}", exc_info=True
|
|
121
|
+
)
|
|
122
|
+
return ProjectDetectionResult(
|
|
123
|
+
success=False,
|
|
124
|
+
error=f"Unexpected error during project detection: {e}",
|
|
125
|
+
)
|
|
126
|
+
|
|
127
|
+
def detect_project_config(
|
|
128
|
+
self, project_path: Path | None = None
|
|
129
|
+
) -> ProjectDetectionResult:
|
|
130
|
+
"""Detect project configuration files and settings.
|
|
131
|
+
|
|
132
|
+
Args:
|
|
133
|
+
project_path: Path to the project directory (defaults to current directory)
|
|
134
|
+
|
|
135
|
+
Returns:
|
|
136
|
+
ProjectDetectionResult: Result containing project configuration information
|
|
137
|
+
"""
|
|
138
|
+
try:
|
|
139
|
+
# Use current directory if no path provided
|
|
140
|
+
resolved_path = (project_path or Path.cwd()).resolve()
|
|
141
|
+
|
|
142
|
+
# Call service to detect project configuration
|
|
143
|
+
config_result = self._detection_service.detect_project_config(resolved_path)
|
|
144
|
+
detected_type = (
|
|
145
|
+
config_result.project_type
|
|
146
|
+
if isinstance(config_result, ProjectDetectionResult)
|
|
147
|
+
else ""
|
|
148
|
+
)
|
|
149
|
+
config_files = (
|
|
150
|
+
config_result.configuration_files
|
|
151
|
+
if isinstance(config_result, ProjectDetectionResult)
|
|
152
|
+
else {}
|
|
153
|
+
)
|
|
154
|
+
detected_files = (
|
|
155
|
+
list(config_result.detected_files or [])
|
|
156
|
+
if isinstance(config_result, ProjectDetectionResult)
|
|
157
|
+
else []
|
|
158
|
+
)
|
|
159
|
+
|
|
160
|
+
return ProjectDetectionResult(
|
|
161
|
+
success=True,
|
|
162
|
+
project_type=str(detected_type) if detected_type else "unknown",
|
|
163
|
+
confidence=100.0 if detected_type else 0.0,
|
|
164
|
+
detected_files=detected_files,
|
|
165
|
+
configuration_files=config_files,
|
|
166
|
+
)
|
|
167
|
+
|
|
168
|
+
except ProjectServiceError as e:
|
|
169
|
+
return ProjectDetectionResult(
|
|
170
|
+
success=False,
|
|
171
|
+
error=f"Failed to detect project configuration: {e.reason}",
|
|
172
|
+
)
|
|
173
|
+
except Exception as e:
|
|
174
|
+
logger.error(
|
|
175
|
+
f"Unexpected error during project configuration detection: {e}",
|
|
176
|
+
exc_info=True,
|
|
177
|
+
)
|
|
178
|
+
return ProjectDetectionResult(
|
|
179
|
+
success=False,
|
|
180
|
+
error=f"Unexpected error during project configuration detection: {e}",
|
|
181
|
+
)
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
# ///////////////////////////////////////////////////////////////
|
|
3
|
+
# PROJECT MANAGER - Project Creation and Management
|
|
4
|
+
# Project: works-on-my-machine
|
|
5
|
+
# ///////////////////////////////////////////////////////////////
|
|
6
|
+
|
|
7
|
+
"""
|
|
8
|
+
Main project manager for WOMM CLI.
|
|
9
|
+
|
|
10
|
+
Orchestrates project creation and management operations.
|
|
11
|
+
Provides unified interface for creating and managing projects
|
|
12
|
+
across different languages and frameworks.
|
|
13
|
+
|
|
14
|
+
This interface never raises: every public method returns a typed Result.
|
|
15
|
+
"""
|
|
16
|
+
|
|
17
|
+
from __future__ import annotations
|
|
18
|
+
|
|
19
|
+
# ///////////////////////////////////////////////////////////////
|
|
20
|
+
# IMPORTS
|
|
21
|
+
# ///////////////////////////////////////////////////////////////
|
|
22
|
+
# Standard library imports
|
|
23
|
+
import logging
|
|
24
|
+
from pathlib import Path
|
|
25
|
+
|
|
26
|
+
# Local imports
|
|
27
|
+
from ...shared.results import (
|
|
28
|
+
ProjectDetectionResult,
|
|
29
|
+
ProjectSetupResult,
|
|
30
|
+
)
|
|
31
|
+
from .detection_interface import ProjectDetectionInterface
|
|
32
|
+
from .setup_interface import ProjectSetupInterface
|
|
33
|
+
|
|
34
|
+
# ///////////////////////////////////////////////////////////////
|
|
35
|
+
# MAIN CLASS
|
|
36
|
+
# ///////////////////////////////////////////////////////////////
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
class ProjectManagerInterface:
|
|
40
|
+
"""Main project manager for WOMM CLI."""
|
|
41
|
+
|
|
42
|
+
def __init__(self):
|
|
43
|
+
"""Initialize the project manager."""
|
|
44
|
+
self._setup_interface = ProjectSetupInterface()
|
|
45
|
+
self._detection_interface = ProjectDetectionInterface()
|
|
46
|
+
self.logger = logging.getLogger(__name__)
|
|
47
|
+
|
|
48
|
+
# ///////////////////////////////////////////////////////////////
|
|
49
|
+
# PUBLIC METHODS
|
|
50
|
+
# ///////////////////////////////////////////////////////////////
|
|
51
|
+
|
|
52
|
+
def detect_project_type(
|
|
53
|
+
self, project_path: Path | None = None
|
|
54
|
+
) -> ProjectDetectionResult:
|
|
55
|
+
"""
|
|
56
|
+
Detect the type of project in the given path.
|
|
57
|
+
|
|
58
|
+
Args:
|
|
59
|
+
project_path: Path to analyze (defaults to current directory)
|
|
60
|
+
|
|
61
|
+
Returns:
|
|
62
|
+
ProjectDetectionResult: Detection result with project type and confidence
|
|
63
|
+
"""
|
|
64
|
+
return self._detection_interface.detect_project_type(project_path)
|
|
65
|
+
|
|
66
|
+
def setup_project(
|
|
67
|
+
self,
|
|
68
|
+
project_type: str,
|
|
69
|
+
project_path: Path,
|
|
70
|
+
virtual_env: bool = False,
|
|
71
|
+
install_deps: bool = False,
|
|
72
|
+
setup_dev_tools: bool = False,
|
|
73
|
+
setup_git_hooks: bool = False,
|
|
74
|
+
**kwargs,
|
|
75
|
+
) -> ProjectSetupResult:
|
|
76
|
+
"""
|
|
77
|
+
Set up an existing project with development tools and configuration.
|
|
78
|
+
|
|
79
|
+
Args:
|
|
80
|
+
project_type: Type of project (python, javascript, react, vue)
|
|
81
|
+
project_path: Path to the existing project
|
|
82
|
+
virtual_env: Whether to create virtual environment (Python only)
|
|
83
|
+
install_deps: Whether to install dependencies
|
|
84
|
+
setup_dev_tools: Whether to set up development tools
|
|
85
|
+
setup_git_hooks: Whether to set up Git hooks
|
|
86
|
+
**kwargs: Additional project-specific options
|
|
87
|
+
|
|
88
|
+
Returns:
|
|
89
|
+
ProjectSetupResult: Result of the setup operation
|
|
90
|
+
"""
|
|
91
|
+
return self._setup_interface.setup_project(
|
|
92
|
+
project_path=project_path,
|
|
93
|
+
project_type=project_type,
|
|
94
|
+
virtual_env=virtual_env,
|
|
95
|
+
install_deps=install_deps,
|
|
96
|
+
setup_dev_tools=setup_dev_tools,
|
|
97
|
+
setup_git_hooks=setup_git_hooks,
|
|
98
|
+
**kwargs,
|
|
99
|
+
)
|