@vercel/build-utils 2.15.2-canary.5 → 2.16.1-canary.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.
@@ -186,15 +186,20 @@ async function scanParentDirs(destPath, readPackageJson = false) {
186
186
  fs_extra_1.default.pathExists(path_1.default.join(currentDestPath, 'yarn.lock')),
187
187
  read_config_file_1.readConfigFile(path_1.default.join(currentDestPath, 'pnpm-lock.yaml')),
188
188
  ]);
189
- if (packageLockJson && !hasYarnLock && !pnpmLockYaml) {
190
- cliType = 'npm';
191
- lockfileVersion = packageLockJson.lockfileVersion;
189
+ // Priority order is Yarn > pnpm > npm
190
+ // - find highest priority lock file and use that
191
+ if (hasYarnLock) {
192
+ cliType = 'yarn';
192
193
  }
193
- if (!packageLockJson && !hasYarnLock && pnpmLockYaml) {
194
+ else if (pnpmLockYaml) {
194
195
  cliType = 'pnpm';
195
196
  // just ensure that it is read as a number and not a string
196
197
  lockfileVersion = Number(pnpmLockYaml.lockfileVersion);
197
198
  }
199
+ else if (packageLockJson) {
200
+ cliType = 'npm';
201
+ lockfileVersion = packageLockJson.lockfileVersion;
202
+ }
198
203
  // Only stop iterating if a lockfile was found, because it's possible
199
204
  // that the lockfile is in a higher path than where the `package.json`
200
205
  // file was found.
@@ -381,7 +386,7 @@ async function runBundleInstall(destPath, args = [], spawnOpts, meta) {
381
386
  exports.runBundleInstall = runBundleInstall;
382
387
  async function runPipInstall(destPath, args = [], spawnOpts, meta) {
383
388
  if (meta && meta.isDev) {
384
- debug_1.default('Skipping dependency installation because dev mode is enabled');
389
+ debug_1.default('Skipping dependency installation because dev mode is enabled');
385
390
  return;
386
391
  }
387
392
  assert_1.default(path_1.default.isAbsolute(destPath));
package/dist/index.js CHANGED
@@ -14791,6 +14791,8 @@ ZipFile.prototype.addEmptyDirectory = function(metadataPath, options) {
14791
14791
  pumpEntries(self);
14792
14792
  };
14793
14793
 
14794
+ var eocdrSignatureBuffer = bufferFrom([0x50, 0x4b, 0x05, 0x06]);
14795
+
14794
14796
  ZipFile.prototype.end = function(options, finalSizeCallback) {
14795
14797
  if (typeof options === "function") {
14796
14798
  finalSizeCallback = options;
@@ -14801,6 +14803,20 @@ ZipFile.prototype.end = function(options, finalSizeCallback) {
14801
14803
  this.ended = true;
14802
14804
  this.finalSizeCallback = finalSizeCallback;
14803
14805
  this.forceZip64Eocd = !!options.forceZip64Format;
14806
+ if (options.comment) {
14807
+ if (typeof options.comment === "string") {
14808
+ this.comment = encodeCp437(options.comment);
14809
+ } else {
14810
+ // It should be a Buffer
14811
+ this.comment = options.comment;
14812
+ }
14813
+ if (this.comment.length > 0xffff) throw new Error("comment is too large");
14814
+ // gotta check for this, because the zipfile format is actually ambiguous.
14815
+ if (bufferIncludes(this.comment, eocdrSignatureBuffer)) throw new Error("comment contains end of central directory record signature");
14816
+ } else {
14817
+ // no comment.
14818
+ this.comment = EMPTY_BUFFER;
14819
+ }
14804
14820
  pumpEntries(this);
14805
14821
  };
14806
14822
 
@@ -14909,7 +14925,7 @@ function calculateFinalSize(self) {
14909
14925
  }
14910
14926
  }
14911
14927
 
14912
- centralDirectorySize += CENTRAL_DIRECTORY_RECORD_FIXED_SIZE + entry.utf8FileName.length;
14928
+ centralDirectorySize += CENTRAL_DIRECTORY_RECORD_FIXED_SIZE + entry.utf8FileName.length + entry.fileComment.length;
14913
14929
  if (useZip64Format) {
14914
14930
  centralDirectorySize += ZIP64_EXTENDED_INFORMATION_EXTRA_FIELD_SIZE;
14915
14931
  }
@@ -14923,7 +14939,7 @@ function calculateFinalSize(self) {
14923
14939
  // use zip64 end of central directory stuff
14924
14940
  endOfCentralDirectorySize += ZIP64_END_OF_CENTRAL_DIRECTORY_RECORD_SIZE + ZIP64_END_OF_CENTRAL_DIRECTORY_LOCATOR_SIZE;
14925
14941
  }
14926
- endOfCentralDirectorySize += END_OF_CENTRAL_DIRECTORY_RECORD_SIZE;
14942
+ endOfCentralDirectorySize += END_OF_CENTRAL_DIRECTORY_RECORD_SIZE + self.comment.length;
14927
14943
  return pretendOutputCursor + centralDirectorySize + endOfCentralDirectorySize;
14928
14944
  }
14929
14945
 
@@ -14960,7 +14976,7 @@ function getEndOfCentralDirectoryRecord(self, actuallyJustTellMeHowLongItWouldBe
14960
14976
  }
14961
14977
  }
14962
14978
 
14963
- var eocdrBuffer = new Buffer(END_OF_CENTRAL_DIRECTORY_RECORD_SIZE);
14979
+ var eocdrBuffer = bufferAlloc(END_OF_CENTRAL_DIRECTORY_RECORD_SIZE + self.comment.length);
14964
14980
  // end of central dir signature 4 bytes (0x06054b50)
14965
14981
  eocdrBuffer.writeUInt32LE(0x06054b50, 0);
14966
14982
  // number of this disk 2 bytes
@@ -14976,15 +14992,15 @@ function getEndOfCentralDirectoryRecord(self, actuallyJustTellMeHowLongItWouldBe
14976
14992
  // offset of start of central directory with respect to the starting disk number 4 bytes
14977
14993
  eocdrBuffer.writeUInt32LE(normalOffsetOfStartOfCentralDirectory, 16);
14978
14994
  // .ZIP file comment length 2 bytes
14979
- eocdrBuffer.writeUInt16LE(0, 20);
14995
+ eocdrBuffer.writeUInt16LE(self.comment.length, 20);
14980
14996
  // .ZIP file comment (variable size)
14981
- // no comment
14997
+ self.comment.copy(eocdrBuffer, 22);
14982
14998
 
14983
14999
  if (!needZip64Format) return eocdrBuffer;
14984
15000
 
14985
15001
  // ZIP64 format
14986
15002
  // ZIP64 End of Central Directory Record
14987
- var zip64EocdrBuffer = new Buffer(ZIP64_END_OF_CENTRAL_DIRECTORY_RECORD_SIZE);
15003
+ var zip64EocdrBuffer = bufferAlloc(ZIP64_END_OF_CENTRAL_DIRECTORY_RECORD_SIZE);
14988
15004
  // zip64 end of central dir signature 4 bytes (0x06064b50)
14989
15005
  zip64EocdrBuffer.writeUInt32LE(0x06064b50, 0);
14990
15006
  // size of zip64 end of central directory record 8 bytes
@@ -15010,7 +15026,7 @@ function getEndOfCentralDirectoryRecord(self, actuallyJustTellMeHowLongItWouldBe
15010
15026
 
15011
15027
 
15012
15028
  // ZIP64 End of Central Directory Locator
15013
- var zip64EocdlBuffer = new Buffer(ZIP64_END_OF_CENTRAL_DIRECTORY_LOCATOR_SIZE);
15029
+ var zip64EocdlBuffer = bufferAlloc(ZIP64_END_OF_CENTRAL_DIRECTORY_LOCATOR_SIZE);
15014
15030
  // zip64 end of central dir locator signature 4 bytes (0x07064b50)
15015
15031
  zip64EocdlBuffer.writeUInt32LE(0x07064b50, 0);
15016
15032
  // number of the disk with the start of the zip64 end of central directory 4 bytes
@@ -15043,12 +15059,11 @@ function validateMetadataPath(metadataPath, isDirectory) {
15043
15059
  return metadataPath;
15044
15060
  }
15045
15061
 
15046
- var defaultFileMode = parseInt("0100664", 8);
15047
- var defaultDirectoryMode = parseInt("040775", 8);
15062
+ var EMPTY_BUFFER = bufferAlloc(0);
15048
15063
 
15049
15064
  // this class is not part of the public API
15050
15065
  function Entry(metadataPath, isDirectory, options) {
15051
- this.utf8FileName = new Buffer(metadataPath);
15066
+ this.utf8FileName = bufferFrom(metadataPath);
15052
15067
  if (this.utf8FileName.length > 0xffff) throw new Error("utf8 file name too long. " + utf8FileName.length + " > " + 0xffff);
15053
15068
  this.isDirectory = isDirectory;
15054
15069
  this.state = Entry.WAITING_FOR_METADATA;
@@ -15056,7 +15071,7 @@ function Entry(metadataPath, isDirectory, options) {
15056
15071
  if (options.mode != null) {
15057
15072
  this.setFileAttributesMode(options.mode);
15058
15073
  } else {
15059
- this.setFileAttributesMode(isDirectory ? defaultDirectoryMode : defaultFileMode);
15074
+ this.setFileAttributesMode(isDirectory ? 0o40775 : 0o100664);
15060
15075
  }
15061
15076
  if (isDirectory) {
15062
15077
  this.crcAndFileSizeKnown = true;
@@ -15078,6 +15093,18 @@ function Entry(metadataPath, isDirectory, options) {
15078
15093
  if (options.compress != null) this.compress = !!options.compress;
15079
15094
  }
15080
15095
  this.forceZip64Format = !!options.forceZip64Format;
15096
+ if (options.fileComment) {
15097
+ if (typeof options.fileComment === "string") {
15098
+ this.fileComment = bufferFrom(options.fileComment, "utf-8");
15099
+ } else {
15100
+ // It should be a Buffer
15101
+ this.fileComment = options.fileComment;
15102
+ }
15103
+ if (this.fileComment.length > 0xffff) throw new Error("fileComment is too large");
15104
+ } else {
15105
+ // no comment.
15106
+ this.fileComment = EMPTY_BUFFER;
15107
+ }
15081
15108
  }
15082
15109
  Entry.WAITING_FOR_METADATA = 0;
15083
15110
  Entry.READY_TO_PUMP_FILE_DATA = 1;
@@ -15123,7 +15150,7 @@ Entry.prototype.getLocalFileHeader = function() {
15123
15150
  uncompressedSize = this.uncompressedSize;
15124
15151
  }
15125
15152
 
15126
- var fixedSizeStuff = new Buffer(LOCAL_FILE_HEADER_FIXED_SIZE);
15153
+ var fixedSizeStuff = bufferAlloc(LOCAL_FILE_HEADER_FIXED_SIZE);
15127
15154
  var generalPurposeBitFlag = FILE_NAME_IS_UTF8;
15128
15155
  if (!this.crcAndFileSizeKnown) generalPurposeBitFlag |= UNKNOWN_CRC32_AND_FILE_SIZES;
15129
15156
 
@@ -15162,10 +15189,10 @@ var ZIP64_DATA_DESCRIPTOR_SIZE = 24;
15162
15189
  Entry.prototype.getDataDescriptor = function() {
15163
15190
  if (this.crcAndFileSizeKnown) {
15164
15191
  // the Mac Archive Utility requires this not be present unless we set general purpose bit 3
15165
- return new Buffer(0);
15192
+ return EMPTY_BUFFER;
15166
15193
  }
15167
15194
  if (!this.useZip64Format()) {
15168
- var buffer = new Buffer(DATA_DESCRIPTOR_SIZE);
15195
+ var buffer = bufferAlloc(DATA_DESCRIPTOR_SIZE);
15169
15196
  // optional signature (required according to Archive Utility)
15170
15197
  buffer.writeUInt32LE(0x08074b50, 0);
15171
15198
  // crc-32 4 bytes
@@ -15177,7 +15204,7 @@ Entry.prototype.getDataDescriptor = function() {
15177
15204
  return buffer;
15178
15205
  } else {
15179
15206
  // ZIP64 format
15180
- var buffer = new Buffer(ZIP64_DATA_DESCRIPTOR_SIZE);
15207
+ var buffer = bufferAlloc(ZIP64_DATA_DESCRIPTOR_SIZE);
15181
15208
  // optional signature (unknown if anyone cares about this)
15182
15209
  buffer.writeUInt32LE(0x08074b50, 0);
15183
15210
  // crc-32 4 bytes
@@ -15192,7 +15219,7 @@ Entry.prototype.getDataDescriptor = function() {
15192
15219
  var CENTRAL_DIRECTORY_RECORD_FIXED_SIZE = 46;
15193
15220
  var ZIP64_EXTENDED_INFORMATION_EXTRA_FIELD_SIZE = 28;
15194
15221
  Entry.prototype.getCentralDirectoryRecord = function() {
15195
- var fixedSizeStuff = new Buffer(CENTRAL_DIRECTORY_RECORD_FIXED_SIZE);
15222
+ var fixedSizeStuff = bufferAlloc(CENTRAL_DIRECTORY_RECORD_FIXED_SIZE);
15196
15223
  var generalPurposeBitFlag = FILE_NAME_IS_UTF8;
15197
15224
  if (!this.crcAndFileSizeKnown) generalPurposeBitFlag |= UNKNOWN_CRC32_AND_FILE_SIZES;
15198
15225
 
@@ -15208,7 +15235,7 @@ Entry.prototype.getCentralDirectoryRecord = function() {
15208
15235
  versionNeededToExtract = VERSION_NEEDED_TO_EXTRACT_ZIP64;
15209
15236
 
15210
15237
  // ZIP64 extended information extra field
15211
- zeiefBuffer = new Buffer(ZIP64_EXTENDED_INFORMATION_EXTRA_FIELD_SIZE);
15238
+ zeiefBuffer = bufferAlloc(ZIP64_EXTENDED_INFORMATION_EXTRA_FIELD_SIZE);
15212
15239
  // 0x0001 2 bytes Tag for this "extra" block type
15213
15240
  zeiefBuffer.writeUInt16LE(0x0001, 0);
15214
15241
  // Size 2 bytes Size of this "extra" block
@@ -15223,7 +15250,7 @@ Entry.prototype.getCentralDirectoryRecord = function() {
15223
15250
  // (omit)
15224
15251
  } else {
15225
15252
  versionNeededToExtract = VERSION_NEEDED_TO_EXTRACT_UTF8;
15226
- zeiefBuffer = new Buffer(0);
15253
+ zeiefBuffer = EMPTY_BUFFER;
15227
15254
  }
15228
15255
 
15229
15256
  // central file header signature 4 bytes (0x02014b50)
@@ -15251,7 +15278,7 @@ Entry.prototype.getCentralDirectoryRecord = function() {
15251
15278
  // extra field length 2 bytes
15252
15279
  fixedSizeStuff.writeUInt16LE(zeiefBuffer.length, 30);
15253
15280
  // file comment length 2 bytes
15254
- fixedSizeStuff.writeUInt16LE(0, 32);
15281
+ fixedSizeStuff.writeUInt16LE(this.fileComment.length, 32);
15255
15282
  // disk number start 2 bytes
15256
15283
  fixedSizeStuff.writeUInt16LE(0, 34);
15257
15284
  // internal file attributes 2 bytes
@@ -15268,7 +15295,7 @@ Entry.prototype.getCentralDirectoryRecord = function() {
15268
15295
  // extra field (variable size)
15269
15296
  zeiefBuffer,
15270
15297
  // file comment (variable size)
15271
- // empty comment
15298
+ this.fileComment,
15272
15299
  ]);
15273
15300
  };
15274
15301
  Entry.prototype.getCompressionMethod = function() {
@@ -15292,7 +15319,7 @@ function dateToDosDateTime(jsDate) {
15292
15319
  }
15293
15320
 
15294
15321
  function writeUInt64LE(buffer, n, offset) {
15295
- // can't use bitshift here, because JavaScript only allows bitshiting on 32-bit integers.
15322
+ // can't use bitshift here, because JavaScript only allows bitshifting on 32-bit integers.
15296
15323
  var high = Math.floor(n / 0x100000000);
15297
15324
  var low = n % 0x100000000;
15298
15325
  buffer.writeUInt32LE(low, offset);
@@ -15323,6 +15350,87 @@ Crc32Watcher.prototype._transform = function(chunk, encoding, cb) {
15323
15350
  cb(null, chunk);
15324
15351
  };
15325
15352
 
15353
+ var cp437 = '\u0000☺☻♥♦♣♠•◘○◙♂♀♪♫☼►◄↕‼¶§▬↨↑↓→←∟↔▲▼ !"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~⌂ÇüéâäàåçêëèïîìÄÅÉæÆôöòûùÿÖÜ¢£¥₧ƒáíóúñѪº¿⌐¬½¼¡«»░▒▓│┤╡╢╖╕╣║╗╝╜╛┐└┴┬├─┼╞╟╚╔╩╦╠═╬╧╨╤╥╙╘╒╓╫╪┘┌█▄▌▐▀αßΓπΣσµτΦΘΩδ∞φε∩≡±≥≤⌠⌡÷≈°∙·√ⁿ²■ ';
15354
+ if (cp437.length !== 256) throw new Error("assertion failure");
15355
+ var reverseCp437 = null;
15356
+
15357
+ function encodeCp437(string) {
15358
+ if (/^[\x20-\x7e]*$/.test(string)) {
15359
+ // CP437, ASCII, and UTF-8 overlap in this range.
15360
+ return bufferFrom(string, "utf-8");
15361
+ }
15362
+
15363
+ // This is the slow path.
15364
+ if (reverseCp437 == null) {
15365
+ // cache this once
15366
+ reverseCp437 = {};
15367
+ for (var i = 0; i < cp437.length; i++) {
15368
+ reverseCp437[cp437[i]] = i;
15369
+ }
15370
+ }
15371
+
15372
+ var result = bufferAlloc(string.length);
15373
+ for (var i = 0; i < string.length; i++) {
15374
+ var b = reverseCp437[string[i]];
15375
+ if (b == null) throw new Error("character not encodable in CP437: " + JSON.stringify(string[i]));
15376
+ result[i] = b;
15377
+ }
15378
+
15379
+ return result;
15380
+ }
15381
+
15382
+ function bufferAlloc(size) {
15383
+ bufferAlloc = modern;
15384
+ try {
15385
+ return bufferAlloc(size);
15386
+ } catch (e) {
15387
+ bufferAlloc = legacy;
15388
+ return bufferAlloc(size);
15389
+ }
15390
+ function modern(size) {
15391
+ return Buffer.allocUnsafe(size);
15392
+ }
15393
+ function legacy(size) {
15394
+ return new Buffer(size);
15395
+ }
15396
+ }
15397
+ function bufferFrom(something, encoding) {
15398
+ bufferFrom = modern;
15399
+ try {
15400
+ return bufferFrom(something, encoding);
15401
+ } catch (e) {
15402
+ bufferFrom = legacy;
15403
+ return bufferFrom(something, encoding);
15404
+ }
15405
+ function modern(something, encoding) {
15406
+ return Buffer.from(something, encoding);
15407
+ }
15408
+ function legacy(something, encoding) {
15409
+ return new Buffer(something, encoding);
15410
+ }
15411
+ }
15412
+ function bufferIncludes(buffer, content) {
15413
+ bufferIncludes = modern;
15414
+ try {
15415
+ return bufferIncludes(buffer, content);
15416
+ } catch (e) {
15417
+ bufferIncludes = legacy;
15418
+ return bufferIncludes(buffer, content);
15419
+ }
15420
+ function modern(buffer, content) {
15421
+ return buffer.includes(content);
15422
+ }
15423
+ function legacy(buffer, content) {
15424
+ for (var i = 0; i <= buffer.length - content.length; i++) {
15425
+ for (var j = 0;; j++) {
15426
+ if (j === content.length) return true;
15427
+ if (buffer[i + j] !== content[j]) break;
15428
+ }
15429
+ }
15430
+ return false;
15431
+ }
15432
+ }
15433
+
15326
15434
 
15327
15435
  /***/ }),
15328
15436
 
@@ -34941,15 +35049,20 @@ async function scanParentDirs(destPath, readPackageJson = false) {
34941
35049
  fs_extra_1.default.pathExists(path_1.default.join(currentDestPath, 'yarn.lock')),
34942
35050
  read_config_file_1.readConfigFile(path_1.default.join(currentDestPath, 'pnpm-lock.yaml')),
34943
35051
  ]);
34944
- if (packageLockJson && !hasYarnLock && !pnpmLockYaml) {
34945
- cliType = 'npm';
34946
- lockfileVersion = packageLockJson.lockfileVersion;
35052
+ // Priority order is Yarn > pnpm > npm
35053
+ // - find highest priority lock file and use that
35054
+ if (hasYarnLock) {
35055
+ cliType = 'yarn';
34947
35056
  }
34948
- if (!packageLockJson && !hasYarnLock && pnpmLockYaml) {
35057
+ else if (pnpmLockYaml) {
34949
35058
  cliType = 'pnpm';
34950
35059
  // just ensure that it is read as a number and not a string
34951
35060
  lockfileVersion = Number(pnpmLockYaml.lockfileVersion);
34952
35061
  }
35062
+ else if (packageLockJson) {
35063
+ cliType = 'npm';
35064
+ lockfileVersion = packageLockJson.lockfileVersion;
35065
+ }
34953
35066
  // Only stop iterating if a lockfile was found, because it's possible
34954
35067
  // that the lockfile is in a higher path than where the `package.json`
34955
35068
  // file was found.
@@ -35136,7 +35249,7 @@ async function runBundleInstall(destPath, args = [], spawnOpts, meta) {
35136
35249
  exports.runBundleInstall = runBundleInstall;
35137
35250
  async function runPipInstall(destPath, args = [], spawnOpts, meta) {
35138
35251
  if (meta && meta.isDev) {
35139
- debug_1.default('Skipping dependency installation because dev mode is enabled');
35252
+ debug_1.default('Skipping dependency installation because dev mode is enabled');
35140
35253
  return;
35141
35254
  }
35142
35255
  assert_1.default(path_1.default.isAbsolute(destPath));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vercel/build-utils",
3
- "version": "2.15.2-canary.5",
3
+ "version": "2.16.1-canary.0",
4
4
  "license": "MIT",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.js",
@@ -29,8 +29,8 @@
29
29
  "@types/multistream": "2.1.1",
30
30
  "@types/node-fetch": "^2.1.6",
31
31
  "@types/semver": "6.0.0",
32
- "@types/yazl": "^2.4.1",
33
- "@vercel/frameworks": "0.7.2-canary.1",
32
+ "@types/yazl": "2.4.2",
33
+ "@vercel/frameworks": "0.8.0",
34
34
  "@vercel/ncc": "0.24.0",
35
35
  "aggregate-error": "3.0.1",
36
36
  "async-retry": "1.2.3",
@@ -47,7 +47,7 @@
47
47
  "node-fetch": "2.6.1",
48
48
  "semver": "6.1.1",
49
49
  "typescript": "4.3.4",
50
- "yazl": "2.4.3"
50
+ "yazl": "2.5.1"
51
51
  },
52
- "gitHead": "438576fc7c392e754d1fc85fc1d9f3122e80d015"
52
+ "gitHead": "8eabbfc6667399fce2a9060fd48a0d7c635a2a62"
53
53
  }