同步完整源码 - 2026-05-25

This commit is contained in:
xiaoxue
2026-05-25 01:45:55 +08:00
commit af7cdc0ffd
1581 changed files with 225877 additions and 0 deletions
@@ -0,0 +1,31 @@
#!/usr/bin/env bash
# Function to check if a command exists
check_command() {
if ! command -v $1 &> /dev/null; then
echo "❌ Error: $1 is not installed or not in PATH"
echo "💡 Please run the following command from the repository root:"
if [ "$1" = "ruff" ]; then
echo " uv pip install -r requirements-dev.txt"
elif [ "$1" = "eslint" ] || [ "$1" = "prettier" ]; then
echo " npm install"
fi
return 1
fi
return 0
}
# Check for required commands
echo "🔍 Checking required dependencies..."
check_command "ruff" && check_command "eslint" && check_command "prettier"
DEPS_STATUS=$?
if [ $DEPS_STATUS -eq 0 ]; then
DEPS_MESSAGE="All required dependencies are installed"
echo "✅ $DEPS_MESSAGE"
else
DEPS_MESSAGE="Missing required dependencies"
echo "❌ $DEPS_MESSAGE"
fi
return 0 # Always return success
+40
View File
@@ -0,0 +1,40 @@
#!/usr/bin/env bash
# $1 = Temporary directory path
if [ -z "$1" ]; then
echo "Error: Temporary directory argument missing." >&2
exit 1
fi
TEMP_DIR="$1"
STATUS_FILE="$TEMP_DIR/js_deps_status.txt"
MESSAGE_FILE="$TEMP_DIR/js_deps_message.txt"
JS_DEPS_STATUS=0 # Assume success
FINAL_MESSAGE=""
MISSING_TOOLS=""
# Check dependencies
if ! npx prettier --version &> /dev/null; then
MISSING_TOOLS="Prettier"
JS_DEPS_STATUS=2 # Warning
fi
if ! npx eslint --version &> /dev/null; then
[ -n "$MISSING_TOOLS" ] && MISSING_TOOLS+=" and "
MISSING_TOOLS+="ESLint"
JS_DEPS_STATUS=2 # Warning
fi
if [ $JS_DEPS_STATUS -eq 0 ]; then
FINAL_MESSAGE="JS/TS dependencies (prettier, eslint) found."
else
FINAL_MESSAGE="$MISSING_TOOLS not installed. Run 'npm install'"
fi
# Write results to temporary files
echo "$JS_DEPS_STATUS" > "$STATUS_FILE"
echo "$FINAL_MESSAGE" > "$MESSAGE_FILE"
# Always exit 0
exit 0
@@ -0,0 +1,30 @@
#!/usr/bin/env bash
# $1 = Temporary directory path
if [ -z "$1" ]; then
echo "Error: Temporary directory argument missing." >&2
exit 1
fi
TEMP_DIR="$1"
STATUS_FILE="$TEMP_DIR/python_deps_status.txt"
MESSAGE_FILE="$TEMP_DIR/python_deps_message.txt"
PYTHON_DEPS_STATUS=0 # Assume success
FINAL_MESSAGE=""
# Check for ruff
if ! command -v ruff &> /dev/null; then
PYTHON_DEPS_STATUS=2 # Warning
FINAL_MESSAGE="Ruff not installed. Install with: uv pip install -r requirements-dev.txt"
else
FINAL_MESSAGE="Python dependencies (ruff) found."
fi
# Write results to temporary files
echo "$PYTHON_DEPS_STATUS" > "$STATUS_FILE"
echo "$FINAL_MESSAGE" > "$MESSAGE_FILE"
# Always exit 0
exit 0
+42
View File
@@ -0,0 +1,42 @@
#!/usr/bin/env bash
# $1 = Temporary directory path
if [ -z "$1" ]; then
echo "Error: Temporary directory argument missing." >&2
exit 1
fi
TEMP_DIR="$1"
STATUS_FILE="$TEMP_DIR/unstaged_status.txt"
MESSAGE_FILE="$TEMP_DIR/unstaged_message.txt"
# Initialize status
UNSTAGED_STATUS=0 # Default to success
FINAL_MESSAGE="No unstaged changes detected"
# Check if formatting/fixing introduced unstaged changes to *staged* files
if ! git diff --cached --quiet --exit-code; then
# echo "⚠️ Warning: Staged files were modified by formatters/linters." # Silenced
# echo " Please review the changes before committing."
UNSTAGED_STATUS=2 # Warning
FINAL_MESSAGE="Staged files were modified by hooks"
fi
# Check for *any* new unstaged changes (including untracked maybe? No, git diff doesn't show untracked)
if ! git diff --quiet --exit-code; then
# Only update message if we didn't already detect modified staged files
if [ $UNSTAGED_STATUS -ne 2 ]; then
# echo "⚠️ Warning: Unstaged changes detected after running hooks." # Silenced
# echo " This might indicate issues during formatting or linting."
UNSTAGED_STATUS=2 # Warning
FINAL_MESSAGE="Other unstaged changes detected after hooks"
fi
fi
# Write results to temporary files
echo "$UNSTAGED_STATUS" > "$STATUS_FILE"
echo "$FINAL_MESSAGE" > "$MESSAGE_FILE"
# Always exit 0 from this script
exit 0
+60
View File
@@ -0,0 +1,60 @@
#!/usr/bin/env bash
# Function to get staged JS/TS files anywhere in the repo
get_staged_js_ts_files() {
# Ensure grep returns 0 exit code even if no match found, and echo "" for empty result
git diff --cached --name-only --diff-filter=ACMR | grep -E '\.(js|jsx|ts|tsx)$' || echo ""
}
# Function to run JS/TS checks (using npx for repo-wide application)
run_js_ts_checks() {
local STAGED_JS_TS_FILES=$(get_staged_js_ts_files)
local JS_STATUS=3 # Default to skipped
if [ ! -z "$STAGED_JS_TS_FILES" ]; then
echo "🔍 Running JS/TS checks on staged files:"
echo "$STAGED_JS_TS_FILES"
# Check if prettier is available via npx
if ! npx prettier --version &> /dev/null; then
echo "❌ Error: prettier is not installed"
echo "💡 Please run the following command from the repository root:"
echo " npm install"
JS_STATUS=1
JS_MESSAGE="Prettier is not installed"
else
# Run prettier on staged JS/TS files (paths relative to repo root)
echo "🔍 Formatting staged JS/TS files with prettier..."
# Assumes prettier config is discoverable (e.g., .prettierrc at root)
echo "$STAGED_JS_TS_FILES" | xargs npx prettier --write --ignore-unknown || true
# Check if eslint is available via npx
if ! npx eslint --version &> /dev/null; then
echo "❌ Error: eslint is not installed"
echo "💡 Please run the following command from the repository root:"
echo " npm install"
JS_STATUS=1
JS_MESSAGE="ESLint is not installed"
else
# Run eslint with auto-fix on staged JS/TS files
echo "🔍 Linting and fixing staged JS/TS files with eslint..."
# Assumes eslint config is discoverable (e.g., .eslintrc.js at root)
echo "$STAGED_JS_TS_FILES" | xargs npx eslint --fix || true
# Add back the fixed/formatted files (paths relative to repo root)
echo "✅ Adding fixed/formatted JS/TS files back to staging..."
echo "$STAGED_JS_TS_FILES" | xargs git add
JS_STATUS=0
JS_MESSAGE="JS/TS files formatted and linted"
fi
fi
else
JS_MESSAGE="No staged JS/TS files found"
echo "✅ $JS_MESSAGE"
fi
return 0 # Always return success
}
# Run the checks
run_js_ts_checks
+59
View File
@@ -0,0 +1,59 @@
#!/usr/bin/env bash
# Function to get staged Python files anywhere in the repo
get_python_files() {
# Ensure grep returns 0 exit code even if no match found, and echo "" for empty result
git diff --cached --name-only --diff-filter=ACMR | grep '\.py$' || echo ""
}
# Function to run Python checks (using ruff - assumes ruff is installed and configured)
run_python_checks() {
local STAGED_PYTHON_FILES=$(get_python_files)
local PYTHON_STATUS=3 # Default to skipped
if [ ! -z "$STAGED_PYTHON_FILES" ]; then
echo "🔍 Running Python checks on staged files:"
echo "$STAGED_PYTHON_FILES"
# Check if uvx is available, fallback to ruff
if command -v uvx &> /dev/null; then
RUFF_CMD="uvx ruff"
echo "🔍 Using uvx ruff (no local Python env required)"
elif command -v ruff &> /dev/null; then
RUFF_CMD="ruff"
echo "🔍 Using local ruff installation"
else
echo "❌ Error: Neither uvx nor ruff is installed"
echo "💡 Please install uv (recommended) or run:"
echo " uv pip install -r requirements-dev.txt"
PYTHON_STATUS=1
PYTHON_MESSAGE="Ruff is not installed (install uv or ruff)"
fi
if [ "$PYTHON_STATUS" != "1" ]; then
# Run ruff format on staged Python files (paths relative to repo root)
echo "🔍 Formatting staged Python files with $RUFF_CMD..."
# Pass files directly to ruff; use --force-exclude if necessary based on ruff config
echo "$STAGED_PYTHON_FILES" | xargs $RUFF_CMD format --force-exclude || true
# Run ruff check with auto-fix on staged Python files
echo "🔍 Linting and fixing staged Python files with $RUFF_CMD..."
# Pass files directly to ruff; use --force-exclude if necessary
echo "$STAGED_PYTHON_FILES" | xargs $RUFF_CMD check --fix --force-exclude || true
# Add back the fixed/formatted files (paths relative to repo root)
echo "✅ Adding fixed/formatted Python files back to staging..."
echo "$STAGED_PYTHON_FILES" | xargs git add
PYTHON_STATUS=0
PYTHON_MESSAGE="Python files formatted and linted successfully"
fi
else
PYTHON_MESSAGE="No staged Python files found"
echo "✅ $PYTHON_MESSAGE"
fi
return 0 # Always return success
}
# Run the checks
run_python_checks