UNPKG

@modyo/cli

Version:

Modyo CLI Command line to expose local development tools

32 lines (31 loc) 1.39 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); const core_1 = require("@oclif/core"); const debug_1 = tslib_1.__importDefault(require("debug")); const modyo_api_paths_1 = require("./modyo-api-paths"); const update_widget_from_resources_1 = require("./update-widget-from-resources"); const debug = (0, debug_1.default)('push/update-widget.ts'); const debugError = (0, debug_1.default)('error::push/update-widget.ts'); async function updateWidget(name, widgetId, resources, { version, accountUrl, siteId, token, }) { const url = `${accountUrl}/${modyo_api_paths_1.MODYO_API_PATH[version]}/sites/${siteId}/widget_definitions/${widgetId}`; debug(`update ${url}`); debug(`update ${token}`); core_1.ux.action.start(`Updating information of widget ${name}`); try { const response = await (0, update_widget_from_resources_1.updateWidgetFromResources)(widgetId, url, token, resources); debug('updated info'); const json = response.data; if (!!json.errors || !!json.error) { core_1.ux.action.stop(`Updating information of widget ${name} Failed`); throw new Error(JSON.stringify(json)); } core_1.ux.action.stop(); return json; } catch (error) { debugError(error); throw error; } } exports.default = updateWidget;