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

Function downloadInstallAndBundle

packages/backends/src/utils.ts:14–76  ·  view source on GitHub ↗
(
  args: Parameters<BuildV2>[0]
)

Source from the content-addressed store, hash-verified

12import type { BuildV2 } from '@vercel/build-utils';
13
14export async function downloadInstallAndBundle(
15 args: Parameters<BuildV2>[0]
16): Promise<{
17 spawnEnv: {
18 [x: string]: string | undefined;
19 };
20 entrypointFsDirname: string;
21 cliType: Awaited<ReturnType<typeof scanParentDirs>>['cliType'];
22 lockfilePath: string | undefined;
23 lockfileVersion: number | undefined;
24}> {
25 const { entrypoint, files, workPath, meta, config, repoRootPath } = args;
26 await download(files, workPath, meta);
27
28 const entrypointFsDirname = join(workPath, dirname(entrypoint));
29
30 const {
31 cliType,
32 lockfilePath,
33 lockfileVersion,
34 packageJsonPackageManager,
35 turboSupportsCorepackHome,
36 } = await scanParentDirs(entrypointFsDirname, true, repoRootPath);
37
38 const spawnEnv = getEnvForPackageManager({
39 cliType,
40 lockfileVersion,
41 packageJsonPackageManager,
42 env: process.env,
43 turboSupportsCorepackHome,
44 projectCreatedAt: config.projectSettings?.createdAt,
45 });
46
47 const installCommand = config.projectSettings?.installCommand;
48 if (typeof installCommand === 'string') {
49 if (installCommand.trim()) {
50 console.log(`Running "install" command: \`${installCommand}\`...`);
51 await execCommand(installCommand, {
52 env: spawnEnv,
53 cwd: entrypointFsDirname,
54 });
55 } else {
56 console.log(`Skipping "install" command...`);
57 }
58 } else {
59 await runNpmInstall(
60 entrypointFsDirname,
61 [],
62 {
63 env: spawnEnv,
64 },
65 meta,
66 config.projectSettings?.createdAt
67 );
68 }
69 return {
70 entrypointFsDirname,
71 spawnEnv,

Callers 1

buildFunction · 0.70

Calls 6

downloadFunction · 0.90
scanParentDirsFunction · 0.90
getEnvForPackageManagerFunction · 0.90
execCommandFunction · 0.90
runNpmInstallFunction · 0.90
logMethod · 0.45

Tested by

no test coverage detected