Path: blob/main/extensions/copilot/test/base/cache-cli.ts
13388 views
/*---------------------------------------------------------------------------------------------1* Copyright (c) Microsoft Corporation. All rights reserved.2* Licensed under the MIT License. See License.txt in the project root for license information.3*--------------------------------------------------------------------------------------------*/45import path from 'path';6import { Cache } from './cache';78async function main() {9const args = process.argv.slice(2);1011if (args.length < 1) {12console.log('Usage:');13console.log(' npx tsx cache-cli check - Check if there are any duplicate keys in the databases');14process.exit(1);15}1617const cache = new Cache(path.resolve(__dirname, '..', 'simulation', 'cache'));1819try {20switch (args[0]) {21case 'check': {22const result = await cache.checkDatabase();23if (result.size === 0) {24console.log('✅ No duplicate keys found.');25} else {26console.log('⛔ Duplicate keys found:');27for (const [key, values] of result) {28console.log(` - "${key}" found in: `, values.join(', '));29}30throw new Error('Duplicate keys found in the database.');31}32break;33}34default: {35console.error('Invalid command. Use: check');36process.exit(1);37}38}39} catch (error) {40console.error('⛔ Error:', error);41process.exit(1);42}43}4445// Run main function if this file is executed directly46if (require.main === module) {47main();48}4950