project-indexer
Version:
Local project indexer with browser trigger support
98 lines (81 loc) • 3.3 kB
JavaScript
// import dotenv from 'dotenv';
// import {DEFAULT_EXTENSIONS} from './fileValidator.js';
// import {runIndexing} from './projectIndexer.js';
// dotenv.config();
// /**
// * Main function to run from command line
// */
// async function main() {
// try {
// // Get command line arguments
// const args = parseCommandLineArgs();
// // Check for required environment variables if not provided as arguments
// const token = args.token || process.env.API_TOKEN;
// const serverUrl = args.serverUrl || process.env.SERVER_URL;
// const deviceId = args.deviceId || process.env.DEVICE_ID;
// if (!token) {
// console.error('API token is required. Provide it as an argument or set API_TOKEN environment variable.');
// process.exit(1);
// }
// if (!serverUrl) {
// console.error('Server URL is required. Provide it as an argument or set SERVER_URL environment variable.');
// process.exit(1);
// }
// if (!deviceId) {
// console.error('Device ID is required. Provide it as an argument or set DEVICE_ID environment variable.');
// process.exit(1);
// }
// // Set up options for indexing
// const options = {
// projectPath: args.projectPath || process.cwd(),
// serverUrl,
// token,
// deviceId,
// projectId: args.projectId,
// projectName: args.projectName,
// extensions: args.extensions ? args.extensions.split(',') : DEFAULT_EXTENSIONS
// };
// console.log('Starting project indexing with the following options:');
// console.log(`- Project path: ${options.projectPath}`);
// console.log(`- Server URL: ${options.serverUrl}`);
// console.log(`- Project ID: ${options.projectId || '(will be created)'}`);
// console.log(`- Project name: ${options.projectName || '(not specified)'}`);
// console.log(`- Included extensions: ${options.extensions.length} extensions`);
// // Run the indexing process
// const result = await runIndexing(options);
// if (result.success) {
// console.log(`[Success] Project indexed successfully with ID: ${result.projectId}`);
// process.exit(0);
// } else {
// console.error(`[Failed] ${result.message}`);
// process.exit(1);
// }
// } catch (error) {
// console.error(`[Error] ${error.message}`);
// process.exit(1);
// }
// }
// /**
// * Parse command line arguments
// * @returns {Object} - Parsed arguments
// */
// function parseCommandLineArgs() {
// const args = {};
// const argv = process.argv.slice(2);
// for (let i = 0; i < argv.length; i++) {
// const arg = argv[i];
// if (arg.startsWith('--')) {
// const key = arg.slice(2);
// const value = argv[i + 1] && !argv[i + 1].startsWith('--') ? argv[++i] : true;
// args[key] = value;
// }
// }
// return args;
// }
// // Run the main function if this file is executed directly
// if (require.main === module) {
// main();
// }
// // Export functions for use in other files
// export {DEFAULT_EXTENSIONS, getFocusedFiles} from './fileValidator.js';
// export {runIndexing} from './projectIndexer.js';