Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 5 additions & 18 deletions packages/app/src/cli/prompts/webhook/trigger.ts
Original file line number Diff line number Diff line change
@@ -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'

Expand Down Expand Up @@ -48,23 +52,6 @@ export async function addressPrompt(deliveryMethod: string): Promise<string> {
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)}`)
Expand Down
8 changes: 7 additions & 1 deletion packages/app/src/cli/services/webhook/trigger-flags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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://`,
Expand Down