ruvector/scripts/ci-sync-lockfile.sh
rUv 38c79dc4ac 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

38 lines
1.3 KiB
Bash
Executable file

#!/bin/bash
# CI/CD script to auto-fix package-lock.json and create a commit
# Use this in GitHub Actions to automatically fix lock file issues
set -e
echo "🔍 Checking package-lock.json sync for CI/CD..."
cd npm
# Try npm ci first to check if lock file is in sync
if npm ci --dry-run 2>&1 | grep -q "can only install packages when your package.json and package-lock.json"; then
echo "❌ Lock file out of sync - fixing automatically..."
# Update lock file
npm install
# Check if we're in a git repository and have changes
if git diff --quiet npm/package-lock.json; then
echo "✅ Lock file is now in sync (no changes needed)"
else
echo "✅ Lock file updated"
# If running in GitHub Actions, commit and push
if [ -n "$GITHUB_ACTIONS" ]; then
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add npm/package-lock.json
git commit -m "chore: Auto-sync package-lock.json [skip ci]"
git push
echo "✅ Lock file committed and pushed"
else
echo "⚠️ Lock file updated but not committed (not in GitHub Actions)"
fi
fi
else
echo "✅ Lock file is already in sync"
fi