@realeng/maestro
Version:
Easy setup and management for local MCP servers
137 lines (135 loc) • 6.09 kB
JavaScript
;
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
var ownKeys = function(o) {
ownKeys = Object.getOwnPropertyNames || function (o) {
var ar = [];
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
return ar;
};
return ownKeys(o);
};
return function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
__setModuleDefault(result, mod);
return result;
};
})();
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.resetCommand = resetCommand;
const chalk_1 = __importDefault(require("chalk"));
const inquirer_1 = __importDefault(require("inquirer"));
const fs = __importStar(require("fs"));
const path = __importStar(require("path"));
const os = __importStar(require("os"));
const init_1 = require("./init");
const CONFIG_DIR = path.join(os.homedir(), '.maestro');
const CONFIG_FILE = path.join(CONFIG_DIR, 'config.json');
async function resetCommand() {
// Check if config exists
if (!fs.existsSync(CONFIG_FILE)) {
console.log(chalk_1.default.yellow('\n⚠️ No configuration found to reset.'));
console.log(chalk_1.default.gray('Run "maestro init" to set up your first server.'));
return;
}
// Show warning with ASCII art
console.log(chalk_1.default.red(`
⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️
██████╗ ███████╗███████╗███████╗████████╗
██╔══██╗██╔════╝██╔════╝██╔════╝╚══██╔══╝
██████╔╝█████╗ ███████╗█████╗ ██║
██╔══██╗██╔══╝ ╚════██║██╔══╝ ██║
██║ ██║███████╗███████║███████╗ ██║
╚═╝ ╚═╝╚══════╝╚══════╝╚══════╝ ╚═╝
⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️
`));
console.log(chalk_1.default.red.bold('\n This will DELETE all your MCP server configurations!'));
console.log(chalk_1.default.yellow(' Including API keys, tokens, and settings.\n'));
// First confirmation
const { confirmReset } = await inquirer_1.default.prompt([
{
type: 'confirm',
name: 'confirmReset',
message: 'Are you sure you want to reset all configurations?',
default: false
}
]);
if (!confirmReset) {
console.log(chalk_1.default.gray('\n✅ Reset cancelled. Your configuration is safe.'));
return;
}
// Second confirmation for safety
const { reallyConfirm } = await inquirer_1.default.prompt([
{
type: 'input',
name: 'reallyConfirm',
message: 'Type "DELETE" to confirm you want to delete all configurations:',
validate: (input) => {
if (input !== 'DELETE') {
return 'Type DELETE to confirm (case sensitive)';
}
return true;
}
}
]);
if (reallyConfirm !== 'DELETE') {
console.log(chalk_1.default.gray('\n✅ Reset cancelled. Your configuration is safe.'));
return;
}
// Perform the reset
try {
// Show what will be deleted
const configData = fs.readFileSync(CONFIG_FILE, 'utf-8');
const config = JSON.parse(configData);
const serverCount = Object.keys(config.servers || {}).length;
console.log(chalk_1.default.yellow(`\n🗑️ Deleting configuration for ${serverCount} server(s)...`));
// Delete the config file
fs.unlinkSync(CONFIG_FILE);
// Clean up empty directory if no other files
const files = fs.readdirSync(CONFIG_DIR);
if (files.length === 0) {
fs.rmdirSync(CONFIG_DIR);
}
console.log(chalk_1.default.green('\n✅ Configuration reset successfully!'));
console.log(chalk_1.default.gray('All server configurations have been removed.\n'));
// Ask if they want to set up again
const { setupNow } = await inquirer_1.default.prompt([
{
type: 'confirm',
name: 'setupNow',
message: 'Would you like to set up a server now?',
default: true
}
]);
if (setupNow) {
await (0, init_1.initCommand)();
}
else {
console.log(chalk_1.default.gray('\nRun "maestro init" when you\'re ready to set up servers again.'));
}
}
catch (error) {
console.error(chalk_1.default.red('\n❌ Error resetting configuration:'), error);
}
}
//# sourceMappingURL=reset.js.map