Check Command

Check if a specific package has changed in your dependencies. cli-check.png

Usage

whatsdiff check <package-name> [options]

Arguments

  • <package-name> - The name of the package to check (e.g., laravel/framework)

Options

The check command supports filtering options to check for specific types of changes:

  • --has-any-change - Check if package has any change (default behavior)
  • --is-updated - Check if package was updated to a newer version
  • --is-downgraded - Check if package was downgraded to an older version
  • --is-removed - Check if package was removed from dependencies
  • --is-added - Check if package was added to dependencies

These options are particularly useful in CI/CD pipelines where you need to verify specific changes or fail builds based on dependency status.

Examples

Basic Check

Check if any changes occurred to a package:

whatsdiff check laravel/framework

Verify Package Was Updated

Useful for confirming security patches were applied:

whatsdiff check laravel/framework --is-updated

Verify Package Was Added

Confirm a new dependency was installed:

whatsdiff check livewire/livewire --is-added

Check if Package Was Removed

Verify a package was successfully removed:

whatsdiff check deprecated/package --is-removed

Output Types and Exit Codes

The check command is designed for automation and returns simple boolean outputs:

Output Types

Success (condition met):

$ whatsdiff check laravel/framework --is-updated
true

Failure (condition not met):

$ whatsdiff check vite --is-updated
false

Error (command failed):

$ whatsdiff check package --is-added
Error: Not in a git repository or git command failed

Quiet mode (no output):

$ whatsdiff check symfony/console --is-updated --quiet
# No output, check exit code only

Exit Codes

The command uses standard exit codes for easy integration with scripts:

Exit Code Status Description
0 SUCCESS Check condition is true (package matches the check)
1 FAILURE Check condition is false (package doesn't match)
2 ERROR Command error (not in git repo, invalid input, etc.)

Use Cases

1. Deployment Script - Conditional Service Restart

Restart services only when their packages are updated, avoiding unnecessary downtime:

git pull origin main
composer install --no-dev --optimize-autoloader

# Restart Laravel Pulse only if it was updated
if whatsdiff check laravel/pulse --is-updated --quiet; then
    echo "✓ Laravel Pulse was updated, restarting..."
    php artisan pulse:restart
else
    echo "→ Laravel Pulse unchanged, skipping restart"
fi

echo "Deployment complete!"

This prevents unnecessary service restarts and clearly logs what was changed.

2. CI/CD - Block Deployment if Security Package Removed

Prevent merging or deploying code that removes critical security packages:

name: Security Check

on: [pull_request, push]

jobs:
  security-check:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
        with:
          fetch-depth: 0  # Need full history for whatsdiff

      - name: Install whatsdiff
        run: composer global require whatsdiff/whatsdiff

      - name: Ensure security advisories package present
        run: |
          if whatsdiff check roave/security-advisories --is-removed --quiet; then
            echo "❌ roave/security-advisories was removed!"
            echo "This package prevents installing dependencies with known vulnerabilities."
            echo "Blocking deployment for security reasons."
            exit 1
          fi
          echo "✓ Security advisories package still present"

The roave/security-advisories package is a meta-package that prevents installing any package versions with known security vulnerabilities. Removing it could expose your application to security risks.

Related Commands

  • Use analyse to see all changes
  • Use between to compare across commits