@vercel/build-utils 6.6.0 → 6.7.1

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/dist/index.js CHANGED
@@ -16994,16 +16994,16 @@ module.exports = { stringify, stripBom }
16994
16994
 
16995
16995
  /***/ }),
16996
16996
 
16997
- /***/ 7767:
16997
+ /***/ 7345:
16998
16998
  /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
16999
16999
 
17000
17000
  module.exports = minimatch
17001
17001
  minimatch.Minimatch = Minimatch
17002
17002
 
17003
- var path = { sep: '/' }
17004
- try {
17005
- path = __webpack_require__(5622)
17006
- } catch (er) {}
17003
+ var path = (function () { try { return __webpack_require__(5622) } catch (e) {}}()) || {
17004
+ sep: '/'
17005
+ }
17006
+ minimatch.sep = path.sep
17007
17007
 
17008
17008
  var GLOBSTAR = minimatch.GLOBSTAR = Minimatch.GLOBSTAR = {}
17009
17009
  var expand = __webpack_require__(490)
@@ -17055,43 +17055,64 @@ function filter (pattern, options) {
17055
17055
  }
17056
17056
 
17057
17057
  function ext (a, b) {
17058
- a = a || {}
17059
17058
  b = b || {}
17060
17059
  var t = {}
17061
- Object.keys(b).forEach(function (k) {
17062
- t[k] = b[k]
17063
- })
17064
17060
  Object.keys(a).forEach(function (k) {
17065
17061
  t[k] = a[k]
17066
17062
  })
17063
+ Object.keys(b).forEach(function (k) {
17064
+ t[k] = b[k]
17065
+ })
17067
17066
  return t
17068
17067
  }
17069
17068
 
17070
17069
  minimatch.defaults = function (def) {
17071
- if (!def || !Object.keys(def).length) return minimatch
17070
+ if (!def || typeof def !== 'object' || !Object.keys(def).length) {
17071
+ return minimatch
17072
+ }
17072
17073
 
17073
17074
  var orig = minimatch
17074
17075
 
17075
17076
  var m = function minimatch (p, pattern, options) {
17076
- return orig.minimatch(p, pattern, ext(def, options))
17077
+ return orig(p, pattern, ext(def, options))
17077
17078
  }
17078
17079
 
17079
17080
  m.Minimatch = function Minimatch (pattern, options) {
17080
17081
  return new orig.Minimatch(pattern, ext(def, options))
17081
17082
  }
17083
+ m.Minimatch.defaults = function defaults (options) {
17084
+ return orig.defaults(ext(def, options)).Minimatch
17085
+ }
17086
+
17087
+ m.filter = function filter (pattern, options) {
17088
+ return orig.filter(pattern, ext(def, options))
17089
+ }
17090
+
17091
+ m.defaults = function defaults (options) {
17092
+ return orig.defaults(ext(def, options))
17093
+ }
17094
+
17095
+ m.makeRe = function makeRe (pattern, options) {
17096
+ return orig.makeRe(pattern, ext(def, options))
17097
+ }
17098
+
17099
+ m.braceExpand = function braceExpand (pattern, options) {
17100
+ return orig.braceExpand(pattern, ext(def, options))
17101
+ }
17102
+
17103
+ m.match = function (list, pattern, options) {
17104
+ return orig.match(list, pattern, ext(def, options))
17105
+ }
17082
17106
 
17083
17107
  return m
17084
17108
  }
17085
17109
 
17086
17110
  Minimatch.defaults = function (def) {
17087
- if (!def || !Object.keys(def).length) return Minimatch
17088
17111
  return minimatch.defaults(def).Minimatch
17089
17112
  }
17090
17113
 
17091
17114
  function minimatch (p, pattern, options) {
17092
- if (typeof pattern !== 'string') {
17093
- throw new TypeError('glob pattern string required')
17094
- }
17115
+ assertValidPattern(pattern)
17095
17116
 
17096
17117
  if (!options) options = {}
17097
17118
 
@@ -17100,9 +17121,6 @@ function minimatch (p, pattern, options) {
17100
17121
  return false
17101
17122
  }
17102
17123
 
17103
- // "" only matches ""
17104
- if (pattern.trim() === '') return p === ''
17105
-
17106
17124
  return new Minimatch(pattern, options).match(p)
17107
17125
  }
17108
17126
 
@@ -17111,15 +17129,14 @@ function Minimatch (pattern, options) {
17111
17129
  return new Minimatch(pattern, options)
17112
17130
  }
17113
17131
 
