@vercel/ruby 2.2.0 → 2.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -174,8 +174,8 @@ var require_isexe = __commonJS({
174
174
  // ../../node_modules/.pnpm/which@1.3.1/node_modules/which/which.js
175
175
  var require_which = __commonJS({
176
176
  "../../node_modules/.pnpm/which@1.3.1/node_modules/which/which.js"(exports, module2) {
177
- module2.exports = which2;
178
- which2.sync = whichSync;
177
+ module2.exports = which3;
178
+ which3.sync = whichSync;
179
179
  var isWindows = process.platform === "win32" || process.env.OSTYPE === "cygwin" || process.env.OSTYPE === "msys";
180
180
  var path = require("path");
181
181
  var COLON = isWindows ? ";" : ":";
@@ -206,7 +206,7 @@ var require_which = __commonJS({
206
206
  extExe: pathExtExe
207
207
  };
208
208
  }
209
- function which2(cmd, opt, cb) {
209
+ function which3(cmd, opt, cb) {
210
210
  if (typeof opt === "function") {
211
211
  cb = opt;
212
212
  opt = {};
@@ -302,18 +302,17 @@ var require_path_key = __commonJS({
302
302
  }
303
303
  });
304
304
 
305
- // ../../node_modules/.pnpm/cross-spawn@6.0.6/node_modules/cross-spawn/lib/util/resolveCommand.js
305
+ // ../../node_modules/.pnpm/cross-spawn@6.0.5/node_modules/cross-spawn/lib/util/resolveCommand.js
306
306
  var require_resolveCommand = __commonJS({
307
- "../../node_modules/.pnpm/cross-spawn@6.0.6/node_modules/cross-spawn/lib/util/resolveCommand.js"(exports, module2) {
307
+ "../../node_modules/.pnpm/cross-spawn@6.0.5/node_modules/cross-spawn/lib/util/resolveCommand.js"(exports, module2) {
308
308
  "use strict";
309
309
  var path = require("path");
310
- var which2 = require_which();
310
+ var which3 = require_which();
311
311
  var pathKey = require_path_key()();
312
312
  function resolveCommandAttempt(parsed, withoutPathExt) {
313
313
  const cwd = process.cwd();
314
314
  const hasCustomCwd = parsed.options.cwd != null;
315
- const shouldSwitchCwd = hasCustomCwd && process.chdir !== void 0;
316
- if (shouldSwitchCwd) {
315
+ if (hasCustomCwd) {
317
316
  try {
318
317
  process.chdir(parsed.options.cwd);
319
318
  } catch (err) {
@@ -321,15 +320,13 @@ var require_resolveCommand = __commonJS({
321
320
  }
322
321
  let resolved;
323
322
  try {
324
- resolved = which2.sync(parsed.command, {
323
+ resolved = which3.sync(parsed.command, {
325
324
  path: (parsed.options.env || process.env)[pathKey],
326
325
  pathExt: withoutPathExt ? path.delimiter : void 0
327
326
  });
328
327
  } catch (e) {
329
328
  } finally {
330
- if (shouldSwitchCwd) {
331
- process.chdir(cwd);
332
- }
329
+ process.chdir(cwd);
333
330
  }
334
331
  if (resolved) {
335
332
  resolved = path.resolve(hasCustomCwd ? parsed.options.cwd : "", resolved);
@@ -343,9 +340,9 @@ var require_resolveCommand = __commonJS({
343
340
  }
344
341
  });
345
342
 
346
- // ../../node_modules/.pnpm/cross-spawn@6.0.6/node_modules/cross-spawn/lib/util/escape.js
343
+ // ../../node_modules/.pnpm/cross-spawn@6.0.5/node_modules/cross-spawn/lib/util/escape.js
347
344
  var require_escape = __commonJS({
348
- "../../node_modules/.pnpm/cross-spawn@6.0.6/node_modules/cross-spawn/lib/util/escape.js"(exports, module2) {
345
+ "../../node_modules/.pnpm/cross-spawn@6.0.5/node_modules/cross-spawn/lib/util/escape.js"(exports, module2) {
349
346
  "use strict";
350
347
  var metaCharsRegExp = /([()\][%!^"`<>&|;, *?])/g;
351
348
  function escapeCommand(arg) {
@@ -354,8 +351,8 @@ var require_escape = __commonJS({
354
351
  }
355
352
  function escapeArgument(arg, doubleEscapeMetaChars) {
356
353
  arg = `${arg}`;
357
- arg = arg.replace(/(?=(\\+?)?)\1"/g, '$1$1\\"');
358
- arg = arg.replace(/(?=(\\+?)?)\1$/, "$1$1");
354
+ arg = arg.replace(/(\\*)"/g, '$1$1\\"');
355
+ arg = arg.replace(/(\\*)$/, "$1$1");
359
356
  arg = `"${arg}"`;
360
357
  arg = arg.replace(metaCharsRegExp, "^$1");
361
358
  if (doubleEscapeMetaChars) {
@@ -394,9 +391,9 @@ var require_shebang_command = __commonJS({
394
391
  }
395
392
  });
396
393
 
397
- // ../../node_modules/.pnpm/cross-spawn@6.0.6/node_modules/cross-spawn/lib/util/readShebang.js
394
+ // ../../node_modules/.pnpm/cross-spawn@6.0.5/node_modules/cross-spawn/lib/util/readShebang.js
398
395
  var require_readShebang = __commonJS({
399
- "../../node_modules/.pnpm/cross-spawn@6.0.6/node_modules/cross-spawn/lib/util/readShebang.js"(exports, module2) {
396
+ "../../node_modules/.pnpm/cross-spawn@6.0.5/node_modules/cross-spawn/lib/util/readShebang.js"(exports, module2) {
400
397
  "use strict";
401
398
  var fs = require("fs");
402
399
  var shebangCommand = require_shebang_command();
@@ -426,15 +423,15 @@ var require_readShebang = __commonJS({
426
423
  var require_semver = __commonJS({
427
424
  "../../node_modules/.pnpm/semver@5.7.2/node_modules/semver/semver.js"(exports, module2) {
428
425
  exports = module2.exports = SemVer;
429
- var debug3;
426
+ var debug4;
430
427
  if (typeof process === "object" && process.env && process.env.NODE_DEBUG && /\bsemver\b/i.test(process.env.NODE_DEBUG)) {
431
- debug3 = function() {
428
+ debug4 = function() {
432
429
  var args = Array.prototype.slice.call(arguments, 0);
433
430
  args.unshift("SEMVER");
434
431
  console.log.apply(console, args);
435
432
  };
436
433
  } else {
437
- debug3 = function() {
434
+ debug4 = function() {
438
435
  };
439
436
  }
440
437
  exports.SEMVER_SPEC_VERSION = "2.0.0";
@@ -543,7 +540,7 @@ var require_semver = __commonJS({
543
540
  var STAR = R++;
544
541
  src[STAR] = "(<|>)?=?\\s*\\*";
545
542
  for (i = 0; i < R; i++) {
546
- debug3(i, src[i]);
543
+ debug4(i, src[i]);
547
544
  if (!re[i]) {
548
545
  re[i] = new RegExp(src[i]);
549
546
  safeRe[i] = new RegExp(makeSafeRe(src[i]));
@@ -610,7 +607,7 @@ var require_semver = __commonJS({
610
607
  if (!(this instanceof SemVer)) {
611
608
  return new SemVer(version2, options);
612
609
  }
613
- debug3("SemVer", version2, options);
610
+ debug4("SemVer", version2, options);
614
611
  this.options = options;
615
612
  this.loose = !!options.loose;
616
613
  var m = version2.trim().match(options.loose ? safeRe[LOOSE] : safeRe[FULL]);
@@ -657,7 +654,7 @@ var require_semver = __commonJS({
657
654
  return this.version;
658
655
  };
659
656
  SemVer.prototype.compare = function(other) {
660
- debug3("SemVer.compare", this.version, this.options, other);
657
+ debug4("SemVer.compare", this.version, this.options, other);
661
658
  if (!(other instanceof SemVer)) {
662
659
  other = new SemVer(other, this.options);
663
660
  }
@@ -684,7 +681,7 @@ var require_semver = __commonJS({
684
681
  do {
685
682
  var a = this.prerelease[i2];
686
683
  var b = other.prerelease[i2];
687
- debug3("prerelease compare", i2, a, b);
684
+ debug4("prerelease compare", i2, a, b);
688
685
  if (a === void 0 && b === void 0) {
689
686
  return 0;
690
687
  } else if (b === void 0) {
@@ -698,8 +695,8 @@ var require_semver = __commonJS({
698
695
  }
699
696
  } while (++i2);
700
697
  };
701
- SemVer.prototype.inc = function(release, identifier) {
702
- switch (release) {
698
+ SemVer.prototype.inc = function(release2, identifier) {
699
+ switch (release2) {
703
700
  case "premajor":
704
701
  this.prerelease.length = 0;
705
702
  this.patch = 0;
@@ -771,20 +768,20 @@ var require_semver = __commonJS({
771
768
  }
772
769
  break;
773
770
  default:
774
- throw new Error("invalid increment argument: " + release);
771
+ throw new Error("invalid increment argument: " + release2);
775
772
  }
776
773
  this.format();
777
774
  this.raw = this.version;
778
775
  return this;
779
776
  };
780
777
  exports.inc = inc;
781
- function inc(version2, release, loose, identifier) {
778
+ function inc(version2, release2, loose, identifier) {
782
779
  if (typeof loose === "string") {
783
780
  identifier = loose;
784
781
  loose = void 0;
785
782
  }
786
783
  try {
787
- return new SemVer(version2, loose).inc(release, identifier).version;
784
+ return new SemVer(version2, loose).inc(release2, identifier).version;
788
785
  } catch (er) {
789
786
  return null;
790
787
  }
@@ -938,7 +935,7 @@ var require_semver = __commonJS({
938
935
  return new Comparator(comp, options);
939
936
  }
940
937
  comp = comp.trim().split(/\s+/).join(" ");
941
- debug3("comparator", comp, options);
938
+ debug4("comparator", comp, options);
942
939
  this.options = options;
943
940
  this.loose = !!options.loose;
944
941
  this.parse(comp);
@@ -947,7 +944,7 @@ var require_semver = __commonJS({
947
944
  } else {
948
945
  this.value = this.operator + this.semver.version;
949
946
  }
950
- debug3("comp", this);
947
+ debug4("comp", this);
951
948
  }
952
949
  var ANY = {};
953
950
  Comparator.prototype.parse = function(comp) {
@@ -970,7 +967,7 @@ var require_semver = __commonJS({
970
967
  return this.value;
971
968
  };
972
969
  Comparator.prototype.test = function(version2) {
973
- debug3("Comparator.test", version2, this.options.loose);
970
+ debug4("Comparator.test", version2, this.options.loose);
974
971
  if (this.semver === ANY) {
975
972
  return true;
976
973
  }
@@ -1053,9 +1050,9 @@ var require_semver = __commonJS({
1053
1050
  var loose = this.options.loose;
1054
1051
  var hr = loose ? safeRe[HYPHENRANGELOOSE] : safeRe[HYPHENRANGE];
1055
1052
  range = range.replace(hr, hyphenReplace);
1056
- debug3("hyphen replace", range);
1053
+ debug4("hyphen replace", range);
1057
1054
  range = range.replace(safeRe[COMPARATORTRIM], comparatorTrimReplace);
1058
- debug3("comparator trim", range, safeRe[COMPARATORTRIM]);
1055
+ debug4("comparator trim", range, safeRe[COMPARATORTRIM]);
1059
1056
  range = range.replace(safeRe[TILDETRIM], tildeTrimReplace);
1060
1057
  range = range.replace(safeRe[CARETTRIM], caretTrimReplace);
1061
1058
  var compRe = loose ? safeRe[COMPARATORLOOSE] : safeRe[COMPARATOR];
@@ -1095,15 +1092,15 @@ var require_semver = __commonJS({
1095
1092
  });
1096
1093
  }
1097
1094
  function parseComparator(comp, options) {
1098
- debug3("comp", comp, options);
1095
+ debug4("comp", comp, options);
1099
1096
  comp = replaceCarets(comp, options);
1100
- debug3("caret", comp);
1097
+ debug4("caret", comp);
1101
1098
  comp = replaceTildes(comp, options);
1102
- debug3("tildes", comp);
1099
+ debug4("tildes", comp);
1103
1100
  comp = replaceXRanges(comp, options);
1104
- debug3("xrange", comp);
1101
+ debug4("xrange", comp);
1105
1102
  comp = replaceStars(comp, options);
1106
- debug3("stars", comp);
1103
+ debug4("stars", comp);
1107
1104
  return comp;
1108
1105
  }
1109
1106
  function isX(id) {
@@ -1117,7 +1114,7 @@ var require_semver = __commonJS({
1117
1114
  function replaceTilde(comp, options) {
1118
1115
  var r = options.loose ? safeRe[TILDELOOSE] : safeRe[TILDE];
1119
1116
  return comp.replace(r, function(_, M, m, p, pr) {
1120
- debug3("tilde", comp, _, M, m, p, pr);
1117
+ debug4("tilde", comp, _, M, m, p, pr);
1121
1118
  var ret;
1122
1119
  if (isX(M)) {
1123
1120
  ret = "";
@@ -1126,12 +1123,12 @@ var require_semver = __commonJS({
1126
1123
  } else if (isX(p)) {
1127
1124
  ret = ">=" + M + "." + m + ".0 <" + M + "." + (+m + 1) + ".0";
1128
1125
  } else if (pr) {
1129
- debug3("replaceTilde pr", pr);
1126
+ debug4("replaceTilde pr", pr);
1130
1127
  ret = ">=" + M + "." + m + "." + p + "-" + pr + " <" + M + "." + (+m + 1) + ".0";
1131
1128
  } else {
1132
1129
  ret = ">=" + M + "." + m + "." + p + " <" + M + "." + (+m + 1) + ".0";
1133
1130
  }
1134
- debug3("tilde return", ret);
1131
+ debug4("tilde return", ret);
1135
1132
  return ret;
1136
1133
  });
1137
1134
  }
@@ -1141,10 +1138,10 @@ var require_semver = __commonJS({
1141
1138
  }).join(" ");
1142
1139
  }
1143
1140
  function replaceCaret(comp, options) {
1144
- debug3("caret", comp, options);
1141
+ debug4("caret", comp, options);
1145
1142
  var r = options.loose ? safeRe[CARETLOOSE] : safeRe[CARET];
1146
1143
  return comp.replace(r, function(_, M, m, p, pr) {
1147
- debug3("caret", comp, _, M, m, p, pr);
1144
+ debug4("caret", comp, _, M, m, p, pr);
1148
1145
  var ret;
1149
1146
  if (isX(M)) {
1150
1147
  ret = "";
@@ -1157,7 +1154,7 @@ var require_semver = __commonJS({
1157
1154
  ret = ">=" + M + "." + m + ".0 <" + (+M + 1) + ".0.0";
1158
1155
  }
1159
1156
  } else if (pr) {
1160
- debug3("replaceCaret pr", pr);
1157
+ debug4("replaceCaret pr", pr);
1161
1158
  if (M === "0") {
1162
1159
  if (m === "0") {
1163
1160
  ret = ">=" + M + "." + m + "." + p + "-" + pr + " <" + M + "." + m + "." + (+p + 1);
@@ -1168,7 +1165,7 @@ var require_semver = __commonJS({
1168
1165
  ret = ">=" + M + "." + m + "." + p + "-" + pr + " <" + (+M + 1) + ".0.0";
1169
1166
  }
1170
1167
  } else {
1171
- debug3("no pr");
1168
+ debug4("no pr");
1172
1169
  if (M === "0") {
1173
1170
  if (m === "0") {
1174
1171
  ret = ">=" + M + "." + m + "." + p + " <" + M + "." + m + "." + (+p + 1);
@@ -1179,12 +1176,12 @@ var require_semver = __commonJS({
1179
1176
  ret = ">=" + M + "." + m + "." + p + " <" + (+M + 1) + ".0.0";
1180
1177
  }
1181
1178
  }
1182
- debug3("caret return", ret);
1179
+ debug4("caret return", ret);
1183
1180
  return ret;
1184
1181
  });
1185
1182
  }
1186
1183
  function replaceXRanges(comp, options) {
1187
- debug3("replaceXRanges", comp, options);
1184
+ debug4("replaceXRanges", comp, options);
1188
1185
  return comp.split(/\s+/).map(function(comp2) {
1189
1186
  return replaceXRange(comp2, options);
1190
1187
  }).join(" ");
@@ -1193,7 +1190,7 @@ var require_semver = __commonJS({
1193
1190
  comp = comp.trim();
1194
1191
  var r = options.loose ? safeRe[XRANGELOOSE] : safeRe[XRANGE];
1195
1192
  return comp.replace(r, function(ret, gtlt, M, m, p, pr) {
1196
- debug3("xRange", comp, ret, gtlt, M, m, p, pr);
1193
+ debug4("xRange", comp, ret, gtlt, M, m, p, pr);
1197
1194
  var xM = isX(M);
1198
1195
  var xm = xM || isX(m);
1199
1196
  var xp = xm || isX(p);
@@ -1236,12 +1233,12 @@ var require_semver = __commonJS({
1236
1233
  } else if (xp) {
1237
1234
  ret = ">=" + M + "." + m + ".0 <" + M + "." + (+m + 1) + ".0";
1238
1235
  }
1239
- debug3("xRange return", ret);
1236
+ debug4("xRange return", ret);
1240
1237
  return ret;
1241
1238
  });
1242
1239
  }
1243
1240
  function replaceStars(comp, options) {
1244
- debug3("replaceStars", comp, options);
1241
+ debug4("replaceStars", comp, options);
1245
1242
  return comp.trim().replace(safeRe[STAR], "");
1246
1243
  }
1247
1244
  function hyphenReplace($0, from, fM, fm, fp, fpr, fb, to, tM, tm, tp, tpr, tb) {
@@ -1289,7 +1286,7 @@ var require_semver = __commonJS({
1289
1286
  }
1290
1287
  if (version2.prerelease.length && !options.includePrerelease) {
1291
1288
  for (i2 = 0; i2 < set.length; i2++) {
1292
- debug3(set[i2].semver);
1289
+ debug4(set[i2].semver);
1293
1290
  if (set[i2].semver === ANY) {
1294
1291
  continue;
1295
1292
  }
@@ -1491,9 +1488,9 @@ var require_semver = __commonJS({
1491
1488
  }
1492
1489
  });
1493
1490
 
1494
- // ../../node_modules/.pnpm/cross-spawn@6.0.6/node_modules/cross-spawn/lib/parse.js
1491
+ // ../../node_modules/.pnpm/cross-spawn@6.0.5/node_modules/cross-spawn/lib/parse.js
1495
1492
  var require_parse = __commonJS({
1496
- "../../node_modules/.pnpm/cross-spawn@6.0.6/node_modules/cross-spawn/lib/parse.js"(exports, module2) {
1493
+ "../../node_modules/.pnpm/cross-spawn@6.0.5/node_modules/cross-spawn/lib/parse.js"(exports, module2) {
1497
1494
  "use strict";
1498
1495
  var path = require("path");
1499
1496
  var niceTry = require_src();
@@ -1577,9 +1574,9 @@ var require_parse = __commonJS({
1577
1574
  }
1578
1575
  });
1579
1576
 
1580
- // ../../node_modules/.pnpm/cross-spawn@6.0.6/node_modules/cross-spawn/lib/enoent.js
1577
+ // ../../node_modules/.pnpm/cross-spawn@6.0.5/node_modules/cross-spawn/lib/enoent.js
1581
1578
  var require_enoent = __commonJS({
1582
- "../../node_modules/.pnpm/cross-spawn@6.0.6/node_modules/cross-spawn/lib/enoent.js"(exports, module2) {
1579
+ "../../node_modules/.pnpm/cross-spawn@6.0.5/node_modules/cross-spawn/lib/enoent.js"(exports, module2) {
1583
1580
  "use strict";
1584
1581
  var isWin = process.platform === "win32";
1585
1582
  function notFoundError(original, syscall) {
@@ -1627,28 +1624,28 @@ var require_enoent = __commonJS({
1627
1624
  }
1628
1625
  });
1629
1626
 
1630
- // ../../node_modules/.pnpm/cross-spawn@6.0.6/node_modules/cross-spawn/index.js
1627
+ // ../../node_modules/.pnpm/cross-spawn@6.0.5/node_modules/cross-spawn/index.js
1631
1628
  var require_cross_spawn = __commonJS({
1632
- "../../node_modules/.pnpm/cross-spawn@6.0.6/node_modules/cross-spawn/index.js"(exports, module2) {
1629
+ "../../node_modules/.pnpm/cross-spawn@6.0.5/node_modules/cross-spawn/index.js"(exports, module2) {
1633
1630
  "use strict";
1634
1631
  var cp = require("child_process");
1635
1632
  var parse = require_parse();
1636
1633
  var enoent = require_enoent();
1637
- function spawn(command, args, options) {
1634
+ function spawn2(command, args, options) {
1638
1635
  const parsed = parse(command, args, options);
1639
1636
  const spawned = cp.spawn(parsed.command, parsed.args, parsed.options);
1640
1637
  enoent.hookChildProcess(spawned, parsed);
1641
1638
  return spawned;
1642
1639
  }
1643
- function spawnSync(command, args, options) {
1640
+ function spawnSync2(command, args, options) {
1644
1641
  const parsed = parse(command, args, options);
1645
1642
  const result = cp.spawnSync(parsed.command, parsed.args, parsed.options);
1646
1643
  result.error = result.error || enoent.verifyENOENTSync(result.status, parsed);
1647
1644
  return result;
1648
1645
  }
1649
- module2.exports = spawn;
1650
- module2.exports.spawn = spawn;
1651
- module2.exports.sync = spawnSync;
1646
+ module2.exports = spawn2;
1647
+ module2.exports.spawn = spawn2;
1648
+ module2.exports.sync = spawnSync2;
1652
1649
  module2.exports._parse = parse;
1653
1650
  module2.exports._enoent = enoent;
1654
1651
  }
@@ -2286,9 +2283,9 @@ var require_once = __commonJS({
2286
2283
  }
2287
2284
  });
2288
2285
 
2289
- // ../../node_modules/.pnpm/end-of-stream@1.4.4/node_modules/end-of-stream/index.js
2286
+ // ../../node_modules/.pnpm/end-of-stream@1.4.1/node_modules/end-of-stream/index.js
2290
2287
  var require_end_of_stream = __commonJS({
2291
- "../../node_modules/.pnpm/end-of-stream@1.4.4/node_modules/end-of-stream/index.js"(exports, module2) {
2288
+ "../../node_modules/.pnpm/end-of-stream@1.4.1/node_modules/end-of-stream/index.js"(exports, module2) {
2292
2289
  var once = require_once();
2293
2290
  var noop = function() {
2294
2291
  };
@@ -2308,7 +2305,6 @@ var require_end_of_stream = __commonJS({
2308
2305
  var rs = stream._readableState;
2309
2306
  var readable = opts.readable || opts.readable !== false && stream.readable;
2310
2307
  var writable = opts.writable || opts.writable !== false && stream.writable;
2311
- var cancelled = false;
2312
2308
  var onlegacyfinish = function() {
2313
2309
  if (!stream.writable)
2314
2310
  onfinish();
@@ -2330,14 +2326,9 @@ var require_end_of_stream = __commonJS({
2330
2326
  callback.call(stream, err);
2331
2327
  };
2332
2328
  var onclose = function() {
2333
- process.nextTick(onclosenexttick);
2334
- };
2335
- var onclosenexttick = function() {
2336
- if (cancelled)
2337
- return;
2338
- if (readable && !(rs && (rs.ended && !rs.destroyed)))
2329
+ if (readable && !(rs && rs.ended))
2339
2330
  return callback.call(stream, new Error("premature close"));
2340
- if (writable && !(ws && (ws.ended && !ws.destroyed)))
2331
+ if (writable && !(ws && ws.ended))
2341
2332
  return callback.call(stream, new Error("premature close"));
2342
2333
  };
2343
2334
  var onrequest = function() {
@@ -2362,7 +2353,6 @@ var require_end_of_stream = __commonJS({
2362
2353
  stream.on("error", onerror);
2363
2354
  stream.on("close", onclose);
2364
2355
  return function() {
2365
- cancelled = true;
2366
2356
  stream.removeListener("complete", onfinish);
2367
2357
  stream.removeListener("abort", onclose);
2368
2358
  stream.removeListener("request", onrequest);
@@ -3475,11 +3465,11 @@ var require_graceful_fs = __commonJS({
3475
3465
  }
3476
3466
  });
3477
3467
  }
3478
- var debug3 = noop;
3468
+ var debug4 = noop;
3479
3469
  if (util.debuglog)
3480
- debug3 = util.debuglog("gfs4");
3470
+ debug4 = util.debuglog("gfs4");
3481
3471
  else if (/\bgfs4\b/i.test(process.env.NODE_DEBUG || ""))
3482
- debug3 = function() {
3472
+ debug4 = function() {
3483
3473
  var m = util.format.apply(util, arguments);
3484
3474
  m = "GFS4: " + m.split(/\n/).join("\nGFS4: ");
3485
3475
  console.error(m);
@@ -3514,7 +3504,7 @@ var require_graceful_fs = __commonJS({
3514
3504
  }(fs.closeSync);
3515
3505
  if (/\bgfs4\b/i.test(process.env.NODE_DEBUG || "")) {
3516
3506
  process.on("exit", function() {
3517
- debug3(fs[gracefulQueue]);
3507
+ debug4(fs[gracefulQueue]);
3518
3508
  require("assert").equal(fs[gracefulQueue].length, 0);
3519
3509
  });
3520
3510
  }
@@ -3767,7 +3757,7 @@ var require_graceful_fs = __commonJS({
3767
3757
  return fs2;
3768
3758
  }
3769
3759
  function enqueue(elem) {
3770
- debug3("ENQUEUE", elem[0].name, elem[1]);
3760
+ debug4("ENQUEUE", elem[0].name, elem[1]);
3771
3761
  fs[gracefulQueue].push(elem);
3772
3762
  retry();
3773
3763
  }
@@ -3794,10 +3784,10 @@ var require_graceful_fs = __commonJS({
3794
3784
  var startTime = elem[3];
3795
3785
  var lastTime = elem[4];
3796
3786
  if (startTime === void 0) {
3797
- debug3("RETRY", fn.name, args);
3787
+ debug4("RETRY", fn.name, args);
3798
3788
  fn.apply(null, args);
3799
3789
  } else if (Date.now() - startTime >= 6e4) {
3800
- debug3("TIMEOUT", fn.name, args);
3790
+ debug4("TIMEOUT", fn.name, args);
3801
3791
  var cb = args.pop();
3802
3792
  if (typeof cb === "function")
3803
3793
  cb.call(null, err);
@@ -3806,7 +3796,7 @@ var require_graceful_fs = __commonJS({
3806
3796
  var sinceStart = Math.max(lastTime - startTime, 1);
3807
3797
  var desiredDelay = Math.min(sinceStart * 1.2, 100);
3808
3798
  if (sinceAttempt >= desiredDelay) {
3809
- debug3("RETRY", fn.name, args);
3799
+ debug4("RETRY", fn.name, args);
3810
3800
  fn.apply(null, args.concat([startTime]));
3811
3801
  } else {
3812
3802
  fs[gracefulQueue].push(elem);
@@ -5291,7 +5281,7 @@ var require_jsonfile = __commonJS({
5291
5281
  callback(null, obj);
5292
5282
  });
5293
5283
  }
5294
- function readFileSync(file, options) {
5284
+ function readFileSync2(file, options) {
5295
5285
  options = options || {};
5296
5286
  if (typeof options === "string") {
5297
5287
  options = { encoding: options };
@@ -5345,7 +5335,7 @@ var require_jsonfile = __commonJS({
5345
5335
  }
5346
5336
  fs.writeFile(file, str, options, callback);
5347
5337
  }
5348
- function writeFileSync(file, obj, options) {
5338
+ function writeFileSync2(file, obj, options) {
5349
5339
  options = options || {};
5350
5340
  var fs = options.fs || _fs;
5351
5341
  var str = stringify(obj, options);
@@ -5359,9 +5349,9 @@ var require_jsonfile = __commonJS({
5359
5349
  }
5360
5350
  var jsonfile = {
5361
5351
  readFile: readFile2,
5362
- readFileSync,
5352
+ readFileSync: readFileSync2,
5363
5353
  writeFile: writeFile2,
5364
- writeFileSync
5354
+ writeFileSync: writeFileSync2
5365
5355
  };
5366
5356
  module2.exports = jsonfile;
5367
5357
  }
@@ -5712,7 +5702,7 @@ var require_lib = __commonJS({
5712
5702
  var require_lib2 = __commonJS({
5713
5703
  "../../node_modules/.pnpm/which@3.0.0/node_modules/which/lib/index.js"(exports, module2) {
5714
5704
  var isexe = require_isexe();
5715
- var { join: join3, delimiter, sep, posix } = require("path");
5705
+ var { join: join4, delimiter, sep, posix } = require("path");
5716
5706
  var isWindows = process.platform === "win32";
5717
5707
  var rSlash = new RegExp(`[${posix.sep}${sep === posix.sep ? "" : sep}]`.replace(/(\\)/g, "\\$1"));
5718
5708
  var rRel = new RegExp(`^\\.${rSlash.source}`);
@@ -5741,9 +5731,9 @@ var require_lib2 = __commonJS({
5741
5731
  var getPathPart = (raw, cmd) => {
5742
5732
  const pathPart = /^".*"$/.test(raw) ? raw.slice(1, -1) : raw;
5743
5733
  const prefix = !pathPart && rRel.test(cmd) ? cmd.slice(0, 2) : "";
5744
- return prefix + join3(pathPart, cmd);
5734
+ return prefix + join4(pathPart, cmd);
5745
5735
  };
5746
- var which2 = async (cmd, opt = {}) => {
5736
+ var which3 = async (cmd, opt = {}) => {
5747
5737
  const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt);
5748
5738
  const found = [];
5749
5739
  for (const envPart of pathEnv) {
@@ -5791,8 +5781,8 @@ var require_lib2 = __commonJS({
5791
5781
  }
5792
5782
  throw getNotFoundError(cmd);
5793
5783
  };
5794
- module2.exports = which2;
5795
- which2.sync = whichSync;
5784
+ module2.exports = which3;
5785
+ which3.sync = whichSync;
5796
5786
  }
5797
5787
  });
5798
5788
 
@@ -5800,15 +5790,15 @@ var require_lib2 = __commonJS({
5800
5790
  var require_semver2 = __commonJS({
5801
5791
  "../../node_modules/.pnpm/semver@6.3.1/node_modules/semver/semver.js"(exports, module2) {
5802
5792
  exports = module2.exports = SemVer;
5803
- var debug3;
5793
+ var debug4;
5804
5794
  if (typeof process === "object" && process.env && process.env.NODE_DEBUG && /\bsemver\b/i.test(process.env.NODE_DEBUG)) {
5805
- debug3 = function() {
5795
+ debug4 = function() {
5806
5796
  var args = Array.prototype.slice.call(arguments, 0);
5807
5797
  args.unshift("SEMVER");
5808
5798
  console.log.apply(console, args);
5809
5799
  };
5810
5800
  } else {
5811
- debug3 = function() {
5801
+ debug4 = function() {
5812
5802
  };
5813
5803
  }
5814
5804
  exports.SEMVER_SPEC_VERSION = "2.0.0";
@@ -5926,7 +5916,7 @@ var require_semver2 = __commonJS({
5926
5916
  tok("STAR");
5927
5917
  src[t.STAR] = "(<|>)?=?\\s*\\*";
5928
5918
  for (i = 0; i < R; i++) {
5929
- debug3(i, src[i]);
5919
+ debug4(i, src[i]);
5930
5920
  if (!re[i]) {
5931
5921
  re[i] = new RegExp(src[i]);
5932
5922
  safeRe[i] = new RegExp(makeSafeRe(src[i]));
@@ -5993,7 +5983,7 @@ var require_semver2 = __commonJS({
5993
5983
  if (!(this instanceof SemVer)) {
5994
5984
  return new SemVer(version2, options);
5995
5985
  }
5996
- debug3("SemVer", version2, options);
5986
+ debug4("SemVer", version2, options);
5997
5987
  this.options = options;
5998
5988
  this.loose = !!options.loose;
5999
5989
  var m = version2.trim().match(options.loose ? safeRe[t.LOOSE] : safeRe[t.FULL]);
@@ -6040,7 +6030,7 @@ var require_semver2 = __commonJS({
6040
6030
  return this.version;
6041
6031
  };
6042
6032
  SemVer.prototype.compare = function(other) {
6043
- debug3("SemVer.compare", this.version, this.options, other);
6033
+ debug4("SemVer.compare", this.version, this.options, other);
6044
6034
  if (!(other instanceof SemVer)) {
6045
6035
  other = new SemVer(other, this.options);
6046
6036
  }
@@ -6067,7 +6057,7 @@ var require_semver2 = __commonJS({
6067
6057
  do {
6068
6058
  var a = this.prerelease[i2];
6069
6059
  var b = other.prerelease[i2];
6070
- debug3("prerelease compare", i2, a, b);
6060
+ debug4("prerelease compare", i2, a, b);
6071
6061
  if (a === void 0 && b === void 0) {
6072
6062
  return 0;
6073
6063
  } else if (b === void 0) {
@@ -6089,7 +6079,7 @@ var require_semver2 = __commonJS({
6089
6079
  do {
6090
6080
  var a = this.build[i2];
6091
6081
  var b = other.build[i2];
6092
- debug3("prerelease compare", i2, a, b);
6082
+ debug4("prerelease compare", i2, a, b);
6093
6083
  if (a === void 0 && b === void 0) {
6094
6084
  return 0;
6095
6085
  } else if (b === void 0) {
@@ -6103,8 +6093,8 @@ var require_semver2 = __commonJS({
6103
6093
  }
6104
6094
  } while (++i2);
6105
6095
  };
6106
- SemVer.prototype.inc = function(release, identifier) {
6107
- switch (release) {
6096
+ SemVer.prototype.inc = function(release2, identifier) {
6097
+ switch (release2) {
6108
6098
  case "premajor":
6109
6099
  this.prerelease.length = 0;
6110
6100
  this.patch = 0;
@@ -6176,20 +6166,20 @@ var require_semver2 = __commonJS({
6176
6166
  }
6177
6167
  break;
6178
6168
  default:
6179
- throw new Error("invalid increment argument: " + release);
6169
+ throw new Error("invalid increment argument: " + release2);
6180
6170
  }
6181
6171
  this.format();
6182
6172
  this.raw = this.version;
6183
6173
  return this;
6184
6174
  };
6185
6175
  exports.inc = inc;
6186
- function inc(version2, release, loose, identifier) {
6176
+ function inc(version2, release2, loose, identifier) {
6187
6177
  if (typeof loose === "string") {
6188
6178
  identifier = loose;
6189
6179
  loose = void 0;
6190
6180
  }
6191
6181
  try {
6192
- return new SemVer(version2, loose).inc(release, identifier).version;
6182
+ return new SemVer(version2, loose).inc(release2, identifier).version;
6193
6183
  } catch (er) {
6194
6184
  return null;
6195
6185
  }
@@ -6349,7 +6339,7 @@ var require_semver2 = __commonJS({
6349
6339
  return new Comparator(comp, options);
6350
6340
  }
6351
6341
  comp = comp.trim().split(/\s+/).join(" ");
6352
- debug3("comparator", comp, options);
6342
+ debug4("comparator", comp, options);
6353
6343
  this.options = options;
6354
6344
  this.loose = !!options.loose;
6355
6345
  this.parse(comp);
@@ -6358,7 +6348,7 @@ var require_semver2 = __commonJS({
6358
6348
  } else {
6359
6349
  this.value = this.operator + this.semver.version;
6360
6350
  }
6361
- debug3("comp", this);
6351
+ debug4("comp", this);
6362
6352
  }
6363
6353
  var ANY = {};
6364
6354
  Comparator.prototype.parse = function(comp) {
@@ -6381,7 +6371,7 @@ var require_semver2 = __commonJS({
6381
6371
  return this.value;
6382
6372
  };
6383
6373
  Comparator.prototype.test = function(version2) {
6384
- debug3("Comparator.test", version2, this.options.loose);
6374
+ debug4("Comparator.test", version2, this.options.loose);
6385
6375
  if (this.semver === ANY || version2 === ANY) {
6386
6376
  return true;
6387
6377
  }
@@ -6474,9 +6464,9 @@ var require_semver2 = __commonJS({
6474
6464
  var loose = this.options.loose;
6475
6465
  var hr = loose ? safeRe[t.HYPHENRANGELOOSE] : safeRe[t.HYPHENRANGE];
6476
6466
  range = range.replace(hr, hyphenReplace);
6477
- debug3("hyphen replace", range);
6467
+ debug4("hyphen replace", range);
6478
6468
  range = range.replace(safeRe[t.COMPARATORTRIM], comparatorTrimReplace);
6479
- debug3("comparator trim", range, safeRe[t.COMPARATORTRIM]);
6469
+ debug4("comparator trim", range, safeRe[t.COMPARATORTRIM]);
6480
6470
  range = range.replace(safeRe[t.TILDETRIM], tildeTrimReplace);
6481
6471
  range = range.replace(safeRe[t.CARETTRIM], caretTrimReplace);
6482
6472
  range = range.split(/\s+/).join(" ");
@@ -6529,15 +6519,15 @@ var require_semver2 = __commonJS({
6529
6519
  });
6530
6520
  }
6531
6521
  function parseComparator(comp, options) {
6532
- debug3("comp", comp, options);
6522
+ debug4("comp", comp, options);
6533
6523
  comp = replaceCarets(comp, options);
6534
- debug3("caret", comp);
6524
+ debug4("caret", comp);
6535
6525
  comp = replaceTildes(comp, options);
6536
- debug3("tildes", comp);
6526
+ debug4("tildes", comp);
6537
6527
  comp = replaceXRanges(comp, options);
6538
- debug3("xrange", comp);
6528
+ debug4("xrange", comp);
6539
6529
  comp = replaceStars(comp, options);
6540
- debug3("stars", comp);
6530
+ debug4("stars", comp);
6541
6531
  return comp;
6542
6532
  }
6543
6533
  function isX(id) {
@@ -6551,7 +6541,7 @@ var require_semver2 = __commonJS({
6551
6541
  function replaceTilde(comp, options) {
6552
6542
  var r = options.loose ? safeRe[t.TILDELOOSE] : safeRe[t.TILDE];
6553
6543
  return comp.replace(r, function(_, M, m, p, pr) {
6554
- debug3("tilde", comp, _, M, m, p, pr);
6544
+ debug4("tilde", comp, _, M, m, p, pr);
6555
6545
  var ret;
6556
6546
  if (isX(M)) {
6557
6547
  ret = "";
@@ -6560,12 +6550,12 @@ var require_semver2 = __commonJS({
6560
6550
  } else if (isX(p)) {
6561
6551
  ret = ">=" + M + "." + m + ".0 <" + M + "." + (+m + 1) + ".0";
6562
6552
  } else if (pr) {
6563
- debug3("replaceTilde pr", pr);
6553
+ debug4("replaceTilde pr", pr);
6564
6554
  ret = ">=" + M + "." + m + "." + p + "-" + pr + " <" + M + "." + (+m + 1) + ".0";
6565
6555
  } else {
6566
6556
  ret = ">=" + M + "." + m + "." + p + " <" + M + "." + (+m + 1) + ".0";
6567
6557
  }
6568
- debug3("tilde return", ret);
6558
+ debug4("tilde return", ret);
6569
6559
  return ret;
6570
6560
  });
6571
6561
  }
@@ -6575,10 +6565,10 @@ var require_semver2 = __commonJS({
6575
6565
  }).join(" ");
6576
6566
  }
6577
6567
  function replaceCaret(comp, options) {
6578
- debug3("caret", comp, options);
6568
+ debug4("caret", comp, options);
6579
6569
  var r = options.loose ? safeRe[t.CARETLOOSE] : safeRe[t.CARET];
6580
6570
  return comp.replace(r, function(_, M, m, p, pr) {
6581
- debug3("caret", comp, _, M, m, p, pr);
6571
+ debug4("caret", comp, _, M, m, p, pr);
6582
6572
  var ret;
6583
6573
  if (isX(M)) {
6584
6574
  ret = "";
@@ -6591,7 +6581,7 @@ var require_semver2 = __commonJS({
6591
6581
  ret = ">=" + M + "." + m + ".0 <" + (+M + 1) + ".0.0";
6592
6582
  }
6593
6583
  } else if (pr) {
6594
- debug3("replaceCaret pr", pr);
6584
+ debug4("replaceCaret pr", pr);
6595
6585
  if (M === "0") {
6596
6586
  if (m === "0") {
6597
6587
  ret = ">=" + M + "." + m + "." + p + "-" + pr + " <" + M + "." + m + "." + (+p + 1);
@@ -6602,7 +6592,7 @@ var require_semver2 = __commonJS({
6602
6592
  ret = ">=" + M + "." + m + "." + p + "-" + pr + " <" + (+M + 1) + ".0.0";
6603
6593
  }
6604
6594
  } else {
6605
- debug3("no pr");
6595
+ debug4("no pr");
6606
6596
  if (M === "0") {
6607
6597
  if (m === "0") {
6608
6598
  ret = ">=" + M + "." + m + "." + p + " <" + M + "." + m + "." + (+p + 1);
@@ -6613,12 +6603,12 @@ var require_semver2 = __commonJS({
6613
6603
  ret = ">=" + M + "." + m + "." + p + " <" + (+M + 1) + ".0.0";
6614
6604
  }
6615
6605
  }
6616
- debug3("caret return", ret);
6606
+ debug4("caret return", ret);
6617
6607
  return ret;
6618
6608
  });
6619
6609
  }
6620
6610
  function replaceXRanges(comp, options) {
6621
- debug3("replaceXRanges", comp, options);
6611
+ debug4("replaceXRanges", comp, options);
6622
6612
  return comp.split(/\s+/).map(function(comp2) {
6623
6613
  return replaceXRange(comp2, options);
6624
6614
  }).join(" ");
@@ -6627,7 +6617,7 @@ var require_semver2 = __commonJS({
6627
6617
  comp = comp.trim();
6628
6618
  var r = options.loose ? safeRe[t.XRANGELOOSE] : safeRe[t.XRANGE];
6629
6619
  return comp.replace(r, function(ret, gtlt, M, m, p, pr) {
6630
- debug3("xRange", comp, ret, gtlt, M, m, p, pr);
6620
+ debug4("xRange", comp, ret, gtlt, M, m, p, pr);
6631
6621
  var xM = isX(M);
6632
6622
  var xm = xM || isX(m);
6633
6623
  var xp = xm || isX(p);
@@ -6671,12 +6661,12 @@ var require_semver2 = __commonJS({
6671
6661
  } else if (xp) {
6672
6662
  ret = ">=" + M + "." + m + ".0" + pr + " <" + M + "." + (+m + 1) + ".0" + pr;
6673
6663
  }
6674
- debug3("xRange return", ret);
6664
+ debug4("xRange return", ret);
6675
6665
  return ret;
6676
6666
  });
6677
6667
  }
6678
6668
  function replaceStars(comp, options) {
6679
- debug3("replaceStars", comp, options);
6669
+ debug4("replaceStars", comp, options);
6680
6670
  return comp.trim().replace(safeRe[t.STAR], "");
6681
6671
  }
6682
6672
  function hyphenReplace($0, from, fM, fm, fp, fpr, fb, to, tM, tm, tp, tpr, tb) {
@@ -6728,7 +6718,7 @@ var require_semver2 = __commonJS({
6728
6718
  }
6729
6719
  if (version2.prerelease.length && !options.includePrerelease) {
6730
6720
  for (i2 = 0; i2 < set.length; i2++) {
6731
- debug3(set[i2].semver);
6721
+ debug4(set[i2].semver);
6732
6722
  if (set[i2].semver === ANY) {
6733
6723
  continue;
6734
6724
  }
@@ -6950,14 +6940,16 @@ var require_semver2 = __commonJS({
6950
6940
  var src_exports = {};
6951
6941
  __export(src_exports, {
6952
6942
  build: () => build,
6943
+ shouldServe: () => shouldServe,
6944
+ startDevServer: () => startDevServer,
6953
6945
  version: () => version
6954
6946
  });
6955
6947
  module.exports = __toCommonJS(src_exports);
6956
- var import_os = require("os");
6957
- var import_path2 = require("path");
6948
+ var import_os2 = require("os");
6949
+ var import_path3 = require("path");
6958
6950
  var import_execa2 = __toESM(require_execa());
6959
6951
  var import_fs_extra = __toESM(require_lib());
6960
- var import_build_utils2 = require("@vercel/build-utils");
6952
+ var import_build_utils3 = require("@vercel/build-utils");
6961
6953
 
6962
6954
  // src/install-ruby.ts
6963
6955
  var import_execa = __toESM(require_execa());
@@ -6965,6 +6957,8 @@ var import_which = __toESM(require_lib2());
6965
6957
  var import_path = require("path");
6966
6958
  var import_semver = __toESM(require_semver2());
6967
6959
  var import_build_utils = require("@vercel/build-utils");
6960
+ var import_child_process = require("child_process");
6961
+ var import_os = require("os");
6968
6962
  var RubyVersion = class extends import_build_utils.Version {
6969
6963
  };
6970
6964
  var allOptions = [
@@ -7006,12 +7000,68 @@ function getLatestRubyVersion() {
7006
7000
  }
7007
7001
  return selection;
7008
7002
  }
7003
+ function resolveSystemRuby() {
7004
+ const rubyPath = import_which.default.sync("ruby", { nothrow: true });
7005
+ const gemPath = import_which.default.sync("gem", { nothrow: true });
7006
+ if (!rubyPath || !gemPath)
7007
+ return null;
7008
+ const ver = (0, import_child_process.spawnSync)(rubyPath, ["-e", "print RUBY_VERSION"], {
7009
+ encoding: "utf8"
7010
+ });
7011
+ if (ver.status !== 0 || !ver.stdout)
7012
+ return null;
7013
+ const [mj, mn] = String(ver.stdout).trim().split(".");
7014
+ const major = Number(mj) ?? 3;
7015
+ const minor = Number(mn) ?? 3;
7016
+ return { rubyPath, gemPath, major, minor };
7017
+ }
7018
+ function makeLocalRubyEnv({
7019
+ major,
7020
+ minor,
7021
+ rubyPath,
7022
+ gemPath
7023
+ }) {
7024
+ const gemHome = (0, import_path.join)((0, import_os.tmpdir)(), `vercel-ruby-${major}${minor}-${process.pid}`);
7025
+ const matchedOption = allOptions.find(
7026
+ (o) => o.major === major && o.minor === minor && o.state !== "discontinued"
7027
+ );
7028
+ if (!matchedOption) {
7029
+ throw new import_build_utils.NowBuildError({
7030
+ code: "RUBY_INVALID_VERSION",
7031
+ link: "http://vercel.link/ruby-version",
7032
+ message: `Local Ruby ${major}.${minor} does not match any supported Vercel runtime. Supported: ${allOptions.filter((o) => o.state !== "discontinued").map((o) => `${o.major}.${o.minor}`).join(", ")}`
7033
+ });
7034
+ }
7035
+ return {
7036
+ major,
7037
+ gemHome,
7038
+ runtime: matchedOption.runtime,
7039
+ rubyPath,
7040
+ gemPath,
7041
+ vendorPath: `vendor/bundle/ruby/${major}.${minor}.0`
7042
+ };
7043
+ }
7009
7044
  function getRubyPath(meta, gemfileContents) {
7010
- let selection = getLatestRubyVersion();
7045
+ let selection = null;
7046
+ try {
7047
+ selection = getLatestRubyVersion();
7048
+ } catch {
7049
+ selection = null;
7050
+ }
7011
7051
  if (meta.isDev) {
7012
- throw new Error(
7013
- "Ruby is in the early alpha stage and does not support vercel dev at this time."
7014
- );
7052
+ const sys2 = resolveSystemRuby();
7053
+ if (sys2) {
7054
+ const result = makeLocalRubyEnv(sys2);
7055
+ (0, import_build_utils.debug)(
7056
+ `ruby: using system ruby for local dev: ${JSON.stringify({ ruby: sys2.rubyPath, gem: sys2.gemPath, version: `${sys2.major}.${sys2.minor}` })}`
7057
+ );
7058
+ return result;
7059
+ }
7060
+ throw new import_build_utils.NowBuildError({
7061
+ code: "RUBY_INVALID_VERSION",
7062
+ link: "http://vercel.link/ruby-version",
7063
+ message: "Unable to find any supported Ruby versions (local). Ensure ruby and gem are on PATH."
7064
+ });
7015
7065
  } else if (gemfileContents) {
7016
7066
  const line = gemfileContents.split("\n").find((line2) => line2.startsWith("ruby"));
7017
7067
  if (line) {
@@ -7027,30 +7077,60 @@ function getRubyPath(meta, gemfileContents) {
7027
7077
  link: "http://vercel.link/ruby-version"
7028
7078
  });
7029
7079
  }
7030
- if (selection.state === "discontinued" || !isInstalled(selection)) {
7031
- const latest = getLatestRubyVersion();
7032
- const intro = `Found \`Gemfile\` with ${selection.state === "discontinued" ? "discontinued" : "invalid"} Ruby version: \`${line}.\``;
7033
- const hint = `Please set \`ruby "~> ${latest.range}"\` in your \`Gemfile\` to use Ruby ${latest.range}.`;
7080
+ if (!selection || selection.state === "discontinued" || !isInstalled(selection)) {
7081
+ const sys2 = resolveSystemRuby();
7082
+ if (sys2) {
7083
+ const sysRange = `${sys2.major}.${sys2.minor}.x`;
7084
+ if (!strVersion || (0, import_semver.intersects)(sysRange, strVersion)) {
7085
+ const result = makeLocalRubyEnv(sys2);
7086
+ (0, import_build_utils.debug)(
7087
+ `ruby: using system ruby (Gemfile) version=${sys2.major}.${sys2.minor} ruby=${sys2.rubyPath}`
7088
+ );
7089
+ return result;
7090
+ }
7091
+ }
7092
+ let latest = null;
7093
+ try {
7094
+ latest = getLatestRubyVersion();
7095
+ } catch {
7096
+ }
7097
+ const intro = `Found \`Gemfile\` with ${selection && selection.state === "discontinued" ? "discontinued" : "invalid"} Ruby version: \`${line}.\``;
7098
+ const hint = latest ? `Please set \`ruby "~> ${latest.range}"\` in your \`Gemfile\` to use Ruby ${latest.range}.` : "Please update your `Gemfile` to use a supported Ruby version.";
7034
7099
  throw new import_build_utils.NowBuildError({
7035
- code: selection.state === "discontinued" ? "RUBY_DISCONTINUED_VERSION" : "RUBY_INVALID_VERSION",
7100
+ code: selection && selection.state === "discontinued" ? "RUBY_DISCONTINUED_VERSION" : "RUBY_INVALID_VERSION",
7036
7101
  link: "http://vercel.link/ruby-version",
7037
7102
  message: `${intro} ${hint}`
7038
7103
  });
7039
7104
  }
7040
7105
  }
7041
7106
  }
7042
- const { major, minor, runtime } = selection;
7043
- const gemHome = "/ruby" + major + minor;
7044
- const result = {
7045
- major,
7046
- gemHome,
7047
- runtime,
7048
- rubyPath: (0, import_path.join)(gemHome, "bin", "ruby"),
7049
- gemPath: (0, import_path.join)(gemHome, "bin", "gem"),
7050
- vendorPath: `vendor/bundle/ruby/${major}.${minor}.0`
7051
- };
7052
- (0, import_build_utils.debug)(JSON.stringify(result, null, " "));
7053
- return result;
7107
+ if (selection) {
7108
+ const { major, minor, runtime } = selection;
7109
+ const gemHome = "/ruby" + major + minor;
7110
+ const result = {
7111
+ major,
7112
+ gemHome,
7113
+ runtime,
7114
+ rubyPath: (0, import_path.join)(gemHome, "bin", "ruby"),
7115
+ gemPath: (0, import_path.join)(gemHome, "bin", "gem"),
7116
+ vendorPath: `vendor/bundle/ruby/${major}.${minor}.0`
7117
+ };
7118
+ (0, import_build_utils.debug)(JSON.stringify(result, null, " "));
7119
+ return result;
7120
+ }
7121
+ const sys = resolveSystemRuby();
7122
+ if (sys) {
7123
+ const result = makeLocalRubyEnv(sys);
7124
+ (0, import_build_utils.debug)(
7125
+ `ruby: using system ruby (fallback) version=${sys.major}.${sys.minor} ruby=${sys.rubyPath}`
7126
+ );
7127
+ return result;
7128
+ }
7129
+ throw new import_build_utils.NowBuildError({
7130
+ code: "RUBY_INVALID_VERSION",
7131
+ link: "http://vercel.link/ruby-version",
7132
+ message: "Unable to find any supported Ruby versions."
7133
+ });
7054
7134
  }
7055
7135
  async function installBundler(meta, gemfileContents) {
7056
7136
  const { gemHome, rubyPath, gemPath, vendorPath, runtime, major } = getRubyPath(meta, gemfileContents);
@@ -7076,6 +7156,292 @@ function isInstalled({ major, minor }) {
7076
7156
  return Boolean(import_which.default.sync((0, import_path.join)(gemHome, "bin/ruby"), { nothrow: true })) && Boolean(import_which.default.sync((0, import_path.join)(gemHome, "bin/gem"), { nothrow: true }));
7077
7157
  }
7078
7158
 
7159
+ // src/start-dev-server.ts
7160
+ var import_child_process2 = require("child_process");
7161
+ var import_fs = require("fs");
7162
+ var import_path2 = require("path");
7163
+ var import_which2 = __toESM(require_lib2());
7164
+ var import_build_utils2 = require("@vercel/build-utils");
7165
+ function silenceNodeWarnings() {
7166
+ const original = process.emitWarning.bind(
7167
+ process
7168
+ );
7169
+ let active = true;
7170
+ const wrapped = (warning, ...args) => {
7171
+ if (!active) {
7172
+ return original(
7173
+ warning,
7174
+ ...args
7175
+ );
7176
+ }
7177
+ return;
7178
+ };
7179
+ process.emitWarning = wrapped;
7180
+ return () => {
7181
+ if (!active)
7182
+ return;
7183
+ active = false;
7184
+ if (process.emitWarning === wrapped) {
7185
+ process.emitWarning = original;
7186
+ }
7187
+ };
7188
+ }
7189
+ var PERSISTENT_SERVERS = /* @__PURE__ */ new Map();
7190
+ var PENDING_STARTS = /* @__PURE__ */ new Map();
7191
+ var restoreWarnings = null;
7192
+ var cleanupHandlersInstalled = false;
7193
+ function installGlobalCleanupHandlers() {
7194
+ if (cleanupHandlersInstalled)
7195
+ return;
7196
+ cleanupHandlersInstalled = true;
7197
+ const killAll = () => {
7198
+ for (const [key, info] of PERSISTENT_SERVERS.entries()) {
7199
+ try {
7200
+ process.kill(info.pid, "SIGTERM");
7201
+ } catch (err) {
7202
+ (0, import_build_utils2.debug)(`Error sending SIGTERM to ${info.pid}: ${err}`);
7203
+ }
7204
+ try {
7205
+ process.kill(info.pid, "SIGKILL");
7206
+ } catch (err) {
7207
+ (0, import_build_utils2.debug)(`Error sending SIGKILL to ${info.pid}: ${err}`);
7208
+ }
7209
+ PERSISTENT_SERVERS.delete(key);
7210
+ }
7211
+ if (restoreWarnings) {
7212
+ try {
7213
+ restoreWarnings();
7214
+ } catch (err) {
7215
+ (0, import_build_utils2.debug)(`Error restoring warnings: ${err}`);
7216
+ }
7217
+ restoreWarnings = null;
7218
+ }
7219
+ };
7220
+ process.on("SIGINT", () => {
7221
+ killAll();
7222
+ process.exit(130);
7223
+ });
7224
+ process.on("SIGTERM", () => {
7225
+ killAll();
7226
+ process.exit(143);
7227
+ });
7228
+ process.on("exit", () => {
7229
+ killAll();
7230
+ });
7231
+ }
7232
+ function createDevRubyShim(workPath, entrypoint) {
7233
+ try {
7234
+ const vercelRubyDir = (0, import_path2.join)(workPath, ".vercel", "ruby");
7235
+ (0, import_fs.mkdirSync)(vercelRubyDir, { recursive: true });
7236
+ const shimPath = (0, import_path2.join)(vercelRubyDir, `vc_init_dev.rb`);
7237
+ const templatePath = (0, import_path2.join)(__dirname, "..", "vc_init_dev.rb");
7238
+ const template = (0, import_fs.readFileSync)(templatePath, "utf8");
7239
+ const shimSource = template.replace(/__VC_DEV_ENTRYPOINT__/g, entrypoint);
7240
+ (0, import_fs.writeFileSync)(shimPath, shimSource, "utf8");
7241
+ (0, import_build_utils2.debug)(`Prepared Ruby dev shim at ${shimPath}`);
7242
+ return shimPath;
7243
+ } catch (err) {
7244
+ (0, import_build_utils2.debug)(`Failed to prepare Ruby dev shim: ${err?.message || err}`);
7245
+ return null;
7246
+ }
7247
+ }
7248
+ function detectGemfile(workPath, entrypoint) {
7249
+ const entryDir = (0, import_path2.dirname)(entrypoint);
7250
+ const localGemfile = (0, import_path2.join)(workPath, entryDir, "Gemfile");
7251
+ if ((0, import_fs.existsSync)(localGemfile))
7252
+ return localGemfile;
7253
+ const rootGemfile = (0, import_path2.join)(workPath, "Gemfile");
7254
+ if ((0, import_fs.existsSync)(rootGemfile))
7255
+ return rootGemfile;
7256
+ return null;
7257
+ }
7258
+ async function run(cmd, args, opts) {
7259
+ return await new Promise((resolve) => {
7260
+ const child = (0, import_child_process2.spawn)(cmd, args, {
7261
+ cwd: opts.cwd,
7262
+ env: opts.env,
7263
+ stdio: ["ignore", "pipe", "pipe"]
7264
+ });
7265
+ child.stdout?.on("data", (buf) => process.stdout.write(buf));
7266
+ child.stderr?.on("data", (buf) => process.stderr.write(buf));
7267
+ child.on("close", (code, signal) => resolve({ code, signal }));
7268
+ });
7269
+ }
7270
+ var startDevServer = async (opts) => {
7271
+ const { entrypoint: rawEntrypoint, workPath, meta = {} } = opts;
7272
+ if (!rawEntrypoint.endsWith(".ru")) {
7273
+ return null;
7274
+ }
7275
+ if (!restoreWarnings)
7276
+ restoreWarnings = silenceNodeWarnings();
7277
+ installGlobalCleanupHandlers();
7278
+ const entrypoint = rawEntrypoint;
7279
+ const env = { ...process.env, ...meta.env || {} };
7280
+ const serverKey = `${workPath}::${entrypoint}::ruby`;
7281
+ const existing = PERSISTENT_SERVERS.get(serverKey);
7282
+ if (existing) {
7283
+ return {
7284
+ port: existing.port,
7285
+ pid: existing.pid,
7286
+ shutdown: async () => {
7287
+ }
7288
+ };
7289
+ }
7290
+ const pending = PENDING_STARTS.get(serverKey);
7291
+ if (pending) {
7292
+ const { port, pid } = await pending;
7293
+ return { port, pid, shutdown: async () => {
7294
+ } };
7295
+ }
7296
+ let childProcess = null;
7297
+ let stdoutLogListener = null;
7298
+ let stderrLogListener = null;
7299
+ let resolveChildReady;
7300
+ let rejectChildReady;
7301
+ const childReady = new Promise(
7302
+ (resolve, reject) => {
7303
+ resolveChildReady = resolve;
7304
+ rejectChildReady = reject;
7305
+ }
7306
+ );
7307
+ PENDING_STARTS.set(serverKey, childReady);
7308
+ try {
7309
+ await new Promise((resolve, reject) => {
7310
+ let resolved = false;
7311
+ const shimPath = createDevRubyShim(workPath, entrypoint);
7312
+ if (!shimPath) {
7313
+ rejectChildReady(
7314
+ new import_build_utils2.NowBuildError({
7315
+ code: "RUBY_DEV_SHIM_ERROR",
7316
+ message: "Failed to create Ruby dev shim."
7317
+ })
7318
+ );
7319
+ return reject(new Error("Failed to create Ruby dev shim"));
7320
+ }
7321
+ const gemfile = detectGemfile(workPath, entrypoint);
7322
+ const bundlePath = import_which2.default.sync("bundle", { nothrow: true });
7323
+ const bundlerPath = bundlePath || import_which2.default.sync("bundler", { nothrow: true });
7324
+ const projectDir = gemfile ? (0, import_path2.dirname)(gemfile) : workPath;
7325
+ if (gemfile) {
7326
+ env.BUNDLE_GEMFILE = gemfile;
7327
+ }
7328
+ const checkDeps = async () => {
7329
+ if (gemfile && bundlerPath) {
7330
+ (0, import_build_utils2.debug)(`Running "bundle check" for ${gemfile}`);
7331
+ const check = await run(
7332
+ bundlerPath,
7333
+ ["check", "--gemfile", gemfile],
7334
+ { cwd: projectDir, env }
7335
+ );
7336
+ if (check.code !== 0) {
7337
+ return false;
7338
+ }
7339
+ }
7340
+ return true;
7341
+ };
7342
+ checkDeps().then((ok) => {
7343
+ if (!ok) {
7344
+ const err = new import_build_utils2.NowBuildError({
7345
+ code: "RUBY_GEMS_MISSING",
7346
+ message: 'Required gems are not installed. Run "vercel build" and try again.'
7347
+ });
7348
+ rejectChildReady(err);
7349
+ return reject(err);
7350
+ }
7351
+ let cmd = "ruby";
7352
+ let args = [shimPath];
7353
+ if (gemfile && bundlerPath) {
7354
+ cmd = bundlerPath;
7355
+ args = ["exec", "ruby", shimPath];
7356
+ }
7357
+ (0, import_build_utils2.debug)(`Starting Ruby dev server: ${cmd} ${args.join(" ")}`);
7358
+ const child = (0, import_child_process2.spawn)(cmd, args, {
7359
+ cwd: workPath,
7360
+ env,
7361
+ stdio: ["inherit", "pipe", "pipe"]
7362
+ });
7363
+ childProcess = child;
7364
+ stdoutLogListener = (buf) => {
7365
+ const s = buf.toString();
7366
+ for (const line of s.split(/\r?\n/)) {
7367
+ if (line)
7368
+ process.stdout.write(line.endsWith("\n") ? line : line + "\n");
7369
+ }
7370
+ };
7371
+ stderrLogListener = (buf) => {
7372
+ const s = buf.toString();
7373
+ for (const line of s.split(/\r?\n/)) {
7374
+ if (line)
7375
+ process.stderr.write(line.endsWith("\n") ? line : line + "\n");
7376
+ }
7377
+ };
7378
+ child.stdout?.on("data", stdoutLogListener);
7379
+ child.stderr?.on("data", stderrLogListener);
7380
+ const readinessRegexes = [
7381
+ /Serving on https?:\/\/(?:\[[^\]]+\]|[^:\s]+):(\d+)/i,
7382
+ /WEBrick.*?listening on.*?:(\d+)/i
7383
+ ];
7384
+ const onDetect = (chunk) => {
7385
+ const text = chunk.toString();
7386
+ let portMatch = null;
7387
+ for (const rx of readinessRegexes) {
7388
+ const m = text.match(rx);
7389
+ if (m) {
7390
+ portMatch = m;
7391
+ break;
7392
+ }
7393
+ }
7394
+ if (portMatch && child.pid) {
7395
+ if (!resolved) {
7396
+ resolved = true;
7397
+ child.stdout?.removeListener("data", onDetect);
7398
+ child.stderr?.removeListener("data", onDetect);
7399
+ const port2 = Number(portMatch[1]);
7400
+ resolveChildReady({ port: port2, pid: child.pid });
7401
+ resolve();
7402
+ }
7403
+ }
7404
+ };
7405
+ child.stdout?.on("data", onDetect);
7406
+ child.stderr?.on("data", onDetect);
7407
+ child.once("error", (err) => {
7408
+ if (!resolved) {
7409
+ rejectChildReady(err);
7410
+ reject(err);
7411
+ }
7412
+ });
7413
+ child.once("exit", (code, signal) => {
7414
+ if (!resolved) {
7415
+ const err = new Error(
7416
+ `Ruby dev server exited before binding (code=${code}, signal=${signal})`
7417
+ );
7418
+ rejectChildReady(err);
7419
+ reject(err);
7420
+ }
7421
+ });
7422
+ }).catch((err) => {
7423
+ if (!resolved) {
7424
+ rejectChildReady(err);
7425
+ reject(err);
7426
+ }
7427
+ });
7428
+ });
7429
+ const { port, pid } = await childReady;
7430
+ PERSISTENT_SERVERS.set(serverKey, {
7431
+ port,
7432
+ pid,
7433
+ child: childProcess,
7434
+ stdoutLogListener,
7435
+ stderrLogListener
7436
+ });
7437
+ const shutdown = async () => {
7438
+ };
7439
+ return { port, pid, shutdown };
7440
+ } finally {
7441
+ PENDING_STARTS.delete(serverKey);
7442
+ }
7443
+ };
7444
+
7079
7445
  // src/index.ts
7080
7446
  async function matchPaths(configPatterns, workPath) {
7081
7447
  const patterns = typeof configPatterns === "string" ? [configPatterns] : configPatterns;
@@ -7084,65 +7450,98 @@ async function matchPaths(configPatterns, workPath) {
7084
7450
  }
7085
7451
  const patternPaths = await Promise.all(
7086
7452
  patterns.map(async (pattern) => {
7087
- const files = await (0, import_build_utils2.glob)(pattern, workPath);
7453
+ const files = await (0, import_build_utils3.glob)(pattern, workPath);
7088
7454
  return Object.keys(files);
7089
7455
  })
7090
7456
  );
7091
7457
  return patternPaths.reduce((a, b) => a.concat(b), []);
7092
7458
  }
7093
- async function bundleInstall(bundlePath, bundleDir, gemfilePath, rubyPath, major) {
7094
- (0, import_build_utils2.debug)(`running "bundle install --deployment"...`);
7095
- const bundleAppConfig = await (0, import_build_utils2.getWriteableDirectory)();
7096
- const gemfileContent = await (0, import_fs_extra.readFile)(gemfilePath, "utf8");
7097
- if (gemfileContent.includes('ruby "~> 2.7.x"')) {
7098
- await (0, import_fs_extra.writeFile)(
7099
- gemfilePath,
7100
- gemfileContent.replace('ruby "~> 2.7.x"', 'ruby "~> 2.7.0"')
7101
- );
7102
- } else if (gemfileContent.includes('ruby "~> 3.2.x"')) {
7103
- await (0, import_fs_extra.writeFile)(
7104
- gemfilePath,
7105
- gemfileContent.replace('ruby "~> 3.2.x"', 'ruby "~> 3.2.0"')
7106
- );
7107
- } else if (gemfileContent.includes('ruby "~> 3.3.x"')) {
7108
- await (0, import_fs_extra.writeFile)(
7109
- gemfilePath,
7110
- gemfileContent.replace('ruby "~> 3.3.x"', 'ruby "~> 3.3.0"')
7111
- );
7459
+ async function prepareGemfile(gemfilePath, major) {
7460
+ let gemfile = await (0, import_fs_extra.readFile)(gemfilePath, "utf8");
7461
+ let modified = false;
7462
+ const patchRuby = (from, to) => {
7463
+ if (gemfile.includes(from)) {
7464
+ gemfile = gemfile.replace(from, to);
7465
+ modified = true;
7466
+ }
7467
+ };
7468
+ patchRuby('ruby "~> 3.3.x"', 'ruby "~> 3.3.0"');
7469
+ patchRuby('ruby "~> 3.2.x"', 'ruby "~> 3.2.0"');
7470
+ patchRuby('ruby "~> 2.7.x"', 'ruby "~> 2.7.0"');
7471
+ const containsWebrick = /^[^#]*\bgem\s+["']webrick["']/m.test(gemfile);
7472
+ if (major >= 3 && !containsWebrick) {
7473
+ gemfile += `${import_os2.EOL}gem "webrick"${import_os2.EOL}`;
7474
+ modified = true;
7112
7475
  }
7113
- const bundlerEnv = (0, import_build_utils2.cloneEnv)(process.env, {
7114
- // Ensure the correct version of `ruby` is in front of the $PATH
7115
- PATH: `${(0, import_path2.dirname)(rubyPath)}:${(0, import_path2.dirname)(bundlePath)}:${process.env.PATH}`,
7476
+ if (modified) {
7477
+ await (0, import_fs_extra.writeFile)(gemfilePath, gemfile);
7478
+ }
7479
+ return { modified };
7480
+ }
7481
+ async function bundleLock(bundlerPath, gemfilePath, rubyPath) {
7482
+ const bundleAppConfig = await (0, import_build_utils3.getWriteableDirectory)();
7483
+ const bundlerEnv = (0, import_build_utils3.cloneEnv)(process.env, {
7484
+ PATH: `${(0, import_path3.dirname)(rubyPath)}:${(0, import_path3.dirname)(bundlerPath)}:${process.env.PATH}`,
7116
7485
  BUNDLE_SILENCE_ROOT_WARNING: "1",
7117
7486
  BUNDLE_APP_CONFIG: bundleAppConfig,
7118
7487
  BUNDLE_JOBS: "4"
7119
7488
  });
7120
- if (major >= 3) {
7121
- const result2 = await (0, import_execa2.default)("bundler", ["add", "webrick"], {
7122
- cwd: (0, import_path2.dirname)(gemfilePath),
7123
- stdio: "pipe",
7124
- env: bundlerEnv,
7125
- reject: false
7126
- });
7127
- if (result2.exitCode !== 0) {
7128
- console.log(result2.stdout);
7129
- console.error(result2.stderr);
7130
- throw result2;
7131
- }
7489
+ const archTokenLinux = process.arch === "arm64" ? "aarch64" : "x86_64";
7490
+ const linuxPlatform = `${archTokenLinux}-linux`;
7491
+ const platforms = [linuxPlatform];
7492
+ if (process.platform === "darwin") {
7493
+ const darwinArchToken = process.arch === "arm64" ? "arm64" : "x86_64";
7494
+ const darwinMajor = Number((0, import_os2.release)().split(".")[0]) || void 0;
7495
+ const darwinPlatform = darwinMajor ? `${darwinArchToken}-darwin-${darwinMajor}` : `${darwinArchToken}-darwin`;
7496
+ platforms.push(darwinPlatform);
7497
+ }
7498
+ (0, import_build_utils3.debug)(`ruby: ensuring Gemfile.lock has platforms ${platforms.join(", ")}`);
7499
+ const lockArgs = ["lock"];
7500
+ for (const platform of platforms) {
7501
+ lockArgs.push("--add-platform", platform);
7502
+ }
7503
+ const lockRes = await (0, import_execa2.default)(bundlerPath, lockArgs, {
7504
+ cwd: (0, import_path3.dirname)(gemfilePath),
7505
+ stdio: "pipe",
7506
+ env: bundlerEnv,
7507
+ reject: false
7508
+ });
7509
+ if (lockRes.exitCode !== 0) {
7510
+ console.log(lockRes.stdout);
7511
+ console.error(lockRes.stderr);
7512
+ throw lockRes;
7132
7513
  }
7133
- const result = await (0, import_execa2.default)(
7514
+ }
7515
+ async function bundleInstall(bundlePath, bundleDir, gemfilePath, rubyPath) {
7516
+ const bundleAppConfig = await (0, import_build_utils3.getWriteableDirectory)();
7517
+ const bundlerEnv = (0, import_build_utils3.cloneEnv)(process.env, {
7518
+ PATH: `${(0, import_path3.dirname)(rubyPath)}:${(0, import_path3.dirname)(bundlePath)}:${process.env.PATH}`,
7519
+ BUNDLE_SILENCE_ROOT_WARNING: "1",
7520
+ BUNDLE_APP_CONFIG: bundleAppConfig,
7521
+ BUNDLE_JOBS: "4"
7522
+ });
7523
+ (0, import_build_utils3.debug)('running "bundle install --deployment --frozen"');
7524
+ const installRes = await (0, import_execa2.default)(
7134
7525
  bundlePath,
7135
- ["install", "--deployment", "--gemfile", gemfilePath, "--path", bundleDir],
7526
+ [
7527
+ "install",
7528
+ "--deployment",
7529
+ "--frozen",
7530
+ "--gemfile",
7531
+ gemfilePath,
7532
+ "--path",
7533
+ bundleDir
7534
+ ],
7136
7535
  {
7137
7536
  stdio: "pipe",
7138
7537
  env: bundlerEnv,
7139
7538
  reject: false
7140
7539
  }
7141
7540
  );
7142
- if (result.exitCode !== 0) {
7143
- console.log(result.stdout);
7144
- console.error(result.stderr);
7145
- throw result;
7541
+ if (installRes.exitCode !== 0) {
7542
+ console.log(installRes.stdout);
7543
+ console.error(installRes.stderr);
7544
+ throw installRes;
7146
7545
  }
7147
7546
  }
7148
7547
  var version = 3;
@@ -7153,66 +7552,80 @@ var build = async ({
7153
7552
  config,
7154
7553
  meta = {}
7155
7554
  }) => {
7156
- await (0, import_build_utils2.download)(files, workPath, meta);
7157
- const entrypointFsDirname = (0, import_path2.join)(workPath, (0, import_path2.dirname)(entrypoint));
7555
+ await (0, import_build_utils3.download)(files, workPath, meta);
7556
+ const entrypointFsDirname = (0, import_path3.join)(workPath, (0, import_path3.dirname)(entrypoint));
7158
7557
  const gemfileName = "Gemfile";
7159
- let gemfilePath = await (0, import_build_utils2.walkParentDirs)({
7558
+ let gemfilePath = await (0, import_build_utils3.walkParentDirs)({
7160
7559
  base: workPath,
7161
7560
  start: entrypointFsDirname,
7162
7561
  filename: gemfileName
7163
7562
  });
7164
7563
  if (!gemfilePath) {
7165
- gemfilePath = (0, import_path2.join)(entrypointFsDirname, gemfileName);
7166
- await (0, import_fs_extra.writeFile)(gemfilePath, `source "https://rubygems.org"${import_os.EOL}`);
7564
+ gemfilePath = (0, import_path3.join)(entrypointFsDirname, gemfileName);
7565
+ await (0, import_fs_extra.writeFile)(gemfilePath, `source "https://rubygems.org"${import_os2.EOL}`);
7167
7566
  }
7168
7567
  const gemfileContents = gemfilePath ? await (0, import_fs_extra.readFile)(gemfilePath, "utf8") : "";
7169
7568
  const { gemHome, bundlerPath, vendorPath, runtime, rubyPath, major } = await installBundler(meta, gemfileContents);
7170
7569
  process.env.GEM_HOME = gemHome;
7171
- (0, import_build_utils2.debug)(`Checking existing vendor directory at "${vendorPath}"`);
7172
- const vendorDir = (0, import_path2.join)(workPath, vendorPath);
7173
- const bundleDir = (0, import_path2.join)(workPath, "vendor", "bundle");
7174
- const relativeVendorDir = (0, import_path2.join)(entrypointFsDirname, vendorPath);
7570
+ try {
7571
+ (0, import_build_utils3.debug)("preparing Gemfile");
7572
+ await prepareGemfile(gemfilePath, major);
7573
+ (0, import_build_utils3.debug)('running "bundle lock"');
7574
+ await bundleLock(bundlerPath, gemfilePath, rubyPath);
7575
+ } catch (err) {
7576
+ (0, import_build_utils3.debug)(
7577
+ "failed to normalize Gemfile/lockfile before vendor check",
7578
+ err
7579
+ );
7580
+ }
7581
+ (0, import_build_utils3.debug)(`Checking existing vendor directory at "${vendorPath}"`);
7582
+ const vendorDir = (0, import_path3.join)(workPath, vendorPath);
7583
+ const bundleDir = (0, import_path3.join)(workPath, "vendor", "bundle");
7584
+ const relativeVendorDir = (0, import_path3.join)(entrypointFsDirname, vendorPath);
7175
7585
  const hasRootVendorDir = await (0, import_fs_extra.pathExists)(vendorDir);
7176
7586
  const hasRelativeVendorDir = await (0, import_fs_extra.pathExists)(relativeVendorDir);
7177
- const hasVendorDir = hasRootVendorDir || hasRelativeVendorDir;
7178
7587
  if (hasRelativeVendorDir) {
7179
7588
  if (hasRootVendorDir) {
7180
- (0, import_build_utils2.debug)(
7589
+ (0, import_build_utils3.debug)(
7181
7590
  "found two vendor directories, choosing the vendor directory relative to entrypoint"
7182
7591
  );
7183
7592
  } else {
7184
- (0, import_build_utils2.debug)("found vendor directory relative to entrypoint");
7593
+ (0, import_build_utils3.debug)("found vendor directory relative to entrypoint");
7185
7594
  }
7186
7595
  await (0, import_fs_extra.move)(relativeVendorDir, vendorDir);
7187
7596
  } else if (hasRootVendorDir) {
7188
- (0, import_build_utils2.debug)("found vendor directory in project root");
7597
+ (0, import_build_utils3.debug)("found vendor directory in project root");
7189
7598
  }
7190
7599
  await (0, import_fs_extra.ensureDir)(vendorDir);
7191
- if (!hasVendorDir) {
7192
- if (gemfilePath) {
7193
- (0, import_build_utils2.debug)(
7194
- "did not find a vendor directory but found a Gemfile, bundling gems..."
7195
- );
7196
- await bundleInstall(bundlerPath, bundleDir, gemfilePath, rubyPath, major);
7197
- }
7198
- } else {
7199
- (0, import_build_utils2.debug)('found vendor directory, skipping "bundle install"...');
7200
- }
7600
+ await bundleInstall(bundlerPath, bundleDir, gemfilePath, rubyPath);
7201
7601
  try {
7202
- await (0, import_fs_extra.remove)((0, import_path2.join)(vendorDir, "cache"));
7602
+ await (0, import_fs_extra.remove)((0, import_path3.join)(vendorDir, "cache"));
7203
7603
  } catch (e) {
7204
7604
  }
7205
- const originalRbPath = (0, import_path2.join)(__dirname, "..", "vc_init.rb");
7605
+ const originalRbPath = (0, import_path3.join)(__dirname, "..", "vc_init.rb");
7206
7606
  const originalHandlerRbContents = await (0, import_fs_extra.readFile)(originalRbPath, "utf8");
7207
- (0, import_build_utils2.debug)("entrypoint is", entrypoint);
7607
+ (0, import_build_utils3.debug)("entrypoint is", entrypoint);
7208
7608
  const userHandlerFilePath = entrypoint.replace(/\.rb$/, "");
7209
7609
  const nowHandlerRbContents = originalHandlerRbContents.replace(
7210
7610
  /__VC_HANDLER_FILENAME/g,
7211
7611
  userHandlerFilePath
7212
7612
  );
7213
7613
  const handlerRbFilename = "vc__handler__ruby";
7214
- const outputFiles = await (0, import_build_utils2.glob)("**", workPath);
7215
- outputFiles[`${handlerRbFilename}.rb`] = new import_build_utils2.FileBlob({
7614
+ const predefinedExcludes = [
7615
+ ".git/**",
7616
+ ".gitignore",
7617
+ ".vercel/**",
7618
+ ".pnpm-store/**",
7619
+ "**/node_modules/**",
7620
+ "**/.next/**",
7621
+ "**/.nuxt/**"
7622
+ ];
7623
+ const globOptions = {
7624
+ cwd: workPath,
7625
+ ignore: predefinedExcludes
7626
+ };
7627
+ const outputFiles = await (0, import_build_utils3.glob)("**", globOptions);
7628
+ outputFiles[`${handlerRbFilename}.rb`] = new import_build_utils3.FileBlob({
7216
7629
  data: nowHandlerRbContents
7217
7630
  });
7218
7631
  if (config && (config.includeFiles || config.excludeFiles)) {
@@ -7234,7 +7647,7 @@ var build = async ({
7234
7647
  delete outputFiles[excludedPaths[i]];
7235
7648
  }
7236
7649
  }
7237
- const output = new import_build_utils2.Lambda({
7650
+ const output = new import_build_utils3.Lambda({
7238
7651
  files: outputFiles,
7239
7652
  handler: `${handlerRbFilename}.vc__handler`,
7240
7653
  runtime,
@@ -7242,8 +7655,11 @@ var build = async ({
7242
7655
  });
7243
7656
  return { output };
7244
7657
  };
7658
+ var shouldServe = () => true;
7245
7659
  // Annotate the CommonJS export names for ESM import in node:
7246
7660
  0 && (module.exports = {
7247
7661
  build,
7662
+ shouldServe,
7663
+ startDevServer,
7248
7664
  version
7249
7665
  });