@copado/copado-cli
Version:
Copado Developer CLI
56 lines • 2.19 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const core_1 = require("@salesforce/core");
const filesystem_1 = require("../../../copado_commons/filesystem");
const sf_plugins_core_1 = require("@salesforce/sf-plugins-core");
core_1.Messages.importMessagesDirectory(__dirname);
const messages = core_1.Messages.loadMessages('@copado/copado-cli', 'copado_config');
class ConfigList extends sf_plugins_core_1.SfCommand {
async run() {
const userConfig = (await filesystem_1.CopadoFiles.getUserConfig()).get('config');
const localConfig = (await filesystem_1.CopadoFiles.getLocalConfig()).get('config');
const columns = {};
['Scope', 'Key', 'Value'].forEach(key => (columns[key] = {}));
const ux = new sf_plugins_core_1.Ux({ jsonEnabled: this.jsonEnabled() });
let data = [];
if (localConfig) {
data = data.concat(this.asFormattedRows(this.getConfig(localConfig), 'Local'));
}
if (userConfig) {
data = data.concat(this.asFormattedRows(this.getConfig(userConfig), 'User'));
}
if (!data.length) {
ux.log(messages.getMessage('list.noConfigSetup'));
}
else {
ux.styledHeader('Copado Config');
ux.table(data, columns);
}
return data;
}
asFormattedRows(copadoContent, scope) {
const result = [];
for (const key of Object.keys(copadoContent)) {
result.push({
Scope: scope,
Key: key,
Value: copadoContent[key] || 'undefined'
});
}
return result;
}
getConfig(config) {
let configContent = [];
const availableConfig = ['defaultlistview', 'externalid', 'bypassforceignore'];
availableConfig.forEach(key => {
if (config[key]) {
configContent[key] = config[key];
}
});
return configContent;
}
}
exports.default = ConfigList;
ConfigList.description = messages.getMessage('list.description');
ConfigList.examples = [messages.getMessage('list.example')];
//# sourceMappingURL=list.js.map