From 85a3c245ee2a01eb7b5adda985905398af87eafe Mon Sep 17 00:00:00 2001 From: Eden Chou Date: Wed, 5 Nov 2025 16:29:23 -0500 Subject: [PATCH 1/4] adding relevant files for event, 404, api route updates and adding template files --- events-404-api-route-updates/README.md | 152 ++++++ events-404-api-route-updates/error.csv | 1 + events-404-api-route-updates/logs.csv | 11 + events-404-api-route-updates/logs.txt | 14 + events-404-api-route-updates/pr-links.txt | 5 + events-404-api-route-updates/repo-list.txt | 227 +++++++++ events-404-api-route-updates/update-repos.sh | 504 ++++++++++++++++++ template/README.md | 76 +++ template/error.csv | 0 template/logs.csv | 0 template/logs.txt | 0 template/pr-links.txt | 0 template/repo-list.txt | 1 + template/update-repos.sh | 505 +++++++++++++++++++ 14 files changed, 1496 insertions(+) create mode 100644 events-404-api-route-updates/README.md create mode 100644 events-404-api-route-updates/error.csv create mode 100644 events-404-api-route-updates/logs.csv create mode 100644 events-404-api-route-updates/logs.txt create mode 100644 events-404-api-route-updates/pr-links.txt create mode 100644 events-404-api-route-updates/repo-list.txt create mode 100644 events-404-api-route-updates/update-repos.sh create mode 100644 template/README.md create mode 100644 template/error.csv create mode 100644 template/logs.csv create mode 100644 template/logs.txt create mode 100644 template/pr-links.txt create mode 100644 template/repo-list.txt create mode 100644 template/update-repos.sh diff --git a/events-404-api-route-updates/README.md b/events-404-api-route-updates/README.md new file mode 100644 index 0000000..5ec40ea --- /dev/null +++ b/events-404-api-route-updates/README.md @@ -0,0 +1,152 @@ +## ๐Ÿงฉ Repository Batch Updater Script + +This script was written for batch updates across our member repos. In this instance, the intent was to update the NextJS version and to make the middleware asynchronous. + +### ๐Ÿš€ What It Does + +1. **Reads a list of repositories** + + - The script expects a `repo-list.txt` file containing one GitHub repository per line (`org-name/repo-name` format). + - Skips blank lines and comments (`#`). + +2. **Processes repositories in batches** + + - A batch size can be passed as an argument (default: `5` apps). + - Stops automatically when the batch limit is reached. + +3. **Clones and prepares each repo** + + - Clones each repository into `all-repos/` if itโ€™s not already there. + - Checks out the `main` or `master` branch and pulls the latest changes. + +4. **Validates TurboRepo structure** + + - Skips repositories that donโ€™t contain a `turbo.json` file or an `apps/` directory. (ie will skip repos like TruSpeed if they end up in the list by accident) + +5. **Iterates through all apps inside `apps/`** + For each app subdirectory, the script: + + - **Updates API route** + - Checks to see if `export * from \"@truvolv/orson-seelib/api/router\";` in `api/[...slug]/route.ts` exists within the file and if not, and replaces all content with + ``` + // exporting all route handlers from orson-seelib + // we can overwrite specific handlers here per member if needed + export * from "@truvolv/orson-seelib/api/router"; + ``` + - **Creates / Updates `not-found.tsx`** + + - Checks to see if `not-found.tsx` page exists, if not, creates one + - If it exists, it overwrites all file content with the new 404 page skeleton we are adding otherwise creates a new file with the code below. + + ``` + import { Metadata } from "next"; + import { generate404PageMeta } from "@truvolv/orson-seelib/lib/generate404PageMeta"; + import { NotFoundPage } from "@truvolv/orson-seelib/components/page"; + + export async function generateMetadata({ + params, + }: { + params: { slug: string | string[] }; + }): Promise { + try { + const result = generate404PageMeta({ params }); + return result; + } catch (error) { + console.error("Error generating metadata:", error); + throw error; + } + } + export default async function Page({ + params, + }: { + params?: { slug?: string | string[] }; + }) { + return ( + + ); + } + ``` + + - **Creates / Updates Events page** + + - Checks to see if `events/[...slug]/page.tsx` page exists, if not, creates one + - If it exists, it overwrites all file content with the new Events page content we are adding otherwise creates a new file with the code below. + + ``` + import { CoreEvent } from "@truvolv/orson-seelib/components/event"; + import { generateStaticEventParams } from "@truvolv/orson-seelib/lib/generateStaticEventParams"; + import { generateEventMeta } from "@truvolv/orson-seelib/lib/generateEventMeta"; + import { Metadata } from "next"; + + export async function generateMetadata({ + params, + }: { + params: { slug: string | string[] }; + }): Promise { + try { + const result = generateEventMeta({ params }); + return result; + } catch (error) { + console.error("Error generating metadata:", error); + throw error; + } + } + + export async function generateStaticParams() { + try { + const result = generateStaticEventParams(); + return result; + } catch (error) { + console.error("Error generating static event params:", error); + throw error; + } + } + + export default async function Event({ + params, + }: { + params: { slug: string | string[] }; + }) { + return ( + <> + + + ); + } + ``` + +6. **Tracks progress and logs results** + + - Logs per-app updates in `logs.csv` with details on status (`success`, `partial`, `no-changes`, etc.) + - Logs repo-level issues in `error.csv` (e.g., clone failures, missing directories). + +7. **Commits and pushes changes** + + - Commits updates with a descriptive message. + - (Optional) Creates a pull request via GitHub CLI โ€” this section is partially commented out for manual control. + +8. **Provides color-coded terminal output** + - Green for success, yellow for skips or partial updates, red for errors. + +### ๐Ÿ“ Output Files + +- **`logs.csv`** โ€” App-level results including repo name, app name, status, and notes. +- **`error.csv`** โ€” Repository-level issues or skips (e.g., missing branches, failed clones). +- **`all-repos/`** โ€” Local clones of all processed repositories. + +### ๐Ÿง  Example Workflow + +```bash +# Run script with default batch size of 5 +bash update-repos.sh + +# Run script to process 10 apps +bash update-repos.sh 10 +``` + +### โš™๏ธ Requirements + +- GitHub CLI (`gh`) authenticated with repo access +- Bash shell (macOS or Linux environment) +- Git installed +- Access to all repos listed in `repo-list.txt` diff --git a/events-404-api-route-updates/error.csv b/events-404-api-route-updates/error.csv new file mode 100644 index 0000000..0cd08ab --- /dev/null +++ b/events-404-api-route-updates/error.csv @@ -0,0 +1 @@ +Repo,Issue,Details diff --git a/events-404-api-route-updates/logs.csv b/events-404-api-route-updates/logs.csv new file mode 100644 index 0000000..65a4616 --- /dev/null +++ b/events-404-api-route-updates/logs.csv @@ -0,0 +1,11 @@ +Repo,App,Status,Notes,PR Link +"truvolv/demo","baths-lp","success","API route updated, 404 page and core events page created","https://github.com/truvolv/demo/pull/8" +"truvolv/demo","bryan-espey","success","API route updated, 404 page and core events page created","https://github.com/truvolv/demo/pull/8" +"truvolv/demo","carrie-testing","success","API route updated, 404 page and core events page created","https://github.com/truvolv/demo/pull/8" +"truvolv/demo","carrie-testing-2","success","API route updated, 404 page and core events page created","https://github.com/truvolv/demo/pull/8" +"truvolv/demo","carrie-testing-site","success","API route updated, 404 page and core events page created","https://github.com/truvolv/demo/pull/8" +"truvolv/demo","chace-test","success","API route updated, 404 page and core events page created","https://github.com/truvolv/demo/pull/8" +"truvolv/demo","cody-test","success","API route updated, 404 page and core events page created","https://github.com/truvolv/demo/pull/8" +"truvolv/demo","eden-testing","success","API route updated, 404 page and core events page created","https://github.com/truvolv/demo/pull/8" +"truvolv/demo","elliot-testing","success","API route updated, 404 page and core events page created","https://github.com/truvolv/demo/pull/8" +"truvolv/demo","fewa-test-demo-site","success","API route updated, 404 page and core events page created","https://github.com/truvolv/demo/pull/8" diff --git a/events-404-api-route-updates/logs.txt b/events-404-api-route-updates/logs.txt new file mode 100644 index 0000000..b817358 --- /dev/null +++ b/events-404-api-route-updates/logs.txt @@ -0,0 +1,14 @@ +Mass repo update started at Wed Nov 5 16:15:22 EST 2025 +================================================ +APP STATUS: truvolv/demo/baths-lp - success - API route updated, 404 page and core events page created +APP STATUS: truvolv/demo/bryan-espey - success - API route updated, 404 page and core events page created +APP STATUS: truvolv/demo/carrie-testing - success - API route updated, 404 page and core events page created +APP STATUS: truvolv/demo/carrie-testing-2 - success - API route updated, 404 page and core events page created +APP STATUS: truvolv/demo/carrie-testing-site - success - API route updated, 404 page and core events page created +APP STATUS: truvolv/demo/chace-test - success - API route updated, 404 page and core events page created +APP STATUS: truvolv/demo/cody-test - success - API route updated, 404 page and core events page created +APP STATUS: truvolv/demo/eden-testing - success - API route updated, 404 page and core events page created +APP STATUS: truvolv/demo/elliot-testing - success - API route updated, 404 page and core events page created +APP STATUS: truvolv/demo/fewa-test-demo-site - success - API route updated, 404 page and core events page created +================================================ +Mass repo update completed at Wed Nov 5 16:15:26 EST 2025 diff --git a/events-404-api-route-updates/pr-links.txt b/events-404-api-route-updates/pr-links.txt new file mode 100644 index 0000000..e6c5efb --- /dev/null +++ b/events-404-api-route-updates/pr-links.txt @@ -0,0 +1,5 @@ +PR Links from mass repo update started at Wed Nov 5 16:15:23 EST 2025 +================================================ +truvolv/demo: https://github.com/truvolv/demo/pull/8 +================================================ +Mass repo update completed at Wed Nov 5 16:15:26 EST 2025 diff --git a/events-404-api-route-updates/repo-list.txt b/events-404-api-route-updates/repo-list.txt new file mode 100644 index 0000000..fa391ec --- /dev/null +++ b/events-404-api-route-updates/repo-list.txt @@ -0,0 +1,227 @@ +truvolv/universal-windows-of-manchester +truvolv/cabinet-experts +truvolv/window-perfections +truvolv/refloor +truvolv/demo +truvolv/orson-template +truvolv/cyprus-air +truvolv/rosewood-home-remodeling +truvolv/paulson-monuments +truvolv/jim-woods-roofing +truvolv/jacuzzi +truvolv/love-your-bath +truvolv/the-board-store +truvolv/bath-experts +truvolv/continental-siding +truvolv/kitchen-restyled +truvolv/c3-construction +truvolv/gutter-cover-kc +truvolv/ljstone +truvolv/okeefe-and-flanagan-electric +truvolv/floorology +truvolv/denver-pergolas +truvolv/bytown-bath +truvolv/luxury-bath-njpa +truvolv/five-star-contracting +truvolv/kris-konstruction- +truvolv/uat +truvolv/cms +truvolv/global +truvolv/carole-frederick +truvolv/coastal-bath-co +truvolv/walshs-remodeling +truvolv/secure-cc +truvolv/pro-home-1 +truvolv/designed-hi +truvolv/mod-bath +truvolv/ez-pro-express +truvolv/american-home-design +truvolv/mkd-kitchen-and-bath +truvolv/floortek +truvolv/struxure-scottsdale +truvolv/altruistic-advisory +truvolv/bee-windows +truvolv/kubala-home-improvement +truvolv/bath-america +truvolv/cal-energy-consultant +truvolv/stressless-remodeling +truvolv/capital-construction +truvolv/sunbrella +truvolv/willis-roofing +truvolv/sharper-impressions-painting +truvolv/swis-pros +truvolv/scc-pros +truvolv/truvolv-corporate +truvolv/nailed-it-home-solutions +truvolv/bath-fitter-inland-nw +truvolv/bath-fitter-tucson +truvolv/americas-best-windows-and-doors +truvolv/a-plus-pro-services +truvolv/mcgill-plumbing +truvolv/blind-and-shutter-spot +truvolv/express-bath +truvolv/vista-homes-utah +truvolv/refined-spaces +truvolv/destination-motivation +truvolv/kingspan +truvolv/hydrotek-plumbing +truvolv/customfit-baths +truvolv/safe-harbor-exteriors +truvolv/surbers-usa +truvolv/brian-gottlieb +truvolv/sir-home +truvolv/always-green-turf +truvolv/kitchens-today +truvolv/twin-cities-jacuzzi +truvolv/style-craft-remodeling- +truvolv/bird-dog-construction +truvolv/cypress-bath +truvolv/premier-home-services +truvolv/install-services +truvolv/premier-services-nj +truvolv/v2-test-org-2-d08648caadccef +truvolv/long-home-products +truvolv/blue-ridge-bath +truvolv/sullivans-bath-and-window +truvolv/your-select-home +truvolv/spancraft +truvolv/theut-glass +truvolv/rgs-exteriors +truvolv/baths-for-the-brave +truvolv/dreamhome-remodeling-ct +truvolv/aspen-windows +truvolv/finish-line-strategies +truvolv/k-c +truvolv/everest-home-improvement +truvolv/white-cloud-cc +truvolv/hunterdon +truvolv/nulook-hd +truvolv/todco-roofing +truvolv/roofing-store +truvolv/armor-guard +truvolv/durante-he +truvolv/pinnacle-exteriors +truvolv/sweetwater-home-services +truvolv/rose-remodeling +truvolv/the-bath-boys +truvolv/contract-exteriors +truvolv/men-with-tools +truvolv/precision-roofing +truvolv/denver-glass-interiors +truvolv/burr-custom-exteriors +truvolv/legacy-cc +truvolv/trident-bath +truvolv/all-american-roofing +truvolv/alco-products +truvolv/b-w-glass +truvolv/my-shower-today +truvolv/360-windows-and-doors +truvolv/for-energy +truvolv/integrity-home-pro +truvolv/galla-rini-roofing +truvolv/bel-sd +truvolv/covered-exteriors +truvolv/integrity-construction-consulting +truvolv/mjf-home-upgrades +truvolv/mattsson-roofing +truvolv/nulook-home-design +truvolv/innovative-gutter-solutions +truvolv/ramco +truvolv/allmaster-home-services +truvolv/signature-home-services +truvolv/privacy-fence-company +truvolv/wealthy-contractor +truvolv/empire-home-remodeling +truvolv/ocala-baths-fl +truvolv/sea-glass-jax +truvolv/gutter-guards-direct +truvolv/ridgeline-floors +truvolv/lifetime-solutions +truvolv/quality-moving-services +truvolv/total-bath-systems +truvolv/comfort-kb +truvolv/k-h-painting-pros +truvolv/bam-showers +truvolv/weatherwize-lhp +truvolv/all-seasons-windows-and-doors +truvolv/solatube +truvolv/solar-shield-inc +truvolv/fba +truvolv/k-p-remodeling +truvolv/illumination-window-door +truvolv/frey +truvolv/pond-roofing +truvolv/coors-remodeling +truvolv/clear-choice-hi +truvolv/inside-out-roofing +truvolv/carolina-home-remodeling +truvolv/trim-a-seal +truvolv/k-h-home-solutions +truvolv/lyfe-ocs +truvolv/jjs-custom +truvolv/siding-and-windows-wizards +truvolv/innovative-exteriors +truvolv/home-pro-mi +truvolv/dgd +truvolv/bath-works-mi +truvolv/rjw-exteriors +truvolv/on-track-doors +truvolv/bathroom-pros-nj +truvolv/erdmann-outdoor-living +truvolv/lehigh-gap-exteriors +truvolv/207-roofers +truvolv/erdmann-exteriors +truvolv/ltg-coatings +truvolv/main-abc-jacuzzi +truvolv/florida-energy-water-air-pure +truvolv/yrp +truvolv/leap +truvolv/asp-windows +truvolv/hutchco-home-and-bath +truvolv/main-bath-remodel-by-c +truvolv/roof-360 +truvolv/black-rock-roofing +truvolv/direct-remodels +truvolv/hegg-windows-doors +truvolv/ohio-state-windows +truvolv/nessler-and-associates +truvolv/home-value-renovation +truvolv/cleanedge-cabinetry +truvolv/jbr-by-capital +truvolv/philadelphia-ge +truvolv/homefix +truvolv/dwight-and-sons +truvolv/five-star-homes +truvolv/struxure-northshore +truvolv/the-home-authority +truvolv/tailor-made-windows-inc +truvolv/jbr-greenville +truvolv/asp-superhome +truvolv/mode-renovation +truvolv/ohp +truvolv/rainsoft-great-lakes +truvolv/rainsoft-ne-iowa +truvolv/aspen-glass +truvolv/psnj-7857601d0eaae1 +truvolv/v2-test-org-b743ba6741b17b +truvolv/julia-b7a839fa971990 +truvolv/cms +truvolv/uat +truvolv/fewa-pure-6ed136f9e848a8 +truvolv/kilas-org-2-6004eb3858b080 +truvolv/kilas-org-906b102867efec +truvolv/carrie-test-org-2-f5c23993926852 +truvolv/carrie-test-org-709ed19a43da4b +truvolv/new-org-58379ecb43bc60 +truvolv/jacuzzibathremodel-cf-workers +truvolv/truvolv-marketing-cf-workers +truvolv/truvolv-embeds +truvolv/k-h-paining-pros +truvolv/your-home-select-043d850891b8dd +truvolv/pahlisch-select-2b3bf0d45e7a2f +truvolv/carrie-test +truvolv/proway-garage-doors +truvolv/site-scraper +truvolv/payload-tenancy +truvolv/turbo-template +truvolv/global \ No newline at end of file diff --git a/events-404-api-route-updates/update-repos.sh b/events-404-api-route-updates/update-repos.sh new file mode 100644 index 0000000..08cb77f --- /dev/null +++ b/events-404-api-route-updates/update-repos.sh @@ -0,0 +1,504 @@ +#!/bin/bash + +# Colors for output +RED='\033[0;31m' +GREEN='\033[0;32m' +YELLOW='\033[1;33m' +NC='\033[0m' # No Color + +SCRIPT_DIR="$(pwd)" +LOG_FILE="$SCRIPT_DIR/logs.csv" +ERROR_FILE="$SCRIPT_DIR/error.csv" +PR_LINKS_FILE="$SCRIPT_DIR/pr-links.txt" +LOG_TRACKING_FILE="$SCRIPT_DIR/logs.txt" + +BATCH_SIZE=${1:-5} +echo -e "${YELLOW}Batch size set to: $BATCH_SIZE apps${NC}" + +echo "Repo,App,Status,Notes,PR Link" > "$LOG_FILE" +echo "Repo,Issue,Details" > "$ERROR_FILE" +echo -e "${GREEN}Created new logs.csv and error.csv files${NC}" + +apps_fixed=0 + +# Start timestamp for logs tracking file, create if not exists +if [[ ! -f "$LOG_TRACKING_FILE" ]]; then + echo "Mass repo update started at $(date)" > "$LOG_TRACKING_FILE" + echo "================================================" >> "$LOG_TRACKING_FILE" +else + # If file exists, append to it with a new header + echo "" >> "$LOG_TRACKING_FILE" + echo "Mass repo update started at $(date)" >> "$LOG_TRACKING_FILE" + echo "================================================" >> "$LOG_TRACKING_FILE" +fi + +# Check if repo list file exists +REPO_LIST_FILE="repo-list.txt" +if [[ ! -f "$REPO_LIST_FILE" ]]; then + echo -e "${RED}Error: $REPO_LIST_FILE not found!${NC}" + echo "Please create a file called 'repo-list.txt' with one repository name per line." + echo "Example format:" + echo " my-org/repo1" + echo " my-org/repo2" + exit 1 +fi + +# Create all-repos directory if it doesn't exist +mkdir -p all-repos + +# Read repos from file +while IFS= read -r repo_name || [[ -n "$repo_name" ]]; do + # Skip empty lines and comments + [[ -z "$repo_name" || "$repo_name" =~ ^[[:space:]]*# ]] && continue + + echo -e "${YELLOW}Processing: $repo_name (Fixed: $apps_fixed/$BATCH_SIZE)${NC}" + + repo_dir="all-repos/$(basename "$repo_name")" + + # Step 2: Clone repo if not present + if [[ ! -d "$repo_dir" ]]; then + echo " Cloning $repo_name..." + if ! gh repo clone "$repo_name" "$repo_dir"; then + echo -e "${RED} Failed to clone $repo_name${NC}" + echo "\"$repo_name\",\"clone-failed\",\"Could not clone repository\"" >> "$ERROR_FILE" + continue + fi + fi + + # Step 3: CD into repo, checkout main, and pull + cd "$repo_dir" || { + echo -e "${RED} Failed to cd into $repo_dir${NC}" + echo "\"$repo_name\",\"access-failed\",\"Could not access repository directory\"" >> "$ERROR_FILE" + cd - > /dev/null + continue + } + + # Checkout main and pull + if ! git checkout main 2>/dev/null && ! git checkout master 2>/dev/null; then + echo -e "${RED} Failed to checkout main/master branch${NC}" + echo "\"$repo_name\",\"checkout-failed\",\"Could not checkout main or master branch\"" >> "$ERROR_FILE" + cd - > /dev/null + continue + fi + + if ! git pull; then + echo -e "${RED} Failed to pull latest changes${NC}" + echo "\"$repo_name\",\"pull-failed\",\"Could not pull latest changes\"" >> "$ERROR_FILE" + cd - > /dev/null + continue + fi + + # Check if turbo.json file exists + if [[ ! -f "turbo.json" ]]; then + echo -e "${YELLOW} Skipped - Not a turbo repo${NC}" + echo "\"$repo_name\",\"skipped\",\"Not a turbo repository (no turbo.json found)\"" >> "$ERROR_FILE" + cd - > /dev/null + continue + fi + + echo " Found turbo repo, processing apps..." + + # Step 4: Check if apps/ directory exists + if [[ ! -d "apps" ]]; then + echo -e "${YELLOW} Skipped - No apps/ directory${NC}" + echo "\"$repo_name\",\"skipped\",\"No apps/ directory found\"" >> "$ERROR_FILE" + cd - > /dev/null + continue + fi + + changes_made=false + pr_url="" + + # Step 4-7: Iterate over subdirectories in apps/ + for app_dir in apps/*; do + [[ ! -d "$app_dir" ]] && continue + + if [[ $apps_fixed -ge $BATCH_SIZE ]]; then + echo -e "${GREEN}Batch limit of $BATCH_SIZE apps reached. Stopping.${NC}" + break + fi + + + app_name=$(basename "$app_dir") + echo " Processing app: $app_name" + echo " App Directory: $app_dir" + + api_route_updated=false + page_404_updated=false + page_404_created=false + core_event_page_updated=false + core_event_page_created=false + + api_route_already_updated=false + page_404_already_updated=false + core_event_page_already_updated=false + + # Check if API route is already updated + if [[ -f "$app_dir/app/api/[...slug]/route.ts" ]]; then + if grep -q "export * from \"@truvolv/orson-seelib/api/router\";" "$app_dir/app/api/[...slug]/route.ts"; then + api_route_already_updated=true + fi + fi + + # Check if 404 page is already updated + if [[ -f "$app_dir/not-found.tsx" ]]; then + if grep -q "" "$app_dir/not-found.tsx"; then + page_404_already_updated=true + fi + fi + + # Check if Core Events page is already created/updated + if [[ -f "$app_dir/app/events/[...slug]/page.tsx" ]]; then + if grep -q "export default async function Event" "$app_dir/app/events/[...slug]/page.tsx"; then + core_event_page_already_updated=true + fi + fi + + if [[ "$api_route_already_updated" == true && "$page_404_already_updated" == true && "$core_event_page_already_updated" == true ]]; then + echo "\"$repo_name\",\"$app_name\",\"completed\",\"already updated (not counted toward batch)\",\"\"" >> "$LOG_FILE" + echo "App already has all three updates, skipping..." + continue + fi + + # Step 5: Update API route, the route should exist + if [[ -f "$app_dir/app/api/[...slug]/route.ts" ]]; then + echo "Updating API route in $app_name/app/api/[...slug]/route.ts" + # Replace all content with new API route content + + cat > "$app_dir/app/api/[...slug]/route.ts" << 'EOF' +// exporting all route handlers from orson-seelib +// we can overwrite specific handlers here per member if needed +export * from "@truvolv/orson-seelib/api/router"; +EOF + api_route_updated=true + changes_made=true + fi + + # Step 6: Update 404 page if it exists, else create it + if [[ -f "$app_dir/not-found.tsx" ]]; then + echo "Updating 404 page in $app_name/not-found.tsx" + # Replace all content with new 404 page content + + cat > "$app_dir/not-found.tsx" << 'EOF' +import { Metadata } from "next"; +import { generate404PageMeta } from "@truvolv/orson-seelib/lib/generate404PageMeta"; +import { NotFoundPage } from "@truvolv/orson-seelib/components/page"; + +export async function generateMetadata({ + params, +}: { + params: { slug: string | string[] }; +}): Promise { + try { + const result = generate404PageMeta({ params }); + return result; + } catch (error) { + console.error("Error generating metadata:", error); + throw error; + } +} +export default async function Page({ + params, +}: { + params?: { slug?: string | string[] }; +}) { + return ( + + ); +} +EOF + + page_404_updated=true + changes_made=true + else + echo "Creating 404 page file in $app_name/not-found.tsx" + cat > "$app_dir/not-found.tsx" << 'EOF' +import { Metadata } from "next"; +import { generate404PageMeta } from "@truvolv/orson-seelib/lib/generate404PageMeta"; +import { NotFoundPage } from "@truvolv/orson-seelib/components/page"; + +export async function generateMetadata({ +params, +}: { +params: { slug: string | string[] }; +}): Promise { +try { + const result = generate404PageMeta({ params }); + return result; +} catch (error) { + console.error("Error generating metadata:", error); + throw error; +} +} +export default async function Page({ +params, +}: { +params?: { slug?: string | string[] }; +}) { +return ( + +); +} +EOF + page_404_created=true + changes_made=true + fi + + # Step 7: Update Core Events page if it exists, else create it + if [[ -f "$app_dir/app/events/[...slug]/page.tsx" ]]; then + echo "Updating Core Events page in $app_name/app/events/[...slug]/page.tsx" + # Replace content with new Core Events page content + mkdir -p "$app_dir/app/events/[...slug]" + cat > "$app_dir/app/events/[...slug]/page.tsx" << 'EOF' +import { CoreEvent } from "@truvolv/orson-seelib/components/event"; +import { generateStaticEventParams } from "@truvolv/orson-seelib/lib/generateStaticEventParams"; +import { generateEventMeta } from "@truvolv/orson-seelib/lib/generateEventMeta"; +import { Metadata } from "next"; + +export async function generateMetadata({ +params, +}: { +params: { slug: string | string[] }; +}): Promise { +try { + const result = generateEventMeta({ params }); + return result; +} catch (error) { + console.error("Error generating metadata:", error); + throw error; +} +} + +export async function generateStaticParams() { +try { + const result = generateStaticEventParams(); + return result; +} catch (error) { + console.error("Error generating static event params:", error); + throw error; +} +} + +export default async function Event({ +params, +}: { +params: { slug: string | string[] }; +}) { +return ( + <> + + +); +} +EOF + + + core_event_page_updated=true + changes_made=true + else + echo "Creating Core Events page file in $app_name/events/[...slug]/page.tsx" + mkdir -p "$app_dir/events/[...slug]" + cat > "$app_dir/events/[...slug]/page.tsx" << 'EOF' +import { CoreEvent } from "@truvolv/orson-seelib/components/event"; +import { generateStaticEventParams } from "@truvolv/orson-seelib/lib/generateStaticEventParams"; +import { generateEventMeta } from "@truvolv/orson-seelib/lib/generateEventMeta"; +import { Metadata } from "next"; + +export async function generateMetadata({ +params, +}: { +params: { slug: string | string[] }; +}): Promise { +try { + const result = generateEventMeta({ params }); + return result; +} catch (error) { + console.error("Error generating metadata:", error); + throw error; +} +} + +export async function generateStaticParams() { +try { + const result = generateStaticEventParams(); + return result; +} catch (error) { + console.error("Error generating static event params:", error); + throw error; +} +} + +export default async function Event({ +params, +}: { +params: { slug: string | string[] }; +}) { +return ( + <> + + +); +} +EOF + core_event_page_created=true + changes_made=true + fi + + # Determine final status and notes based on the updates made + notes="" + if [[ "$api_route_updated" == true && "$page_404_updated" == true && "$core_event_page_updated" == true ]]; then + notes="API route, 404 page, and core events page updated" + status="success" + elif [[ "$api_route_updated" == true && "$page_404_created" == true && "$core_event_page_created" == true ]]; then + notes="API route updated, 404 page and core events page created" + status="success" + elif [[ "$api_route_updated" == true && "$page_404_updated" == true && "$core_event_page_created" == true ]]; then + notes="API route and 404 page updated, core events page created" + status="success" + elif [[ "$api_route_updated" == true && "$page_404_created" == true && "$core_event_page_updated" == true ]]; then + notes="API route updated, 404 page created, core events page updated" + status="success" + else + # Partial updates - build detailed notes + status="partial" + notes="Updates:" + if [[ "$api_route_updated" == true ]]; then + notes="$notes API route updated," + else + notes="$notes API route not updated," + fi + if [[ "$page_404_updated" == true ]]; then + notes="$notes 404 page updated," + elif [[ "$page_404_created" == true ]]; then + notes="$notes 404 page created," + else + notes="$notes 404 page not updated," + fi + if [[ "$core_event_page_updated" == true ]]; then + notes="$notes core events page updated," + elif [[ "$core_event_page_created" == true ]]; then + notes="$notes core events page created," + else + notes="$notes core events page not updated," + fi + notes="${notes%,}" # Remove trailing comma + fi + + echo "\"$repo_name\",\"$app_name\",\"$status\",\"$notes\",\"\"" >> "$LOG_FILE" + + # Count toward batch only if all three components were successfully processed + if [[ "$api_route_updated" == true && ("$page_404_updated" == true || "$page_404_created" == true) && ("$core_event_page_updated" == true || "$core_event_page_created" == true) ]]; then + ((apps_fixed++)) + echo "APP STATUS: $repo_name/$app_name - $status - $notes" >> "$LOG_TRACKING_FILE" + echo "App fixed! Total fixed: $apps_fixed" + fi + done + + # Start timestamp for PR links file, create if not exists + if [[ ! -f "$PR_LINKS_FILE" ]]; then + echo "PR Links from mass repo update started at $(date)" > "$PR_LINKS_FILE" + echo "================================================" >> "$PR_LINKS_FILE" + else + # If file exists, append to it with a new header + echo "" >> "$PR_LINKS_FILE" + echo "PR Links from mass repo update started at $(date)" >> "$PR_LINKS_FILE" + echo "================================================" >> "$PR_LINKS_FILE" + fi + + # Step 8-9: Create branch, commit, push, and create PR if changes were made + if [[ "$changes_made" == true ]]; then + # Comment out lines 422 - 438 once tested and ready to push to main + branch_name="chore/TRUSPD-587/update-api-route-404-component-core-events-page" + + echo " Cleaning up git references..." + git fetch --prune origin 2>/dev/null || true + + echo " Creating branch: $branch_name" + if ! git checkout -b "$branch_name" 2>/dev/null; then + echo -e "${YELLOW} Branch creation failed (likely already exists), discarding local changes${NC}" + echo "\"$repo_name\",\"branch-exists\",\"Branch creation failed, likely already exists - local changes discarded\"" >> "$ERROR_FILE" + + # Reset any local changes + git reset --hard HEAD + git clean -fd + + cd - > /dev/null + continue + fi + + echo " Committing changes..." + git add . + if ! git commit -m "Update API route to include all handlers from orson-seelib, update or create 404 page skeleton, and update or create core events page"; then + echo -e "${RED} Failed to commit changes${NC}" + echo "\"$repo_name\",\"commit-failed\",\"Could not commit changes\"" >> "$ERROR_FILE" + cd - > /dev/null + continue + fi + + echo " Pushing branch..." + # Comment out line 451 and uncomment next line once tested to push without PR creation + if ! git push origin "$branch_name"; then + # if ! git push; then + + echo -e "${RED} Failed to push branch${NC}" + echo "\"$repo_name\",\"push-failed\",\"Could not push branch $branch_name\"" >> "$ERROR_FILE" + cd - > /dev/null + continue + fi + + # Comment out lines 461 - 493 once tested and ready to push straight to main + echo " Creating PR..." + pr_url=$(gh pr create \ + --title "Update API route, 404 page, and core events page" \ + --body "This PR updates: + + - API route to include all handlers from orson-seelib + - 404 page skeleton to use NotFoundPage component from orson-seelib + - Events page to display separate events page using CoreEvent component from orson-seelib + + This is an automated update across multiple repositories." \ + --head "$branch_name" 2>&1) + + if [[ $? -eq 0 ]]; then + echo -e "${GREEN} โœ“ PR created successfully${NC}" + + # Add to PR links file + echo "$repo_name: $pr_url" >> "$PR_LINKS_FILE" + + # Update the CSV with PR URL for successful app updates + temp_file=$(mktemp) + while IFS= read -r line; do + if [[ "$line" == *"\"$repo_name\","*"\",\"success\","* ]]; then + # Replace the empty PR link with the actual URL + echo "${line%,\"\"*},\"$pr_url\"" >> "$temp_file" + else + echo "$line" >> "$temp_file" + fi + done < "$LOG_FILE" + mv "$temp_file" "$LOG_FILE" + else + echo -e "${RED} Failed to create PR${NC}" + echo "\"$repo_name\",\"pr-failed\",\"Could not create pull request\"" >> "$ERROR_FILE" + fi + else + echo -e "${YELLOW} No changes needed${NC}" + echo "\"$repo_name\",\"no-changes\",\"Repository processed but no changes were needed\"" >> "$ERROR_FILE" + fi + + cd - > /dev/null + echo "" + +done < "$REPO_LIST_FILE" + +# End timestamp for PR links file +echo "================================================" >> "$PR_LINKS_FILE" +echo "Mass repo update completed at $(date)" >> "$PR_LINKS_FILE" + +# End timestamp for logs tracking file +echo "================================================" >> "$LOG_TRACKING_FILE" +echo "Mass repo update completed at $(date)" >> "$LOG_TRACKING_FILE" + +echo -e "${GREEN}Batch processing completed! Fixed $apps_fixed apps out of target $BATCH_SIZE.${NC}" +echo -e "${GREEN}Check logs.csv for app-level status and error.csv for repo-level issues.${NC}" +echo -e "${GREEN}PR links saved to: $PR_LINKS_FILE${NC}" +echo -e "${GREEN}Detailed logs saved to: $LOG_TRACKING_FILE${NC}" \ No newline at end of file diff --git a/template/README.md b/template/README.md new file mode 100644 index 0000000..8d3042a --- /dev/null +++ b/template/README.md @@ -0,0 +1,76 @@ +## ๐Ÿงฉ Repository Batch Updater Script Template + +This script was written for batch updates across our member repos. [โ€ผ๏ธTODO: Add description of updates here] + +### ๐Ÿš€ What It Does + +1. **Reads a list of repositories** + + - The script expects a `repo-list.txt` file containing one GitHub repository per line (`org-name/repo-name` format). + - Skips blank lines and comments (`#`). + +2. **Processes repositories in batches** + + - A batch size can be passed as an argument (default: `5` apps). + - Stops automatically when the batch limit is reached. + +3. **Clones and prepares each repo** + + - Clones each repository into `all-repos/` if itโ€™s not already there. + - Checks out the `main` or `master` branch and pulls the latest changes. + +4. **Validates TurboRepo structure** + + - Skips repositories that donโ€™t contain a `turbo.json` file or an `apps/` directory. (ie will skip repos like TruSpeed if they end up in the list by accident) + +5. **Iterates through all apps inside `apps/`** + For each app subdirectory, the script: + + - โ€ผ๏ธTODO: Add description of script here + +6. **Tracks progress and logs results** + + - Logs per-app updates in `logs.csv` with details on status (`success`, `partial`, `no-changes`, etc.) + - Logs repo-level issues in `error.csv` (e.g., clone failures, missing directories). + +7. **Commits and pushes changes** + + - Commits updates with a descriptive message. + - (Optional) Creates a pull request via GitHub CLI โ€” this section is partially commented out for manual control. + +8. **Provides color-coded terminal output** + - Green for success, yellow for skips or partial updates, red for errors. + +### ๐Ÿ“ Output Files + +- **`logs.csv`** โ€” App-level results including repo name, app name, status, and notes. +- **`error.csv`** โ€” Repository-level issues or skips (e.g., missing branches, failed clones). +- **`all-repos/`** โ€” Local clones of all processed repositories. + +### ๐Ÿง  Example Workflow + +```bash +# Run script with default batch size of 5 +bash update-repos.sh + +# Run script to process 10 apps +bash update-repos.sh 10 +``` + +### โš™๏ธ Requirements + +- GitHub CLI (`gh`) authenticated with repo access +- Bash shell (macOS or Linux environment) +- Git installed +- Access to all repos listed in `repo-list.txt` + +### ๐Ÿš€ Helpful Queries + +**Get all current repos** + +- Run `gh auth login` to log into Github CLI +- Select `Github.com` +- Select `HTTPS` to login using Github UI +- Follow steps to login and authorize Github access +- Once authorized, run `gh repo list truvolv --limit 1000 --json nameWithOwner --jq '.[].nameWithOwner'` +- That should return all current repos in the org, be sure to omit non-member repos diff --git a/template/error.csv b/template/error.csv new file mode 100644 index 0000000..e69de29 diff --git a/template/logs.csv b/template/logs.csv new file mode 100644 index 0000000..e69de29 diff --git a/template/logs.txt b/template/logs.txt new file mode 100644 index 0000000..e69de29 diff --git a/template/pr-links.txt b/template/pr-links.txt new file mode 100644 index 0000000..e69de29 diff --git a/template/repo-list.txt b/template/repo-list.txt new file mode 100644 index 0000000..9f847f3 --- /dev/null +++ b/template/repo-list.txt @@ -0,0 +1 @@ +โ€ผ๏ธTODO: Add repos here, follow steps in `README.md` to get all current sites. Be sure to omit non-member sites. \ No newline at end of file diff --git a/template/update-repos.sh b/template/update-repos.sh new file mode 100644 index 0000000..8baa450 --- /dev/null +++ b/template/update-repos.sh @@ -0,0 +1,505 @@ +#!/bin/bash + +# Colors for output +RED='\033[0;31m' +GREEN='\033[0;32m' +YELLOW='\033[1;33m' +NC='\033[0m' # No Color + +SCRIPT_DIR="$(pwd)" +LOG_FILE="$SCRIPT_DIR/logs.csv" +ERROR_FILE="$SCRIPT_DIR/error.csv" +PR_LINKS_FILE="$SCRIPT_DIR/pr-links.txt" +LOG_TRACKING_FILE="$SCRIPT_DIR/logs.txt" + +BATCH_SIZE=${1:-5} +echo -e "${YELLOW}Batch size set to: $BATCH_SIZE apps${NC}" + +echo "Repo,App,Status,Notes,PR Link" > "$LOG_FILE" +echo "Repo,Issue,Details" > "$ERROR_FILE" +echo -e "${GREEN}Created new logs.csv and error.csv files${NC}" + +apps_fixed=0 + +# Start timestamp for logs tracking file, create if not exists +if [[ ! -f "$LOG_TRACKING_FILE" ]]; then + echo "Mass repo update started at $(date)" > "$LOG_TRACKING_FILE" + echo "================================================" >> "$LOG_TRACKING_FILE" +else + # If file exists, append to it with a new header + echo "" >> "$LOG_TRACKING_FILE" + echo "Mass repo update started at $(date)" >> "$LOG_TRACKING_FILE" + echo "================================================" >> "$LOG_TRACKING_FILE" +fi + +# Check if repo list file exists +REPO_LIST_FILE="repo-list.txt" +if [[ ! -f "$REPO_LIST_FILE" ]]; then + echo -e "${RED}Error: $REPO_LIST_FILE not found!${NC}" + echo "Please create a file called 'repo-list.txt' with one repository name per line." + echo "Example format:" + echo " my-org/repo1" + echo " my-org/repo2" + exit 1 +fi + +# Create all-repos directory if it doesn't exist +mkdir -p all-repos + +# Read repos from file +while IFS= read -r repo_name || [[ -n "$repo_name" ]]; do + # Skip empty lines and comments + [[ -z "$repo_name" || "$repo_name" =~ ^[[:space:]]*# ]] && continue + + echo -e "${YELLOW}Processing: $repo_name (Fixed: $apps_fixed/$BATCH_SIZE)${NC}" + + repo_dir="all-repos/$(basename "$repo_name")" + + # Step 2: Clone repo if not present + if [[ ! -d "$repo_dir" ]]; then + echo " Cloning $repo_name..." + if ! gh repo clone "$repo_name" "$repo_dir"; then + echo -e "${RED} Failed to clone $repo_name${NC}" + echo "\"$repo_name\",\"clone-failed\",\"Could not clone repository\"" >> "$ERROR_FILE" + continue + fi + fi + + # Step 3: CD into repo, checkout main, and pull + cd "$repo_dir" || { + echo -e "${RED} Failed to cd into $repo_dir${NC}" + echo "\"$repo_name\",\"access-failed\",\"Could not access repository directory\"" >> "$ERROR_FILE" + cd - > /dev/null + continue + } + + # Checkout main and pull + if ! git checkout main 2>/dev/null && ! git checkout master 2>/dev/null; then + echo -e "${RED} Failed to checkout main/master branch${NC}" + echo "\"$repo_name\",\"checkout-failed\",\"Could not checkout main or master branch\"" >> "$ERROR_FILE" + cd - > /dev/null + continue + fi + + if ! git pull; then + echo -e "${RED} Failed to pull latest changes${NC}" + echo "\"$repo_name\",\"pull-failed\",\"Could not pull latest changes\"" >> "$ERROR_FILE" + cd - > /dev/null + continue + fi + + # Check if turbo.json file exists + if [[ ! -f "turbo.json" ]]; then + echo -e "${YELLOW} Skipped - Not a turbo repo${NC}" + echo "\"$repo_name\",\"skipped\",\"Not a turbo repository (no turbo.json found)\"" >> "$ERROR_FILE" + cd - > /dev/null + continue + fi + + echo " Found turbo repo, processing apps..." + + # Step 4: Check if apps/ directory exists + if [[ ! -d "apps" ]]; then + echo -e "${YELLOW} Skipped - No apps/ directory${NC}" + echo "\"$repo_name\",\"skipped\",\"No apps/ directory found\"" >> "$ERROR_FILE" + cd - > /dev/null + continue + fi + + changes_made=false + pr_url="" + + # Step 4-7: Iterate over subdirectories in apps/ + for app_dir in apps/*; do + [[ ! -d "$app_dir" ]] && continue + + if [[ $apps_fixed -ge $BATCH_SIZE ]]; then + echo -e "${GREEN}Batch limit of $BATCH_SIZE apps reached. Stopping.${NC}" + break + fi + + + app_name=$(basename "$app_dir") + echo " Processing app: $app_name" + echo " App Directory: $app_dir" + + api_route_updated=false + page_404_updated=false + page_404_created=false + core_event_page_updated=false + core_event_page_created=false + + api_route_already_updated=false + page_404_already_updated=false + core_event_page_already_updated=false + + # Check if API route is already updated + if [[ -f "$app_dir/app/api/[...slug]/route.ts" ]]; then + if grep -q "export * from \"@truvolv/orson-seelib/api/router\";" "$app_dir/app/api/[...slug]/route.ts"; then + api_route_already_updated=true + fi + fi + + # Check if 404 page is already updated + if [[ -f "$app_dir/not-found.tsx" ]]; then + if grep -q "" "$app_dir/not-found.tsx"; then + page_404_already_updated=true + fi + fi + + # Check if Core Events page is already created/updated + if [[ -f "$app_dir/app/events/[...slug]/page.tsx" ]]; then + if grep -q "export default async function Event" "$app_dir/app/events/[...slug]/page.tsx"; then + core_event_page_already_updated=true + fi + fi + + if [[ "$api_route_already_updated" == true && "$page_404_already_updated" == true && "$core_event_page_already_updated" == true ]]; then + echo "\"$repo_name\",\"$app_name\",\"completed\",\"already updated (not counted toward batch)\",\"\"" >> "$LOG_FILE" + echo "App already has all three updates, skipping..." + continue + fi + + # Step 5: Update API route, the route should exist + if [[ -f "$app_dir/app/api/[...slug]/route.ts" ]]; then + echo "Updating API route in $app_name/app/api/[...slug]/route.ts" + # Replace all content with new API route content + + cat > "$app_dir/app/api/[...slug]/route.ts" << 'EOF' +// exporting all route handlers from orson-seelib +// we can overwrite specific handlers here per member if needed +export * from "@truvolv/orson-seelib/api/router"; +EOF + api_route_updated=true + changes_made=true + fi + + # Step 6: Update 404 page if it exists, else create it + if [[ -f "$app_dir/not-found.tsx" ]]; then + echo "Updating 404 page in $app_name/not-found.tsx" + # Replace all content with new 404 page content + + cat > "$app_dir/not-found.tsx" << 'EOF' +import { Metadata } from "next"; +import { generate404PageMeta } from "@truvolv/orson-seelib/lib/generate404PageMeta"; +import { NotFoundPage } from "@truvolv/orson-seelib/components/page"; + +export async function generateMetadata({ + params, +}: { + params: { slug: string | string[] }; +}): Promise { + try { + const result = generate404PageMeta({ params }); + return result; + } catch (error) { + console.error("Error generating metadata:", error); + throw error; + } +} +export default async function Page({ + params, +}: { + params?: { slug?: string | string[] }; +}) { + return ( + + ); +} +EOF + + page_404_updated=true + changes_made=true + else + echo "Creating 404 page file in $app_name/not-found.tsx" + cat > "$app_dir/not-found.tsx" << 'EOF' +import { Metadata } from "next"; +import { generate404PageMeta } from "@truvolv/orson-seelib/lib/generate404PageMeta"; +import { NotFoundPage } from "@truvolv/orson-seelib/components/page"; + +export async function generateMetadata({ +params, +}: { +params: { slug: string | string[] }; +}): Promise { +try { + const result = generate404PageMeta({ params }); + return result; +} catch (error) { + console.error("Error generating metadata:", error); + throw error; +} +} +export default async function Page({ +params, +}: { +params?: { slug?: string | string[] }; +}) { +return ( + +); +} +EOF + page_404_created=true + changes_made=true + fi + + # Step 7: Update Core Events page if it exists, else create it + if [[ -f "$app_dir/app/events/[...slug]/page.tsx" ]]; then + echo "Updating Core Events page in $app_name/app/events/[...slug]/page.tsx" + # Replace content with new Core Events page content + mkdir -p "$app_dir/app/events/[...slug]" + cat > "$app_dir/app/events/[...slug]/page.tsx" << 'EOF' +import { CoreEvent } from "@truvolv/orson-seelib/components/event"; +import { generateStaticEventParams } from "@truvolv/orson-seelib/lib/generateStaticEventParams"; +import { generateEventMeta } from "@truvolv/orson-seelib/lib/generateEventMeta"; +import { Metadata } from "next"; + +export async function generateMetadata({ +params, +}: { +params: { slug: string | string[] }; +}): Promise { +try { + const result = generateEventMeta({ params }); + return result; +} catch (error) { + console.error("Error generating metadata:", error); + throw error; +} +} + +export async function generateStaticParams() { +try { + const result = generateStaticEventParams(); + return result; +} catch (error) { + console.error("Error generating static event params:", error); + throw error; +} +} + +export default async function Event({ +params, +}: { +params: { slug: string | string[] }; +}) { +return ( + <> + + +); +} +EOF + + + core_event_page_updated=true + changes_made=true + else + echo "Creating Core Events page file in $app_name/events/[...slug]/page.tsx" + mkdir -p "$app_dir/events/[...slug]" + cat > "$app_dir/events/[...slug]/page.tsx" << 'EOF' +import { CoreEvent } from "@truvolv/orson-seelib/components/event"; +import { generateStaticEventParams } from "@truvolv/orson-seelib/lib/generateStaticEventParams"; +import { generateEventMeta } from "@truvolv/orson-seelib/lib/generateEventMeta"; +import { Metadata } from "next"; + +export async function generateMetadata({ +params, +}: { +params: { slug: string | string[] }; +}): Promise { +try { + const result = generateEventMeta({ params }); + return result; +} catch (error) { + console.error("Error generating metadata:", error); + throw error; +} +} + +export async function generateStaticParams() { +try { + const result = generateStaticEventParams(); + return result; +} catch (error) { + console.error("Error generating static event params:", error); + throw error; +} +} + +export default async function Event({ +params, +}: { +params: { slug: string | string[] }; +}) { +return ( + <> + + +); +} +EOF + core_event_page_created=true + changes_made=true + fi + + # Determine final status and notes based on the updates made + notes="" + if [[ "$api_route_updated" == true && "$page_404_updated" == true && "$core_event_page_updated" == true ]]; then + notes="API route, 404 page, and core events page updated" + status="success" + elif [[ "$api_route_updated" == true && "$page_404_created" == true && "$core_event_page_created" == true ]]; then + notes="API route updated, 404 page and core events page created" + status="success" + elif [[ "$api_route_updated" == true && "$page_404_updated" == true && "$core_event_page_created" == true ]]; then + notes="API route and 404 page updated, core events page created" + status="success" + elif [[ "$api_route_updated" == true && "$page_404_created" == true && "$core_event_page_updated" == true ]]; then + notes="API route updated, 404 page created, core events page updated" + status="success" + else + # Partial updates - build detailed notes + status="partial" + notes="Updates:" + if [[ "$api_route_updated" == true ]]; then + notes="$notes API route updated," + else + notes="$notes API route not updated," + fi + if [[ "$page_404_updated" == true ]]; then + notes="$notes 404 page updated," + elif [[ "$page_404_created" == true ]]; then + notes="$notes 404 page created," + else + notes="$notes 404 page not updated," + fi + if [[ "$core_event_page_updated" == true ]]; then + notes="$notes core events page updated," + elif [[ "$core_event_page_created" == true ]]; then + notes="$notes core events page created," + else + notes="$notes core events page not updated," + fi + notes="${notes%,}" # Remove trailing comma + fi + + echo "\"$repo_name\",\"$app_name\",\"$status\",\"$notes\",\"\"" >> "$LOG_FILE" + + # Count toward batch only if all three components were successfully processed + if [[ "$api_route_updated" == true && ("$page_404_updated" == true || "$page_404_created" == true) && ("$core_event_page_updated" == true || "$core_event_page_created" == true) ]]; then + ((apps_fixed++)) + echo "APP STATUS: $repo_name/$app_name - $status - $notes" >> "$LOG_TRACKING_FILE" + echo "App fixed! Total fixed: $apps_fixed" + fi + done + + # Start timestamp for PR links file, create if not exists + if [[ ! -f "$PR_LINKS_FILE" ]]; then + echo "PR Links from mass repo update started at $(date)" > "$PR_LINKS_FILE" + echo "================================================" >> "$PR_LINKS_FILE" + else + # If file exists, append to it with a new header + echo "" >> "$PR_LINKS_FILE" + echo "PR Links from mass repo update started at $(date)" >> "$PR_LINKS_FILE" + echo "================================================" >> "$PR_LINKS_FILE" + fi + + # Step 8-9: Create branch, commit, push, and create PR if changes were made + if [[ "$changes_made" == true ]]; then + # Comment out lines 422 - 438 once tested and ready to push to main + # Branch name will need to be unique every time you push, so update accordingly + branch_name="chore/TRUSPD-XXX/xxx" + + echo " Cleaning up git references..." + git fetch --prune origin 2>/dev/null || true + + echo " Creating branch: $branch_name" + if ! git checkout -b "$branch_name" 2>/dev/null; then + echo -e "${YELLOW} Branch creation failed (likely already exists), discarding local changes${NC}" + echo "\"$repo_name\",\"branch-exists\",\"Branch creation failed, likely already exists - local changes discarded\"" >> "$ERROR_FILE" + + # Reset any local changes + git reset --hard HEAD + git clean -fd + + cd - > /dev/null + continue + fi + + echo " Committing changes..." + git add . + if ! git commit -m "Update API route to include all handlers from orson-seelib, update or create 404 page skeleton, and update or create core events page"; then + echo -e "${RED} Failed to commit changes${NC}" + echo "\"$repo_name\",\"commit-failed\",\"Could not commit changes\"" >> "$ERROR_FILE" + cd - > /dev/null + continue + fi + + echo " Pushing branch..." + # Comment out line 451 and uncomment next line once tested to push without PR creation + if ! git push origin "$branch_name"; then + # if ! git push; then + + echo -e "${RED} Failed to push branch${NC}" + echo "\"$repo_name\",\"push-failed\",\"Could not push branch $branch_name\"" >> "$ERROR_FILE" + cd - > /dev/null + continue + fi + + # Comment out lines 461 - 493 once tested and ready to push straight to main + echo " Creating PR..." + pr_url=$(gh pr create \ + --title "Update API route, 404 page, and core events page" \ + --body "This PR updates: + + - API route to include all handlers from orson-seelib + - 404 page skeleton to use NotFoundPage component from orson-seelib + - Events page to display separate events page using CoreEvent component from orson-seelib + + This is an automated update across multiple repositories." \ + --head "$branch_name" 2>&1) + + if [[ $? -eq 0 ]]; then + echo -e "${GREEN} โœ“ PR created successfully${NC}" + + # Add to PR links file + echo "$repo_name: $pr_url" >> "$PR_LINKS_FILE" + + # Update the CSV with PR URL for successful app updates + temp_file=$(mktemp) + while IFS= read -r line; do + if [[ "$line" == *"\"$repo_name\","*"\",\"success\","* ]]; then + # Replace the empty PR link with the actual URL + echo "${line%,\"\"*},\"$pr_url\"" >> "$temp_file" + else + echo "$line" >> "$temp_file" + fi + done < "$LOG_FILE" + mv "$temp_file" "$LOG_FILE" + else + echo -e "${RED} Failed to create PR${NC}" + echo "\"$repo_name\",\"pr-failed\",\"Could not create pull request\"" >> "$ERROR_FILE" + fi + else + echo -e "${YELLOW} No changes needed${NC}" + echo "\"$repo_name\",\"no-changes\",\"Repository processed but no changes were needed\"" >> "$ERROR_FILE" + fi + + cd - > /dev/null + echo "" + +done < "$REPO_LIST_FILE" + +# End timestamp for PR links file +echo "================================================" >> "$PR_LINKS_FILE" +echo "Mass repo update completed at $(date)" >> "$PR_LINKS_FILE" + +# End timestamp for logs tracking file +echo "================================================" >> "$LOG_TRACKING_FILE" +echo "Mass repo update completed at $(date)" >> "$LOG_TRACKING_FILE" + +echo -e "${GREEN}Batch processing completed! Fixed $apps_fixed apps out of target $BATCH_SIZE.${NC}" +echo -e "${GREEN}Check logs.csv for app-level status and error.csv for repo-level issues.${NC}" +echo -e "${GREEN}PR links saved to: $PR_LINKS_FILE${NC}" +echo -e "${GREEN}Detailed logs saved to: $LOG_TRACKING_FILE${NC}" \ No newline at end of file From 139d46f369d3600619787d1e0a875cce3c4c68f9 Mon Sep 17 00:00:00 2001 From: Eden Chou Date: Wed, 5 Nov 2025 16:43:26 -0500 Subject: [PATCH 2/4] fixing app check in script --- events-404-api-route-updates/logs.csv | 20 ++++++++++---------- events-404-api-route-updates/logs.txt | 5 +++-- events-404-api-route-updates/pr-links.txt | 7 ++++--- events-404-api-route-updates/update-repos.sh | 13 +++++++++---- template/update-repos.sh | 5 +++++ 5 files changed, 31 insertions(+), 19 deletions(-) diff --git a/events-404-api-route-updates/logs.csv b/events-404-api-route-updates/logs.csv index 65a4616..0fd852f 100644 --- a/events-404-api-route-updates/logs.csv +++ b/events-404-api-route-updates/logs.csv @@ -1,11 +1,11 @@ Repo,App,Status,Notes,PR Link -"truvolv/demo","baths-lp","success","API route updated, 404 page and core events page created","https://github.com/truvolv/demo/pull/8" -"truvolv/demo","bryan-espey","success","API route updated, 404 page and core events page created","https://github.com/truvolv/demo/pull/8" -"truvolv/demo","carrie-testing","success","API route updated, 404 page and core events page created","https://github.com/truvolv/demo/pull/8" -"truvolv/demo","carrie-testing-2","success","API route updated, 404 page and core events page created","https://github.com/truvolv/demo/pull/8" -"truvolv/demo","carrie-testing-site","success","API route updated, 404 page and core events page created","https://github.com/truvolv/demo/pull/8" -"truvolv/demo","chace-test","success","API route updated, 404 page and core events page created","https://github.com/truvolv/demo/pull/8" -"truvolv/demo","cody-test","success","API route updated, 404 page and core events page created","https://github.com/truvolv/demo/pull/8" -"truvolv/demo","eden-testing","success","API route updated, 404 page and core events page created","https://github.com/truvolv/demo/pull/8" -"truvolv/demo","elliot-testing","success","API route updated, 404 page and core events page created","https://github.com/truvolv/demo/pull/8" -"truvolv/demo","fewa-test-demo-site","success","API route updated, 404 page and core events page created","https://github.com/truvolv/demo/pull/8" +"truvolv/demo","baths-lp","success","API route updated, 404 page and core events page created","https://github.com/truvolv/demo/pull/9" +"truvolv/demo","bryan-espey","success","API route updated, 404 page and core events page created","https://github.com/truvolv/demo/pull/9" +"truvolv/demo","carrie-testing","success","API route updated, 404 page and core events page created","https://github.com/truvolv/demo/pull/9" +"truvolv/demo","carrie-testing-2","success","API route updated, 404 page and core events page created","https://github.com/truvolv/demo/pull/9" +"truvolv/demo","carrie-testing-site","success","API route updated, 404 page and core events page created","https://github.com/truvolv/demo/pull/9" +"truvolv/demo","chace-test","success","API route updated, 404 page and core events page created","https://github.com/truvolv/demo/pull/9" +"truvolv/demo","cody-test","success","API route updated, 404 page and core events page created","https://github.com/truvolv/demo/pull/9" +"truvolv/demo","eden-testing","success","API route updated, 404 page and core events page created","https://github.com/truvolv/demo/pull/9" +"truvolv/demo","elliot-testing","success","API route updated, 404 page and core events page created","https://github.com/truvolv/demo/pull/9" +"truvolv/demo","fewa-test-demo-site","success","API route updated, 404 page and core events page created","https://github.com/truvolv/demo/pull/9" diff --git a/events-404-api-route-updates/logs.txt b/events-404-api-route-updates/logs.txt index b817358..212c24c 100644 --- a/events-404-api-route-updates/logs.txt +++ b/events-404-api-route-updates/logs.txt @@ -1,4 +1,5 @@ -Mass repo update started at Wed Nov 5 16:15:22 EST 2025 + +Mass repo update started at Wed Nov 5 16:38:02 EST 2025 ================================================ APP STATUS: truvolv/demo/baths-lp - success - API route updated, 404 page and core events page created APP STATUS: truvolv/demo/bryan-espey - success - API route updated, 404 page and core events page created @@ -11,4 +12,4 @@ APP STATUS: truvolv/demo/eden-testing - success - API route updated, 404 page an APP STATUS: truvolv/demo/elliot-testing - success - API route updated, 404 page and core events page created APP STATUS: truvolv/demo/fewa-test-demo-site - success - API route updated, 404 page and core events page created ================================================ -Mass repo update completed at Wed Nov 5 16:15:26 EST 2025 +Mass repo update completed at Wed Nov 5 16:38:06 EST 2025 diff --git a/events-404-api-route-updates/pr-links.txt b/events-404-api-route-updates/pr-links.txt index e6c5efb..f3cadff 100644 --- a/events-404-api-route-updates/pr-links.txt +++ b/events-404-api-route-updates/pr-links.txt @@ -1,5 +1,6 @@ -PR Links from mass repo update started at Wed Nov 5 16:15:23 EST 2025 + +PR Links from mass repo update started at Wed Nov 5 16:38:03 EST 2025 ================================================ -truvolv/demo: https://github.com/truvolv/demo/pull/8 +truvolv/demo: https://github.com/truvolv/demo/pull/9 ================================================ -Mass repo update completed at Wed Nov 5 16:15:26 EST 2025 +Mass repo update completed at Wed Nov 5 16:38:06 EST 2025 diff --git a/events-404-api-route-updates/update-repos.sh b/events-404-api-route-updates/update-repos.sh index 08cb77f..9eeea46 100644 --- a/events-404-api-route-updates/update-repos.sh +++ b/events-404-api-route-updates/update-repos.sh @@ -50,6 +50,11 @@ mkdir -p all-repos while IFS= read -r repo_name || [[ -n "$repo_name" ]]; do # Skip empty lines and comments [[ -z "$repo_name" || "$repo_name" =~ ^[[:space:]]*# ]] && continue + + if [[ $apps_fixed -ge $BATCH_SIZE ]]; then + echo -e "${GREEN}Batch limit of $BATCH_SIZE apps reached. Stopping.${NC}" + break + fi echo -e "${YELLOW}Processing: $repo_name (Fixed: $apps_fixed/$BATCH_SIZE)${NC}" @@ -296,9 +301,9 @@ EOF core_event_page_updated=true changes_made=true else - echo "Creating Core Events page file in $app_name/events/[...slug]/page.tsx" - mkdir -p "$app_dir/events/[...slug]" - cat > "$app_dir/events/[...slug]/page.tsx" << 'EOF' + echo "Creating Core Events page file in $app_name/app/events/[...slug]/page.tsx" + mkdir -p "$app_dir/app/events/[...slug]" + cat > "$app_dir/app/events/[...slug]/page.tsx" << 'EOF' import { CoreEvent } from "@truvolv/orson-seelib/components/event"; import { generateStaticEventParams } from "@truvolv/orson-seelib/lib/generateStaticEventParams"; import { generateEventMeta } from "@truvolv/orson-seelib/lib/generateEventMeta"; @@ -408,7 +413,7 @@ EOF # Step 8-9: Create branch, commit, push, and create PR if changes were made if [[ "$changes_made" == true ]]; then # Comment out lines 422 - 438 once tested and ready to push to main - branch_name="chore/TRUSPD-587/update-api-route-404-component-core-events-page" + branch_name="chore/TRUSPD-587/update-api-route-404-page-core-events-page" echo " Cleaning up git references..." git fetch --prune origin 2>/dev/null || true diff --git a/template/update-repos.sh b/template/update-repos.sh index 8baa450..3f5c628 100644 --- a/template/update-repos.sh +++ b/template/update-repos.sh @@ -50,6 +50,11 @@ mkdir -p all-repos while IFS= read -r repo_name || [[ -n "$repo_name" ]]; do # Skip empty lines and comments [[ -z "$repo_name" || "$repo_name" =~ ^[[:space:]]*# ]] && continue + + if [[ $apps_fixed -ge $BATCH_SIZE ]]; then + echo -e "${GREEN}Batch limit of $BATCH_SIZE apps reached. Stopping.${NC}" + break + fi echo -e "${YELLOW}Processing: $repo_name (Fixed: $apps_fixed/$BATCH_SIZE)${NC}" From 2ba6e1a6ed719223d52a449b12ba684351710f0f Mon Sep 17 00:00:00 2001 From: Eden Chou Date: Thu, 6 Nov 2025 11:13:39 -0500 Subject: [PATCH 3/4] adding manual update flag --- events-404-api-route-updates/README.md | 2 +- events-404-api-route-updates/logs.csv | 13 +-- .../manual-update.txt | 1 + events-404-api-route-updates/update-repos.sh | 97 +++++++------------ template/manual-update.txt | 0 5 files changed, 41 insertions(+), 72 deletions(-) create mode 100644 events-404-api-route-updates/manual-update.txt create mode 100644 template/manual-update.txt diff --git a/events-404-api-route-updates/README.md b/events-404-api-route-updates/README.md index 5ec40ea..08a7266 100644 --- a/events-404-api-route-updates/README.md +++ b/events-404-api-route-updates/README.md @@ -1,6 +1,6 @@ ## ๐Ÿงฉ Repository Batch Updater Script -This script was written for batch updates across our member repos. In this instance, the intent was to update the NextJS version and to make the middleware asynchronous. +This script was written for batch updates across our member repos. In this instance, the intent was to update the API routes from Orson-Seelib, use a 404 page component from Orson-Seelib, and add an Events page route for the Events collection.\ ### ๐Ÿš€ What It Does diff --git a/events-404-api-route-updates/logs.csv b/events-404-api-route-updates/logs.csv index 0fd852f..6cb9d0a 100644 --- a/events-404-api-route-updates/logs.csv +++ b/events-404-api-route-updates/logs.csv @@ -1,11 +1,4 @@ Repo,App,Status,Notes,PR Link -"truvolv/demo","baths-lp","success","API route updated, 404 page and core events page created","https://github.com/truvolv/demo/pull/9" -"truvolv/demo","bryan-espey","success","API route updated, 404 page and core events page created","https://github.com/truvolv/demo/pull/9" -"truvolv/demo","carrie-testing","success","API route updated, 404 page and core events page created","https://github.com/truvolv/demo/pull/9" -"truvolv/demo","carrie-testing-2","success","API route updated, 404 page and core events page created","https://github.com/truvolv/demo/pull/9" -"truvolv/demo","carrie-testing-site","success","API route updated, 404 page and core events page created","https://github.com/truvolv/demo/pull/9" -"truvolv/demo","chace-test","success","API route updated, 404 page and core events page created","https://github.com/truvolv/demo/pull/9" -"truvolv/demo","cody-test","success","API route updated, 404 page and core events page created","https://github.com/truvolv/demo/pull/9" -"truvolv/demo","eden-testing","success","API route updated, 404 page and core events page created","https://github.com/truvolv/demo/pull/9" -"truvolv/demo","elliot-testing","success","API route updated, 404 page and core events page created","https://github.com/truvolv/demo/pull/9" -"truvolv/demo","fewa-test-demo-site","success","API route updated, 404 page and core events page created","https://github.com/truvolv/demo/pull/9" +"truvolv/cyprus-air","ca-module-multistep-form","partial, needs manual update"," API route not updated, 404 page created, core events page created","" +"truvolv/cyprus-air","cyprus-air-main","success","API route updated, 404 page and core events page created","" +"truvolv/bath-experts","main-bath-experts","partial"," API route updated, 404 page created, core events page not updated","" diff --git a/events-404-api-route-updates/manual-update.txt b/events-404-api-route-updates/manual-update.txt new file mode 100644 index 0000000..35ee83a --- /dev/null +++ b/events-404-api-route-updates/manual-update.txt @@ -0,0 +1 @@ +"truvolv/cyprus-air","manual-update-required","Custom member edits detected in /app/api/[...slug]/route.ts" diff --git a/events-404-api-route-updates/update-repos.sh b/events-404-api-route-updates/update-repos.sh index 9eeea46..b34cde6 100644 --- a/events-404-api-route-updates/update-repos.sh +++ b/events-404-api-route-updates/update-repos.sh @@ -11,6 +11,7 @@ LOG_FILE="$SCRIPT_DIR/logs.csv" ERROR_FILE="$SCRIPT_DIR/error.csv" PR_LINKS_FILE="$SCRIPT_DIR/pr-links.txt" LOG_TRACKING_FILE="$SCRIPT_DIR/logs.txt" +MANUAL_UPDATE_FILE="$SCRIPT_DIR/manual-update.txt" BATCH_SIZE=${1:-5} echo -e "${YELLOW}Batch size set to: $BATCH_SIZE apps${NC}" @@ -62,7 +63,7 @@ while IFS= read -r repo_name || [[ -n "$repo_name" ]]; do # Step 2: Clone repo if not present if [[ ! -d "$repo_dir" ]]; then - echo " Cloning $repo_name..." + echo "Cloning $repo_name..." if ! gh repo clone "$repo_name" "$repo_dir"; then echo -e "${RED} Failed to clone $repo_name${NC}" echo "\"$repo_name\",\"clone-failed\",\"Could not clone repository\"" >> "$ERROR_FILE" @@ -127,7 +128,9 @@ while IFS= read -r repo_name || [[ -n "$repo_name" ]]; do app_name=$(basename "$app_dir") echo " Processing app: $app_name" echo " App Directory: $app_dir" - + + needs_manual_update=false + api_route_updated=false page_404_updated=false page_404_created=false @@ -161,14 +164,16 @@ while IFS= read -r repo_name || [[ -n "$repo_name" ]]; do if [[ "$api_route_already_updated" == true && "$page_404_already_updated" == true && "$core_event_page_already_updated" == true ]]; then echo "\"$repo_name\",\"$app_name\",\"completed\",\"already updated (not counted toward batch)\",\"\"" >> "$LOG_FILE" - echo "App already has all three updates, skipping..." + echo " App already has all three updates, skipping..." continue fi - # Step 5: Update API route, the route should exist + # Step 5: Update API route if no custom member edits have been made to the file, the route should exist if [[ -f "$app_dir/app/api/[...slug]/route.ts" ]]; then - echo "Updating API route in $app_name/app/api/[...slug]/route.ts" - # Replace all content with new API route content + if grep -q "import { GET } from \"@truvolv/orson-seelib/api/router\";" "$app_dir/app/api/[...slug]/route.ts" && \ + grep -q "export { GET };" "$app_dir/app/api/[...slug]/route.ts"; then + echo " Updating API route in $app_name/app/api/[...slug]/route.ts" + # Replace all content with new API route content cat > "$app_dir/app/api/[...slug]/route.ts" << 'EOF' // exporting all route handlers from orson-seelib @@ -177,11 +182,21 @@ export * from "@truvolv/orson-seelib/api/router"; EOF api_route_updated=true changes_made=true + + else + echo " Skipping API route update in $app_name/app/api/[...slug]/route.ts - custom member edits detected" + echo "\"$repo_name\",\"manual-update-required\",\"Custom member edits detected in /app/api/[...slug]/route.ts\"" >> "$MANUAL_UPDATE_FILE" + + needs_manual_update=true + api_route_updated=false + changes_made=false + + fi fi # Step 6: Update 404 page if it exists, else create it if [[ -f "$app_dir/not-found.tsx" ]]; then - echo "Updating 404 page in $app_name/not-found.tsx" + echo " Updating 404 page in $app_name/not-found.tsx" # Replace all content with new 404 page content cat > "$app_dir/not-found.tsx" << 'EOF' @@ -216,7 +231,7 @@ EOF page_404_updated=true changes_made=true else - echo "Creating 404 page file in $app_name/not-found.tsx" + echo " Creating 404 page file in $app_name/not-found.tsx" cat > "$app_dir/not-found.tsx" << 'EOF' import { Metadata } from "next"; import { generate404PageMeta } from "@truvolv/orson-seelib/lib/generate404PageMeta"; @@ -249,59 +264,14 @@ EOF changes_made=true fi - # Step 7: Update Core Events page if it exists, else create it + # Step 7: Only create Core Events page if it doesn't exist if [[ -f "$app_dir/app/events/[...slug]/page.tsx" ]]; then - echo "Updating Core Events page in $app_name/app/events/[...slug]/page.tsx" - # Replace content with new Core Events page content - mkdir -p "$app_dir/app/events/[...slug]" - cat > "$app_dir/app/events/[...slug]/page.tsx" << 'EOF' -import { CoreEvent } from "@truvolv/orson-seelib/components/event"; -import { generateStaticEventParams } from "@truvolv/orson-seelib/lib/generateStaticEventParams"; -import { generateEventMeta } from "@truvolv/orson-seelib/lib/generateEventMeta"; -import { Metadata } from "next"; - -export async function generateMetadata({ -params, -}: { -params: { slug: string | string[] }; -}): Promise { -try { - const result = generateEventMeta({ params }); - return result; -} catch (error) { - console.error("Error generating metadata:", error); - throw error; -} -} - -export async function generateStaticParams() { -try { - const result = generateStaticEventParams(); - return result; -} catch (error) { - console.error("Error generating static event params:", error); - throw error; -} -} - -export default async function Event({ -params, -}: { -params: { slug: string | string[] }; -}) { -return ( - <> - - -); -} -EOF - + echo " Skipping update, Core Events page in $app_name/app/events/[...slug]/page.tsx already exists" - core_event_page_updated=true - changes_made=true + core_event_page_updated=false + changes_made=false else - echo "Creating Core Events page file in $app_name/app/events/[...slug]/page.tsx" + echo " Creating Core Events page file in $app_name/app/events/[...slug]/page.tsx" mkdir -p "$app_dir/app/events/[...slug]" cat > "$app_dir/app/events/[...slug]/page.tsx" << 'EOF' import { CoreEvent } from "@truvolv/orson-seelib/components/event"; @@ -366,7 +336,6 @@ EOF else # Partial updates - build detailed notes status="partial" - notes="Updates:" if [[ "$api_route_updated" == true ]]; then notes="$notes API route updated," else @@ -389,13 +358,17 @@ EOF notes="${notes%,}" # Remove trailing comma fi - echo "\"$repo_name\",\"$app_name\",\"$status\",\"$notes\",\"\"" >> "$LOG_FILE" + if [[ "$needs_manual_update" == true ]]; then + echo "\"$repo_name\",\"$app_name\",\"$status, needs manual update\",\"$notes\",\"\"" >> "$LOG_FILE" + else + echo "\"$repo_name\",\"$app_name\",\"$status\",\"$notes\",\"\"" >> "$LOG_FILE" + fi # Count toward batch only if all three components were successfully processed if [[ "$api_route_updated" == true && ("$page_404_updated" == true || "$page_404_created" == true) && ("$core_event_page_updated" == true || "$core_event_page_created" == true) ]]; then ((apps_fixed++)) echo "APP STATUS: $repo_name/$app_name - $status - $notes" >> "$LOG_TRACKING_FILE" - echo "App fixed! Total fixed: $apps_fixed" + echo " App fixed! Total fixed: $apps_fixed" fi done @@ -461,6 +434,8 @@ EOF - 404 page skeleton to use NotFoundPage component from orson-seelib - Events page to display separate events page using CoreEvent component from orson-seelib + Ticket: https://truvolv-company.monday.com/item/TRUSPD-583 + This is an automated update across multiple repositories." \ --head "$branch_name" 2>&1) diff --git a/template/manual-update.txt b/template/manual-update.txt new file mode 100644 index 0000000..e69de29 From f6ecc1be549de36debb67e66e959766f0889ce36 Mon Sep 17 00:00:00 2001 From: Eden Chou Date: Thu, 6 Nov 2025 11:42:54 -0500 Subject: [PATCH 4/4] updating manual updates csv file --- .../manual-update.txt | 1 - .../manual-updates.csv | 2 + events-404-api-route-updates/update-repos.sh | 144 +++++------ .../{manual-update.txt => manual-updates.csv} | 0 template/update-repos.sh | 240 ++++++++---------- 5 files changed, 181 insertions(+), 206 deletions(-) delete mode 100644 events-404-api-route-updates/manual-update.txt create mode 100644 events-404-api-route-updates/manual-updates.csv rename template/{manual-update.txt => manual-updates.csv} (100%) diff --git a/events-404-api-route-updates/manual-update.txt b/events-404-api-route-updates/manual-update.txt deleted file mode 100644 index 35ee83a..0000000 --- a/events-404-api-route-updates/manual-update.txt +++ /dev/null @@ -1 +0,0 @@ -"truvolv/cyprus-air","manual-update-required","Custom member edits detected in /app/api/[...slug]/route.ts" diff --git a/events-404-api-route-updates/manual-updates.csv b/events-404-api-route-updates/manual-updates.csv new file mode 100644 index 0000000..7ec272a --- /dev/null +++ b/events-404-api-route-updates/manual-updates.csv @@ -0,0 +1,2 @@ +Repo,App,Status,Notes +"truvolv/cyprus-air","ca-module-multistep-form","manual-update-required","Custom member edits detected in /app/api/[...slug]/route.ts" diff --git a/events-404-api-route-updates/update-repos.sh b/events-404-api-route-updates/update-repos.sh index b34cde6..daa8969 100644 --- a/events-404-api-route-updates/update-repos.sh +++ b/events-404-api-route-updates/update-repos.sh @@ -11,14 +11,15 @@ LOG_FILE="$SCRIPT_DIR/logs.csv" ERROR_FILE="$SCRIPT_DIR/error.csv" PR_LINKS_FILE="$SCRIPT_DIR/pr-links.txt" LOG_TRACKING_FILE="$SCRIPT_DIR/logs.txt" -MANUAL_UPDATE_FILE="$SCRIPT_DIR/manual-update.txt" +MANUAL_UPDATE_FILE="$SCRIPT_DIR/manual-updates.csv" BATCH_SIZE=${1:-5} echo -e "${YELLOW}Batch size set to: $BATCH_SIZE apps${NC}" echo "Repo,App,Status,Notes,PR Link" > "$LOG_FILE" echo "Repo,Issue,Details" > "$ERROR_FILE" -echo -e "${GREEN}Created new logs.csv and error.csv files${NC}" +echo "Repo,App,Status,Notes" > "$MANUAL_UPDATE_FILE" +echo -e "${GREEN}Created new logs.csv, error.csv, and manual-updates.csv files${NC}" apps_fixed=0 @@ -185,7 +186,7 @@ EOF else echo " Skipping API route update in $app_name/app/api/[...slug]/route.ts - custom member edits detected" - echo "\"$repo_name\",\"manual-update-required\",\"Custom member edits detected in /app/api/[...slug]/route.ts\"" >> "$MANUAL_UPDATE_FILE" + echo "\"$repo_name\",\"$app_name\",\"manual-update-required\",\"Custom member edits detected in /app/api/[...slug]/route.ts\"" >> "$MANUAL_UPDATE_FILE" needs_manual_update=true api_route_updated=false @@ -384,89 +385,88 @@ EOF fi # Step 8-9: Create branch, commit, push, and create PR if changes were made - if [[ "$changes_made" == true ]]; then - # Comment out lines 422 - 438 once tested and ready to push to main - branch_name="chore/TRUSPD-587/update-api-route-404-page-core-events-page" + # if [[ "$changes_made" == true ]]; then + # # Comment out lines for Step #8-9 once tested and ready to push to main + # branch_name="chore/TRUSPD-587/update-api-route-404-page-core-events-page" - echo " Cleaning up git references..." - git fetch --prune origin 2>/dev/null || true + # echo " Cleaning up git references..." + # git fetch --prune origin 2>/dev/null || true - echo " Creating branch: $branch_name" - if ! git checkout -b "$branch_name" 2>/dev/null; then - echo -e "${YELLOW} Branch creation failed (likely already exists), discarding local changes${NC}" - echo "\"$repo_name\",\"branch-exists\",\"Branch creation failed, likely already exists - local changes discarded\"" >> "$ERROR_FILE" + # echo " Creating branch: $branch_name" + # if ! git checkout -b "$branch_name" 2>/dev/null; then + # echo -e "${YELLOW} Branch creation failed (likely already exists), discarding local changes${NC}" + # echo "\"$repo_name\",\"branch-exists\",\"Branch creation failed, likely already exists - local changes discarded\"" >> "$ERROR_FILE" - # Reset any local changes - git reset --hard HEAD - git clean -fd + # # Reset any local changes + # git reset --hard HEAD + # git clean -fd - cd - > /dev/null - continue - fi + # cd - > /dev/null + # continue + # fi - echo " Committing changes..." - git add . - if ! git commit -m "Update API route to include all handlers from orson-seelib, update or create 404 page skeleton, and update or create core events page"; then - echo -e "${RED} Failed to commit changes${NC}" - echo "\"$repo_name\",\"commit-failed\",\"Could not commit changes\"" >> "$ERROR_FILE" - cd - > /dev/null - continue - fi + # echo " Committing changes..." + # git add . + # if ! git commit -m "Update API route to include all handlers from orson-seelib, update or create 404 page skeleton, and update or create core events page"; then + # echo -e "${RED} Failed to commit changes${NC}" + # echo "\"$repo_name\",\"commit-failed\",\"Could not commit changes\"" >> "$ERROR_FILE" + # cd - > /dev/null + # continue + # fi - echo " Pushing branch..." - # Comment out line 451 and uncomment next line once tested to push without PR creation - if ! git push origin "$branch_name"; then - # if ! git push; then - - echo -e "${RED} Failed to push branch${NC}" - echo "\"$repo_name\",\"push-failed\",\"Could not push branch $branch_name\"" >> "$ERROR_FILE" - cd - > /dev/null - continue - fi + # echo " Pushing branch..." + # # Comment out line 451 and uncomment next line once tested to push without PR creation + # if ! git push origin "$branch_name"; then + # # if ! git push; then + + # echo -e "${RED} Failed to push branch${NC}" + # echo "\"$repo_name\",\"push-failed\",\"Could not push branch $branch_name\"" >> "$ERROR_FILE" + # cd - > /dev/null + # continue + # fi - # Comment out lines 461 - 493 once tested and ready to push straight to main - echo " Creating PR..." - pr_url=$(gh pr create \ - --title "Update API route, 404 page, and core events page" \ - --body "This PR updates: + # echo " Creating PR..." + # pr_url=$(gh pr create \ + # --title "Update API route, 404 page, and core events page" \ + # --body "This PR updates: - - API route to include all handlers from orson-seelib - - 404 page skeleton to use NotFoundPage component from orson-seelib - - Events page to display separate events page using CoreEvent component from orson-seelib + # - API route to include all handlers from orson-seelib + # - 404 page skeleton to use NotFoundPage component from orson-seelib + # - Events page to display separate events page using CoreEvent component from orson-seelib - Ticket: https://truvolv-company.monday.com/item/TRUSPD-583 + # Ticket: https://truvolv-company.monday.com/item/TRUSPD-583 - This is an automated update across multiple repositories." \ - --head "$branch_name" 2>&1) + # This is an automated update across multiple repositories." \ + # --head "$branch_name" 2>&1) - if [[ $? -eq 0 ]]; then - echo -e "${GREEN} โœ“ PR created successfully${NC}" + # if [[ $? -eq 0 ]]; then + # echo -e "${GREEN} โœ“ PR created successfully${NC}" - # Add to PR links file - echo "$repo_name: $pr_url" >> "$PR_LINKS_FILE" + # # Add to PR links file + # echo "$repo_name: $pr_url" >> "$PR_LINKS_FILE" - # Update the CSV with PR URL for successful app updates - temp_file=$(mktemp) - while IFS= read -r line; do - if [[ "$line" == *"\"$repo_name\","*"\",\"success\","* ]]; then - # Replace the empty PR link with the actual URL - echo "${line%,\"\"*},\"$pr_url\"" >> "$temp_file" - else - echo "$line" >> "$temp_file" - fi - done < "$LOG_FILE" - mv "$temp_file" "$LOG_FILE" - else - echo -e "${RED} Failed to create PR${NC}" - echo "\"$repo_name\",\"pr-failed\",\"Could not create pull request\"" >> "$ERROR_FILE" - fi - else - echo -e "${YELLOW} No changes needed${NC}" - echo "\"$repo_name\",\"no-changes\",\"Repository processed but no changes were needed\"" >> "$ERROR_FILE" - fi + # # Update the CSV with PR URL for successful app updates + # temp_file=$(mktemp) + # while IFS= read -r line; do + # if [[ "$line" == *"\"$repo_name\","*"\",\"success\","* ]]; then + # # Replace the empty PR link with the actual URL + # echo "${line%,\"\"*},\"$pr_url\"" >> "$temp_file" + # else + # echo "$line" >> "$temp_file" + # fi + # done < "$LOG_FILE" + # mv "$temp_file" "$LOG_FILE" + # else + # echo -e "${RED} Failed to create PR${NC}" + # echo "\"$repo_name\",\"pr-failed\",\"Could not create pull request\"" >> "$ERROR_FILE" + # fi + # else + # echo -e "${YELLOW} No changes needed${NC}" + # echo "\"$repo_name\",\"no-changes\",\"Repository processed but no changes were needed\"" >> "$ERROR_FILE" + # fi - cd - > /dev/null - echo "" + # cd - > /dev/null + # echo "" done < "$REPO_LIST_FILE" diff --git a/template/manual-update.txt b/template/manual-updates.csv similarity index 100% rename from template/manual-update.txt rename to template/manual-updates.csv diff --git a/template/update-repos.sh b/template/update-repos.sh index 3f5c628..daa8969 100644 --- a/template/update-repos.sh +++ b/template/update-repos.sh @@ -11,13 +11,15 @@ LOG_FILE="$SCRIPT_DIR/logs.csv" ERROR_FILE="$SCRIPT_DIR/error.csv" PR_LINKS_FILE="$SCRIPT_DIR/pr-links.txt" LOG_TRACKING_FILE="$SCRIPT_DIR/logs.txt" +MANUAL_UPDATE_FILE="$SCRIPT_DIR/manual-updates.csv" BATCH_SIZE=${1:-5} echo -e "${YELLOW}Batch size set to: $BATCH_SIZE apps${NC}" echo "Repo,App,Status,Notes,PR Link" > "$LOG_FILE" echo "Repo,Issue,Details" > "$ERROR_FILE" -echo -e "${GREEN}Created new logs.csv and error.csv files${NC}" +echo "Repo,App,Status,Notes" > "$MANUAL_UPDATE_FILE" +echo -e "${GREEN}Created new logs.csv, error.csv, and manual-updates.csv files${NC}" apps_fixed=0 @@ -62,7 +64,7 @@ while IFS= read -r repo_name || [[ -n "$repo_name" ]]; do # Step 2: Clone repo if not present if [[ ! -d "$repo_dir" ]]; then - echo " Cloning $repo_name..." + echo "Cloning $repo_name..." if ! gh repo clone "$repo_name" "$repo_dir"; then echo -e "${RED} Failed to clone $repo_name${NC}" echo "\"$repo_name\",\"clone-failed\",\"Could not clone repository\"" >> "$ERROR_FILE" @@ -127,7 +129,9 @@ while IFS= read -r repo_name || [[ -n "$repo_name" ]]; do app_name=$(basename "$app_dir") echo " Processing app: $app_name" echo " App Directory: $app_dir" - + + needs_manual_update=false + api_route_updated=false page_404_updated=false page_404_created=false @@ -161,14 +165,16 @@ while IFS= read -r repo_name || [[ -n "$repo_name" ]]; do if [[ "$api_route_already_updated" == true && "$page_404_already_updated" == true && "$core_event_page_already_updated" == true ]]; then echo "\"$repo_name\",\"$app_name\",\"completed\",\"already updated (not counted toward batch)\",\"\"" >> "$LOG_FILE" - echo "App already has all three updates, skipping..." + echo " App already has all three updates, skipping..." continue fi - # Step 5: Update API route, the route should exist + # Step 5: Update API route if no custom member edits have been made to the file, the route should exist if [[ -f "$app_dir/app/api/[...slug]/route.ts" ]]; then - echo "Updating API route in $app_name/app/api/[...slug]/route.ts" - # Replace all content with new API route content + if grep -q "import { GET } from \"@truvolv/orson-seelib/api/router\";" "$app_dir/app/api/[...slug]/route.ts" && \ + grep -q "export { GET };" "$app_dir/app/api/[...slug]/route.ts"; then + echo " Updating API route in $app_name/app/api/[...slug]/route.ts" + # Replace all content with new API route content cat > "$app_dir/app/api/[...slug]/route.ts" << 'EOF' // exporting all route handlers from orson-seelib @@ -177,11 +183,21 @@ export * from "@truvolv/orson-seelib/api/router"; EOF api_route_updated=true changes_made=true + + else + echo " Skipping API route update in $app_name/app/api/[...slug]/route.ts - custom member edits detected" + echo "\"$repo_name\",\"$app_name\",\"manual-update-required\",\"Custom member edits detected in /app/api/[...slug]/route.ts\"" >> "$MANUAL_UPDATE_FILE" + + needs_manual_update=true + api_route_updated=false + changes_made=false + + fi fi # Step 6: Update 404 page if it exists, else create it if [[ -f "$app_dir/not-found.tsx" ]]; then - echo "Updating 404 page in $app_name/not-found.tsx" + echo " Updating 404 page in $app_name/not-found.tsx" # Replace all content with new 404 page content cat > "$app_dir/not-found.tsx" << 'EOF' @@ -216,7 +232,7 @@ EOF page_404_updated=true changes_made=true else - echo "Creating 404 page file in $app_name/not-found.tsx" + echo " Creating 404 page file in $app_name/not-found.tsx" cat > "$app_dir/not-found.tsx" << 'EOF' import { Metadata } from "next"; import { generate404PageMeta } from "@truvolv/orson-seelib/lib/generate404PageMeta"; @@ -249,61 +265,16 @@ EOF changes_made=true fi - # Step 7: Update Core Events page if it exists, else create it + # Step 7: Only create Core Events page if it doesn't exist if [[ -f "$app_dir/app/events/[...slug]/page.tsx" ]]; then - echo "Updating Core Events page in $app_name/app/events/[...slug]/page.tsx" - # Replace content with new Core Events page content - mkdir -p "$app_dir/app/events/[...slug]" - cat > "$app_dir/app/events/[...slug]/page.tsx" << 'EOF' -import { CoreEvent } from "@truvolv/orson-seelib/components/event"; -import { generateStaticEventParams } from "@truvolv/orson-seelib/lib/generateStaticEventParams"; -import { generateEventMeta } from "@truvolv/orson-seelib/lib/generateEventMeta"; -import { Metadata } from "next"; - -export async function generateMetadata({ -params, -}: { -params: { slug: string | string[] }; -}): Promise { -try { - const result = generateEventMeta({ params }); - return result; -} catch (error) { - console.error("Error generating metadata:", error); - throw error; -} -} - -export async function generateStaticParams() { -try { - const result = generateStaticEventParams(); - return result; -} catch (error) { - console.error("Error generating static event params:", error); - throw error; -} -} - -export default async function Event({ -params, -}: { -params: { slug: string | string[] }; -}) { -return ( - <> - - -); -} -EOF - + echo " Skipping update, Core Events page in $app_name/app/events/[...slug]/page.tsx already exists" - core_event_page_updated=true - changes_made=true + core_event_page_updated=false + changes_made=false else - echo "Creating Core Events page file in $app_name/events/[...slug]/page.tsx" - mkdir -p "$app_dir/events/[...slug]" - cat > "$app_dir/events/[...slug]/page.tsx" << 'EOF' + echo " Creating Core Events page file in $app_name/app/events/[...slug]/page.tsx" + mkdir -p "$app_dir/app/events/[...slug]" + cat > "$app_dir/app/events/[...slug]/page.tsx" << 'EOF' import { CoreEvent } from "@truvolv/orson-seelib/components/event"; import { generateStaticEventParams } from "@truvolv/orson-seelib/lib/generateStaticEventParams"; import { generateEventMeta } from "@truvolv/orson-seelib/lib/generateEventMeta"; @@ -366,7 +337,6 @@ EOF else # Partial updates - build detailed notes status="partial" - notes="Updates:" if [[ "$api_route_updated" == true ]]; then notes="$notes API route updated," else @@ -389,13 +359,17 @@ EOF notes="${notes%,}" # Remove trailing comma fi - echo "\"$repo_name\",\"$app_name\",\"$status\",\"$notes\",\"\"" >> "$LOG_FILE" + if [[ "$needs_manual_update" == true ]]; then + echo "\"$repo_name\",\"$app_name\",\"$status, needs manual update\",\"$notes\",\"\"" >> "$LOG_FILE" + else + echo "\"$repo_name\",\"$app_name\",\"$status\",\"$notes\",\"\"" >> "$LOG_FILE" + fi # Count toward batch only if all three components were successfully processed if [[ "$api_route_updated" == true && ("$page_404_updated" == true || "$page_404_created" == true) && ("$core_event_page_updated" == true || "$core_event_page_created" == true) ]]; then ((apps_fixed++)) echo "APP STATUS: $repo_name/$app_name - $status - $notes" >> "$LOG_TRACKING_FILE" - echo "App fixed! Total fixed: $apps_fixed" + echo " App fixed! Total fixed: $apps_fixed" fi done @@ -411,88 +385,88 @@ EOF fi # Step 8-9: Create branch, commit, push, and create PR if changes were made - if [[ "$changes_made" == true ]]; then - # Comment out lines 422 - 438 once tested and ready to push to main - # Branch name will need to be unique every time you push, so update accordingly - branch_name="chore/TRUSPD-XXX/xxx" + # if [[ "$changes_made" == true ]]; then + # # Comment out lines for Step #8-9 once tested and ready to push to main + # branch_name="chore/TRUSPD-587/update-api-route-404-page-core-events-page" - echo " Cleaning up git references..." - git fetch --prune origin 2>/dev/null || true + # echo " Cleaning up git references..." + # git fetch --prune origin 2>/dev/null || true - echo " Creating branch: $branch_name" - if ! git checkout -b "$branch_name" 2>/dev/null; then - echo -e "${YELLOW} Branch creation failed (likely already exists), discarding local changes${NC}" - echo "\"$repo_name\",\"branch-exists\",\"Branch creation failed, likely already exists - local changes discarded\"" >> "$ERROR_FILE" + # echo " Creating branch: $branch_name" + # if ! git checkout -b "$branch_name" 2>/dev/null; then + # echo -e "${YELLOW} Branch creation failed (likely already exists), discarding local changes${NC}" + # echo "\"$repo_name\",\"branch-exists\",\"Branch creation failed, likely already exists - local changes discarded\"" >> "$ERROR_FILE" - # Reset any local changes - git reset --hard HEAD - git clean -fd + # # Reset any local changes + # git reset --hard HEAD + # git clean -fd - cd - > /dev/null - continue - fi + # cd - > /dev/null + # continue + # fi - echo " Committing changes..." - git add . - if ! git commit -m "Update API route to include all handlers from orson-seelib, update or create 404 page skeleton, and update or create core events page"; then - echo -e "${RED} Failed to commit changes${NC}" - echo "\"$repo_name\",\"commit-failed\",\"Could not commit changes\"" >> "$ERROR_FILE" - cd - > /dev/null - continue - fi + # echo " Committing changes..." + # git add . + # if ! git commit -m "Update API route to include all handlers from orson-seelib, update or create 404 page skeleton, and update or create core events page"; then + # echo -e "${RED} Failed to commit changes${NC}" + # echo "\"$repo_name\",\"commit-failed\",\"Could not commit changes\"" >> "$ERROR_FILE" + # cd - > /dev/null + # continue + # fi - echo " Pushing branch..." - # Comment out line 451 and uncomment next line once tested to push without PR creation - if ! git push origin "$branch_name"; then - # if ! git push; then - - echo -e "${RED} Failed to push branch${NC}" - echo "\"$repo_name\",\"push-failed\",\"Could not push branch $branch_name\"" >> "$ERROR_FILE" - cd - > /dev/null - continue - fi + # echo " Pushing branch..." + # # Comment out line 451 and uncomment next line once tested to push without PR creation + # if ! git push origin "$branch_name"; then + # # if ! git push; then + + # echo -e "${RED} Failed to push branch${NC}" + # echo "\"$repo_name\",\"push-failed\",\"Could not push branch $branch_name\"" >> "$ERROR_FILE" + # cd - > /dev/null + # continue + # fi - # Comment out lines 461 - 493 once tested and ready to push straight to main - echo " Creating PR..." - pr_url=$(gh pr create \ - --title "Update API route, 404 page, and core events page" \ - --body "This PR updates: + # echo " Creating PR..." + # pr_url=$(gh pr create \ + # --title "Update API route, 404 page, and core events page" \ + # --body "This PR updates: + + # - API route to include all handlers from orson-seelib + # - 404 page skeleton to use NotFoundPage component from orson-seelib + # - Events page to display separate events page using CoreEvent component from orson-seelib - - API route to include all handlers from orson-seelib - - 404 page skeleton to use NotFoundPage component from orson-seelib - - Events page to display separate events page using CoreEvent component from orson-seelib + # Ticket: https://truvolv-company.monday.com/item/TRUSPD-583 - This is an automated update across multiple repositories." \ - --head "$branch_name" 2>&1) + # This is an automated update across multiple repositories." \ + # --head "$branch_name" 2>&1) - if [[ $? -eq 0 ]]; then - echo -e "${GREEN} โœ“ PR created successfully${NC}" + # if [[ $? -eq 0 ]]; then + # echo -e "${GREEN} โœ“ PR created successfully${NC}" - # Add to PR links file - echo "$repo_name: $pr_url" >> "$PR_LINKS_FILE" + # # Add to PR links file + # echo "$repo_name: $pr_url" >> "$PR_LINKS_FILE" - # Update the CSV with PR URL for successful app updates - temp_file=$(mktemp) - while IFS= read -r line; do - if [[ "$line" == *"\"$repo_name\","*"\",\"success\","* ]]; then - # Replace the empty PR link with the actual URL - echo "${line%,\"\"*},\"$pr_url\"" >> "$temp_file" - else - echo "$line" >> "$temp_file" - fi - done < "$LOG_FILE" - mv "$temp_file" "$LOG_FILE" - else - echo -e "${RED} Failed to create PR${NC}" - echo "\"$repo_name\",\"pr-failed\",\"Could not create pull request\"" >> "$ERROR_FILE" - fi - else - echo -e "${YELLOW} No changes needed${NC}" - echo "\"$repo_name\",\"no-changes\",\"Repository processed but no changes were needed\"" >> "$ERROR_FILE" - fi + # # Update the CSV with PR URL for successful app updates + # temp_file=$(mktemp) + # while IFS= read -r line; do + # if [[ "$line" == *"\"$repo_name\","*"\",\"success\","* ]]; then + # # Replace the empty PR link with the actual URL + # echo "${line%,\"\"*},\"$pr_url\"" >> "$temp_file" + # else + # echo "$line" >> "$temp_file" + # fi + # done < "$LOG_FILE" + # mv "$temp_file" "$LOG_FILE" + # else + # echo -e "${RED} Failed to create PR${NC}" + # echo "\"$repo_name\",\"pr-failed\",\"Could not create pull request\"" >> "$ERROR_FILE" + # fi + # else + # echo -e "${YELLOW} No changes needed${NC}" + # echo "\"$repo_name\",\"no-changes\",\"Repository processed but no changes were needed\"" >> "$ERROR_FILE" + # fi - cd - > /dev/null - echo "" + # cd - > /dev/null + # echo "" done < "$REPO_LIST_FILE"