111 lines
2.4 KiB
Bash
Executable File
111 lines
2.4 KiB
Bash
Executable File
#!/bin/zsh
|
|
|
|
# Combined submodule update + Claude docs sync script
|
|
|
|
# Platform-specific commands
|
|
case $OSTYPE in
|
|
darwin*)
|
|
date_cmd() { gdate "$@"; }
|
|
;;
|
|
linux*)
|
|
date_cmd() { date "$@"; }
|
|
;;
|
|
esac
|
|
|
|
# Colors
|
|
BLUE='\033[0;34m'
|
|
GREEN='\033[0;32m'
|
|
YELLOW='\033[1;33m'
|
|
NC='\033[0m'
|
|
|
|
SCRIPT_DIR="${0:a:h}"
|
|
|
|
# Usage function
|
|
usage() {
|
|
echo "Usage: $0 [--dry-run] [--help]"
|
|
echo ""
|
|
echo "This script performs a complete sync:"
|
|
echo "1. Updates all git submodules"
|
|
echo "2. Regenerates Claude documentation for all projects"
|
|
echo "3. Auto-commits changes if any"
|
|
echo ""
|
|
echo "Options:"
|
|
echo " --dry-run Show what would be done without making changes"
|
|
echo " --help Show this help message"
|
|
exit 1
|
|
}
|
|
|
|
DRY_RUN=false
|
|
|
|
for arg in "$@"; do
|
|
case $arg in
|
|
--dry-run)
|
|
DRY_RUN=true
|
|
;;
|
|
--help|-h)
|
|
usage
|
|
;;
|
|
*)
|
|
echo "Unknown argument: $arg"
|
|
usage
|
|
;;
|
|
esac
|
|
done
|
|
|
|
echo -e "${BLUE}🚀 Starting complete project sync...${NC}"
|
|
echo "📅 Time: $(date_cmd '+%Y-%m-%d %H:%M:%S')"
|
|
|
|
if [[ "$DRY_RUN" == true ]]; then
|
|
echo -e "${YELLOW}🔍 DRY RUN MODE - No changes will be made${NC}"
|
|
fi
|
|
|
|
echo ""
|
|
|
|
# Step 1: Update submodules
|
|
echo -e "${BLUE}📦 Step 1: Updating submodules...${NC}"
|
|
if [[ "$DRY_RUN" == true ]]; then
|
|
"$SCRIPT_DIR/update-submodules.sh" --all --dry-run
|
|
else
|
|
"$SCRIPT_DIR/update-submodules.sh" --all --auto
|
|
fi
|
|
|
|
submodule_exit_code=$?
|
|
echo ""
|
|
|
|
# Step 2: Sync Claude documentation
|
|
echo -e "${BLUE}📝 Step 2: Syncing Claude documentation...${NC}"
|
|
if [[ "$DRY_RUN" == true ]]; then
|
|
"$SCRIPT_DIR/sync_docs.sh" --dry-run --all
|
|
else
|
|
"$SCRIPT_DIR/sync_docs.sh" --all
|
|
fi
|
|
|
|
docs_exit_code=$?
|
|
echo ""
|
|
|
|
# Summary
|
|
echo -e "${BLUE}📊 Complete sync summary:${NC}"
|
|
if [[ $submodule_exit_code -eq 0 ]]; then
|
|
echo -e " ✅ Submodules: ${GREEN}Success${NC}"
|
|
else
|
|
echo -e " ❌ Submodules: ${RED}Failed${NC}"
|
|
fi
|
|
|
|
if [[ $docs_exit_code -eq 0 ]]; then
|
|
echo -e " ✅ Documentation: ${GREEN}Success${NC}"
|
|
else
|
|
echo -e " ❌ Documentation: ${RED}Failed${NC}"
|
|
fi
|
|
|
|
if [[ "$DRY_RUN" == true ]]; then
|
|
echo ""
|
|
echo -e "${YELLOW}🔍 This was a dry run. To apply changes, run without --dry-run${NC}"
|
|
fi
|
|
|
|
echo ""
|
|
echo -e "${GREEN}🎉 Complete project sync finished!${NC}"
|
|
|
|
# Exit with error if any step failed
|
|
if [[ $submodule_exit_code -ne 0 || $docs_exit_code -ne 0 ]]; then
|
|
exit 1
|
|
fi |