@hotglue/cli
Version:
hotglue CLI tools
69 lines (51 loc) • 2.24 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.handler = exports.desc = exports.command = exports.builder = void 0;
var _path = _interopRequireDefault(require("path"));
var _debug = _interopRequireDefault(require("../helpers/debug"));
var _yaml = _interopRequireDefault(require("yaml"));
var _cliTable = _interopRequireDefault(require("cli-table"));
var _config = require("../helpers/config");
var _print = require("../helpers/print");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
const debug = (0, _debug.default)('commands:config');
const command = 'config [action]';
exports.command = command;
const desc = 'Configure your hotglue CLI';
exports.desc = desc;
const builder = async function (yargs) {
debug('builder', command);
return yargs.commandDir('config');
};
exports.builder = builder;
const handler = async function (argv) {
debug('handler', command, argv);
const {
action
} = argv; // implement using yarg default command
if (!action) {
try {
const profileConfig = await (0, _config.getProfileConfig)();
if (!profileConfig.config || Object.keys(profileConfig.config).length === 0) {
(0, _print.pr)('No profile configuration found. Run config set to configure the hotglue CLI.');
}
const table = new _cliTable.default({
head: ['Setting', 'Value', 'Config File', 'Type']
});
if (profileConfig.config) Object.entries(profileConfig.config).forEach(([k, v]) => table.push([k, v, profileConfig.filepath, `Profile`]));
const projectConfig = await (0, _config.getProjectConfig)();
if (projectConfig.config) Object.entries(projectConfig.config).forEach(([k, v]) => table.push([k, v, _path.default.relative(process.cwd(), projectConfig.filepath), 'Project']));
if (table.length > 0) {
// pr('CURRENT CONTEXT SETTINGS');
console.log(table.toString()); // console.log(YAML.stringify(fileConfig.config));
} // pr('The configuration file is empty. Run config set to configure the hotglue CLI.');
} catch (err) {
// log elsewhere
console.log(err);
throw err;
}
}
};
exports.handler = handler;