gh-legacy
Version:
A powerful GitHub CLI tool for automatic repository ownership transfer to trusted beneficiaries after periods of inactivity
37 lines (31 loc) ⢠1.21 kB
JavaScript
// commands/resendEmail.js
const fs = require('fs');
const path = require('path');
const CONFIG_PATH = path.join(__dirname, '../db.json');
const { sendEmailNotification } = require('../lib/email');
exports.resendEmail = () => {
if (!fs.existsSync(CONFIG_PATH)) {
console.error('ā No configuration found. Run "gh-legacy init" first.');
return;
}
const config = JSON.parse(fs.readFileSync(CONFIG_PATH));
console.log('š§ Resending emails to granted beneficiaries...\n');
let sentCount = 0;
config.beneficiaries.forEach((b, index) => {
if (b.granted && b.githubUsername) {
console.log(`š§ Resending email to ${b.email} for ${b.repo}...`);
try {
sendEmailNotification(b.email, b.repo, b.githubUsername);
sentCount++;
console.log(`ā
Email sent to ${b.email}`);
} catch (error) {
console.error(`ā Failed to send email to ${b.email}:`, error.message);
}
}
});
if (sentCount > 0) {
console.log(`\nā
Successfully resent ${sentCount} email(s) with updated template.`);
} else {
console.log('\nš No granted beneficiaries found to resend emails to.');
}
};