ruvector/scripts/sync-lockfile.sh
rUv 8256656c49 fix: Resolve pre-existing test failures and fix sync script
Test fixes:
- test_version: Updated assertion from "0.1.0" to "0.1.2" to match Cargo.toml
- test_tokenize: Fixed assertion - "the" (3 chars) passes > 2 filter
- test_mode_collapse_detection: Use truly identical vectors for collapse test

Script fix:
- sync-lockfile.sh: Handle missing npm directory gracefully

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-26 17:54:38 +00:00

46 lines
1.3 KiB
Bash
Executable file

#!/bin/bash
# Automatically sync package-lock.json with package.json changes
# Can be used as git hook, CI/CD step, or manual script
set -e
echo "🔍 Checking package-lock.json sync..."
# Change to npm directory (if it exists)
NPM_DIR="$(dirname "$0")/../npm"
if [ ! -d "$NPM_DIR" ]; then
echo "✅ No npm directory found, skipping sync"
exit 0
fi
cd "$NPM_DIR"
# Check if package.json or any workspace package.json changed
CHANGED_PACKAGES=$(git diff --cached --name-only | grep -E 'package\.json$' || true)
if [ -n "$CHANGED_PACKAGES" ]; then
echo "📦 Package.json changes detected:"
echo "$CHANGED_PACKAGES"
echo ""
echo "🔄 Running npm install to sync lock file..."
# Run npm install to update lock file
npm install
# Check if lock file changed
if git diff --name-only | grep -q 'package-lock.json'; then
echo "✅ Lock file updated successfully"
# If running as pre-commit hook, add the lock file
if [ "${GIT_HOOK}" = "pre-commit" ]; then
git add npm/package-lock.json
echo "✅ Lock file staged for commit"
else
echo "⚠️ Lock file modified but not staged"
echo " Run: git add npm/package-lock.json"
fi
else
echo "✅ Lock file already in sync"
fi
else
echo "✅ No package.json changes detected"
fi