fix: github workflow
This commit is contained in:
120
lib/indexer.js
120
lib/indexer.js
@@ -89,29 +89,42 @@ function isAwesomeList(url, name, description) {
|
||||
}
|
||||
|
||||
// Build the complete index
|
||||
async function buildIndex(force = false) {
|
||||
async function buildIndex(force = false, mode = null) {
|
||||
console.clear();
|
||||
console.log(purpleGold('\n🚀 AWESOME INDEX BUILDER 🚀\n'));
|
||||
|
||||
// Check if running in CI/non-interactive mode
|
||||
const isNonInteractive = process.env.CI === 'true' || mode !== null;
|
||||
|
||||
if (force) {
|
||||
const { confirm } = await inquirer.prompt([
|
||||
{
|
||||
type: 'confirm',
|
||||
name: 'confirm',
|
||||
message: chalk.yellow('⚠️ Force rebuild will clear all indexed data (bookmarks will be preserved). Continue?'),
|
||||
default: false
|
||||
}
|
||||
]);
|
||||
if (isNonInteractive) {
|
||||
// Clear index data without confirmation in CI
|
||||
console.log(chalk.gray('\nClearing existing index...'));
|
||||
const dbInstance = require('./database').getDb();
|
||||
dbInstance.exec('DELETE FROM readmes');
|
||||
dbInstance.exec('DELETE FROM repositories');
|
||||
dbInstance.exec('DELETE FROM awesome_lists');
|
||||
console.log(chalk.green('✓ Index cleared\n'));
|
||||
} else {
|
||||
const { confirm } = await inquirer.prompt([
|
||||
{
|
||||
type: 'confirm',
|
||||
name: 'confirm',
|
||||
message: chalk.yellow('⚠️ Force rebuild will clear all indexed data (bookmarks will be preserved). Continue?'),
|
||||
default: false
|
||||
}
|
||||
]);
|
||||
|
||||
if (!confirm) return;
|
||||
if (!confirm) return;
|
||||
|
||||
// Clear index data (keep bookmarks)
|
||||
console.log(chalk.gray('\nClearing existing index...'));
|
||||
const dbInstance = require('./database').getDb();
|
||||
dbInstance.exec('DELETE FROM readmes');
|
||||
dbInstance.exec('DELETE FROM repositories');
|
||||
dbInstance.exec('DELETE FROM awesome_lists');
|
||||
console.log(chalk.green('✓ Index cleared\n'));
|
||||
// Clear index data (keep bookmarks)
|
||||
console.log(chalk.gray('\nClearing existing index...'));
|
||||
const dbInstance = require('./database').getDb();
|
||||
dbInstance.exec('DELETE FROM readmes');
|
||||
dbInstance.exec('DELETE FROM repositories');
|
||||
dbInstance.exec('DELETE FROM awesome_lists');
|
||||
console.log(chalk.green('✓ Index cleared\n'));
|
||||
}
|
||||
}
|
||||
|
||||
// Fetch main awesome list
|
||||
@@ -132,46 +145,61 @@ async function buildIndex(force = false) {
|
||||
const awesomeLists = parseMarkdownLinks(mainReadme);
|
||||
console.log(chalk.green(`✓ Found ${awesomeLists.length} awesome lists!\n`));
|
||||
|
||||
// Ask user what to index
|
||||
const { indexChoice } = await inquirer.prompt([
|
||||
{
|
||||
type: 'list',
|
||||
name: 'indexChoice',
|
||||
message: 'What would you like to index?',
|
||||
choices: [
|
||||
{ name: '🎯 Index everything (recommended for first run)', value: 'full' },
|
||||
{ name: '📋 Index lists only (metadata, no READMEs)', value: 'lists' },
|
||||
{ name: '🎲 Index a random sample (10 lists)', value: 'sample' },
|
||||
{ name: '🔍 Select specific categories', value: 'select' },
|
||||
{ name: '← Back', value: 'cancel' }
|
||||
]
|
||||
}
|
||||
]);
|
||||
let indexChoice = mode;
|
||||
|
||||
// Ask user what to index (only if interactive)
|
||||
if (!isNonInteractive) {
|
||||
const result = await inquirer.prompt([
|
||||
{
|
||||
type: 'list',
|
||||
name: 'indexChoice',
|
||||
message: 'What would you like to index?',
|
||||
choices: [
|
||||
{ name: '🎯 Index everything (recommended for first run)', value: 'full' },
|
||||
{ name: '📋 Index lists only (metadata, no READMEs)', value: 'lists' },
|
||||
{ name: '🎲 Index a random sample (10 lists)', value: 'sample' },
|
||||
{ name: '🔍 Select specific categories', value: 'select' },
|
||||
{ name: '← Back', value: 'cancel' }
|
||||
]
|
||||
}
|
||||
]);
|
||||
indexChoice = result.indexChoice;
|
||||
}
|
||||
|
||||
if (indexChoice === 'cancel') return;
|
||||
|
||||
// Default to 'full' if no mode specified
|
||||
if (!indexChoice) indexChoice = 'full';
|
||||
|
||||
console.log(chalk.cyan(`Index mode: ${indexChoice}\n`));
|
||||
|
||||
let listsToIndex = awesomeLists;
|
||||
|
||||
if (indexChoice === 'sample') {
|
||||
listsToIndex = awesomeLists.sort(() => 0.5 - Math.random()).slice(0, 10);
|
||||
} else if (indexChoice === 'select') {
|
||||
const categories = [...new Set(awesomeLists.map(l => l.category).filter(Boolean))];
|
||||
const { selectedCategories } = await inquirer.prompt([
|
||||
{
|
||||
type: 'checkbox',
|
||||
name: 'selectedCategories',
|
||||
message: 'Select categories to index:',
|
||||
choices: categories,
|
||||
pageSize: 15
|
||||
if (isNonInteractive) {
|
||||
console.log(chalk.yellow('Select mode not available in non-interactive mode, using full'));
|
||||
indexChoice = 'full';
|
||||
} else {
|
||||
const categories = [...new Set(awesomeLists.map(l => l.category).filter(Boolean))];
|
||||
const { selectedCategories } = await inquirer.prompt([
|
||||
{
|
||||
type: 'checkbox',
|
||||
name: 'selectedCategories',
|
||||
message: 'Select categories to index:',
|
||||
choices: categories,
|
||||
pageSize: 15
|
||||
}
|
||||
]);
|
||||
|
||||
if (selectedCategories.length === 0) {
|
||||
console.log(chalk.yellow('No categories selected'));
|
||||
return;
|
||||
}
|
||||
]);
|
||||
|
||||
if (selectedCategories.length === 0) {
|
||||
console.log(chalk.yellow('No categories selected'));
|
||||
return;
|
||||
listsToIndex = awesomeLists.filter(l => selectedCategories.includes(l.category));
|
||||
}
|
||||
|
||||
listsToIndex = awesomeLists.filter(l => selectedCategories.includes(l.category));
|
||||
}
|
||||
|
||||
console.log(pinkPurple(`\n✨ Starting index of ${listsToIndex.length} awesome lists ✨\n`));
|
||||
|
||||
Reference in New Issue
Block a user