From 20cf160d8d7a37f667345322da1329f795de6aeb Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 1 Oct 2026 00:42:13 +0000 Subject: [PATCH] [Refactor] Share deliveryMethodInstructions between webhook flags and prompts The function was duplicated byte-for-byte in trigger-flags.ts and prompts/webhook/trigger.ts. Export the service copy and import it in the prompt, which already imports from the same module. Co-Authored-By: Claude Opus 4.8 --- .../app/src/cli/prompts/webhook/trigger.ts | 23 ++++--------------- .../src/cli/services/webhook/trigger-flags.ts | 8 ++++++- 2 files changed, 12 insertions(+), 19 deletions(-) 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://`,