agentic-qe
Version:
Agentic Quality Engineering Fleet System - AI-driven quality management platform
119 lines • 4.36 kB
JavaScript
;
/**
* Config Get Command - Get configuration values
*/
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.configGet = exports.ConfigGetCommand = 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 ConfigGetCommand {
static async execute(options) {
const spinner = (0, ora_1.default)('Reading 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);
// Get value
let value;
if (options.key) {
value = this.getNestedValue(config, options.key);
}
else {
value = config;
}
spinner.stop();
// Format output
const result = { value };
if (options.format) {
result.formatted = this.formatValue(value, options.format);
}
// Display value
if (value === undefined) {
console.log(chalk_1.default.yellow(`\n⚠️ Key not found: ${options.key}\n`));
}
else {
console.log(chalk_1.default.blue('\n📋 Configuration Value:\n'));
if (result.formatted) {
console.log(result.formatted);
}
else {
console.log(this.formatValue(value, 'json'));
}
}
return result;
}
catch (error) {
spinner.fail(chalk_1.default.red('Failed to read configuration'));
throw error;
}
}
static getNestedValue(obj, path) {
const keys = path.split('.');
let current = obj;
for (const key of keys) {
if (current === null || current === undefined) {
return undefined;
}
current = current[key];
}
return current;
}
static formatValue(value, format) {
switch (format) {
case 'json':
return JSON.stringify(value, null, 2);
case 'yaml':
return yaml.stringify(value);
case 'plain':
if (typeof value === 'object') {
return JSON.stringify(value);
}
return String(value);
default:
return JSON.stringify(value, null, 2);
}
}
}
exports.ConfigGetCommand = ConfigGetCommand;
ConfigGetCommand.DEFAULT_CONFIG_PATH = '.agentic-qe/config/aqe.config.json';
/**
* Wrapper function for CLI usage
*/
async function configGet(options) {
return ConfigGetCommand.execute(options);
}
exports.configGet = configGet;
//# sourceMappingURL=get.js.map