@zendesk/zcli-themes
Version:
zcli theme commands live here
39 lines (38 loc) • 1.46 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const core_1 = require("@oclif/core");
const zcli_core_1 = require("@zendesk/zcli-core");
const chalk = require("chalk");
const getBrandId_1 = require("../../lib/getBrandId");
const handleThemeApiError_1 = require("../../lib/handleThemeApiError");
class List extends core_1.Command {
async run() {
let { flags: { brandId } } = await this.parse(List);
brandId = brandId || await (0, getBrandId_1.default)();
try {
core_1.CliUx.ux.action.start('Listing themes');
const { data: { themes } } = await zcli_core_1.request.requestAPI(`/api/v2/guide/theming/themes?brand_id=${brandId}`, {
headers: {
'X-Zendesk-Request-Originator': 'zcli themes:list'
},
validateStatus: (status) => status === 200
});
core_1.CliUx.ux.action.stop('Ok');
this.log(chalk.green('Themes listed successfully'), themes);
return { themes };
}
catch (error) {
(0, handleThemeApiError_1.default)(error);
}
}
}
exports.default = List;
List.description = 'list installed themes';
List.enableJsonFlag = true;
List.flags = {
brandId: core_1.Flags.string({ description: 'The id of the brand where the themes are installed' })
};
List.examples = [
'$ zcli themes:list --brandId=123456'
];
List.strict = false;