mirror of
https://github.com/yoshiko-pg/difit.git
synced 2026-09-19 05:03:24 +08:00
dd5e6d1b09
* Add untracked file detection with CLI prompt - Add checkUntrackedFiles() function to detect untracked files when viewing working directory changes (commitish = '.') - Prompt user to add files with --intent-to-add to include them in diff - Only activates for working directory diffs, not commit comparisons - Uses simple-git and readline for Git operations and user interaction 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * Refactor CLI logic: Extract untracked files handling into separate functions Extracted handling of untracked files into dedicated functions (handleUntrackedFiles, promptUserToIncludeUntracked) for improved readability. Moved shared logic (findUntrackedFiles, markFilesIntentToAdd, promptUser) to utils.ts. Replaced manual readline handling with readline/promises API for cleaner asynchronous prompting. * Support checking untracked files in tui mode * Improve dev script: Add constants, process cleanup, and documentation - Extract CLI_SERVER_READY_MESSAGE constant for maintainability - Fix resource leak by tracking and killing Vite process on shutdown - Add comments explaining stdout piping rationale and design decisions - Improve graceful shutdown handling for both CLI and Vite processes 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * merge main * Fix git reset command suggestion for untracked files Change from 'git reset --mixed' to 'git reset -- <files>' to specifically unstage only the intent-to-add files rather than all staged changes. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * docs: improve comment writing * chore: remove unused function --------- Co-authored-by: Claude <noreply@anthropic.com>
50 lines
1.3 KiB
JavaScript
Executable File
50 lines
1.3 KiB
JavaScript
Executable File
#!/usr/bin/env node
|
|
import { spawn } from 'child_process';
|
|
|
|
const commitish = process.argv[2] || 'HEAD';
|
|
const CLI_SERVER_READY_MESSAGE = 'ReviewIt server started';
|
|
|
|
console.log('🚀 Starting CLI server...');
|
|
|
|
// Start CLI server
|
|
const cliProcess = spawn('pnpm', ['run', 'dev:cli', commitish, '--no-open'], {
|
|
// Pipe stdout to capture CLI server ready
|
|
stdio: ['inherit', 'pipe', 'inherit'],
|
|
shell: true,
|
|
});
|
|
|
|
// Wait for CLI server to be ready, then start Vite
|
|
let cliReady = false;
|
|
let viteProcess = null;
|
|
|
|
cliProcess.stdout.on('data', (data) => {
|
|
process.stdout.write(data);
|
|
const output = data.toString();
|
|
|
|
// Wait for CLI server before starting Vite to prevent proxy connection errors
|
|
// Uses stdout parsing to keep dev orchestration separate from main CLI logic
|
|
if (!cliReady && output.includes(CLI_SERVER_READY_MESSAGE)) {
|
|
cliReady = true;
|
|
console.log('🎨 Starting Vite dev server...');
|
|
viteProcess = spawn('vite', ['--open'], {
|
|
stdio: 'inherit',
|
|
shell: true,
|
|
});
|
|
}
|
|
});
|
|
|
|
// Handle graceful shutdown
|
|
process.on('SIGINT', () => {
|
|
console.log('\n👋 Shutting down...');
|
|
cliProcess.kill('SIGINT');
|
|
viteProcess?.kill('SIGINT');
|
|
process.exit(0);
|
|
});
|
|
|
|
cliProcess.on('exit', (code) => {
|
|
if (code !== 0) {
|
|
console.error(`CLI server exited with code ${code}`);
|
|
process.exit(code);
|
|
}
|
|
});
|