@vercel/build-utils 8.6.0 → 8.8.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,17 @@
1
1
  # @vercel/build-utils
2
2
 
3
+ ## 8.8.0
4
+
5
+ ### Minor Changes
6
+
7
+ - Add bun detection using bun.lock ([#12740](https://github.com/vercel/vercel/pull/12740))
8
+
9
+ ## 8.7.0
10
+
11
+ ### Minor Changes
12
+
13
+ - Support splitting archive deployments in parts. ([#12671](https://github.com/vercel/vercel/pull/12671))
14
+
3
15
  ## 8.6.0
4
16
 
5
17
  ### Minor Changes
@@ -239,7 +239,13 @@ async function scanParentDirs(destPath, readPackageJson = false, base = "/") {
239
239
  });
240
240
  const packageJson = readPackageJson && pkgJsonPath ? JSON.parse(await import_fs_extra.default.readFile(pkgJsonPath, "utf8")) : void 0;
241
241
  const {
242
- paths: [yarnLockPath, npmLockPath, pnpmLockPath, bunLockPath],
242
+ paths: [
243
+ yarnLockPath,
244
+ npmLockPath,
245
+ pnpmLockPath,
246
+ bunLockTextPath,
247
+ bunLockBinPath
248
+ ],
243
249
  packageJsonPackageManager
244
250
  } = await walkParentDirsMulti({
245
251
  base,
@@ -248,17 +254,19 @@ async function scanParentDirs(destPath, readPackageJson = false, base = "/") {
248
254
  "yarn.lock",
249
255
  "package-lock.json",
250
256
  "pnpm-lock.yaml",
257
+ "bun.lock",
251
258
  "bun.lockb"
252
259
  ]
253
260
  });
254
261
  let lockfilePath;
255
262
  let lockfileVersion;
256
263
  let cliType;
257
- const [hasYarnLock, packageLockJson, pnpmLockYaml, bunLockBin] = await Promise.all([
264
+ const bunLockPath = bunLockTextPath ?? bunLockBinPath;
265
+ const [hasYarnLock, packageLockJson, pnpmLockYaml, bunLock] = await Promise.all([
258
266
  Boolean(yarnLockPath),
259
267
  npmLockPath ? (0, import_read_config_file.readConfigFile)(npmLockPath) : null,
260
268
  pnpmLockPath ? (0, import_read_config_file.readConfigFile)(pnpmLockPath) : null,
261
- bunLockPath ? import_fs_extra.default.readFile(bunLockPath, "utf8") : null
269
+ bunLockPath ? import_fs_extra.default.readFile(bunLockPath) : null
262
270
  ]);
263
271
  const rootProjectInfo = readPackageJson ? await readProjectRootInfo({
264
272
  base,
@@ -269,10 +277,10 @@ async function scanParentDirs(destPath, readPackageJson = false, base = "/") {
269
277
  turboVersionRange,
270
278
  rootProjectInfo?.rootDir
271
279
  ) : void 0;
272
- if (bunLockBin && hasYarnLock) {
280
+ if (bunLock && hasYarnLock) {
273
281
  cliType = "bun";
274
282
  lockfilePath = bunLockPath;
275
- lockfileVersion = 0;
283
+ lockfileVersion = bunLockTextPath ? 1 : 0;
276
284
  } else if (hasYarnLock) {
277
285
  cliType = "yarn";
278
286
  lockfilePath = yarnLockPath;
@@ -284,10 +292,10 @@ async function scanParentDirs(destPath, readPackageJson = false, base = "/") {
284
292
  cliType = "npm";
285
293
  lockfilePath = npmLockPath;
286
294
  lockfileVersion = packageLockJson.lockfileVersion;
287
- } else if (bunLockBin) {
295
+ } else if (bunLock) {
288
296
  cliType = "bun";
289
297
  lockfilePath = bunLockPath;
290
- lockfileVersion = 0;
298
+ lockfileVersion = bunLockTextPath ? 1 : 0;
291
299
  } else {
292
300
  cliType = detectPackageManagerNameWithoutLockfile(
293
301
  packageJsonPackageManager,
@@ -751,7 +759,7 @@ function detectPackageManager(cliType, lockfileVersion) {
751
759
  case "bun":
752
760
  return {
753
761
  path: "/bun1",
754
- detectedLockfile: "bun.lockb",
762
+ detectedLockfile: lockfileVersion === 0 ? "bun.lockb" : "bun.lock",
755
763
  detectedPackageManager: "bun@1.x"
756
764
  };
757
765
  case "yarn":
@@ -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;
@@ -24771,7 +24798,13 @@ async function scanParentDirs(destPath, readPackageJson = false, base = "/") {
24771
24798
  });
24772
24799
  const packageJson = readPackageJson && pkgJsonPath ? JSON.parse(await import_fs_extra7.default.readFile(pkgJsonPath, "utf8")) : void 0;
24773
24800
  const {
24774
- paths: [yarnLockPath, npmLockPath, pnpmLockPath, bunLockPath],
24801
+ paths: [
24802
+ yarnLockPath,
24803
+ npmLockPath,
24804
+ pnpmLockPath,
24805
+ bunLockTextPath,
24806
+ bunLockBinPath
24807
+ ],
24775
24808
  packageJsonPackageManager
24776
24809
  } = await walkParentDirsMulti({
24777
24810
  base,
@@ -24780,17 +24813,19 @@ async function scanParentDirs(destPath, readPackageJson = false, base = "/") {
24780
24813
  "yarn.lock",
24781
24814
  "package-lock.json",
24782
24815
  "pnpm-lock.yaml",
24816
+ "bun.lock",
24783
24817
  "bun.lockb"
24784
24818
  ]
24785
24819
  });
24786
24820
  let lockfilePath;
24787
24821
  let lockfileVersion;
24788
24822
  let cliType;
24789
- const [hasYarnLock, packageLockJson, pnpmLockYaml, bunLockBin] = await Promise.all([
24823
+ const bunLockPath = bunLockTextPath ?? bunLockBinPath;
24824
+ const [hasYarnLock, packageLockJson, pnpmLockYaml, bunLock] = await Promise.all([
24790
24825
  Boolean(yarnLockPath),
24791
24826
  npmLockPath ? readConfigFile(npmLockPath) : null,
24792
24827
  pnpmLockPath ? readConfigFile(pnpmLockPath) : null,
24793
- bunLockPath ? import_fs_extra7.default.readFile(bunLockPath, "utf8") : null
24828
+ bunLockPath ? import_fs_extra7.default.readFile(bunLockPath) : null
24794
24829
  ]);
24795
24830
  const rootProjectInfo = readPackageJson ? await readProjectRootInfo({
24796
24831
  base,
@@ -24801,10 +24836,10 @@ async function scanParentDirs(destPath, readPackageJson = false, base = "/") {
24801
24836
  turboVersionRange,
24802
24837
  rootProjectInfo?.rootDir
24803
24838
  ) : void 0;
24804
- if (bunLockBin && hasYarnLock) {
24839
+ if (bunLock && hasYarnLock) {
24805
24840
  cliType = "bun";
24806
24841
  lockfilePath = bunLockPath;
24807
- lockfileVersion = 0;
24842
+ lockfileVersion = bunLockTextPath ? 1 : 0;
24808
24843
  } else if (hasYarnLock) {
24809
24844
  cliType = "yarn";
24810
24845
  lockfilePath = yarnLockPath;
@@ -24816,10 +24851,10 @@ async function scanParentDirs(destPath, readPackageJson = false, base = "/") {
24816
24851
  cliType = "npm";
24817
24852
  lockfilePath = npmLockPath;
24818
24853
  lockfileVersion = packageLockJson.lockfileVersion;
24819
- } else if (bunLockBin) {
24854
+ } else if (bunLock) {
24820
24855
  cliType = "bun";
24821
24856
  lockfilePath = bunLockPath;
24822
- lockfileVersion = 0;
24857
+ lockfileVersion = bunLockTextPath ? 1 : 0;
24823
24858
  } else {
24824
24859
  cliType = detectPackageManagerNameWithoutLockfile(
24825
24860
  packageJsonPackageManager,
@@ -25283,7 +25318,7 @@ function detectPackageManager(cliType, lockfileVersion) {
25283
25318
  case "bun":
25284
25319
  return {
25285
25320
  path: "/bun1",
25286
- detectedLockfile: "bun.lockb",
25321
+ detectedLockfile: lockfileVersion === 0 ? "bun.lockb" : "bun.lock",
25287
25322
  detectedPackageManager: "bun@1.x"
25288
25323
  };
25289
25324
  case "yarn":
@@ -25812,6 +25847,7 @@ async function getInstalledPackageVersion(packageName, path7) {
25812
25847
  spawnAsync,
25813
25848
  spawnCommand,
25814
25849
  streamToBuffer,
25850
+ streamToBufferChunks,
25815
25851
  traverseUpDirectories,
25816
25852
  validateNpmrc,
25817
25853
  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.8.0",
4
4
  "license": "Apache-2.0",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.js",
@@ -53,7 +53,7 @@
53
53
  "build": "node build.mjs",
54
54
  "test": "jest --reporters=default --reporters=jest-junit --env node --verbose --bail --runInBand",
55
55
  "vitest-run": "vitest -c ../../vitest.config.mts",
56
- "vitest-unit": "glob --absolute 'test/unit.*.test.ts'",
56
+ "vitest-unit": "glob --absolute 'test/unit.*test.ts'",
57
57
  "vitest-e2e": "glob --absolute 'test/integration-*.test.ts'",
58
58
  "type-check": "tsc --noEmit"
59
59
  }