UNPKG

agentic-qe

Version:

Agentic Quality Engineering Fleet System - AI-driven quality management platform

94 lines 4.32 kB
"use strict"; /** * Config Export Command - Export configuration to file */ 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 (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __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.ConfigExportCommand = void 0; const fs = __importStar(require("fs-extra")); const chalk_1 = __importDefault(require("chalk")); const ora_1 = __importDefault(require("ora")); const yaml = __importStar(require("yaml")); class ConfigExportCommand { static async execute(options) { const spinner = (0, ora_1.default)('Exporting configuration...').start(); try { // Determine config file path const configPath = options.config || this.DEFAULT_CONFIG_PATH; // Check if config exists if (!(await fs.pathExists(configPath))) { throw new Error(`Configuration file not found: ${configPath}`); } // Read configuration const config = await fs.readJson(configPath); // Determine output path const format = options.format || 'json'; const defaultFilename = `aqe-config-${Date.now()}.${format}`; const outputPath = options.output || defaultFilename; // Check if output file exists if ((await fs.pathExists(outputPath)) && !options.force) { throw new Error('File already exists. Use --force to overwrite'); } // Prepare export data let exportData = config; if (options.includeMetadata) { exportData = { metadata: { exportedAt: new Date().toISOString(), exportedFrom: configPath, version: config.version }, config: config }; } // Write to file based on format if (format === 'json') { await fs.writeJson(outputPath, exportData, { spaces: 2 }); } else if (format === 'yaml') { const yamlContent = yaml.stringify(exportData); await fs.writeFile(outputPath, yamlContent, 'utf-8'); } spinner.succeed(chalk_1.default.green('Configuration exported successfully!')); console.log(chalk_1.default.blue('\n📦 Export Details:')); console.log(chalk_1.default.gray(` Source: ${configPath}`)); console.log(chalk_1.default.gray(` Output: ${outputPath}`)); console.log(chalk_1.default.gray(` Format: ${format}`)); console.log(chalk_1.default.gray(` Metadata: ${options.includeMetadata ? 'Included' : 'Not included'}`)); console.log(chalk_1.default.yellow('\n💡 Tip:')); console.log(chalk_1.default.gray(' Import this config: aqe config import --input ' + outputPath)); } catch (error) { spinner.fail(chalk_1.default.red('Failed to export configuration')); throw error; } } } exports.ConfigExportCommand = ConfigExportCommand; ConfigExportCommand.DEFAULT_CONFIG_PATH = '.agentic-qe/config/aqe.config.json'; //# sourceMappingURL=export.js.map