Skip to content

Commit e4b787d

Browse files
Taniya Mathurgudivt
authored andcommitted
Add --clean-build option to delete all .checksum files
1 parent 6bde97e commit e4b787d

File tree

1 file changed

+45
-1
lines changed

1 file changed

+45
-1
lines changed

publish.py

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,45 @@ def __init__(self, verbose=False):
5959
self._is_lib_changed = False
6060
self.skip_validation = False
6161

62+
def clean_checksums(self):
63+
"""Delete all .checksum files in main, patterns, options, and lib directories"""
64+
self.console.print("[yellow]🧹 Cleaning all .checksum files...[/yellow]")
65+
66+
checksum_paths = [
67+
".checksum", # main
68+
"lib/.checksum", # lib
69+
]
70+
71+
# Add patterns checksum files
72+
patterns_dir = "patterns"
73+
if os.path.exists(patterns_dir):
74+
for item in os.listdir(patterns_dir):
75+
pattern_path = os.path.join(patterns_dir, item)
76+
if os.path.isdir(pattern_path):
77+
checksum_paths.append(f"{pattern_path}/.checksum")
78+
79+
# Add options checksum files
80+
options_dir = "options"
81+
if os.path.exists(options_dir):
82+
for item in os.listdir(options_dir):
83+
option_path = os.path.join(options_dir, item)
84+
if os.path.isdir(option_path):
85+
checksum_paths.append(f"{option_path}/.checksum")
86+
87+
deleted_count = 0
88+
for checksum_path in checksum_paths:
89+
if os.path.exists(checksum_path):
90+
os.remove(checksum_path)
91+
self.console.print(f"[green] ✓ Deleted {checksum_path}[/green]")
92+
deleted_count += 1
93+
94+
if deleted_count == 0:
95+
self.console.print("[dim] No .checksum files found to delete[/dim]")
96+
else:
97+
self.console.print(
98+
f"[green]✅ Deleted {deleted_count} .checksum files - full rebuild will be triggered[/green]"
99+
)
100+
62101
def log_verbose(self, message, style="dim"):
63102
"""Log verbose messages if verbose mode is enabled"""
64103
if self.verbose:
@@ -120,7 +159,7 @@ def print_usage(self):
120159
"""Print usage information with Rich formatting"""
121160
self.console.print("\n[bold cyan]Usage:[/bold cyan]")
122161
self.console.print(
123-
" python3 publish.py <cfn_bucket_basename> <cfn_prefix> <region> [public] [--max-workers N] [--verbose] [--no-validate]"
162+
" python3 publish.py <cfn_bucket_basename> <cfn_prefix> <region> [public] [--max-workers N] [--verbose] [--no-validate] [--clean-build]"
124163
)
125164

126165
self.console.print("\n[bold cyan]Parameters:[/bold cyan]")
@@ -144,6 +183,9 @@ def print_usage(self):
144183
self.console.print(
145184
" [yellow][--no-validate][/yellow]: Optional. Skip CloudFormation template validation"
146185
)
186+
self.console.print(
187+
" [yellow][--clean-build][/yellow]: Optional. Delete all .checksum files to force full rebuild"
188+
)
147189

148190
def check_parameters(self, args):
149191
"""Check and validate input parameters"""
@@ -206,6 +248,8 @@ def check_parameters(self, args):
206248
self.console.print(
207249
"[yellow]CloudFormation template validation will be skipped[/yellow]"
208250
)
251+
elif arg == "--clean-build":
252+
self.clean_checksums()
209253
else:
210254
self.console.print(
211255
f"[yellow]Warning: Unknown argument '{arg}' ignored[/yellow]"

0 commit comments

Comments
 (0)