@vercel/build-utils 13.0.0 → 13.0.2
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 +12 -0
- package/dist/fs/run-user-scripts.d.ts +1 -0
- package/dist/fs/run-user-scripts.js +26 -5
- package/dist/generate-node-builder-functions.d.ts +8 -2
- package/dist/generate-node-builder-functions.js +4 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +30 -7
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @vercel/build-utils
|
|
2
2
|
|
|
3
|
+
## 13.0.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Improve warning messages surrounding Elysia ([#14272](https://github.com/vercel/vercel/pull/14272))
|
|
8
|
+
|
|
9
|
+
## 13.0.1
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- Revert "Remove getSpawnOptions" ([#14261](https://github.com/vercel/vercel/pull/14261))
|
|
14
|
+
|
|
3
15
|
## 13.0.0
|
|
4
16
|
|
|
5
17
|
### Major Changes
|
|
@@ -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);
|
|
@@ -642,11 +667,6 @@ To use ${otherVersion}, manually opt in using corepack (https://vercel.com/docs/
|
|
|
642
667
|
`Detected \`${detectedLockfile}\` ${versionString}generated by ${detectedPackageManager}`
|
|
643
668
|
);
|
|
644
669
|
}
|
|
645
|
-
if (cliType === "bun") {
|
|
646
|
-
console.warn(
|
|
647
|
-
"Warning: Bun is used as a package manager at build time only, not at runtime with Functions"
|
|
648
|
-
);
|
|
649
|
-
}
|
|
650
670
|
}
|
|
651
671
|
}
|
|
652
672
|
if (cliType === "yarn" && !env.YARN_NODE_LINKER) {
|
|
@@ -1044,6 +1064,7 @@ const installDependencies = (0, import_util.deprecate)(
|
|
|
1044
1064
|
getPathForPackageManager,
|
|
1045
1065
|
getPathOverrideForPackageManager,
|
|
1046
1066
|
getScriptName,
|
|
1067
|
+
getSpawnOptions,
|
|
1047
1068
|
installDependencies,
|
|
1048
1069
|
runBundleInstall,
|
|
1049
1070
|
runCustomInstallCommand,
|
|
@@ -1,6 +1,12 @@
|
|
|
1
|
-
import { BuildV3 } from './types';
|
|
1
|
+
import { BuildV3, Config } from './types';
|
|
2
2
|
import type FileFsRef from './file-fs-ref';
|
|
3
|
-
export declare function generateNodeBuilderFunctions(frameworkName: string, regex: RegExp, validFilenames: string[], validExtensions: string[], nodeBuild: any
|
|
3
|
+
export declare function generateNodeBuilderFunctions(frameworkName: string, regex: RegExp, validFilenames: string[], validExtensions: string[], nodeBuild: any, // necessary to avoid circular dependency
|
|
4
|
+
opts?: {
|
|
5
|
+
checks?: (info: {
|
|
6
|
+
config: Config;
|
|
7
|
+
isBun: boolean;
|
|
8
|
+
}) => void;
|
|
9
|
+
}): {
|
|
4
10
|
require_: NodeRequire;
|
|
5
11
|
findEntrypoint: (files: Record<string, FileFsRef>) => {
|
|
6
12
|
entrypoint: string;
|
|
@@ -35,7 +35,7 @@ var import_glob = __toESM(require("./fs/glob"));
|
|
|
35
35
|
var import_node_path = require("node:path");
|
|
36
36
|
var import_node_fs = __toESM(require("node:fs"));
|
|
37
37
|
var import_node_module = require("node:module");
|
|
38
|
-
function generateNodeBuilderFunctions(frameworkName, regex, validFilenames, validExtensions, nodeBuild) {
|
|
38
|
+
function generateNodeBuilderFunctions(frameworkName, regex, validFilenames, validExtensions, nodeBuild, opts) {
|
|
39
39
|
const entrypointsForMessage = validFilenames.map((filename) => `- ${filename}.{${validExtensions.join(",")}}`).join("\n");
|
|
40
40
|
const require_ = (0, import_node_module.createRequire)(__filename);
|
|
41
41
|
const build = async (args) => {
|
|
@@ -57,7 +57,9 @@ function generateNodeBuilderFunctions(frameworkName, regex, validFilenames, vali
|
|
|
57
57
|
considerBuildCommand: true,
|
|
58
58
|
entrypointCallback: async () => {
|
|
59
59
|
return entrypointCallback(args);
|
|
60
|
-
}
|
|
60
|
+
},
|
|
61
|
+
checks: opts?.checks ?? (() => {
|
|
62
|
+
})
|
|
61
63
|
});
|
|
62
64
|
let version = void 0;
|
|
63
65
|
try {
|
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);
|
|
@@ -23765,11 +23790,6 @@ To use ${otherVersion}, manually opt in using corepack (https://vercel.com/docs/
|
|
|
23765
23790
|
`Detected \`${detectedLockfile}\` ${versionString}generated by ${detectedPackageManager}`
|
|
23766
23791
|
);
|
|
23767
23792
|
}
|
|
23768
|
-
if (cliType === "bun") {
|
|
23769
|
-
console.warn(
|
|
23770
|
-
"Warning: Bun is used as a package manager at build time only, not at runtime with Functions"
|
|
23771
|
-
);
|
|
23772
|
-
}
|
|
23773
23793
|
}
|
|
23774
23794
|
}
|
|
23775
23795
|
if (cliType === "yarn" && !env.YARN_NODE_LINKER) {
|
|
@@ -24596,7 +24616,7 @@ var defaultCachePathGlob = "**/{node_modules,.yarn/cache}/**";
|
|
|
24596
24616
|
var import_node_path = require("path");
|
|
24597
24617
|
var import_node_fs = __toESM(require("fs"));
|
|
24598
24618
|
var import_node_module = require("module");
|
|
24599
|
-
function generateNodeBuilderFunctions(frameworkName, regex, validFilenames, validExtensions, nodeBuild) {
|
|
24619
|
+
function generateNodeBuilderFunctions(frameworkName, regex, validFilenames, validExtensions, nodeBuild, opts) {
|
|
24600
24620
|
const entrypointsForMessage = validFilenames.map((filename) => `- ${filename}.{${validExtensions.join(",")}}`).join("\n");
|
|
24601
24621
|
const require_ = (0, import_node_module.createRequire)(__filename);
|
|
24602
24622
|
const build = async (args) => {
|
|
@@ -24618,7 +24638,9 @@ function generateNodeBuilderFunctions(frameworkName, regex, validFilenames, vali
|
|
|
24618
24638
|
considerBuildCommand: true,
|
|
24619
24639
|
entrypointCallback: async () => {
|
|
24620
24640
|
return entrypointCallback(args);
|
|
24621
|
-
}
|
|
24641
|
+
},
|
|
24642
|
+
checks: opts?.checks ?? (() => {
|
|
24643
|
+
})
|
|
24622
24644
|
});
|
|
24623
24645
|
let version = void 0;
|
|
24624
24646
|
try {
|
|
@@ -24832,6 +24854,7 @@ function shouldUseExperimentalBackends(framework) {
|
|
|
24832
24854
|
getPrettyError,
|
|
24833
24855
|
getProvidedRuntime,
|
|
24834
24856
|
getScriptName,
|
|
24857
|
+
getSpawnOptions,
|
|
24835
24858
|
getSupportedBunVersion,
|
|
24836
24859
|
getSupportedNodeVersion,
|
|
24837
24860
|
getWriteableDirectory,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vercel/build-utils",
|
|
3
|
-
"version": "13.0.
|
|
3
|
+
"version": "13.0.2",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.js",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"@types/semver": "6.0.0",
|
|
28
28
|
"@types/yazl": "2.4.2",
|
|
29
29
|
"@vercel/error-utils": "2.0.3",
|
|
30
|
-
"@vercel/routing-utils": "5.2.
|
|
30
|
+
"@vercel/routing-utils": "5.2.2",
|
|
31
31
|
"aggregate-error": "3.0.1",
|
|
32
32
|
"async-retry": "1.2.3",
|
|
33
33
|
"async-sema": "2.1.4",
|