@aerocorp/cli
Version:
AeroCorp CLI 5.1.0 - Future-Proofed Enterprise Infrastructure with Live Preview, Tunneling & Advanced DevOps
117 lines ⢠4.3 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.ConfigService = void 0;
const conf_1 = __importDefault(require("conf"));
const chalk_1 = __importDefault(require("chalk"));
const os_1 = require("os");
const path_1 = require("path");
class ConfigService {
constructor() {
this.config = new conf_1.default({
projectName: 'aerocorp-cli',
configName: 'config',
cwd: (0, path_1.join)((0, os_1.homedir)(), '.aerocorp'),
defaults: {
coolify_url: 'https://coolify.aerocorpindustries.org',
server_ip: '128.140.35.238',
environment: 'production',
authenticated: false,
root_access: false
}
});
}
async handleConfig(options) {
if (options.set) {
await this.setConfig(options.set);
}
else if (options.get) {
await this.getConfig(options.get);
}
else if (options.list) {
await this.listConfig();
}
else if (options.reset) {
await this.resetConfig();
}
else {
console.log(chalk_1.default.yellow('ā¹ Config options:'));
console.log(chalk_1.default.white(' --set <key=value> Set configuration value'));
console.log(chalk_1.default.white(' --get <key> Get configuration value'));
console.log(chalk_1.default.white(' --list List all configuration'));
console.log(chalk_1.default.white(' --reset Reset configuration'));
}
}
async setConfig(keyValue) {
const [key, ...valueParts] = keyValue.split('=');
const value = valueParts.join('=');
if (!key || !value) {
throw new Error('Invalid format. Use: --set key=value');
}
this.config.set(key, value);
console.log(chalk_1.default.green(`ā Set ${key} = ${value}`));
}
async getConfig(key) {
const value = this.config.get(key);
if (value !== undefined) {
console.log(chalk_1.default.blue(`${key} = ${value}`));
}
else {
console.log(chalk_1.default.yellow(`ā Key '${key}' not found`));
}
}
async listConfig() {
console.log(chalk_1.default.cyan('š AeroCorp CLI Configuration:'));
console.log(chalk_1.default.cyan('================================'));
const allConfig = this.config.store;
// Mask sensitive values
Object.entries(allConfig).forEach(([key, value]) => {
let displayValue = value;
if (key.includes('token') || key.includes('password')) {
displayValue = typeof value === 'string' ? '*'.repeat(Math.min(value.length, 20)) : value;
}
const color = key.includes('token') ? 'red' :
key.includes('url') ? 'blue' :
key.includes('authenticated') ? 'green' : 'white';
console.log(chalk_1.default[color](` ${key}: ${displayValue}`));
});
// Show environment variables
console.log(chalk_1.default.cyan('\nš Environment Variables:'));
const rootToken = process.env.AEROCORP_CLI_ROOT_API_TOKEN;
if (rootToken) {
console.log(chalk_1.default.red(` AEROCORP_CLI_ROOT_API_TOKEN: ${'*'.repeat(20)}`));
}
else {
console.log(chalk_1.default.gray(' AEROCORP_CLI_ROOT_API_TOKEN: (not set)'));
}
}
async resetConfig() {
this.config.clear();
console.log(chalk_1.default.green('ā Configuration reset successfully'));
}
get(key) {
return this.config.get(key);
}
set(key, value) {
this.config.set(key, value);
}
has(key) {
return this.config.has(key);
}
delete(key) {
this.config.delete(key);
}
clear() {
this.config.clear();
}
getAll() {
return this.config.store;
}
getConfigPath() {
return this.config.path;
}
}
exports.ConfigService = ConfigService;
//# sourceMappingURL=config.js.map