Added full control over incremental indexing behavior: **CLI Changes:** - Added `--incremental` flag (default: true) - Added `--full` flag to disable incremental mode - Updated interactive prompt to ask about incremental mode **Function Changes:** - Updated buildIndex(force, mode, incremental) signature - Added incremental parameter with default value true - Conditional logic: if incremental=true, skip unchanged repos; else re-index all - Added console logging to show incremental mode status **Workflow Changes:** - Added `incremental` input (boolean, default: true) - Passes incremental setting to buildIndex via environment variable - Defaults to true for scheduled (cron) runs **Usage Examples:** ```bash # CLI - incremental mode (default) ./awesome index # CLI - force full re-index ./awesome index --full # CLI - explicit incremental ./awesome index --incremental # Workflow - incremental (default) gh workflow run build-database.yml # Workflow - full re-index gh workflow run build-database.yml -f incremental=false ``` This makes incremental indexing opt-out instead of hardcoded, giving users full control over indexing behavior. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
147 lines
3.7 KiB
JavaScript
Executable File
147 lines
3.7 KiB
JavaScript
Executable File
#!/usr/bin/env node
|
|
|
|
/**
|
|
* AWESOME - A next-level ground-breaking CLI application
|
|
* for exploring and curating awesome lists from GitHub
|
|
*/
|
|
|
|
const { program } = require('commander');
|
|
const { showBanner } = require('./lib/banner');
|
|
const db = require('./lib/database');
|
|
|
|
// Initialize database
|
|
db.initialize();
|
|
|
|
// Program metadata
|
|
program
|
|
.name('awesome')
|
|
.description('A next-level CLI application for exploring awesome lists')
|
|
.version('1.0.0');
|
|
|
|
// Commands
|
|
program
|
|
.command('index')
|
|
.description('Build or rebuild the index from awesome lists')
|
|
.option('-f, --force', 'Force rebuild, clearing existing data')
|
|
.option('-i, --incremental', 'Incremental mode: only update changed repositories (default: true)')
|
|
.option('--full', 'Full mode: re-index all repositories even if unchanged')
|
|
.action(async (options) => {
|
|
const indexer = require('./lib/indexer');
|
|
// Determine incremental mode: default true unless --full is specified
|
|
const incremental = options.full ? false : (options.incremental !== false);
|
|
await indexer.buildIndex(options.force, null, incremental);
|
|
});
|
|
|
|
program
|
|
.command('search <query>')
|
|
.description('Search the indexed READMEs')
|
|
.option('-l, --limit <number>', 'Limit results', '50')
|
|
.action(async (query, options) => {
|
|
const search = require('./lib/search');
|
|
await search.quickSearch(query, parseInt(options.limit));
|
|
});
|
|
|
|
program
|
|
.command('shell')
|
|
.description('Start interactive shell with search completion')
|
|
.action(async () => {
|
|
const shell = require('./lib/shell');
|
|
await shell.start();
|
|
});
|
|
|
|
program
|
|
.command('browse')
|
|
.description('Browse awesome lists interactively')
|
|
.action(async () => {
|
|
const browser = require('./lib/browser');
|
|
await browser.browse();
|
|
});
|
|
|
|
program
|
|
.command('random')
|
|
.description('Show a random README from the index')
|
|
.action(async () => {
|
|
const random = require('./lib/random');
|
|
await random.showRandom();
|
|
});
|
|
|
|
program
|
|
.command('bookmarks')
|
|
.description('Manage your bookmarks')
|
|
.action(async () => {
|
|
const bookmarks = require('./lib/bookmarks');
|
|
await bookmarks.manage();
|
|
});
|
|
|
|
program
|
|
.command('lists')
|
|
.description('Manage your custom awesome lists')
|
|
.action(async () => {
|
|
const customLists = require('./lib/custom-lists');
|
|
await customLists.manage();
|
|
});
|
|
|
|
program
|
|
.command('history')
|
|
.description('View your reading history')
|
|
.action(async () => {
|
|
const history = require('./lib/history');
|
|
await history.show();
|
|
});
|
|
|
|
program
|
|
.command('stats')
|
|
.description('Show index statistics')
|
|
.action(async () => {
|
|
const stats = require('./lib/stats');
|
|
await stats.show();
|
|
});
|
|
|
|
program
|
|
.command('settings')
|
|
.description('Manage application settings')
|
|
.action(async () => {
|
|
const settings = require('./lib/settings');
|
|
await settings.manage();
|
|
});
|
|
|
|
program
|
|
.command('checkout <repo>')
|
|
.description('Checkout a GitHub repository')
|
|
.option('-d, --directory <dir>', 'Target directory')
|
|
.action(async (repo, options) => {
|
|
const checkout = require('./lib/checkout');
|
|
await checkout.cloneRepository(repo, options.directory);
|
|
});
|
|
|
|
program
|
|
.command('db')
|
|
.description('Download pre-built database from GitHub Actions')
|
|
.action(async () => {
|
|
const dbDownload = require('./lib/db-download');
|
|
await dbDownload.manage();
|
|
});
|
|
|
|
// If no command is provided, show the main menu
|
|
if (process.argv.length === 2) {
|
|
(async () => {
|
|
showBanner();
|
|
const menu = require('./lib/menu');
|
|
await menu.showMainMenu();
|
|
})();
|
|
} else {
|
|
program.parse(process.argv);
|
|
}
|
|
|
|
// Handle graceful shutdown
|
|
process.on('SIGINT', () => {
|
|
console.log('\n\nGoodbye! 👋\n');
|
|
db.close();
|
|
process.exit(0);
|
|
});
|
|
|
|
process.on('SIGTERM', () => {
|
|
db.close();
|
|
process.exit(0);
|
|
});
|