UNPKG

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
// 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.'); } };