dep-watcher
v2.1.0
Published
Automated dependency update watcher - monitor outdated packages and get email notifications
Downloads
21
Maintainers
Readme
DepWatcher
An automated dependency monitoring tool that checks for outdated packages in your Node.js project and sends detailed email notifications via Gmail.
Features
- 🔍 Single Project Monitoring: Monitor your current project's dependencies
- 📧 Email Notifications: Send detailed HTML email reports with changelog links and severity information
- ⏰ Automated Scheduling: Run checks daily via cron scheduler (configurable)
- 🎯 Smart Categorization: Categorize updates by severity (major, minor, patch)
- 🔗 Rich Information: Include npm links, changelog URLs, and package descriptions
- 🛡️ Error Handling: Graceful error handling with email notifications
- 🚀 Production Ready: Support for both development and production modes
- 📦 Easy Integration: Simple CLI tool that works with any Node.js project
Installation
Global Installation (Recommended)
npm install -g dep-watcherLocal Installation
npm install --save-dev dep-watcherQuick Start
Option 1: Interactive Setup (Recommended)
Install globally:
npm install -g dep-watcherNavigate to your project:
cd /path/to/your/projectRun interactive setup:
dep-watcher setupThis will guide you through the entire configuration process!
Start monitoring:
dep-watcher start
Option 2: Manual Setup
Initialize DepWatcher:
dep-watcher initConfigure Gmail credentials:
dep-watcher config --gmail [email protected] --recipient [email protected]Set up Gmail app password (see Gmail Setup section below)
Set password in .env file:
# Create .env file with your Gmail app password echo "DEPWATCH_GMAIL_PASSWORD=your-app-password" > .envStart monitoring:
dep-watcher start
Configuration
DepWatcher uses a .env file in your project root for configuration.
1. Initialize Configuration
Run dep-watcher init to create the environment file:
dep-watcher initThis creates a .env file with default settings.
2. Configure Environment Variables
Edit the .env file with your Gmail credentials:
# DepWatcher Configuration
[email protected]
DEPWATCH_GMAIL_PASSWORD=your-gmail-app-password
[email protected]3. Interactive Setup (Recommended)
For first-time users, use the interactive setup wizard:
dep-watcher setupThis will guide you through the configuration process and create the .env file automatically.
4. Gmail App Password Setup
Since Gmail requires app-specific passwords for SMTP:
- Go to your Google Account settings
- Navigate to Security → 2-Step Verification (enable if not already)
- Go to App passwords
- Generate a new app password for "Mail"
- Add it to .env file:
DEPWATCH_GMAIL_PASSWORD=your-app-password
5. Schedule Configuration
Set custom schedule in your .env file:
CRON_SCHEDULE=0 9 * * 1-5 # Weekdays at 9 AMCommon cron schedules:
0 9 * * *- Daily at 9 AM (default)0 9 * * 1-5- Weekdays at 9 AM0 9 * * 1- Weekly on Monday at 9 AM0 */6 * * *- Every 6 hours
Usage
CLI Commands
dep-watcher init # Initialize DepWatcher for current project
dep-watcher check # Run dependency check
dep-watcher version # Show version information
dep-watcher help # Show help informationUsage
Initialize DepWatcher
dep-watcher initThis creates a .env file in your project root with default configuration.
Run Dependency Check
dep-watcher checkThis will:
- Check for outdated dependencies
- Send email notification if updates are found
- Exit when complete
Production Deployment
Using GitHub Actions
name: Dependency Check
on:
schedule:
- cron: '0 9 * * *' # Daily at 9 AM
workflow_dispatch:
jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '18'
- run: npm install
- run: dep-watcher check
env:
GMAIL_USER: ${{ secrets.GMAIL_USER }}
DEPWATCH_GMAIL_PASSWORD: ${{ secrets.DEPWATCH_GMAIL_PASSWORD }}
RECIPIENT_EMAIL: ${{ secrets.RECIPIENT_EMAIL }}Using Docker
FROM node:18-alpine
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
CMD ["dep-watcher", "check"]Using PM2
# Install PM2 globally
npm install -g pm2
# Start DepWatcher
pm2 start "dep-watcher check" --name depwatcher
# Save PM2 configuration
pm2 save
pm2 startupManual Testing
Run a dependency check:
dep-watcher checkThis will:
- Check for outdated dependencies in your project
- Display results in the console
- Send email notification if updates are found
Cron Schedule Examples
The schedule uses standard cron syntax:
# Daily at 9:00 AM (default)
dep-watcher config --schedule "0 9 * * *"
# Weekly on Monday at midnight
dep-watcher config --schedule "0 0 * * 1"
# Weekdays at 9:00 AM
dep-watcher config --schedule "0 9 * * 1-5"
# Every 6 hours
dep-watcher config --schedule "0 */6 * * *"
# Twice daily (9 AM and 6 PM)
dep-watcher config --schedule "0 9,18 * * *"Email Report Features
The email reports include:
- Summary Statistics: Total updates, major/minor/patch breakdown
- Project-wise Results: Organized by project with detailed tables
- Package Information: Current vs latest versions, update types, severity
- Direct Links: npm package pages, changelog URLs, homepage links
- Visual Indicators: Color-coded severity badges and update types
- Error Reporting: Clear error messages for failed checks
Project Structure
When you run dep-watcher init, it creates:
your-project/
├── package.json # Your project's dependencies
├── .depwatch.json # DepWatcher configuration
└── ... # Your other project filesThe .depwatch.json file contains:
{
"email": {
"gmail": {
"user": "[email protected]"
},
"recipient": "[email protected]"
},
"schedule": "0 9 * * *",
"environment": "development",
"env": {
"gmailPassword": "DEPWATCH_GMAIL_PASSWORD"
}
}Note: The password field is intentionally omitted for security reasons.
Security
DepWatcher follows security best practices:
Password Storage
- Never stores passwords in config files
- Uses environment variables for sensitive data
- Supports both
GMAIL_APP_PASSWORDandDEPWATCH_GMAIL_PASSWORDenvironment variables
Environment Variables
# Set Gmail app password
export DEPWATCH_GMAIL_PASSWORD="your-app-password"
# Or use the legacy variable name
export GMAIL_APP_PASSWORD="your-app-password"Config File Security
The .depwatch.json file only contains non-sensitive configuration:
{
"email": {
"gmail": {
"user": "[email protected]"
},
"recipient": "[email protected]"
},
"schedule": "0 9 * * *",
"environment": "development"
}Best Practices
- Never commit passwords to version control
- Use environment variables for sensitive data
- Keep your Gmail app password secure
- Regularly rotate your app passwords
Error Handling
DepWatcher includes comprehensive error handling:
- Configuration Validation: Validates all required settings before starting
- Email Configuration Testing: Tests Gmail SMTP connection on startup
- Project Validation: Ensures package.json exists in current directory
- Network Error Handling: Graceful handling of npm registry API failures
- Email Error Notifications: Sends error reports via email when checks fail
Production Deployment
Using PM2 (Recommended)
Install PM2 globally:
npm install -g pm2Start DepWatcher in your project:
cd /path/to/your/project
pm2 start "dep-watcher start" --name "dep-watcher-$(basename $(pwd))"Save PM2 configuration:
pm2 save
pm2 startupUsing systemd
Create a systemd service file /etc/systemd/system/dep-watcher-yourproject.service:
[Unit]
Description=Dependency Watcher for Your Project
After=network.target
[Service]
Type=simple
User=your-user
WorkingDirectory=/path/to/your/project
ExecStart=/usr/bin/dep-watcher start
Restart=always
RestartSec=10
Environment=NODE_ENV=production
[Install]
WantedBy=multi-user.targetEnable and start the service:
sudo systemctl enable dep-watcher-yourproject
sudo systemctl start dep-watcher-yourprojectTroubleshooting
Common Issues
Gmail Authentication Failed
- Ensure 2-Step Verification is enabled
- Use app-specific password, not your regular password
- Check that the email address is correct
Configuration Not Found
- Run
dep-watcher initto create configuration file - Ensure you're in the correct project directory
- Check that
.depwatch.jsonexists
- Run
No Email Received
- Check spam/junk folder
- Verify recipient email address
- Test email configuration manually
Cron Schedule Not Working
- Verify cron syntax is correct
- Check timezone settings
- Ensure the application is running continuously
Debug Mode
Enable debug logging by setting:
DEBUG=dep-watcher:* dep-watcher startExamples
Basic Setup
# Install globally
npm install -g dep-watcher
# Navigate to your project
cd /path/to/your/project
# Run interactive setup (recommended)
dep-watcher setup
# Start monitoring
dep-watcher startManual Setup
# Install globally
npm install -g dep-watcher
# Navigate to your project
cd /path/to/your/project
# Initialize DepWatcher
dep-watcher init
# Configure Gmail
dep-watcher config --gmail [email protected] --recipient [email protected]
# Start monitoring
dep-watcher startAdvanced Configuration
# Set custom schedule (weekdays at 9 AM)
dep-watcher config --schedule "0 9 * * 1-5"
# Set production environment
dep-watcher config --environment production
# Run manual check
dep-watcher checkContributing
- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
License
ISC License - see package.json for details.
Support
For issues and questions:
- Check the troubleshooting section above
- Review the error logs
- Test your configuration manually
- Open an issue on GitHub if needed
