Open source CapCut alternative.
TypeScript
Add log tailing to the Donkey dev runner
David Le271a0bcdded3
diff --git a/apps/Donkey/Sources/DonkeyUI/PointerPromptNotchStatusView.swift b/apps/Donkey/Sources/DonkeyUI/PointerPromptNotchStatusView.swiftindex 4134d140..902edc5b 100644--- a/apps/Donkey/Sources/DonkeyUI/PointerPromptNotchStatusView.swift+++ b/apps/Donkey/Sources/DonkeyUI/PointerPromptNotchStatusView.swift@@ -254,7 +254,7 @@ public struct PointerPromptNotchStatusView: View {expandedUpdateHeader}- VStack(spacing: 0) {+ VStack(spacing: Self.taskListCommandSpacing) {ScrollView(.vertical, showsIndicators: false) {VStack(spacing: 8) {if tasks.isEmpty {@@ -733,6 +733,7 @@ public struct PointerPromptNotchStatusView: View {.delay(0.15)private static let expandedContentDismissAnimation = Animation.easeOut(duration: 0.1)private static let contentInset: CGFloat = 14+ private static let taskListCommandSpacing: CGFloat = 8}private struct TaskArrowMark: View {diff --git a/scripts/run-donkey-dev.sh b/scripts/run-donkey-dev.shindex 32819ece..0aa42a9a 100755--- a/scripts/run-donkey-dev.sh+++ b/scripts/run-donkey-dev.sh@@ -3,6 +3,44 @@ set -euo pipefailROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"APP_DIR="$ROOT_DIR/apps/Donkey"+LOG_SCRIPT="$ROOT_DIR/scripts/tail-donkey-logs.sh"+LOG_PID=""++cleanup() {+ if [ -n "$LOG_PID" ] && kill -0 "$LOG_PID" >/dev/null 2>&1; then+ kill "$LOG_PID" >/dev/null 2>&1 || true+ wait "$LOG_PID" >/dev/null 2>&1 || true+ fi+}++start_logger() {+ if [ "${DONKEY_TAIL_LOGS:-1}" = "0" ]; then+ echo "Skipping Donkey log tail because DONKEY_TAIL_LOGS=0."+ return+ fi++ if [ ! -x "$LOG_SCRIPT" ]; then+ echo "Skipping Donkey log tail because $LOG_SCRIPT is not executable." >&2+ return+ fi++ local log_args=()+ if [ "${DONKEY_LOG_ERRORS_ONLY:-0}" = "1" ]; then+ log_args+=(--errors)+ fi+ if [ "${DONKEY_LOG_DEBUG:-0}" = "1" ]; then+ log_args+=(--debug)+ fi+ if [ -n "${DONKEY_LOG_CONTAINS:-}" ]; then+ log_args+=(--contains "$DONKEY_LOG_CONTAINS")+ fi++ echo "Tailing Donkey logs..."+ "$LOG_SCRIPT" "${log_args[@]}" &+ LOG_PID="$!"+}++trap cleanup EXITecho "Stopping any running Donkey app..."killall Donkey >/dev/null 2>&1 || true@@ -13,4 +51,5 @@ echo "Building Donkey..."swift buildecho "Starting Donkey..."-exec swift run Donkey+start_logger+swift run Donkeydiff --git a/scripts/tail-donkey-logs.sh b/scripts/tail-donkey-logs.shnew file mode 100755index 00000000..844df213--- /dev/null+++ b/scripts/tail-donkey-logs.sh@@ -0,0 +1,159 @@+#!/usr/bin/env bash+set -euo pipefail++PROCESS_NAME="Donkey"+STYLE="compact"+MODE="stream"+LAST_DURATION=""+PID=""+SUBSYSTEM=""+CATEGORY=""+CONTAINS_TEXT=""+ERRORS_ONLY=0+INCLUDE_INFO=1+INCLUDE_DEBUG=0++usage() {+ cat <<'EOF'+Tail Donkey logs from macOS Unified Logging.++Usage:+ scripts/tail-donkey-logs.sh [options]++Options:+ --process NAME Process name to filter. Default: Donkey+ --pid PID Process ID to filter instead of process name.+ --errors Show only error and fault messages.+ --debug Include debug messages as well as default/info logs.+ --no-info Do not include info messages.+ --subsystem NAME Add a subsystem filter.+ --category NAME Add a category filter.+ --contains TEXT Add a message text contains filter.+ --last DURATION Show recent history instead of streaming, e.g. 5m, 1h.+ --style STYLE log(1) style. Default: compact+ -h, --help Show this help.++Examples:+ scripts/tail-donkey-logs.sh+ scripts/tail-donkey-logs.sh --errors+ scripts/tail-donkey-logs.sh --last 10m --errors+ scripts/tail-donkey-logs.sh --pid 88494 --debug+EOF+}++quote_predicate_value() {+ local value="$1"+ value="${value//\\/\\\\}"+ value="${value//\"/\\\"}"+ printf '"%s"' "$value"+}++append_clause() {+ local clause="$1"+ if [ -z "$PREDICATE" ]; then+ PREDICATE="$clause"+ else+ PREDICATE="$PREDICATE AND $clause"+ fi+}++while [ "$#" -gt 0 ]; do+ case "$1" in+ --process)+ PROCESS_NAME="${2:?--process requires a value}"+ shift 2+ ;;+ --pid)+ PID="${2:?--pid requires a value}"+ shift 2+ ;;+ --errors)+ ERRORS_ONLY=1+ shift+ ;;+ --debug)+ INCLUDE_DEBUG=1+ shift+ ;;+ --no-info)+ INCLUDE_INFO=0+ shift+ ;;+ --subsystem)+ SUBSYSTEM="${2:?--subsystem requires a value}"+ shift 2+ ;;+ --category)+ CATEGORY="${2:?--category requires a value}"+ shift 2+ ;;+ --contains)+ CONTAINS_TEXT="${2:?--contains requires a value}"+ shift 2+ ;;+ --last)+ MODE="show"+ LAST_DURATION="${2:?--last requires a duration}"+ shift 2+ ;;+ --style)+ STYLE="${2:?--style requires a value}"+ shift 2+ ;;+ -h|--help)+ usage+ exit 0+ ;;+ *)+ echo "Unknown option: $1" >&2+ usage >&2+ exit 2+ ;;+ esac+done++if [ -n "$PID" ] && ! [[ "$PID" =~ ^[0-9]+$ ]]; then+ echo "--pid must be numeric." >&2+ exit 2+fi++PREDICATE=""+if [ -n "$PID" ]; then+ append_clause "processID == $PID"+else+ append_clause "process == $(quote_predicate_value "$PROCESS_NAME")"+fi++if [ "$ERRORS_ONLY" -eq 1 ]; then+ append_clause "(messageType == error OR messageType == fault)"+fi++if [ -n "$SUBSYSTEM" ]; then+ append_clause "subsystem == $(quote_predicate_value "$SUBSYSTEM")"+fi++if [ -n "$CATEGORY" ]; then+ append_clause "category == $(quote_predicate_value "$CATEGORY")"+fi++if [ -n "$CONTAINS_TEXT" ]; then+ append_clause "eventMessage CONTAINS[c] $(quote_predicate_value "$CONTAINS_TEXT")"+fi++LOG_COMMAND=(/usr/bin/log "$MODE" --style "$STYLE" --predicate "$PREDICATE")++if [ "$MODE" = "show" ]; then+ LOG_COMMAND=(/usr/bin/log show --last "$LAST_DURATION" --style "$STYLE" --predicate "$PREDICATE")+fi++if [ "$INCLUDE_INFO" -eq 1 ]; then+ LOG_COMMAND+=(--info)+fi++if [ "$INCLUDE_DEBUG" -eq 1 ]; then+ LOG_COMMAND+=(--debug)+fi++echo "Predicate: $PREDICATE" >&2+echo "Press Ctrl-C to stop." >&2+exec "${LOG_COMMAND[@]}"