Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.
TypeScript agentaiai-agentsall-in-onecrmcrm-systememaillinearmcpmessagingnotesnotionofficerustslackslack-alternativestartupstartup-toolstypescriptworkspace
chg(local): restyle just run_local (#3696)
teod9eb5ac5f16b
diff --git a/justfile b/justfileindex 4bb81dca3f..7aa600aef5 100644--- a/justfile+++ b/justfile@@ -61,59 +61,11 @@ docker_up *ARGS:# Run all services locally using docker-compose# Requires .env file (from `just get_environment`) and FusionAuth setup (from `just setup`).# Automatically patches .env with local FusionAuth values before starting services.+# Uses staged output by default; set MACRO_LOCAL_VERBOSE=1 to show command output.run_local *ARGS:#!/usr/bin/env bashset -euo pipefail-- just create_networks- AWS_ACCESS_KEY_ID="${AWS_ACCESS_KEY_ID:-test}" \- AWS_SECRET_ACCESS_KEY="${AWS_SECRET_ACCESS_KEY:-test}" \- AWS_DEFAULT_REGION="${AWS_DEFAULT_REGION:-us-east-1}" \- just setup_localstack- just patch_local_fusionauth_env-- do_build=false- build_processors=false- filtered_args=()- expecting_profile_name=false- for arg in "$@"; do- if [ "$expecting_profile_name" = true ]; then- if [ "$arg" = "processors" ]; then- build_processors=true- fi- expecting_profile_name=false- filtered_args+=("$arg")- continue- fi-- if [ "$arg" = "--build" ]; then- do_build=true- elif [ "$arg" = "--profile" ]; then- expecting_profile_name=true- filtered_args+=("$arg")- elif [ "$arg" = "search_processing_service" ]; then- build_processors=true- filtered_args+=("$arg")- else- filtered_args+=("$arg")- fi- done-- docker compose build rust_services_image-- if [ "$do_build" = true ]; then- docker compose build websocket_service sync_service lexical_service- if [ "$build_processors" = true ]; then- docker compose build search_processing_service- fi- fi-- echo "startup docker compose"- if [ "${#filtered_args[@]}" -gt 0 ]; then- docker compose up "${filtered_args[@]}"- else- docker compose up- fi+ bash scripts/run-local.sh "$@"# Reset and seed deterministic data used by local E2E tests.local-e2e-seed:diff --git a/scripts/lib/stage-ui.sh b/scripts/lib/stage-ui.shnew file mode 100644index 0000000000..af613d4879--- /dev/null+++ b/scripts/lib/stage-ui.sh@@ -0,0 +1,165 @@+#!/usr/bin/env bash++stage_ui_verbose="${MACRO_LOCAL_VERBOSE:-0}"+stage_ui_dry_run="${MACRO_LOCAL_DRY_RUN:-0}"+stage_ui_is_tty=false+stage_ui_current_pid=""+stage_ui_width=48++if [ -t 1 ]; then+ stage_ui_is_tty=true+fi++if [ "$stage_ui_is_tty" = true ] && [ -z "${NO_COLOR:-}" ]; then+ stage_ui_bold="$(printf '\033[1m')"+ stage_ui_dim="$(printf '\033[2m')"+ stage_ui_green="$(printf '\033[32m')"+ stage_ui_red="$(printf '\033[31m')"+ stage_ui_cyan="$(printf '\033[36m')"+ stage_ui_reset="$(printf '\033[0m')"+else+ stage_ui_bold=""+ stage_ui_dim=""+ stage_ui_green=""+ stage_ui_red=""+ stage_ui_cyan=""+ stage_ui_reset=""+fi++stage_ui_cleanup_child() {+ if [ -n "$stage_ui_current_pid" ]; then+ kill "$stage_ui_current_pid" 2>/dev/null || true+ fi+}++stage_ui_init() {+ trap 'stage_ui_cleanup_child; exit 130' INT+ trap 'stage_ui_cleanup_child; exit 143' TERM+}++stage_is_dry_run() {+ [ "$stage_ui_dry_run" = "1" ]+}++stage_elapsed() {+ local start="$1"+ local seconds=$((SECONDS - start))+ if [ "$seconds" -lt 60 ]; then+ printf "%ss" "$seconds"+ else+ printf "%sm%ss" "$((seconds / 60))" "$((seconds % 60))"+ fi+}++stage_section() {+ local label="$1"+ printf "%b[+]%b %s\n" "$stage_ui_green" "$stage_ui_reset" "$label"+}++stage_note() {+ printf "%b%s%b\n" "$stage_ui_dim" "$1" "$stage_ui_reset"+}++stage_print_line() {+ local marker="$1"+ local label="$2"+ local status="$3"+ local marker_color="$4"+ local status_color="$5"++ if [ "$stage_ui_is_tty" = true ]; then+ printf "\r\033[K"+ fi++ printf " %b%s%b %-*s %b%s%b\n" \+ "$marker_color" "$marker" "$stage_ui_reset" \+ "$stage_ui_width" "$label" \+ "$status_color" "$status" "$stage_ui_reset"+}++stage_print_running() {+ local label="$1"+ local marker="$2"++ if [ "$stage_ui_is_tty" = true ]; then+ printf "\r\033[K %b%s%b %-*s %bRunning%b" \+ "$stage_ui_cyan" "$marker" "$stage_ui_reset" \+ "$stage_ui_width" "$label" \+ "$stage_ui_cyan" "$stage_ui_reset"+ else+ stage_print_line "$marker" "$label" "Running" "$stage_ui_cyan" "$stage_ui_cyan"+ fi+}++stage_print_command() {+ local label="$1"+ shift++ printf "%b%s%b" "$stage_ui_bold" "$label" "$stage_ui_reset"+ printf " %q" "$@"+ printf "\n"+}++stage_run() {+ local label="$1"+ shift+ local start="$SECONDS"++ if stage_is_dry_run; then+ stage_print_line "•" "$label" "Dry run" "$stage_ui_dim" "$stage_ui_dim"+ return+ fi++ if [ "$stage_ui_verbose" = "1" ]; then+ stage_print_line "-" "$label" "Running" "$stage_ui_cyan" "$stage_ui_cyan"+ if "$@"; then+ stage_print_line "✓" "$label" "Done $(stage_elapsed "$start")" "$stage_ui_green" "$stage_ui_green"+ return+ fi++ local status=$?+ stage_print_line "✗" "$label" "Failed $(stage_elapsed "$start")" "$stage_ui_red" "$stage_ui_red" >&2+ exit "$status"+ fi++ local log_file+ log_file="$(mktemp "${TMPDIR:-/tmp}/macro-run-local.XXXXXX")"++ "$@" >"$log_file" 2>&1 &+ stage_ui_current_pid="$!"++ local spinner=('-' '\' '|' '/')+ local frame=0+ if [ "$stage_ui_is_tty" = true ]; then+ while kill -0 "$stage_ui_current_pid" 2>/dev/null; do+ stage_print_running "$label" "${spinner[$frame]}"+ frame=$(((frame + 1) % ${#spinner[@]}))+ sleep 0.12+ done+ else+ stage_print_running "$label" "-"+ fi++ set +e+ wait "$stage_ui_current_pid"+ local status=$?+ set -e+ stage_ui_current_pid=""++ if [ "$status" -eq 0 ]; then+ stage_print_line "✓" "$label" "Done $(stage_elapsed "$start")" "$stage_ui_green" "$stage_ui_green"+ rm -f "$log_file"+ return+ fi++ stage_print_line "✗" "$label" "Failed $(stage_elapsed "$start")" "$stage_ui_red" "$stage_ui_red" >&2+ stage_print_command "Command failed:" "$@" >&2++ if [ -s "$log_file" ]; then+ printf "%bOutput:%b\n" "$stage_ui_bold" "$stage_ui_reset" >&2+ sed 's/^/ /' "$log_file" >&2+ fi++ rm -f "$log_file"+ exit "$status"+}diff --git a/scripts/run-local.sh b/scripts/run-local.shnew file mode 100755index 0000000000..8ac0470ab7--- /dev/null+++ b/scripts/run-local.sh@@ -0,0 +1,107 @@+#!/usr/bin/env bash+set -euo pipefail++ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"+cd "$ROOT_DIR"++source "$ROOT_DIR/scripts/lib/stage-ui.sh"+stage_ui_init++do_build=false+build_processors=false+filtered_args=()+compose_cmd=()+local_aws_env=(+ env+ "AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID:-test}"+ "AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY:-test}"+ "AWS_DEFAULT_REGION=${AWS_DEFAULT_REGION:-us-east-1}"+)++parse_args() {+ local expecting_profile_name=false++ for arg in "$@"; do+ if [ "$expecting_profile_name" = true ]; then+ if [ "$arg" = "processors" ]; then+ build_processors=true+ fi+ expecting_profile_name=false+ filtered_args+=("$arg")+ continue+ fi++ case "$arg" in+ --build)+ do_build=true+ ;;+ --profile)+ expecting_profile_name=true+ filtered_args+=("$arg")+ ;;+ search_processing_service)+ build_processors=true+ filtered_args+=("$arg")+ ;;+ *)+ filtered_args+=("$arg")+ ;;+ esac+ done+}++run_local_setup() {+ stage_section "Running local setup"+ stage_note "Set MACRO_LOCAL_VERBOSE=1 to show setup command output."+ if stage_is_dry_run; then+ stage_note "Dry run: stages will be shown but not executed."+ fi+ printf "\n"++ stage_run "Preparing Docker networks" just create_networks+ stage_run "Starting LocalStack" "${local_aws_env[@]}" just start_localstack+ stage_run "Ensuring SQS queues" "${local_aws_env[@]}" just create_local_queues+ stage_run "Ensuring DynamoDB tables" "${local_aws_env[@]}" just create_local_tables+ stage_run "Ensuring S3 buckets" "${local_aws_env[@]}" just create_local_buckets+ stage_run "Configuring S3 notifications" "${local_aws_env[@]}" just configure_document_upload_finalizer_notifications+ stage_run "Patching FusionAuth env" just patch_local_fusionauth_env+}++run_builds() {+ stage_run "Building Rust services image" docker compose build rust_services_image++ if [ "$do_build" != true ]; then+ return+ fi++ stage_run "Building app services" docker compose build websocket_service sync_service lexical_service++ if [ "$build_processors" = true ]; then+ stage_run "Building search processor" docker compose build search_processing_service+ fi+}++compose_command() {+ compose_cmd=(docker compose up)+ if [ "${#filtered_args[@]}" -gt 0 ]; then+ compose_cmd+=("${filtered_args[@]}")+ fi+}++start_compose() {+ printf "\n"+ stage_section "Starting Docker Compose"++ if stage_is_dry_run; then+ stage_print_command "Command:" "${compose_cmd[@]}"+ return+ fi++ exec "${compose_cmd[@]}"+}++parse_args "$@"+run_local_setup+run_builds+compose_command+start_compose