You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@texera.apache.org by yi...@apache.org on 2025/10/13 07:26:27 UTC

(texera) branch feat/add-some-helper-scripts created (now d55c2e6bb7)

This is an automated email from the ASF dual-hosted git repository.

yiconghuang pushed a change to branch feat/add-some-helper-scripts
in repository https://gitbox.apache.org/repos/asf/texera.git


      at d55c2e6bb7 feat: add a script to fix format

This branch includes the following new commits:

     new 3e64e4153f feat: add a script to resolve TEXERA_HOME
     new 7ec4560d79 feat: add a script to do colorful logging with texera headers
     new d55c2e6bb7 feat: add a script to fix format

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



(texera) 03/03: feat: add a script to fix format

Posted by yi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

yiconghuang pushed a commit to branch feat/add-some-helper-scripts
in repository https://gitbox.apache.org/repos/asf/texera.git

commit d55c2e6bb75364059cc9113df982e018dabe0231
Author: Yicong Huang <17...@users.noreply.github.com>
AuthorDate: Mon Oct 13 00:26:16 2025 -0700

    feat: add a script to fix format
---
 bin/fix-format.sh | 110 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 110 insertions(+)

diff --git a/bin/fix-format.sh b/bin/fix-format.sh
new file mode 100755
index 0000000000..f9b256a9ab
--- /dev/null
+++ b/bin/fix-format.sh
@@ -0,0 +1,110 @@
+#!/usr/bin/env bash
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+# -------------------------------------------------------------
+# fix-format.sh
+# -------------------------------------------------------------
+# Runs code formatters for the Texera repository.
+#
+# Usage:
+#   bin/fix-format.sh               # Format all (Scala, Frontend, Python)
+#   bin/fix-format.sh --scala       # Format Scala only
+#   bin/fix-format.sh --frontend    # Format Frontend only
+#   bin/fix-format.sh --python      # Format Python only
+# -------------------------------------------------------------
+
+set -euo pipefail
+
+SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
+
+
+source "$SCRIPT_DIR/utils/texera-logging.sh"
+
+TEXERA_HOME="$(/usr/bin/env bash "$SCRIPT_DIR/utils/resolve-texera-home.sh")"
+if [[ -z "${TEXERA_HOME:-}" ]]; then
+  exit 1
+fi
+
+# --- Key directories ---
+FRONTEND_DIR="$TEXERA_HOME/frontend"
+AMBER_PY_DIR="$TEXERA_HOME/amber/src/main/python"
+
+[[ -d "$FRONTEND_DIR" ]] || { tx_error "Frontend directory not found: $FRONTEND_DIR"; exit 1; }
+[[ -d "$AMBER_PY_DIR"  ]] || { tx_error "Amber Python directory not found: $AMBER_PY_DIR"; exit 1; }
+
+# --- Argument parsing ---
+TARGET="${1:-all}"
+run_scala=false
+run_frontend=false
+run_python=false
+
+case "$TARGET" in
+  --scala)    run_scala=true ;;
+  --frontend) run_frontend=true ;;
+  --python)   run_python=true ;;
+  ""|--all|all) run_scala=true; run_frontend=true; run_python=true ;;
+  *)
+    tx_error "Unknown option: $TARGET"
+    echo "Usage: bin/fix-format.sh [--scala | --frontend | --python | --all]"
+    exit 1
+    ;;
+esac
+
+# --- 1) Scala formatting ---
+if $run_scala; then
+  tx_info "Running sbt scalafmtAll at repo root..."
+  if ! command -v sbt >/dev/null 2>&1; then
+    tx_error "sbt not found. Please install sbt."
+    exit 1
+  fi
+  (
+    cd "$TEXERA_HOME"
+    sbt scalafmtAll
+  )
+  tx_success "Scala formatting completed."
+fi
+
+# --- 2) Frontend formatting ---
+if $run_frontend; then
+  tx_info "Running yarn format:fix in frontend..."
+  if ! command -v yarn >/dev/null 2>&1; then
+    tx_error "yarn not found. Please install Yarn."
+    exit 1
+  fi
+  (
+    cd "$FRONTEND_DIR"
+    yarn format:fix
+  )
+  tx_success "Frontend formatting completed."
+fi
+
+# --- 3) Python formatting ---
+if $run_python; then
+  tx_info "Running black in amber/src/main/python..."
+  if ! command -v black >/dev/null 2>&1; then
+    tx_error "black not found. Install with: pip install black"
+    exit 1
+  fi
+  (
+    cd "$AMBER_PY_DIR"
+    black .
+  )
+  tx_success "Python formatting completed."
+fi
+
+tx_success "✅ Formatting tasks completed successfully!"
\ No newline at end of file


