@vercel/build-utils 8.6.0 → 8.7.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 +6 -0
- package/dist/fs/stream-to-buffer.d.ts +1 -0
- package/dist/fs/stream-to-buffer.js +32 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +28 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
@@ -28,7 +28,8 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
28
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
29
29
|
var stream_to_buffer_exports = {};
|
30
30
|
__export(stream_to_buffer_exports, {
|
31
|
-
default: () => streamToBuffer
|
31
|
+
default: () => streamToBuffer,
|
32
|
+
streamToBufferChunks: () => streamToBufferChunks
|
32
33
|
});
|
33
34
|
module.exports = __toCommonJS(stream_to_buffer_exports);
|
34
35
|
var import_end_of_stream = __toESM(require("end-of-stream"));
|
@@ -54,3 +55,33 @@ function streamToBuffer(stream) {
|
|
54
55
|
});
|
55
56
|
});
|
56
57
|
}
|
58
|
+
const MB = 1024 * 1024;
|
59
|
+
async function streamToBufferChunks(stream, chunkSize = 100 * MB) {
|
60
|
+
const chunks = [];
|
61
|
+
let currentChunk = [];
|
62
|
+
let currentSize = 0;
|
63
|
+
for await (const chunk of stream) {
|
64
|
+
const buffer = Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk);
|
65
|
+
let offset = 0;
|
66
|
+
while (offset < buffer.length) {
|
67
|
+
const remainingSpace = chunkSize - currentSize;
|
68
|
+
const sliceSize = Math.min(remainingSpace, buffer.length - offset);
|
69
|
+
currentChunk.push(buffer.slice(offset, offset + sliceSize));
|
70
|
+
currentSize += sliceSize;
|
71
|
+
offset += sliceSize;
|
72
|
+
if (currentSize >= chunkSize) {
|
73
|
+
chunks.push(Buffer.concat(currentChunk));
|
74
|
+
currentChunk = [];
|
75
|
+
currentSize = 0;
|
76
|
+
}
|
77
|
+
}
|
78
|
+
}
|
79
|
+
if (currentChunk.length > 0) {
|
80
|
+
chunks.push(Buffer.concat(currentChunk));
|
81
|
+
}
|
82
|
+
return chunks;
|
83
|
+
}
|
84
|
+
// Annotate the CommonJS export names for ESM import in node:
|
85
|
+
0 && (module.exports = {
|
86
|
+
streamToBufferChunks
|
87
|
+
});
|
package/dist/index.d.ts
CHANGED
@@ -10,7 +10,7 @@ import glob, { GlobOptions } from './fs/glob';
|
|
10
10
|
import rename from './fs/rename';
|
11
11
|
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';
|
12
12
|
import { getLatestNodeVersion, getDiscontinuedNodeVersions, getSupportedNodeVersion } from './fs/node-version';
|
13
|
-
import streamToBuffer from './fs/stream-to-buffer';
|
13
|
+
import streamToBuffer, { streamToBufferChunks } from './fs/stream-to-buffer';
|
14
14
|
import debug from './debug';
|
15
15
|
import getIgnoreFilter from './get-ignore-filter';
|
16
16
|
import { getPlatformEnv } from './get-platform-env';
|
@@ -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, runNpmInstall, runBundleInstall, runPipInstall, runShellScript, runCustomInstallCommand, getEnvForPackageManager, getNodeVersion, getPathForPackageManager, getLatestNodeVersion, getDiscontinuedNodeVersions, getSpawnOptions, getPlatformEnv, getPrefixedEnvVars, streamToBuffer, 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, 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
@@ -23499,6 +23499,7 @@ __export(src_exports, {
|
|
23499
23499
|
spawnAsync: () => spawnAsync,
|
23500
23500
|
spawnCommand: () => spawnCommand,
|
23501
23501
|
streamToBuffer: () => streamToBuffer,
|
23502
|
+
streamToBufferChunks: () => streamToBufferChunks,
|
23502
23503
|
traverseUpDirectories: () => traverseUpDirectories,
|
23503
23504
|
validateNpmrc: () => validateNpmrc,
|
23504
23505
|
walkParentDirs: () => walkParentDirs
|
@@ -23872,6 +23873,32 @@ function streamToBuffer(stream) {
|
|
23872
23873
|
});
|
23873
23874
|
});
|
23874
23875
|
}
|
23876
|
+
var MB = 1024 * 1024;
|
23877
|
+
async function streamToBufferChunks(stream, chunkSize = 100 * MB) {
|
23878
|
+
const chunks = [];
|
23879
|
+
let currentChunk = [];
|
23880
|
+
let currentSize = 0;
|
23881
|
+
for await (const chunk of stream) {
|
23882
|
+
const buffer = Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk);
|
23883
|
+
let offset = 0;
|
23884
|
+
while (offset < buffer.length) {
|
23885
|
+
const remainingSpace = chunkSize - currentSize;
|
23886
|
+
const sliceSize = Math.min(remainingSpace, buffer.length - offset);
|
23887
|
+
currentChunk.push(buffer.slice(offset, offset + sliceSize));
|
23888
|
+
currentSize += sliceSize;
|
23889
|
+
offset += sliceSize;
|
23890
|
+
if (currentSize >= chunkSize) {
|
23891
|
+
chunks.push(Buffer.concat(currentChunk));
|
23892
|
+
currentChunk = [];
|
23893
|
+
currentSize = 0;
|
23894
|
+
}
|
23895
|
+
}
|
23896
|
+
}
|
23897
|
+
if (currentChunk.length > 0) {
|
23898
|
+
chunks.push(Buffer.concat(currentChunk));
|
23899
|
+
}
|
23900
|
+
return chunks;
|
23901
|
+
}
|
23875
23902
|
|
23876
23903
|
// src/fs/download.ts
|
23877
23904
|
var S_IFDIR = 16384;
|
@@ -25812,6 +25839,7 @@ async function getInstalledPackageVersion(packageName, path7) {
|
|
25812
25839
|
spawnAsync,
|
25813
25840
|
spawnCommand,
|
25814
25841
|
streamToBuffer,
|
25842
|
+
streamToBufferChunks,
|
25815
25843
|
traverseUpDirectories,
|
25816
25844
|
validateNpmrc,
|
25817
25845
|
walkParentDirs
|