vercel 59.1.4 → 59.3.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.
Files changed (96) hide show
  1. package/dist/chunks/{add-PP3PJPJV.js → add-4L46WVRT.js} +5 -5
  2. package/dist/chunks/{add-CUGPQYFW.js → add-BBWVXE2R.js} +5 -5
  3. package/dist/chunks/{add-PRG4KKYH.js → add-KOD24LEM.js} +8 -8
  4. package/dist/chunks/{build-T22GMLY6.js → build-2SX3XIRI.js} +5 -5
  5. package/dist/chunks/{chunk-XZLI27ES.js → chunk-6GWLC2IP.js} +3 -3
  6. package/dist/chunks/{chunk-SOKQBFF7.js → chunk-7GE2K2WR.js} +239 -41
  7. package/dist/chunks/{chunk-7NQLRE5V.js → chunk-7PEQVFHI.js} +1 -1
  8. package/dist/chunks/{chunk-QD5NX7RG.js → chunk-AAMJ4ZU4.js} +1 -1
  9. package/dist/chunks/{chunk-M34ZRNDQ.js → chunk-ANIKVXGZ.js} +2 -2
  10. package/dist/chunks/{chunk-DEB45ND4.js → chunk-CURHMEJX.js} +2 -2
  11. package/dist/chunks/{chunk-NM43FFV6.js → chunk-CV4S27SS.js} +0 -1
  12. package/dist/chunks/{chunk-ECCWJHC6.js → chunk-CYNB6LL4.js} +43 -36
  13. package/dist/chunks/{chunk-SQGMTRZD.js → chunk-D35JUCTC.js} +641 -461
  14. package/dist/chunks/{chunk-5DVMXOFT.js → chunk-DAA5RXUK.js} +32 -30
  15. package/dist/chunks/{chunk-CSJBZKC5.js → chunk-EG5BSAXD.js} +69 -57
  16. package/dist/chunks/{chunk-BCZFZETZ.js → chunk-G55RLNFE.js} +5 -5
  17. package/dist/chunks/{chunk-TJLBCLEX.js → chunk-J5ZEHLFM.js} +1 -0
  18. package/dist/chunks/{chunk-QCVKGY2A.js → chunk-KAYSW4CJ.js} +35 -12
  19. package/dist/chunks/{chunk-DOMLWKKZ.js → chunk-KBUCAAG6.js} +17 -20
  20. package/dist/chunks/{chunk-VE545BR3.js → chunk-KDL2L4KL.js} +42 -39
  21. package/dist/chunks/{chunk-P65EEFTR.js → chunk-KQRVZWJU.js} +1 -0
  22. package/dist/chunks/{chunk-JYEO6OJS.js → chunk-MWYQ24FO.js} +4 -3
  23. package/dist/chunks/{chunk-4JKZ7SRX.js → chunk-NN2W7WFC.js} +4 -4
  24. package/dist/chunks/{chunk-KTLFN5FV.js → chunk-OISTYQGR.js} +1 -1
  25. package/dist/chunks/{chunk-ZUVJISHS.js → chunk-P3BFTZXW.js} +2 -2
  26. package/dist/chunks/{chunk-3BU2UCGV.js → chunk-PIMIKY4X.js} +1 -1
  27. package/dist/chunks/{chunk-57G6HBJ4.js → chunk-Q6QCRFTC.js} +3 -3
  28. package/dist/chunks/{chunk-IKKUCZE7.js → chunk-QKO2DGWR.js} +3 -3
  29. package/dist/chunks/{chunk-QQ6PH4RY.js → chunk-STPH4Y62.js} +10 -0
  30. package/dist/chunks/{chunk-P2QZZ6MR.js → chunk-TVXCXIRO.js} +1 -1
  31. package/dist/chunks/{chunk-43DD2KNM.js → chunk-VTP6WIQA.js} +1114 -943
  32. package/dist/chunks/{chunk-DOAYLTBJ.js → chunk-WNS53IOA.js} +1 -1
  33. package/dist/chunks/{chunk-DAWJOQF6.js → chunk-WODLA275.js} +2 -2
  34. package/dist/chunks/{chunk-SJQEGGH7.js → chunk-XI6NJLI4.js} +1 -1
  35. package/dist/chunks/{chunk-LNVZ3T7X.js → chunk-YPPWGI3F.js} +5 -5
  36. package/dist/chunks/{chunk-TM3F7PLR.js → chunk-Z2G6SO5B.js} +3 -3
  37. package/dist/chunks/{chunk-4HI7G6KG.js → chunk-ZHRZMQGN.js} +1 -1
  38. package/dist/chunks/{clear-Z4IKUIN7.js → clear-2DMDKLWZ.js} +5 -5
  39. package/dist/chunks/{compile-vercel-config-PSVXFAZW.js → compile-vercel-config-7HZ4UN6R.js} +3 -3
  40. package/dist/chunks/{config-M5GMZ2X5.js → config-CVZ25C54.js} +5 -5
  41. package/dist/chunks/{delete-P4XIBY7T.js → delete-4LQKP5DG.js} +5 -5
  42. package/dist/chunks/{delete-5GRRDJSF.js → delete-QNAGJM6C.js} +4 -4
  43. package/dist/chunks/{disable-NT5NYVO7.js → disable-2RBFIZUB.js} +4 -4
  44. package/dist/chunks/{discard-TBNIEAJZ.js → discard-UCOSPSUU.js} +4 -4
  45. package/dist/chunks/{edit-DJ6MT6HA.js → edit-JX73BG3V.js} +6 -6
  46. package/dist/chunks/{edit-UF3D2CCH.js → edit-QSAO74S4.js} +6 -6
  47. package/dist/chunks/{enable-JTQBQMBO.js → enable-NDSB4T26.js} +4 -4
  48. package/dist/chunks/{export-OKMRGRVM.js → export-DB6BIYQJ.js} +4 -4
  49. package/dist/chunks/{image-ARUJH4H5.js → image-MKB6II6L.js} +4 -4
  50. package/dist/chunks/{import-builders-3NTMZM64.js → import-builders-FIQ7QTVG.js} +10 -9
  51. package/dist/chunks/{inspect-CHFKZKKP.js → inspect-IYRKEWTM.js} +5 -5
  52. package/dist/chunks/{inspect-PTXIBSYW.js → inspect-NY6QRX5W.js} +5 -5
  53. package/dist/chunks/{inspect-RI4K77NG.js → inspect-QWTWAYLS.js} +6 -6
  54. package/dist/chunks/{inspect-UXP2HDES.js → inspect-REJXLWLL.js} +5 -5
  55. package/dist/chunks/{inspect-5NETOGAI.js → inspect-XS2TC7TC.js} +5 -5
  56. package/dist/chunks/{list-DYCZA2VX.js → list-CDCITV4K.js} +4 -4
  57. package/dist/chunks/{list-G7LGVDAJ.js → list-PXKVKXHG.js} +6 -6
  58. package/dist/chunks/{list-ADI55WKW.js → list-VQHBVY3Q.js} +5 -5
  59. package/dist/chunks/{login-YCSIQG6B.js → login-PE4JK7A2.js} +5 -5
  60. package/dist/chunks/{ls-VIOMDUGW.js → ls-3GRHYFDM.js} +5 -5
  61. package/dist/chunks/{ls-PQFDGOJL.js → ls-DL2POAY2.js} +6 -6
  62. package/dist/chunks/{ls-EOMIQLRH.js → ls-S67TNMEG.js} +5 -5
  63. package/dist/chunks/{ls-2TKUIUK4.js → ls-SKOQOPK4.js} +5 -5
  64. package/dist/chunks/{ls-RZVTIP5U.js → ls-YHS5IEBJ.js} +5 -5
  65. package/dist/chunks/{open-JYPWOXQD.js → open-DUN3BTDH.js} +5 -5
  66. package/dist/chunks/{permissions-SGJWGEVD.js → permissions-VLIZYINB.js} +5 -5
  67. package/dist/chunks/{publish-ZUQHJAXL.js → publish-36BIJPLN.js} +4 -4
  68. package/dist/chunks/{push-XMVKG5A5.js → push-5NTQV3EC.js} +5 -5
  69. package/dist/chunks/{query-ZLJZEGZB.js → query-ONR2W7HS.js} +218 -81
  70. package/dist/chunks/{reorder-NVHDWMRU.js → reorder-YKAT4XG3.js} +4 -4
  71. package/dist/chunks/{reply-PUUPUQ3V.js → reply-DH4ZPEXT.js} +6 -6
  72. package/dist/chunks/{resolve-5U2LJVE6.js → resolve-446IVH6V.js} +5 -5
  73. package/dist/chunks/{restore-OXIUY2UI.js → restore-HA6TSOOE.js} +4 -4
  74. package/dist/chunks/{rm-BZNKJRXU.js → rm-BCPJUK2C.js} +5 -5
  75. package/dist/chunks/{rm-3IOCBNPE.js → rm-COV73VE4.js} +6 -6
  76. package/dist/chunks/{rm-Z2KYJ7XT.js → rm-EG35766L.js} +5 -5
  77. package/dist/chunks/{rm-OUI4ZB5R.js → rm-IKYJI7MP.js} +5 -5
  78. package/dist/chunks/{routes-JP2CNQ5J.js → routes-SZI2G4SE.js} +2 -2
  79. package/dist/chunks/{rule-inspect-ZBJJCDQV.js → rule-inspect-FQ2635LY.js} +6 -6
  80. package/dist/chunks/{rules-HEGAXXUN.js → rules-PBOQISWV.js} +8 -8
  81. package/dist/chunks/{schema-7GVL3BNP.js → schema-4CDJVH7T.js} +22 -12
  82. package/dist/chunks/{schema-ZYIJYA2E.js → schema-LUVFYPWN.js} +1 -1
  83. package/dist/chunks/{tags-3SCWCMNQ.js → tags-HNOL4JXL.js} +3 -3
  84. package/dist/chunks/{update-YR2GCCJN.js → update-ZIGVLUYG.js} +8 -8
  85. package/dist/commands/build/index.js +3095 -2519
  86. package/dist/commands/deploy/index.js +12 -12
  87. package/dist/commands/dev/index.js +22 -15
  88. package/dist/commands/env/index.js +8 -8
  89. package/dist/commands/link/index.js +7 -7
  90. package/dist/commands/list/index.js +5 -5
  91. package/dist/commands-bulk.js +2548 -1829
  92. package/dist/help.js +1 -1
  93. package/dist/index.js +27 -15
  94. package/dist/runtime-assets/node-preloads/next-dev-websocket.cjs +5 -1
  95. package/dist/version.mjs +1 -1
  96. package/package.json +42 -40
@@ -5,11 +5,10 @@ const require = __createRequire(import.meta.url);
5
5
  const __filename = __fileURLToPath(import.meta.url);
6
6
  const __dirname = __dirname_(__filename);
