Socket
Socket
Sign inDemoInstall

@vercel/build-utils

Package Overview
Dependencies
Maintainers
9
Versions
311
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@vercel/build-utils - npm Package Compare versions

Comparing version 7.3.0 to 7.4.0

6

CHANGELOG.md
# @vercel/build-utils
## 7.4.0
### Minor Changes
- Adds new helper `getPathForPackageManager()` ([#10918](https://github.com/vercel/vercel/pull/10918))
## 7.3.0

@@ -4,0 +10,0 @@

@@ -81,2 +81,6 @@ /// <reference types="node" />

export declare function runNpmInstall(destPath: string, args?: string[], spawnOpts?: SpawnOptions, meta?: Meta, nodeVersion?: NodeVersion): Promise<boolean>;
/**
* Prepares the input environment based on the used package manager and lockfile
* versions.
*/
export declare function getEnvForPackageManager({ cliType, lockfileVersion, nodeVersion, env, }: {

@@ -92,2 +96,33 @@ cliType: CliType;

};
/**
* Helper to get the binary paths that link to the used package manager.
* Note: Make sure it doesn't contain any `console.log` calls.
*/
export declare function getPathForPackageManager({ cliType, lockfileVersion, nodeVersion, env, }: {
cliType: CliType;
lockfileVersion: number | undefined;
nodeVersion: NodeVersion | undefined;
env: {
[x: string]: string | undefined;
};
}): {
/**
* Which lockfile was detected.
*/
detectedLockfile: string | undefined;
/**
* Detected package manager that generated the found lockfile.
*/
detectedPackageManager: string | undefined;
/**
* Value of $PATH that includes the binaries for the detected package manager.
* Undefined if no $PATH are necessary.
*/
path: string | undefined;
/**
* Set if yarn was identified as package manager and `YARN_NODE_LINKER`
* environment variable was not found on the input environment.
*/
yarnNodeLinker: string | undefined;
};
export declare function runCustomInstallCommand({ destPath, installCommand, nodeVersion, spawnOpts, }: {

@@ -94,0 +129,0 @@ destPath: string;

83

dist/fs/run-user-scripts.js

@@ -36,2 +36,3 @@ "use strict";

getNodeVersion: () => getNodeVersion,
getPathForPackageManager: () => getPathForPackageManager,
getScriptName: () => getScriptName,

@@ -380,3 +381,46 @@ getSpawnOptions: () => getSpawnOptions,

}) {
const newEnv = { ...env };
const {
detectedLockfile,
detectedPackageManager,
path: newPath,
yarnNodeLinker
} = getPathForPackageManager({
cliType,
lockfileVersion,
nodeVersion,
env
});
const newEnv = {
...env
};
if (newPath) {
const oldPath = env.PATH + "";
newEnv.PATH = `${newPath}${import_path.default.delimiter}${oldPath}`;
}
if (yarnNodeLinker) {
newEnv.YARN_NODE_LINKER = yarnNodeLinker;
}
if (detectedLockfile && detectedPackageManager) {
const versionString = cliType === "pnpm" ? `version ${lockfileVersion} ` : "";
console.log(
`Detected \`${detectedLockfile}\` ${versionString}generated by ${detectedPackageManager}`
);
if (cliType === "bun") {
console.warn(
"Warning: Bun is used as a package manager at build time only, not at runtime with Functions"
);
}
}
return newEnv;
}
function getPathForPackageManager({
cliType,
lockfileVersion,
nodeVersion,
env
}) {
let detectedLockfile;
let detectedPackageManager;
let pathValue;
let yarnNodeLinker;
const oldPath = env.PATH + "";

@@ -390,31 +434,33 @@ const npm7 = "/node16/bin-npm7";

if (typeof lockfileVersion === "number" && lockfileVersion >= 2 && (nodeVersion?.major || 0) < 16 && !oldPath.includes(npm7) && !corepackEnabled) {
newEnv.PATH = `${npm7}${import_path.default.delimiter}${oldPath}`;
console.log("Detected `package-lock.json` generated by npm 7+");
pathValue = npm7;
detectedLockfile = "package-lock.json";
detectedPackageManager = "npm 7+";
}
} else if (cliType === "pnpm") {
if (typeof lockfileVersion === "number" && lockfileVersion === 5.4 && !oldPath.includes(pnpm7) && !corepackEnabled) {
newEnv.PATH = `${pnpm7}${import_path.default.delimiter}${oldPath}`;
console.log(
`Detected \`pnpm-lock.yaml\` version ${lockfileVersion} generated by pnpm 7`
);
pathValue = pnpm7;
detectedLockfile = "pnpm-lock.yaml";
detectedPackageManager = "pnpm 7";
} else if (typeof lockfileVersion === "number" && lockfileVersion >= 6 && !oldPath.includes(pnpm8) && !corepackEnabled) {
newEnv.PATH = `${pnpm8}${import_path.default.delimiter}${oldPath}`;
console.log(
`Detected \`pnpm-lock.yaml\` version ${lockfileVersion} generated by pnpm 8`
);
pathValue = pnpm8;
detectedLockfile = "pnpm-lock.yaml";
detectedPackageManager = "pnpm 8";
}
} else if (cliType === "bun") {
if (!oldPath.includes(bun1) && !corepackEnabled) {
newEnv.PATH = `${bun1}${import_path.default.delimiter}${oldPath}`;
console.log("Detected `bun.lockb` generated by Bun");
console.warn(
"Warning: Bun is used as a package manager at build time only, not at runtime with Functions"
);
pathValue = bun1;
detectedLockfile = "bun.lockb";
detectedPackageManager = "Bun";
}
} else {
if (!env.YARN_NODE_LINKER) {
newEnv.YARN_NODE_LINKER = "node-modules";
yarnNodeLinker = "node-modules";
}
}
return newEnv;
return {
detectedLockfile,
detectedPackageManager,
path: pathValue,
yarnNodeLinker
};
}

@@ -523,2 +569,3 @@ async function runCustomInstallCommand({

getNodeVersion,
getPathForPackageManager,
getScriptName,

@@ -525,0 +572,0 @@ getSpawnOptions,

@@ -11,3 +11,3 @@ import FileBlob from './file-blob';

import rename from './fs/rename';
import { spawnAsync, execCommand, spawnCommand, walkParentDirs, getScriptName, installDependencies, runPackageJsonScript, runNpmInstall, runBundleInstall, runPipInstall, runShellScript, runCustomInstallCommand, getEnvForPackageManager, getNodeVersion, getSpawnOptions, getNodeBinPath, getNodeBinPaths, scanParentDirs, traverseUpDirectories } from './fs/run-user-scripts';
import { spawnAsync, execCommand, spawnCommand, walkParentDirs, getScriptName, installDependencies, runPackageJsonScript, runNpmInstall, runBundleInstall, runPipInstall, runShellScript, runCustomInstallCommand, getEnvForPackageManager, getNodeVersion, getPathForPackageManager, getSpawnOptions, getNodeBinPath, getNodeBinPaths, scanParentDirs, traverseUpDirectories } from './fs/run-user-scripts';
import { getLatestNodeVersion, getDiscontinuedNodeVersions } from './fs/node-version';

@@ -22,3 +22,3 @@ import streamToBuffer from './fs/stream-to-buffer';

import { validateNpmrc } from './validate-npmrc';
export { FileBlob, FileFsRef, FileRef, Lambda, NodejsLambda, createLambda, Prerender, download, downloadFile, DownloadedFiles, getWriteableDirectory, glob, GlobOptions, rename, spawnAsync, getScriptName, installDependencies, runPackageJsonScript, execCommand, spawnCommand, walkParentDirs, getNodeBinPath, getNodeBinPaths, runNpmInstall, runBundleInstall, runPipInstall, runShellScript, runCustomInstallCommand, getEnvForPackageManager, getNodeVersion, getLatestNodeVersion, getDiscontinuedNodeVersions, getSpawnOptions, getPlatformEnv, getPrefixedEnvVars, streamToBuffer, debug, isSymbolicLink, isDirectory, getLambdaOptionsFromFunction, scanParentDirs, getIgnoreFilter, cloneEnv, hardLinkDir, traverseUpDirectories, validateNpmrc, };
export { FileBlob, FileFsRef, FileRef, Lambda, NodejsLambda, createLambda, Prerender, download, downloadFile, DownloadedFiles, getWriteableDirectory, glob, GlobOptions, rename, spawnAsync, getScriptName, installDependencies, runPackageJsonScript, execCommand, spawnCommand, walkParentDirs, getNodeBinPath, getNodeBinPaths, runNpmInstall, runBundleInstall, runPipInstall, runShellScript, runCustomInstallCommand, getEnvForPackageManager, getNodeVersion, getPathForPackageManager, getLatestNodeVersion, getDiscontinuedNodeVersions, getSpawnOptions, getPlatformEnv, getPrefixedEnvVars, streamToBuffer, debug, isSymbolicLink, isDirectory, getLambdaOptionsFromFunction, scanParentDirs, getIgnoreFilter, cloneEnv, hardLinkDir, traverseUpDirectories, validateNpmrc, };
export { EdgeFunction } from './edge-function';

@@ -25,0 +25,0 @@ export { readConfigFile } from './fs/read-config-file';

{
"name": "@vercel/build-utils",
"version": "7.3.0",
"version": "7.4.0",
"license": "Apache-2.0",

@@ -5,0 +5,0 @@ "main": "./dist/index.js",

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc