ruvector/scripts/sync-lockfile.sh
rUv 9108adeeb5 feat: Add automated package-lock.json sync tooling
 New Features:
- sync-lockfile.sh: Auto-sync lock file with package.json changes
- install-hooks.sh: Install git pre-commit hooks
- ci-sync-lockfile.sh: CI/CD auto-fix for lock file issues
- Pre-commit hook: Automatically runs on git commit
- validate-lockfile.yml: GitHub Actions workflow for validation

📚 Documentation:
- CONTRIBUTING.md: Complete contribution guide
- scripts/README.md: Automation scripts documentation

🎯 Benefits:
- Prevents "lock file out of sync" CI/CD failures
- Automatic staging of lock file changes
- Zero manual intervention needed
- Works with any workflow (hooks, manual, CI/CD)

🔧 Usage:
1. Install hooks: ./scripts/install-hooks.sh
2. Add dependencies normally
3. Commit - hook auto-syncs lock file
4. CI validates automatically

Resolves the recurring package-lock.json sync issues.
2025-11-25 21:24:14 +00:00

41 lines
1.2 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
cd "$(dirname "$0")/../npm"
# 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