-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathsync-to-xdg.sh
More file actions
executable file
·107 lines (93 loc) · 2.92 KB
/
sync-to-xdg.sh
File metadata and controls
executable file
·107 lines (93 loc) · 2.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#!/bin/bash
# Sync JAT development changes to XDG installation
# Usage: ./sync-to-xdg.sh
set -e
# Colors for output
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
CYAN='\033[0;36m'
RED='\033[0;31m'
NC='\033[0m'
SOURCE_DIR="$HOME/code/jat"
TARGET_DIR="$HOME/.local/share/jat"
echo -e "${CYAN}🔄 JAT Development → XDG Sync${NC}"
echo ""
echo -e "Source: ${SOURCE_DIR}"
echo -e "Target: ${TARGET_DIR}"
echo ""
# Check if source exists
if [ ! -d "$SOURCE_DIR" ]; then
echo -e "${RED}❌ Source directory not found: $SOURCE_DIR${NC}"
exit 1
fi
# Check if target exists
if [ ! -d "$TARGET_DIR" ]; then
echo -e "${RED}❌ Target directory not found: $TARGET_DIR${NC}"
echo -e "${YELLOW}Run JAT installer first to create XDG installation${NC}"
exit 1
fi
# Confirm before syncing
echo -e "${YELLOW}⚠️ This will overwrite the XDG installation with your dev changes${NC}"
echo -e "Continue? [y/N]: "
read -r response
if [[ ! "$response" =~ ^([yY][eE][sS]|[yY])$ ]]; then
echo -e "${RED}Sync cancelled${NC}"
exit 0
fi
echo ""
echo -e "${GREEN}Syncing files...${NC}"
# Check for rsync or use cp fallback
if command -v rsync >/dev/null 2>&1; then
# Use rsync if available
rsync -av --delete \
--exclude 'node_modules' \
--exclude '.git' \
--exclude '*.log' \
--exclude '.svelte-kit' \
--exclude 'dist' \
--exclude 'build' \
--exclude '.env' \
--exclude '.env.local' \
"$SOURCE_DIR/" "$TARGET_DIR/"
else
echo -e "${YELLOW}rsync not found, using cp instead (slower)${NC}"
# Remove old files first (but keep node_modules if they exist)
find "$TARGET_DIR" -mindepth 1 -maxdepth 1 \
-not -name 'node_modules' \
-not -name '.git' \
-exec rm -rf {} \;
# Copy everything except excluded files
for item in "$SOURCE_DIR"/*; do
basename_item=$(basename "$item")
# Skip excluded items
case "$basename_item" in
node_modules|.git|*.log|.svelte-kit|dist|build|.env|.env.local)
continue
;;
*)
cp -r "$item" "$TARGET_DIR/"
;;
esac
done
# Copy hidden files (except .git and .env*)
for item in "$SOURCE_DIR"/.*; do
basename_item=$(basename "$item")
case "$basename_item" in
.|..|.git|.env|.env.local|.svelte-kit)
continue
;;
*)
[ -e "$item" ] && cp -r "$item" "$TARGET_DIR/"
;;
esac
done
fi
echo ""
echo -e "${GREEN}✅ Sync complete!${NC}"
echo ""
echo -e "Changes synced to XDG installation:"
echo -e " • IDE changes → ${CYAN}jat${NC} will now use updated code"
echo -e " • Tool changes → ${CYAN}am-*, db-*, etc.${NC} will use updated scripts"
echo -e " • Config changes → Templates and shared docs updated"
echo ""
echo -e "Your dev environment (${CYAN}jat-dev${NC}) remains unchanged."