UNPKG

@zendesk/zcli-themes

Version:

zcli theme commands live here

43 lines (42 loc) 1.86 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const core_1 = require("@oclif/core"); const path = require("path"); const chalk = require("chalk"); const createThemeUpdateJob_1 = require("../../lib/createThemeUpdateJob"); const createThemePackage_1 = require("../../lib/createThemePackage"); const uploadThemePackage_1 = require("../../lib/uploadThemePackage"); const pollJobStatus_1 = require("../../lib/pollJobStatus"); class Update extends core_1.Command { async run() { let { flags: { themeId, replaceSettings }, argv: [themeDirectory] } = await this.parse(Update); const themePath = path.resolve(themeDirectory); themeId = themeId || await core_1.CliUx.ux.prompt('Theme ID'); const job = await (0, createThemeUpdateJob_1.default)(themeId, replaceSettings); const { file, removePackage } = await (0, createThemePackage_1.default)(themePath); try { await (0, uploadThemePackage_1.default)(job, file, path.basename(themePath)); } finally { removePackage(); } await (0, pollJobStatus_1.default)(themePath, job.id); this.log(chalk.green('Theme updated successfully')); return { themeId }; } } exports.default = Update; Update.description = 'update a theme'; Update.enableJsonFlag = true; Update.flags = { themeId: core_1.Flags.string({ description: 'The id of the theme to update' }), replaceSettings: core_1.Flags.boolean({ default: false, description: 'Whether or not to replace the current theme settings' }) }; Update.args = [ { name: 'themeDirectory', required: true, default: '.' } ]; Update.examples = [ '$ zcli themes:update ./copenhagen_theme --themeId=123456789100', '$ zcli themes:update ./copenhagen_theme --themeId=123456789100 --replaceSettings' ]; Update.strict = false;