@vercel/go 10.0.1 → 10.1.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.
Binary file
Binary file
package/dist/index.js CHANGED
@@ -164,12 +164,12 @@ var require_isexe = __commonJS({
164
164
  if (typeof Promise !== "function") {
165
165
  throw new TypeError("callback not provided");
166
166
  }
167
- return new Promise(function(resolve, reject) {
167
+ return new Promise(function(resolve2, reject) {
168
168
  isexe(path, options || {}, function(er2, is2) {
169
169
  if (er2) {
170
170
  reject(er2);
171
171
  } else {
172
- resolve(is2);
172
+ resolve2(is2);
173
173
  }
174
174
  });
175
175
  });
@@ -2069,7 +2069,7 @@ var require_get_stream = __commonJS({
2069
2069
  options = Object.assign({ maxBuffer: Infinity }, options);
2070
2070
  const { maxBuffer } = options;
2071
2071
  let stream;
2072
- return new Promise((resolve, reject) => {
2072
+ return new Promise((resolve2, reject) => {
2073
2073
  const rejectPromise = (error) => {
2074
2074
  if (error) {
2075
2075
  error.bufferedData = stream.getBufferedValue();
@@ -2081,7 +2081,7 @@ var require_get_stream = __commonJS({
2081
2081
  rejectPromise(error);
2082
2082
  return;
2083
2083
  }
2084
- resolve();
2084
+ resolve2();
2085
2085
  });
2086
2086
  stream.on("data", () => {
2087
2087
  if (stream.getBufferedLength() > maxBuffer) {
@@ -2105,11 +2105,11 @@ var require_p_finally = __commonJS({
2105
2105
  onFinally = onFinally || (() => {
2106
2106
  });
2107
2107
  return promise.then(
2108
- (val) => new Promise((resolve) => {
2109
- resolve(onFinally());
2108
+ (val) => new Promise((resolve2) => {
2109
+ resolve2(onFinally());
2110
2110
  }).then(() => val),
2111
- (err) => new Promise((resolve) => {
2112
- resolve(onFinally());
2111
+ (err) => new Promise((resolve2) => {
2112
+ resolve2(onFinally());
2113
2113
  }).then(() => {
2114
2114
  throw err;
2115
2115
  })
@@ -2488,8 +2488,8 @@ var require_execa = __commonJS({
2488
2488
  }
2489
2489
  let ret;
2490
2490
  if (!buffer) {
2491
- ret = new Promise((resolve, reject) => {
2492
- process2[stream].once("end", resolve).once("error", reject);
2491
+ ret = new Promise((resolve2, reject) => {
2492
+ process2[stream].once("end", resolve2).once("error", reject);
2493
2493
  });
2494
2494
  } else if (encoding) {
2495
2495
  ret = _getStream(process2[stream], {
@@ -2578,19 +2578,19 @@ ${stderr}${stdout}`;
2578
2578
  spawned.kill(parsed.opts.killSignal);
2579
2579
  }, parsed.opts.timeout);
2580
2580
  }
2581
- const processDone = new Promise((resolve) => {
2581
+ const processDone = new Promise((resolve2) => {
2582
2582
  spawned.on("exit", (code, signal) => {
2583
2583
  cleanup();
2584
- resolve({ code, signal });
2584
+ resolve2({ code, signal });
2585
2585
  });
2586
2586
  spawned.on("error", (err) => {
2587
2587
  cleanup();
2588
- resolve({ error: err });
2588
+ resolve2({ error: err });
2589
2589
  });
2590
2590
  if (spawned.stdin) {
2591
2591
  spawned.stdin.on("error", (err) => {
2592
2592
  cleanup();
2593
- resolve({ error: err });
2593
+ resolve2({ error: err });
2594
2594
  });
2595
2595
  }
2596
2596
  });
@@ -2907,7 +2907,7 @@ var require_lib = __commonJS({
2907
2907
  "../../node_modules/.pnpm/async-retry@1.3.3/node_modules/async-retry/lib/index.js"(exports, module2) {
2908
2908
  var retrier = require_retry2();
2909
2909
  function retry2(fn2, opts) {
2910
- function run(resolve, reject) {
2910
+ function run(resolve2, reject) {
2911
2911
  var options = opts || {};
2912
2912
  var op;
2913
2913
  if (!("randomize" in options)) {
@@ -2936,7 +2936,7 @@ var require_lib = __commonJS({
2936
2936
  onError(err, num);
2937
2937
  return;
2938
2938
  }
2939
- Promise.resolve(val).then(resolve).catch(function catchIt(err) {
2939
+ Promise.resolve(val).then(resolve2).catch(function catchIt(err) {
2940
2940
  onError(err, num);
2941
2941
  });
2942
2942
  }
@@ -2963,7 +2963,7 @@ var require_dist = __commonJS({
2963
2963
  (function(once3) {
2964
2964
  function spread(emitter, name) {
2965
2965
  let c = null;
2966
- const p2 = new Promise((resolve, reject) => {
2966
+ const p2 = new Promise((resolve2, reject) => {
2967
2967
  function cancel() {
2968
2968
  emitter.removeListener(name, onEvent);
2969
2969
  emitter.removeListener("error", onError);
@@ -2971,7 +2971,7 @@ var require_dist = __commonJS({
2971
2971
  }
2972
2972
  function onEvent(...args) {
2973
2973
  cancel();
2974
- resolve(args);
2974
+ resolve2(args);
2975
2975
  }
2976
2976
  function onError(err) {
2977
2977
  cancel();
@@ -3002,11 +3002,11 @@ var require_universalify = __commonJS({
3002
3002
  if (typeof arguments[arguments.length - 1] === "function")
3003
3003
  fn2.apply(this, arguments);
3004
3004
  else {
3005
- return new Promise((resolve, reject) => {
3005
+ return new Promise((resolve2, reject) => {
3006
3006
  arguments[arguments.length] = (err, res) => {
3007
3007
  if (err)
3008
3008
  return reject(err);
3009
- resolve(res);
3009
+ resolve2(res);
3010
3010
  };
3011
3011
  arguments.length++;
3012
3012
  fn2.apply(this, arguments);
@@ -3096,7 +3096,7 @@ var require_polyfills = __commonJS({
3096
3096
  }
3097
3097
  if (platform === "win32") {
3098
3098
  fs3.rename = typeof fs3.rename !== "function" ? fs3.rename : function(fs$rename) {
3099
- function rename(from, to2, cb) {
3099
+ function rename2(from, to2, cb) {
3100
3100
  var start = Date.now();
3101
3101
  var backoff = 0;
3102
3102
  fs$rename(from, to2, function CB(er2) {
@@ -3118,8 +3118,8 @@ var require_polyfills = __commonJS({
3118
3118
  });
3119
3119
  }
3120
3120
  if (Object.setPrototypeOf)
3121
- Object.setPrototypeOf(rename, fs$rename);
3122
- return rename;
3121
+ Object.setPrototypeOf(rename2, fs$rename);
3122
+ return rename2;
3123
3123
  }(fs3.rename);
3124
3124
  }
3125
3125
  fs3.read = typeof fs3.read !== "function" ? fs3.read : function(fs$read) {
@@ -3889,19 +3889,19 @@ var require_fs = __commonJS({
3889
3889
  if (typeof callback === "function") {
3890
3890
  return fs3.exists(filename, callback);
3891
3891
  }
3892
- return new Promise((resolve) => {
3893
- return fs3.exists(filename, resolve);
3892
+ return new Promise((resolve2) => {
3893
+ return fs3.exists(filename, resolve2);
3894
3894
  });
3895
3895
  };
3896
3896
  exports.read = function(fd, buffer, offset, length, position, callback) {
3897
3897
  if (typeof callback === "function") {
3898
3898
  return fs3.read(fd, buffer, offset, length, position, callback);
3899
3899
  }
3900
- return new Promise((resolve, reject) => {
3900
+ return new Promise((resolve2, reject) => {
3901
3901
  fs3.read(fd, buffer, offset, length, position, (err, bytesRead, buffer2) => {
3902
3902
  if (err)
3903
3903
  return reject(err);
3904
- resolve({ bytesRead, buffer: buffer2 });
3904
+ resolve2({ bytesRead, buffer: buffer2 });
3905
3905
  });
3906
3906
  });
3907
3907
  };
@@ -3909,11 +3909,11 @@ var require_fs = __commonJS({
3909
3909
  if (typeof args[args.length - 1] === "function") {
3910
3910
  return fs3.write(fd, buffer, ...args);
3911
3911
  }
3912
- return new Promise((resolve, reject) => {
3912
+ return new Promise((resolve2, reject) => {
3913
3913
  fs3.write(fd, buffer, ...args, (err, bytesWritten, buffer2) => {
3914
3914
  if (err)
3915
3915
  return reject(err);
3916
- resolve({ bytesWritten, buffer: buffer2 });
3916
+ resolve2({ bytesWritten, buffer: buffer2 });
3917
3917
  });
3918
3918
  });
3919
3919
  };
@@ -5194,11 +5194,11 @@ var require_symlink = __commonJS({
5194
5194
  return callback(err);
5195
5195
  if (destinationExists)
5196
5196
  return callback(null);
5197
- symlinkPaths(srcpath, dstpath, (err2, relative2) => {
5197
+ symlinkPaths(srcpath, dstpath, (err2, relative4) => {
5198
5198
  if (err2)
5199
5199
  return callback(err2);
5200
- srcpath = relative2.toDst;
5201
- symlinkType(relative2.toCwd, type, (err3, type2) => {
5200
+ srcpath = relative4.toDst;
5201
+ symlinkType(relative4.toCwd, type, (err3, type2) => {
5202
5202
  if (err3)
5203
5203
  return callback(err3);
5204
5204
  const dir = path.dirname(dstpath);
@@ -5221,9 +5221,9 @@ var require_symlink = __commonJS({
5221
5221
  const destinationExists = fs3.existsSync(dstpath);
5222
5222
  if (destinationExists)
5223
5223
  return void 0;
5224
- const relative2 = symlinkPathsSync(srcpath, dstpath);
5225
- srcpath = relative2.toDst;
5226
- type = symlinkTypeSync(relative2.toCwd, type);
5224
+ const relative4 = symlinkPathsSync(srcpath, dstpath);
5225
+ srcpath = relative4.toDst;
5226
+ type = symlinkTypeSync(relative4.toCwd, type);
5227
5227
  const dir = path.dirname(dstpath);
5228
5228
  const exists = fs3.existsSync(dir);
5229
5229
  if (exists)
@@ -5244,7 +5244,7 @@ var require_ensure = __commonJS({
5244
5244
  "use strict";
5245
5245
  var file = require_file();
5246
5246
  var link = require_link();
5247
- var symlink2 = require_symlink();
5247
+ var symlink3 = require_symlink();
5248
5248
  module2.exports = {
5249
5249
  // file
5250
5250
  createFile: file.createFile,
@@ -5257,10 +5257,10 @@ var require_ensure = __commonJS({
5257
5257
  ensureLink: link.createLink,
5258
5258
  ensureLinkSync: link.createLinkSync,
5259
5259
  // symlink
5260
- createSymlink: symlink2.createSymlink,
5261
- createSymlinkSync: symlink2.createSymlinkSync,
5262
- ensureSymlink: symlink2.createSymlink,
5263
- ensureSymlinkSync: symlink2.createSymlinkSync
5260
+ createSymlink: symlink3.createSymlink,
5261
+ createSymlinkSync: symlink3.createSymlinkSync,
5262
+ ensureSymlink: symlink3.createSymlink,
5263
+ ensureSymlinkSync: symlink3.createSymlinkSync
5264
5264
  };
5265
5265
  }
5266
5266
  });
@@ -5605,7 +5605,7 @@ var require_move = __commonJS({
5605
5605
  return remove4(dest, (err) => {
5606
5606
  if (err)
5607
5607
  return cb(err);
5608
- return rename(src, dest, overwrite, cb);
5608
+ return rename2(src, dest, overwrite, cb);
5609
5609
  });
5610
5610
  }
5611
5611
  pathExists5(dest, (err, destExists) => {
@@ -5613,10 +5613,10 @@ var require_move = __commonJS({
5613
5613
  return cb(err);
5614
5614
  if (destExists)
5615
5615
  return cb(new Error("dest already exists."));
5616
- return rename(src, dest, overwrite, cb);
5616
+ return rename2(src, dest, overwrite, cb);
5617
5617
  });
5618
5618
  }
5619
- function rename(src, dest, overwrite, cb) {
5619
+ function rename2(src, dest, overwrite, cb) {
5620
5620
  fs3.rename(src, dest, (err) => {
5621
5621
  if (!err)
5622
5622
  return cb();
@@ -7791,7 +7791,7 @@ var require_lib4 = __commonJS({
7791
7791
  let accum = [];
7792
7792
  let accumBytes = 0;
7793
7793
  let abort = false;
7794
- return new Body.Promise(function(resolve, reject) {
7794
+ return new Body.Promise(function(resolve2, reject) {
7795
7795
  let resTimeout;
7796
7796
  if (_this4.timeout) {
7797
7797
  resTimeout = setTimeout(function() {
@@ -7825,7 +7825,7 @@ var require_lib4 = __commonJS({
7825
7825
  }
7826
7826
  clearTimeout(resTimeout);
7827
7827
  try {
7828
- resolve(Buffer.concat(accum, accumBytes));
7828
+ resolve2(Buffer.concat(accum, accumBytes));
7829
7829
  } catch (err) {
7830
7830
  reject(new FetchError(`Could not create Buffer from response body for ${_this4.url}: ${err.message}`, "system", err));
7831
7831
  }
@@ -8505,7 +8505,7 @@ var require_lib4 = __commonJS({
8505
8505
  throw new Error("native promise missing, set fetch.Promise to your favorite alternative");
8506
8506
  }
8507
8507
  Body.Promise = fetch.Promise;
8508
- return new fetch.Promise(function(resolve, reject) {
8508
+ return new fetch.Promise(function(resolve2, reject) {
8509
8509
  const request = new Request(url, opts);
8510
8510
  const options = getNodeRequestOptions(request);
8511
8511
  const send = (options.protocol === "https:" ? https : http).request;
@@ -8640,7 +8640,7 @@ var require_lib4 = __commonJS({
8640
8640
  requestOpts.body = void 0;
8641
8641
  requestOpts.headers.delete("content-length");
8642
8642
  }
8643
- resolve(fetch(new Request(locationURL, requestOpts)));
8643
+ resolve2(fetch(new Request(locationURL, requestOpts)));
8644
8644
  finalize();
8645
8645
  return;
8646
8646
  }
@@ -8662,7 +8662,7 @@ var require_lib4 = __commonJS({
8662
8662
  const codings = headers.get("Content-Encoding");
8663
8663
  if (!request.compress || request.method === "HEAD" || codings === null || res.statusCode === 204 || res.statusCode === 304) {
8664
8664
  response = new Response(body, response_options);
8665
- resolve(response);
8665
+ resolve2(response);
8666
8666
  return;
8667
8667
  }
8668
8668
  const zlibOptions = {
@@ -8672,7 +8672,7 @@ var require_lib4 = __commonJS({
8672
8672
  if (codings == "gzip" || codings == "x-gzip") {
8673
8673
  body = body.pipe(zlib.createGunzip(zlibOptions));
8674
8674
  response = new Response(body, response_options);
8675
- resolve(response);
8675
+ resolve2(response);
8676
8676
  return;
8677
8677
  }
8678
8678
  if (codings == "deflate" || codings == "x-deflate") {
@@ -8684,12 +8684,12 @@ var require_lib4 = __commonJS({
8684
8684
  body = body.pipe(zlib.createInflateRaw());
8685
8685
  }
8686
8686
  response = new Response(body, response_options);
8687
- resolve(response);
8687
+ resolve2(response);
8688
8688
  });
8689
8689
  raw.on("end", function() {
8690
8690
  if (!response) {
8691
8691
  response = new Response(body, response_options);
8692
- resolve(response);
8692
+ resolve2(response);
8693
8693
  }
8694
8694
  });
8695
8695
  return;
@@ -8697,11 +8697,11 @@ var require_lib4 = __commonJS({
8697
8697
  if (codings == "br" && typeof zlib.createBrotliDecompress === "function") {
8698
8698
  body = body.pipe(zlib.createBrotliDecompress());
8699
8699
  response = new Response(body, response_options);
8700
- resolve(response);
8700
+ resolve2(response);
8701
8701
  return;
8702
8702
  }
8703
8703
  response = new Response(body, response_options);
8704
- resolve(response);
8704
+ resolve2(response);
8705
8705
  });
8706
8706
  writeToStream(req, request);
8707
8707
  });
@@ -10463,18 +10463,18 @@ var require_promisify = __commonJS({
10463
10463
  const fromBuffer = fnName == "fromBuffer";
10464
10464
  cloner.patch(yauzl2, fnName, (original) => {
10465
10465
  return function(path, totalSize, options) {
10466
- return new Promise2((resolve, reject) => {
10466
+ return new Promise2((resolve2, reject) => {
10467
10467
  options = Object.assign({}, options, { lazyEntries: true, autoClose: false });
10468
10468
  original(path, totalSize, options, (err, zipFile) => {
10469
10469
  if (err)
10470
10470
  return reject(err);
10471
- opened(zipFile, resolve, fromBuffer, yauzl2);
10471
+ opened(zipFile, resolve2, fromBuffer, yauzl2);
10472
10472
  });
10473
10473
  });
10474
10474
  };
10475
10475
  });
10476
10476
  }
10477
- function opened(zipFile, resolve, fromBuffer, yauzl2) {
10477
+ function opened(zipFile, resolve2, fromBuffer, yauzl2) {
10478
10478
  if (fromBuffer) {
10479
10479
  zipFile.reader.unref = yauzl2.RandomAccessReader.prototype.unref;
10480
10480
  zipFile.reader.close = (cb) => cb();
@@ -10485,7 +10485,7 @@ var require_promisify = __commonJS({
10485
10485
  zipFile.intercept("end", emittedEnd);
10486
10486
  zipFile.intercept("close", emittedClose);
10487
10487
  zipFile.intercept("error", emittedError);
10488
- resolve(zipFile);
10488
+ resolve2(zipFile);
10489
10489
  }
10490
10490
  function emittedError(err) {
10491
10491
  const state = getState(this);
@@ -10504,14 +10504,14 @@ var require_promisify = __commonJS({
10504
10504
  function promisifyClose(ZipFile, Promise2) {
10505
10505
  const close = ZipFile.prototype.close;
10506
10506
  ZipFile.prototype.close = function() {
10507
- return new Promise2((resolve, reject) => {
10507
+ return new Promise2((resolve2, reject) => {
10508
10508
  if (getError(this))
10509
10509
  return rejectWithStoredError(this, reject);
10510
10510
  if (!this.isOpen)
10511
- return resolve();
10511
+ return resolve2();
10512
10512
  if (getState(this))
10513
10513
  return reject(new Error("Previous operation has not completed yet"));
10514
- setState(this, { action: "close", resolve, reject });
10514
+ setState(this, { action: "close", resolve: resolve2, reject });
10515
10515
  close.call(this);
10516
10516
  });
10517
10517
  };
@@ -10526,14 +10526,14 @@ var require_promisify = __commonJS({
10526
10526
  function promisifyReadEntry(ZipFile, Promise2) {
10527
10527
  const readEntry = ZipFile.prototype.readEntry;
10528
10528
  ZipFile.prototype.readEntry = function() {
10529
- return new Promise2((resolve, reject) => {
10529
+ return new Promise2((resolve2, reject) => {
10530
10530
  if (getError(this))
10531
10531
  return rejectWithStoredError(this, reject);
10532
10532
  if (!this.isOpen)
10533
10533
  return reject(new Error("ZipFile is not open"));
10534
10534
  if (getState(this))
10535
10535
  return reject(new Error("Previous operation has not completed yet"));
10536
- setState(this, { action: "read", resolve, reject });
10536
+ setState(this, { action: "read", resolve: resolve2, reject });
10537
10537
  readEntry.call(this);
10538
10538
  });
10539
10539
  };
@@ -10579,11 +10579,11 @@ var require_promisify = __commonJS({
10579
10579
  function addWalkEntriesMethod(ZipFile, Promise2) {
10580
10580
  ZipFile.prototype.walkEntries = function(callback, numEntries) {
10581
10581
  callback = wrapFunctionToReturnPromise(callback, Promise2);
10582
- return new Promise2((resolve, reject) => {
10582
+ return new Promise2((resolve2, reject) => {
10583
10583
  walkNextEntry(this, callback, numEntries, 0, (err) => {
10584
10584
  if (err)
10585
10585
  return reject(err);
10586
- resolve();
10586
+ resolve2();
10587
10587
  });
10588
10588
  });
10589
10589
  };
@@ -10604,13 +10604,13 @@ var require_promisify = __commonJS({
10604
10604
  function promisifyOpenReadStream(ZipFile, Promise2) {
10605
10605
  const openReadStream = ZipFile.prototype.openReadStream;
10606
10606
  ZipFile.prototype.openReadStream = function(entry, options) {
10607
- return new Promise2((resolve, reject) => {
10607
+ return new Promise2((resolve2, reject) => {
10608
10608
  if (getError(this))
10609
10609
  return rejectWithStoredError(this, reject);
10610
10610
  openReadStream.call(this, entry, options || {}, (err, stream) => {
10611
10611
  if (err)
10612
10612
  return reject(err);
10613
- resolve(stream);
10613
+ resolve2(stream);
10614
10614
  });
10615
10615
  });
10616
10616
  };
@@ -10626,7 +10626,7 @@ var require_promisify = __commonJS({
10626
10626
  return result;
10627
10627
  return Promise2.resolve(result);
10628
10628
  } catch (err) {
10629
- return new Promise2((resolve, reject) => {
10629
+ return new Promise2((resolve2, reject) => {
10630
10630
  reject(err);
10631
10631
  });
10632
10632
  }
@@ -11045,7 +11045,7 @@ var require_dev_proxy = __commonJS({
11045
11045
  return sanitized;
11046
11046
  }
11047
11047
  function findFreePort() {
11048
- return new Promise((resolve, reject) => {
11048
+ return new Promise((resolve2, reject) => {
11049
11049
  const server = (0, import_node_net.createServer)();
11050
11050
  server.unref();
11051
11051
  server.once("error", reject);
@@ -11056,17 +11056,17 @@ var require_dev_proxy = __commonJS({
11056
11056
  return;
11057
11057
  }
11058
11058
  const { port } = address;
11059
- server.close(() => resolve(port));
11059
+ server.close(() => resolve2(port));
11060
11060
  });
11061
11061
  });
11062
11062
  }
11063
11063
  function isPortReachable(port) {
11064
- return new Promise((resolve) => {
11064
+ return new Promise((resolve2) => {
11065
11065
  const socket = (0, import_node_net.createConnection)({ port, host: LOCALHOST });
11066
11066
  const done = (reachable) => {
11067
11067
  socket.removeAllListeners();
11068
11068
  socket.destroy();
11069
- resolve(reachable);
11069
+ resolve2(reachable);
11070
11070
  };
11071
11071
  socket.setTimeout(READINESS_DIAL_TIMEOUT);
11072
11072
  socket.once("connect", () => done(true));
@@ -11075,7 +11075,7 @@ var require_dev_proxy = __commonJS({
11075
11075
  });
11076
11076
  }
11077
11077
  function sleep(ms2) {
11078
- return new Promise((resolve) => setTimeout(resolve, ms2));
11078
+ return new Promise((resolve2) => setTimeout(resolve2, ms2));
11079
11079
  }
11080
11080
  async function waitForPort(port, child, timeout, label = "Dev server") {
11081
11081
  let exited;
@@ -11188,8 +11188,8 @@ var require_dev_proxy = __commonJS({
11188
11188
  let server;
11189
11189
  const close = async () => {
11190
11190
  if (server) {
11191
- await new Promise((resolve) => {
11192
- server?.close(() => resolve());
11191
+ await new Promise((resolve2) => {
11192
+ server?.close(() => resolve2());
11193
11193
  server?.closeAllConnections?.();
11194
11194
  });
11195
11195
  }
@@ -11204,9 +11204,9 @@ var require_dev_proxy = __commonJS({
11204
11204
  routePrefix: resolveServiceRoutePrefix(env)
11205
11205
  });
11206
11206
  const listenPort = options.port ?? await findFreePort();
11207
- await new Promise((resolve, reject) => {
11207
+ await new Promise((resolve2, reject) => {
11208
11208
  server?.once("error", reject);
11209
- server?.listen(listenPort, () => resolve());
11209
+ server?.listen(listenPort, () => resolve2());
11210
11210
  });
11211
11211
  if (!child.pid) {
11212
11212
  throw new Error(`${label} started without a PID`);
@@ -14555,7 +14555,8 @@ var import_yauzl_promise = __toESM(require_lib6());
14555
14555
  var import_xdg_app_paths = __toESM(require_xdg_app_paths());
14556
14556
  var streamPipeline = (0, import_util.promisify)(import_stream.pipeline);
14557
14557
  var versionMap = /* @__PURE__ */ new Map([
14558
- ["1.26", "1.26.1"],
14558
+ ["1.27", "1.27.1"],
14559
+ ["1.26", "1.26.8"],
14559
14560
  ["1.25", "1.25.8"],
14560
14561
  ["1.24", "1.24.13"],
14561
14562
  ["1.23", "1.23.12"],
@@ -14680,13 +14681,14 @@ Learn more: https://vercel.com/docs/functions/serverless-functions/runtimes/go
14680
14681
  return JSON.parse(analyzed);
14681
14682
  }
14682
14683
  var GoWrapper = class {
14683
- constructor(env, opts = {}, resolvedVersion) {
14684
+ constructor(env, opts = {}, resolvedVersion, versionSource = { kind: "default" }) {
14684
14685
  if (!opts.cwd) {
14685
14686
  opts.cwd = process.cwd();
14686
14687
  }
14687
14688
  this.env = env;
14688
14689
  this.opts = opts;
14689
14690
  this.resolvedVersion = resolvedVersion;
14691
+ this.versionSource = versionSource;
14690
14692
  }
14691
14693
  async execute(...args) {
14692
14694
  const { opts, env } = this;
@@ -14771,6 +14773,40 @@ var GoWrapper = class {
14771
14773
  function newestSupportedGoVersion() {
14772
14774
  return Array.from(versionMap.values())[0];
14773
14775
  }
14776
+ async function findFileInAncestors(startDir, stopDir, filename) {
14777
+ let dir = (0, import_path4.resolve)(startDir);
14778
+ const boundary = (0, import_path4.resolve)(stopDir);
14779
+ const fromBoundary = (0, import_path4.relative)(boundary, dir);
14780
+ if (fromBoundary === ".." || fromBoundary.startsWith(`..${import_path4.sep}`) || (0, import_path4.isAbsolute)(fromBoundary)) {
14781
+ return void 0;
14782
+ }
14783
+ let reachedTop = false;
14784
+ while (!reachedTop) {
14785
+ const candidate = (0, import_path4.join)(dir, filename);
14786
+ if (await (0, import_fs_extra.pathExists)(candidate)) {
14787
+ (0, import_build_utils.debug)(`Found ${candidate}`);
14788
+ return candidate;
14789
+ }
14790
+ const parent = (0, import_path4.dirname)(dir);
14791
+ reachedTop = (0, import_path4.relative)(boundary, dir) === "" || parent === dir;
14792
+ dir = parent;
14793
+ }
14794
+ return void 0;
14795
+ }
14796
+ function findGoModPath(startDir, stopDir) {
14797
+ return findFileInAncestors(startDir, stopDir, "go.mod");
14798
+ }
14799
+ async function findGoWorkPath(startDir, stopDir, goWork) {
14800
+ if (goWork === "off")
14801
+ return void 0;
14802
+ if (goWork && goWork !== "auto") {
14803
+ if (!(0, import_path4.isAbsolute)(goWork)) {
14804
+ throw new Error("GOWORK must be an absolute path");
14805
+ }
14806
+ return goWork;
14807
+ }
14808
+ return findFileInAncestors(startDir, stopDir, "go.work");
14809
+ }
14774
14810
  function compareGoVersions(left, right) {
14775
14811
  const leftParts = left.split(".").map((part) => parseInt(part, 10));
14776
14812
  const rightParts = right.split(".").map((part) => parseInt(part, 10));
@@ -14805,22 +14841,58 @@ function isBelowMinDarwinRunnable(version2) {
14805
14841
  }
14806
14842
  return minor < MIN_DARWIN_RUNNABLE_GO.minor;
14807
14843
  }
14844
+ async function getInstalledGoVersion(env) {
14845
+ const { stdout } = await (0, import_execa.default)("go", ["version"], {
14846
+ env: { ...env, GOTOOLCHAIN: "local" },
14847
+ extendEnv: false
14848
+ });
14849
+ return parseGoVersionString(stdout);
14850
+ }
14851
+ async function resolvePreferredGoVersion({
14852
+ modulePath,
14853
+ workspaceFile
14854
+ }) {
14855
+ if (workspaceFile) {
14856
+ const versions = await parseGoVersionFile(workspaceFile);
14857
+ if (versions) {
14858
+ return { versions, file: workspaceFile, kind: "go.work" };
14859
+ }
14860
+ }
14861
+ if (modulePath) {
14862
+ const file = (0, import_path4.join)(modulePath, "go.mod");
14863
+ const versions = await parseGoVersionFile(file);
14864
+ if (versions) {
14865
+ return { versions, file, kind: "go.mod" };
14866
+ }
14867
+ }
14868
+ return void 0;
14869
+ }
14808
14870
  async function createGo({
14809
14871
  modulePath,
14872
+ workspaceFile,
14810
14873
  opts = {},
14811
14874
  workPath,
14812
14875
  preferNewestToolchain = false
14813
14876
  }) {
14814
- let goPreferredVersion;
14815
- if (modulePath) {
14816
- goPreferredVersion = await parseGoModVersionFromModule(modulePath);
14817
- }
14877
+ const preferred = await resolvePreferredGoVersion({
14878
+ modulePath,
14879
+ workspaceFile
14880
+ });
14881
+ const goPreferredVersion = preferred?.versions;
14818
14882
  const goSelectedVersion = selectGoVersion(goPreferredVersion, {
14819
14883
  preferNewestToolchain
14820
14884
  });
14885
+ let versionSource = { kind: "default" };
14886
+ if (preferred && preferred.versions.toolchain === goSelectedVersion) {
14887
+ const { kind, file } = preferred;
14888
+ versionSource = { kind, file, directive: "toolchain" };
14889
+ } else if (preferred && preferred.versions.go === goSelectedVersion) {
14890
+ const { kind, file } = preferred;
14891
+ versionSource = { kind, file, directive: "go" };
14892
+ }
14821
14893
  if (preferNewestToolchain && process.platform === "darwin" && isBelowMinDarwinRunnable(goSelectedVersion)) {
14822
14894
  console.warn(
14823
- `Warning: your \`go.mod\` pins Go ${goSelectedVersion} via \`toolchain\`. Binaries built with Go older than ${MIN_DARWIN_RUNNABLE_GO.major}.${MIN_DARWIN_RUNNABLE_GO.minor} do not start on recent macOS. Remove the directive to use Go ${newestSupportedGoVersion()} locally.`
14895
+ `Warning: your \`${preferred?.kind ?? "go.mod"}\` pins Go ${goSelectedVersion} via \`toolchain\`. Binaries built with Go older than ${MIN_DARWIN_RUNNABLE_GO.major}.${MIN_DARWIN_RUNNABLE_GO.minor} do not start on recent macOS. Remove the directive to use Go ${newestSupportedGoVersion()} locally.`
14824
14896
  );
14825
14897
  }
14826
14898
  const env = opts.env ? (0, import_build_utils.cloneEnv)(opts.env) : (0, import_build_utils.cloneEnv)(process.env);
@@ -14831,8 +14903,8 @@ async function createGo({
14831
14903
  `${goSelectedVersion}_${platform}_${process.arch}`
14832
14904
  );
14833
14905
  const goCacheDir = (0, import_path4.join)(workPath, localCacheDir);
14834
- if (goPreferredVersion) {
14835
- (0, import_build_utils.debug)(`Preferred go version ${goSelectedVersion} (from go.mod)`);
14906
+ if (preferred) {
14907
+ (0, import_build_utils.debug)(`Preferred go version ${goSelectedVersion} (from ${preferred.file})`);
14836
14908
  env.GO111MODULE = "on";
14837
14909
  } else {
14838
14910
  (0, import_build_utils.debug)(
@@ -14900,18 +14972,14 @@ async function createGo({
14900
14972
  }
14901
14973
  env.GOROOT = goDir || void 0;
14902
14974
  env.PATH = goBinDir || PATH;
14903
- const { stdout } = await (0, import_execa.default)("go", ["version"], {
14904
- env,
14905
- extendEnv: false
14906
- });
14907
- const { major, minor, short, version: version2 } = parseGoVersionString(stdout);
14975
+ const { major, minor, short, version: version2 } = await getInstalledGoVersion(env);
14908
14976
  if (major < GO_MIN_MAJOR_VERSION || major === GO_MIN_MAJOR_VERSION && minor < GO_MIN_MINOR_VERSION) {
14909
14977
  (0, import_build_utils.debug)(`Found go ${version2} in ${label}, but version is unsupported`);
14910
14978
  }
14911
14979
  if (version2 === goSelectedVersion || short === goSelectedVersion) {
14912
14980
  (0, import_build_utils.debug)(`Selected go ${version2} (from ${label})`);
14913
14981
  await setGoEnv(goDir);
14914
- return new GoWrapper(env, opts, version2);
14982
+ return new GoWrapper(env, opts, version2, versionSource);
14915
14983
  } else {
14916
14984
  (0, import_build_utils.debug)(`Found go ${version2} in ${label}, but need ${goSelectedVersion}`);
14917
14985
  }
@@ -14924,7 +14992,7 @@ async function createGo({
14924
14992
  version: goSelectedVersion
14925
14993
  });
14926
14994
  await setGoEnv(goGlobalCacheDir);
14927
- return new GoWrapper(env, opts, goSelectedVersion);
14995
+ return new GoWrapper(env, opts, goSelectedVersion, versionSource);
14928
14996
  }
14929
14997
  async function download({ dest, version: version2 }) {
14930
14998
  const { filename, url } = getGoUrl(version2);
@@ -14965,8 +15033,8 @@ async function download({ dest, version: version2 }) {
14965
15033
  await (0, import_fs_extra.remove)(zipFile);
14966
15034
  }
14967
15035
  } else {
14968
- await new Promise((resolve, reject) => {
14969
- res.body.on("error", reject).pipe(lo({ cwd: tmpDest, strip: 1 })).on("error", reject).on("finish", resolve);
15036
+ await new Promise((resolve2, reject) => {
15037
+ res.body.on("error", reject).pipe(lo({ cwd: tmpDest, strip: 1 })).on("error", reject).on("finish", resolve2);
14970
15038
  });
14971
15039
  }
14972
15040
  await import_fs5.default.promises.writeFile((0, import_path4.join)(tmpDest, GO_INSTALL_MARKER), version2);
@@ -15000,9 +15068,8 @@ function parseGoVersionString(goVersionOutput) {
15000
15068
  }
15001
15069
  var GoError = class extends Error {
15002
15070
  };
15003
- async function parseGoModVersionFromModule(modulePath) {
15071
+ async function parseGoVersionFile(file) {
15004
15072
  let version2;
15005
- const file = (0, import_path4.join)(modulePath, "go.mod");
15006
15073
  try {
15007
15074
  const content = await (0, import_fs_extra.readFile)(file, "utf8");
15008
15075
  version2 = parseGoModVersion(content);
@@ -15124,6 +15191,12 @@ function parseGoModVersion(content) {
15124
15191
  toolchain
15125
15192
  };
15126
15193
  }
15194
+ if (major === GO_MIN_MAJOR_VERSION && compareGoVersions(`${major}.${minor}`, newestSupportedGoVersion()) > 0) {
15195
+ return {
15196
+ go: `${major}.${minor}.0`,
15197
+ toolchain
15198
+ };
15199
+ }
15127
15200
  }
15128
15201
  const err = new GoError(`Unsupported Go version ${major}.${minor}`);
15129
15202
  err.code = "ERR_UNSUPPORTED_GO_VERSION";
@@ -15276,25 +15349,42 @@ function getStandaloneServerRoutes(service) {
15276
15349
  }
15277
15350
  ];
15278
15351
  }
15279
- async function findGoModPath(entrypointDir, workPath) {
15280
- let goModPath = void 0;
15281
- let isGoModInRootDir = false;
15282
- let dir = entrypointDir;
15283
- while (!isGoModInRootDir) {
15284
- isGoModInRootDir = dir === workPath;
15285
- const goMod = (0, import_path6.join)(dir, "go.mod");
15286
- if (await (0, import_fs_extra3.pathExists)(goMod)) {
15287
- goModPath = goMod;
15288
- (0, import_build_utils4.debug)(`Found ${goModPath}"`);
15289
- break;
15290
- }
15291
- dir = (0, import_path6.dirname)(dir);
15292
- }
15352
+ async function locateGoModule({
15353
+ entrypoint,
15354
+ workPath,
15355
+ repoRootPath,
15356
+ goWork
15357
+ }) {
15358
+ const entrypointDir = (0, import_path6.dirname)((0, import_path6.join)(workPath, entrypoint));
15359
+ const repoRoot = repoRootPath ?? workPath;
15360
+ const [goModPath, goWorkPath] = await Promise.all([
15361
+ findGoModPath(entrypointDir, repoRoot),
15362
+ findGoWorkPath(workPath, repoRoot, goWork)
15363
+ ]);
15293
15364
  return {
15294
15365
  goModPath,
15295
- isGoModInRootDir
15366
+ modulePath: goModPath ? (0, import_path6.dirname)(goModPath) : workPath,
15367
+ workspaceFile: goWorkPath,
15368
+ repoRoot
15296
15369
  };
15297
15370
  }
15371
+ function describeGoVersion(go, repoRoot) {
15372
+ const { versionSource } = go;
15373
+ if (versionSource.kind === "default") {
15374
+ return `Using Go ${go.resolvedVersion} (default)`;
15375
+ }
15376
+ const file = (0, import_path6.relative)(repoRoot, versionSource.file) || versionSource.kind;
15377
+ const via = versionSource.directive === "toolchain" ? " via `toolchain` directive" : "";
15378
+ return `Using Go ${go.resolvedVersion} (from ${file}${via})`;
15379
+ }
15380
+ function logGoVersion(go, repoRoot, entrypoint) {
15381
+ console.log(describeGoVersion(go, repoRoot));
15382
+ if (go.versionSource.kind === "default") {
15383
+ console.log(
15384
+ `Warning: no go.mod or go.work found for ${entrypoint} (searched up to ${repoRoot}). Add a \`go\` directive to pin the toolchain version.`
15385
+ );
15386
+ }
15387
+ }
15298
15388
  async function buildStandaloneServer(options) {
15299
15389
  const lambda = await createStandaloneServerLambda(options);
15300
15390
  const { service } = options;
@@ -15314,6 +15404,7 @@ async function createStandaloneServerLambda({
15314
15404
  entrypoint,
15315
15405
  config,
15316
15406
  workPath,
15407
+ repoRootPath,
15317
15408
  meta = {},
15318
15409
  registerPreDeploy,
15319
15410
  service
@@ -15330,13 +15421,19 @@ async function createStandaloneServerLambda({
15330
15421
  GOOS: "linux",
15331
15422
  CGO_ENABLED: "0"
15332
15423
  });
15333
- const { goModPath } = await findGoModPath(workPath, workPath);
15334
- const modulePath = goModPath ? (0, import_path6.dirname)(goModPath) : workPath;
15424
+ const { goModPath, modulePath, workspaceFile, repoRoot } = await locateGoModule({
15425
+ entrypoint,
15426
+ workPath,
15427
+ repoRootPath,
15428
+ goWork: env.GOWORK
15429
+ });
15335
15430
  const go = await createGo({
15336
15431
  modulePath,
15432
+ workspaceFile,
15337
15433
  opts: { cwd: workPath, env },
15338
15434
  workPath
15339
15435
  });
15436
+ logGoVersion(go, repoRoot, entrypoint);
15340
15437
  const outDir = await (0, import_build_utils4.getWriteableDirectory)();
15341
15438
  const userServerPath = (0, import_path6.join)(outDir, "user-server");
15342
15439
  const vendorModulesPath = (0, import_path6.join)(workPath, "vendor", "modules.txt");
@@ -15458,7 +15555,7 @@ function toDevServerResult(serverKey, handle) {
15458
15555
  };
15459
15556
  }
15460
15557
  async function startStandaloneDevServer(opts, resolvedEntrypoint) {
15461
- const { workPath, meta = {} } = opts;
15558
+ const { workPath, repoRootPath, meta = {} } = opts;
15462
15559
  const { devCacheDir = (0, import_path6.join)(workPath, ".vercel", "cache") } = meta;
15463
15560
  const serverKey = `${workPath}::${resolvedEntrypoint}`;
15464
15561
  const existing = PERSISTENT_SERVERS.get(serverKey);
@@ -15472,11 +15569,15 @@ async function startStandaloneDevServer(opts, resolvedEntrypoint) {
15472
15569
  }
15473
15570
  const startPromise = (async () => {
15474
15571
  const env = (0, import_build_utils4.cloneEnv)(process.env, meta.env);
15475
- const entrypointDir = (0, import_path6.dirname)((0, import_path6.join)(workPath, resolvedEntrypoint));
15476
- const { goModPath } = await findGoModPath(entrypointDir, workPath);
15477
- const modulePath = goModPath ? (0, import_path6.dirname)(goModPath) : workPath;
15572
+ const { modulePath, workspaceFile } = await locateGoModule({
15573
+ entrypoint: resolvedEntrypoint,
15574
+ workPath,
15575
+ repoRootPath,
15576
+ goWork: env.GOWORK
15577
+ });
15478
15578
  const go = await createGo({
15479
15579
  modulePath,
15580
+ workspaceFile,
15480
15581
  opts: { cwd: workPath, env },
15481
15582
  workPath,
15482
15583
  // The binary has to run on this machine, so don't downgrade.
@@ -16010,8 +16111,8 @@ async function cleanupFileSystem({
16010
16111
  await (0, import_fs_extra4.remove)(action.from);
16011
16112
  }
16012
16113
  }
16013
- for (const rename of functionRenames) {
16014
- await renameHandlerFunction(rename.fsPath, rename.from, rename.to);
16114
+ for (const rename2 of functionRenames) {
16115
+ await renameHandlerFunction(rename2.fsPath, rename2.from, rename2.to);
16015
16116
  }
16016
16117
  const undoDirectoryPromises = directoryCreation.map(async (directory) => {
16017
16118
  const contents = await (0, import_fs_extra4.readdir)(directory);
@@ -16276,10 +16377,10 @@ async function startDevServer(opts) {
16276
16377
  if (!isReadable(portPipe)) {
16277
16378
  throw new Error("File descriptor 3 is not readable");
16278
16379
  }
16279
- const onPort = new Promise((resolve) => {
16380
+ const onPort = new Promise((resolve2) => {
16280
16381
  portPipe.setEncoding("utf8");
16281
16382
  portPipe.once("data", (d) => {
16282
- resolve({ port: Number(d) });
16383
+ resolve2({ port: Number(d) });
16283
16384
  });
16284
16385
  });
16285
16386
  const onPortFile = waitForPortFile(portFile);
@@ -16310,7 +16411,7 @@ function waitForPortFile(portFile) {
16310
16411
  }
16311
16412
  async function waitForPortFile_(opts) {
16312
16413
  while (!opts.canceled) {
16313
- await new Promise((resolve) => setTimeout(resolve, 100));
16414
+ await new Promise((resolve2) => setTimeout(resolve2, 100));
16314
16415
  try {
16315
16416
  const port = Number(await (0, import_fs_extra4.readFile)(opts.portFile, "ascii"));
16316
16417
  (0, import_async_retry.default)(() => (0, import_fs_extra4.remove)(opts.portFile)).catch((err) => {
@@ -16324,19 +16425,73 @@ async function waitForPortFile_(opts) {
16324
16425
  }
16325
16426
  }
16326
16427
  }
16428
+ var pendingGoCacheCopies = /* @__PURE__ */ new Map();
16429
+ async function removeStagedGoCache(path) {
16430
+ const stat = await (0, import_fs_extra4.lstat)(path);
16431
+ if (stat.isDirectory()) {
16432
+ await (0, import_fs_extra4.chmod)(path, stat.mode | 448);
16433
+ for (const entry of await (0, import_fs_extra4.readdir)(path)) {
16434
+ await removeStagedGoCache((0, import_path7.join)(path, entry));
16435
+ }
16436
+ }
16437
+ await (0, import_fs_extra4.remove)(path);
16438
+ }
16439
+ async function materializeGoCache(goCacheDir) {
16440
+ let source;
16441
+ let target;
16442
+ try {
16443
+ if (!(await (0, import_fs_extra4.lstat)(goCacheDir)).isSymbolicLink())
16444
+ return;
16445
+ target = await (0, import_fs_extra4.readlink)(goCacheDir);
16446
+ source = await (0, import_fs_extra4.realpath)(goCacheDir);
16447
+ } catch (err) {
16448
+ if (err?.code === "ENOENT" || err?.code === "ENOTDIR")
16449
+ return;
16450
+ throw err;
16451
+ }
16452
+ const stagingDir = await (0, import_fs_extra4.mkdtemp)(`${goCacheDir}.tmp-`);
16453
+ try {
16454
+ (0, import_build_utils5.debug)(`Preparing cache by copying ${source} -> ${goCacheDir}`);
16455
+ await (0, import_fs_extra4.copy)(source, stagingDir);
16456
+ await (0, import_fs_extra4.unlink)(goCacheDir);
16457
+ try {
16458
+ await (0, import_fs_extra4.rename)(stagingDir, goCacheDir);
16459
+ } catch (err) {
16460
+ await (0, import_fs_extra4.symlink)(target, goCacheDir).catch(
16461
+ (linkErr) => {
16462
+ if (linkErr.code !== "EEXIST")
16463
+ throw linkErr;
16464
+ }
16465
+ );
16466
+ throw err;
16467
+ }
16468
+ } catch (err) {
16469
+ await removeStagedGoCache(stagingDir).catch((cleanupErr) => {
16470
+ (0, import_build_utils5.debug)(`Failed to remove Go cache staging directory: ${cleanupErr}`);
16471
+ });
16472
+ throw err;
16473
+ }
16474
+ }
16327
16475
  async function prepareCache({
16328
- workPath
16476
+ workPath,
16477
+ repoRootPath
16329
16478
  }) {
16479
+ const root = repoRootPath || workPath;
16330
16480
  const goCacheDir = (0, import_path7.join)(workPath, localCacheDir);
16331
- const stat = await (0, import_fs_extra4.lstat)(goCacheDir);
16332
- if (stat.isSymbolicLink()) {
16333
- const goGlobalCacheDir = await (0, import_fs_extra4.readlink)(goCacheDir);
16334
- (0, import_build_utils5.debug)(`Preparing cache by moving ${goGlobalCacheDir} -> ${goCacheDir}`);
16335
- await (0, import_fs_extra4.unlink)(goCacheDir);
16336
- await (0, import_fs_extra4.move)(goGlobalCacheDir, goCacheDir);
16481
+ let copying = pendingGoCacheCopies.get(goCacheDir);
16482
+ if (!copying) {
16483
+ copying = materializeGoCache(goCacheDir);
16484
+ pendingGoCacheCopies.set(goCacheDir, copying);
16485
+ }
16486
+ try {
16487
+ await copying;
16488
+ } finally {
16489
+ if (pendingGoCacheCopies.get(goCacheDir) === copying) {
16490
+ pendingGoCacheCopies.delete(goCacheDir);
16491
+ }
16337
16492
  }
16338
- const cache = await (0, import_build_utils5.glob)(`${localCacheDir}/**`, workPath);
16339
- return cache;
16493
+ const mountpoint = (0, import_path7.relative)(root, workPath) || void 0;
16494
+ return (0, import_build_utils5.glob)(`${localCacheDir}/**`, workPath, mountpoint);
16340
16495
  }
16341
16496
  // Annotate the CommonJS export names for ESM import in node:
16342
16497
  0 && (module.exports = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vercel/go",
3
- "version": "10.0.1",
3
+ "version": "10.1.0",
4
4
  "license": "Apache-2.0",
5
5
  "main": "./dist/index",
6
6
  "homepage": "https://vercel.com/docs/runtimes#official-runtimes/go",
@@ -16,7 +16,7 @@
16
16
  ],
17
17
  "dependencies": {},
18
18
  "peerDependencies": {
19
- "@vercel/build-utils": "14.9.1"
19
+ "@vercel/build-utils": "14.9.2"
20
20
  },
21
21
  "devDependencies": {
22
22
  "@tootallnate/once": "1.1.2",
@@ -35,7 +35,7 @@
35
35
  "vitest": "4.1.10",
36
36
  "xdg-app-paths": "5.1.0",
37
37
  "yauzl-promise": "2.1.3",
38
- "@vercel/build-utils": "14.9.1",
38
+ "@vercel/build-utils": "14.9.2",
39
39
  "@vercel-internals/ipc-proxy": "1.0.0"
40
40
  },
41
41
  "scripts": {