MCPcopy Create free account
hub / github.com/vercel/vercel / create

Function create

packages/cli/src/commands/webhooks/create.ts:24–283  ·  view source on GitHub ↗
(client: Client, argv: string[])

Source from the content-addressed store, hash-verified

22 'https://vercel.com/docs/webhooks/webhooks-api';
23
24export default async function create(client: Client, argv: string[]) {
25 const telemetry = new WebhooksCreateTelemetryClient({
26 opts: {
27 store: client.telemetryEventStore,
28 },
29 });
30
31 let parsedArgs;
32 const flagsSpecification = getFlagsSpecification(createSubcommand.options);
33 try {
34 parsedArgs = parseArguments(argv, flagsSpecification);
35 } catch (error) {
36 printError(error);
37 return 1;
38 }
39 const { args, flags: opts } = parsedArgs;
40 let [url] = args;
41
42 // --- Collect URL ---
43 if (!url) {
44 if (client.nonInteractive) {
45 const argv = client.argv.slice(2);
46 const subcommandParts = argv.slice(0, 2); // e.g. ['webhooks', 'create']
47 const rest = argv.slice(2);
48 const subcommandWithPlaceholder = `${subcommandParts.join(' ')} <url>${
49 rest.length ? ` ${rest.join(' ')}` : ''
50 }`;
51 outputAgentError(
52 client,
53 {
54 status: AGENT_STATUS.ERROR,
55 reason: AGENT_REASON.MISSING_URL,
56 message:
57 'Webhook URL is required. Provide URL as the first argument.',
58 next: [
59 {
60 command: getCommandNamePlain(subcommandWithPlaceholder),
61 },
62 ],
63 },
64 1
65 );
66 }
67 url = await client.input.text({
68 message: 'Webhook URL:',
69 validate: (val: string) => {
70 if (!val) return 'URL is required';
71 try {
72 const urlObj = new URL(val);
73 if (!['http:', 'https:'].includes(urlObj.protocol)) {
74 return 'Webhook URL must use http or https protocol';
75 }
76 } catch {
77 return 'Invalid URL';
78 }
79 return true;
80 },
81 });

Callers 1

mainFunction · 0.70

Calls 15

trackCliArgumentUrlMethod · 0.95
trackCliOptionEventMethod · 0.95
trackCliOptionProjectMethod · 0.95
getFlagsSpecificationFunction · 0.90
parseArgumentsFunction · 0.90
printErrorFunction · 0.90
outputAgentErrorFunction · 0.90
getCommandNamePlainFunction · 0.90
getWebhookEventsFunction · 0.90
validateWebhookEventsFunction · 0.90
isAPIErrorFunction · 0.90

Tested by

no test coverage detected