@vercel/build-utils 13.0.0 → 13.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/dist/fs/run-user-scripts.d.ts +1 -0
- package/dist/fs/run-user-scripts.js +26 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +26 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -84,6 +84,7 @@ export declare function getNodeBinPath({ cwd, }: {
|
|
|
84
84
|
}): Promise<string>;
|
|
85
85
|
export declare function getNodeBinPaths({ start, base, }: TraverseUpDirectoriesProps): string[];
|
|
86
86
|
export declare function runShellScript(fsPath: string, args?: string[], spawnOpts?: SpawnOptions): Promise<boolean>;
|
|
87
|
+
export declare function getSpawnOptions(meta: Meta, nodeVersion: NodeVersion): SpawnOptions;
|
|
87
88
|
export declare function getNodeVersion(destPath: string, fallbackVersion?: string | undefined, config?: Config, meta?: Meta, availableVersions?: number[]): Promise<NodeVersion | BunVersion>;
|
|
88
89
|
export declare function scanParentDirs(destPath: string, readPackageJson?: boolean, base?: string): Promise<ScanParentDirsResult>;
|
|
89
90
|
export declare function turboVersionSpecifierSupportsCorepack(turboVersionSpecifier: string): boolean;
|
|
@@ -38,6 +38,7 @@ __export(run_user_scripts_exports, {
|
|
|
38
38
|
getPathForPackageManager: () => getPathForPackageManager,
|
|
39
39
|
getPathOverrideForPackageManager: () => getPathOverrideForPackageManager,
|
|
40
40
|
getScriptName: () => getScriptName,
|
|
41
|
+
getSpawnOptions: () => getSpawnOptions,
|
|
41
42
|
installDependencies: () => installDependencies,
|
|
42
43
|
runBundleInstall: () => runBundleInstall,
|
|
43
44
|
runCustomInstallCommand: () => runCustomInstallCommand,
|
|
@@ -177,6 +178,30 @@ async function runShellScript(fsPath, args = [], spawnOpts) {
|
|
|
177
178
|
});
|
|
178
179
|
return true;
|
|
179
180
|
}
|
|
181
|
+
function getSpawnOptions(meta, nodeVersion) {
|
|
182
|
+
const opts = {
|
|
183
|
+
env: (0, import_clone_env.cloneEnv)(process.env)
|
|
184
|
+
};
|
|
185
|
+
if ((0, import_node_version.isBunVersion)(nodeVersion)) {
|
|
186
|
+
return opts;
|
|
187
|
+
}
|
|
188
|
+
if (!meta.isDev) {
|
|
189
|
+
let found = false;
|
|
190
|
+
const oldPath = opts.env.PATH || process.env.PATH || "";
|
|
191
|
+
const pathSegments = oldPath.split(import_path.default.delimiter).map((segment) => {
|
|
192
|
+
if (/^\/node[0-9]+\/bin/.test(segment)) {
|
|
193
|
+
found = true;
|
|
194
|
+
return `/node${nodeVersion.major}/bin`;
|
|
195
|
+
}
|
|
196
|
+
return segment;
|
|
197
|
+
});
|
|
198
|
+
if (!found) {
|
|
199
|
+
pathSegments.unshift(`/node${nodeVersion.major}/bin`);
|
|
200
|
+
}
|
|
201
|
+
opts.env.PATH = pathSegments.filter(Boolean).join(import_path.default.delimiter);
|
|
202
|
+
}
|
|
203
|
+
return opts;
|
|
204
|
+
}
|
|
180
205
|
async function getNodeVersion(destPath, fallbackVersion = process.env.VERCEL_PROJECT_SETTINGS_NODE_VERSION, config = {}, meta = {}, availableVersions = (0, import_node_version.getAvailableNodeVersions)()) {
|
|
181
206
|
if (config.bunVersion) {
|
|
182
207
|
return (0, import_node_version.getSupportedBunVersion)(config.bunVersion);
|
|
@@ -1044,6 +1069,7 @@ const installDependencies = (0, import_util.deprecate)(
|
|
|
1044
1069
|
getPathForPackageManager,
|
|
1045
1070
|
getPathOverrideForPackageManager,
|
|
1046
1071
|
getScriptName,
|
|
1072
|
+
getSpawnOptions,
|
|
1047
1073
|
installDependencies,
|
|
1048
1074
|
runBundleInstall,
|
|
1049
1075
|
runCustomInstallCommand,
|
package/dist/index.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ import download, { downloadFile, DownloadedFiles, isSymbolicLink, isDirectory }
|
|
|
8
8
|
import getWriteableDirectory from './fs/get-writable-directory';
|
|
9
9
|
import glob, { GlobOptions } from './fs/glob';
|
|
10
10
|
import rename from './fs/rename';
|
|
11
|
-
import { spawnAsync, execCommand, spawnCommand, walkParentDirs, getScriptName, installDependencies, runPackageJsonScript, runNpmInstall, runBundleInstall, runPipInstall, runShellScript, runCustomInstallCommand, getEnvForPackageManager, getNodeVersion, getPathForPackageManager, detectPackageManager, getNodeBinPath, getNodeBinPaths, scanParentDirs, traverseUpDirectories } from './fs/run-user-scripts';
|
|
11
|
+
import { spawnAsync, execCommand, spawnCommand, walkParentDirs, getScriptName, installDependencies, runPackageJsonScript, runNpmInstall, runBundleInstall, runPipInstall, runShellScript, runCustomInstallCommand, getEnvForPackageManager, getNodeVersion, getPathForPackageManager, detectPackageManager, getSpawnOptions, getNodeBinPath, getNodeBinPaths, scanParentDirs, traverseUpDirectories } from './fs/run-user-scripts';
|
|
12
12
|
import { getLatestNodeVersion, getDiscontinuedNodeVersions, getSupportedNodeVersion, isBunVersion, getSupportedBunVersion } from './fs/node-version';
|
|
13
13
|
import streamToBuffer, { streamToBufferChunks } from './fs/stream-to-buffer';
|
|
14
14
|
import debug from './debug';
|
|
@@ -18,7 +18,7 @@ import { getPrefixedEnvVars } from './get-prefixed-env-vars';
|
|
|
18
18
|
import { cloneEnv } from './clone-env';
|
|
19
19
|
import { hardLinkDir } from './hard-link-dir';
|
|
20
20
|
import { validateNpmrc } from './validate-npmrc';
|
|
21
|
-
export { FileBlob, FileFsRef, FileRef, Lambda, NodejsLambda, createLambda, Prerender, download, downloadFile, DownloadedFiles, getWriteableDirectory, glob, GlobOptions, rename, spawnAsync, getScriptName, installDependencies, runPackageJsonScript, execCommand, spawnCommand, walkParentDirs, getNodeBinPath, getNodeBinPaths, getSupportedNodeVersion, isBunVersion, getSupportedBunVersion, detectPackageManager, runNpmInstall, runBundleInstall, runPipInstall, runShellScript, runCustomInstallCommand, getEnvForPackageManager, getNodeVersion, getPathForPackageManager, getLatestNodeVersion, getDiscontinuedNodeVersions, getPlatformEnv, getPrefixedEnvVars, streamToBuffer, streamToBufferChunks, debug, isSymbolicLink, isDirectory, getLambdaOptionsFromFunction, scanParentDirs, getIgnoreFilter, cloneEnv, hardLinkDir, traverseUpDirectories, validateNpmrc, };
|
|
21
|
+
export { FileBlob, FileFsRef, FileRef, Lambda, NodejsLambda, createLambda, Prerender, download, downloadFile, DownloadedFiles, getWriteableDirectory, glob, GlobOptions, rename, spawnAsync, getScriptName, installDependencies, runPackageJsonScript, execCommand, spawnCommand, walkParentDirs, getNodeBinPath, getNodeBinPaths, getSupportedNodeVersion, isBunVersion, getSupportedBunVersion, detectPackageManager, runNpmInstall, runBundleInstall, runPipInstall, runShellScript, runCustomInstallCommand, getEnvForPackageManager, getNodeVersion, getPathForPackageManager, getLatestNodeVersion, getDiscontinuedNodeVersions, getSpawnOptions, getPlatformEnv, getPrefixedEnvVars, streamToBuffer, streamToBufferChunks, debug, isSymbolicLink, isDirectory, getLambdaOptionsFromFunction, scanParentDirs, getIgnoreFilter, cloneEnv, hardLinkDir, traverseUpDirectories, validateNpmrc, };
|
|
22
22
|
export { EdgeFunction } from './edge-function';
|
|
23
23
|
export { readConfigFile } from './fs/read-config-file';
|
|
24
24
|
export { normalizePath } from './fs/normalize-path';
|
package/dist/index.js
CHANGED
|
@@ -21860,6 +21860,7 @@ __export(src_exports, {
|
|
|
21860
21860
|
getPrettyError: () => getPrettyError,
|
|
21861
21861
|
getProvidedRuntime: () => getProvidedRuntime,
|
|
21862
21862
|
getScriptName: () => getScriptName,
|
|
21863
|
+
getSpawnOptions: () => getSpawnOptions,
|
|
21863
21864
|
getSupportedBunVersion: () => getSupportedBunVersion,
|
|
21864
21865
|
getSupportedNodeVersion: () => getSupportedNodeVersion,
|
|
21865
21866
|
getWriteableDirectory: () => getWritableDirectory,
|
|
@@ -23300,6 +23301,30 @@ async function runShellScript(fsPath, args = [], spawnOpts) {
|
|
|
23300
23301
|
});
|
|
23301
23302
|
return true;
|
|
23302
23303
|
}
|
|
23304
|
+
function getSpawnOptions(meta, nodeVersion) {
|
|
23305
|
+
const opts = {
|
|
23306
|
+
env: cloneEnv(process.env)
|
|
23307
|
+
};
|
|
23308
|
+
if (isBunVersion(nodeVersion)) {
|
|
23309
|
+
return opts;
|
|
23310
|
+
}
|
|
23311
|
+
if (!meta.isDev) {
|
|
23312
|
+
let found = false;
|
|
23313
|
+
const oldPath = opts.env.PATH || process.env.PATH || "";
|
|
23314
|
+
const pathSegments = oldPath.split(import_path5.default.delimiter).map((segment) => {
|
|
23315
|
+
if (/^\/node[0-9]+\/bin/.test(segment)) {
|
|
23316
|
+
found = true;
|
|
23317
|
+
return `/node${nodeVersion.major}/bin`;
|
|
23318
|
+
}
|
|
23319
|
+
return segment;
|
|
23320
|
+
});
|
|
23321
|
+
if (!found) {
|
|
23322
|
+
pathSegments.unshift(`/node${nodeVersion.major}/bin`);
|
|
23323
|
+
}
|
|
23324
|
+
opts.env.PATH = pathSegments.filter(Boolean).join(import_path5.default.delimiter);
|
|
23325
|
+
}
|
|
23326
|
+
return opts;
|
|
23327
|
+
}
|
|
23303
23328
|
async function getNodeVersion(destPath, fallbackVersion = process.env.VERCEL_PROJECT_SETTINGS_NODE_VERSION, config = {}, meta = {}, availableVersions = getAvailableNodeVersions()) {
|
|
23304
23329
|
if (config.bunVersion) {
|
|
23305
23330
|
return getSupportedBunVersion(config.bunVersion);
|
|
@@ -24832,6 +24857,7 @@ function shouldUseExperimentalBackends(framework) {
|
|
|
24832
24857
|
getPrettyError,
|
|
24833
24858
|
getProvidedRuntime,
|
|
24834
24859
|
getScriptName,
|
|
24860
|
+
getSpawnOptions,
|
|
24835
24861
|
getSupportedBunVersion,
|
|
24836
24862
|
getSupportedNodeVersion,
|
|
24837
24863
|
getWriteableDirectory,
|