@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 CHANGED
@@ -1,5 +1,11 @@
1
1
  # @vercel/build-utils
2
2
 
3
+ ## 8.7.0
4
+
5
+ ### Minor Changes
6
+
7
+ - Support splitting archive deployments in parts. ([#12671](https://github.com/vercel/vercel/pull/12671))
8
+
3
9
  ## 8.6.0
4
10
 
5
11
  ### Minor Changes
@@ -1,2 +1,3 @@
1
1
  /// <reference types="node" />
2
2
  export default function streamToBuffer(stream: NodeJS.ReadableStream): Promise<Buffer>;
3
+ export declare function streamToBufferChunks(stream: NodeJS.ReadableStream, chunkSize?: number): Promise<Buffer[]>;
@@ -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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vercel/build-utils",
3
- "version": "8.6.0",
3
+ "version": "8.7.0",
4
4
  "license": "Apache-2.0",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.js",