(texera) 02/03: feat: add a script to do colorful logging with texera headers

Posted by yi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

yiconghuang pushed a commit to branch feat/add-some-helper-scripts
in repository https://gitbox.apache.org/repos/asf/texera.git

commit 7ec4560d79cdbb0df61042f75141ac8cf5eda8e0
Author: Yicong Huang <17...@users.noreply.github.com>
AuthorDate: Mon Oct 13 00:26:00 2025 -0700

    feat: add a script to do colorful logging with texera headers
---
 bin/utils/texera-logging.sh | 80 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 80 insertions(+)

diff --git a/bin/utils/texera-logging.sh b/bin/utils/texera-logging.sh
new file mode 100755
index 0000000000..ad0dc9b1d7
--- /dev/null
+++ b/bin/utils/texera-logging.sh
@@ -0,0 +1,80 @@
+#!/usr/bin/env bash
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+# -------------------------------------------------------------
+# texera-logging.sh
+# -------------------------------------------------------------
+# Shared logging utilities for all Texera bash scripts.
+#
+# Features:
+#   • Colored, consistent logs prefixed with "Texera ▶"
+#   • Logs go to STDERR by default (so STDOUT stays clean)
+#   • Easy to override prefix or disable colors
+#
+# Env vars:
+#   TEXERA_LOG_PREFIX="Texera ▸"   # change prefix
+#   NO_COLOR=1                     # disable color
+#   TEXERA_LOG_TO_STDERR=0         # send to STDOUT instead
+# -------------------------------------------------------------
+
+# Prevent direct execution
+if [[ "${BASH_SOURCE[0]}" == "$0" ]]; then
+  printf 'Texera ▶ This file must be sourced, not executed.\n' >&2
+  exit 1
+fi
+
+# --- Color setup ---
+_use_color=true
+if [[ -n "${NO_COLOR:-}" ]]; then
+  _use_color=false
+fi
+
+if $_use_color; then
+  readonly TL_COLOR_BLUE=$'\033[34m'
+  readonly TL_COLOR_GREEN=$'\033[32m'
+  readonly TL_COLOR_YELLOW=$'\033[33m'
+  readonly TL_COLOR_RED=$'\033[31m'
+  readonly TL_COLOR_BOLD=$'\033[1m'
+  readonly TL_COLOR_RESET=$'\033[0m'
+else
+  readonly TL_COLOR_BLUE="" TL_COLOR_GREEN="" TL_COLOR_YELLOW="" TL_COLOR_RED="" TL_COLOR_BOLD="" TL_COLOR_RESET=""
+fi
+
+# --- Prefix & output stream ---
+readonly TEXERA_LOG_PREFIX="${TEXERA_LOG_PREFIX:-Texera ▶}"
+readonly TL_PREFIX="${TL_COLOR_BOLD}${TEXERA_LOG_PREFIX}${TL_COLOR_RESET}"
+readonly _TL_TO_STDERR="${TEXERA_LOG_TO_STDERR:-1}"
+
+# --- Core emitter ---
+_tx_emit() {
+  local _color="$1"; shift
+  local _level="$1"; shift
+  if [[ "$_TL_TO_STDERR" == "1" ]]; then
+    printf '%s %s[%s]%s %s\n' "$TL_PREFIX" "$_color" "$_level" "$TL_COLOR_RESET" "$*" >&2
+  else
+    printf '%s %s[%s]%s %s\n' "$TL_PREFIX" "$_color" "$_level" "$TL_COLOR_RESET" "$*"
+  fi
+}
+
+# --- Public API ---
+tx_info()    { _tx_emit "$TL_COLOR_BLUE"   "INFO" "$*"; }
+tx_success() { _tx_emit "$TL_COLOR_GREEN"  "SUCCESS" "$*"; }
+tx_warn()    { _tx_emit "$TL_COLOR_YELLOW" "WARN" "$*"; }
+tx_error()   { _tx_emit "$TL_COLOR_RED"    "ERROR" "$*"; }
+
+export -f tx_info tx_success tx_warn tx_error
\ No newline at end of file


