| Server IP : 3.147.158.171 / Your IP : 216.73.216.229 Web Server : Apache/2.4.67 (Amazon Linux) OpenSSL/3.5.5 System : Linux ip-172-31-2-178.us-east-2.compute.internal 6.1.172-216.329.amzn2023.x86_64 #1 SMP PREEMPT_DYNAMIC Wed May 20 06:31:34 UTC 2026 x86_64 User : ec2-user ( 1000) PHP Version : 8.4.21 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /tsai/repo/builder/backend/scripts/ |
Upload File : |
#!/usr/bin/env python3
"""
Write Build Info
Generates build-info.json for Angular apps with git date metadata.
Used by the builder config for Angular app builds.
Usage:
python write_build_info.py <app_name> <chatbot_dir>
Example:
python write_build_info.py creator /path/to/john/chatbot
"""
import json
import os
import subprocess
import sys
def get_git_date(working_dir: str) -> str:
"""Get the date from the most recent git commit."""
try:
result = subprocess.run(
['git', 'log', '-1', '--format=%cd'],
cwd=working_dir,
capture_output=True,
text=True,
check=True
)
return result.stdout.strip()
except subprocess.CalledProcessError as e:
print(f"Warning: Could not get git date: {e}")
return "Unknown"
def write_build_info(app_name: str, chatbot_dir: str) -> None:
"""Write build-info.json for the specified app."""
# App display names
app_display_names = {
'creator': 'Chatbot 2.0 (Beta)',
'player': 'Chatbot Player',
'sas': 'Sales and Support'
}
display_name = app_display_names.get(app_name, app_name)
build_date = get_git_date(chatbot_dir)
file_path = os.path.join(chatbot_dir, 'projects', app_name, 'public', 'build-info.json')
build_info = {
"name": display_name,
"date": build_date
}
# Ensure directory exists
os.makedirs(os.path.dirname(file_path), exist_ok=True)
with open(file_path, 'w') as f:
json.dump(build_info, f, indent=2)
f.write('\n')
print(f"Build info written for {app_name}: {file_path}")
def main():
if len(sys.argv) < 3:
print("Usage: python write_build_info.py <app_name> <chatbot_dir>")
sys.exit(1)
app_name = sys.argv[1]
chatbot_dir = sys.argv[2]
if not os.path.exists(chatbot_dir):
print(f"Error: Directory not found: {chatbot_dir}")
sys.exit(1)
write_build_info(app_name, chatbot_dir)
if __name__ == "__main__":
main()