mirror of
https://github.com/acedanger/finance.git
synced 2025-12-05 14:40:13 -08:00
expanded dependencies to incldue biomejs and husky, check for compatible node version
This commit is contained in:
@@ -9,6 +9,7 @@ set -o pipefail # Error if any command in a pipe fails
|
||||
# Constants
|
||||
readonly SCRIPT_NAME="$(basename "$0")"
|
||||
readonly WORK_DIR="/home/acedanger/dev/finance"
|
||||
readonly REQUIRED_NODE_VERSION="20.19.0" # Match the version from devcontainer
|
||||
|
||||
# Functions
|
||||
log() {
|
||||
@@ -19,10 +20,39 @@ error() {
|
||||
echo "ERROR: $*" >&2
|
||||
}
|
||||
|
||||
validate_node_version() {
|
||||
local current_version
|
||||
current_version=$(node -v | cut -d 'v' -f 2)
|
||||
if [[ "$current_version" != "$REQUIRED_NODE_VERSION" ]]; then
|
||||
error "Node.js version mismatch. Required: $REQUIRED_NODE_VERSION, Found: $current_version"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
validate_dependencies() {
|
||||
command -v npx >/dev/null || error "npx is not installed" && exit 1
|
||||
command -v docker >/dev/null || error "docker is not installed" && exit 1
|
||||
command -v npm >/dev/null || error "npm is not installed" && exit 1
|
||||
local missing_deps=()
|
||||
|
||||
# Check core dependencies
|
||||
for cmd in npx docker npm node git; do
|
||||
if ! command -v "$cmd" >/dev/null; then
|
||||
missing_deps+=("$cmd")
|
||||
fi
|
||||
done
|
||||
|
||||
# Check for biome in node_modules
|
||||
if [[ ! -f "node_modules/@biomejs/biome/bin/biome" ]]; then
|
||||
missing_deps+=("biome.js")
|
||||
fi
|
||||
|
||||
# Check for husky hooks
|
||||
if [[ ! -f ".husky/pre-commit" ]]; then
|
||||
missing_deps+=("husky pre-commit hook")
|
||||
fi
|
||||
|
||||
if [[ ${#missing_deps[@]} -ne 0 ]]; then
|
||||
error "Missing dependencies: ${missing_deps[*]}"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Main script logic
|
||||
@@ -34,6 +64,7 @@ cd "$WORK_DIR" || {
|
||||
}
|
||||
|
||||
validate_dependencies
|
||||
validate_node_version
|
||||
|
||||
if ! npx prisma migrate reset --force; then
|
||||
error "Prisma migration reset failed"
|
||||
@@ -45,15 +76,25 @@ docker compose down || {
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Clean up generated files and dependencies
|
||||
log "Cleaning up generated files and dependencies..."
|
||||
rm -f package-lock.json
|
||||
[[ -d dist ]] && rm -rf dist || true
|
||||
[[ -d node_modules ]] && rm -rf node_modules || true
|
||||
[[ -d .prisma ]] && rm -rf .prisma || true # Clean Prisma generated files
|
||||
[[ -f prisma/migrations/migration_lock.toml ]] && rm -f prisma/migrations/migration_lock.toml || true
|
||||
|
||||
npm install || {
|
||||
error "Failed to install npm dependencies"
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Verify Husky hooks are installed
|
||||
npm run prepare || {
|
||||
error "Failed to install Husky hooks"
|
||||
exit 1
|
||||
}
|
||||
|
||||
npm run build || {
|
||||
error "Failed to build the project"
|
||||
exit 1
|
||||
|
||||
Reference in New Issue
Block a user