Files
archicratie-edition/scripts/clean-macos-artifacts.sh
archicratia 60d88939b0
All checks were successful
CI / build-and-anchors (push) Successful in 1m25s
SMOKE / smoke (push) Successful in 11s
CI / build-and-anchors (pull_request) Successful in 1m20s
Seed from NAS prod snapshot 20260130-190531
2026-01-31 10:51:38 +00:00

76 lines
2.0 KiB
Bash
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/bin/sh
set -eu
ROOT="$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd)"
MODE="${1:-}"
if [ "$MODE" = "--help" ] || [ "$MODE" = "-h" ]; then
echo "Usage:"
echo " $0 # DRY-RUN (liste ce qui serait supprimé)"
echo " $0 --apply # supprime réellement"
exit 0
fi
if [ "$MODE" = "--apply" ]; then
DO_DELETE=1
echo "[clean-macos] MODE=APPLY (suppression réelle)"
else
DO_DELETE=0
echo "[clean-macos] MODE=DRY-RUN (aucune suppression)"
echo " Passe --apply pour supprimer réellement."
fi
cd "$ROOT"
# Conventions Mac à purger :
# - .DS_Store
# - fichiers AppleDouble : ._*
# - dossiers darchives : __MACOSX, PaxHeader
# Attention : on évite .git/, node_modules/, dist/
echo ""
echo "[clean-macos] Recherche dartefacts… (hors .git/, node_modules/, dist/)"
# Liste des cibles (robuste BusyBox : pas de -print0/-0)
find . \
\( -path "./.git" -o -path "./.git/*" -o -path "./node_modules" -o -path "./node_modules/*" -o -path "./dist" -o -path "./dist/*" \) -prune -o \
\( -name ".DS_Store" -o -name "._*" -o -name "__MACOSX" -o -name "PaxHeader" \) \
-print > /tmp/macos_artifacts.$$ || true
COUNT="$(wc -l < /tmp/macos_artifacts.$$ | tr -d ' ')"
if [ "${COUNT:-0}" = "0" ]; then
echo "[clean-macos] OK: aucun artefact détecté."
rm -f /tmp/macos_artifacts.$$
exit 0
fi
echo "[clean-macos] Trouvé: $COUNT"
sed 's|^\./||' /tmp/macos_artifacts.$$ | head -n 200
if [ "$COUNT" -gt 200 ]; then
echo "[clean-macos] … (liste tronquée à 200)"
fi
if [ "$DO_DELETE" -ne 1 ]; then
echo ""
echo "[clean-macos] DRY-RUN terminé. Pour supprimer:"
echo " $0 --apply"
rm -f /tmp/macos_artifacts.$$
exit 0
fi
echo ""
echo "[clean-macos] Suppression…"
# Suppression : fichiers + dossiers (si dossier, rm -rf)
# (on re-lit la liste pour éviter de re-run find)
while IFS= read -r p; do
[ -z "$p" ] && continue
if [ -d "$p" ]; then
rm -rf "$p"
else
rm -f "$p"
fi
done < /tmp/macos_artifacts.$$
rm -f /tmp/macos_artifacts.$$
echo "[clean-macos] OK: suppression terminée."