ia_dev/deploy/lib/deploy-log.sh
Nicolas Cantu ecb2811209 ia_dev: analyse agent, SSH scp helpers, deploy log, kogus docs, push-by-script rules
**Motivations:**
- Version the new analyse Cursor agent and keep push-by-script closure rules accurate.
- Improve deploy SSH/SCP reliability for publishing remote lib pairs and transient connection failures.
- Align kogus documentation with current deployment and code standards.

**Root causes:**
- None (incremental tooling and documentation maintenance).

**Correctifs:**
- Minor adjustment in deploy log helper output (staged change).

**Evolutions:**
- Add `.smartIde/agents/analyse.md` for the analyse agent workflow.
- Extend `deploy/lib/ssh.sh` with remote lib pair publish helpers and `scp_copy_retry` / retry wrapper for ProxyJump/transient SCP failures.
- Update `.smartIde/agents/push-by-script.md` (lint closure and workflow notes).
- Update `projects/kogus/docs/Code-Standards.md` and `projects/kogus/docs/Deployment.md`.

**Pages affectées:**
- N/A (ia_dev agents, deploy libs, and project docs only).
2026-04-29 13:20:16 +02:00

36 lines
1.6 KiB
Bash

#!/usr/bin/env bash
# Optional tee of deploy output to a log file under the project root.
# Args: project_root log_to_dir_relative [deploy_env]
# With deploy_env: SITE_CODE|LECOFFRE_SITE_CODE|DEPLOY_SITE_CODE is required — deploy_<env>_<site>_kogus_YYYYMMDD_HHMMSS.log (multisite + .secrets/kogus/<env>/). No basename without site when deploy_env is set.
deploy_script_tee_log_if_requested() {
local project_root="${1:?}"
local log_to_dir="${2:-}"
local deploy_env="${3:-}"
if [[ -z "$log_to_dir" ]]; then
return 0
fi
local _lecoffre_deploy_log_fn="${project_root}/deploy/scripts_v2/_lib/deploy-log-filename.sh"
if [[ ! -f "$_lecoffre_deploy_log_fn" ]]; then
echo "[deploy-log] missing shared helper (expected LeCoffre repo layout): ${_lecoffre_deploy_log_fn}" >&2
return 1
fi
# shellcheck source=/dev/null
source "$_lecoffre_deploy_log_fn"
mkdir -p "${project_root}/${log_to_dir}"
local log_file
log_file="$(lecoffre_deploy_log_file_path_for_tee "$project_root" "$log_to_dir" "${deploy_env:-}")"
{
printf '%s\n' "=== LeCoffre deploy log ==="
lecoffre_deploy_log_tee_header_metadata_line "$project_root" "${deploy_env:-}"
} >"$log_file"
_IA_DEV_DEPLOY_LOG="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
if [[ -f "${_IA_DEV_DEPLOY_LOG}/lib/smart_ide_logs.sh" ]]; then
# shellcheck source=../../lib/smart_ide_logs.sh
SMART_IDE_LOG_IA_DEV_ROOT="$_IA_DEV_DEPLOY_LOG" source "${_IA_DEV_DEPLOY_LOG}/lib/smart_ide_logs.sh"
smart_ide_log_event "deploy_script_tee_log project_root=${project_root} log_file=${log_file}"
fi
exec > >(tee -a "$log_file")
info "[deploy] Teeing output to ${log_file}"
}