74 lines
2.7 KiB
Python
74 lines
2.7 KiB
Python
import sys
|
|
import os
|
|
from services.gsheet_client import GSheetClient
|
|
from mappers.sheet_mapper import SheetMapper
|
|
from mappers.markdown_builder import MarkdownBuilder
|
|
from services.readme_editor import ReadmeEditor
|
|
from config.settings import settings
|
|
|
|
def main():
|
|
try:
|
|
print("🚀 Starting README Update Process...")
|
|
|
|
# 1. Fetch data from Google Sheets
|
|
client = GSheetClient()
|
|
raw_rows = client.fetch_data()
|
|
|
|
if not raw_rows:
|
|
print("⚠️ No data found in the spreadsheet or error occurred.")
|
|
return
|
|
|
|
# 2. Map raw rows to Core Models
|
|
report = SheetMapper.map_rows_to_report(raw_rows)
|
|
print(f"✅ Data fetched: {len(report.tasks)} tasks parsed.")
|
|
|
|
# 3. Prepare Dynamic Content
|
|
markdown_table = MarkdownBuilder.build_table(report)
|
|
progress_summary = MarkdownBuilder.build_team_progress(report)
|
|
|
|
# 4. First, update the local section files with the new dynamic data
|
|
print("🔧 Injecting data into local sections...")
|
|
editor = ReadmeEditor()
|
|
|
|
# Inject progress into 08_team_standards.md
|
|
editor.inject_content_between_markers(
|
|
"sections/08_team_standards.md",
|
|
progress_summary,
|
|
"<!-- START_PROGRESS -->",
|
|
"<!-- END_PROGRESS -->"
|
|
)
|
|
|
|
# Inject task table into 07_roadmap.md (or whichever section has the marker)
|
|
# Note: Your main README markers were originally in 07_roadmap or similar
|
|
editor.inject_content_between_markers(
|
|
"sections/07_roadmap.md",
|
|
markdown_table,
|
|
"<!-- START_UPDATES -->",
|
|
"<!-- END_UPDATES -->"
|
|
)
|
|
|
|
# 5. Aggregate all sections into one big README content
|
|
print("📚 Aggregating all sections from 00 to 10...")
|
|
all_sections_content = ""
|
|
section_files = sorted([f for f in os.listdir("sections") if f.endswith(".md")])
|
|
|
|
for filename in section_files:
|
|
file_path = os.path.join("sections", filename)
|
|
with open(file_path, "r", encoding="utf-8") as f:
|
|
all_sections_content += f.read() + "\n\n---\n\n"
|
|
|
|
# 6. Update the ROOT README.md (../README.md)
|
|
print(f"📄 Updating Root README.md at: {settings.README_PATH}")
|
|
root_editor = ReadmeEditor(file_path=settings.README_PATH)
|
|
if root_editor.update_whole_readme(all_sections_content):
|
|
print("🎉 Root README.md successfully updated from all sections!")
|
|
else:
|
|
print("❌ Failed to update Root README.md.")
|
|
|
|
except Exception as e:
|
|
print(f"💥 An unexpected error occurred: {e}")
|
|
sys.exit(1)
|
|
|
|
if __name__ == "__main__":
|
|
main()
|