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

Function buildCreateDeployment

packages/client/src/create-deployment.ts:16–101  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

14} from './collect-deployment-files';
15
16export default function buildCreateDeployment() {
17 return async function* createDeployment(
18 clientOptions: VercelClientOptions,
19 deploymentOptions: DeploymentOptions = {}
20 ): AsyncIterableIterator<{ type: DeploymentEventType; payload: any }> {
21 const { path } = clientOptions;
22
23 const debug = createDebug(clientOptions.debug);
24
25 debug('Creating deployment...');
26
27 assertDeploymentPath(path, debug);
28
29 if (typeof clientOptions.token !== 'string') {
30 debug(
31 `Error: 'token' is expected to be a string. Received ${typeof clientOptions.token}`
32 );
33
34 throw new DeploymentError({
35 code: 'token_not_provided',
36 message: 'Options object must include a `token`',
37 });
38 }
39
40 /**
41 * Manual deployment is an experimental feature that supports only prebuilt
42 * deployments. We could implicitly pass prebuilt=true when hitting the
43 * API but it is more intentional to require the user to set it.
44 */
45 if (clientOptions.manual) {
46 debug('Manual provisioning mode enabled');
47 if (!clientOptions.prebuilt) {
48 throw new DeploymentError({
49 code: 'invalid_options',
50 message: 'The `manual` option requires `prebuilt` to be true',
51 });
52 }
53
54 // Once the feature becomes stable we will use a new body parameter
55 deploymentOptions.build = deploymentOptions.build || {};
56 deploymentOptions.build.env = deploymentOptions.build.env || {};
57 deploymentOptions.build.env.VERCEL_MANUAL_PROVISIONING = '1';
58 deploymentOptions.version = 2;
59
60 debug('Creating deployment with manual provisioning...');
61 yield* deploy(new Map(), clientOptions, deploymentOptions);
62 return;
63 }
64
65 const { fileList, filesMap: files } = await collectDeploymentFiles(
66 path,
67 clientOptions,
68 debug
69 );
70
71 // This is a useful warning because it prevents people
72 // from getting confused about a deployment that renders 404.
73 if (fileList.length === 0) {

Callers 2

index.tsFile · 0.85

Calls 7

createDebugFunction · 0.90
assertDeploymentPathFunction · 0.90
deployFunction · 0.90
collectDeploymentFilesFunction · 0.90
mapToObjectFunction · 0.90
uploadFunction · 0.90
debugFunction · 0.50

Tested by

no test coverage detected