feat: criado repositório jhonny-editor no Gitea
criado repositório jhonny-editor no Gitea adicionado script admin/deploy.command com commit automático atualizado admin/DEV-NOTES.md com template limpo Resumo: - 48 arquivos alterados - 26 novos - 19 modificados - 3 removidos 22 files changed, 658 insertions(+), 568 deletions(-) Arquivos: - AGENTS.md - admin/DEV-NOTES.md - admin/OpenCut.command - admin/commit.command - admin/deploy.command - admin/update.command - code/cep-plugin/index.html - code/cep-plugin/main.js - code/cep-plugin/styles.css - code/engine/ARQUITETURA.md - code/engine/arquitetura/README.md - code/engine/gerar_relatorio_timeline.py - code/engine/integracoes/apple_speech/apple_speech_transcriber.swift - code/engine/integracoes/apple_speech/provider_de_transcricao_apple.py - code/engine/integracoes/midia/__init__.py - code/engine/integracoes/whisper/provider_de_transcricao_local.py - code/engine/scanner/__init__.py - code/engine/scanner/coordenacao/__init__.py - code/engine/scanner/descoberta/__init__.py - code/engine/scanner/modelos.py - code/engine/scanner/transcricao_da_timeline.py - code/src/tools/discovery.ts - :memory:.ses - admin/Jhonny.command - admin/inativos/OpenCut.command - admin/inativos/update.command - code/docs/glossario-analise-emocional.md - code/docs/levantamento-apple-vision-e-apple-intelligence.md - code/docs/levantamento-ferramentas-analise-visual-local.md - code/engine/arquitetura/biblioteca-inteligente-de-videos.md - code/engine/executar_scanner.py - code/engine/integracoes/huggingface/ - code/engine/integracoes/midia/extracao_de_metadados.py - code/engine/integracoes/visual/ - code/engine/requirements-visual.txt - code/engine/scanner/configuracao_visual.py - code/engine/scanner/descoberta/descoberta_de_arquivos.py - code/engine/scanner/metadados.py - code/engine/scanner/relatorio_visual.py - code/engine/scanner/retakes/ - code/engine/scanner/visual.py - code/engine/testes/test_analise_visual_local.py - code/engine/testes/test_arquivos_e_metadados.py - code/engine/testes/test_provider_de_transcricao_apple.py - code/relatorios/analise-brools/ - code/relatorios/analise-visual/ - code/relatorios/audio/arquivos/ - code/relatorios/transcricao-timeline.md
This commit is contained in:
+122
-103
@@ -1,128 +1,147 @@
|
||||
#!/bin/zsh
|
||||
# ============================================================
|
||||
# OpenCut Ronald - admin/deploy.command
|
||||
# Jhonny Editor - admin/deploy.command
|
||||
#
|
||||
# DEPLOY: garante o backend OpenCut no ar em http://127.0.0.1:5679
|
||||
# e sobe a ponte de live-updates (WebSocket) que o painel consome.
|
||||
# DEPLOY COMMIT: verifica alterações, documenta e faz push
|
||||
#
|
||||
# E este o script que o painel do Premiere dispara quando pede
|
||||
# "iniciar backend" (via ~/.opencut/launcher.command). Por isso ele
|
||||
# nao pergunta nada e nao mexe no git: roda sozinho e sai.
|
||||
# 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 sobe (ou recupera) o backend
|
||||
# OPENCUT_RESTART=1 admin/deploy.command reinicia o backend atual
|
||||
# OPENCUT_NO_OPEN=1 admin/deploy.command nao abre o navegador
|
||||
# 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)"
|
||||
CODE="$ROOT/code"
|
||||
START_SCRIPT="$CODE/start-opencut.sh"
|
||||
RUNTIME_DIR="$CODE/.opencut-runtime"
|
||||
LOG="$RUNTIME_DIR/server.log"
|
||||
URL="http://127.0.0.1:5679"
|
||||
HEALTH="$URL/health"
|
||||
RESTART="${OPENCUT_RESTART:-0}"
|
||||
ADMIN="$ROOT/admin"
|
||||
NOTES="$ADMIN/DEV-NOTES.md"
|
||||
REMOTE="origin"
|
||||
BRANCH="main"
|
||||
|
||||
notify() { osascript -e "display notification \"$1\" with title \"OpenCut\"" 2>/dev/null || true; }
|
||||
open_ui() { [ "${OPENCUT_NO_OPEN:-0}" = "1" ] || open "$URL" 2>/dev/null || true; }
|
||||
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)"
|
||||
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; }
|
||||
|
||||
server_ok() { curl -s -m 5 "$HEALTH" 2>/dev/null | grep -q '"status":"ok"'; }
|
||||
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"
|
||||
|
||||
stop_opencut_pids() {
|
||||
local signal="$1"
|
||||
local pid
|
||||
for pid in ${(f)PGREP}; do
|
||||
[ -n "$pid" ] && kill "$signal" "$pid" 2>/dev/null || true
|
||||
done
|
||||
}
|
||||
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}"
|
||||
|
||||
# ------------------------------------------------------------
|
||||
# Ponte de live-updates (WebSocket)
|
||||
#
|
||||
# O backend nao sobe a ponte sozinho: ela so existe apos um POST em
|
||||
# /ws/start, e esse endpoint exige o token CSRF que o /health entrega.
|
||||
# Sem este passo o painel abre mostrando "Bridge stopped" e o usuario
|
||||
# precisa clicar em "Start" na mao a cada boot.
|
||||
# 1) Ha o que commitar?
|
||||
# ------------------------------------------------------------
|
||||
start_bridge() {
|
||||
if curl -s -m 5 "$URL/ws/status" 2>/dev/null | grep -q '"running":true'; then
|
||||
echo "-> ponte de live-updates ja ativa"
|
||||
return 0
|
||||
fi
|
||||
local token
|
||||
token="$(curl -s -m 5 -H "Origin: $URL" "$HEALTH" 2>/dev/null \
|
||||
| /usr/bin/python3 -c 'import sys,json
|
||||
try: print(json.load(sys.stdin).get("csrf_token") or "")
|
||||
except Exception: print("")' 2>/dev/null)"
|
||||
if [ -z "$token" ]; then
|
||||
echo "-> Aviso: /health nao devolveu token CSRF; ponte nao iniciada"
|
||||
return 1
|
||||
fi
|
||||
if curl -s -m 10 -X POST "$URL/ws/start" \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "X-OpenCut-Token: $token" \
|
||||
-H "Origin: $URL" -d '{}' 2>/dev/null | grep -q '"running":true'; then
|
||||
echo "-> ponte de live-updates ativa"
|
||||
return 0
|
||||
fi
|
||||
echo "-> Aviso: a ponte de live-updates nao subiu (veja $LOG)"
|
||||
return 1
|
||||
}
|
||||
|
||||
# 1) Ja esta no ar?
|
||||
if server_ok && [ "$RESTART" != "1" ]; then
|
||||
echo "-> backend ja rodando em $URL"
|
||||
start_bridge
|
||||
notify "Backend ja esta rodando em $URL"
|
||||
open_ui
|
||||
exit 0
|
||||
CHANGES="$(git status --porcelain)"
|
||||
if [[ -z "$CHANGES" ]]; then
|
||||
ok "Nenhuma alteracao para commitar."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ "$RESTART" = "1" ]; then
|
||||
echo "-> reinicio solicitado; substituindo o backend atual"
|
||||
say "Alteracoes detectadas:"
|
||||
echo "$CHANGES" | sed 's/^/ /' | head -60
|
||||
echo " ... ($(echo "$CHANGES" | grep -c .) itens)"
|
||||
echo
|
||||
|
||||
# ------------------------------------------------------------
|
||||
# 2) Extrair notas do DEV-NOTES.md
|
||||
# ------------------------------------------------------------
|
||||
MSG_NOTA=""
|
||||
if [[ -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
|
||||
|
||||
# 2) Processo antigo travado? Derruba antes de subir outro.
|
||||
PGREP=$(pgrep -f 'opencut.server' || true)
|
||||
if [ -n "$PGREP" ]; then
|
||||
notify "Backend travado detectado - reiniciando..."
|
||||
echo "Encerrando processo(s) antigo(s): $PGREP"
|
||||
stop_opencut_pids TERM
|
||||
sleep 3
|
||||
PGREP=$(pgrep -f 'opencut.server' || true)
|
||||
[ -n "$PGREP" ] && stop_opencut_pids KILL
|
||||
sleep 1
|
||||
# ------------------------------------------------------------
|
||||
# 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
|
||||
|
||||
# 3) Sobe pelo start-opencut.sh (venv, modelos, ffmpeg e tmp no Merongo)
|
||||
if [ ! -x "$START_SCRIPT" ]; then
|
||||
echo "Erro: $START_SCRIPT nao encontrado ou sem permissao de execucao" >&2
|
||||
notify "Falha: start-opencut.sh ausente"
|
||||
exit 1
|
||||
COMMIT_MSG="feat: $(echo "$BODY" | head -1 | cut -c1-50)
|
||||
|
||||
$BODY
|
||||
|
||||
Resumo:
|
||||
- $TOTAL_FILES arquivos alterados
|
||||
- $NEW_FILES novos
|
||||
- $MODIFIED_FILES modificados
|
||||
- $DELETED_FILES removidos
|
||||
|
||||
$STAT
|
||||
|
||||
Arquivos:
|
||||
$FILES"
|
||||
|
||||
say "Mensagem do commit:"
|
||||
echo "----------------------------------------------"
|
||||
echo "$COMMIT_MSG"
|
||||
echo "----------------------------------------------"
|
||||
echo
|
||||
|
||||
if [[ "${DRY:-0}" = "1" ]]; then
|
||||
say "DRY=1 - nao vou commitar/push."
|
||||
exit 0
|
||||
fi
|
||||
mkdir -p "$RUNTIME_DIR"
|
||||
mkdir -p "/Volumes/Merongo/SISTEMAS/OPENCUT-MEDIA/tmp"
|
||||
nohup "$START_SCRIPT" > "$LOG" 2>&1 &
|
||||
NEW_PID=$!
|
||||
echo "Backend iniciado (PID $NEW_PID). Aguardando health check..."
|
||||
|
||||
# 4) Espera ate 60s pelo health check
|
||||
for i in {1..30}; do
|
||||
if server_ok; then
|
||||
start_bridge
|
||||
notify "Backend pronto em $URL"
|
||||
open_ui
|
||||
exit 0
|
||||
fi
|
||||
if ! kill -0 $NEW_PID 2>/dev/null; then
|
||||
break
|
||||
fi
|
||||
sleep 2
|
||||
done
|
||||
# ------------------------------------------------------------
|
||||
# 5) Commit
|
||||
# ------------------------------------------------------------
|
||||
say "Adicionando arquivos e commitando..."
|
||||
git add -A
|
||||
git commit -m "$COMMIT_MSG" || die "commit falhou"
|
||||
ok "commit criado: $(git rev-parse --short HEAD)"
|
||||
echo
|
||||
|
||||
echo "Falha ao iniciar. Log em $LOG" >&2
|
||||
notify "Falha ao iniciar o backend. Veja $LOG"
|
||||
tail -30 "$LOG"
|
||||
exit 1
|
||||
# ------------------------------------------------------------
|
||||
# 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!"
|
||||
|
||||
Reference in New Issue
Block a user