(texera) 01/03: feat: add a script to resolve TEXERA_HOME

Posted by yi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

yiconghuang pushed a commit to branch feat/add-some-helper-scripts
in repository https://gitbox.apache.org/repos/asf/texera.git

commit 3e64e4153f8bcfb330d08802ac431a5fd2f44bc1
Author: Yicong Huang <17...@users.noreply.github.com>
AuthorDate: Mon Oct 13 00:25:38 2025 -0700

    feat: add a script to resolve TEXERA_HOME
---
 bin/utils/resolve-texera-home.sh | 83 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 83 insertions(+)

diff --git a/bin/utils/resolve-texera-home.sh b/bin/utils/resolve-texera-home.sh
new file mode 100755
index 0000000000..ccc736c7b4
--- /dev/null
+++ b/bin/utils/resolve-texera-home.sh
@@ -0,0 +1,83 @@
+#!/usr/bin/env bash
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+# -------------------------------------------------------------
+# resolve-texera-home.sh
+# -------------------------------------------------------------
+# Determines TEXERA_HOME using the following priority:
+#   1. TEXERA_HOME environment variable (if already set)
+#   2. git repository root (if inside a git repo)
+#   3. parent directory if current dir is 'bin'
+#   4. current working directory (.)
+#
+# Prints the resolved TEXERA_HOME to stdout.
+# Logs human-readable messages via texera-logging.sh.
+#
+# Intended usage:
+#   TEXERA_HOME="$(bin/resolve-texera-home.sh)"
+#
+# Exits with code 1 if resolution fails.
+# -------------------------------------------------------------
+
+set -euo pipefail
+
+SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
+
+# --- Load logging helper ---
+# shellcheck source=bin/texera-logging.sh
+source "$SCRIPT_DIR/texera-logging.sh"
+
+resolve_texera_home() {
+  # 1. TEXERA_HOME environment variable
+  if [[ -n "${TEXERA_HOME:-}" ]]; then
+    tx_info "TEXERA_HOME found in environment: $TEXERA_HOME"
+    echo "$TEXERA_HOME"
+    return 0
+  fi
+
+  # 2. Git repository root (if any)
+  if git -C . rev-parse --show-toplevel >/dev/null 2>&1; then
+    local root
+    root="$(git rev-parse --show-toplevel)"
+    tx_info "TEXERA_HOME resolved via git repository root: $root"
+    echo "$root"
+    return 0
+  fi
+
+  # 3. Parent directory if current folder is 'bin'
+  local cwd cwd_basename
+  cwd="$(pwd)"
+  cwd_basename="$(basename "$cwd")"
+  if [[ "$cwd_basename" == "bin" ]]; then
+    local parent
+    parent="$(dirname "$cwd")"
+    tx_info "TEXERA_HOME resolved as parent of bin/: $parent"
+    echo "$parent"
+    return 0
+  fi
+
+  # 4. Fallback to current working directory
+  tx_warn "Falling back to current working directory as TEXERA_HOME: $cwd"
+  echo "$cwd"
+}
+
+# --- Main execution ---
+if ! resolve_texera_home; then
+  tx_error "Failed to resolve TEXERA_HOME."
+  exit 1
+fi
\ No newline at end of file