feat: make incremental indexing configurable via CLI and workflow
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>
This commit is contained in:
@@ -89,7 +89,7 @@ function isAwesomeList(url, name, description) {
|
||||
}
|
||||
|
||||
// Build the complete index
|
||||
async function buildIndex(force = false, mode = null) {
|
||||
async function buildIndex(force = false, mode = null, incremental = true) {
|
||||
console.clear();
|
||||
console.log(purpleGold('\n🚀 AWESOME INDEX BUILDER 🚀\n'));
|
||||
|
||||
@@ -146,6 +146,7 @@ async function buildIndex(force = false, mode = null) {
|
||||
console.log(chalk.green(`✓ Found ${awesomeLists.length} awesome lists!\n`));
|
||||
|
||||
let indexChoice = mode;
|
||||
let incrementalChoice = incremental;
|
||||
|
||||
// Ask user what to index (only if interactive)
|
||||
if (!isNonInteractive) {
|
||||
@@ -161,9 +162,19 @@ async function buildIndex(force = false, mode = null) {
|
||||
{ name: '🔍 Select specific categories', value: 'select' },
|
||||
{ name: '← Back', value: 'cancel' }
|
||||
]
|
||||
},
|
||||
{
|
||||
type: 'confirm',
|
||||
name: 'incremental',
|
||||
message: 'Use incremental mode? (only update changed repos, faster)',
|
||||
default: true,
|
||||
when: (answers) => answers.indexChoice === 'full' || answers.indexChoice === 'sample'
|
||||
}
|
||||
]);
|
||||
indexChoice = result.indexChoice;
|
||||
if (result.incremental !== undefined) {
|
||||
incrementalChoice = result.incremental;
|
||||
}
|
||||
}
|
||||
|
||||
if (indexChoice === 'cancel') return;
|
||||
@@ -171,7 +182,12 @@ async function buildIndex(force = false, mode = null) {
|
||||
// Default to 'full' if no mode specified
|
||||
if (!indexChoice) indexChoice = 'full';
|
||||
|
||||
console.log(chalk.cyan(`Index mode: ${indexChoice}\n`));
|
||||
console.log(chalk.cyan(`Index mode: ${indexChoice}`));
|
||||
if (indexChoice === 'full' || indexChoice === 'sample') {
|
||||
console.log(chalk.cyan(`Incremental: ${incrementalChoice ? 'Yes (skip unchanged repos)' : 'No (re-index all)'}\n`));
|
||||
} else {
|
||||
console.log('');
|
||||
}
|
||||
|
||||
let listsToIndex = awesomeLists;
|
||||
|
||||
@@ -274,14 +290,20 @@ async function buildIndex(force = false, mode = null) {
|
||||
// Determine if we need to fetch README
|
||||
let shouldFetchReadme = false;
|
||||
if (indexChoice === 'full' || indexChoice === 'sample') {
|
||||
if (!existingRepo) {
|
||||
// New repo - fetch README
|
||||
shouldFetchReadme = true;
|
||||
} else if (existingRepo.last_commit !== repoInfo.pushedAt) {
|
||||
// Repo updated since last index - fetch README
|
||||
if (incrementalChoice) {
|
||||
// Incremental mode: only fetch if new or changed
|
||||
if (!existingRepo) {
|
||||
// New repo - fetch README
|
||||
shouldFetchReadme = true;
|
||||
} else if (existingRepo.last_commit !== repoInfo.pushedAt) {
|
||||
// Repo updated since last index - fetch README
|
||||
shouldFetchReadme = true;
|
||||
}
|
||||
// else: repo unchanged, skip README fetch
|
||||
} else {
|
||||
// Full re-index mode: always fetch README
|
||||
shouldFetchReadme = true;
|
||||
}
|
||||
// else: repo unchanged, skip README fetch
|
||||
}
|
||||
|
||||
if (shouldFetchReadme) {
|
||||
|
||||
Reference in New Issue
Block a user