dep-watcher
Version:
Automated dependency update watcher - monitor outdated packages and get email notifications
68 lines (54 loc) • 1.87 kB
JavaScript
const config = require('./src/config');
const DependencyChecker = require('./src/dependency-checker');
const EmailService = require('./src/email-service');
class DependencyWatcher {
constructor() {
this.isShuttingDown = false;
}
/**
* Run dependency check
*/
async check() {
try {
// Reload config to pick up any environment variables set after module load
config.reloadConfig();
// Validate configuration
const configErrors = config.validateConfig();
if (configErrors.length > 0) {
console.error('❌ Configuration errors found:');
configErrors.forEach(error => console.error(` - ${error}`));
console.error('\nPlease fix these issues and restart the application.');
process.exit(1);
}
// Run dependency check
await this.runDependencyCheck();
console.log('✅ Dependency check completed successfully');
} catch (error) {
console.error('❌ Failed to run dependency check:', error.message);
process.exit(1);
}
}
/**
* Run dependency check
*/
async runDependencyCheck() {
const dependencyChecker = new DependencyChecker();
const emailService = new EmailService(config);
// Run dependency check
const results = await dependencyChecker.checkAllProjects(config.projects);
// Send email notification if there are updates
if (results && results.length > 0) {
await emailService.sendNotification(results);
}
}
}
// Start the application
if (require.main === module) {
const watcher = new DependencyWatcher();
watcher.check().catch(error => {
console.error('❌ Failed to run dependency check:', error.message);
process.exit(1);
});
}
module.exports = DependencyWatcher;