haraka 0.2.36__py3-none-any.whl → 0.2.38__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.
@@ -1,6 +1,6 @@
1
1
  from dataclasses import dataclass
2
2
  from pathlib import Path
3
- from typing import Iterable
3
+ from typing import Iterable, List, Tuple
4
4
  import yaml
5
5
  from pathspec import PathSpec
6
6
 
@@ -18,7 +18,7 @@ class PostGenConfig:
18
18
  evm: bool = False # Extreme Verbosity Mode - For in depth debugging
19
19
 
20
20
 
21
- def load_manifest(variant: str) -> list[str]:
21
+ def load_manifest(variant: str) -> Tuple[List[str], List[str]]:
22
22
  """Return the `keep:` pattern list from `<variant>.yml`."""
23
23
  manifest_path = _MANIFEST_DIR / f"{variant}.yml"
24
24
  if not manifest_path.exists():
@@ -27,12 +27,15 @@ def load_manifest(variant: str) -> list[str]:
27
27
  f"(expected {manifest_path})"
28
28
  )
29
29
  doc = yaml.safe_load(manifest_path.read_text())
30
- if not isinstance(doc, dict) or "keep" not in doc:
30
+ if not isinstance(doc, dict) or "keep" not in doc or "protected_dirs" not in doc:
31
31
  raise ValueError(f"Manifest {manifest_path} missing a `keep:` section")
32
32
  keep_patterns = doc["keep"]
33
+ protected_dirs = doc.get("protected_dirs", [])
33
34
  if not isinstance(keep_patterns, Iterable):
34
35
  raise TypeError(f"`keep` section in {manifest_path} must be a list")
35
- return list(keep_patterns)
36
+ if not isinstance(protected_dirs, Iterable):
37
+ raise TypeError(f"`protected` section in {manifest_path} must be a list")
38
+ return list(keep_patterns), list(protected_dirs)
36
39
 
37
40
 
38
41
  def build_spec(patterns: Iterable[str]) -> PathSpec:
@@ -65,12 +65,14 @@ class ResourcePurger:
65
65
  self._log.info(f"Starting purge for variant: {variant}")
66
66
  self._log.debug(f"Loaded variant for purge: {variant}")
67
67
 
68
- raw_patterns = config.load_manifest(variant)
68
+ raw_patterns, raw_protected_dirs = config.load_manifest(variant)
69
69
  keep_patterns = [p.rstrip("/") for p in raw_patterns]
70
+ protected_dirs = [p.rstrip("/") for p in raw_protected_dirs]
70
71
 
71
72
  self._log.debug(f"Loaded manifest for variant '{variant}': {keep_patterns}")
72
73
 
73
74
  spec = config.build_spec(keep_patterns)
75
+ protected_spec = config.build_spec(protected_dirs)
74
76
  self._log.debug(f"Built PathSpec for keep patterns. Total patterns: {len(keep_patterns)}")
75
77
 
76
78
  self._log.info(f"Keeping {len(keep_patterns)} pattern(s)")
@@ -81,7 +83,7 @@ class ResourcePurger:
81
83
 
82
84
  matched, non_dirs, non_files, _ = self.classify_paths(all_paths, project_dir, spec)
83
85
 
84
- self._purge_unrelated(project_dir, matched, non_dirs, non_files)
86
+ self._purge_unrelated(project_dir, matched, non_dirs, non_files, protected_spec)
85
87
 
86
88
  self._log.debug(f"Finished purging unrelated paths in project directory: {project_dir}")
87
89
 
@@ -146,13 +148,14 @@ class ResourcePurger:
146
148
  self._log.info(" (none)")
147
149
  self._log.info("-" * 70)
148
150
 
149
- def _dir_batch_delete(self, title: str, items: List[str], root: Path) -> None:
151
+ def _dir_batch_delete(self, title: str, items: List[str], root: Path, protected_spec: PathSpec) -> None:
150
152
  self._log.info(f"{title} — {len(items)}")
151
153
  if items:
152
154
  for p in sorted(items):
153
- full_path = root / Path(p)
154
- self._f.remove_dir(full_path)
155
- self._log.debug(f" 🗑️ DELETED DIR {p}")
155
+ if not protected_spec.match_file(p):
156
+ full_path = root / Path(p)
157
+ self._f.remove_dir(full_path)
158
+ self._log.debug(f" 🗑️ DELETED DIR {p}")
156
159
  else:
157
160
  self._log.info(" (none)")
158
161
  self._log.info("-" * 70)
@@ -174,11 +177,12 @@ class ResourcePurger:
174
177
  matched: List[str],
175
178
  non_matched_dirs: List[str],
176
179
  non_matched_files: List[str],
180
+ protected_spec: PathSpec,
177
181
  ) -> None:
178
182
  """Human-friendly digest of keep/delete results."""
179
183
  self._log.info("\n" + "=" * 70)
180
184
  self._print_matches("✅ MATCHED (keep)", matched)
181
- self._dir_batch_delete("🗂️ NON-MATCHED DIRECTORIES (delete)", non_matched_dirs, root)
185
+ self._dir_batch_delete("🗂️ NON-MATCHED DIRECTORIES (delete)", non_matched_dirs, root, protected_spec)
182
186
  self._file_batch_delete("📄 NON-MATCHED FILES (delete)", non_matched_files, root)
183
187
  self._log.info("=" * 70)
184
188
 
@@ -2,15 +2,12 @@ variant: java-springboot
2
2
 
3
3
  keep:
