Repository navigation
Expand file tree
/
Copy pathpack.sh
More file actions
executable file
·64 lines (57 loc) · 1.78 KB
/
Copy pathpack.sh
File metadata and controls
executable file
·64 lines (57 loc) · 1.78 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
#!/usr/bin/env bash
# Build a WordPress.org-ready zip. Staging under reactpress-blog/ so the
# archive root matches the theme slug; pack.sh / docs / CI files stay out.
set -euo pipefail
REPO_ROOT="$(cd "$(dirname "$0")" && pwd)"
THEME_NAME="reactpress-blog"
DIST="$REPO_ROOT/dist"
ZIP="$DIST/${THEME_NAME}.zip"
STAGE="$(mktemp -d)"
STAGE_THEME="$STAGE/$THEME_NAME"
cleanup() {
rm -rf "$STAGE"
}
trap cleanup EXIT
if [[ ! -f "$REPO_ROOT/style.css" || ! -f "$REPO_ROOT/theme.json" ]]; then
echo "Theme files not found at repo root (style.css / theme.json)." >&2
exit 1
fi
mkdir -p "$DIST" "$STAGE_THEME"
rm -f "$ZIP"
# Copy theme files into a slug-named folder for the zip root.
rsync -a \
--exclude '.git/' \
--exclude '.github/' \
--exclude '.DS_Store' \
--exclude 'dist/' \
--exclude '.ci-theme/' \
--exclude '.wp-env.json' \
--exclude '.wp-env/' \
--exclude 'node_modules/' \
--exclude 'pack.sh' \
--exclude 'README.md' \
--exclude 'SUBMIT.md' \
--exclude '.gitignore' \
"$REPO_ROOT/" "$STAGE_THEME/"
(
cd "$STAGE"
zip -r "$ZIP" "$THEME_NAME"
)
echo "Created: $ZIP"
LISTING="$(unzip -l "$ZIP")"
echo "$LISTING" | head -n 40
echo
echo "Sanity checks:"
LEAKAGE_PATTERN='\.sh$|(^|/)SUBMIT\.md$|(^|/)\.gitignore$|(^|/)\.github/|(^|/)\.wp-env(\.json|/)'
if echo "$LISTING" | grep -E "$LEAKAGE_PATTERN" >/dev/null; then
echo "ERROR: package still contains scripts, docs, or development paths" >&2
echo "$LISTING" | grep -E "$LEAKAGE_PATTERN" || true
exit 1
fi
for REQUIRED_FILE in style.css theme.json readme.txt screenshot.png templates/index.html inc/setup.php; do
if ! echo "$LISTING" | grep -F "${THEME_NAME}/${REQUIRED_FILE}" >/dev/null; then
echo "ERROR: package missing ${REQUIRED_FILE}" >&2
exit 1
fi
done
echo "OK: zip root is ${THEME_NAME}/; required files present; no dev-file leakage"