@vercel/build-utils 13.2.10 → 13.2.12
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 +13 -5
- package/dist/fs/run-user-scripts.js +16 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +16 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @vercel/build-utils
|
|
2
2
|
|
|
3
|
+
## 13.2.12
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Add `findPackageJson` function for optimized package.json lookup without lockfile scanning. This improves `getNodeVersion` performance by avoiding unnecessary lockfile parsing. ([#14658](https://github.com/vercel/vercel/pull/14658))
|
|
8
|
+
|
|
3
9
|
## 13.2.10
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
|
@@ -2,11 +2,7 @@
|
|
|
2
2
|
import { SpawnOptions } from 'child_process';
|
|
3
3
|
import { Meta, PackageJson, NodeVersion, Config, BunVersion } from '../types';
|
|
4
4
|
export type CliType = 'yarn' | 'npm' | 'pnpm' | 'bun' | 'vlt';
|
|
5
|
-
export interface
|
|
6
|
-
/**
|
|
7
|
-
* "yarn", "npm", or "pnpm" depending on the presence of lockfiles.
|
|
8
|
-
*/
|
|
9
|
-
cliType: CliType;
|
|
5
|
+
export interface FindPackageJsonResult {
|
|
10
6
|
/**
|
|
11
7
|
* The file path of found `package.json` file, or `undefined` if not found.
|
|
12
8
|
*/
|
|
@@ -16,6 +12,12 @@ export interface ScanParentDirsResult {
|
|
|
16
12
|
* option is enabled.
|
|
17
13
|
*/
|
|
18
14
|
packageJson?: PackageJson;
|
|
15
|
+
}
|
|
16
|
+
export interface ScanParentDirsResult extends FindPackageJsonResult {
|
|
17
|
+
/**
|
|
18
|
+
* "yarn", "npm", or "pnpm" depending on the presence of lockfiles.
|
|
19
|
+
*/
|
|
20
|
+
cliType: CliType;
|
|
19
21
|
/**
|
|
20
22
|
* The file path of the lockfile (`yarn.lock`, `package-lock.json`, or `pnpm-lock.yaml`)
|
|
21
23
|
* or `undefined` if not found.
|
|
@@ -91,6 +93,12 @@ export declare function runShellScript(fsPath: string, args?: string[], spawnOpt
|
|
|
91
93
|
*/
|
|
92
94
|
export declare function getSpawnOptions(meta: Meta, nodeVersion: NodeVersion): SpawnOptions;
|
|
93
95
|
export declare function getNodeVersion(destPath: string, fallbackVersion?: string | undefined, config?: Config, meta?: Meta, availableVersions?: number[]): Promise<NodeVersion | BunVersion>;
|
|
96
|
+
/**
|
|
97
|
+
* Traverses up directories to find and optionally read package.json.
|
|
98
|
+
* This is a lightweight alternative to `scanParentDirs` when only
|
|
99
|
+
* package.json information is needed (without lockfile detection).
|
|
100
|
+
*/
|
|
101
|
+
export declare function findPackageJson(destPath: string, readPackageJson?: boolean, base?: string): Promise<FindPackageJsonResult>;
|
|
94
102
|
export declare function scanParentDirs(destPath: string, readPackageJson?: boolean, base?: string): Promise<ScanParentDirsResult>;
|
|
95
103
|
export declare function turboVersionSpecifierSupportsCorepack(turboVersionSpecifier: string): boolean;
|
|
96
104
|
export declare function usingCorepack(env: {
|
|
@@ -31,6 +31,7 @@ __export(run_user_scripts_exports, {
|
|
|
31
31
|
PNPM_10_PREFERRED_AT: () => PNPM_10_PREFERRED_AT,
|
|
32
32
|
detectPackageManager: () => detectPackageManager,
|
|
33
33
|
execCommand: () => execCommand,
|
|
34
|
+
findPackageJson: () => findPackageJson,
|
|
34
35
|
getEnvForPackageManager: () => getEnvForPackageManager,
|
|
35
36
|
getNodeBinPath: () => getNodeBinPath,
|
|
36
37
|
getNodeBinPaths: () => getNodeBinPaths,
|
|
@@ -212,7 +213,7 @@ async function getNodeVersion(destPath, fallbackVersion = process.env.VERCEL_PRO
|
|
|
212
213
|
latestVersion.runtime = "nodejs";
|
|
213
214
|
return latestVersion;
|
|
214
215
|
}
|
|
215
|
-
const { packageJson } = await
|
|
216
|
+
const { packageJson } = await findPackageJson(destPath, true);
|
|
216
217
|
const configuredVersion = config.nodeVersion || fallbackVersion;
|
|
217
218
|
const packageJsonVersion = packageJson?.engines?.node;
|
|
218
219
|
const supportedNodeVersion = await (0, import_node_version.getSupportedNodeVersion)(
|
|
@@ -239,7 +240,7 @@ async function getNodeVersion(destPath, fallbackVersion = process.env.VERCEL_PRO
|
|
|
239
240
|
}
|
|
240
241
|
return supportedNodeVersion;
|
|
241
242
|
}
|
|
242
|
-
async function
|
|
243
|
+
async function findPackageJson(destPath, readPackageJson = false, base = "/") {
|
|
243
244
|
(0, import_assert.default)(import_path.default.isAbsolute(destPath));
|
|
244
245
|
const pkgJsonPath = await walkParentDirs({
|
|
245
246
|
base,
|
|
@@ -256,6 +257,18 @@ async function scanParentDirs(destPath, readPackageJson = false, base = "/") {
|
|
|
256
257
|
);
|
|
257
258
|
}
|
|
258
259
|
}
|
|
260
|
+
return {
|
|
261
|
+
packageJsonPath: pkgJsonPath || void 0,
|
|
262
|
+
packageJson
|
|
263
|
+
};
|
|
264
|
+
}
|
|
265
|
+
async function scanParentDirs(destPath, readPackageJson = false, base = "/") {
|
|
266
|
+
(0, import_assert.default)(import_path.default.isAbsolute(destPath));
|
|
267
|
+
const { packageJsonPath: pkgJsonPath, packageJson } = await findPackageJson(
|
|
268
|
+
destPath,
|
|
269
|
+
readPackageJson,
|
|
270
|
+
base
|
|
271
|
+
);
|
|
259
272
|
const {
|
|
260
273
|
paths: [
|
|
261
274
|
yarnLockPath,
|
|
@@ -1089,6 +1102,7 @@ const installDependencies = (0, import_util.deprecate)(
|
|
|
1089
1102
|
PNPM_10_PREFERRED_AT,
|
|
1090
1103
|
detectPackageManager,
|
|
1091
1104
|
execCommand,
|
|
1105
|
+
findPackageJson,
|
|
1092
1106
|
getEnvForPackageManager,
|
|
1093
1107
|
getNodeBinPath,
|
|
1094
1108
|
getNodeBinPaths,
|
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, resetCustomInstallCommandSet, getEnvForPackageManager, getNodeVersion, getPathForPackageManager, detectPackageManager, getSpawnOptions, getNodeBinPath, getNodeBinPaths, scanParentDirs, traverseUpDirectories } from './fs/run-user-scripts';
|
|
11
|
+
import { spawnAsync, execCommand, spawnCommand, walkParentDirs, getScriptName, installDependencies, runPackageJsonScript, runNpmInstall, runBundleInstall, runPipInstall, runShellScript, runCustomInstallCommand, resetCustomInstallCommandSet, getEnvForPackageManager, getNodeVersion, getPathForPackageManager, detectPackageManager, getSpawnOptions, getNodeBinPath, getNodeBinPaths, scanParentDirs, findPackageJson, 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, resetCustomInstallCommandSet, getEnvForPackageManager, getNodeVersion, getPathForPackageManager, getLatestNodeVersion, getDiscontinuedNodeVersions, getSpawnOptions, 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, resetCustomInstallCommandSet, getEnvForPackageManager, getNodeVersion, getPathForPackageManager, getLatestNodeVersion, getDiscontinuedNodeVersions, getSpawnOptions, getPlatformEnv, getPrefixedEnvVars, streamToBuffer, streamToBufferChunks, debug, isSymbolicLink, isDirectory, getLambdaOptionsFromFunction, scanParentDirs, findPackageJson, getIgnoreFilter, cloneEnv, hardLinkDir, traverseUpDirectories, validateNpmrc, };
|
|
22
22
|
export { EdgeFunction } from './edge-function';
|
|
23
23
|
export { readConfigFile, getPackageJson } from './fs/read-config-file';
|
|
24
24
|
export { normalizePath } from './fs/normalize-path';
|
package/dist/index.js
CHANGED
|
@@ -23740,6 +23740,7 @@ __export(src_exports, {
|
|
|
23740
23740
|
download: () => download,
|
|
23741
23741
|
downloadFile: () => downloadFile,
|
|
23742
23742
|
execCommand: () => execCommand,
|
|
23743
|
+
findPackageJson: () => findPackageJson,
|
|
23743
23744
|
functionsSchema: () => functionsSchema,
|
|
23744
23745
|
generateNodeBuilderFunctions: () => generateNodeBuilderFunctions,
|
|
23745
23746
|
getDiscontinuedNodeVersions: () => getDiscontinuedNodeVersions,
|
|
@@ -25251,7 +25252,7 @@ async function getNodeVersion(destPath, fallbackVersion = process.env.VERCEL_PRO
|
|
|
25251
25252
|
latestVersion.runtime = "nodejs";
|
|
25252
25253
|
return latestVersion;
|
|
25253
25254
|
}
|
|
25254
|
-
const { packageJson } = await
|
|
25255
|
+
const { packageJson } = await findPackageJson(destPath, true);
|
|
25255
25256
|
const configuredVersion = config.nodeVersion || fallbackVersion;
|
|
25256
25257
|
const packageJsonVersion = packageJson?.engines?.node;
|
|
25257
25258
|
const supportedNodeVersion = await getSupportedNodeVersion(
|
|
@@ -25278,7 +25279,7 @@ async function getNodeVersion(destPath, fallbackVersion = process.env.VERCEL_PRO
|
|
|
25278
25279
|
}
|
|
25279
25280
|
return supportedNodeVersion;
|
|
25280
25281
|
}
|
|
25281
|
-
async function
|
|
25282
|
+
async function findPackageJson(destPath, readPackageJson = false, base = "/") {
|
|
25282
25283
|
(0, import_assert6.default)(import_path6.default.isAbsolute(destPath));
|
|
25283
25284
|
const pkgJsonPath = await walkParentDirs({
|
|
25284
25285
|
base,
|
|
@@ -25295,6 +25296,18 @@ async function scanParentDirs(destPath, readPackageJson = false, base = "/") {
|
|
|
25295
25296
|
);
|
|
25296
25297
|
}
|
|
25297
25298
|
}
|
|
25299
|
+
return {
|
|
25300
|
+
packageJsonPath: pkgJsonPath || void 0,
|
|
25301
|
+
packageJson
|
|
25302
|
+
};
|
|
25303
|
+
}
|
|
25304
|
+
async function scanParentDirs(destPath, readPackageJson = false, base = "/") {
|
|
25305
|
+
(0, import_assert6.default)(import_path6.default.isAbsolute(destPath));
|
|
25306
|
+
const { packageJsonPath: pkgJsonPath, packageJson } = await findPackageJson(
|
|
25307
|
+
destPath,
|
|
25308
|
+
readPackageJson,
|
|
25309
|
+
base
|
|
25310
|
+
);
|
|
25298
25311
|
const {
|
|
25299
25312
|
paths: [
|
|
25300
25313
|
yarnLockPath,
|
|
@@ -26836,6 +26849,7 @@ async function isPythonEntrypoint(file) {
|
|
|
26836
26849
|
download,
|
|
26837
26850
|
downloadFile,
|
|
26838
26851
|
execCommand,
|
|
26852
|
+
findPackageJson,
|
|
26839
26853
|
functionsSchema,
|
|
26840
26854
|
generateNodeBuilderFunctions,
|
|
26841
26855
|
getDiscontinuedNodeVersions,
|