init version

This commit is contained in:
Xuwznln
2025-09-02 16:39:44 +08:00
commit 94f0c112e5
41 changed files with 6004 additions and 0 deletions

59
scripts/setup-dev.ps1 Normal file
View File

@@ -0,0 +1,59 @@
Write-Host "[INFO] Setting up MsgCenterPy development environment..." -ForegroundColor Green
# Check if Python is available
try {
$pythonVersion = python --version
Write-Host "[SUCCESS] Found: $pythonVersion" -ForegroundColor Green
} catch {
Write-Host "[ERROR] Python 3 is required but not found in PATH." -ForegroundColor Red
Write-Host "Please install Python 3.10+ and add it to your PATH." -ForegroundColor Yellow
exit 1
}
# Install the package in development mode
Write-Host "[INFO] Installing package in development mode..." -ForegroundColor Blue
pip install -e .[dev]
if ($LASTEXITCODE -ne 0) {
Write-Host "[ERROR] Failed to install package in development mode" -ForegroundColor Red
exit 1
}
# Install pre-commit hooks
Write-Host "[INFO] Installing pre-commit hooks..." -ForegroundColor Blue
pre-commit install
if ($LASTEXITCODE -ne 0) {
Write-Host "[ERROR] Failed to install pre-commit hooks" -ForegroundColor Red
exit 1
}
# Install pre-commit hooks for commit-msg (optional)
Write-Host "[INFO] Installing commit-msg hooks..." -ForegroundColor Blue
pre-commit install --hook-type commit-msg
if ($LASTEXITCODE -ne 0) {
Write-Host "[WARNING] commit-msg hooks installation failed (optional)" -ForegroundColor Yellow
}
# Run pre-commit on all files to check setup
Write-Host "[INFO] Running pre-commit on all files to verify setup..." -ForegroundColor Blue
pre-commit run --all-files
if ($LASTEXITCODE -eq 0) {
Write-Host "[SUCCESS] Pre-commit setup completed successfully!" -ForegroundColor Green
Write-Host ""
Write-Host "[SUCCESS] You're all set! Pre-commit will now run automatically on every commit." -ForegroundColor Green
Write-Host ""
Write-Host "[INFO] Quick commands:" -ForegroundColor Cyan
Write-Host " • Run all hooks manually: pre-commit run --all-files" -ForegroundColor White
Write-Host " • Update hook versions: pre-commit autoupdate" -ForegroundColor White
Write-Host " • Skip hooks for one commit: git commit --no-verify" -ForegroundColor White
Write-Host " • Run tests: pytest" -ForegroundColor White
Write-Host " • Type checking: mypy msgcenterpy" -ForegroundColor White
} else {
Write-Host "[WARNING] Pre-commit found some issues. Please fix them and run 'pre-commit run --all-files' again." -ForegroundColor Yellow
Write-Host "[TIP] Or use 'pre-commit run --all-files --show-diff-on-failure' to see what needs to be fixed." -ForegroundColor Yellow
}
Write-Host ""
Write-Host "[INFO] Integration with CI:" -ForegroundColor Cyan
Write-Host " • CI will run the same pre-commit hooks" -ForegroundColor White
Write-Host " • If you skip pre-commit locally, CI will catch the issues" -ForegroundColor White
Write-Host " • Best practice: Always let pre-commit fix issues before committing" -ForegroundColor White

46
scripts/setup-dev.sh Executable file
View File

@@ -0,0 +1,46 @@
#!/bin/bash
set -e # Exit on any error
echo "[INFO] Setting up MsgCenterPy development environment..."
# Check if Python is available
if ! command -v python3 &> /dev/null; then
echo "[ERROR] Python 3 is required but not installed."
exit 1
fi
# Install the package in development mode
echo "[INFO] Installing package in development mode..."
pip install -e .[dev]
# Install pre-commit hooks
echo "[INFO] Installing pre-commit hooks..."
pre-commit install
# Install pre-commit hooks for commit-msg (optional)
echo "[INFO] Installing commit-msg hooks..."
pre-commit install --hook-type commit-msg || echo "[WARNING] commit-msg hooks installation failed (optional)"
# Run pre-commit on all files to check setup
echo "[INFO] Running pre-commit on all files to verify setup..."
if pre-commit run --all-files; then
echo "[SUCCESS] Pre-commit setup completed successfully!"
echo ""
echo "[SUCCESS] You're all set! Pre-commit will now run automatically on every commit."
echo ""
echo "[INFO] Quick commands:"
echo " • Run all hooks manually: pre-commit run --all-files"
echo " • Update hook versions: pre-commit autoupdate"
echo " • Skip hooks for one commit: git commit --no-verify"
echo " • Run tests: pytest"
echo " • Type checking: mypy msgcenterpy"
else
echo "[WARNING] Pre-commit found some issues. Please fix them and run 'pre-commit run --all-files' again."
echo "[TIP] Or use 'pre-commit run --all-files --show-diff-on-failure' to see what needs to be fixed."
fi
echo ""
echo "[INFO] Integration with CI:"
echo " • CI will run the same pre-commit hooks"
echo " • If you skip pre-commit locally, CI will catch the issues"
echo " • Best practice: Always let pre-commit fix issues before committing"