17114
- if (typeof pattern !== 'string') {
17115
- throw new TypeError('glob pattern string required')
17116
- }
17132
+ assertValidPattern(pattern)
17117
17133
 
17118
17134
  if (!options) options = {}
17135
+
17119
17136
  pattern = pattern.trim()
17120
17137
 
17121
17138
  // windows support: need to use /, not \
17122
- if (path.sep !== '/') {
17139
+ if (!options.allowWindowsEscape && path.sep !== '/') {
17123
17140
  pattern = pattern.split(path.sep).join('/')
17124
17141
  }
17125
17142
 
@@ -17130,6 +17147,7 @@ function Minimatch (pattern, options) {
17130
17147
  this.negate = false
17131
17148
  this.comment = false
17132
17149
  this.empty = false
17150
+ this.partial = !!options.partial
17133
17151
 
17134
17152
  // make the set of regexps etc.
17135
17153
  this.make()
@@ -17139,9 +17157,6 @@ Minimatch.prototype.debug = function () {}
17139
17157
 
17140
17158
  Minimatch.prototype.make = make
17141
17159
  function make () {
17142
- // don't do it more than once.
17143
- if (this._made) return
17144
-
17145
17160
  var pattern = this.pattern
17146
17161
  var options = this.options
17147
17162
 
@@ -17161,7 +17176,7 @@ function make () {
17161
17176
  // step 2: expand braces
17162
17177
  var set = this.globSet = this.braceExpand()
17163
17178
 
17164
- if (options.debug) this.debug = console.error
17179
+ if (options.debug) this.debug = function debug() { console.error.apply(console, arguments) }
17165
17180
 
17166
17181
  this.debug(this.pattern, set)
17167
17182
 
@@ -17241,12 +17256,11 @@ function braceExpand (pattern, options) {
17241
17256
  pattern = typeof pattern === 'undefined'
17242
17257
  ? this.pattern : pattern
17243
17258
 
17244
- if (typeof pattern === 'undefined') {
17245
- throw new TypeError('undefined pattern')
17246
- }
17259
+ assertValidPattern(pattern)
17247
17260
 
17248
- if (options.nobrace ||
17249
- !pattern.match(/\{.*\}/)) {
17261
+ // Thanks to Yeting Li <https://github.com/yetingli> for
17262
+ // improving this regexp to avoid a ReDOS vulnerability.
17263
+ if (options.nobrace || !/\{(?:(?!\{).)*\}/.test(pattern)) {
17250
17264
  // shortcut. no need to expand.
17251
17265
  return [pattern]
17252
17266
  }
@@ -17254,6 +17268,17 @@ function braceExpand (pattern, options) {
17254
17268
  return expand(pattern)
17255
17269
  }
17256
17270
 
17271
+ var MAX_PATTERN_LENGTH = 1024 * 64
17272
+ var assertValidPattern = function (pattern) {
17273
+ if (typeof pattern !== 'string') {
17274
+ throw new TypeError('invalid pattern')
17275
+ }
17276
+
17277
+ if (pattern.length > MAX_PATTERN_LENGTH) {
17278
+ throw new TypeError('pattern is too long')
17279
+ }
17280
+ }
17281
+
17257
17282
  // parse a component of the expanded set.
17258
17283
  // At this point, no pattern may contain "/" in it
17259
17284
  // so we're going to return a 2d array, where each entry is the full
@@ -17268,14 +17293,17 @@ function braceExpand (pattern, options) {
17268
17293
  Minimatch.prototype.parse = parse
17269
17294
  var SUBPARSE = {}
17270
17295
  function parse (pattern, isSub) {
17271
- if (pattern.length > 1024 * 64) {
17272
- throw new TypeError('pattern is too long')
17273
- }
17296
+ assertValidPattern(pattern)
17274
17297
 
17275
17298
  var options = this.options
17276
17299
 
17277
17300
  // shortcuts
17278
- if (!options.noglobstar && pattern === '**') return GLOBSTAR
17301
+ if (pattern === '**') {
17302
+ if (!options.noglobstar)
17303
+ return GLOBSTAR
17304
+ else
17305
+ pattern = '*'
17306
+ }
17279
17307
  if (pattern === '') return ''
17280
17308
 
17281
17309
  var re = ''
@@ -17331,10 +17359,12 @@ function parse (pattern, isSub) {
17331
17359
  }
17332
17360
 
17333
17361
  switch (c) {
17334
- case '/':
17362
+ /* istanbul ignore next */
17363
+ case '/': {
17335
17364
  // completely not allowed, even escaped.
17336
17365
  // Should already be path-split by now.
17337
17366
  return false
17367
+ }
17338
17368
 
17339
17369
  case '\\':
17340
17370
  clearStateChar()
@@ -17453,25 +17483,23 @@ function parse (pattern, isSub) {
17453
17483
 
17454
17484
  // handle the case where we left a class open.
17455
17485
  // "[z-a]" is valid, equivalent to "\[z-a\]"
17456
- if (inClass) {
17457
- // split where the last [ was, make sure we don't have
17458
- // an invalid re. if so, re-walk the contents of the
17459
- // would-be class to re-translate any characters that
17460
- // were passed through as-is
17461
- // TODO: It would probably be faster to determine this
17462
- // without a try/catch and a new RegExp, but it's tricky
17463
- // to do safely. For now, this is safe and works.
17464
- var cs = pattern.substring(classStart + 1, i)
17465
- try {
17466
- RegExp('[' + cs + ']')
17467
- } catch (er) {
17468
- // not a valid class!
17469
- var sp = this.parse(cs, SUBPARSE)
17470
- re = re.substr(0, reClassStart) + '\\[' + sp[0] + '\\]'
17471
- hasMagic = hasMagic || sp[1]
17472
- inClass = false
17473
- continue
17474
- }
17486
+ // split where the last [ was, make sure we don't have
17487
+ // an invalid re. if so, re-walk the contents of the
17488
+ // would-be class to re-translate any characters that
17489
+ // were passed through as-is
17490
+ // TODO: It would probably be faster to determine this
17491
+ // without a try/catch and a new RegExp, but it's tricky
17492
+ // to do safely. For now, this is safe and works.
17493
+ var cs = pattern.substring(classStart + 1, i)
17494
+ try {
17495
+ RegExp('[' + cs + ']')
17496
+ } catch (er) {
17497
+ // not a valid class!
17498
+ var sp = this.parse(cs, SUBPARSE)
17499
+ re = re.substr(0, reClassStart) + '\\[' + sp[0] + '\\]'
17500
+ hasMagic = hasMagic || sp[1]
17501
+ inClass = false
17502
+ continue
17475
17503
  }
17476
17504
 
17477
17505
  // finish up the class.
@@ -17555,9 +17583,7 @@ function parse (pattern, isSub) {
17555
17583
  // something that could conceivably capture a dot
17556
17584
  var addPatternStart = false
17557
17585
  switch (re.charAt(0)) {
17558
- case '.':
17559
- case '[':
17560
- case '(': addPatternStart = true
17586
+ case '[': case '.': case '(': addPatternStart = true
17561
17587
  }
17562
17588
 
17563
17589
  // Hack to work around lack of negative lookbehind in JS
@@ -17619,7 +17645,7 @@ function parse (pattern, isSub) {
17619
17645
  var flags = options.nocase ? 'i' : ''
17620
17646
  try {
17621
17647
  var regExp = new RegExp('^' + re + '$', flags)
17622
- } catch (er) {
17648
+ } catch (er) /* istanbul ignore next - should be impossible */ {
17623
17649
  // If it was an invalid regular expression, then it can't match
17624
17650
  // anything. This trick looks for a character after the end of
17625
17651
  // the string, which is of course impossible, except in multi-line
@@ -17677,7 +17703,7 @@ function makeRe () {
17677
17703
 
17678
17704
  try {
17679
17705
  this.regexp = new RegExp(re, flags)
17680
- } catch (ex) {
17706
+ } catch (ex) /* istanbul ignore next - should be impossible */ {
17681
17707
  this.regexp = false
17682
17708
  }
17683
17709
  return this.regexp
@@ -17695,8 +17721,8 @@ minimatch.match = function (list, pattern, options) {
17695
17721
  return list
17696
17722
  }
17697
17723
 
17698
- Minimatch.prototype.match = match
17699
- function match (f, partial) {
17724
+ Minimatch.prototype.match = function match (f, partial) {
17725
+ if (typeof partial === 'undefined') partial = this.partial
17700
17726
  this.debug('match', f, this.pattern)
17701
17727
  // short-circuit in the case of busted things.
17702
17728
  // comments, etc.
@@ -17778,6 +17804,7 @@ Minimatch.prototype.matchOne = function (file, pattern, partial) {
17778
17804
 
17779
17805
  // should be impossible.
17780
17806
  // some invalid regexp stuff in the set.
17807
+ /* istanbul ignore if */
17781
17808
  if (p === false) return false
17782
17809
 
17783
17810
  if (p === GLOBSTAR) {
@@ -17851,6 +17878,7 @@ Minimatch.prototype.matchOne = function (file, pattern, partial) {
17851
17878
  // no match was found.
17852
17879
  // However, in partial mode, we can't say this is necessarily over.
17853
17880
  // If there's more *pattern* left, then
17881
+ /* istanbul ignore if */
17854
17882
  if (partial) {
17855
17883
  // ran out of file
17856
17884
  this.debug('\n>>> no match, partial?', file, fr, pattern, pr)
@@ -17864,11 +17892,7 @@ Minimatch.prototype.matchOne = function (file, pattern, partial) {
17864
17892
  // patterns with magic have been turned into regexps.
17865
17893
  var hit
17866
17894
  if (typeof p === 'string') {
17867
- if (options.nocase) {
17868
- hit = f.toLowerCase() === p.toLowerCase()
17869
- } else {
17870
- hit = f === p
17871
- }
17895
+ hit = f === p
17872
17896
  this.debug('string match', p, f, hit)
17873
17897
  } else {
17874
17898
  hit = f.match(p)
@@ -17899,16 +17923,16 @@ Minimatch.prototype.matchOne = function (file, pattern, partial) {
17899
17923
  // this is ok if we're doing the match as part of
17900
17924
  // a glob fs traversal.
17901
17925
  return partial
17902
- } else if (pi === pl) {
17926
+ } else /* istanbul ignore else */ if (pi === pl) {
17903
17927
  // ran out of pattern, still have file left.
17904
17928
  // this is only acceptable if we're on the very last
17905
17929
  // empty segment of a file with a trailing slash.
17906
17930
  // a/* should match a/b/
17907
- var emptyFileEnd = (fi === fl - 1) && (file[fi] === '')
17908
- return emptyFileEnd
17931
+ return (fi === fl - 1) && (file[fi] === '')
17909
17932
  }
17910
17933
 
17911
17934
  // should be unreachable.
17935
+ /* istanbul ignore next */
17912
17936
  throw new Error('wtf?')
17913
17937
  }
17914
17938
 
@@ -31845,13 +31869,13 @@ exports.getLambdaOptionsFromFunction = exports.createZip = exports.createLambda
31845
31869
  const assert_1 = __importDefault(__webpack_require__(2357));
31846
31870
  const async_sema_1 = __importDefault(__webpack_require__(2219));
31847
31871
  const yazl_1 = __webpack_require__(3044);
31848
- const minimatch_1 = __importDefault(__webpack_require__(7767));
31872
+ const minimatch_1 = __importDefault(__webpack_require__(7345));
31849
31873
  const fs_extra_1 = __webpack_require__(6365);
31850
31874
  const download_1 = __webpack_require__(3166);
31851
31875
  const stream_to_buffer_1 = __importDefault(__webpack_require__(9688));
31852
31876
  class Lambda {
31853
31877
  constructor(opts) {
31854
- const { handler, runtime, maxDuration, memory, environment = {}, allowQuery, regions, supportsMultiPayloads, supportsWrapper, experimentalResponseStreaming, operationType, framework, } = opts;
31878
+ const { handler, runtime, maxDuration, memory, environment = {}, allowQuery, regions, supportsMultiPayloads, supportsWrapper, supportsResponseStreaming, experimentalResponseStreaming, operationType, framework, } = opts;
31855
31879
  if ('files' in opts) {
31856
31880
  assert_1.default(typeof opts.files === 'object', '"files" must be an object');
31857
31881
  }
@@ -31901,7 +31925,8 @@ class Lambda {
31901
31925
  this.zipBuffer = 'zipBuffer' in opts ? opts.zipBuffer : undefined;
31902
31926
  this.supportsMultiPayloads = supportsMultiPayloads;
31903
31927
  this.supportsWrapper = supportsWrapper;
31904
- this.experimentalResponseStreaming = experimentalResponseStreaming;
31928
+ this.supportsResponseStreaming =
31929
+ supportsResponseStreaming ?? experimentalResponseStreaming;
31905
31930
  this.framework = framework;
31906
31931
  }
31907
31932
  async createZip() {
@@ -31920,6 +31945,15 @@ class Lambda {
31920
31945
  }
31921
31946
  return zipBuffer;
31922
31947
  }
31948
+ /**
31949
+ * @deprecated Use the `supportsResponseStreaming` property instead.
31950
+ */
31951
+ get experimentalResponseStreaming() {
31952
+ return this.supportsResponseStreaming;
31953
+ }
31954
+ set experimentalResponseStreaming(v) {
31955
+ this.supportsResponseStreaming = v;
31956
+ }
31923
31957
  }
31924
31958
  exports.Lambda = Lambda;
31925
31959
  const sema = new async_sema_1.default(10);
package/dist/lambda.d.ts CHANGED
@@ -14,6 +14,10 @@ export interface LambdaOptionsBase {
14
14
  regions?: string[];
15
15
  supportsMultiPayloads?: boolean;
16
16
  supportsWrapper?: boolean;
17
+ supportsResponseStreaming?: boolean;
18
+ /**
19
+ * @deprecated Use the `supportsResponseStreaming` property instead.
20
+ */
17
21
  experimentalResponseStreaming?: boolean;
18
22
  operationType?: string;
19
23
  framework?: FunctionFramework;
@@ -56,10 +60,15 @@ export declare class Lambda {
56
60
  zipBuffer?: Buffer;
57
61
  supportsMultiPayloads?: boolean;
58
62
  supportsWrapper?: boolean;
59
- experimentalResponseStreaming?: boolean;
63
+ supportsResponseStreaming?: boolean;
60
64
  framework?: FunctionFramework;
61
65
  constructor(opts: LambdaOptions);
62
66
  createZip(): Promise<Buffer>;
67
+ /**
68
+ * @deprecated Use the `supportsResponseStreaming` property instead.
69
+ */
70
+ get experimentalResponseStreaming(): boolean | undefined;
71
+ set experimentalResponseStreaming(v: boolean | undefined);
63
72
  }
64
73
  /**
65
74
  * @deprecated Use `new Lambda()` instead.
package/dist/lambda.js CHANGED
@@ -13,7 +13,7 @@ const download_1 = require("./fs/download");
13
13
  const stream_to_buffer_1 = __importDefault(require("./fs/stream-to-buffer"));
14
14
  class Lambda {
15
15
  constructor(opts) {
16
- const { handler, runtime, maxDuration, memory, environment = {}, allowQuery, regions, supportsMultiPayloads, supportsWrapper, experimentalResponseStreaming, operationType, framework, } = opts;
16
+ const { handler, runtime, maxDuration, memory, environment = {}, allowQuery, regions, supportsMultiPayloads, supportsWrapper, supportsResponseStreaming, experimentalResponseStreaming, operationType, framework, } = opts;
17
17
  if ('files' in opts) {
18
18
  assert_1.default(typeof opts.files === 'object', '"files" must be an object');
19
19
  }
@@ -63,7 +63,8 @@ class Lambda {
63
63
  this.zipBuffer = 'zipBuffer' in opts ? opts.zipBuffer : undefined;
64
64
  this.supportsMultiPayloads = supportsMultiPayloads;
65
65
  this.supportsWrapper = supportsWrapper;
66
- this.experimentalResponseStreaming = experimentalResponseStreaming;
66
+ this.supportsResponseStreaming =
67
+ supportsResponseStreaming ?? experimentalResponseStreaming;
67
68
  this.framework = framework;
68
69
  }
69
70
  async createZip() {
@@ -82,6 +83,15 @@ class Lambda {
82
83
  }
83
84
  return zipBuffer;
84
85
  }
86
+ /**
87
+ * @deprecated Use the `supportsResponseStreaming` property instead.
88
+ */
89
+ get experimentalResponseStreaming() {
90
+ return this.supportsResponseStreaming;
91
+ }
92
+ set experimentalResponseStreaming(v) {
93
+ this.supportsResponseStreaming = v;
94
+ }
85
95
  }
86
96
  exports.Lambda = Lambda;
87
97
  const sema = new async_sema_1.default(10);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@vercel/build-utils",
3
- "version": "6.6.0",
4
- "license": "MIT",
3
+ "version": "6.7.1",
4
+ "license": "Apache-2.0",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.js",
7
7
  "homepage": "https://github.com/vercel/vercel/blob/main/DEVELOPING_A_RUNTIME.md",
@@ -44,12 +44,12 @@
44
44
  "ignore": "4.0.6",
45
45
  "into-stream": "5.0.0",
46
46
  "js-yaml": "3.13.1",
47
- "minimatch": "3.0.4",
47
+ "minimatch": "3.1.2",
48
48
  "multistream": "2.1.1",
49
49
  "node-fetch": "2.6.7",
50
50
  "semver": "6.1.1",
51
51
  "typescript": "4.3.4",
52
52
  "yazl": "2.5.1"
53
53
  },
54
- "gitHead": "54514a44afef48726220bc8be8d20f4fda8e8b4f"
54
+ "gitHead": "925c8ba18ceec80174d9440cd2cad0e725ed4f56"
55
55
  }