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,65 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
# ///////////////////////////////////////////////////////////////
|
|
3
|
+
# TEMPLATE SOURCE - Template catalog entry model
|
|
4
|
+
# Project: works-on-my-machine
|
|
5
|
+
# ///////////////////////////////////////////////////////////////
|
|
6
|
+
|
|
7
|
+
"""Immutable model describing a Copier template known to WOMM."""
|
|
8
|
+
|
|
9
|
+
from __future__ import annotations
|
|
10
|
+
|
|
11
|
+
# ///////////////////////////////////////////////////////////////
|
|
12
|
+
# IMPORTS
|
|
13
|
+
# ///////////////////////////////////////////////////////////////
|
|
14
|
+
from dataclasses import dataclass
|
|
15
|
+
from enum import StrEnum
|
|
16
|
+
from pathlib import Path
|
|
17
|
+
|
|
18
|
+
# ///////////////////////////////////////////////////////////////
|
|
19
|
+
# MODELS
|
|
20
|
+
# ///////////////////////////////////////////////////////////////
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
class TemplateOrigin(StrEnum):
|
|
24
|
+
"""Where a template comes from.
|
|
25
|
+
|
|
26
|
+
Official templates ship inside the wheel and are read-only. User
|
|
27
|
+
templates are registered by the user and stored in the catalog.
|
|
28
|
+
"""
|
|
29
|
+
|
|
30
|
+
OFFICIAL = "official"
|
|
31
|
+
USER = "user"
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
@dataclass(frozen=True)
|
|
35
|
+
class TemplateEntry:
|
|
36
|
+
"""A Copier template known to WOMM.
|
|
37
|
+
|
|
38
|
+
Attributes:
|
|
39
|
+
id: Short identifier, unique within an origin (e.g. "python").
|
|
40
|
+
origin: Whether the template ships with WOMM or was registered.
|
|
41
|
+
source: Absolute path to the template root holding ``copier.yml``.
|
|
42
|
+
version: Declared template version, empty when unknown.
|
|
43
|
+
description: One-line human description, empty when unknown.
|
|
44
|
+
setup_language: Language family driving `womm setup` ("python" or
|
|
45
|
+
"javascript"), empty when the manifest declares none.
|
|
46
|
+
"""
|
|
47
|
+
|
|
48
|
+
id: str
|
|
49
|
+
origin: TemplateOrigin
|
|
50
|
+
source: Path
|
|
51
|
+
version: str = ""
|
|
52
|
+
description: str = ""
|
|
53
|
+
setup_language: str = ""
|
|
54
|
+
|
|
55
|
+
@property
|
|
56
|
+
def qualified_id(self) -> str:
|
|
57
|
+
"""Get the fully-qualified, unambiguous identifier."""
|
|
58
|
+
return f"{self.origin.value}/{self.id}"
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
# ///////////////////////////////////////////////////////////////
|
|
62
|
+
# PUBLIC API
|
|
63
|
+
# ///////////////////////////////////////////////////////////////
|
|
64
|
+
|
|
65
|
+
__all__ = ["TemplateEntry", "TemplateOrigin"]
|
womm/shared/paths.py
ADDED
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
# ///////////////////////////////////////////////////////////////
|
|
3
|
+
# SHARED PATHS - Single Authority on Data and Asset Locations
|
|
4
|
+
# Project: works-on-my-machine
|
|
5
|
+
# ///////////////////////////////////////////////////////////////
|
|
6
|
+
|
|
7
|
+
"""
|
|
8
|
+
Path contract for Works On My Machine.
|
|
9
|
+
|
|
10
|
+
This module is the **single authority** on where things live. It keeps two
|
|
11
|
+
notions strictly apart:
|
|
12
|
+
|
|
13
|
+
- **Data** — mutable, user-owned, always under ``~/.womm`` (overridable via
|
|
14
|
+
``$WOMM_HOME``), both in a source checkout and in an installed package. This
|
|
15
|
+
directory never contains code.
|
|
16
|
+
- **Code and assets** — immutable, shipped inside the package, read through
|
|
17
|
+
:mod:`importlib.resources` so they resolve identically from a source tree
|
|
18
|
+
and from a wheel.
|
|
19
|
+
|
|
20
|
+
Directory accessors create their target lazily on access; file accessors
|
|
21
|
+
return a path and guarantee only that its parent exists.
|
|
22
|
+
"""
|
|
23
|
+
|
|
24
|
+
from __future__ import annotations
|
|
25
|
+
|
|
26
|
+
# ///////////////////////////////////////////////////////////////
|
|
27
|
+
# IMPORTS
|
|
28
|
+
# ///////////////////////////////////////////////////////////////
|
|
29
|
+
# Standard library imports
|
|
30
|
+
import os
|
|
31
|
+
from importlib.resources import files
|
|
32
|
+
from pathlib import Path
|
|
33
|
+
from typing import TYPE_CHECKING
|
|
34
|
+
|
|
35
|
+
if TYPE_CHECKING:
|
|
36
|
+
from importlib.abc import Traversable
|
|
37
|
+
|
|
38
|
+
# ///////////////////////////////////////////////////////////////
|
|
39
|
+
# CONSTANTS
|
|
40
|
+
# ///////////////////////////////////////////////////////////////
|
|
41
|
+
|
|
42
|
+
# Environment variable overriding the data directory. Primarily an isolation
|
|
43
|
+
# seam for tests, which must never touch the real ``~/.womm``.
|
|
44
|
+
WOMM_HOME_ENV = "WOMM_HOME"
|
|
45
|
+
|
|
46
|
+
# Default data directory name, relative to the user's home.
|
|
47
|
+
DEFAULT_DATA_DIRNAME = ".womm"
|
|
48
|
+
|
|
49
|
+
# Sub-paths, relative to the data directory.
|
|
50
|
+
LOGS_DIRNAME = "logs"
|
|
51
|
+
TEMPLATES_DIRNAME = "templates"
|
|
52
|
+
BACKUPS_DIRNAME = "backups"
|
|
53
|
+
PATH_BACKUPS_DIRNAME = "path"
|
|
54
|
+
REGISTRY_BACKUPS_DIRNAME = "registry"
|
|
55
|
+
CONFIG_FILENAME = "config.toml"
|
|
56
|
+
|
|
57
|
+
# Package subdirectory holding the shipped, read-only assets.
|
|
58
|
+
ASSETS_DIRNAME = "assets"
|
|
59
|
+
|
|
60
|
+
# Sub-paths of the shipped assets tree holding Copier templates.
|
|
61
|
+
COPIER_DIRNAME = "copier"
|
|
62
|
+
COPIER_OFFICIAL_DIRNAME = "official"
|
|
63
|
+
COPIER_META_DIRNAME = "meta"
|
|
64
|
+
|
|
65
|
+
# Sub-paths of the user templates directory.
|
|
66
|
+
TEMPLATE_CATALOG_FILENAME = "catalog.json"
|
|
67
|
+
|
|
68
|
+
# ///////////////////////////////////////////////////////////////
|
|
69
|
+
# INTERNAL HELPERS
|
|
70
|
+
# ///////////////////////////////////////////////////////////////
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
def _ensure_dir(directory: Path) -> Path:
|
|
74
|
+
"""Create ``directory`` (and parents) if needed and return it."""
|
|
75
|
+
directory.mkdir(parents=True, exist_ok=True)
|
|
76
|
+
return directory
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
def _data_subdir(*parts: str) -> Path:
|
|
80
|
+
"""Resolve and create a directory under the data directory."""
|
|
81
|
+
return _ensure_dir(womm_data_dir().joinpath(*parts))
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
# ///////////////////////////////////////////////////////////////
|
|
85
|
+
# PUBLIC API - DATA LOCATIONS
|
|
86
|
+
# ///////////////////////////////////////////////////////////////
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
def womm_data_path() -> Path:
|
|
90
|
+
"""Resolve the WOMM data directory without creating it.
|
|
91
|
+
|
|
92
|
+
Honors ``$WOMM_HOME`` when set to a non-blank value; otherwise defaults
|
|
93
|
+
to ``~/.womm``. This path holds user data only — never code.
|
|
94
|
+
|
|
95
|
+
Returns:
|
|
96
|
+
Path: The data directory location.
|
|
97
|
+
"""
|
|
98
|
+
override = os.environ.get(WOMM_HOME_ENV, "").strip()
|
|
99
|
+
return (
|
|
100
|
+
Path(override).expanduser().resolve()
|
|
101
|
+
if override
|
|
102
|
+
else Path.home() / DEFAULT_DATA_DIRNAME
|
|
103
|
+
)
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
def womm_data_dir() -> Path:
|
|
107
|
+
"""Get the WOMM data directory, creating it if absent."""
|
|
108
|
+
return _ensure_dir(womm_data_path())
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
def logs_dir() -> Path:
|
|
112
|
+
"""Get the directory holding WOMM log files."""
|
|
113
|
+
return _data_subdir(LOGS_DIRNAME)
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
def user_templates_dir() -> Path:
|
|
117
|
+
"""Get the directory holding user-created project templates."""
|
|
118
|
+
return _data_subdir(TEMPLATES_DIRNAME)
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
def template_catalog_file() -> Path:
|
|
122
|
+
"""Get the user template catalog path (not created).
|
|
123
|
+
|
|
124
|
+
Holds only user-registered templates; official templates shipped in the
|
|
125
|
+
wheel are discovered at read time and never persisted here.
|
|
126
|
+
"""
|
|
127
|
+
return user_templates_dir() / TEMPLATE_CATALOG_FILENAME
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
def path_backups_dir() -> Path:
|
|
131
|
+
"""Get the directory holding system ``PATH`` backups (``womm path``)."""
|
|
132
|
+
return _data_subdir(BACKUPS_DIRNAME, PATH_BACKUPS_DIRNAME)
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
def registry_backups_dir() -> Path:
|
|
136
|
+
"""Get the directory holding context-menu registry backups."""
|
|
137
|
+
return _data_subdir(BACKUPS_DIRNAME, REGISTRY_BACKUPS_DIRNAME)
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
def config_file() -> Path:
|
|
141
|
+
"""Get the user configuration file path (not created)."""
|
|
142
|
+
return womm_data_dir() / CONFIG_FILENAME
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
# ///////////////////////////////////////////////////////////////
|
|
146
|
+
# PUBLIC API - PACKAGED CODE AND ASSETS
|
|
147
|
+
# ///////////////////////////////////////////////////////////////
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
def packaged_assets() -> Traversable:
|
|
151
|
+
"""Get the shipped assets tree, read-only.
|
|
152
|
+
|
|
153
|
+
Anchored on the ``womm`` package rather than on ``womm.assets``: the
|
|
154
|
+
assets directory carries no ``__init__.py``, so anchoring on it directly
|
|
155
|
+
would depend on namespace-package resolution. Traversing from the parent
|
|
156
|
+
package works identically from a source tree, a wheel, or a frozen
|
|
157
|
+
executable.
|
|
158
|
+
|
|
159
|
+
Returns:
|
|
160
|
+
Traversable: The ``assets`` directory inside the installed package.
|
|
161
|
+
"""
|
|
162
|
+
return files("womm") / ASSETS_DIRNAME
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
def packaged_copier_official() -> Traversable:
|
|
166
|
+
"""Get the shipped official Copier templates tree, read-only."""
|
|
167
|
+
return packaged_assets() / COPIER_DIRNAME / COPIER_OFFICIAL_DIRNAME
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
def packaged_copier_meta() -> Traversable:
|
|
171
|
+
"""Get the shipped meta-template used by ``womm template init``."""
|
|
172
|
+
return packaged_assets() / COPIER_DIRNAME / COPIER_META_DIRNAME
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
# ///////////////////////////////////////////////////////////////
|
|
176
|
+
# EXPORTS
|
|
177
|
+
# ///////////////////////////////////////////////////////////////
|
|
178
|
+
|
|
179
|
+
__all__ = [
|
|
180
|
+
"WOMM_HOME_ENV",
|
|
181
|
+
"config_file",
|
|
182
|
+
"logs_dir",
|
|
183
|
+
"packaged_assets",
|
|
184
|
+
"packaged_copier_official",
|
|
185
|
+
"packaged_copier_meta",
|
|
186
|
+
"path_backups_dir",
|
|
187
|
+
"registry_backups_dir",
|
|
188
|
+
"template_catalog_file",
|
|
189
|
+
"user_templates_dir",
|
|
190
|
+
"womm_data_path",
|
|
191
|
+
"womm_data_dir",
|
|
192
|
+
]
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
# ///////////////////////////////////////////////////////////////
|
|
3
|
+
# RESULTS - Result Classes Package
|
|
4
|
+
# Project: works-on-my-machine
|
|
5
|
+
# ///////////////////////////////////////////////////////////////
|
|
6
|
+
|
|
7
|
+
"""
|
|
8
|
+
Result classes for Works On My Machine.
|
|
9
|
+
|
|
10
|
+
This package provides structured data objects for service and interface operations.
|
|
11
|
+
Results are organized by domain for better maintainability.
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
from __future__ import annotations
|
|
15
|
+
|
|
16
|
+
# ///////////////////////////////////////////////////////////////
|
|
17
|
+
# IMPORTS
|
|
18
|
+
# ///////////////////////////////////////////////////////////////
|
|
19
|
+
# Local imports
|
|
20
|
+
from .base import BaseResult, CommandResult
|
|
21
|
+
from .command_results import CommandAvailabilityResult, CommandVersionResult
|
|
22
|
+
from .context_results import (
|
|
23
|
+
BackupCleanupResult,
|
|
24
|
+
BackupDataResult,
|
|
25
|
+
BackupFileInfo,
|
|
26
|
+
BackupFileListResult,
|
|
27
|
+
BackupFileResult,
|
|
28
|
+
ContextBackupResult,
|
|
29
|
+
ContextCherryPickResult,
|
|
30
|
+
ContextEntriesResult,
|
|
31
|
+
ContextRegistryResult,
|
|
32
|
+
ContextRestoreResult,
|
|
33
|
+
ContextSetupResult,
|
|
34
|
+
ContextValidationResult,
|
|
35
|
+
ScriptInfoResult,
|
|
36
|
+
ScriptRegistrationResult,
|
|
37
|
+
ScriptUnregistrationResult,
|
|
38
|
+
ScriptValidationResult,
|
|
39
|
+
)
|
|
40
|
+
from .dependency_results import (
|
|
41
|
+
DependencyCheckResult,
|
|
42
|
+
DependencyInventoryEntry,
|
|
43
|
+
DependencyInventoryResult,
|
|
44
|
+
DependencyProbe,
|
|
45
|
+
DependencyStatusResult,
|
|
46
|
+
)
|
|
47
|
+
from .doctor_results import DoctorResult
|
|
48
|
+
from .file_results import FileOperationResult, FileScanResult, FileSearchResult
|
|
49
|
+
from .project_results import (
|
|
50
|
+
ConfigurationResult,
|
|
51
|
+
ProjectCreationResult,
|
|
52
|
+
ProjectDetectionResult,
|
|
53
|
+
ProjectSetupResult,
|
|
54
|
+
SetupResult,
|
|
55
|
+
)
|
|
56
|
+
from .security_results import (
|
|
57
|
+
CommandValidationResult,
|
|
58
|
+
PathValidationResult,
|
|
59
|
+
SecurityReportResult,
|
|
60
|
+
SecurityResult,
|
|
61
|
+
ValidationResult,
|
|
62
|
+
)
|
|
63
|
+
from .system_results import (
|
|
64
|
+
EnvironmentRefreshResult,
|
|
65
|
+
EnvironmentVerificationResult,
|
|
66
|
+
PathBackupContentResult,
|
|
67
|
+
PathBackupInfo,
|
|
68
|
+
PathBackupListResult,
|
|
69
|
+
PathBackupResult,
|
|
70
|
+
PathOperationResult,
|
|
71
|
+
PrerequisitesCheckResult,
|
|
72
|
+
PrerequisitesInstallResult,
|
|
73
|
+
SystemDetectionResult,
|
|
74
|
+
SystemInfoResult,
|
|
75
|
+
)
|
|
76
|
+
from .template_results import (
|
|
77
|
+
TemplateListResult,
|
|
78
|
+
TemplateStoreResult,
|
|
79
|
+
)
|
|
80
|
+
|
|
81
|
+
# ///////////////////////////////////////////////////////////////
|
|
82
|
+
# PUBLIC API
|
|
83
|
+
# ///////////////////////////////////////////////////////////////
|
|
84
|
+
|
|
85
|
+
__all__ = [
|
|
86
|
+
"BackupCleanupResult",
|
|
87
|
+
"BackupDataResult",
|
|
88
|
+
"BackupFileInfo",
|
|
89
|
+
"BackupFileListResult",
|
|
90
|
+
"BackupFileResult",
|
|
91
|
+
"BaseResult",
|
|
92
|
+
"CommandAvailabilityResult",
|
|
93
|
+
"CommandResult",
|
|
94
|
+
"CommandValidationResult",
|
|
95
|
+
"CommandVersionResult",
|
|
96
|
+
"ConfigurationResult",
|
|
97
|
+
"ContextBackupResult",
|
|
98
|
+
"ContextCherryPickResult",
|
|
99
|
+
"ContextEntriesResult",
|
|
100
|
+
"ContextRegistryResult",
|
|
101
|
+
"ContextRestoreResult",
|
|
102
|
+
"ContextSetupResult",
|
|
103
|
+
"ContextValidationResult",
|
|
104
|
+
"DependencyCheckResult",
|
|
105
|
+
"DependencyInventoryEntry",
|
|
106
|
+
"DependencyInventoryResult",
|
|
107
|
+
"DependencyProbe",
|
|
108
|
+
"DependencyStatusResult",
|
|
109
|
+
"DoctorResult",
|
|
110
|
+
"EnvironmentRefreshResult",
|
|
111
|
+
"EnvironmentVerificationResult",
|
|
112
|
+
"FileOperationResult",
|
|
113
|
+
"FileScanResult",
|
|
114
|
+
"FileSearchResult",
|
|
115
|
+
"PathBackupContentResult",
|
|
116
|
+
"PathBackupInfo",
|
|
117
|
+
"PathBackupListResult",
|
|
118
|
+
"PathBackupResult",
|
|
119
|
+
"PathOperationResult",
|
|
120
|
+
"PathValidationResult",
|
|
121
|
+
"PrerequisitesCheckResult",
|
|
122
|
+
"PrerequisitesInstallResult",
|
|
123
|
+
"ProjectCreationResult",
|
|
124
|
+
"ProjectDetectionResult",
|
|
125
|
+
"ProjectSetupResult",
|
|
126
|
+
"ScriptInfoResult",
|
|
127
|
+
"ScriptRegistrationResult",
|
|
128
|
+
"ScriptUnregistrationResult",
|
|
129
|
+
"ScriptValidationResult",
|
|
130
|
+
"SecurityReportResult",
|
|
131
|
+
"SecurityResult",
|
|
132
|
+
"SetupResult",
|
|
133
|
+
"SystemDetectionResult",
|
|
134
|
+
"SystemInfoResult",
|
|
135
|
+
"TemplateListResult",
|
|
136
|
+
"TemplateStoreResult",
|
|
137
|
+
"ValidationResult",
|
|
138
|
+
]
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
# ///////////////////////////////////////////////////////////////
|
|
3
|
+
# RESULTS BASE - Base Result Classes
|
|
4
|
+
# Project: works-on-my-machine
|
|
5
|
+
# ///////////////////////////////////////////////////////////////
|
|
6
|
+
|
|
7
|
+
"""
|
|
8
|
+
Base result classes for Works On My Machine.
|
|
9
|
+
|
|
10
|
+
This module provides the base result class and common result types
|
|
11
|
+
used across both services and interfaces.
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
from __future__ import annotations
|
|
15
|
+
|
|
16
|
+
# ///////////////////////////////////////////////////////////////
|
|
17
|
+
# IMPORTS
|
|
18
|
+
# ///////////////////////////////////////////////////////////////
|
|
19
|
+
# Standard library imports
|
|
20
|
+
from dataclasses import dataclass
|
|
21
|
+
from pathlib import Path
|
|
22
|
+
|
|
23
|
+
# ///////////////////////////////////////////////////////////////
|
|
24
|
+
# BASE RESULT CLASSES
|
|
25
|
+
# ///////////////////////////////////////////////////////////////
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
@dataclass
|
|
29
|
+
class BaseResult:
|
|
30
|
+
"""Base result class with common attributes."""
|
|
31
|
+
|
|
32
|
+
success: bool
|
|
33
|
+
message: str = ""
|
|
34
|
+
error: str = ""
|
|
35
|
+
|
|
36
|
+
def __bool__(self) -> bool:
|
|
37
|
+
"""Return success status as boolean."""
|
|
38
|
+
return self.success
|
|
39
|
+
|
|
40
|
+
def __str__(self) -> str:
|
|
41
|
+
"""Return string representation."""
|
|
42
|
+
if self.success:
|
|
43
|
+
return f"Success: {self.message}"
|
|
44
|
+
else:
|
|
45
|
+
return f"Failed: {self.error}"
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
@dataclass
|
|
49
|
+
class CommandResult:
|
|
50
|
+
"""Result for command execution."""
|
|
51
|
+
|
|
52
|
+
returncode: int
|
|
53
|
+
stdout: str = ""
|
|
54
|
+
stderr: str = ""
|
|
55
|
+
command: list[str] | None = None
|
|
56
|
+
cwd: Path | None = None
|
|
57
|
+
security_validated: bool = False
|
|
58
|
+
execution_time: float = 0.0
|
|
59
|
+
|
|
60
|
+
def __post_init__(self) -> None:
|
|
61
|
+
"""Initialize derived fields."""
|
|
62
|
+
if self.command is None:
|
|
63
|
+
self.command = []
|
|
64
|
+
|
|
65
|
+
def __bool__(self) -> bool:
|
|
66
|
+
"""Return success status as boolean."""
|
|
67
|
+
return self.returncode == 0
|
|
68
|
+
|
|
69
|
+
def __str__(self) -> str:
|
|
70
|
+
"""Return string representation."""
|
|
71
|
+
return (
|
|
72
|
+
f"CommandResult(success={bool(self)}, "
|
|
73
|
+
f"validated={self.security_validated}, "
|
|
74
|
+
f"time={self.execution_time:.2f}s)"
|
|
75
|
+
)
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
# ///////////////////////////////////////////////////////////////
|
|
79
|
+
# PUBLIC API
|
|
80
|
+
# ///////////////////////////////////////////////////////////////
|
|
81
|
+
|
|
82
|
+
__all__ = [
|
|
83
|
+
"BaseResult",
|
|
84
|
+
"CommandResult",
|
|
85
|
+
]
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
# ///////////////////////////////////////////////////////////////
|
|
3
|
+
# COMMAND RESULTS - Command Result Classes
|
|
4
|
+
# Project: works-on-my-machine
|
|
5
|
+
# ///////////////////////////////////////////////////////////////
|
|
6
|
+
|
|
7
|
+
"""
|
|
8
|
+
Command result classes for Works On My Machine.
|
|
9
|
+
|
|
10
|
+
This module contains result classes for command operations:
|
|
11
|
+
- Command availability
|
|
12
|
+
- Command version information
|
|
13
|
+
"""
|
|
14
|
+
|
|
15
|
+
from __future__ import annotations
|
|
16
|
+
|
|
17
|
+
# ///////////////////////////////////////////////////////////////
|
|
18
|
+
# IMPORTS
|
|
19
|
+
# ///////////////////////////////////////////////////////////////
|
|
20
|
+
# Standard library imports
|
|
21
|
+
from dataclasses import dataclass
|
|
22
|
+
|
|
23
|
+
# Local imports
|
|
24
|
+
from .base import BaseResult
|
|
25
|
+
|
|
26
|
+
# ///////////////////////////////////////////////////////////////
|
|
27
|
+
# COMMAND AVAILABILITY RESULT
|
|
28
|
+
# ///////////////////////////////////////////////////////////////
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
@dataclass
|
|
32
|
+
class CommandAvailabilityResult(BaseResult):
|
|
33
|
+
"""Result of command availability check."""
|
|
34
|
+
|
|
35
|
+
command_name: str = ""
|
|
36
|
+
is_available: bool = False
|
|
37
|
+
security_validated: bool = False
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
# ///////////////////////////////////////////////////////////////
|
|
41
|
+
# COMMAND VERSION RESULT
|
|
42
|
+
# ///////////////////////////////////////////////////////////////
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
@dataclass
|
|
46
|
+
class CommandVersionResult(BaseResult):
|
|
47
|
+
"""Result of command version retrieval."""
|
|
48
|
+
|
|
49
|
+
command_name: str = ""
|
|
50
|
+
version: str = ""
|
|
51
|
+
version_flag: str = "--version"
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
# ///////////////////////////////////////////////////////////////
|
|
55
|
+
# PUBLIC API
|
|
56
|
+
# ///////////////////////////////////////////////////////////////
|
|
57
|
+
|
|
58
|
+
__all__ = [
|
|
59
|
+
"CommandAvailabilityResult",
|
|
60
|
+
"CommandVersionResult",
|
|
61
|
+
]
|