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

Function postDeployment

packages/client/src/deploy.ts:18–112  ·  view source on GitHub ↗
(
  files: FilesMap,
  clientOptions: VercelClientOptions,
  deploymentOptions: DeploymentOptions
)

Source from the content-addressed store, hash-verified

16} from './types';
17
18async function* postDeployment(
19 files: FilesMap,
20 clientOptions: VercelClientOptions,
21 deploymentOptions: DeploymentOptions
22): AsyncIterableIterator<{
23 type: DeploymentEventType;
24 payload: any;
25 action?: string;
26 link?: string;
27}> {
28 const debug = createDebug(clientOptions.debug);
29 const preparedFiles = prepareFiles(files, clientOptions);
30 const apiDeployments = getApiDeploymentsUrl();
31
32 if (deploymentOptions?.builds && !deploymentOptions.functions) {
33 clientOptions.skipAutoDetectionConfirmation = true;
34 }
35
36 // Preview deployments are the default - no need to set `target`
37 if (deploymentOptions.target === 'preview') {
38 deploymentOptions.target = undefined;
39 }
40
41 // "production" environment need to use `target`,
42 // otherwise use `customEnvironmentSlugOrId` for a Custom Environment
43 if (deploymentOptions.target && deploymentOptions.target !== 'production') {
44 deploymentOptions.customEnvironmentSlugOrId = deploymentOptions.target;
45 deploymentOptions.target = undefined;
46 }
47
48 debug('Sending deployment creation API request');
49 try {
50 const response = await fetchApi(
51 `${apiDeployments}${generateQueryString(clientOptions)}`,
52 clientOptions.token,
53 {
54 method: 'POST',
55 headers: {
56 Accept: 'application/json',
57 'Content-Type': 'application/json',
58 },
59 body: JSON.stringify({
60 ...deploymentOptions,
61 files: preparedFiles,
62 }),
63 apiUrl: clientOptions.apiUrl,
64 userAgent: clientOptions.userAgent,
65 agent: clientOptions.agent,
66 }
67 );
68
69 let deployment = undefined;
70 try {
71 deployment = await response.json();
72 } catch (_error) {
73 throw new Error('Invalid JSON response');
74 }
75

Callers 1

deployFunction · 0.85

Calls 10

createDebugFunction · 0.90
prepareFilesFunction · 0.90
getApiDeploymentsUrlFunction · 0.90
fetchApiFunction · 0.90
generateQueryStringFunction · 0.90
jsonMethod · 0.65
getMethod · 0.65
debugFunction · 0.50
matchMethod · 0.45
hasMethod · 0.45

Tested by

no test coverage detected