diff --git a/packages/app/src/cli/prompts/webhook/trigger.ts b/packages/app/src/cli/prompts/webhook/trigger.ts index 5aa4a237b21..d21fdb4a09f 100644 --- a/packages/app/src/cli/prompts/webhook/trigger.ts +++ b/packages/app/src/cli/prompts/webhook/trigger.ts @@ -1,4 +1,8 @@ -import {DELIVERY_METHOD, isAddressAllowedForDeliveryMethod} from '../../services/webhook/trigger-flags.js' +import { + DELIVERY_METHOD, + deliveryMethodInstructions, + isAddressAllowedForDeliveryMethod, +} from '../../services/webhook/trigger-flags.js' import {renderAutocompletePrompt, renderSelectPrompt, renderTextPrompt} from '@shopify/cli-kit/node/ui' import {stringifyMessage} from '@shopify/cli-kit/node/output' @@ -48,23 +52,6 @@ export async function addressPrompt(deliveryMethod: string): Promise { return input.trim() } -function deliveryMethodInstructions(method: string): string[] { - if (method === DELIVERY_METHOD.HTTP) { - return [ - `For remote HTTP testing, use a URL that starts with https://`, - `For local HTTP testing, use http://localhost:{port}/{url-path}`, - ] - } - if (method === DELIVERY_METHOD.PUBSUB) { - return [`For Google Pub/Sub, use pubsub://{project-id}:{topic-id}`] - } - if (method === DELIVERY_METHOD.EVENTBRIDGE) { - return [`For Amazon EventBridge, use an Amazon Resource Name (ARN) starting with arn:aws:events:`] - } - - return [] -} - export function deliveryMethodInstructionsAsString(method: string): string { return deliveryMethodInstructions(method) .map((hint) => ` ยท ${stringifyMessage(hint)}`) diff --git a/packages/app/src/cli/services/webhook/trigger-flags.ts b/packages/app/src/cli/services/webhook/trigger-flags.ts index 0a2a6ad2338..313ff0ff84d 100644 --- a/packages/app/src/cli/services/webhook/trigger-flags.ts +++ b/packages/app/src/cli/services/webhook/trigger-flags.ts @@ -58,7 +58,13 @@ export function validateAddressMethod(address: string, deliveryMethod: string): return [address.trim(), method] } -function deliveryMethodInstructions(method: string): string[] { +/** + * Hints describing the address format expected by a delivery method + * + * @param method - An existing delivery-method + * @returns A list of hints, empty if the method has no address format to describe + */ +export function deliveryMethodInstructions(method: string): string[] { if (method === DELIVERY_METHOD.HTTP) { return [ `For remote HTTP testing, use a URL that starts with https://`,