- destacado no deploy o resumo que será gravado na mensagem do commit Resumo: - 8 arquivos alterados - 1 novos - 7 modificados - 0 removidos 7 files changed, 143 insertions(+), 11 deletions(-) Arquivos: - .jhonny/analises.db - admin/deploy.command - code/engine/executar_scanner.py - code/engine/integracoes/midia/__init__.py - code/engine/integracoes/visual/apple_vision.py - code/engine/scanner/configuracao_visual.py - code/engine/scanner/visual.py - code/engine/integracoes/midia/compactador_de_proxy.py
162 lines
5.1 KiB
Bash
Executable File
162 lines
5.1 KiB
Bash
Executable File
#!/bin/zsh
|
|
# ============================================================
|
|
# Jhonny Editor - admin/deploy.command
|
|
#
|
|
# DEPLOY COMMIT: verifica alterações, documenta e faz push
|
|
#
|
|
# Fluxo:
|
|
# 1. Verifica se há alterações no repositório
|
|
# 2. Lê as notas do admin/DEV-NOTES.md
|
|
# 3. Monta mensagem de commit descritiva
|
|
# 4. Faz commit e push automático
|
|
#
|
|
# Uso:
|
|
# admin/deploy.command commit + push interativo
|
|
# AUTO=1 admin/deploy.command commit + push automático
|
|
# DRY=1 admin/deploy.command mostra plano sem executar
|
|
# ============================================================
|
|
set -u
|
|
umask 077
|
|
|
|
ROOT="$(cd "$(dirname "$0")/.." && pwd -P)"
|
|
ADMIN="$ROOT/admin"
|
|
NOTES="$ADMIN/DEV-NOTES.md"
|
|
COMMIT_DETAILS="$ADMIN/COMMIT-DETAILS.md"
|
|
REMOTE="origin"
|
|
BRANCH="main"
|
|
|
|
GRN="$(tput setaf 2 2>/dev/null)"; YLW="$(tput setaf 3 2>/dev/null)"
|
|
RD="$(tput setaf 1 2>/dev/null)"; BLU="$(tput setaf 4 2>/dev/null)"
|
|
BD="$(tput bold 2>/dev/null)"
|
|
NC="$(tput sgr0 2>/dev/null)"
|
|
say() { echo "${BLU}== ${NC}$*"; }
|
|
ok() { echo "${GRN}-> OK ${NC}$*"; }
|
|
warn() { echo "${YLW}-> Aviso: ${NC}$*"; }
|
|
die() { echo "${RD}-> Erro: ${NC}$*" >&2; exit 1; }
|
|
|
|
cd "$ROOT" || die "nao consegui entrar em $ROOT"
|
|
[[ -d .git ]] || die "nao e um repositorio git em $ROOT"
|
|
git remote get-url "$REMOTE" >/dev/null 2>&1 || die "remote '$REMOTE' nao configurado"
|
|
|
|
echo "${BLU}============================================================${NC}"
|
|
say "Jhonny Editor - Deploy com Commit Automático"
|
|
say "repositorio: $(git remote get-url "$REMOTE")"
|
|
say "branch: $(git branch --show-current)"
|
|
echo "${BLU}============================================================${NC}"
|
|
|
|
# ------------------------------------------------------------
|
|
# 1) Ha o que commitar?
|
|
# ------------------------------------------------------------
|
|
CHANGES="$(git status --porcelain)"
|
|
if [[ -z "$CHANGES" ]]; then
|
|
ok "Nenhuma alteracao para commitar."
|
|
exit 0
|
|
fi
|
|
|
|
say "Alteracoes detectadas:"
|
|
echo "$CHANGES" | sed 's/^/ /' | head -60
|
|
echo " ... ($(echo "$CHANGES" | grep -c .) itens)"
|
|
echo
|
|
|
|
# ------------------------------------------------------------
|
|
# 2) Extrair detalhes preparados pelo agente
|
|
# ------------------------------------------------------------
|
|
MSG_NOTA=""
|
|
if [[ -f "$COMMIT_DETAILS" && -s "$COMMIT_DETAILS" ]]; then
|
|
MSG_NOTA="$(sed 's/^[[:space:]]*//; s/[[:space:]]*$//' "$COMMIT_DETAILS" \
|
|
| grep -v '^$' \
|
|
| grep -v '^<!--' \
|
|
| grep -v '^-->' || true)"
|
|
fi
|
|
if [[ -z "$MSG_NOTA" && -f "$NOTES" && -s "$NOTES" ]]; then
|
|
MSG_NOTA="$(awk '
|
|
/^## NOVO NESTE LOTE/ {f=1; next}
|
|
/^## / && f {exit}
|
|
f
|
|
' "$NOTES" 2>/dev/null \
|
|
| sed 's/^[[:space:]]*//; s/[[:space:]]*$//' \
|
|
| grep -v '^$' \
|
|
| awk '/^<!--/{c=1;next} /-->/&&c{c=0;next} c{next} {print}' \
|
|
| sed 's/^[-*] //' \
|
|
| grep -v '(_vazio' || true)"
|
|
fi
|
|
|
|
# ------------------------------------------------------------
|
|
# 3) Montar estatísticas
|
|
# ------------------------------------------------------------
|
|
FILES="$(git status --porcelain | sed 's/^.../ - /' | head -80)"
|
|
STAT="$(git diff --stat HEAD | tail -1)"
|
|
TOTAL_FILES=$(echo "$CHANGES" | grep -c .)
|
|
NEW_FILES=$(echo "$CHANGES" | grep -c '^??' || true)
|
|
MODIFIED_FILES=$(echo "$CHANGES" | grep -c '^ M\|^M' || true)
|
|
DELETED_FILES=$(echo "$CHANGES" | grep -c '^ D\|^D' || true)
|
|
|
|
# ------------------------------------------------------------
|
|
# 4) Montar mensagem do commit
|
|
# ------------------------------------------------------------
|
|
if [[ -n "$MSG_NOTA" ]]; then
|
|
BODY="$MSG_NOTA"
|
|
else
|
|
BODY="(sem nota em DEV-NOTES.md)"
|
|
fi
|
|
|
|
ASSUNTO="$(echo "$BODY" | head -1 | sed 's/^[[:space:]]*[-*][[:space:]]*//' | cut -c1-60)"
|
|
COMMIT_MSG="feat: $ASSUNTO
|
|
|
|
$BODY
|
|
|
|
Resumo:
|
|
- $TOTAL_FILES arquivos alterados
|
|
- $NEW_FILES novos
|
|
- $MODIFIED_FILES modificados
|
|
- $DELETED_FILES removidos
|
|
|
|
$STAT
|
|
|
|
Arquivos:
|
|
$FILES"
|
|
|
|
echo
|
|
echo "${BD}${YLW}============================================================${NC}"
|
|
echo "${BD}${YLW} MENSAGEM QUE SERÁ GRAVADA NO COMMIT${NC}"
|
|
echo "${BD}${YLW}============================================================${NC}"
|
|
echo "$COMMIT_MSG"
|
|
echo "${BD}${YLW}============================================================${NC}"
|
|
echo
|
|
|
|
if [[ "${DRY:-0}" = "1" ]]; then
|
|
say "DRY=1 - nao vou commitar/push."
|
|
exit 0
|
|
fi
|
|
|
|
# ------------------------------------------------------------
|
|
# 5) Commit
|
|
# ------------------------------------------------------------
|
|
say "Adicionando arquivos e commitando..."
|
|
git add -A
|
|
git commit -m "$COMMIT_MSG" || die "commit falhou"
|
|
if [[ -f "$COMMIT_DETAILS" ]]; then
|
|
: > "$COMMIT_DETAILS"
|
|
fi
|
|
ok "commit criado: $(git rev-parse --short HEAD)"
|
|
echo
|
|
|
|
# ------------------------------------------------------------
|
|
# 6) Push (automático ou interativo)
|
|
# ------------------------------------------------------------
|
|
if [[ "${AUTO:-0}" = "1" ]]; then
|
|
RESP="s"
|
|
else
|
|
printf "Enviar para '%s' agora? [s/N] " "$REMOTE"
|
|
read -r RESP
|
|
fi
|
|
|
|
case "$RESP" in
|
|
[sS]|[sS][iI][mM]|[yY]|[yY][eE][sS]) ;;
|
|
*) warn "push cancelado - commit local salvo"; exit 0 ;;
|
|
esac
|
|
|
|
say "Fazendo push para '$REMOTE'..."
|
|
git push "$REMOTE" "$BRANCH" || die "push falhou"
|
|
ok "push concluido - deploy finalizado!"
|