UNPKG

@khala/jira-ai

Version:

Interactive CLI tool for JIRA issue management with Gemini AI

85 lines (75 loc) • 2.45 kB
import { writeFileSync } from 'fs'; /** * Parse command line arguments for dry run mode * @returns {Object} Parsed arguments with dryRun flag */ export function parseCommandLineArgs() { const args = process.argv.slice(2); const isDryRun = args.includes('-d') || args.includes('--dry-run'); return { dryRun: isDryRun, }; } /** * Simulate JIRA update results for dry run mode * @param {Array} issues - Issues to simulate updating * @param {string} actionType - Type of action being simulated * @returns {Array} Simulated update results */ export function simulateJiraUpdates(issues, actionType) { console.log(`\nšŸ” DRY RUN MODE: Simulating ${actionType} updates for ${issues.length} issues...`); const results = issues.map(issue => { console.log(`āœ… [DRY RUN] Would update ${issue.key}`); return { issueKey: issue.key, status: 'success', actionType, confidence: issue.confidence || '100%', dryRun: true, }; }); // Summary console.log(`\nšŸ“Š [DRY RUN] ${actionType} Update Summary:`); console.log(` āœ… Would be successful: ${results.length}`); console.log(` āŒ Would fail: 0`); console.log(` āš ļø Would be skipped: 0`); console.log(` šŸ“‹ Total: ${results.length}`); return results; } /** * Save issues to success.json file for dry run mode * @param {Array} issues - Issues to save * @param {string} actionType - Type of action that was simulated */ export function saveDryRunResults(issues, actionType) { try { const filename = 'static/success.json'; const data = { dryRun: true, actionType, timestamp: new Date().toISOString(), issues: issues, summary: { total: issues.length, successful: issues.length, failed: 0, skipped: 0, }, }; writeFileSync(filename, JSON.stringify(data, null, 2)); console.log(`\nšŸ’¾ [DRY RUN] Results saved to ${filename}`); console.log(`šŸ” Review what would have been updated without making actual changes`); } catch (error) { console.error(`āŒ Error saving dry run results: ${error.message}`); } } /** * Display dry run mode banner */ export function displayDryRunBanner() { console.log('\n' + '='.repeat(60)); console.log('šŸ” DRY RUN MODE ENABLED'); console.log('No actual changes will be made to JIRA'); console.log('All updates will be simulated and logged'); console.log('='.repeat(60)); }