UNPKG

eas-cli

Version:

EAS command line tool

53 lines (52 loc) 2.43 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); const core_1 = require("@oclif/core"); const EasCommand_1 = tslib_1.__importDefault(require("../../commandUtils/EasCommand")); const flags_1 = require("../../commandUtils/flags"); const generated_1 = require("../../graphql/generated"); const WebhookMutation_1 = require("../../graphql/mutations/WebhookMutation"); const WebhookQuery_1 = require("../../graphql/queries/WebhookQuery"); const ora_1 = require("../../ora"); const pick_1 = tslib_1.__importDefault(require("../../utils/expodash/pick")); const input_1 = require("../../webhooks/input"); class WebhookUpdate extends EasCommand_1.default { static description = 'update a webhook'; static flags = { id: core_1.Flags.string({ description: 'Webhook ID', required: true, }), event: core_1.Flags.enum({ description: 'Event type that triggers the webhook', options: [generated_1.WebhookType.Build, generated_1.WebhookType.Submit], }), url: core_1.Flags.string({ description: 'Webhook URL', }), secret: core_1.Flags.string({ description: "Secret used to create a hash signature of the request payload, provided in the 'Expo-Signature' header.", }), ...flags_1.EASNonInteractiveFlag, }; static contextDefinition = { ...this.ContextOptions.LoggedIn, }; async runAsync() { const { flags } = await this.parse(WebhookUpdate); const { loggedIn: { graphqlClient }, } = await this.getContextAsync(WebhookUpdate, { nonInteractive: flags['non-interactive'] }); const webhookId = flags.id; const webhook = await WebhookQuery_1.WebhookQuery.byIdAsync(graphqlClient, webhookId); const webhookInputParams = await (0, input_1.prepareInputParamsAsync)((0, pick_1.default)(flags, ['event', 'url', 'secret', 'non-interactive']), webhook); const spinner = (0, ora_1.ora)('Updating a webhook').start(); try { await WebhookMutation_1.WebhookMutation.updateWebhookAsync(graphqlClient, webhookId, webhookInputParams); spinner.succeed('Successfully updated a webhook'); } catch (err) { spinner.fail('Failed to update a webhook'); throw err; } } } exports.default = WebhookUpdate;