@pmaddire/gcie 0.1.9 → 0.1.10
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.
- package/GCIE_USAGE.md +58 -1
- package/cli/app.py +18 -1
- package/cli/commands/adaptation.py +821 -553
- package/cli/commands/setup.py +53 -2
- package/package.json +1 -1
package/cli/commands/setup.py
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
"""
|
|
1
|
+
"""Repository setup and teardown helpers for GCIE."""
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
5
|
+
import shutil
|
|
5
6
|
from pathlib import Path
|
|
6
7
|
|
|
7
8
|
from context.architecture_bootstrap import ensure_initialized
|
|
@@ -24,6 +25,26 @@ def _copy_if_needed(source: Path, target: Path, *, force: bool) -> str:
|
|
|
24
25
|
return "written"
|
|
25
26
|
|
|
26
27
|
|
|
28
|
+
def _is_within(base: Path, target: Path) -> bool:
|
|
29
|
+
try:
|
|
30
|
+
target.resolve().relative_to(base.resolve())
|
|
31
|
+
return True
|
|
32
|
+
except ValueError:
|
|
33
|
+
return False
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def _remove_path(root: Path, target: Path) -> str:
|
|
37
|
+
if not _is_within(root, target):
|
|
38
|
+
return "skipped_outside_repo"
|
|
39
|
+
if not target.exists():
|
|
40
|
+
return "not_found"
|
|
41
|
+
if target.is_dir():
|
|
42
|
+
shutil.rmtree(target)
|
|
43
|
+
return "removed_dir"
|
|
44
|
+
target.unlink()
|
|
45
|
+
return "removed_file"
|
|
46
|
+
|
|
47
|
+
|
|
27
48
|
def run_setup(
|
|
28
49
|
path: str,
|
|
29
50
|
*,
|
|
@@ -84,4 +105,34 @@ def run_setup(
|
|
|
84
105
|
else:
|
|
85
106
|
status["adaptation"] = {"skipped": True}
|
|
86
107
|
|
|
87
|
-
return status
|
|
108
|
+
return status
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
def run_remove(
|
|
112
|
+
path: str,
|
|
113
|
+
*,
|
|
114
|
+
remove_planning: bool = False,
|
|
115
|
+
remove_gcie_usage: bool = True,
|
|
116
|
+
remove_setup_doc: bool = True,
|
|
117
|
+
) -> dict:
|
|
118
|
+
"""Remove GCIE-managed files from a repository."""
|
|
119
|
+
target = Path(path).resolve()
|
|
120
|
+
target.mkdir(parents=True, exist_ok=True)
|
|
121
|
+
|
|
122
|
+
removed: dict[str, str] = {}
|
|
123
|
+
removed[".gcie"] = _remove_path(target, target / ".gcie")
|
|
124
|
+
|
|
125
|
+
if remove_gcie_usage:
|
|
126
|
+
removed["GCIE_USAGE.md"] = _remove_path(target, target / "GCIE_USAGE.md")
|
|
127
|
+
|
|
128
|
+
if remove_setup_doc:
|
|
129
|
+
removed["SETUP_ANY_REPO.md"] = _remove_path(target, target / "SETUP_ANY_REPO.md")
|
|
130
|
+
|
|
131
|
+
if remove_planning:
|
|
132
|
+
removed[".planning"] = _remove_path(target, target / ".planning")
|
|
133
|
+
|
|
134
|
+
return {
|
|
135
|
+
"repo": target.as_posix(),
|
|
136
|
+
"removed": removed,
|
|
137
|
+
"remove_planning": remove_planning,
|
|
138
|
+
}
|