@vercel/build-utils 12.2.3 → 13.0.0
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/framework-helpers.d.ts +3 -0
- package/dist/framework-helpers.js +18 -0
- package/dist/fs/run-user-scripts.d.ts +0 -1
- package/dist/fs/run-user-scripts.js +0 -26
- package/dist/index.d.ts +3 -3
- package/dist/index.js +16 -26
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @vercel/build-utils
|
|
2
2
|
|
|
3
|
+
## 13.0.0
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- Remove getSpawnOptions ([#14176](https://github.com/vercel/vercel/pull/14176))
|
|
8
|
+
|
|
9
|
+
## 12.2.4
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- Add helper for detecting backend builders ([#14182](https://github.com/vercel/vercel/pull/14182))
|
|
14
|
+
|
|
3
15
|
## 12.2.3
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import { Builder } from '.';
|
|
1
2
|
/**
|
|
2
3
|
* List of backend frameworks supported by the experimental backends feature
|
|
3
4
|
*/
|
|
4
5
|
export declare const BACKEND_FRAMEWORKS: readonly ["express", "hono", "h3", "nestjs", "fastify", "elysia"];
|
|
6
|
+
export declare const BACKEND_BUILDERS: readonly ["@vercel/express", "@vercel/hono", "@vercel/h3", "@vercel/nestjs", "@vercel/fastify", "@vercel/elysia"];
|
|
5
7
|
export type BackendFramework = (typeof BACKEND_FRAMEWORKS)[number];
|
|
6
8
|
/**
|
|
7
9
|
* Checks if the given framework is a backend framework
|
|
@@ -11,6 +13,7 @@ export declare function isBackendFramework(framework: string | null | undefined)
|
|
|
11
13
|
* Checks if experimental backends are enabled via environment variable
|
|
12
14
|
*/
|
|
13
15
|
export declare function isExperimentalBackendsEnabled(): boolean;
|
|
16
|
+
export declare function isBackendBuilder(builder: Builder | null | undefined): boolean;
|
|
14
17
|
/**
|
|
15
18
|
* Checks if experimental backends are enabled AND the framework is a backend framework
|
|
16
19
|
*/
|
|
@@ -18,7 +18,9 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
var framework_helpers_exports = {};
|
|
20
20
|
__export(framework_helpers_exports, {
|
|
21
|
+
BACKEND_BUILDERS: () => BACKEND_BUILDERS,
|
|
21
22
|
BACKEND_FRAMEWORKS: () => BACKEND_FRAMEWORKS,
|
|
23
|
+
isBackendBuilder: () => isBackendBuilder,
|
|
22
24
|
isBackendFramework: () => isBackendFramework,
|
|
23
25
|
isExperimentalBackendsEnabled: () => isExperimentalBackendsEnabled,
|
|
24
26
|
shouldUseExperimentalBackends: () => shouldUseExperimentalBackends
|
|
@@ -32,6 +34,14 @@ const BACKEND_FRAMEWORKS = [
|
|
|
32
34
|
"fastify",
|
|
33
35
|
"elysia"
|
|
34
36
|
];
|
|
37
|
+
const BACKEND_BUILDERS = [
|
|
38
|
+
"@vercel/express",
|
|
39
|
+
"@vercel/hono",
|
|
40
|
+
"@vercel/h3",
|
|
41
|
+
"@vercel/nestjs",
|
|
42
|
+
"@vercel/fastify",
|
|
43
|
+
"@vercel/elysia"
|
|
44
|
+
];
|
|
35
45
|
function isBackendFramework(framework) {
|
|
36
46
|
if (!framework)
|
|
37
47
|
return false;
|
|
@@ -41,12 +51,20 @@ function isExperimentalBackendsEnabled() {
|
|
|
41
51
|
return process.env.VERCEL_EXPERIMENTAL_BACKENDS === "1" || // Previously used for experimental express and hono builds
|
|
42
52
|
process.env.VERCEL_EXPERIMENTAL_EXPRESS_BUILD === "1" || process.env.VERCEL_EXPERIMENTAL_HONO_BUILD === "1";
|
|
43
53
|
}
|
|
54
|
+
function isBackendBuilder(builder) {
|
|
55
|
+
if (!builder)
|
|
56
|
+
return false;
|
|
57
|
+
const use = builder.use;
|
|
58
|
+
return BACKEND_BUILDERS.includes(use);
|
|
59
|
+
}
|
|
44
60
|
function shouldUseExperimentalBackends(framework) {
|
|
45
61
|
return isExperimentalBackendsEnabled() && isBackendFramework(framework);
|
|
46
62
|
}
|
|
47
63
|
// Annotate the CommonJS export names for ESM import in node:
|
|
48
64
|
0 && (module.exports = {
|
|
65
|
+
BACKEND_BUILDERS,
|
|
49
66
|
BACKEND_FRAMEWORKS,
|
|
67
|
+
isBackendBuilder,
|
|
50
68
|
isBackendFramework,
|
|
51
69
|
isExperimentalBackendsEnabled,
|
|
52
70
|
shouldUseExperimentalBackends
|
|
@@ -84,7 +84,6 @@ 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;
|
|
88
87
|
export declare function getNodeVersion(destPath: string, fallbackVersion?: string | undefined, config?: Config, meta?: Meta, availableVersions?: number[]): Promise<NodeVersion | BunVersion>;
|
|
89
88
|
export declare function scanParentDirs(destPath: string, readPackageJson?: boolean, base?: string): Promise<ScanParentDirsResult>;
|
|
90
89
|
export declare function turboVersionSpecifierSupportsCorepack(turboVersionSpecifier: string): boolean;
|
|
@@ -38,7 +38,6 @@ __export(run_user_scripts_exports, {
|
|
|
38
38
|
getPathForPackageManager: () => getPathForPackageManager,
|
|
39
39
|
getPathOverrideForPackageManager: () => getPathOverrideForPackageManager,
|
|
40
40
|
getScriptName: () => getScriptName,
|
|
41
|
-
getSpawnOptions: () => getSpawnOptions,
|
|
42
41
|
installDependencies: () => installDependencies,
|
|
43
42
|
runBundleInstall: () => runBundleInstall,
|
|
44
43
|
runCustomInstallCommand: () => runCustomInstallCommand,
|
|
@@ -178,30 +177,6 @@ async function runShellScript(fsPath, args = [], spawnOpts) {
|
|
|
178
177
|
});
|
|
179
178
|
return true;
|
|
180
179
|
}
|
|
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
|
-
}
|
|
205
180
|
async function getNodeVersion(destPath, fallbackVersion = process.env.VERCEL_PROJECT_SETTINGS_NODE_VERSION, config = {}, meta = {}, availableVersions = (0, import_node_version.getAvailableNodeVersions)()) {
|
|
206
181
|
if (config.bunVersion) {
|
|
207
182
|
return (0, import_node_version.getSupportedBunVersion)(config.bunVersion);
|
|
@@ -1069,7 +1044,6 @@ const installDependencies = (0, import_util.deprecate)(
|
|
|
1069
1044
|
getPathForPackageManager,
|
|
1070
1045
|
getPathOverrideForPackageManager,
|
|
1071
1046
|
getScriptName,
|
|
1072
|
-
getSpawnOptions,
|
|
1073
1047
|
installDependencies,
|
|
1074
1048
|
runBundleInstall,
|
|
1075
1049
|
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,
|
|
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';
|
|
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,
|
|
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, };
|
|
22
22
|
export { EdgeFunction } from './edge-function';
|
|
23
23
|
export { readConfigFile } from './fs/read-config-file';
|
|
24
24
|
export { normalizePath } from './fs/normalize-path';
|
|
@@ -32,4 +32,4 @@ export { NODE_VERSIONS } from './fs/node-version';
|
|
|
32
32
|
export { getInstalledPackageVersion } from './get-installed-package-version';
|
|
33
33
|
export { defaultCachePathGlob } from './default-cache-path-glob';
|
|
34
34
|
export { generateNodeBuilderFunctions } from './generate-node-builder-functions';
|
|
35
|
-
export { BACKEND_FRAMEWORKS, BackendFramework, isBackendFramework, isExperimentalBackendsEnabled, shouldUseExperimentalBackends, } from './framework-helpers';
|
|
35
|
+
export { BACKEND_FRAMEWORKS, BackendFramework, isBackendFramework, isBackendBuilder, isExperimentalBackendsEnabled, shouldUseExperimentalBackends, } from './framework-helpers';
|
package/dist/index.js
CHANGED
|
@@ -21860,13 +21860,13 @@ __export(src_exports, {
|
|
|
21860
21860
|
getPrettyError: () => getPrettyError,
|
|
21861
21861
|
getProvidedRuntime: () => getProvidedRuntime,
|
|
21862
21862
|
getScriptName: () => getScriptName,
|
|
21863
|
-
getSpawnOptions: () => getSpawnOptions,
|
|
21864
21863
|
getSupportedBunVersion: () => getSupportedBunVersion,
|
|
21865
21864
|
getSupportedNodeVersion: () => getSupportedNodeVersion,
|
|
21866
21865
|
getWriteableDirectory: () => getWritableDirectory,
|
|
21867
21866
|
glob: () => glob,
|
|
21868
21867
|
hardLinkDir: () => hardLinkDir,
|
|
21869
21868
|
installDependencies: () => installDependencies,
|
|
21869
|
+
isBackendBuilder: () => isBackendBuilder,
|
|
21870
21870
|
isBackendFramework: () => isBackendFramework,
|
|
21871
21871
|
isBunVersion: () => isBunVersion,
|
|
21872
21872
|
isDirectory: () => isDirectory,
|
|
@@ -23300,30 +23300,6 @@ async function runShellScript(fsPath, args = [], spawnOpts) {
|
|
|
23300
23300
|
});
|
|
23301
23301
|
return true;
|
|
23302
23302
|
}
|
|
23303
|
-
function getSpawnOptions(meta, nodeVersion) {
|
|
23304
|
-
const opts = {
|
|
23305
|
-
env: cloneEnv(process.env)
|
|
23306
|
-
};
|
|
23307
|
-
if (isBunVersion(nodeVersion)) {
|
|
23308
|
-
return opts;
|
|
23309
|
-
}
|
|
23310
|
-
if (!meta.isDev) {
|
|
23311
|
-
let found = false;
|
|
23312
|
-
const oldPath = opts.env.PATH || process.env.PATH || "";
|
|
23313
|
-
const pathSegments = oldPath.split(import_path5.default.delimiter).map((segment) => {
|
|
23314
|
-
if (/^\/node[0-9]+\/bin/.test(segment)) {
|
|
23315
|
-
found = true;
|
|
23316
|
-
return `/node${nodeVersion.major}/bin`;
|
|
23317
|
-
}
|
|
23318
|
-
return segment;
|
|
23319
|
-
});
|
|
23320
|
-
if (!found) {
|
|
23321
|
-
pathSegments.unshift(`/node${nodeVersion.major}/bin`);
|
|
23322
|
-
}
|
|
23323
|
-
opts.env.PATH = pathSegments.filter(Boolean).join(import_path5.default.delimiter);
|
|
23324
|
-
}
|
|
23325
|
-
return opts;
|
|
23326
|
-
}
|
|
23327
23303
|
async function getNodeVersion(destPath, fallbackVersion = process.env.VERCEL_PROJECT_SETTINGS_NODE_VERSION, config = {}, meta = {}, availableVersions = getAvailableNodeVersions()) {
|
|
23328
23304
|
if (config.bunVersion) {
|
|
23329
23305
|
return getSupportedBunVersion(config.bunVersion);
|
|
@@ -24785,6 +24761,14 @@ var BACKEND_FRAMEWORKS = [
|
|
|
24785
24761
|
"fastify",
|
|
24786
24762
|
"elysia"
|
|
24787
24763
|
];
|
|
24764
|
+
var BACKEND_BUILDERS = [
|
|
24765
|
+
"@vercel/express",
|
|
24766
|
+
"@vercel/hono",
|
|
24767
|
+
"@vercel/h3",
|
|
24768
|
+
"@vercel/nestjs",
|
|
24769
|
+
"@vercel/fastify",
|
|
24770
|
+
"@vercel/elysia"
|
|
24771
|
+
];
|
|
24788
24772
|
function isBackendFramework(framework) {
|
|
24789
24773
|
if (!framework)
|
|
24790
24774
|
return false;
|
|
@@ -24794,6 +24778,12 @@ function isExperimentalBackendsEnabled() {
|
|
|
24794
24778
|
return process.env.VERCEL_EXPERIMENTAL_BACKENDS === "1" || // Previously used for experimental express and hono builds
|
|
24795
24779
|
process.env.VERCEL_EXPERIMENTAL_EXPRESS_BUILD === "1" || process.env.VERCEL_EXPERIMENTAL_HONO_BUILD === "1";
|
|
24796
24780
|
}
|
|
24781
|
+
function isBackendBuilder(builder) {
|
|
24782
|
+
if (!builder)
|
|
24783
|
+
return false;
|
|
24784
|
+
const use = builder.use;
|
|
24785
|
+
return BACKEND_BUILDERS.includes(use);
|
|
24786
|
+
}
|
|
24797
24787
|
function shouldUseExperimentalBackends(framework) {
|
|
24798
24788
|
return isExperimentalBackendsEnabled() && isBackendFramework(framework);
|
|
24799
24789
|
}
|
|
@@ -24842,13 +24832,13 @@ function shouldUseExperimentalBackends(framework) {
|
|
|
24842
24832
|
getPrettyError,
|
|
24843
24833
|
getProvidedRuntime,
|
|
24844
24834
|
getScriptName,
|
|
24845
|
-
getSpawnOptions,
|
|
24846
24835
|
getSupportedBunVersion,
|
|
24847
24836
|
getSupportedNodeVersion,
|
|
24848
24837
|
getWriteableDirectory,
|
|
24849
24838
|
glob,
|
|
24850
24839
|
hardLinkDir,
|
|
24851
24840
|
installDependencies,
|
|
24841
|
+
isBackendBuilder,
|
|
24852
24842
|
isBackendFramework,
|
|
24853
24843
|
isBunVersion,
|
|
24854
24844
|
isDirectory,
|