-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-deploy.sh
More file actions
executable file
·140 lines (122 loc) · 3.71 KB
/
Copy pathtest-deploy.sh
File metadata and controls
executable file
·140 lines (122 loc) · 3.71 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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
#!/bin/bash
# test-deploy.sh - Script to test GitHub Pages deployment process locally
# --- Configuration ---
# Define directories to include in deployment (relative to project root)
DEPLOY_INCLUDE=(
"index.html"
"build"
"guides"
"mainwp-hooks"
"source-code"
"LICENSE"
"README.md"
# Add any other files/directories you want to deploy
)
# Define directories explicitly excluded from deployment
DEPLOY_EXCLUDE=(
"mainwp-hooks-old"
"mainwp-hooks-temp"
"hooks-generator"
"phpdoc"
"sources"
"memory-bank"
".git"
".github"
".clineignore"
"clinerules.md"
# Add any other files/directories you want to exclude
)
# --- Setup ---
set -e # Exit immediately if a command fails
ROOT_DIR="$(pwd)"
DEPLOY_DIR="$ROOT_DIR/deploy-test"
LOG_FILE="$ROOT_DIR/deploy-test.log"
# Clear log file
> "$LOG_FILE"
# Helper function for logging
log() {
echo "$1"
echo "$(date '+%Y-%m-%d %H:%M:%S') - $1" >> "$LOG_FILE"
}
log "=== MainWP.dev Documentation Deployment Test ==="
log "Root directory: $ROOT_DIR"
# --- Generate Documentation (optional) ---
if [ "$1" == "--generate" ]; then
log "Generating hooks documentation..."
if [ -d "$ROOT_DIR/hooks-generator" ]; then
(cd "$ROOT_DIR/hooks-generator" && ./generate-categorized-hooks.sh) || {
log "ERROR: Failed to generate hooks documentation"
exit 1
}
log "Hooks documentation generated successfully"
else
log "WARNING: hooks-generator directory not found, skipping documentation generation"
fi
else
log "Skipping documentation generation (use --generate to include this step)"
fi
# --- Prepare Deployment Directory ---
log "Preparing clean deployment directory..."
if [ -d "$DEPLOY_DIR" ]; then
rm -rf "$DEPLOY_DIR"
fi
mkdir -p "$DEPLOY_DIR"
# --- Copy Files for Deployment ---
log "Copying files for deployment..."
# Process each include item
for item in "${DEPLOY_INCLUDE[@]}"; do
if [ -e "$ROOT_DIR/$item" ]; then
log "Including: $item"
if [ -d "$ROOT_DIR/$item" ]; then
mkdir -p "$DEPLOY_DIR/$item"
cp -R "$ROOT_DIR/$item"/* "$DEPLOY_DIR/$item/" 2>/dev/null || true
else
cp "$ROOT_DIR/$item" "$DEPLOY_DIR/" 2>/dev/null || {
log "WARNING: Failed to copy $item"
}
fi
else
log "WARNING: Included item not found: $item"
fi
done
# --- Verify Deployment ---
log "Verifying deployment..."
# Check for required files
REQUIRED_FILES=("index.html" "guides/index.md" "mainwp-hooks/index.md")
missing=0
for file in "${REQUIRED_FILES[@]}"; do
if [ ! -f "$DEPLOY_DIR/$file" ]; then
log "ERROR: Required file missing from deployment: $file"
missing=$((missing + 1))
fi
done
# Verify excluded directories aren't present
for excluded in "${DEPLOY_EXCLUDE[@]}"; do
if [ -e "$DEPLOY_DIR/$excluded" ]; then
log "ERROR: Excluded item found in deployment: $excluded"
missing=$((missing + 1))
fi
done
# --- Summary ---
total_files=$(find "$DEPLOY_DIR" -type f | wc -l)
total_dirs=$(find "$DEPLOY_DIR" -type d | wc -l)
log "=== Deployment Summary ==="
log "Total files: $total_files"
log "Total directories: $total_dirs"
log "Excluded directories:"
for excluded in "${DEPLOY_EXCLUDE[@]}"; do
if [ -e "$ROOT_DIR/$excluded" ]; then
count=$(find "$ROOT_DIR/$excluded" -type f 2>/dev/null | wc -l)
log " - $excluded: $count files (not deployed)"
fi
done
if [ $missing -eq 0 ]; then
log "✅ Verification PASSED: All required files present and excluded items not found"
else
log "❌ Verification FAILED: $missing issues found"
fi
log "Deployment test complete! Review the contents of the '$DEPLOY_DIR' directory"
log "To test the site locally:"
log " cd $DEPLOY_DIR && python3 -m http.server 8000"
log "Then visit http://localhost:8000 in your browser"
log "A log file has been saved to: $LOG_FILE"