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
@@ -18,10 +18,10 @@ import {
18
18
  require_lib,
19
19
  require_minimatch,
20
20
  require_pluralize
21
- } from "./chunk-VE545BR3.js";
21
+ } from "./chunk-KDL2L4KL.js";
22
22
  import {
23
23
  isNativeBinaryInstall
24
- } from "./chunk-ECCWJHC6.js";
24
+ } from "./chunk-CYNB6LL4.js";
25
25
  import {
26
26
  CantParseJSONFile,
27
27
  cmd,
@@ -629,8 +629,8 @@ var require_osenv = __commonJS({
629
629
  var require_npa = __commonJS({
630
630
  "../../node_modules/.pnpm/npm-package-arg@6.1.0/node_modules/npm-package-arg/npa.js"(exports, module) {
631
631
  "use strict";
632
- module.exports = npa2;
633
- module.exports.resolve = resolve2;
632
+ module.exports = npa;
633
+ module.exports.resolve = resolve;
634
634
  module.exports.Result = Result;
635
635
  var url;
636
636
  var HostedGit;
@@ -642,16 +642,16 @@ var require_npa = __commonJS({
642
642
  var hasSlashes = isWindows ? /\\|[/]/ : /[/]/;
643
643
  var isURL = /^(?:git[+])?[a-z]+:/i;
644
644
  var isFilename = /[.](?:tgz|tar.gz|tar)$/i;
645
- function npa2(arg, where) {
645
+ function npa(arg, where) {
646
646
  let name;
647
647
  let spec;
648
648
  if (typeof arg === "object") {
649
649
  if (arg instanceof Result && (!where || where === arg.where)) {
650
650
  return arg;
651
651
  } else if (arg.name && arg.rawSpec) {
652
- return npa2.resolve(arg.name, arg.rawSpec, where || arg.where);
652
+ return npa.resolve(arg.name, arg.rawSpec, where || arg.where);
653
653
  } else {
654
- return npa2(arg.raw, where || arg.where);
654
+ return npa(arg.raw, where || arg.where);
655
655
  }
656
656
  }
657
657
  const nameEndsAt = arg[0] === "@" ? arg.slice(1).indexOf("@") + 1 : arg.indexOf("@");
@@ -666,17 +666,17 @@ var require_npa = __commonJS({
666
666
  } else {
667
667
  if (!validatePackageName)
668
668
  validatePackageName = require_validate_npm_package_name();
669
- const valid2 = validatePackageName(arg);
670
- if (valid2.validForOldPackages) {
669
+ const valid = validatePackageName(arg);
670
+ if (valid.validForOldPackages) {
671
671
  name = arg;
672
672
  } else {
673
673
  spec = arg;
674
674
  }
675
675
  }
676
- return resolve2(name, spec, where, arg);
676
+ return resolve(name, spec, where, arg);
677
677
  }
678
678
  var isFilespec = isWindows ? /^(?:[.]|~[/]|[/\\]|[a-zA-Z]:)/ : /^(?:[.]|~[/]|[/]|[a-zA-Z]:)/;
679
- function resolve2(name, spec, where, arg) {
679
+ function resolve(name, spec, where, arg) {
680
680
  const res = new Result({
681
681
  raw: arg,
682
682
  name,
@@ -703,8 +703,8 @@ var require_npa = __commonJS({
703
703
  return fromRegistry(res);
704
704
  }
705
705
  }
706
- function invalidPackageName(name, valid2) {
707
- const err = new Error(`Invalid package name "${name}": ${valid2.errors.join("; ")}`);
706
+ function invalidPackageName(name, valid) {
707
+ const err = new Error(`Invalid package name "${name}": ${valid.errors.join("; ")}`);
708
708
  err.code = "EINVALIDPACKAGENAME";
709
709
  return err;
710
710
  }
@@ -738,9 +738,9 @@ var require_npa = __commonJS({
738
738
  Result.prototype.setName = function(name) {
739
739
  if (!validatePackageName)
740
740
  validatePackageName = require_validate_npm_package_name();
741
- const valid2 = validatePackageName(name);
742
- if (!valid2.validForOldPackages) {
743
- throw invalidPackageName(name, valid2);
741
+ const valid = validatePackageName(name);
742
+ if (!valid.validForOldPackages) {
743
+ throw invalidPackageName(name, valid);
744
744
  }
745
745
  this.name = name;
746
746
  this.scope = name[0] === "@" ? name.slice(0, name.indexOf("/")) : void 0;
@@ -778,7 +778,7 @@ var require_npa = __commonJS({
778
778
  path = __require("path");
779
779
  return path.resolve(where, spec);
780
780
  }
781
- function isAbsolute2(dir) {
781
+ function isAbsolute(dir) {
782
782
  if (dir[0] === "/")
783
783
  return true;
784
784
  if (/^[A-Za-z]:/.test(dir))
@@ -798,7 +798,7 @@ var require_npa = __commonJS({
798
798
  res.saveSpec = "file:" + spec;
799
799
  } else {
800
800
  res.fetchSpec = resolvePath(where, spec);
801
- if (isAbsolute2(spec)) {
801
+ if (isAbsolute(spec)) {
802
802
  res.saveSpec = "file:" + spec;
803
803
  } else {
804
804
  if (!path)
@@ -863,7 +863,7 @@ var require_npa = __commonJS({
863
863
  return res;
864
864
  }
865
865
  function fromAlias(res, where) {
866
- const subSpec = npa2(res.rawSpec.substr(4), where);
866
+ const subSpec = npa(res.rawSpec.substr(4), where);
867
867
  if (subSpec.type === "alias") {
868
868
  throw new Error("nested aliases not supported");
869
869
  }
@@ -901,485 +901,665 @@ var require_npa = __commonJS({
901
901
  }
902
902
  });
903
903
 
904
- // src/util/build/import-builders.ts
905
- var import_npm_package_arg = __toESM(require_npa(), 1);
906
- var import_semver2 = __toESM(require_semver(), 1);
907
- var import_fs_extra2 = __toESM(require_lib(), 1);
908
- var import_fs_detectors = __toESM(require_dist2(), 1);
909
- import { dirname, isAbsolute, join as join2, resolve } from "path";
910
- import { createRequire } from "module";
911
-
912
- // src/util/build/static-builder.ts
913
- var static_builder_exports = {};
914
- __export(static_builder_exports, {
915
- build: () => build,
916
- shouldServe: () => shouldServe,
917
- version: () => version
918
- });
919
- var import_minimatch = __toESM(require_minimatch(), 1);
920
- import { shouldServe as defaultShouldServe } from "@vercel/build-utils";
921
- var version = 2;
922
- var ALWAYS_EXCLUDED_PREFIXES = [".git/", "node_modules/"];
923
- var ALWAYS_EXCLUDED_FILES = [
924
- "vercel.json",
925
- "vercel.toml",
926
- ...VERCEL_CONFIG_EXTENSIONS.map((ext) => `vercel.${ext}`),
927
- ".vercelignore",
928
- "now.json",
929
- ".nowignore"
930
- ];
931
- var DEFAULT_EXCLUDED_FILES = [
932
- ".gitignore",
933
- "package.json",
934
- "package-lock.json",
935
- "yarn.lock",
936
- "pnpm-lock.yaml",
937
- "bun.lock",
938
- "bun.lockb",
939
- "README.md"
940
- ];
941
- var build = async ({ entrypoint, files, config }) => {
942
- const output = {};
943
- const outputDirectory = config.zeroConfig ? config.outputDirectory : "";
944
- for (let [filename, fileFsRef] of Object.entries(files)) {
945
- if (ALWAYS_EXCLUDED_PREFIXES.some((prefix) => filename.startsWith(prefix)) || ALWAYS_EXCLUDED_FILES.includes(filename) || DEFAULT_EXCLUDED_FILES.includes(filename) || filename.startsWith(".env")) {
946
- continue;
947
- }
948
- if (entrypoint && !(entrypoint === filename || (0, import_minimatch.default)(filename, entrypoint, { dot: true }))) {
949
- continue;
950
- }
951
- if (outputDirectory) {
952
- const outputMatch = outputDirectory + "/";
953
- if (filename.startsWith(outputMatch)) {
954
- filename = filename.slice(outputMatch.length);
904
+ // ../../internals/builder-orchestration/dist/import-builders.js
905
+ var require_import_builders = __commonJS({
906
+ "../../internals/builder-orchestration/dist/import-builders.js"(exports, module) {
907
+ "use strict";
908
+ var __create = Object.create;
909
+ var __defProp = Object.defineProperty;
910
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
911
+ var __getOwnPropNames = Object.getOwnPropertyNames;
912
+ var __getProtoOf = Object.getPrototypeOf;
913
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
914
+ var __export2 = (target, all) => {
915
+ for (var name in all)
916
+ __defProp(target, name, { get: all[name], enumerable: true });
917
+ };
918
+ var __copyProps = (to, from, except, desc) => {
919
+ if (from && typeof from === "object" || typeof from === "function") {
920
+ for (let key of __getOwnPropNames(from))
921
+ if (!__hasOwnProp.call(to, key) && key !== except)
922
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
955
923
  }
956
- }
957
- output[filename] = fileFsRef;
958
- }
959
- return { output };
960
- };
961
- var shouldServe = (_opts) => {
962
- const opts = { ..._opts };
963
- const {
964
- config: { zeroConfig, outputDirectory }
965
- } = opts;
966
- if (zeroConfig && outputDirectory) {
967
- opts.entrypoint = `${outputDirectory}/${opts.entrypoint}`;
968
- opts.requestPath = `${outputDirectory}/${opts.requestPath}`;
969
- }
970
- return defaultShouldServe(opts);
971
- };
972
-
973
- // src/util/build/import-builders.ts
974
- var import_error_utils2 = __toESM(require_dist(), 1);
975
-
976
- // src/util/build/install-builders.ts
977
- var import_pluralize = __toESM(require_pluralize(), 1);
978
- var import_semver = __toESM(require_semver(), 1);
979
- var import_fs_extra = __toESM(require_lib(), 1);
980
- var import_execa = __toESM(require_execa(), 1);
981
- import { URL } from "url";
982
- import { join } from "path";
983
- var import_error_utils = __toESM(require_dist(), 1);
984
- function getErrorMessage(err, execaMessage) {
985
- if (!err || !("stderr" in err)) {
986
- return execaMessage;
987
- }
988
- if (typeof err.stderr === "string") {
989
- return err.stderr;
990
- }
991
- return execaMessage;
992
- }
993
- async function untracedInstallBuilders(buildersDir, buildersToAdd) {
994
- const resolvedSpecs = /* @__PURE__ */ new Map();
995
- const buildersPkgPath = join(buildersDir, "package.json");
996
- try {
997
- const emptyPkgJson = {
998
- private: true,
999
- license: "UNLICENSED"
924
+ return to;
1000
925
  };
1001
- await (0, import_fs_extra.outputJSON)(buildersPkgPath, emptyPkgJson, {
1002
- flag: "wx"
1003
- });
1004
- } catch (err) {
1005
- if (err.code !== "EEXIST")
1006
- throw err;
1007
- }
1008
- output_manager_default.log(
1009
- `Installing ${(0, import_pluralize.default)("Builder", buildersToAdd.size)}: ${Array.from(
1010
- buildersToAdd
1011
- ).join(", ")}`
1012
- );
1013
- const buildUtilsVersion = pkg_default.dependencies?.["@vercel/build-utils"];
1014
- const buildUtilsSpec = buildUtilsVersion && (0, import_semver.validRange)(buildUtilsVersion) ? `@vercel/build-utils@${buildUtilsVersion}` : "@vercel/build-utils";
1015
- const installArgs = ["install", buildUtilsSpec, ...buildersToAdd];
1016
- try {
1017
- const { stderr } = await (0, import_execa.default)("npm", installArgs, {
1018
- cwd: buildersDir,
1019
- stdio: "pipe",
1020
- reject: true
926
+ var __toESM2 = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
927
+ // If the importer is in node compatibility mode or this is not an ESM
928
+ // file that has been converted to a CommonJS file using a Babel-
929
+ // compatible transform (i.e. "__esModule" has not been set), then set
930
+ // "default" to the CommonJS "module.exports" for node compatibility.
931
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
932
+ mod
933
+ ));
934
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
935
+ var import_builders_exports = {};
936
+ __export2(import_builders_exports, {
937
+ createImportBuilders: () => createImportBuilders2,
938
+ formatResolvedBuilders: () => formatResolvedBuilders2,
939
+ getBuildersDir: () => getBuildersDir2
1021
940
  });
1022
- stderr.split("/\r?\n/").filter((line) => line.includes("npm WARN deprecated")).forEach((line) => {
1023
- output_manager_default.warn(line);
1024
- });
1025
- } catch (err) {
1026
- if ((0, import_error_utils.isError)(err)) {
1027
- const execaMessage = err.message;
1028
- let message = getErrorMessage(err, execaMessage);
1029
- if (execaMessage.startsWith("Command failed with ENOENT")) {
1030
- message = `Please install ${cmd("npm")} before continuing`;
1031
- } else {
1032
- const notFound = /GET (.*) - Not found/.exec(message);
1033
- if (notFound) {
1034
- const url = new URL(notFound[1]);
1035
- const packagePath = decodeURIComponent(url.pathname);
1036
- const packageName = /(@[^/]+\/[^/]+)$/.exec(packagePath)?.[1] ?? packagePath.split("/").filter(Boolean).at(-1) ?? packagePath;
1037
- message = `The package ${code(
1038
- packageName
1039
- )} is not published on the npm registry`;
941
+ module.exports = __toCommonJS(import_builders_exports);
942
+ var import_npm_package_arg = __toESM2(require_npa());
943
+ var import_semver = require_semver();
944
+ var import_path = __require("path");
945
+ var import_fs_extra = require_lib();
946
+ var import_fs_detectors = require_dist2();
947
+ var import_error_utils = require_dist();
948
+ function isRemoteBuilderPin(pin) {
949
+ return /^https?:\/\//i.test(pin);
950
+ }
951
+ function isBareSpec(parsed) {
952
+ return parsed.type === "tag" && parsed.rawSpec === "";
953
+ }
954
+ function formatResolvedBuilders2(builders) {
955
+ return Array.from(
956
+ builders.values(),
957
+ (b) => b.pkgPath ? `${b.pkg.name}@${b.pkg.version}=${(0, import_path.dirname)(b.pkgPath)}` : `${b.pkg.name}=built-in`
958
+ ).join(",");
959
+ }
960
+ function pinBuilderSpecs(specs, pins) {
961
+ const pinnedSpecs = /* @__PURE__ */ new Map();
962
+ for (const spec of specs) {
963
+ const parsed = (0, import_npm_package_arg.default)(spec);
964
+ if (parsed.name && isBareSpec(parsed)) {
965
+ const version2 = pins.get(parsed.name);
966
+ if (version2) {
967
+ pinnedSpecs.set(
968
+ spec,
969
+ isRemoteBuilderPin(version2) ? version2 : `${parsed.name}@${version2}`
970
+ );
971
+ }
1040
972
  }
1041
973
  }
1042
- err.message = message;
1043
- err.link = "https://vercel.link/builder-dependencies-install-failed";
974
+ return pinnedSpecs;
1044
975
  }
1045
- throw err;
1046
- }
1047
- const nowScopePath = join(buildersDir, "node_modules/@now");
1048
- await (0, import_fs_extra.mkdirp)(nowScopePath);
1049
- try {
1050
- await (0, import_fs_extra.symlink)("../@vercel/build-utils", join(nowScopePath, "build-utils"));
1051
- } catch (err) {
1052
- if (!(0, import_error_utils.isErrnoException)(err) || err.code !== "EEXIST") {
1053
- throw err;
976
+ function getBuildersDir2(cwd, vercelDir = ".vercel") {
977
+ const override = process.env.VERCEL_BUILDERS_DIR;
978
+ if (override) {
979
+ return (0, import_path.isAbsolute)(override) ? override : (0, import_path.resolve)(cwd, override);
980
+ }
981
+ return (0, import_path.join)(cwd, vercelDir, "builders");
1054
982
  }
1055
- }
1056
- const buildersPkg = await readJSONFile(buildersPkgPath);
1057
- if (buildersPkg instanceof CantParseJSONFile)
1058
- throw buildersPkg;
1059
- if (!buildersPkg) {
1060
- throw new Error(`Failed to load "${buildersPkgPath}"`);
1061
- }
1062
- for (const spec of buildersToAdd) {
1063
- for (const [name, version2] of Object.entries(
1064
- buildersPkg.dependencies || {}
1065
- )) {
1066
- if (version2 === spec) {
1067
- output_manager_default.debug(`Resolved Builder spec "${spec}" to name "${name}"`);
1068
- resolvedSpecs.set(spec, name);
983
+ function createImportBuilders2(dependencies) {
984
+ const {
985
+ debug,
986
+ installBuilders: installBuilders2,
987
+ isNativeBinaryInstall: isNativeBinaryInstall2,
988
+ require: require2,
989
+ staticBuilder,
990
+ vercelDir
991
+ } = dependencies;
992
+ const builderPins = /* @__PURE__ */ new Map();
993
+ for (const [name, version2] of Object.entries(dependencies.builderPins)) {
994
+ if ((0, import_semver.validRange)(version2) || isRemoteBuilderPin(version2)) {
995
+ builderPins.set(name, version2);
996
+ }
1069
997
  }
998
+ const resolveDependencies = {
999
+ builderPins,
1000
+ debug,
1001
+ isNativeBinaryInstall: isNativeBinaryInstall2,
1002
+ require: require2,
1003
+ staticBuilder
1004
+ };
1005
+ return async function importBuilders2(builderSpecs, cwd, span) {
1006
+ const buildersDir = getBuildersDir2(cwd, vercelDir);
1007
+ let importResult = await resolveBuilders(
1008
+ buildersDir,
1009
+ builderSpecs,
1010
+ resolveDependencies
1011
+ );
1012
+ if ("buildersToAdd" in importResult) {
1013
+ const { buildersToAdd, installReasons } = importResult;
1014
+ const pinnedSpecs = pinBuilderSpecs(buildersToAdd, builderPins);
1015
+ const installResult = await installBuilders2(
1016
+ buildersDir,
1017
+ new Set(
1018
+ Array.from(buildersToAdd, (spec) => pinnedSpecs.get(spec) ?? spec)
1019
+ ),
1020
+ span,
1021
+ installReasons,
1022
+ pinnedSpecs
1023
+ );
1024
+ const allowedPinDriftSpecs = new Set(
1025
+ Array.from(pinnedSpecs.keys()).filter((spec) => installResult.has(spec))
1026
+ );
1027
+ importResult = await resolveBuilders(
1028
+ buildersDir,
1029
+ builderSpecs,
1030
+ resolveDependencies,
1031
+ installResult,
1032
+ allowedPinDriftSpecs
1033
+ );
1034
+ if ("buildersToAdd" in importResult) {
1035
+ const { buildersToAdd: failed, installReasons: reasons } = importResult;
1036
+ const failures = Array.from(failed, (spec) => {
1037
+ const reason = reasons.get(spec);
1038
+ return reason ? `${spec} (${reason})` : spec;
1039
+ });
1040
+ const err = new Error(
1041
+ `Failed to load Builders after installing them: ${failures.join(
1042
+ ", "
1043
+ )}. Retry the build. If the failure persists, contact Vercel Support.`
1044
+ );
1045
+ Object.assign(err, {
1046
+ link: "https://vercel.link/builder-dependencies-install-failed"
1047
+ });
1048
+ throw err;
1049
+ }
1050
+ }
1051
+ const resolvedBuildersDebug = [];
1052
+ for (const [spec, builderSpec] of importResult.builders) {
1053
+ resolvedBuildersDebug.push(`${spec} => ${builderSpec.pkg.version}`);
1054
+ }
1055
+ debug(`Resolved builders: "${resolvedBuildersDebug.join(", ")}"`);
1056
+ return importResult.builders;
1057
+ };
1070
1058
  }
1071
- }
1072
- return resolvedSpecs;
1073
- }
1074
- async function installBuilders(buildersDir, buildersToAdd, span, installReasons, pinnedSpecs) {
1075
- const install = async () => {
1076
- try {
1077
- return await untracedInstallBuilders(buildersDir, buildersToAdd);
1078
- } catch (err) {
1079
- if (!pinnedSpecs?.size) {
1080
- throw err;
1059
+ function missingModuleId(err) {
1060
+ const match = /Cannot find module '([^']+)'/.exec(err.message);
1061
+ const id = match?.[1];
1062
+ if (!id) {
1063
+ return void 0;
1064
+ }
1065
+ if (id.startsWith("/") || id.startsWith(".") || /^[A-Za-z]:[\\/]/.test(id)) {
1066
+ return void 0;
1081
1067
  }
1082
- const fallbackSpecs = new Set(
1083
- Array.from(buildersToAdd, (spec) => {
1084
- for (const [originalSpec, pinnedSpec] of pinnedSpecs) {
1085
- if (pinnedSpec === spec) {
1086
- return originalSpec;
1068
+ return id.replace(/[,=]/g, "_").slice(0, 100);
1069
+ }
1070
+ async function resolveBuilders(buildersDir, builderSpecs, dependencies, resolvedSpecs, allowedPinDriftSpecs) {
1071
+ const builders = /* @__PURE__ */ new Map();
1072
+ const buildersToAdd = /* @__PURE__ */ new Set();
1073
+ const installReasons = /* @__PURE__ */ new Map();
1074
+ for (const spec of builderSpecs) {
1075
+ const resolvedSpec = resolvedSpecs?.get(spec) || spec;
1076
+ const parsed = (0, import_npm_package_arg.default)(resolvedSpec);
1077
+ const { name } = parsed;
1078
+ if (!name) {
1079
+ buildersToAdd.add(spec);
1080
+ installReasons.set(spec, "url-spec");
1081
+ continue;
1082
+ }
1083
+ if ((0, import_fs_detectors.isStaticRuntime)(name)) {
1084
+ builders.set(name, {
1085
+ builder: dependencies.staticBuilder,
1086
+ pkg: { name },
1087
+ path: "",
1088
+ pkgPath: "",
1089
+ dynamicallyInstalled: false
1090
+ });
1091
+ continue;
1092
+ }
1093
+ let entrypointLoadFailed = false;
1094
+ try {
1095
+ let pkgPath;
1096
+ let builderPkg;
1097
+ try {
1098
+ pkgPath = (0, import_path.join)(buildersDir, "node_modules", name, "package.json");
1099
+ builderPkg = await (0, import_fs_extra.readJSON)(pkgPath);
1100
+ } catch (error) {
1101
+ if (!(0, import_error_utils.isErrnoException)(error)) {
1102
+ throw error;
1103
+ }
1104
+ if (error.code !== "ENOENT") {
1105
+ throw error;
1106
+ }
1107
+ if (dependencies.isNativeBinaryInstall()) {
1108
+ buildersToAdd.add(spec);
1109
+ installReasons.set(spec, "not-installed");
1110
+ continue;
1087
1111
  }
1112
+ pkgPath = dependencies.require.resolve(`${name}/package.json`);
1113
+ builderPkg = await (0, import_fs_extra.readJSON)(pkgPath);
1114
+ }
1115
+ if (!builderPkg || !pkgPath) {
1116
+ throw new Error(`Failed to load \`package.json\` for "${name}"`);
1117
+ }
1118
+ if (typeof builderPkg.version !== "string") {
1119
+ throw new Error(
1120
+ `\`package.json\` for "${name}" does not contain a "version" field`
1121
+ );
1122
+ }
1123
+ const peerVersion = dependencies.builderPins.get(name);
1124
+ if (isBareSpec(parsed) && peerVersion && (0, import_semver.valid)(peerVersion) && builderPkg.version !== peerVersion && !allowedPinDriftSpecs?.has(spec)) {
1125
+ dependencies.debug(
1126
+ `Resolved "${name}@${builderPkg.version}" does not match pin "${peerVersion}"`
1127
+ );
1128
+ buildersToAdd.add(spec);
1129
+ installReasons.set(spec, "pin-version-mismatch");
1130
+ continue;
1131
+ }
1132
+ if (isBareSpec(parsed) && peerVersion && isRemoteBuilderPin(peerVersion) && pkgPath.startsWith(buildersDir)) {
1133
+ let installedSpec;
1134
+ try {
1135
+ const buildersPkg = await (0, import_fs_extra.readJSON)((0, import_path.join)(buildersDir, "package.json"));
1136
+ installedSpec = buildersPkg.dependencies?.[name];
1137
+ } catch (error) {
1138
+ if (!(0, import_error_utils.isErrnoException)(error) || error.code !== "ENOENT") {
1139
+ throw error;
1140
+ }
1141
+ }
1142
+ if (installedSpec !== peerVersion) {
1143
+ dependencies.debug(
1144
+ `Installed source for "${name}@${builderPkg.version}" is "${installedSpec ?? "unknown"}", not pin "${peerVersion}"`
1145
+ );
1146
+ buildersToAdd.add(spec);
1147
+ installReasons.set(spec, "preview-pack-mismatch");
1148
+ continue;
1149
+ }
1150
+ }
1151
+ if (parsed.type === "version" && parsed.rawSpec !== builderPkg.version) {
1152
+ dependencies.debug(
1153
+ `Installed version "${name}@${builderPkg.version}" does not match "${parsed.rawSpec}"`
1154
+ );
1155
+ buildersToAdd.add(spec);
1156
+ installReasons.set(spec, "version-mismatch");
1157
+ continue;
1158
+ }
1159
+ if (parsed.type === "range" && !(0, import_semver.satisfies)(builderPkg.version, parsed.rawSpec)) {
1160
+ dependencies.debug(
1161
+ `Installed version "${name}@${builderPkg.version}" is not compatible with "${parsed.rawSpec}"`
1162
+ );
1163
+ buildersToAdd.add(spec);
1164
+ installReasons.set(spec, "range-mismatch");
1165
+ continue;
1166
+ }
1167
+ const path = (0, import_path.join)((0, import_path.dirname)(pkgPath), builderPkg.main || "index.js");
1168
+ let builder;
1169
+ try {
1170
+ builder = dependencies.require(path);
1171
+ } catch (requireErr) {
1172
+ entrypointLoadFailed = true;
1173
+ throw requireErr;
1174
+ }
1175
+ const dynamicallyInstalled = pkgPath.startsWith(buildersDir);
1176
+ builders.set(spec, {
1177
+ builder,
1178
+ pkg: {
1179
+ name,
1180
+ ...builderPkg
1181
+ },
1182
+ path,
1183
+ pkgPath,
1184
+ dynamicallyInstalled
1185
+ });
1186
+ dependencies.debug(
1187
+ `Imported Builder "${name}" from "${(0, import_path.dirname)(pkgPath)}"`
1188
+ );
1189
+ } catch (error) {
1190
+ if (!(error instanceof Error)) {
1191
+ throw error;
1192
+ }
1193
+ const err = error;
1194
+ if ((err.code === "MODULE_NOT_FOUND" || err.code === "ENOENT") && !resolvedSpecs) {
1195
+ dependencies.debug(`Failed to import "${name}": ${err}`);
1196
+ buildersToAdd.add(spec);
1197
+ if (entrypointLoadFailed) {
1198
+ const missing = missingModuleId(err);
1199
+ installReasons.set(
1200
+ spec,
1201
+ missing ? `entrypoint-load-failed:${missing}` : "entrypoint-load-failed"
1202
+ );
1203
+ } else {
1204
+ installReasons.set(spec, "not-installed");
1205
+ }
1206
+ } else {
1207
+ err.message = `Importing "${name}": ${err.message}`;
1208
+ throw err;
1088
1209
  }
1089
- return spec;
1090
- })
1091
- );
1092
- output_manager_default.warn(
1093
- "Could not install the Builder versions pinned by this Vercel CLI release. Retrying with versions allowed by your npm settings."
1094
- );
1095
- const resolvedSpecs = await untracedInstallBuilders(
1096
- buildersDir,
1097
- fallbackSpecs
1098
- );
1099
- for (const originalSpec of pinnedSpecs.keys()) {
1100
- if (fallbackSpecs.has(originalSpec)) {
1101
- resolvedSpecs.set(originalSpec, originalSpec);
1102
1210
  }
1103
1211
  }
1104
- return resolvedSpecs;
1212
+ if (buildersToAdd.size > 0) {
1213
+ return { buildersToAdd, installReasons };
1214
+ }
1215
+ return { builders };
1105
1216
  }
1106
- };
1107
- if (!span) {
1108
- return install();
1109
- }
1110
- const attributes = {
1111
- packages: Array.from(buildersToAdd).join(",")
1112
- };
1113
- if (installReasons && installReasons.size > 0) {
1114
- attributes.reasons = Array.from(installReasons).map(([spec, reason]) => `${spec}=${reason}`).join(",");
1115
- }
1116
- if (pinnedSpecs && pinnedSpecs.size > 0) {
1117
- attributes.pinned = "true";
1118
- attributes.pinnedPackages = Array.from(pinnedSpecs.values()).join(",");
1119
1217
  }
1120
- const installSpan = span.child("vc.installBuilders", attributes);
1121
- return installSpan.trace(async (s) => {
1122
- try {
1123
- return await install();
1124
- } catch (err) {
1125
- s.setAttributes({
1126
- error: (0, import_error_utils.isError)(err) ? err.message : String(err)
1127
- });
1128
- throw err;
1129
- }
1130
- });
1131
- }
1218
+ });
1132
1219
 
1133
- // src/util/build/import-builders.ts
1134
- var require_ = createRequire(__filename);
1135
- function isRemoteBuilderPin(pin) {
1136
- return /^https?:\/\//i.test(pin);
1137
- }
1138
- function getBuilderPins() {
1139
- const builderPins = /* @__PURE__ */ new Map();
1140
- const pins = pkg_default.builders ?? {};
1141
- for (const [name, version2] of Object.entries(pins)) {
1142
- if ((0, import_semver2.validRange)(version2) || isRemoteBuilderPin(version2)) {
1143
- builderPins.set(name, version2);
1144
- }
1145
- }
1146
- return builderPins;
1147
- }
1148
- function isBareSpec(parsed) {
1149
- return parsed.type === "tag" && parsed.rawSpec === "";
1150
- }
1151
- function formatResolvedBuilders(builders) {
1152
- return Array.from(
1153
- builders.values(),
1154
- (b) => b.pkgPath ? `${b.pkg.name}@${b.pkg.version}=${dirname(b.pkgPath)}` : `${b.pkg.name}=built-in`
1155
- ).join(",");
1156
- }
1157
- function pinBuilderSpecs(specs) {
1158
- const pins = getBuilderPins();
1159
- const pinnedSpecs = /* @__PURE__ */ new Map();
1160
- for (const spec of specs) {
1161
- const parsed = (0, import_npm_package_arg.default)(spec);
1162
- if (parsed.name && isBareSpec(parsed)) {
1163
- const version2 = pins.get(parsed.name);
1164
- if (version2) {
1165
- pinnedSpecs.set(
1166
- spec,
1167
- isRemoteBuilderPin(version2) ? version2 : `${parsed.name}@${version2}`
1168
- );
1220
+ // ../../internals/builder-orchestration/dist/static-builder.js
1221
+ var require_static_builder = __commonJS({
1222
+ "../../internals/builder-orchestration/dist/static-builder.js"(exports, module) {
1223
+ "use strict";
1224
+ var __create = Object.create;
1225
+ var __defProp = Object.defineProperty;
1226
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
1227
+ var __getOwnPropNames = Object.getOwnPropertyNames;
1228
+ var __getProtoOf = Object.getPrototypeOf;
1229
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
1230
+ var __export2 = (target, all) => {
1231
+ for (var name in all)
1232
+ __defProp(target, name, { get: all[name], enumerable: true });
1233
+ };
1234
+ var __copyProps = (to, from, except, desc) => {
1235
+ if (from && typeof from === "object" || typeof from === "function") {
1236
+ for (let key of __getOwnPropNames(from))
1237
+ if (!__hasOwnProp.call(to, key) && key !== except)
1238
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
1169
1239
  }
1240
+ return to;
1241
+ };
1242
+ var __toESM2 = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
1243
+ // If the importer is in node compatibility mode or this is not an ESM
1244
+ // file that has been converted to a CommonJS file using a Babel-
1245
+ // compatible transform (i.e. "__esModule" has not been set), then set
1246
+ // "default" to the CommonJS "module.exports" for node compatibility.
1247
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
1248
+ mod
1249
+ ));
1250
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
1251
+ var static_builder_exports2 = {};
1252
+ __export2(static_builder_exports2, {
1253
+ createStaticBuilder: () => createStaticBuilder2,
1254
+ version: () => version2
1255
+ });
1256
+ module.exports = __toCommonJS(static_builder_exports2);
1257
+ var import_minimatch = __toESM2(require_minimatch());
1258
+ var import_build_utils = __require("@vercel/build-utils");
1259
+ var version2 = 2;
1260
+ var ALWAYS_EXCLUDED_PREFIXES = [".git/", "node_modules/"];
1261
+ var DEFAULT_EXCLUDED_FILES = [
1262
+ ".gitignore",
1263
+ "package.json",
1264
+ "package-lock.json",
1265
+ "yarn.lock",
1266
+ "pnpm-lock.yaml",
1267
+ "bun.lock",
1268
+ "bun.lockb",
1269
+ "README.md"
1270
+ ];
1271
+ function createStaticBuilder2(vercelConfigExtensions) {
1272
+ const alwaysExcludedFiles = [
1273
+ "vercel.json",
1274
+ "vercel.toml",
1275
+ ...vercelConfigExtensions.map((ext) => `vercel.${ext}`),
1276
+ ".vercelignore",
1277
+ "now.json",
1278
+ ".nowignore"
1279
+ ];
1280
+ const build2 = async ({ entrypoint, files, config }) => {
1281
+ const output = {};
1282
+ const outputDirectory = config.zeroConfig ? config.outputDirectory : "";
1283
+ for (let [filename, fileFsRef] of Object.entries(files)) {
1284
+ if (ALWAYS_EXCLUDED_PREFIXES.some((prefix) => filename.startsWith(prefix)) || alwaysExcludedFiles.includes(filename) || DEFAULT_EXCLUDED_FILES.includes(filename) || filename.startsWith(".env")) {
1285
+ continue;
1286
+ }
1287
+ if (entrypoint && !(entrypoint === filename || (0, import_minimatch.default)(filename, entrypoint, { dot: true }))) {
1288
+ continue;
1289
+ }
1290
+ if (outputDirectory) {
1291
+ const outputMatch = outputDirectory + "/";
1292
+ if (filename.startsWith(outputMatch)) {
1293
+ filename = filename.slice(outputMatch.length);
1294
+ }
1295
+ }
1296
+ output[filename] = fileFsRef;
1297
+ }
1298
+ return { output };
1299
+ };
1300
+ const shouldServe2 = (_opts) => {
1301
+ const opts = { ..._opts };
1302
+ const {
1303
+ config: { zeroConfig, outputDirectory }
1304
+ } = opts;
1305
+ if (zeroConfig && outputDirectory) {
1306
+ opts.entrypoint = `${outputDirectory}/${opts.entrypoint}`;
1307
+ opts.requestPath = `${outputDirectory}/${opts.requestPath}`;
1308
+ }
1309
+ return (0, import_build_utils.shouldServe)(opts);
1310
+ };
1311
+ return { version: version2, build: build2, shouldServe: shouldServe2 };
1170
1312
  }
1171
1313
  }
1172
- return pinnedSpecs;
1173
- }
1174
- function getBuildersDir(cwd) {
1175
- const override = process.env.VERCEL_BUILDERS_DIR;
1176
- if (override) {
1177
- return isAbsolute(override) ? override : resolve(cwd, override);
1178
- }
1179
- return join2(cwd, VERCEL_DIR, "builders");
1180
- }
1181
- async function importBuilders(builderSpecs, cwd, span) {
1182
- const buildersDir = getBuildersDir(cwd);
1183
- let importResult = await resolveBuilders(buildersDir, builderSpecs);
1184
- if ("buildersToAdd" in importResult) {
1185
- const { buildersToAdd, installReasons } = importResult;
1186
- const pinnedSpecs = pinBuilderSpecs(buildersToAdd);
1187
- const installResult = await installBuilders(
1188
- buildersDir,
1189
- new Set(Array.from(buildersToAdd, (spec) => pinnedSpecs.get(spec) ?? spec)),
1190
- span,
1191
- installReasons,
1192
- pinnedSpecs
1193
- );
1194
- const allowedPinDriftSpecs = new Set(
1195
- Array.from(pinnedSpecs.keys()).filter((spec) => installResult.has(spec))
1196
- );
1197
- importResult = await resolveBuilders(
1198
- buildersDir,
1199
- builderSpecs,
1200
- installResult,
1201
- allowedPinDriftSpecs
1202
- );
1203
- if ("buildersToAdd" in importResult) {
1204
- const { buildersToAdd: failed, installReasons: reasons } = importResult;
1205
- const failures = Array.from(failed, (spec) => {
1206
- const reason = reasons.get(spec);
1207
- return reason ? `${spec} (${reason})` : spec;
1208
- });
1209
- const err = new Error(
1210
- `Failed to load Builders after installing them: ${failures.join(
1211
- ", "
1212
- )}. Retry the build. If the failure persists, contact Vercel Support.`
1213
- );
1214
- err.link = "https://vercel.link/builder-dependencies-install-failed";
1215
- throw err;
1216
- }
1217
- }
1218
- const resolvedBuildersDebug = [];
1219
- for (const [spec, builderSpec] of importResult.builders) {
1220
- resolvedBuildersDebug.push(`${spec} => ${builderSpec.pkg.version}`);
1221
- }
1222
- output_manager_default.debug(`Resolved builders: "${resolvedBuildersDebug.join(", ")}"`);
1223
- return importResult.builders;
1224
- }
1225
- function missingModuleId(err) {
1226
- const match = /Cannot find module '([^']+)'/.exec(err.message);
1227
- const id = match?.[1];
1228
- if (!id) {
1229
- return void 0;
1230
- }
1231
- if (id.startsWith("/") || id.startsWith(".") || /^[A-Za-z]:[\\/]/.test(id)) {
1232
- return void 0;
1233
- }
1234
- return id.replace(/[,=]/g, "_").slice(0, 100);
1235
- }
1236
- async function resolveBuilders(buildersDir, builderSpecs, resolvedSpecs, allowedPinDriftSpecs) {
1237
- const builders = /* @__PURE__ */ new Map();
1238
- const buildersToAdd = /* @__PURE__ */ new Set();
1239
- const installReasons = /* @__PURE__ */ new Map();
1240
- for (const spec of builderSpecs) {
1241
- const resolvedSpec = resolvedSpecs?.get(spec) || spec;
1242
- const parsed = (0, import_npm_package_arg.default)(resolvedSpec);
1243
- const { name } = parsed;
1244
- if (!name) {
1245
- buildersToAdd.add(spec);
1246
- installReasons.set(spec, "url-spec");
1247
- continue;
1248
- }
1249
- if ((0, import_fs_detectors.isStaticRuntime)(name)) {
1250
- builders.set(name, {
1251
- builder: static_builder_exports,
1252
- pkg: { name },
1253
- path: "",
1254
- pkgPath: "",
1255
- dynamicallyInstalled: false
1256
- });
1257
- continue;
1314
+ });
1315
+
1316
+ // ../../internals/builder-orchestration/dist/install-builders.js
1317
+ var require_install_builders = __commonJS({
1318
+ "../../internals/builder-orchestration/dist/install-builders.js"(exports, module) {
1319
+ "use strict";
1320
+ var __create = Object.create;
1321
+ var __defProp = Object.defineProperty;
1322
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
1323
+ var __getOwnPropNames = Object.getOwnPropertyNames;
1324
+ var __getProtoOf = Object.getPrototypeOf;
1325
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
1326
+ var __export2 = (target, all) => {
1327
+ for (var name in all)
1328
+ __defProp(target, name, { get: all[name], enumerable: true });
1329
+ };
1330
+ var __copyProps = (to, from, except, desc) => {
1331
+ if (from && typeof from === "object" || typeof from === "function") {
1332
+ for (let key of __getOwnPropNames(from))
1333
+ if (!__hasOwnProp.call(to, key) && key !== except)
1334
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
1335
+ }
1336
+ return to;
1337
+ };
1338
+ var __toESM2 = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
1339
+ // If the importer is in node compatibility mode or this is not an ESM
1340
+ // file that has been converted to a CommonJS file using a Babel-
1341
+ // compatible transform (i.e. "__esModule" has not been set), then set
1342
+ // "default" to the CommonJS "module.exports" for node compatibility.
1343
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
1344
+ mod
1345
+ ));
1346
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
1347
+ var install_builders_exports = {};
1348
+ __export2(install_builders_exports, {
1349
+ createInstallBuilders: () => createInstallBuilders2
1350
+ });
1351
+ module.exports = __toCommonJS(install_builders_exports);
1352
+ var import_url = __require("url");
1353
+ var import_pluralize = __toESM2(require_pluralize());
1354
+ var import_path = __require("path");
1355
+ var import_semver = require_semver();
1356
+ var import_fs_extra = require_lib();
1357
+ var import_error_utils = require_dist();
1358
+ function getErrorMessage(err, execaMessage) {
1359
+ if (!err || !("stderr" in err)) {
1360
+ return execaMessage;
1361
+ }
1362
+ if (typeof err.stderr === "string") {
1363
+ return err.stderr;
1364
+ }
1365
+ return execaMessage;
1258
1366
  }
1259
- let entrypointLoadFailed = false;
1260
- try {
1261
- let pkgPath;
1262
- let builderPkg;
1367
+ async function untracedInstallBuilders(buildersDir, buildersToAdd, dependencies) {
1368
+ const { buildUtilsVersion, code: code2, cmd: cmd2, output, readJSONFile: readJSONFile2, run } = dependencies;
1369
+ const resolvedSpecs = /* @__PURE__ */ new Map();
1370
+ const buildersPkgPath = (0, import_path.join)(buildersDir, "package.json");
1263
1371
  try {
1264
- pkgPath = join2(buildersDir, "node_modules", name, "package.json");
1265
- builderPkg = await (0, import_fs_extra2.readJSON)(pkgPath);
1372
+ const emptyPkgJson = {
1373
+ private: true,
1374
+ license: "UNLICENSED"
1375
+ };
1376
+ await (0, import_fs_extra.outputJSON)(buildersPkgPath, emptyPkgJson, {
1377
+ flag: "wx"
1378
+ });
1266
1379
  } catch (error) {
1267
- if (!(0, import_error_utils2.isErrnoException)(error)) {
1380
+ if (!(0, import_error_utils.isErrnoException)(error) || error.code !== "EEXIST")
1268
1381
  throw error;
1269
- }
1270
- if (error.code !== "ENOENT") {
1271
- throw error;
1272
- }
1273
- if (isNativeBinaryInstall()) {
1274
- buildersToAdd.add(spec);
1275
- installReasons.set(spec, "not-installed");
1276
- continue;
1277
- }
1278
- pkgPath = require_.resolve(`${name}/package.json`, {
1279
- paths: [__dirname]
1382
+ }
1383
+ output.log(
1384
+ `Installing ${(0, import_pluralize.default)("Builder", buildersToAdd.size)}: ${Array.from(
1385
+ buildersToAdd
1386
+ ).join(", ")}`
1387
+ );
1388
+ const buildUtilsSpec = buildUtilsVersion && (0, import_semver.validRange)(buildUtilsVersion) ? `@vercel/build-utils@${buildUtilsVersion}` : "@vercel/build-utils";
1389
+ const installArgs = ["install", buildUtilsSpec, ...buildersToAdd];
1390
+ try {
1391
+ const { stderr } = await run("npm", installArgs, {
1392
+ cwd: buildersDir,
1393
+ stdio: "pipe",
1394
+ reject: true
1280
1395
  });
1281
- builderPkg = await (0, import_fs_extra2.readJSON)(pkgPath);
1396
+ stderr.split("/\r?\n/").filter((line) => line.includes("npm WARN deprecated")).forEach((line) => {
1397
+ output.warn(line);
1398
+ });
1399
+ } catch (err) {
1400
+ if ((0, import_error_utils.isError)(err)) {
1401
+ const execaMessage = err.message;
1402
+ let message = getErrorMessage(err, execaMessage);
1403
+ if (execaMessage.startsWith("Command failed with ENOENT")) {
1404
+ message = `Please install ${cmd2("npm")} before continuing`;
1405
+ } else {
1406
+ const notFound = /GET (.*) - Not found/.exec(message);
1407
+ const notFoundUrl = notFound?.[1];
1408
+ if (notFoundUrl) {
1409
+ const url = new import_url.URL(notFoundUrl);
1410
+ const packagePath = decodeURIComponent(url.pathname);
1411
+ const packageName = /(@[^/]+\/[^/]+)$/.exec(packagePath)?.[1] ?? packagePath.split("/").filter(Boolean).at(-1) ?? packagePath;
1412
+ message = `The package ${code2(
1413
+ packageName
1414
+ )} is not published on the npm registry`;
1415
+ }
1416
+ }
1417
+ err.message = message;
1418
+ Object.assign(err, {
1419
+ link: "https://vercel.link/builder-dependencies-install-failed"
1420
+ });
1421
+ }
1422
+ throw err;
1282
1423
  }
1283
- if (!builderPkg || !pkgPath) {
1284
- throw new Error(`Failed to load \`package.json\` for "${name}"`);
1424
+ const nowScopePath = (0, import_path.join)(buildersDir, "node_modules/@now");
1425
+ await (0, import_fs_extra.mkdirp)(nowScopePath);
1426
+ try {
1427
+ await (0, import_fs_extra.symlink)("../@vercel/build-utils", (0, import_path.join)(nowScopePath, "build-utils"));
1428
+ } catch (err) {
1429
+ if (!(0, import_error_utils.isErrnoException)(err) || err.code !== "EEXIST") {
1430
+ throw err;
1431
+ }
1285
1432
  }
1286
- if (typeof builderPkg.version !== "string") {
1287
- throw new Error(
1288
- `\`package.json\` for "${name}" does not contain a "version" field`
1289
- );
1433
+ const buildersPkg = await readJSONFile2(buildersPkgPath);
1434
+ if (dependencies.isCantParseJSONFile(buildersPkg))
1435
+ throw buildersPkg;
1436
+ if (!buildersPkg) {
1437
+ throw new Error(`Failed to load "${buildersPkgPath}"`);
1290
1438
  }
1291
- const peerVersion = getBuilderPins().get(name);
1292
- if (isBareSpec(parsed) && peerVersion && (0, import_semver2.valid)(peerVersion) && builderPkg.version !== peerVersion && !allowedPinDriftSpecs?.has(spec)) {
1293
- output_manager_default.debug(
1294
- `Resolved "${name}@${builderPkg.version}" does not match pin "${peerVersion}"`
1295
- );
1296
- buildersToAdd.add(spec);
1297
- installReasons.set(spec, "pin-version-mismatch");
1298
- continue;
1439
+ for (const spec of buildersToAdd) {
1440
+ for (const [name, version2] of Object.entries(
1441
+ buildersPkg.dependencies || {}
1442
+ )) {
1443
+ if (version2 === spec) {
1444
+ output.debug(`Resolved Builder spec "${spec}" to name "${name}"`);
1445
+ resolvedSpecs.set(spec, name);
1446
+ }
1447
+ }
1299
1448
  }
1300
- if (isBareSpec(parsed) && peerVersion && isRemoteBuilderPin(peerVersion) && pkgPath.startsWith(buildersDir)) {
1301
- let installedSpec;
1302
- try {
1303
- const buildersPkg = await (0, import_fs_extra2.readJSON)(join2(buildersDir, "package.json"));
1304
- installedSpec = buildersPkg.dependencies?.[name];
1305
- } catch (error) {
1306
- if (!(0, import_error_utils2.isErrnoException)(error) || error.code !== "ENOENT") {
1307
- throw error;
1449
+ return resolvedSpecs;
1450
+ }
1451
+ function createInstallBuilders2(dependencies) {
1452
+ const { output } = dependencies;
1453
+ return async function installBuilders2(buildersDir, buildersToAdd, span, installReasons, pinnedSpecs) {
1454
+ const install = async () => {
1455
+ try {
1456
+ return await untracedInstallBuilders(
1457
+ buildersDir,
1458
+ buildersToAdd,
1459
+ dependencies
1460
+ );
1461
+ } catch (err) {
1462
+ if (!pinnedSpecs?.size) {
1463
+ throw err;
1464
+ }
1465
+ const fallbackSpecs = new Set(
1466
+ Array.from(buildersToAdd, (spec) => {
1467
+ for (const [originalSpec, pinnedSpec] of pinnedSpecs) {
1468
+ if (pinnedSpec === spec) {
1469
+ return originalSpec;
1470
+ }
1471
+ }
1472
+ return spec;
1473
+ })
1474
+ );
1475
+ output.warn(
1476
+ "Could not install the Builder versions pinned by this Vercel CLI release. Retrying with versions allowed by your npm settings."
1477
+ );
1478
+ const resolvedSpecs = await untracedInstallBuilders(
1479
+ buildersDir,
1480
+ fallbackSpecs,
1481
+ dependencies
1482
+ );
1483
+ for (const originalSpec of pinnedSpecs.keys()) {
1484
+ if (fallbackSpecs.has(originalSpec)) {
1485
+ resolvedSpecs.set(originalSpec, originalSpec);
1486
+ }
1487
+ }
1488
+ return resolvedSpecs;
1308
1489
  }
1490
+ };
1491
+ if (!span) {
1492
+ return install();
1309
1493
  }
1310
- if (installedSpec !== peerVersion) {
1311
- output_manager_default.debug(
1312
- `Installed source for "${name}@${builderPkg.version}" is "${installedSpec ?? "unknown"}", not pin "${peerVersion}"`
1313
- );
1314
- buildersToAdd.add(spec);
1315
- installReasons.set(spec, "preview-pack-mismatch");
1316
- continue;
1494
+ const attributes = {
1495
+ packages: Array.from(buildersToAdd).join(",")
1496
+ };
1497
+ if (installReasons && installReasons.size > 0) {
1498
+ attributes.reasons = Array.from(installReasons).map(([spec, reason]) => `${spec}=${reason}`).join(",");
1317
1499
  }
1318
- }
1319
- if (parsed.type === "version" && parsed.rawSpec !== builderPkg.version) {
1320
- output_manager_default.debug(
1321
- `Installed version "${name}@${builderPkg.version}" does not match "${parsed.rawSpec}"`
1322
- );
1323
- buildersToAdd.add(spec);
1324
- installReasons.set(spec, "version-mismatch");
1325
- continue;
1326
- }
1327
- if (parsed.type === "range" && !(0, import_semver2.satisfies)(builderPkg.version, parsed.rawSpec)) {
1328
- output_manager_default.debug(
1329
- `Installed version "${name}@${builderPkg.version}" is not compatible with "${parsed.rawSpec}"`
1330
- );
1331
- buildersToAdd.add(spec);
1332
- installReasons.set(spec, "range-mismatch");
1333
- continue;
1334
- }
1335
- const path = join2(dirname(pkgPath), builderPkg.main || "index.js");
1336
- let builder;
1337
- try {
1338
- builder = require_(path);
1339
- } catch (requireErr) {
1340
- entrypointLoadFailed = true;
1341
- throw requireErr;
1342
- }
1343
- const dynamicallyInstalled = pkgPath.startsWith(buildersDir);
1344
- builders.set(spec, {
1345
- builder,
1346
- pkg: {
1347
- name,
1348
- ...builderPkg
1349
- },
1350
- path,
1351
- pkgPath,
1352
- dynamicallyInstalled
1353
- });
1354
- output_manager_default.debug(`Imported Builder "${name}" from "${dirname(pkgPath)}"`);
1355
- } catch (err) {
1356
- if ((err.code === "MODULE_NOT_FOUND" || err.code === "ENOENT") && !resolvedSpecs) {
1357
- output_manager_default.debug(`Failed to import "${name}": ${err}`);
1358
- buildersToAdd.add(spec);
1359
- if (entrypointLoadFailed) {
1360
- const missing = missingModuleId(err);
1361
- installReasons.set(
1362
- spec,
1363
- missing ? `entrypoint-load-failed:${missing}` : "entrypoint-load-failed"
1364
- );
1365
- } else {
1366
- installReasons.set(spec, "not-installed");
1500
+ if (pinnedSpecs && pinnedSpecs.size > 0) {
1501
+ attributes.pinned = "true";
1502
+ attributes.pinnedPackages = Array.from(pinnedSpecs.values()).join(",");
1367
1503
  }
1368
- } else {
1369
- err.message = `Importing "${name}": ${err.message}`;
1370
- throw err;
1371
- }
1504
+ const installSpan = span.child("vc.installBuilders", attributes);
1505
+ return installSpan.trace(async (s) => {
1506
+ try {
1507
+ return await install();
1508
+ } catch (err) {
1509
+ s.setAttributes({
1510
+ error: (0, import_error_utils.isError)(err) ? err.message : String(err)
1511
+ });
1512
+ throw err;
1513
+ }
1514
+ });
1515
+ };
1372
1516
  }
1373
1517
  }
1374
- if (buildersToAdd.size > 0) {
1375
- return { buildersToAdd, installReasons };
1376
- }
1377
- return { builders };
1378
- }
1518
+ });
1519
+
1520
+ // src/builders/import-builders.ts
1521
+ var import_import_builders = __toESM(require_import_builders(), 1);
1522
+
1523
+ // src/builders/static-builder.ts
1524
+ var static_builder_exports = {};
1525
+ __export(static_builder_exports, {
1526
+ build: () => build,
1527
+ shouldServe: () => shouldServe,
1528
+ version: () => version
1529
+ });
1530
+ var import_static_builder = __toESM(require_static_builder(), 1);
1531
+ var { version, build, shouldServe } = (0, import_static_builder.createStaticBuilder)(
1532
+ VERCEL_CONFIG_EXTENSIONS
1533
+ );
1534
+
1535
+ // src/builders/install-builders.ts
1536
+ var import_install_builders = __toESM(require_install_builders(), 1);
1537
+ var import_execa = __toESM(require_execa(), 1);
1538
+ var installBuilders = (0, import_install_builders.createInstallBuilders)({
1539
+ buildUtilsVersion: pkg_default.dependencies?.["@vercel/build-utils"],
1540
+ code,
1541
+ cmd,
1542
+ isCantParseJSONFile: (value) => value instanceof CantParseJSONFile,
1543
+ output: output_manager_default,
1544
+ readJSONFile,
1545
+ run: import_execa.default
1546
+ });
1547
+
1548
+ // src/builders/import-builders.ts
1549
+ import { createRequire } from "module";
1550
+ var require_ = createRequire(__filename);
1551
+ var importBuilders = (0, import_import_builders.createImportBuilders)({
1552
+ builderPins: pkg_default.builders ?? {},
1553
+ debug: (message) => output_manager_default.debug(message),
1554
+ installBuilders,
1555
+ isNativeBinaryInstall,
1556
+ require: require_,
1557
+ staticBuilder: static_builder_exports,
1558
+ vercelDir: VERCEL_DIR
1559
+ });
1379
1560
 
1380
1561
  export {
1381
1562
  require_npa,
1382
- formatResolvedBuilders,
1383
- getBuildersDir,
1563
+ import_import_builders,
1384
1564
  importBuilders
1385
1565
  };