7
7
  import {
8
- VERCEL_DIR,
9
8
  require_dist as require_dist2,
10
9
  require_dist3,
11
10
  require_lib
12
- } from "./chunk-VE545BR3.js";
11
+ } from "./chunk-KDL2L4KL.js";
13
12
  import {
14
13
  output_manager_default,
15
14
  require_dist
@@ -7872,7 +7871,7 @@ var require_mime_types = __commonJS({
7872
7871
  "../../node_modules/.pnpm/mime-types@2.1.24/node_modules/mime-types/index.js"(exports) {
7873
7872
  "use strict";
7874
7873
  var db = require_mime_db();
7875
- var extname2 = __require("path").extname;
7874
+ var extname = __require("path").extname;
7876
7875
  var EXTRACT_TYPE_REGEXP = /^\s*([^;\s]*)(?:;|\s|$)/;
7877
7876
  var TEXT_TYPE_REGEXP = /^text\//i;
7878
7877
  exports.charset = charset;
@@ -7923,11 +7922,11 @@ var require_mime_types = __commonJS({
7923
7922
  }
7924
7923
  return exts[0];
7925
7924
  }
7926
- function lookup(path2) {
7927
- if (!path2 || typeof path2 !== "string") {
7925
+ function lookup(path) {
7926
+ if (!path || typeof path !== "string") {
7928
7927
  return false;
7929
7928
  }
7930
- var extension2 = extname2("x." + path2).toLowerCase().substr(1);
7929
+ var extension2 = extname("x." + path).toLowerCase().substr(1);
7931
7930
  if (!extension2) {
7932
7931
  return false;
7933
7932
  }
@@ -7980,13 +7979,13 @@ var require_promisepipe = __commonJS({
7980
7979
  }
7981
7980
  const isReadable = stream.readable || typeof stream._read === "function";
7982
7981
  function on(evt) {
7983
- function executor(resolve3, reject) {
7982
+ function executor(resolve, reject) {
7984
7983
  const fn = evt === "error" ? (err) => reject(new StreamError(err, stream)) : () => {
7985
7984
  if (isReadable && evt === "finish" && !state.error) {
7986
7985
  return;
7987
7986
  }
7988
7987
  cleanupEventHandlers(stream, fn);
7989
- resolve3(stream);
7988
+ resolve(stream);
7990
7989
  };
7991
7990
  stream.on(evt, fn);
7992
7991
  }
@@ -8032,6 +8031,77 @@ var require_promisepipe = __commonJS({
8032
8031
  }
8033
8032
  });
8034
8033
 
8034
+ // ../../internals/builder-orchestration/dist/merge.js
8035
+ var require_merge = __commonJS({
8036
+ "../../internals/builder-orchestration/dist/merge.js"(exports, module) {
8037
+ "use strict";
8038
+ var __defProp = Object.defineProperty;
8039
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
8040
+ var __getOwnPropNames = Object.getOwnPropertyNames;
8041
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8042
+ var __export = (target, all) => {
8043
+ for (var name in all)
8044
+ __defProp(target, name, { get: all[name], enumerable: true });
8045
+ };
8046
+ var __copyProps = (to, from, except, desc) => {
8047
+ if (from && typeof from === "object" || typeof from === "function") {
8048
+ for (let key of __getOwnPropNames(from))
8049
+ if (!__hasOwnProp.call(to, key) && key !== except)
8050
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
8051
+ }
8052
+ return to;
8053
+ };
8054
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
8055
+ var merge_exports = {};
8056
+ __export(merge_exports, {
8057
+ merge: () => merge
8058
+ });
8059
+ module.exports = __toCommonJS(merge_exports);
8060
+ var import_path = __require("path");
8061
+ var import_error_utils = require_dist();
8062
+ var import_fs_extra = require_lib();
8063
+ async function merge(source, destination, ignoreFilter, sourceRoot) {
8064
+ const root = sourceRoot || source;
8065
+ if (ignoreFilter) {
8066
+ const relPath = (0, import_path.relative)(root, source);
8067
+ if (relPath && !ignoreFilter(relPath)) {
8068
+ await (0, import_fs_extra.remove)(source);
8069
+ return;
8070
+ }
8071
+ }
8072
+ const destStat = await (0, import_fs_extra.stat)(destination).catch(
8073
+ (err) => err
8074
+ );
8075
+ if ((0, import_error_utils.isErrnoException)(destStat)) {
8076
+ if (destStat.code === "ENOENT") {
8077
+ await (0, import_fs_extra.move)(source, destination);
8078
+ return;
8079
+ }
8080
+ throw destStat;
8081
+ } else if (destStat.isDirectory()) {
8082
+ const contents = await (0, import_fs_extra.readdir)(
8083
+ source
8084
+ ).catch((err) => err);
8085
+ if ((0, import_error_utils.isErrnoException)(contents)) {
8086
+ if (contents.code !== "ENOTDIR") {
8087
+ throw contents;
8088
+ }
8089
+ } else {
8090
+ await Promise.all(
8091
+ contents.map(
8092
+ (name) => merge((0, import_path.join)(source, name), (0, import_path.join)(destination, name), ignoreFilter, root)
8093
+ )
8094
+ );
8095
+ await (0, import_fs_extra.rmdir)(source);
8096
+ return;
8097
+ }
8098
+ }
8099
+ await (0, import_fs_extra.remove)(destination);
8100
+ await (0, import_fs_extra.move)(source, destination);
8101
+ }
8102
+ }
8103
+ });
8104
+
8035
8105
  // ../../node_modules/.pnpm/pend@1.2.0/node_modules/pend/index.js
8036
8106
  var require_pend = __commonJS({
8037
8107
  "../../node_modules/.pnpm/pend@1.2.0/node_modules/pend/index.js"(exports, module) {
@@ -8091,7 +8161,7 @@ var require_pend = __commonJS({
8091
8161
  // ../../node_modules/.pnpm/fd-slicer@1.1.0/node_modules/fd-slicer/index.js
8092
8162
  var require_fd_slicer = __commonJS({
8093
8163
  "../../node_modules/.pnpm/fd-slicer@1.1.0/node_modules/fd-slicer/index.js"(exports) {
8094
- var fs4 = __require("fs");
8164
+ var fs = __require("fs");
8095
8165
  var util = __require("util");
8096
8166
  var stream = __require("stream");
8097
8167
  var Readable = stream.Readable;
@@ -8116,7 +8186,7 @@ var require_fd_slicer = __commonJS({
8116
8186
  FdSlicer.prototype.read = function(buffer, offset, length, position, callback) {
8117
8187
  var self = this;
8118
8188
  self.pend.go(function(cb) {
8119
- fs4.read(self.fd, buffer, offset, length, position, function(err, bytesRead, buffer2) {
8189
+ fs.read(self.fd, buffer, offset, length, position, function(err, bytesRead, buffer2) {
8120
8190
  cb();
8121
8191
  callback(err, bytesRead, buffer2);
8122
8192
  });
@@ -8125,7 +8195,7 @@ var require_fd_slicer = __commonJS({
8125
8195
  FdSlicer.prototype.write = function(buffer, offset, length, position, callback) {
8126
8196
  var self = this;
8127
8197
  self.pend.go(function(cb) {
8128
- fs4.write(self.fd, buffer, offset, length, position, function(err, written, buffer2) {
8198
+ fs.write(self.fd, buffer, offset, length, position, function(err, written, buffer2) {
8129
8199
  cb();
8130
8200
  callback(err, written, buffer2);
8131
8201
  });
@@ -8148,7 +8218,7 @@ var require_fd_slicer = __commonJS({
8148
8218
  if (self.refCount < 0)
8149
8219
  throw new Error("invalid unref");
8150
8220
  if (self.autoClose) {
8151
- fs4.close(self.fd, onCloseDone);
8221
+ fs.close(self.fd, onCloseDone);
8152
8222
  }
8153
8223
  function onCloseDone(err) {
8154
8224
  if (err) {
@@ -8187,7 +8257,7 @@ var require_fd_slicer = __commonJS({
8187
8257
  if (self.destroyed)
8188
8258
  return cb();
8189
8259
  var buffer = new Buffer(toRead);
8190
- fs4.read(self.context.fd, buffer, 0, toRead, self.pos, function(err, bytesRead) {
8260
+ fs.read(self.context.fd, buffer, 0, toRead, self.pos, function(err, bytesRead) {
8191
8261
  if (err) {
8192
8262
  self.destroy(err);
8193
8263
  } else if (bytesRead === 0) {
@@ -8237,7 +8307,7 @@ var require_fd_slicer = __commonJS({
8237
8307
  self.context.pend.go(function(cb) {
8238
8308
  if (self.destroyed)
8239
8309
  return cb();
8240
- fs4.write(self.context.fd, buffer, 0, buffer.length, self.pos, function(err2, bytes) {
8310
+ fs.write(self.context.fd, buffer, 0, buffer.length, self.pos, function(err2, bytes) {
8241
8311
  if (err2) {
8242
8312
  self.destroy();
8243
8313
  cb();
@@ -8666,7 +8736,7 @@ var require_buffer_crc32 = __commonJS({
8666
8736
  // ../../node_modules/.pnpm/yauzl@2.10.0/node_modules/yauzl/index.js
8667
8737
  var require_yauzl = __commonJS({
8668
8738
  "../../node_modules/.pnpm/yauzl@2.10.0/node_modules/yauzl/index.js"(exports) {
8669
- var fs4 = __require("fs");
8739
+ var fs = __require("fs");
8670
8740
  var zlib = __require("zlib");
8671
8741
  var fd_slicer = require_fd_slicer();
8672
8742
  var crc32 = require_buffer_crc32();
@@ -8684,7 +8754,7 @@ var require_yauzl = __commonJS({
8684
8754
  exports.ZipFile = ZipFile;
8685
8755
  exports.Entry = Entry;
8686
8756
  exports.RandomAccessReader = RandomAccessReader;
8687
- function open(path2, options, callback) {
8757
+ function open(path, options, callback) {
8688
8758
  if (typeof options === "function") {
8689
8759
  callback = options;
8690
8760
  options = null;
@@ -8703,12 +8773,12 @@ var require_yauzl = __commonJS({
8703
8773
  options.strictFileNames = false;
8704
8774
  if (callback == null)
8705
8775
  callback = defaultCallback;
8706
- fs4.open(path2, "r", function(err, fd) {
8776
+ fs.open(path, "r", function(err, fd) {
8707
8777
  if (err)
8708
8778
  return callback(err);
8709
8779
  fromFd(fd, options, function(err2, zipfile) {
8710
8780
  if (err2)
8711
- fs4.close(fd, defaultCallback);
8781
+ fs.close(fd, defaultCallback);
8712
8782
  callback(err2, zipfile);
8713
8783
  });
8714
8784
  });
@@ -8732,7 +8802,7 @@ var require_yauzl = __commonJS({
8732
8802
  options.strictFileNames = false;
8733
8803
  if (callback == null)
8734
8804
  callback = defaultCallback;
8735
- fs4.fstat(fd, function(err, stats) {
8805
+ fs.fstat(fd, function(err, stats) {
8736
8806
  if (err)
8737
8807
  return callback(err);
8738
8808
  var reader = fd_slicer.createFromFd(fd, { autoClose: true });
@@ -9613,27 +9683,27 @@ var require_lib2 = __commonJS({
9613
9683
  return shimmed.call(this, reader, totalSize, options, callback);
9614
9684
  };
9615
9685
  } else {
9616
- const shimmed = fn(function(path2, unused, options, callback) {
9617
- return original.call(this, path2, options, callback);
9686
+ const shimmed = fn(function(path, unused, options, callback) {
9687
+ return original.call(this, path, options, callback);
9618
9688
  });
9619
- yauzl[methodName] = function(path2, options, callback) {
9689
+ yauzl[methodName] = function(path, options, callback) {
9620
9690
  if (typeof options == "function") {
9621
9691
  callback = options;
9622
9692
  options = {};
9623
9693
  } else if (!options) {
9624
9694
  options = {};
9625
9695
  }
9626
- return shimmed.call(this, path2, null, options, callback);
9696
+ return shimmed.call(this, path, null, options, callback);
9627
9697
  };
9628
9698
  }
9629
9699
  return yauzl[methodName];
9630
9700
  }
9631
9701
  function zipFilePatcher(original, ZipFile) {
9632
- return function(path2, totalSize, options, callback) {
9702
+ return function(path, totalSize, options, callback) {
9633
9703
  const { lazyEntries } = options, hasLazyEntries = options.hasOwnProperty("lazyEntries");
9634
9704
  if (!lazyEntries)
9635
9705
  options.lazyEntries = true;
9636
- return original.call(this, path2, totalSize, options, function(err, zipFile) {
9706
+ return original.call(this, path, totalSize, options, function(err, zipFile) {
9637
9707
  if (err)
9638
9708
  return callback(err);
9639
9709
  const zipFileInternal = zipFile;
@@ -9654,8 +9724,8 @@ var require_lib2 = __commonJS({
9654
9724
  };
9655
9725
  }
9656
9726
  function entryPatcher(original, Entry) {
9657
- return function(path2, totalSize, options, callback) {
9658
- return original.call(this, path2, totalSize, options, function(err, zipFile) {
9727
+ return function(path, totalSize, options, callback) {
9728
+ return original.call(this, path, totalSize, options, function(err, zipFile) {
9659
9729
  if (err)
9660
9730
  return callback(err);
9661
9731
  zipFile.intercept("entry", function(entry, cb) {
@@ -9706,19 +9776,19 @@ var require_promisify = __commonJS({
9706
9776
  function promisifyMethod(yauzl, Promise2, fnName) {
9707
9777
  const fromBuffer = fnName == "fromBuffer";
9708
9778
  cloner.patch(yauzl, fnName, (original) => {
9709
- return function(path2, totalSize, options) {
9710
- return new Promise2((resolve3, reject) => {
9779
+ return function(path, totalSize, options) {
9780
+ return new Promise2((resolve, reject) => {
9711
9781
  options = Object.assign({}, options, { lazyEntries: true, autoClose: false });
9712
- original(path2, totalSize, options, (err, zipFile) => {
9782
+ original(path, totalSize, options, (err, zipFile) => {
9713
9783
  if (err)
9714
9784
  return reject(err);
9715
- opened(zipFile, resolve3, fromBuffer, yauzl);
9785
+ opened(zipFile, resolve, fromBuffer, yauzl);
9716
9786
  });
9717
9787
  });
9718
9788
  };
9719
9789
  });
9720
9790
  }
9721
- function opened(zipFile, resolve3, fromBuffer, yauzl) {
9791
+ function opened(zipFile, resolve, fromBuffer, yauzl) {
9722
9792
  if (fromBuffer) {
9723
9793
  zipFile.reader.unref = yauzl.RandomAccessReader.prototype.unref;
9724
9794
  zipFile.reader.close = (cb) => cb();
@@ -9729,7 +9799,7 @@ var require_promisify = __commonJS({
9729
9799
  zipFile.intercept("end", emittedEnd);
9730
9800
  zipFile.intercept("close", emittedClose);
9731
9801
  zipFile.intercept("error", emittedError);
9732
- resolve3(zipFile);
9802
+ resolve(zipFile);
9733
9803
  }
9734
9804
  function emittedError(err) {
9735
9805
  const state = getState(this);
@@ -9748,14 +9818,14 @@ var require_promisify = __commonJS({
9748
9818
  function promisifyClose(ZipFile, Promise2) {
9749
9819
  const close = ZipFile.prototype.close;
9750
9820
  ZipFile.prototype.close = function() {
9751
- return new Promise2((resolve3, reject) => {
9821
+ return new Promise2((resolve, reject) => {
9752
9822
  if (getError(this))
9753
9823
  return rejectWithStoredError(this, reject);
9754
9824
  if (!this.isOpen)
9755
- return resolve3();
9825
+ return resolve();
9756
9826
  if (getState(this))
9757
9827
  return reject(new Error("Previous operation has not completed yet"));
9758
- setState(this, { action: "close", resolve: resolve3, reject });
9828
+ setState(this, { action: "close", resolve, reject });
9759
9829
  close.call(this);
9760
9830
  });
9761
9831
  };
@@ -9770,14 +9840,14 @@ var require_promisify = __commonJS({
9770
9840
  function promisifyReadEntry(ZipFile, Promise2) {
9771
9841
  const readEntry = ZipFile.prototype.readEntry;
9772
9842
  ZipFile.prototype.readEntry = function() {
9773
- return new Promise2((resolve3, reject) => {
9843
+ return new Promise2((resolve, reject) => {
9774
9844
  if (getError(this))
9775
9845
  return rejectWithStoredError(this, reject);
9776
9846
  if (!this.isOpen)
9777
9847
  return reject(new Error("ZipFile is not open"));
9778
9848
  if (getState(this))
9779
9849
  return reject(new Error("Previous operation has not completed yet"));
9780
- setState(this, { action: "read", resolve: resolve3, reject });
9850
+ setState(this, { action: "read", resolve, reject });
9781
9851
  readEntry.call(this);
9782
9852
  });
9783
9853
  };
@@ -9823,11 +9893,11 @@ var require_promisify = __commonJS({
9823
9893
  function addWalkEntriesMethod(ZipFile, Promise2) {
9824
9894
  ZipFile.prototype.walkEntries = function(callback, numEntries) {
9825
9895
  callback = wrapFunctionToReturnPromise(callback, Promise2);
9826
- return new Promise2((resolve3, reject) => {
9896
+ return new Promise2((resolve, reject) => {
9827
9897
  walkNextEntry(this, callback, numEntries, 0, (err) => {
9828
9898
  if (err)
9829
9899
  return reject(err);
9830
- resolve3();
9900
+ resolve();
9831
9901
  });
9832
9902
  });
9833
9903
  };
@@ -9848,13 +9918,13 @@ var require_promisify = __commonJS({
9848
9918
  function promisifyOpenReadStream(ZipFile, Promise2) {
9849
9919
  const openReadStream = ZipFile.prototype.openReadStream;
9850
9920
  ZipFile.prototype.openReadStream = function(entry, options) {
9851
- return new Promise2((resolve3, reject) => {
9921
+ return new Promise2((resolve, reject) => {
9852
9922
  if (getError(this))
9853
9923
  return rejectWithStoredError(this, reject);
9854
9924
  openReadStream.call(this, entry, options || {}, (err, stream) => {
9855
9925
  if (err)
9856
9926
  return reject(err);
9857
- resolve3(stream);
9927
+ resolve(stream);
9858
9928
  });
9859
9929
  });
9860
9930
  };
@@ -9870,7 +9940,7 @@ var require_promisify = __commonJS({
9870
9940
  return result;
9871
9941
  return Promise2.resolve(result);
9872
9942
  } catch (err) {
9873
- return new Promise2((resolve3, reject) => {
9943
+ return new Promise2((resolve, reject) => {
9874
9944
  reject(err);
9875
9945
  });
9876
9946
  }
@@ -9916,471 +9986,461 @@ var require_lib3 = __commonJS({
9916
9986
  }
9917
9987
  });
9918
9988
 
9919
- // src/util/build/write-build-result.ts
9920
- var import_fs_extra2 = __toESM(require_lib(), 1);
9921
- var import_mime_types = __toESM(require_mime_types(), 1);
9922
- var import_fs_detectors = __toESM(require_dist3(), 1);
9923
- var import_promisepipe2 = __toESM(require_promisepipe(), 1);
9924
- import {
9925
- basename,
9926
- dirname,
9927
- extname,
9928
- join as join2,
9929
- relative as relative2,
9930
- resolve,
9931
- posix
9932
- } from "path";
9933
- import {
9934
- FileFsRef,
9935
- download,
9936
- downloadFile,
9937
- getLambdaOptionsFromFunction,
9938
- normalizePath,
9939
- isBackendBuilder,
9940
- isExperimentalBackendsEnabled,
9941
- isExperimentalService,
9942
- isExperimentalServiceV2,
9943
- isSymbolicLink
9944
- } from "@vercel/build-utils";
9945
-
9946
- // src/util/build/merge.ts
9947
- var import_error_utils = __toESM(require_dist(), 1);
9948
- var import_fs_extra = __toESM(require_lib(), 1);
9949
- import { join, relative } from "path";
9950
- async function merge(source, destination, ignoreFilter, sourceRoot) {
9951
- const root = sourceRoot || source;
9952
- if (ignoreFilter) {
9953
- const relPath = relative(root, source);
9954
- if (relPath && !ignoreFilter(relPath)) {
9955
- await (0, import_fs_extra.remove)(source);
9956
- return;
9957
- }
9958
- }
9959
- const destStat = await (0, import_fs_extra.stat)(destination).catch(
9960
- (err) => err
9961
- );
9962
- if ((0, import_error_utils.isErrnoException)(destStat)) {
9963
- if (destStat.code === "ENOENT") {
9964
- await (0, import_fs_extra.move)(source, destination);
9965
- return;
9989
+ // ../../internals/builder-orchestration/dist/unzip.js
9990
+ var require_unzip = __commonJS({
9991
+ "../../internals/builder-orchestration/dist/unzip.js"(exports, module) {
9992
+ "use strict";
9993
+ var __create = Object.create;
9994
+ var __defProp = Object.defineProperty;
9995
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
9996
+ var __getOwnPropNames = Object.getOwnPropertyNames;
9997
+ var __getProtoOf = Object.getPrototypeOf;
9998
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
9999
+ var __export = (target, all) => {
10000
+ for (var name in all)
10001
+ __defProp(target, name, { get: all[name], enumerable: true });
10002
+ };
10003
+ var __copyProps = (to, from, except, desc) => {
10004
+ if (from && typeof from === "object" || typeof from === "function") {
10005
+ for (let key of __getOwnPropNames(from))
10006
+ if (!__hasOwnProp.call(to, key) && key !== except)
10007
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
10008
+ }
10009
+ return to;
10010
+ };
10011
+ var __toESM2 = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
10012
+ // If the importer is in node compatibility mode or this is not an ESM
10013
+ // file that has been converted to a CommonJS file using a Babel-
10014
+ // compatible transform (i.e. "__esModule" has not been set), then set
10015
+ // "default" to the CommonJS "module.exports" for node compatibility.
10016
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
10017
+ mod
10018
+ ));
10019
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
10020
+ var unzip_exports = {};
10021
+ __export(unzip_exports, {
10022
+ unzip: () => unzip
10023
+ });
10024
+ module.exports = __toCommonJS(unzip_exports);
10025
+ var import_path = __toESM2(__require("path"));
10026
+ var import_promisepipe = __toESM2(require_promisepipe());
10027
+ var fs = __toESM2(require_lib());
10028
+ var import_build_utils = __require("@vercel/build-utils");
10029
+ var import_yauzl_promise = require_lib3();
10030
+ async function* createZipIterator(zipFile) {
10031
+ let entry;
10032
+ while ((entry = await zipFile.readEntry()) !== null) {
10033
+ yield entry;
10034
+ }
9966
10035
  }
9967
- throw destStat;
9968
- } else if (destStat.isDirectory()) {
9969
- const contents = await (0, import_fs_extra.readdir)(
9970
- source
9971
- ).catch((err) => err);
9972
- if ((0, import_error_utils.isErrnoException)(contents)) {
9973
- if (contents.code !== "ENOTDIR") {
9974
- throw contents;
10036
+ async function unzip(buffer, dir) {
10037
+ const zipFile = await (0, import_yauzl_promise.fromBuffer)(buffer);
10038
+ for await (const entry of createZipIterator(zipFile)) {
10039
+ if (entry.fileName.startsWith("__MACOSX/"))
10040
+ continue;
10041
+ try {
10042
+ const destDir = import_path.default.dirname(import_path.default.join(dir, entry.fileName));
10043
+ await fs.mkdirp(destDir);
10044
+ const canonicalDestDir = await fs.realpath(destDir);
10045
+ const relativeDestDir = import_path.default.relative(dir, canonicalDestDir);
10046
+ if (relativeDestDir.split(import_path.default.sep).includes("..")) {
10047
+ throw new Error(
10048
+ `Out of bound path "${canonicalDestDir}" found while processing file ${entry.fileName}`
10049
+ );
10050
+ }
10051
+ await extractEntry(zipFile, entry, dir);
10052
+ } catch (err) {
10053
+ await zipFile.close();
10054
+ throw err;
10055
+ }
9975
10056
  }
9976
- } else {
9977
- await Promise.all(
9978
- contents.map(
9979
- (name) => merge(join(source, name), join(destination, name), ignoreFilter, root)
9980
- )
9981
- );
9982
- await (0, import_fs_extra.rmdir)(source);
9983
- return;
9984
10057
  }
9985
- }
9986
- await (0, import_fs_extra.remove)(destination);
9987
- await (0, import_fs_extra.move)(source, destination);
9988
- }
9989
-
9990
- // src/util/build/unzip.ts
9991
- var import_promisepipe = __toESM(require_promisepipe(), 1);
9992
- var fs = __toESM(require_lib(), 1);
9993
- var import_yauzl_promise = __toESM(require_lib3(), 1);
9994
- import path from "path";
9995
- import { streamToBuffer } from "@vercel/build-utils";
9996
- async function* createZipIterator(zipFile) {
9997
- let entry;
9998
- while ((entry = await zipFile.readEntry()) !== null) {
9999
- yield entry;
10000
- }
10001
- }
10002
- async function unzip(buffer, dir) {
10003
- const zipFile = await (0, import_yauzl_promise.fromBuffer)(buffer);
10004
- for await (const entry of createZipIterator(zipFile)) {
10005
- if (entry.fileName.startsWith("__MACOSX/"))
10006
- continue;
10007
- try {
10008
- const destDir = path.dirname(path.join(dir, entry.fileName));
10009
- await fs.mkdirp(destDir);
10010
- const canonicalDestDir = await fs.realpath(destDir);
10011
- const relativeDestDir = path.relative(dir, canonicalDestDir);
10012
- if (relativeDestDir.split(path.sep).includes("..")) {
10013
- throw new Error(
10014
- `Out of bound path "${canonicalDestDir}" found while processing file ${entry.fileName}`
10015
- );
10058
+ async function extractEntry(zipFile, entry, dir) {
10059
+ const dest = import_path.default.join(dir, entry.fileName);
10060
+ const mode = entry.externalFileAttributes >> 16 & 65535;
10061
+ const IFMT = 61440;
10062
+ const IFDIR = 16384;
10063
+ const IFLNK = 40960;
10064
+ const symlink = (mode & IFMT) === IFLNK;
10065
+ let isDir = (mode & IFMT) === IFDIR;
10066
+ if (!isDir && entry.fileName.endsWith("/")) {
10067
+ isDir = true;
10068
+ }
10069
+ const madeBy = entry.versionMadeBy >> 8;
10070
+ if (!isDir)
10071
+ isDir = madeBy === 0 && entry.externalFileAttributes === 16;
10072
+ const procMode = getExtractedMode(mode, isDir) & 511;
10073
+ const destDir = isDir ? dest : import_path.default.dirname(dest);
10074
+ const mkdirOptions = { recursive: true };
10075
+ if (isDir) {
10076
+ mkdirOptions.mode = procMode;
10077
+ }
10078
+ await fs.mkdir(destDir, mkdirOptions);
10079
+ if (isDir)
10080
+ return;
10081
+ const readStream = await zipFile.openReadStream(entry);
10082
+ if (symlink) {
10083
+ const link = await (0, import_build_utils.streamToBuffer)(readStream);
10084
+ await fs.symlink(link.toString("utf8"), dest);
10085
+ } else {
10086
+ await (0, import_promisepipe.default)(readStream, fs.createWriteStream(dest, { mode: procMode }));
10016
10087
  }
10017
- await extractEntry(zipFile, entry, dir);
10018
- } catch (err) {
10019
- await zipFile.close();
10020
- throw err;
10021
10088
  }
10022
- }
10023
- }
10024
- async function extractEntry(zipFile, entry, dir) {
10025
- const dest = path.join(dir, entry.fileName);
10026
- const mode = entry.externalFileAttributes >> 16 & 65535;
10027
- const IFMT = 61440;
10028
- const IFDIR = 16384;
10029
- const IFLNK = 40960;
10030
- const symlink2 = (mode & IFMT) === IFLNK;
10031
- let isDir = (mode & IFMT) === IFDIR;
10032
- if (!isDir && entry.fileName.endsWith("/")) {
10033
- isDir = true;
10034
- }
10035
- const madeBy = entry.versionMadeBy >> 8;
10036
- if (!isDir)
10037
- isDir = madeBy === 0 && entry.externalFileAttributes === 16;
10038
- const procMode = getExtractedMode(mode, isDir) & 511;
10039
- const destDir = isDir ? dest : path.dirname(dest);
10040
- const mkdirOptions = { recursive: true };
10041
- if (isDir) {
10042
- mkdirOptions.mode = procMode;
10043
- }
10044
- await fs.mkdir(destDir, mkdirOptions);
10045
- if (isDir)
10046
- return;
10047
- const readStream = await zipFile.openReadStream(entry);
10048
- if (symlink2) {
10049
- const link = await streamToBuffer(readStream);
10050
- await fs.symlink(link.toString("utf8"), dest);
10051
- } else {
10052
- await (0, import_promisepipe.default)(readStream, fs.createWriteStream(dest, { mode: procMode }));
10053
- }
10054
- }
10055
- function getExtractedMode(entryMode, isDir) {
10056
- let mode = entryMode;
10057
- if (mode === 0) {
10058
- if (isDir) {
10059
- mode = 493;
10060
- } else {
10061
- mode = 420;
10089
+ function getExtractedMode(entryMode, isDir) {
10090
+ let mode = entryMode;
10091
+ if (mode === 0) {
10092
+ if (isDir) {
10093
+ mode = 493;
10094
+ } else {
10095
+ mode = 420;
10096
+ }
10097
+ }
10098
+ return mode;
10062
10099
  }
10063
10100
  }
10064
- return mode;
10065
- }
10101
+ });
10066
10102
 
10067
- // src/util/build/write-build-result.ts
10068
- var import_client = __toESM(require_dist2(), 1);
10069
- var { normalize } = posix;
10070
- var OUTPUT_DIR = join2(VERCEL_DIR, "output");
10071
- var BUILD_OUTPUT_API_ENTRIES = [
10072
- "config.json",
10073
- "functions",
10074
- "routes",
10075
- "static"
10076
- ];
10077
- async function writeBuildResult(args) {
10078
- const {
10079
- repoRootPath,
10080
- outputDir,
10081
- buildResult,
10082
- build,
10083
- builder,
10084
- builderPkg,
10085
- vercelConfig,
10086
- standalone,
10087
- workPath,
10088
- service,
10089
- nestServiceOutput = false,
10090
- stripServiceRoutePrefix = false
10091
- } = args;
10092
- const writeOutputDir = service && nestServiceOutput ? getServiceOutputDir(outputDir, service) : outputDir;
10093
- let version;
10094
- let actualResult;
10095
- if (builder.version === -1) {
10096
- const vx = buildResult;
10097
- version = vx.resultVersion;
10098
- actualResult = vx.result;
10099
- } else {
10100
- version = builder.version;
10101
- actualResult = buildResult;
10102
- }
10103
- if (typeof version !== "number" || version === 2) {
10104
- return writeBuildResultV2({
10105
- repoRootPath,
10106
- outputDir: writeOutputDir,
10107
- buildResult: actualResult,
10108
- build,
10109
- vercelConfig,
10110
- standalone,
10111
- workPath,
10112
- service,
10113
- rootOutputDir: outputDir,
10114
- stripServiceRoutePrefix
10115
- });
10116
- } else if (version === 3) {
10117
- return writeBuildResultV3({
10118
- repoRootPath,
10119
- outputDir: writeOutputDir,
10120
- buildResult: actualResult,
10121
- build,
10122
- vercelConfig,
10123
- standalone,
10124
- workPath,
10125
- service,
10126
- rootOutputDir: outputDir,
10127
- stripServiceRoutePrefix
10128
- });
10129
- }
10130
- throw new Error(
10131
- `Unsupported Builder version \`${version}\` from "${builderPkg.name}"`
10132
- );
10133
- }
10134
- function isEdgeFunction(v) {
10135
- return v?.type === "EdgeFunction";
10136
- }
10137
- function isContainerImage(value) {
10138
- return typeof value === "object" && value !== null && "runtime" in value && value.runtime === "container";
10139
- }
10140
- function isLambda(v) {
10141
- return v?.type === "Lambda";
10142
- }
10143
- function isPrerender(v) {
10144
- return v?.type === "Prerender";
10145
- }
10146
- function isFile(v) {
10147
- const type = v?.type;
10148
- return type === "FileRef" || type === "FileFsRef" || type === "FileBlob";
10149
- }
10150
- function injectServiceEnvVars(fn, service, stripServiceRoutePrefix = false) {
10151
- const target = fn.config ?? fn;
10152
- target.environment ??= {};
10153
- if (service?.name) {
10154
- target.environment.VERCEL_SERVICE_NAME = service.name;
10155
- }
10156
- if (service?.type) {
10157
- target.environment.VERCEL_SERVICE_TYPE = service.type;
10158
- }
10159
- if (service?.trigger) {
10160
- target.environment.VERCEL_SERVICE_TRIGGER = service.trigger;
10161
- }
10162
- if (service?.routePrefix && service.routePrefix !== "/") {
10163
- target.environment.VERCEL_SERVICE_ROUTE_PREFIX = service.routePrefix;
10164
- }
10165
- if (stripServiceRoutePrefix) {
10166
- target.environment.VERCEL_SERVICE_ROUTE_PREFIX_STRIP = "1";
10167
- }
10168
- }
10169
- function stripDuplicateSlashes(path2) {
10170
- return normalize(path2).replace(/(^\/|\/$)/g, "");
10171
- }
10172
- async function resolveFunctionConfiguration(src, vercelConfig, service) {
10173
- if (service && isExperimentalServiceV2(service) && service.functions) {
10174
- let sourceFile = src;
10175
- const serviceRoot = stripDuplicateSlashes(service.root);
10176
- if (serviceRoot && serviceRoot !== ".") {
10177
- const prefix = `${serviceRoot}/`;
10178
- if (sourceFile.startsWith(prefix)) {
10179
- sourceFile = sourceFile.slice(prefix.length);
10180
- }
10181
- }
10182
- return getLambdaOptionsFromFunction({
10183
- sourceFile,
10184
- config: {
10185
- ...vercelConfig,
10186
- functions: service.functions,
10187
- serviceName: service.name
10103
+ // ../../internals/builder-orchestration/dist/write-build-result.js
10104
+ var require_write_build_result = __commonJS({
10105
+ "../../internals/builder-orchestration/dist/write-build-result.js"(exports, module) {
10106
+ "use strict";
10107
+ var __create = Object.create;
10108
+ var __defProp = Object.defineProperty;
10109
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
10110
+ var __getOwnPropNames = Object.getOwnPropertyNames;
10111
+ var __getProtoOf = Object.getPrototypeOf;
10112
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
10113
+ var __export = (target, all) => {
10114
+ for (var name in all)
10115
+ __defProp(target, name, { get: all[name], enumerable: true });
10116
+ };
10117
+ var __copyProps = (to, from, except, desc) => {
10118
+ if (from && typeof from === "object" || typeof from === "function") {
10119
+ for (let key of __getOwnPropNames(from))
10120
+ if (!__hasOwnProp.call(to, key) && key !== except)
10121
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
10188
10122
  }
10123
+ return to;
10124
+ };
10125
+ var __toESM2 = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
10126
+ // If the importer is in node compatibility mode or this is not an ESM
10127
+ // file that has been converted to a CommonJS file using a Babel-
10128
+ // compatible transform (i.e. "__esModule" has not been set), then set
10129
+ // "default" to the CommonJS "module.exports" for node compatibility.
10130
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
10131
+ mod
10132
+ ));
10133
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
10134
+ var write_build_result_exports = {};
10135
+ __export(write_build_result_exports, {
10136
+ OUTPUT_DIR: () => OUTPUT_DIR2,
10137
+ createWriteBuildResult: () => createWriteBuildResult2,
10138
+ filesWithoutFsRefs: () => filesWithoutFsRefs2,
10139
+ findDirs: () => findDirs2,
10140
+ isLambda: () => isLambda2,
10141
+ relocateRootBuildOutputToService: () => relocateRootBuildOutputToService2
10189
10142
  });
10190
- }
10191
- if (vercelConfig) {
10192
- return getLambdaOptionsFromFunction({
10193
- sourceFile: src,
10194
- config: vercelConfig
10195
- });
10196
- }
10197
- return {};
10198
- }
10199
- function getServiceOutputDir(outputDir, service) {
10200
- return join2(outputDir, "services", service.name);
10201
- }
10202
- async function writeBuildResultV2(args) {
10203
- const {
10204
- repoRootPath,
10205
- outputDir,
10206
- buildResult,
10207
- build,
10208
- vercelConfig,
10209
- standalone,
10210
- workPath,
10211
- service,
10212
- rootOutputDir,
10213
- stripServiceRoutePrefix
10214
- } = args;
10215
- if ("buildOutputPath" in buildResult) {
10216
- await mergeBuilderOutput(outputDir, buildResult, workPath, rootOutputDir);
10217
- return;
10218
- }
10219
- if (!buildResult.output) {
10220
- const configFile = vercelConfig?.[import_client.fileNameSymbol];
10221
- const updateMessage = build.use.startsWith("@now/") ? ` Please update from "@now" to "@vercel" in your \`${configFile}\` file.` : "";
10222
- throw new Error(
10223
- `The build result from "${build.use}" is missing the "output" property.${updateMessage}`
10224
- );
10225
- }
10226
- const existingFunctions = /* @__PURE__ */ new Map();
10227
- const overrides = {};
10228
- const functionConfiguration = build.src ? await resolveFunctionConfiguration(build.src, vercelConfig, service) : {};
10229
- for (const [path2, output] of Object.entries(buildResult.output)) {
10230
- const normalizedPath = stripDuplicateSlashes(path2);
10231
- if (isContainerImage(output)) {
10232
- injectServiceEnvVars(
10233
- output,
10234
- service && isExperimentalService(service) ? service : void 0,
10235
- stripServiceRoutePrefix
10236
- );
10237
- await writeContainerImage(
10238
- outputDir,
10239
- output,
10240
- normalizedPath,
10241
- functionConfiguration
10242
- );
10243
- } else if (isLambda(output)) {
10244
- injectServiceEnvVars(
10245
- output,
10246
- service && isExperimentalService(service) ? service : void 0,
10247
- stripServiceRoutePrefix
10248
- );
10249
- await writeLambda(
10143
+ module.exports = __toCommonJS(write_build_result_exports);
10144
+ var import_fs_extra = __toESM2(require_lib());
10145
+ var import_mime_types = __toESM2(require_mime_types());
10146
+ var import_path = __require("path");
10147
+ var import_build_utils = __require("@vercel/build-utils");
10148
+ var import_fs_detectors = require_dist3();
10149
+ var import_promisepipe = __toESM2(require_promisepipe());
10150
+ var import_merge = require_merge();
10151
+ var import_unzip = require_unzip();
10152
+ var import_client = require_dist2();
10153
+ var { normalize } = import_path.posix;
10154
+ var OUTPUT_DIR2 = (0, import_path.join)(".vercel", "output");
10155
+ function createWriteBuildResult2(output) {
10156
+ return {
10157
+ writeBuildResult: (args) => writeBuildResult2(args, output),
10158
+ relocateRootBuildOutputToService: relocateRootBuildOutputToService2,
10159
+ filesWithoutFsRefs: filesWithoutFsRefs2
10160
+ };
10161
+ }
10162
+ var BUILD_OUTPUT_API_ENTRIES = [
10163
+ "config.json",
10164
+ "functions",
10165
+ "routes",
10166
+ "static"
10167
+ ];
10168
+ async function writeBuildResult2(args, outputManager) {
10169
+ const {
10250
10170
  repoRootPath,
10251
10171
  outputDir,
10252
- output,
10253
- normalizedPath,
10254
- void 0,
10255
- existingFunctions,
10256
- standalone
10257
- );
10258
- } else if (isPrerender(output)) {
10259
- if (!output.lambda) {
10260
- throw new Error(
10261
- `Invalid Prerender with no "lambda" property: ${normalizedPath}`
10262
- );
10172
+ buildResult,
10173
+ build,
10174
+ builder,
10175
+ builderPkg,
10176
+ vercelConfig,
10177
+ standalone,
10178
+ workPath,
10179
+ service,
10180
+ nestServiceOutput = false,
10181
+ stripServiceRoutePrefix = false
10182
+ } = args;
10183
+ const writeOutputDir = service && nestServiceOutput ? getServiceOutputDir(outputDir, service) : outputDir;
10184
+ let version;
10185
+ let actualResult;
10186
+ if (builder.version === -1) {
10187
+ const vx = buildResult;
10188
+ version = vx.resultVersion;
10189
+ actualResult = vx.result;
10190
+ } else {
10191
+ version = builder.version;
10192
+ actualResult = buildResult;
10263
10193
  }
10264
- await writeLambda(
10265
- repoRootPath,
10266
- outputDir,
10267
- output.lambda,
10268
- normalizedPath,
10269
- void 0,
10270
- existingFunctions,
10271
- standalone
10194
+ if (typeof version !== "number" || version === 2) {
10195
+ return writeBuildResultV2({
10196
+ repoRootPath,
10197
+ outputDir: writeOutputDir,
10198
+ buildResult: actualResult,
10199
+ build,
10200
+ vercelConfig,
10201
+ standalone,
10202
+ workPath,
10203
+ service,
10204
+ rootOutputDir: outputDir,
10205
+ stripServiceRoutePrefix,
10206
+ outputManager
10207
+ });
10208
+ } else if (version === 3) {
10209
+ return writeBuildResultV3({
10210
+ repoRootPath,
10211
+ outputDir: writeOutputDir,
10212
+ buildResult: actualResult,
10213
+ build,
10214
+ vercelConfig,
10215
+ standalone,
10216
+ workPath,
10217
+ service,
10218
+ rootOutputDir: outputDir,
10219
+ stripServiceRoutePrefix,
10220
+ outputManager
10221
+ });
10222
+ }
10223
+ throw new Error(
10224
+ `Unsupported Builder version \`${version}\` from "${builderPkg.name}"`
10272
10225
  );
10273
- let fallback = output.fallback;
10274
- if (fallback) {
10275
- const ext = getFileExtension(fallback);
10276
- const fallbackName = `${normalizedPath}.prerender-fallback${ext}`;
10277
- const fallbackPath = join2(outputDir, "functions", fallbackName);
10278
- let usedHardLink = false;
10279
- if ("fsPath" in fallback) {
10280
- try {
10281
- await import_fs_extra2.default.link(fallback.fsPath, fallbackPath);
10282
- usedHardLink = true;
10283
- } catch (_) {
10226
+ }
10227
+ function isEdgeFunction(v) {
10228
+ return v?.type === "EdgeFunction";
10229
+ }
10230
+ function isContainerImage(value) {
10231
+ return typeof value === "object" && value !== null && "runtime" in value && value.runtime === "container";
10232
+ }
10233
+ function isLambda2(v) {
10234
+ return v?.type === "Lambda";
10235
+ }
10236
+ function isPrerender(v) {
10237
+ return v?.type === "Prerender";
10238
+ }
10239
+ function isFile(v) {
10240
+ const type = v?.type;
10241
+ return type === "FileRef" || type === "FileFsRef" || type === "FileBlob";
10242
+ }
10243
+ function injectServiceEnvVars(fn, service, stripServiceRoutePrefix = false) {
10244
+ const target = fn.config ?? fn;
10245
+ target.environment ??= {};
10246
+ if (service?.name) {
10247
+ target.environment.VERCEL_SERVICE_NAME = service.name;
10248
+ }
10249
+ if (service?.type) {
10250
+ target.environment.VERCEL_SERVICE_TYPE = service.type;
10251
+ }
10252
+ if (service?.trigger) {
10253
+ target.environment.VERCEL_SERVICE_TRIGGER = service.trigger;
10254
+ }
10255
+ if (service?.routePrefix && service.routePrefix !== "/") {
10256
+ target.environment.VERCEL_SERVICE_ROUTE_PREFIX = service.routePrefix;
10257
+ }
10258
+ if (stripServiceRoutePrefix) {
10259
+ target.environment.VERCEL_SERVICE_ROUTE_PREFIX_STRIP = "1";
10260
+ }
10261
+ }
10262
+ function stripDuplicateSlashes(path) {
10263
+ return normalize(path).replace(/(^\/|\/$)/g, "");
10264
+ }
10265
+ async function resolveFunctionConfiguration(src, vercelConfig, service) {
10266
+ if (service && (0, import_build_utils.isExperimentalServiceV2)(service) && service.functions) {
10267
+ let sourceFile = src;
10268
+ const serviceRoot = stripDuplicateSlashes(service.root);
10269
+ if (serviceRoot && serviceRoot !== ".") {
10270
+ const prefix = `${serviceRoot}/`;
10271
+ if (sourceFile.startsWith(prefix)) {
10272
+ sourceFile = sourceFile.slice(prefix.length);
10284
10273
  }
10285
10274
  }
10286
- if (!usedHardLink) {
10287
- const stream = fallback.toStream();
10288
- await (0, import_promisepipe2.default)(
10289
- stream,
10290
- import_fs_extra2.default.createWriteStream(fallbackPath, { mode: fallback.mode })
10291
- );
10292
- }
10293
- fallback = new FileFsRef({
10294
- ...output.fallback,
10295
- fsPath: basename(fallbackName)
10275
+ return (0, import_build_utils.getLambdaOptionsFromFunction)({
10276
+ sourceFile,
10277
+ config: {
10278
+ ...vercelConfig,
10279
+ functions: service.functions,
10280
+ serviceName: service.name
10281
+ }
10296
10282
  });
10297
10283
  }
10298
- const prerenderConfigPath = join2(
10299
- outputDir,
10300
- "functions",
10301
- `${normalizedPath}.prerender-config.json`
10302
- );
10303
- const prerenderConfig = {
10304
- ...output,
10305
- lambda: void 0,
10306
- fallback
10307
- };
10308
- await import_fs_extra2.default.writeJSON(prerenderConfigPath, prerenderConfig, { spaces: 2 });
10309
- } else if (isFile(output)) {
10310
- await writeStaticFile(
10284
+ if (vercelConfig) {
10285
+ return (0, import_build_utils.getLambdaOptionsFromFunction)({
10286
+ sourceFile: src,
10287
+ config: vercelConfig
10288
+ });
10289
+ }
10290
+ return {};
10291
+ }
10292
+ function getServiceOutputDir(outputDir, service) {
10293
+ return (0, import_path.join)(outputDir, "services", service.name);
10294
+ }
10295
+ async function relocateRootBuildOutputToService2(args) {
10296
+ const { outputDir, service, workPath } = args;
10297
+ await relocateBuildOutputApiEntries(
10311
10298
  outputDir,
10312
- output,
10313
- normalizedPath,
10314
- overrides,
10315
- vercelConfig?.cleanUrls
10299
+ getServiceOutputDir(outputDir, service),
10300
+ workPath
10316
10301
  );
10317
- } else if (isEdgeFunction(output)) {
10318
- await writeEdgeFunction(
10302
+ }
10303
+ async function writeBuildResultV2(args) {
10304
+ const {
10319
10305
  repoRootPath,
10320
10306
  outputDir,
10321
- output,
10322
- normalizedPath,
10323
- existingFunctions,
10324
- standalone
10325
- );
10326
- } else {
10327
- throw new Error(
10328
- `Unsupported output type: "${output.type}" for ${normalizedPath}`
10329
- );
10330
- }
10331
- }
10332
- return Object.keys(overrides).length > 0 ? overrides : void 0;
10333
- }
10334
- async function writeBuildResultV3(args) {
10335
- const {
10336
- repoRootPath,
10337
- outputDir,
10338
- buildResult,
10339
- build,
10340
- vercelConfig,
10341
- standalone,
10342
- workPath,
10343
- service,
10344
- rootOutputDir,
10345
- stripServiceRoutePrefix
10346
- } = args;
10347
- const { output } = buildResult;
10348
- const routesJsonPath = join2(workPath, ".vercel", "routes.json");
10349
- if (isBackendBuilder(build) || build.use === "@vercel/python") {
10350
- if ((0, import_fs_extra2.existsSync)(routesJsonPath)) {
10351
- try {
10352
- const newOutput = {
10353
- index: output
10354
- };
10355
- const routesJson = await import_fs_extra2.default.readJSON(routesJsonPath);
10356
- if (routesJson && typeof routesJson === "object" && "routes" in routesJson && Array.isArray(routesJson.routes)) {
10357
- for (const route of routesJson.routes) {
10358
- if (route.source === "/") {
10359
- continue;
10307
+ buildResult,
10308
+ build,
10309
+ vercelConfig,
10310
+ standalone,
10311
+ workPath,
10312
+ service,
10313
+ rootOutputDir,
10314
+ stripServiceRoutePrefix,
10315
+ outputManager
10316
+ } = args;
10317
+ if ("buildOutputPath" in buildResult) {
10318
+ await mergeBuilderOutput(
10319
+ outputDir,
10320
+ buildResult,
10321
+ workPath,
10322
+ rootOutputDir,
10323
+ outputManager
10324
+ );
10325
+ return;
10326
+ }
10327
+ if (!buildResult.output) {
10328
+ const configFile = vercelConfig?.[import_client.fileNameSymbol];
10329
+ const updateMessage = build.use.startsWith("@now/") ? ` Please update from "@now" to "@vercel" in your \`${configFile}\` file.` : "";
10330
+ throw new Error(
10331
+ `The build result from "${build.use}" is missing the "output" property.${updateMessage}`
10332
+ );
10333
+ }
10334
+ const existingFunctions = /* @__PURE__ */ new Map();
10335
+ const overrides = {};
10336
+ const functionConfiguration = build.src ? await resolveFunctionConfiguration(build.src, vercelConfig, service) : {};
10337
+ for (const [path, output] of Object.entries(buildResult.output)) {
10338
+ const normalizedPath = stripDuplicateSlashes(path);
10339
+ if (isContainerImage(output)) {
10340
+ injectServiceEnvVars(
10341
+ output,
10342
+ service && (0, import_build_utils.isExperimentalService)(service) ? service : void 0,
10343
+ stripServiceRoutePrefix
10344
+ );
10345
+ await writeContainerImage(
10346
+ outputDir,
10347
+ output,
10348
+ normalizedPath,
10349
+ functionConfiguration
10350
+ );
10351
+ } else if (isLambda2(output)) {
10352
+ injectServiceEnvVars(
10353
+ output,
10354
+ service && (0, import_build_utils.isExperimentalService)(service) ? service : void 0,
10355
+ stripServiceRoutePrefix
10356
+ );
10357
+ await writeLambda(
10358
+ repoRootPath,
10359
+ outputDir,
10360
+ output,
10361
+ normalizedPath,
10362
+ void 0,
10363
+ existingFunctions,
10364
+ standalone
10365
+ );
10366
+ } else if (isPrerender(output)) {
10367
+ if (!output.lambda) {
10368
+ throw new Error(
10369
+ `Invalid Prerender with no "lambda" property: ${normalizedPath}`
10370
+ );
10371
+ }
10372
+ await writeLambda(
10373
+ repoRootPath,
10374
+ outputDir,
10375
+ output.lambda,
10376
+ normalizedPath,
10377
+ void 0,
10378
+ existingFunctions,
10379
+ standalone
10380
+ );
10381
+ let fallback = output.fallback;
10382
+ if (fallback) {
10383
+ const ext = getFileExtension(fallback);
10384
+ const fallbackName = `${normalizedPath}.prerender-fallback${ext}`;
10385
+ const fallbackPath = (0, import_path.join)(outputDir, "functions", fallbackName);
10386
+ let usedHardLink = false;
10387
+ if ("fsPath" in fallback) {
10388
+ try {
10389
+ await import_fs_extra.default.link(fallback.fsPath, fallbackPath);
10390
+ usedHardLink = true;
10391
+ } catch (_) {
10392
+ }
10360
10393
  }
10361
- if (route.source) {
10362
- newOutput[route.source] = output;
10394
+ if (!usedHardLink) {
10395
+ const stream = fallback.toStream();
10396
+ await (0, import_promisepipe.default)(
10397
+ stream,
10398
+ import_fs_extra.default.createWriteStream(fallbackPath, { mode: fallback.mode })
10399
+ );
10363
10400
  }
10401
+ fallback = new import_build_utils.FileFsRef({
10402
+ ...output.fallback,
10403
+ fsPath: (0, import_path.basename)(fallbackName)
10404
+ });
10364
10405
  }
10406
+ const prerenderConfigPath = (0, import_path.join)(
10407
+ outputDir,
10408
+ "functions",
10409
+ `${normalizedPath}.prerender-config.json`
10410
+ );
10411
+ const prerenderConfig = {
10412
+ ...output,
10413
+ lambda: void 0,
10414
+ fallback
10415
+ };
10416
+ await import_fs_extra.default.writeJSON(prerenderConfigPath, prerenderConfig, { spaces: 2 });
10417
+ } else if (isFile(output)) {
10418
+ await writeStaticFile(
10419
+ outputDir,
10420
+ output,
10421
+ normalizedPath,
10422
+ overrides,
10423
+ vercelConfig?.cleanUrls
10424
+ );
10425
+ } else if (isEdgeFunction(output)) {
10426
+ await writeEdgeFunction(
10427
+ repoRootPath,
10428
+ outputDir,
10429
+ output,
10430
+ normalizedPath,
10431
+ existingFunctions,
10432
+ standalone
10433
+ );
10434
+ } else {
10435
+ throw new Error(
10436
+ `Unsupported output type: "${output.type}" for ${normalizedPath}`
10437
+ );
10365
10438
  }
10366
- return writeBuildResultV2({
10367
- repoRootPath,
10368
- outputDir,
10369
- buildResult: { output: newOutput, routes: buildResult.routes },
10370
- build,
10371
- vercelConfig,
10372
- standalone,
10373
- workPath,
10374
- service,
10375
- rootOutputDir,
10376
- stripServiceRoutePrefix
10377
- });
10378
- } catch (error) {
10379
- output_manager_default.error(`Failed to read routes.json: ${error}`);
10380
10439
  }
10440
+ return Object.keys(overrides).length > 0 ? overrides : void 0;
10381
10441
  }
10382
- if (isBackendBuilder(build) && isExperimentalBackendsEnabled() && "routes" in buildResult) {
10383
- return writeBuildResultV2({
10442
+ async function writeBuildResultV3(args) {
10443
+ const {
10384
10444
  repoRootPath,
10385
10445
  outputDir,
10386
10446
  buildResult,
@@ -10390,502 +10450,613 @@ async function writeBuildResultV3(args) {
10390
10450
  workPath,
10391
10451
  service,
10392
10452
  rootOutputDir,
10393
- stripServiceRoutePrefix
10394
- });
10395
- }
10396
- }
10397
- const src = build.src;
10398
- if (typeof src !== "string") {
10399
- throw new Error(`Expected "build.src" to be a string`);
10400
- }
10401
- const functionConfiguration = await resolveFunctionConfiguration(
10402
- src,
10403
- vercelConfig,
10404
- service
10405
- );
10406
- const ext = extname(src);
10407
- const path2 = service && isExperimentalServiceV2(service) ? "index" : service && typeof service.runtime === "string" ? stripDuplicateSlashes((0, import_fs_detectors.getInternalServiceFunctionPath)(service.name)) : stripDuplicateSlashes(
10408
- build.config?.zeroConfig ? src.substring(0, src.length - ext.length) : src
10409
- );
10410
- if (isContainerImage(output)) {
10411
- injectServiceEnvVars(
10412
- output,
10413
- service && isExperimentalService(service) ? service : void 0,
10414
- stripServiceRoutePrefix
10415
- );
10416
- await writeContainerImage(outputDir, output, path2, functionConfiguration);
10417
- } else if (isLambda(output)) {
10418
- injectServiceEnvVars(
10419
- output,
10420
- service && isExperimentalService(service) ? service : void 0,
10421
- stripServiceRoutePrefix
10422
- );
10423
- await writeLambda(
10424
- repoRootPath,
10425
- outputDir,
10426
- output,
10427
- path2,
10428
- functionConfiguration,
10429
- void 0,
10430
- standalone
10431
- );
10432
- } else if (isEdgeFunction(output)) {
10433
- await writeEdgeFunction(
10434
- repoRootPath,
10435
- outputDir,
10436
- output,
10437
- path2,
10438
- void 0,
10439
- standalone
10440
- );
10441
- } else {
10442
- throw new Error(
10443
- `Unsupported output type: "${output.type}" for ${build.src}`
10444
- );
10445
- }
10446
- }
10447
- async function writeStaticFile(outputDir, file, path2, overrides, cleanUrls = false) {
10448
- let fsPath = path2;
10449
- let override = null;
10450
- const ext = getFileExtension(file);
10451
- if (ext && extname(path2) !== ext) {
10452
- fsPath += ext;
10453
- if (!override)
10454
- override = {};
10455
- override.path = path2;
10456
- }
10457
- if (cleanUrls && path2.endsWith(".html")) {
10458
- if (!override)
10459
- override = {};
10460
- override.path = path2.slice(0, -5);
10461
- }
10462
- if (file.contentType) {
10463
- if (!override)
10464
- override = {};
10465
- override.contentType = file.contentType;
10466
- }
10467
- if (override) {
10468
- overrides[fsPath] = override;
10469
- }
10470
- const dest = join2(outputDir, "static", fsPath);
10471
- await import_fs_extra2.default.mkdirp(dirname(dest));
10472
- if ("fsPath" in file) {
10473
- if (resolve(file.fsPath) === resolve(dest)) {
10474
- return;
10475
- }
10476
- try {
10477
- return await import_fs_extra2.default.link(file.fsPath, dest);
10478
- } catch (_) {
10453
+ stripServiceRoutePrefix,
10454
+ outputManager
10455
+ } = args;
10456
+ const { output } = buildResult;
10457
+ const routesJsonPath = (0, import_path.join)(workPath, ".vercel", "routes.json");
10458
+ if ((0, import_build_utils.isBackendBuilder)(build) || build.use === "@vercel/python") {
10459
+ if ((0, import_fs_extra.existsSync)(routesJsonPath)) {
10460
+ try {
10461
+ const newOutput = {
10462
+ index: output
10463
+ };
10464
+ const routesJson = await import_fs_extra.default.readJSON(routesJsonPath);
10465
+ if (routesJson && typeof routesJson === "object" && "routes" in routesJson && Array.isArray(routesJson.routes)) {
10466
+ for (const route of routesJson.routes) {
10467
+ if (route.source === "/") {
10468
+ continue;
10469
+ }
10470
+ if (route.source) {
10471
+ newOutput[route.source] = output;
10472
+ }
10473
+ }
10474
+ }
10475
+ return writeBuildResultV2({
10476
+ repoRootPath,
10477
+ outputDir,
10478
+ buildResult: { output: newOutput, routes: buildResult.routes },
10479
+ build,
10480
+ vercelConfig,
10481
+ standalone,
10482
+ workPath,
10483
+ service,
10484
+ rootOutputDir,
10485
+ stripServiceRoutePrefix,
10486
+ outputManager
10487
+ });
10488
+ } catch (error) {
10489
+ outputManager.error(`Failed to read routes.json: ${error}`);
10490
+ }
10491
+ }
10492
+ if ((0, import_build_utils.isBackendBuilder)(build) && (0, import_build_utils.isExperimentalBackendsEnabled)() && "routes" in buildResult) {
10493
+ return writeBuildResultV2({
10494
+ repoRootPath,
10495
+ outputDir,
10496
+ buildResult,
10497
+ build,
10498
+ vercelConfig,
10499
+ standalone,
10500
+ workPath,
10501
+ service,
10502
+ rootOutputDir,
10503
+ stripServiceRoutePrefix,
10504
+ outputManager
10505
+ });
10506
+ }
10507
+ }
10508
+ const src = build.src;
10509
+ if (typeof src !== "string") {
10510
+ throw new Error(`Expected "build.src" to be a string`);
10511
+ }
10512
+ const functionConfiguration = await resolveFunctionConfiguration(
10513
+ src,
10514
+ vercelConfig,
10515
+ service
10516
+ );
10517
+ const ext = (0, import_path.extname)(src);
10518
+ const path = service && (0, import_build_utils.isExperimentalServiceV2)(service) ? "index" : service && typeof service.runtime === "string" ? stripDuplicateSlashes((0, import_fs_detectors.getInternalServiceFunctionPath)(service.name)) : stripDuplicateSlashes(
10519
+ build.config?.zeroConfig ? src.substring(0, src.length - ext.length) : src
10520
+ );
10521
+ if (isContainerImage(output)) {
10522
+ injectServiceEnvVars(
10523
+ output,
10524
+ service && (0, import_build_utils.isExperimentalService)(service) ? service : void 0,
10525
+ stripServiceRoutePrefix
10526
+ );
10527
+ await writeContainerImage(outputDir, output, path, functionConfiguration);
10528
+ } else if (isLambda2(output)) {
10529
+ injectServiceEnvVars(
10530
+ output,
10531
+ service && (0, import_build_utils.isExperimentalService)(service) ? service : void 0,
10532
+ stripServiceRoutePrefix
10533
+ );
10534
+ await writeLambda(
10535
+ repoRootPath,
10536
+ outputDir,
10537
+ output,
10538
+ path,
10539
+ functionConfiguration,
10540
+ void 0,
10541
+ standalone
10542
+ );
10543
+ } else if (isEdgeFunction(output)) {
10544
+ await writeEdgeFunction(
10545
+ repoRootPath,
10546
+ outputDir,
10547
+ output,
10548
+ path,
10549
+ void 0,
10550
+ standalone
10551
+ );
10552
+ } else {
10553
+ throw new Error(
10554
+ `Unsupported output type: "${output.type}" for ${build.src}`
10555
+ );
10556
+ }
10479
10557
  }
10480
- }
10481
- await downloadFile(file, dest);
10482
- }
10483
- async function writeFunctionSymlink(outputDir, dest, fn, existingFunctions) {
10484
- const existingPath = existingFunctions.get(fn);
10485
- if (!existingPath)
10486
- return false;
10487
- const destDir = dirname(dest);
10488
- const targetDest = join2(outputDir, "functions", `${existingPath}.func`);
10489
- const target = relative2(destDir, targetDest);
10490
- await import_fs_extra2.default.mkdirp(destDir);
10491
- await import_fs_extra2.default.symlink(target, dest);
10492
- return true;
10493
- }
10494
- async function writeContainerImage(outputDir, containerImage, path2, functionConfiguration) {
10495
- const dest = join2(outputDir, "functions", `${path2}.func`);
10496
- const handler = containerImage.handler;
10497
- if (typeof handler !== "string" || handler.length === 0) {
10498
- throw new Error(
10499
- `Container image output for "${path2}" is missing "handler".`
10500
- );
10501
- }
10502
- const architecture = functionConfiguration?.architecture ?? containerImage.architecture;
10503
- const memory = functionConfiguration?.memory ?? containerImage.memory;
10504
- const maxDuration = functionConfiguration?.maxDuration ?? containerImage.maxDuration;
10505
- const maxConcurrency = functionConfiguration?.maxConcurrency ?? containerImage.maxConcurrency;
10506
- const regions = functionConfiguration?.regions ?? containerImage.regions;
10507
- const functionFailoverRegions = functionConfiguration?.functionFailoverRegions ?? containerImage.functionFailoverRegions;
10508
- const experimentalTriggers = functionConfiguration?.experimentalTriggers ?? containerImage.experimentalTriggers;
10509
- const supportsCancellation = functionConfiguration?.supportsCancellation ?? containerImage.supportsCancellation;
10510
- await import_fs_extra2.default.mkdirp(dest);
10511
- await import_fs_extra2.default.writeJSON(
10512
- join2(dest, ".vc-config.json"),
10513
- {
10514
- handler,
10515
- runtime: "container",
10516
- environment: containerImage.environment ?? {},
10517
- ...containerImage.command ? { command: containerImage.command } : {},
10518
- ...architecture !== void 0 ? { architecture } : {},
10519
- ...memory !== void 0 ? { memory } : {},
10520
- ...maxDuration !== void 0 ? { maxDuration } : {},
10521
- ...maxConcurrency !== void 0 ? { maxConcurrency } : {},
10522
- ...regions !== void 0 ? { regions } : {},
10523
- ...functionFailoverRegions !== void 0 ? { functionFailoverRegions } : {},
10524
- ...experimentalTriggers !== void 0 ? { experimentalTriggers } : {},
10525
- ...supportsCancellation !== void 0 ? { supportsCancellation } : {}
10526
- },
10527
- { spaces: 2 }
10528
- );
10529
- }
10530
- async function writeEdgeFunction(repoRootPath, outputDir, edgeFunction, path2, existingFunctions, standalone = false) {
10531
- const dest = join2(outputDir, "functions", `${path2}.func`);
10532
- if (existingFunctions) {
10533
- if (await writeFunctionSymlink(
10534
- outputDir,
10535
- dest,
10536
- edgeFunction,
10537
- existingFunctions
10538
- )) {
10539
- return;
10558
+ async function writeStaticFile(outputDir, file, path, overrides, cleanUrls = false) {
10559
+ let fsPath = path;
10560
+ let override = null;
10561
+ const ext = getFileExtension(file);
10562
+ if (ext && (0, import_path.extname)(path) !== ext) {
10563
+ fsPath += ext;
10564
+ if (!override)
10565
+ override = {};
10566
+ override.path = path;
10567
+ }
10568
+ if (cleanUrls && path.endsWith(".html")) {
10569
+ if (!override)
10570
+ override = {};
10571
+ override.path = path.slice(0, -5);
10572
+ }
10573
+ if (file.contentType) {
10574
+ if (!override)
10575
+ override = {};
10576
+ override.contentType = file.contentType;
10577
+ }
10578
+ if (override) {
10579
+ overrides[fsPath] = override;
10580
+ }
10581
+ const dest = (0, import_path.join)(outputDir, "static", fsPath);
10582
+ await import_fs_extra.default.mkdirp((0, import_path.dirname)(dest));
10583
+ if ("fsPath" in file) {
10584
+ if ((0, import_path.resolve)(file.fsPath) === (0, import_path.resolve)(dest)) {
10585
+ return;
10586
+ }
10587
+ try {
10588
+ return await import_fs_extra.default.link(file.fsPath, dest);
10589
+ } catch (_) {
10590
+ }
10591
+ }
10592
+ await (0, import_build_utils.downloadFile)(file, dest);
10540
10593
  }
10541
- existingFunctions.set(edgeFunction, path2);
10542
- }
10543
- await import_fs_extra2.default.mkdirp(dest);
10544
- const ops = [];
10545
- const { files, filePathMap } = filesWithoutFsRefs(
10546
- edgeFunction.files,
10547
- repoRootPath,
10548
- standalone
10549
- );
10550
- ops.push(download(files, dest));
10551
- const config = {
10552
- runtime: "edge",
10553
- ...edgeFunction,
10554
- entrypoint: normalizePath(edgeFunction.entrypoint),
10555
- filePathMap,
10556
- files: void 0,
10557
- type: void 0
10558
- };
10559
- const configPath = join2(dest, ".vc-config.json");
10560
- ops.push(
10561
- import_fs_extra2.default.writeJSON(configPath, config, {
10562
- spaces: 2
10563
- })
10564
- );
10565
- await Promise.all(ops);
10566
- }
10567
- async function writeLambda(repoRootPath, outputDir, lambda, path2, functionConfiguration, existingFunctions, standalone = false) {
10568
- const dest = join2(outputDir, "functions", `${path2}.func`);
10569
- if (existingFunctions) {
10570
- if (await writeFunctionSymlink(outputDir, dest, lambda, existingFunctions)) {
10571
- return;
10594
+ async function writeFunctionSymlink(outputDir, dest, fn, existingFunctions) {
10595
+ const existingPath = existingFunctions.get(fn);
10596
+ if (!existingPath)
10597
+ return false;
10598
+ const destDir = (0, import_path.dirname)(dest);
10599
+ const targetDest = (0, import_path.join)(outputDir, "functions", `${existingPath}.func`);
10600
+ const target = (0, import_path.relative)(destDir, targetDest);
10601
+ await import_fs_extra.default.mkdirp(destDir);
10602
+ await import_fs_extra.default.symlink(target, dest);
10603
+ return true;
10572
10604
  }
10573
- existingFunctions.set(lambda, path2);
10574
- }
10575
- await import_fs_extra2.default.mkdirp(dest);
10576
- const ops = [];
10577
- let filePathMap;
10578
- if (lambda.files) {
10579
- const f = filesWithoutFsRefs(lambda.files, repoRootPath, standalone);
10580
- filePathMap = f.filePathMap;
10581
- ops.push(download(f.files, dest));
10582
- } else if (lambda.zipBuffer) {
10583
- ops.push(unzip(lambda.zipBuffer, dest));
10584
- } else {
10585
- throw new Error('Malformed `Lambda` - no "files" present');
10586
- }
10587
- const architecture = functionConfiguration?.architecture ?? lambda.architecture;
10588
- const memory = functionConfiguration?.memory ?? lambda.memory;
10589
- const maxDuration = functionConfiguration?.maxDuration ?? lambda.maxDuration;
10590
- const maxConcurrency = functionConfiguration?.maxConcurrency ?? lambda.maxConcurrency;
10591
- const regions = functionConfiguration?.regions ?? lambda.regions;
10592
- const functionFailoverRegions = functionConfiguration?.functionFailoverRegions ?? lambda.functionFailoverRegions;
10593
- const experimentalTriggers = functionConfiguration?.experimentalTriggers ?? lambda.experimentalTriggers;
10594
- const supportsCancellation = functionConfiguration?.supportsCancellation ?? lambda.supportsCancellation;
10595
- const config = {
10596
- ...lambda,
10597
- handler: normalizePath(lambda.handler),
10598
- architecture,
10599
- memory,
10600
- maxDuration,
10601
- maxConcurrency,
10602
- regions,
10603
- functionFailoverRegions,
10604
- experimentalTriggers,
10605
- supportsCancellation,
10606
- filePathMap,
10607
- type: void 0,
10608
- files: void 0,
10609
- zipBuffer: void 0
10610
- };
10611
- const configPath = join2(dest, ".vc-config.json");
10612
- ops.push(
10613
- import_fs_extra2.default.writeJSON(configPath, config, {
10614
- spaces: 2
10615
- })
10616
- );
10617
- await Promise.all(ops);
10618
- for await (const dir of findDirs(".vercel", dest)) {
10619
- const absDir = join2(dest, dir);
10620
- const entries = await import_fs_extra2.default.readdir(absDir);
10621
- if (entries.includes("cache")) {
10622
- await Promise.all(
10623
- entries.filter((e) => e !== "cache").map((entry) => import_fs_extra2.default.remove(join2(absDir, entry)))
10605
+ async function writeContainerImage(outputDir, containerImage, path, functionConfiguration) {
10606
+ const dest = (0, import_path.join)(outputDir, "functions", `${path}.func`);
10607
+ const handler = containerImage.handler;
10608
+ if (typeof handler !== "string" || handler.length === 0) {
10609
+ throw new Error(
10610
+ `Container image output for "${path}" is missing "handler".`
10611
+ );
10612
+ }
10613
+ const architecture = functionConfiguration?.architecture ?? containerImage.architecture;
10614
+ const memory = functionConfiguration?.memory ?? containerImage.memory;
10615
+ const maxDuration = functionConfiguration?.maxDuration ?? containerImage.maxDuration;
10616
+ const maxConcurrency = functionConfiguration?.maxConcurrency ?? containerImage.maxConcurrency;
10617
+ const regions = functionConfiguration?.regions ?? containerImage.regions;
10618
+ const functionFailoverRegions = functionConfiguration?.functionFailoverRegions ?? containerImage.functionFailoverRegions;
10619
+ const experimentalTriggers = functionConfiguration?.experimentalTriggers ?? containerImage.experimentalTriggers;
10620
+ const supportsCancellation = functionConfiguration?.supportsCancellation ?? containerImage.supportsCancellation;
10621
+ await import_fs_extra.default.mkdirp(dest);
10622
+ await import_fs_extra.default.writeJSON(
10623
+ (0, import_path.join)(dest, ".vc-config.json"),
10624
+ {
10625
+ handler,
10626
+ runtime: "container",
10627
+ environment: containerImage.environment ?? {},
10628
+ ...containerImage.command ? { command: containerImage.command } : {},
10629
+ ...architecture !== void 0 ? { architecture } : {},
10630
+ ...memory !== void 0 ? { memory } : {},
10631
+ ...maxDuration !== void 0 ? { maxDuration } : {},
10632
+ ...maxConcurrency !== void 0 ? { maxConcurrency } : {},
10633
+ ...regions !== void 0 ? { regions } : {},
10634
+ ...functionFailoverRegions !== void 0 ? { functionFailoverRegions } : {},
10635
+ ...experimentalTriggers !== void 0 ? { experimentalTriggers } : {},
10636
+ ...supportsCancellation !== void 0 ? { supportsCancellation } : {}
10637
+ },
10638
+ { spaces: 2 }
10624
10639
  );
10625
- } else {
10626
- await import_fs_extra2.default.remove(absDir);
10627
- }
10628
- }
10629
- }
10630
- async function mergeBuilderOutput(outputDir, buildResult, workPath, rootOutputDir) {
10631
- const absOutputDir = resolve(outputDir);
10632
- const absRootOutputDir = resolve(rootOutputDir);
10633
- const { ig } = await (0, import_client.getVercelIgnore)(workPath);
10634
- const filter = ig.createFilter();
10635
- if (absOutputDir === buildResult.buildOutputPath) {
10636
- const staticDir = join2(outputDir, "static");
10637
- try {
10638
- await cleanIgnoredFiles(staticDir, staticDir, filter);
10639
- } catch (err) {
10640
- if (err.code !== "ENOENT")
10641
- throw err;
10642
10640
  }
10643
- return;
10644
- }
10645
- if (resolve(buildResult.buildOutputPath) === absRootOutputDir) {
10646
- await relocateBuildOutputApiEntries(rootOutputDir, outputDir, workPath);
10647
- return;
10648
- }
10649
- const ignoreFilter = (path2) => {
10650
- const normalizedPath = path2.replace(/\\/g, "/");
10651
- if (normalizedPath.startsWith("static/")) {
10652
- return filter(normalizedPath.substring("static/".length));
10641
+ async function writeEdgeFunction(repoRootPath, outputDir, edgeFunction, path, existingFunctions, standalone = false) {
10642
+ const dest = (0, import_path.join)(outputDir, "functions", `${path}.func`);
10643
+ if (existingFunctions) {
10644
+ if (await writeFunctionSymlink(
10645
+ outputDir,
10646
+ dest,
10647
+ edgeFunction,
10648
+ existingFunctions
10649
+ )) {
10650
+ return;
10651
+ }
10652
+ existingFunctions.set(edgeFunction, path);
10653
+ }
10654
+ await import_fs_extra.default.mkdirp(dest);
10655
+ const ops = [];
10656
+ const { files, filePathMap } = filesWithoutFsRefs2(
10657
+ edgeFunction.files,
10658
+ repoRootPath,
10659
+ standalone
10660
+ );
10661
+ ops.push((0, import_build_utils.download)(files, dest));
10662
+ const config = {
10663
+ runtime: "edge",
10664
+ ...edgeFunction,
10665
+ entrypoint: (0, import_build_utils.normalizePath)(edgeFunction.entrypoint),
10666
+ filePathMap,
10667
+ files: void 0,
10668
+ type: void 0
10669
+ };
10670
+ const configPath = (0, import_path.join)(dest, ".vc-config.json");
10671
+ ops.push(
10672
+ import_fs_extra.default.writeJSON(configPath, config, {
10673
+ spaces: 2
10674
+ })
10675
+ );
10676
+ await Promise.all(ops);
10653
10677
  }
10654
- return true;
10655
- };
10656
- await merge(buildResult.buildOutputPath, outputDir, ignoreFilter);
10657
- }
10658
- async function relocateBuildOutputApiEntries(rootOutputDir, outputDir, workPath) {
10659
- const { ig } = await (0, import_client.getVercelIgnore)(workPath);
10660
- const filter = ig.createFilter();
10661
- await import_fs_extra2.default.mkdirp(outputDir);
10662
- await Promise.all(
10663
- BUILD_OUTPUT_API_ENTRIES.map(async (entry) => {
10664
- const src = join2(rootOutputDir, entry);
10665
- if (!await import_fs_extra2.default.pathExists(src))
10666
- return;
10667
- const dest = join2(outputDir, entry);
10668
- if (entry === "static") {
10669
- await merge(src, dest, (path2) => filter(path2));
10678
+ async function writeLambda(repoRootPath, outputDir, lambda, path, functionConfiguration, existingFunctions, standalone = false) {
10679
+ const dest = (0, import_path.join)(outputDir, "functions", `${path}.func`);
10680
+ if (existingFunctions) {
10681
+ if (await writeFunctionSymlink(outputDir, dest, lambda, existingFunctions)) {
10682
+ return;
10683
+ }
10684
+ existingFunctions.set(lambda, path);
10685
+ }
10686
+ await import_fs_extra.default.mkdirp(dest);
10687
+ const ops = [];
10688
+ let filePathMap;
10689
+ if (lambda.files) {
10690
+ const f = filesWithoutFsRefs2(lambda.files, repoRootPath, standalone);
10691
+ filePathMap = f.filePathMap;
10692
+ ops.push((0, import_build_utils.download)(f.files, dest));
10693
+ } else if (lambda.zipBuffer) {
10694
+ ops.push((0, import_unzip.unzip)(lambda.zipBuffer, dest));
10670
10695
  } else {
10671
- await merge(src, dest);
10696
+ throw new Error('Malformed `Lambda` - no "files" present');
10672
10697
  }
10673
- })
10674
- );
10675
- }
10676
- async function cleanIgnoredFiles(dir, staticRoot, filter) {
10677
- const entries = await import_fs_extra2.default.readdir(dir);
10678
- await Promise.all(
10679
- entries.map(async (entry) => {
10680
- const entryPath = join2(dir, entry);
10681
- const stat2 = await import_fs_extra2.default.stat(entryPath);
10682
- const relativePath = relative2(staticRoot, entryPath);
10683
- if (stat2.isDirectory()) {
10684
- await cleanIgnoredFiles(entryPath, staticRoot, filter);
10685
- const remaining = await import_fs_extra2.default.readdir(entryPath);
10686
- if (remaining.length === 0) {
10687
- await import_fs_extra2.default.rmdir(entryPath);
10698
+ const architecture = functionConfiguration?.architecture ?? lambda.architecture;
10699
+ const memory = functionConfiguration?.memory ?? lambda.memory;
10700
+ const maxDuration = functionConfiguration?.maxDuration ?? lambda.maxDuration;
10701
+ const maxConcurrency = functionConfiguration?.maxConcurrency ?? lambda.maxConcurrency;
10702
+ const regions = functionConfiguration?.regions ?? lambda.regions;
10703
+ const functionFailoverRegions = functionConfiguration?.functionFailoverRegions ?? lambda.functionFailoverRegions;
10704
+ const experimentalTriggers = functionConfiguration?.experimentalTriggers ?? lambda.experimentalTriggers;
10705
+ const supportsCancellation = functionConfiguration?.supportsCancellation ?? lambda.supportsCancellation;
10706
+ const config = {
10707
+ ...lambda,
10708
+ handler: (0, import_build_utils.normalizePath)(lambda.handler),
10709
+ architecture,
10710
+ memory,
10711
+ maxDuration,
10712
+ maxConcurrency,
10713
+ regions,
10714
+ functionFailoverRegions,
10715
+ experimentalTriggers,
10716
+ supportsCancellation,
10717
+ filePathMap,
10718
+ type: void 0,
10719
+ files: void 0,
10720
+ zipBuffer: void 0
10721
+ };
10722
+ const configPath = (0, import_path.join)(dest, ".vc-config.json");
10723
+ ops.push(
10724
+ import_fs_extra.default.writeJSON(configPath, config, {
10725
+ spaces: 2
10726
+ })
10727
+ );
10728
+ await Promise.all(ops);
10729
+ for await (const dir of findDirs2(".vercel", dest)) {
10730
+ const absDir = (0, import_path.join)(dest, dir);
10731
+ const entries = await import_fs_extra.default.readdir(absDir);
10732
+ if (entries.includes("cache")) {
10733
+ await Promise.all(
10734
+ entries.filter((e) => e !== "cache").map((entry) => import_fs_extra.default.remove((0, import_path.join)(absDir, entry)))
10735
+ );
10736
+ } else {
10737
+ await import_fs_extra.default.remove(absDir);
10688
10738
  }
10689
- } else if (!filter(relativePath)) {
10690
- output_manager_default.debug(`Removing ignored file: ${relativePath}`);
10691
- await import_fs_extra2.default.remove(entryPath);
10692
10739
  }
10693
- })
10694
- );
10695
- }
10696
- function getFileExtension(file) {
10697
- let ext = "";
10698
- if (file.type === "FileFsRef") {
10699
- ext = extname(file.fsPath);
10700
- }
10701
- if (!ext && file.contentType) {
10702
- const e = import_mime_types.default.extension(file.contentType);
10703
- if (e) {
10704
- ext = `.${e}`;
10705
10740
  }
10706
- }
10707
- return ext;
10708
- }
10709
- async function* findDirs(name, dir, root = dir) {
10710
- let paths;
10711
- try {
10712
- paths = await import_fs_extra2.default.readdir(dir);
10713
- } catch (err) {
10714
- if (err.code !== "ENOENT") {
10715
- throw err;
10741
+ async function mergeBuilderOutput(outputDir, buildResult, workPath, rootOutputDir, outputManager) {
10742
+ const absOutputDir = (0, import_path.resolve)(outputDir);
10743
+ const absRootOutputDir = (0, import_path.resolve)(rootOutputDir);
10744
+ const { ig } = await (0, import_client.getVercelIgnore)(workPath);
10745
+ const filter = ig.createFilter();
10746
+ if (absOutputDir === buildResult.buildOutputPath) {
10747
+ const staticDir = (0, import_path.join)(outputDir, "static");
10748
+ try {
10749
+ await cleanIgnoredFiles(staticDir, staticDir, filter, outputManager);
10750
+ } catch (err) {
10751
+ if (err.code !== "ENOENT")
10752
+ throw err;
10753
+ }
10754
+ return;
10755
+ }
10756
+ if ((0, import_path.resolve)(buildResult.buildOutputPath) === absRootOutputDir) {
10757
+ await relocateBuildOutputApiEntries(rootOutputDir, outputDir, workPath);
10758
+ return;
10759
+ }
10760
+ const ignoreFilter = (path) => {
10761
+ const normalizedPath = path.replace(/\\/g, "/");
10762
+ if (normalizedPath.startsWith("static/")) {
10763
+ return filter(normalizedPath.substring("static/".length));
10764
+ }
10765
+ return true;
10766
+ };
10767
+ await (0, import_merge.merge)(buildResult.buildOutputPath, outputDir, ignoreFilter);
10716
10768
  }
10717
- paths = [];
10718
- }
10719
- for (const path2 of paths) {
10720
- const abs = join2(dir, path2);
10721
- let stat2;
10722
- try {
10723
- stat2 = await import_fs_extra2.default.lstat(abs);
10724
- } catch (err) {
10725
- if (err.code === "ENOENT")
10726
- continue;
10727
- throw err;
10769
+ async function relocateBuildOutputApiEntries(rootOutputDir, outputDir, workPath) {
10770
+ const { ig } = await (0, import_client.getVercelIgnore)(workPath);
10771
+ const filter = ig.createFilter();
10772
+ await import_fs_extra.default.mkdirp(outputDir);
10773
+ await Promise.all(
10774
+ BUILD_OUTPUT_API_ENTRIES.map(async (entry) => {
10775
+ const src = (0, import_path.join)(rootOutputDir, entry);
10776
+ if (!await import_fs_extra.default.pathExists(src))
10777
+ return;
10778
+ const dest = (0, import_path.join)(outputDir, entry);
10779
+ if (entry === "static") {
10780
+ await (0, import_merge.merge)(src, dest, (path) => filter(path));
10781
+ } else {
10782
+ await (0, import_merge.merge)(src, dest);
10783
+ }
10784
+ })
10785
+ );
10728
10786
  }
10729
- if (stat2.isDirectory()) {
10730
- if (path2 === name) {
10731
- yield relative2(root, abs);
10732
- } else {
10733
- yield* findDirs(name, abs, root);
10787
+ async function cleanIgnoredFiles(dir, staticRoot, filter, outputManager) {
10788
+ const entries = await import_fs_extra.default.readdir(dir);
10789
+ await Promise.all(
10790
+ entries.map(async (entry) => {
10791
+ const entryPath = (0, import_path.join)(dir, entry);
10792
+ const stat = await import_fs_extra.default.stat(entryPath);
10793
+ const relativePath = (0, import_path.relative)(staticRoot, entryPath);
10794
+ if (stat.isDirectory()) {
10795
+ await cleanIgnoredFiles(entryPath, staticRoot, filter, outputManager);
10796
+ const remaining = await import_fs_extra.default.readdir(entryPath);
10797
+ if (remaining.length === 0) {
10798
+ await import_fs_extra.default.rmdir(entryPath);
10799
+ }
10800
+ } else if (!filter(relativePath)) {
10801
+ outputManager.debug(`Removing ignored file: ${relativePath}`);
10802
+ await import_fs_extra.default.remove(entryPath);
10803
+ }
10804
+ })
10805
+ );
10806
+ }
10807
+ function getFileExtension(file) {
10808
+ let ext = "";
10809
+ if (file.type === "FileFsRef") {
10810
+ ext = (0, import_path.extname)(file.fsPath);
10811
+ }
10812
+ if (!ext && file.contentType) {
10813
+ const e = import_mime_types.default.extension(file.contentType);
10814
+ if (e) {
10815
+ ext = `.${e}`;
10816
+ }
10734
10817
  }
10818
+ return ext;
10735
10819
  }
10736
- }
10737
- }
10738
- function filesWithoutFsRefs(files, repoRootPath, standalone) {
10739
- const symlinkDirs = standalone ? Object.entries(files).filter(([, f]) => f.type === "FileFsRef" && isSymbolicLink(f.mode)).map(([p]) => `${normalizePath(p)}/`) : [];
10740
- let filePathMap;
10741
- const out = {};
10742
- for (const [path2, file] of Object.entries(files)) {
10743
- if (file.type === "FileFsRef") {
10744
- if (standalone) {
10745
- const normalized = normalizePath(path2);
10746
- if (symlinkDirs.some((prefix) => normalized.startsWith(prefix))) {
10747
- continue;
10820
+ async function* findDirs2(name, dir, root = dir) {
10821
+ let paths;
10822
+ try {
10823
+ paths = await import_fs_extra.default.readdir(dir);
10824
+ } catch (err) {
10825
+ if (err.code !== "ENOENT") {
10826
+ throw err;
10827
+ }
10828
+ paths = [];
10829
+ }
10830
+ for (const path of paths) {
10831
+ const abs = (0, import_path.join)(dir, path);
10832
+ let stat;
10833
+ try {
10834
+ stat = await import_fs_extra.default.lstat(abs);
10835
+ } catch (err) {
10836
+ if (err.code === "ENOENT")
10837
+ continue;
10838
+ throw err;
10839
+ }
10840
+ if (stat.isDirectory()) {
10841
+ if (path === name) {
10842
+ yield (0, import_path.relative)(root, abs);
10843
+ } else {
10844
+ yield* findDirs2(name, abs, root);
10845
+ }
10748
10846
  }
10749
- out[normalized] = file;
10750
- } else {
10751
- if (!filePathMap)
10752
- filePathMap = {};
10753
- filePathMap[normalizePath(path2)] = normalizePath(
10754
- relative2(repoRootPath, file.fsPath)
10755
- );
10756
10847
  }
10757
- } else {
10758
- out[path2] = file;
10848
+ }
10849
+ function filesWithoutFsRefs2(files, repoRootPath, standalone) {
10850
+ const symlinkDirs = standalone ? Object.entries(files).filter(([, f]) => f.type === "FileFsRef" && (0, import_build_utils.isSymbolicLink)(f.mode)).map(([p]) => `${(0, import_build_utils.normalizePath)(p)}/`) : [];
10851
+ let filePathMap;
10852
+ const out = {};
10853
+ for (const [path, file] of Object.entries(files)) {
10854
+ if (file.type === "FileFsRef") {
10855
+ if (standalone) {
10856
+ const normalized = (0, import_build_utils.normalizePath)(path);
10857
+ if (symlinkDirs.some((prefix) => normalized.startsWith(prefix))) {
10858
+ continue;
10859
+ }
10860
+ out[normalized] = file;
10861
+ } else {
10862
+ if (!filePathMap)
10863
+ filePathMap = {};
10864
+ filePathMap[(0, import_build_utils.normalizePath)(path)] = (0, import_build_utils.normalizePath)(
10865
+ (0, import_path.relative)(repoRootPath, file.fsPath)
10866
+ );
10867
+ }
10868
+ } else {
10869
+ out[path] = file;
10870
+ }
10871
+ }
10872
+ return { files: out, filePathMap };
10759
10873
  }
10760
10874
  }
10761
- return { files: out, filePathMap };
10762
- }
10763
-
10764
- // src/util/get-files.ts
10765
- var import_fs_extra3 = __toESM(require_lib(), 1);
10766
- var import_client2 = __toESM(require_dist2(), 1);
10767
- import { resolve as resolve2 } from "path";
10768
-
10769
- // src/util/unique-strings.ts
10770
- var unique_strings_default = (arr) => {
10771
- const len = arr.length;
10772
- const res = [];
10773
- const o = {};
10774
- let i;
10775
- for (i = 0; i < len; i += 1) {
10776
- o[arr[i]] = o[arr[i]] || res.push(arr[i]);
10777
- }
10778
- return res;
10779
- };
10875
+ });
10780
10876
 
10781
- // src/util/get-files.ts
10782
- function flatten(arr, res = []) {
10783
- for (const cur of arr) {
10784
- if (Array.isArray(cur)) {
10785
- flatten(cur, res);
10786
- } else {
10787
- res.push(cur);
10877
+ // ../../internals/cli-builder-integration/dist/service-schedules.js
10878
+ var require_service_schedules = __commonJS({
10879
+ "../../internals/cli-builder-integration/dist/service-schedules.js"(exports, module) {
10880
+ "use strict";
10881
+ var __defProp = Object.defineProperty;
10882
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
10883
+ var __getOwnPropNames = Object.getOwnPropertyNames;
10884
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
10885
+ var __export = (target, all) => {
10886
+ for (var name in all)
10887
+ __defProp(target, name, { get: all[name], enumerable: true });
10888
+ };
10889
+ var __copyProps = (to, from, except, desc) => {
10890
+ if (from && typeof from === "object" || typeof from === "function") {
10891
+ for (let key of __getOwnPropNames(from))
10892
+ if (!__hasOwnProp.call(to, key) && key !== except)
10893
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
10894
+ }
10895
+ return to;
10896
+ };
10897
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
10898
+ var service_schedules_exports = {};
10899
+ __export(service_schedules_exports, {
10900
+ getStaticServiceSchedules: () => getStaticServiceSchedules
10901
+ });
10902
+ module.exports = __toCommonJS(service_schedules_exports);
10903
+ var DYNAMIC_SCHEDULE = "<dynamic>";
10904
+ function getStaticServiceSchedules(schedule) {
10905
+ if (!schedule || schedule === DYNAMIC_SCHEDULE) {
10906
+ return [];
10907
+ }
10908
+ return Array.isArray(schedule) ? schedule.filter((item) => item !== DYNAMIC_SCHEDULE) : [schedule];
10788
10909
  }
10789
10910
  }
10790
- return res;
10791
- }
10792
- var asAbsolute = function(path2, parent) {
10793
- if (path2[0] === "/") {
10794
- return path2;
10795
- }
10796
- return resolve2(parent, path2);
10797
- };
10798
- async function staticFiles(path2, { src }) {
10799
- const { debug, time } = output_manager_default;
10800
- let files = [];
10801
- const source = src || ".";
10802
- const search = resolve2(path2, source);
10803
- const { ig } = await (0, import_client2.getVercelIgnore)(path2);
10804
- const filter = ig.createFilter();
10805
- const prefixLength = path2.length + 1;
10806
- const accepts = (file) => {
10807
- const relativePath = file.slice(prefixLength);
10808
- if (relativePath === "") {
10809
- return true;
10810
- }
10811
- const accepted = filter(relativePath);
10812
- if (!accepted) {
10813
- debug(`Ignoring ${file}`);
10814
- }
10815
- return accepted;
10816
- };
10817
- files = await time(
10818
- `Locating files ${path2}`,
10819
- explode([search], {
10820
- accepts
10821
- })
10822
- );
10823
- return unique_strings_default(files);
10824
- }
10825
- async function explode(paths, { accepts }) {
10826
- const { debug } = output_manager_default;
10827
- const list = async (file) => {
10828
- let path2 = file;
10829
- let s;
10830
- if (!accepts(file)) {
10831
- return null;
10911
+ });
10912
+
10913
+ // ../../internals/cli-builder-integration/dist/get-files.js
10914
+ var require_get_files = __commonJS({
10915
+ "../../internals/cli-builder-integration/dist/get-files.js"(exports, module) {
10916
+ "use strict";
10917
+ var __create = Object.create;
10918
+ var __defProp = Object.defineProperty;
10919
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
10920
+ var __getOwnPropNames = Object.getOwnPropertyNames;
10921
+ var __getProtoOf = Object.getPrototypeOf;
10922
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
10923
+ var __export = (target, all) => {
10924
+ for (var name in all)
10925
+ __defProp(target, name, { get: all[name], enumerable: true });
10926
+ };
10927
+ var __copyProps = (to, from, except, desc) => {
10928
+ if (from && typeof from === "object" || typeof from === "function") {
10929
+ for (let key of __getOwnPropNames(from))
10930
+ if (!__hasOwnProp.call(to, key) && key !== except)
10931
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
10932
+ }
10933
+ return to;
10934
+ };
10935
+ var __toESM2 = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
10936
+ // If the importer is in node compatibility mode or this is not an ESM
10937
+ // file that has been converted to a CommonJS file using a Babel-
10938
+ // compatible transform (i.e. "__esModule" has not been set), then set
10939
+ // "default" to the CommonJS "module.exports" for node compatibility.
10940
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
10941
+ mod
10942
+ ));
10943
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
10944
+ var get_files_exports = {};
10945
+ __export(get_files_exports, {
10946
+ staticFiles: () => staticFiles
10947
+ });
10948
+ module.exports = __toCommonJS(get_files_exports);
10949
+ var import_fs_extra = __toESM2(require_lib());
10950
+ var import_path = __require("path");
10951
+ var import_client = require_dist2();
10952
+ function flatten(arr, res = []) {
10953
+ for (const cur of arr) {
10954
+ if (Array.isArray(cur)) {
10955
+ flatten(cur, res);
10956
+ } else {
10957
+ res.push(cur);
10958
+ }
10959
+ }
10960
+ return res;
10832
10961
  }
10833
- try {
10834
- s = await import_fs_extra3.default.stat(path2);
10835
- } catch (_e) {
10836
- path2 = `${file}.js`;
10837
- try {
10838
- s = await import_fs_extra3.default.stat(path2);
10839
- } catch (_e2) {
10840
- debug(`Ignoring invalid file ${file}`);
10841
- return null;
10962
+ var asAbsolute = function(path, parent) {
10963
+ if (path[0] === "/") {
10964
+ return path;
10842
10965
  }
10966
+ return (0, import_path.resolve)(parent, path);
10967
+ };
10968
+ async function staticFiles(path, { src }, output) {
10969
+ const { debug, time } = output;
10970
+ let files = [];
10971
+ const source = src || ".";
10972
+ const search = (0, import_path.resolve)(path, source);
10973
+ const { ig } = await (0, import_client.getVercelIgnore)(path);
10974
+ const filter = ig.createFilter();
10975
+ const prefixLength = path.length + 1;
10976
+ const accepts = (file) => {
10977
+ const relativePath = file.slice(prefixLength);
10978
+ if (relativePath === "") {
10979
+ return true;
10980
+ }
10981
+ const accepted = filter(relativePath);
10982
+ if (!accepted) {
10983
+ debug(`Ignoring ${file}`);
10984
+ }
10985
+ return accepted;
10986
+ };
10987
+ files = await time(
10988
+ `Locating files ${path}`,
10989
+ explode([search], {
10990
+ accepts,
10991
+ output
10992
+ })
10993
+ );
10994
+ return Array.from(new Set(files));
10843
10995
  }
10844
- if (s.isDirectory()) {
10845
- let all;
10846
- try {
10847
- all = await import_fs_extra3.default.readdir(file);
10848
- } catch (err) {
10849
- const code = err instanceof Error && "code" in err ? err.code : void 0;
10850
- if (code === "ENOENT" || code === "ENOTDIR") {
10851
- debug(`Ignoring directory that has since been removed ${file}`);
10996
+ async function explode(paths, { accepts, output }) {
10997
+ const { debug } = output;
10998
+ const list = async (file) => {
10999
+ let path = file;
11000
+ let s;
11001
+ if (!accepts(file)) {
10852
11002
  return null;
10853
11003
  }
10854
- throw err;
10855
- }
10856
- const recursive = many(all.map((subdir) => asAbsolute(subdir, file)));
10857
- return recursive;
11004
+ try {
11005
+ s = await import_fs_extra.default.stat(path);
11006
+ } catch (_e) {
11007
+ path = `${file}.js`;
11008
+ try {
11009
+ s = await import_fs_extra.default.stat(path);
11010
+ } catch (_e2) {
11011
+ debug(`Ignoring invalid file ${file}`);
11012
+ return null;
11013
+ }
11014
+ }
11015
+ if (s.isDirectory()) {
11016
+ let all;
11017
+ try {
11018
+ all = await import_fs_extra.default.readdir(file);
11019
+ } catch (err) {
11020
+ const code = err instanceof Error && "code" in err ? err.code : void 0;
11021
+ if (code === "ENOENT" || code === "ENOTDIR") {
11022
+ debug(`Ignoring directory that has since been removed ${file}`);
11023
+ return null;
11024
+ }
11025
+ throw err;
11026
+ }
11027
+ return many(all.map((subdir) => asAbsolute(subdir, file)));
11028
+ }
11029
+ if (!s.isFile()) {
11030
+ debug(`Ignoring special file ${file}`);
11031
+ return null;
11032
+ }
11033
+ return path;
11034
+ };
11035
+ const many = (all) => Promise.all(all.map((file) => list(file)));
11036
+ const arrayOfArrays = await many(paths);
11037
+ return flatten(arrayOfArrays).filter(notNull);
10858
11038
  }
10859
- if (!s.isFile()) {
10860
- debug(`Ignoring special file ${file}`);
10861
- return null;
11039
+ function notNull(value) {
11040
+ return value !== null;
10862
11041
  }
10863
- return path2;
10864
- };
10865
- const many = (all) => Promise.all(all.map((file) => list(file)));
10866
- const arrayOfArrays = await many(paths);
10867
- return flatten(arrayOfArrays).filter(notNull);
10868
- }
10869
- function notNull(value) {
10870
- return value !== null;
10871
- }
10872
-
10873
- // src/util/service-schedules.ts
10874
- var DYNAMIC_SCHEDULE = "<dynamic>";
10875
- function getStaticServiceSchedules(schedule) {
10876
- if (!schedule || schedule === DYNAMIC_SCHEDULE) {
10877
- return [];
10878
11042
  }
10879
- return Array.isArray(schedule) ? schedule.filter((item) => item !== DYNAMIC_SCHEDULE) : [schedule];
10880
- }
11043
+ });
11044
+
11045
+ // src/builders/write-build-result.ts
11046
+ var import_write_build_result = __toESM(require_write_build_result(), 1);
11047
+ var {
11048
+ filesWithoutFsRefs,
11049
+ relocateRootBuildOutputToService,
11050
+ writeBuildResult
11051
+ } = (0, import_write_build_result.createWriteBuildResult)(output_manager_default);
10881
11052
 
10882
11053
  export {
10883
11054
  require_mime_types,
10884
- OUTPUT_DIR,
10885
- writeBuildResult,
10886
- isLambda,
10887
- staticFiles,
10888
- getStaticServiceSchedules
11055
+ require_write_build_result,
11056
+ require_service_schedules,
11057
+ require_get_files,
11058
+ import_write_build_result,
11059
+ writeBuildResult
10889
11060
  };
10890
11061
  /*! Bundled license information:
10891
11062