Your music, beautifully tracked. All yours. (coming soon) teal.fm
teal-fm atproto
at fix-compose-path 97 lines 2.8 kB view raw
1import { execa } from 'execa'; 2import pc from 'picocolors'; 3import { findWorkspaceRoot } from '../utils/workspace.js'; 4 5export async function diff(commit: string = 'HEAD~1') { 6 const workspaceRoot = findWorkspaceRoot(); 7 8 console.log(pc.blue(`🔍 Showing lexicon changes since ${commit}...`)); 9 10 try { 11 await showLexiconDiff(workspaceRoot, commit); 12 await showGeneratedDiff(workspaceRoot, commit); 13 } catch (error) { 14 console.error(pc.red('❌ Diff failed:'), error instanceof Error ? error.message : String(error)); 15 process.exit(1); 16 } 17} 18 19async function showLexiconDiff(workspaceRoot: string, commit: string) { 20 console.log(pc.cyan(' 📝 Lexicon source changes:')); 21 22 try { 23 const { stdout } = await execa('git', [ 24 'diff', 25 '--name-only', 26 commit, 27 'HEAD', 28 'lexicons/' 29 ], { 30 cwd: workspaceRoot, 31 stdio: 'pipe' 32 }); 33 34 if (stdout.trim()) { 35 console.log(pc.yellow(' Changed files:')); 36 stdout.split('\n').forEach(file => { 37 if (file.trim()) { 38 console.log(pc.gray(` ${file}`)); 39 } 40 }); 41 42 // Show actual diff for lexicon files 43 const { stdout: diffOutput } = await execa('git', [ 44 'diff', 45 commit, 46 'HEAD', 47 'lexicons/' 48 ], { 49 cwd: workspaceRoot, 50 stdio: 'pipe' 51 }); 52 53 if (diffOutput.trim()) { 54 console.log(pc.cyan('\n Detailed changes:')); 55 console.log(diffOutput); 56 } 57 } else { 58 console.log(pc.green(' ✓ No lexicon source changes')); 59 } 60 } catch (error) { 61 console.log(pc.yellow(' ⚠️ Could not check lexicon diff (not a git repo?)')); 62 } 63} 64 65async function showGeneratedDiff(workspaceRoot: string, commit: string) { 66 console.log(pc.cyan('\n 🔄 Generated type changes:')); 67 68 try { 69 const { stdout } = await execa('git', [ 70 'diff', 71 '--name-only', 72 commit, 73 'HEAD', 74 'packages/lexicons/src/types/', 75 'services/types/src/' 76 ], { 77 cwd: workspaceRoot, 78 stdio: 'pipe' 79 }); 80 81 if (stdout.trim()) { 82 console.log(pc.yellow(' Changed generated files:')); 83 stdout.split('\n').forEach(file => { 84 if (file.trim()) { 85 console.log(pc.gray(` ${file}`)); 86 } 87 }); 88 89 console.log(pc.cyan(`\n 💡 Run 'git diff ${commit} HEAD -- packages/lexicons/src/types/' to see TypeScript changes`)); 90 console.log(pc.cyan(` 💡 Run 'git diff ${commit} HEAD -- services/types/src/' to see Rust changes`)); 91 } else { 92 console.log(pc.green(' ✓ No generated type changes')); 93 } 94 } catch (error) { 95 console.log(pc.yellow(' ⚠️ Could not check generated file diff')); 96 } 97}