4
4
  # ── application source ────────────────────────────
5
- - src/
6
- - src/main/
7
5
  - src/main/java/
8
6
  - src/main/java/**
9
7
  - src/main/resources/
10
8
  - src/main/resources/**
11
9
 
12
10
  # ── tests ─────────────────────────────────────────
13
- - src/test/
14
11
  - src/test/java/
15
12
  - src/test/java/**
16
13
 
@@ -21,7 +18,6 @@ keep:
21
18
  - README.md
22
19
 
23
20
  # ── IDE / run configs ─────────────────────────────
24
- - runConfigurations/
25
21
  - runConfigurations/SpringBoot/
26
22
  - runConfigurations/SpringBoot/**
27
23
 
@@ -31,3 +27,7 @@ keep:
31
27
  - chart/**
32
28
  - infra/
33
29
  - infra/**
30
+
31
+ protected:
32
+ - src
33
+ - src/main
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: haraka
3
- Version: 0.2.36
3
+ Version: 0.2.38
4
4
  Summary: Reusable post-generation helper for Cookiecutter micro-service templates
5
5
  Author-email: Will Burks <will@example.com>
6
6
  License: MIT
@@ -10,14 +10,14 @@ haraka/art/ascii/frame/width_utils.py,sha256=in4AV3gTBBXUX6N01j67Icu9vsHFomybBN8
10
10
  haraka/post_gen/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
11
11
  haraka/post_gen/runner.py,sha256=CgC3-mOA6dOovJBCLykrec_Segitbu0XesMH6jsl6lM,3271
12
12
  haraka/post_gen/config/__init__.py,sha256=-_XkJ_Dni28yJCMfIceQSiH1wa_hHsZMoBTyvR9Ikbc,62
13
- haraka/post_gen/config/config.py,sha256=IsIoz8Ul132coGuTrCMN34ktRK6QA2o_GLuguZSFfQQ,1382
13
+ haraka/post_gen/config/config.py,sha256=XexywLrjD2cR0K-9J8ObVCSchHnQuoQfW0-YIElG8ig,1652
14
14
  haraka/post_gen/resources/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
15
15
  haraka/post_gen/resources/assets.py,sha256=-oz3vlBaVOjeCOO2QHRvOmfyurR1KgihqXqbTtxDNG4,461
16
16
  haraka/post_gen/service/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
17
17
  haraka/post_gen/service/command.py,sha256=yvEzW9rMSXWeQ_2DXuQNtGH6sRuZnK6viMud-amFQXw,2348
18
18
  haraka/post_gen/service/fileOps/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
19
19
  haraka/post_gen/service/fileOps/files.py,sha256=Jm_0bhvVnNqSPGKQ2RnMpx8JLV74M-IXMmwly9fpmVw,3020
20
- haraka/post_gen/service/fileOps/purge.py,sha256=YhtIQYRVtoo65Wp1zPJGtolHub6BoukZlka1cDMaJVk,7253
20
+ haraka/post_gen/service/fileOps/purge.py,sha256=lZ7I98J0UTxU0VAM5pNLjImUluIyzhyLN0Skh4quQ0o,7562
21
21
  haraka/post_gen/service/gitOps/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
22
22
  haraka/post_gen/service/gitOps/gitops.py,sha256=clWny1m9qB4yr8asba8JwqBjewlMVsJUmIOCLtAL8RI,4052
23
23
  haraka/utils/__init__.py,sha256=3Cp4u0dyAGcmqes-tIr95KFsNsJx5Ji5Yzkto9546Hs,168
@@ -27,9 +27,9 @@ haraka/utils/logging/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hS
27
27
  haraka/utils/logging/log_util.py,sha256=UQq2E24q3brvXqcyGCjfSxxHH48JF_BMg54TKdl1SHk,1049
28
28
  haraka/utils/manifests/go-grpc-gateway-buf.yml,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
29
29
  haraka/utils/manifests/go-grpc-protoc.yml,sha256=OaQlfW_S_OguhW_UcpBVdqdEtUMlg-SrT4bqLhQrY7Y,936
30
- haraka/utils/manifests/java-springboot.yml,sha256=DTZoVrIDNVpq2AuuXjL2jAvPggeKWVuKJEKwFb90cz4,989
30
+ haraka/utils/manifests/java-springboot.yml,sha256=AF4ebSqKj2AG4dlTfgJJjzG7Nke4wknRshROHbSL_dc,961
31
31
  haraka/utils/manifests/python-fastapi.yml,sha256=nhO6S9j_r-S10nM8nuw7PtR247-ePhBXHvaXg74CjWw,922
32
- haraka-0.2.36.dist-info/METADATA,sha256=8HrIRSvD02n2Mj47vow3srS3Vie-FO5DD6VMU2mJhQc,579
33
- haraka-0.2.36.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
34
- haraka-0.2.36.dist-info/top_level.txt,sha256=1khpwypLKWoklVd_CgFiwAfcctVSXRoRPc3BI9lyIXo,7
35
- haraka-0.2.36.dist-info/RECORD,,
32
+ haraka-0.2.38.dist-info/METADATA,sha256=A5nj60d9nrUhfK061R74gQkTzh8M72qa5JWLEB2ijWM,579
33
+ haraka-0.2.38.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
34
+ haraka-0.2.38.dist-info/top_level.txt,sha256=1khpwypLKWoklVd_CgFiwAfcctVSXRoRPc3BI9lyIXo,7
35
+ haraka-0.2.38.dist-info/RECORD,,