feat(scripts): add checksum generation script and locale template generator for asset management

This commit is contained in:
2026-01-03 16:07:40 -06:00
parent 54b81663bd
commit e88dad7a86
2 changed files with 60 additions and 0 deletions

20
scripts/gen_checksums.sh Executable file
View File

@@ -0,0 +1,20 @@
#!/bin/bash
# Generate SHA256 checksums for release assets
# Usage: ./scripts/gen_checksums.sh [directory]
TARGET_DIR=${1:-"./dist"}
if [ ! -d "$TARGET_DIR" ]; then
echo "Error: Directory $TARGET_DIR does not exist."
exit 1
fi
echo "Generating SHA256SUMS for assets in $TARGET_DIR..."
cd "$TARGET_DIR" || exit 1
# Exclude existing SHA256SUMS file if it exists
find . -maxdepth 1 -type f ! -name "SHA256SUMS" -exec sha256sum {} + > SHA256SUMS
echo "Done. SHA256SUMS created in $TARGET_DIR"
cat SHA256SUMS

View File

@@ -0,0 +1,40 @@
import json
import os
import sys
def clear_values(d):
"""Recursively replace all string values with empty strings in a dictionary."""
if isinstance(d, dict):
return {k: clear_values(v) for k, v in d.items()}
return ""
def main():
# Paths are relative to the workspace root where Taskfile is run
en_path = os.path.join("meshchatx", "src", "frontend", "locales", "en.json")
out_path = "locales.json"
if not os.path.exists(en_path):
print(f"Error: Source file not found at {en_path}")
sys.exit(1)
try:
with open(en_path, "r", encoding="utf-8") as f:
en_data = json.load(f)
template = clear_values(en_data)
with open(out_path, "w", encoding="utf-8") as f:
json.dump(template, f, indent=4, ensure_ascii=False)
print(
f"Successfully generated {out_path} with all keys from {en_path} (empty values)."
)
except Exception as e:
print(f"Error generating locale template: {e}")
sys.exit(1)
if __name__ == "__main__":
main()