vercel 50.1.2 → 50.1.4

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 (2) hide show
  1. package/dist/index.js +383 -401
  2. package/package.json +18 -18
package/dist/index.js CHANGED
@@ -50100,7 +50100,7 @@ var require_package = __commonJS2({
50100
50100
  "../client/package.json"(exports2, module2) {
50101
50101
  module2.exports = {
50102
50102
  name: "@vercel/client",
50103
- version: "17.2.17",
50103
+ version: "17.2.18",
50104
50104
  main: "dist/index.js",
50105
50105
  typings: "dist/index.d.ts",
50106
50106
  homepage: "https://vercel.com",
@@ -82995,6 +82995,7 @@ var require_detect_builders = __commonJS2({
82995
82995
  var import_path43 = require("path");
82996
82996
  var import_frameworks8 = __toESM4(require_frameworks());
82997
82997
  var import_is_official_runtime = require_is_official_runtime();
82998
+ var import_build_utils19 = require("@vercel/build-utils");
82998
82999
  var REGEX_MIDDLEWARE_FILES = "middleware.[jt]s";
82999
83000
  var REGEX_VERCEL_PLATFORM_FILES = `api/**,package.json,${REGEX_MIDDLEWARE_FILES}`;
83000
83001
  var REGEX_NON_VERCEL_PLATFORM_FILES2 = `!{${REGEX_VERCEL_PLATFORM_FILES}}`;
@@ -83079,7 +83080,7 @@ var require_detect_builders = __commonJS2({
83079
83080
  const apiRoutes = [];
83080
83081
  const dynamicRoutes = [];
83081
83082
  for (const fileName of sortedFiles) {
83082
- const apiBuilder = maybeGetApiBuilder(fileName, apiMatches, options);
83083
+ const apiBuilder = await maybeGetApiBuilder(fileName, apiMatches, options);
83083
83084
  if (apiBuilder) {
83084
83085
  const { routeError, apiRoute, isDynamic } = getApiRoute(
83085
83086
  fileName,
@@ -83226,7 +83227,7 @@ var require_detect_builders = __commonJS2({
83226
83227
  errorRoutes: routesResult.errorRoutes
83227
83228
  };
83228
83229
  }
83229
- function maybeGetApiBuilder(fileName, apiMatches, options) {
83230
+ async function maybeGetApiBuilder(fileName, apiMatches, options) {
83230
83231
  const middleware = fileName === "middleware.js" || fileName === "middleware.ts";
83231
83232
  if (middleware && options.projectSettings?.framework === "nextjs") {
83232
83233
  return null;
@@ -83246,6 +83247,13 @@ var require_detect_builders = __commonJS2({
83246
83247
  if (fileName.endsWith(".d.ts")) {
83247
83248
  return null;
83248
83249
  }
83250
+ if (fileName.endsWith(".py") && options.workPath) {
83251
+ const fsPath = (0, import_path43.join)(options.workPath, fileName);
83252
+ const isEntrypoint = await (0, import_build_utils19.isPythonEntrypoint)({ fsPath });
83253
+ if (!isEntrypoint) {
83254
+ return null;
83255
+ }
83256
+ }
83249
83257
  const match = apiMatches.find(({ src = "**" }) => {
83250
83258
  return src === fileName || (0, import_minimatch5.default)(fileName, src);
83251
83259
  });
@@ -92321,12 +92329,10 @@ function getLocalPathConfig(prefix) {
92321
92329
  if (nowConfigExists && vercelConfigExists) {
92322
92330
  throw new ConflictingConfigFiles([vercelConfigPath, nowConfigPath]);
92323
92331
  }
92324
- if (process.env.VERCEL_TS_CONFIG_ENABLED) {
92325
- const compiledConfigPath = import_path10.default.join(prefix, VERCEL_DIR, "vercel.json");
92326
- const compiledConfigExists = (0, import_fs4.existsSync)(compiledConfigPath);
92327
- if (compiledConfigExists) {
92328
- return compiledConfigPath;
92329
- }
92332
+ const compiledConfigPath = import_path10.default.join(prefix, VERCEL_DIR, "vercel.json");
92333
+ const compiledConfigExists = (0, import_fs4.existsSync)(compiledConfigPath);
92334
+ if (compiledConfigExists) {
92335
+ return compiledConfigPath;
92330
92336
  }
92331
92337
  if (nowConfigExists) {
92332
92338
  return nowConfigPath;
@@ -92346,6 +92352,318 @@ var init_local_path = __esm({
92346
92352
  }
92347
92353
  });
92348
92354
 
92355
+ // ../../node_modules/.pnpm/dotenv@4.0.0/node_modules/dotenv/lib/main.js
92356
+ var require_main = __commonJS2({
92357
+ "../../node_modules/.pnpm/dotenv@4.0.0/node_modules/dotenv/lib/main.js"(exports2, module2) {
92358
+ "use strict";
92359
+ var fs15 = require("fs");
92360
+ function parse11(src) {
92361
+ var obj = {};
92362
+ src.toString().split("\n").forEach(function(line) {
92363
+ var keyValueArr = line.match(/^\s*([\w\.\-]+)\s*=\s*(.*)?\s*$/);
92364
+ if (keyValueArr != null) {
92365
+ var key = keyValueArr[1];
92366
+ var value = keyValueArr[2] ? keyValueArr[2] : "";
92367
+ var len = value ? value.length : 0;
92368
+ if (len > 0 && value.charAt(0) === '"' && value.charAt(len - 1) === '"') {
92369
+ value = value.replace(/\\n/gm, "\n");
92370
+ }
92371
+ value = value.replace(/(^['"]|['"]$)/g, "").trim();
92372
+ obj[key] = value;
92373
+ }
92374
+ });
92375
+ return obj;
92376
+ }
92377
+ function config2(options) {
92378
+ var path11 = ".env";
92379
+ var encoding = "utf8";
92380
+ if (options) {
92381
+ if (options.path) {
92382
+ path11 = options.path;
92383
+ }
92384
+ if (options.encoding) {
92385
+ encoding = options.encoding;
92386
+ }
92387
+ }
92388
+ try {
92389
+ var parsedObj = parse11(fs15.readFileSync(path11, { encoding }));
92390
+ Object.keys(parsedObj).forEach(function(key) {
92391
+ process.env[key] = process.env[key] || parsedObj[key];
92392
+ });
92393
+ return { parsed: parsedObj };
92394
+ } catch (e2) {
92395
+ return { error: e2 };
92396
+ }
92397
+ }
92398
+ module2.exports.config = config2;
92399
+ module2.exports.load = config2;
92400
+ module2.exports.parse = parse11;
92401
+ }
92402
+ });
92403
+
92404
+ // src/util/compile-vercel-config.ts
92405
+ var compile_vercel_config_exports = {};
92406
+ __export3(compile_vercel_config_exports, {
92407
+ DEFAULT_VERCEL_CONFIG_FILENAME: () => DEFAULT_VERCEL_CONFIG_FILENAME,
92408
+ VERCEL_CONFIG_EXTENSIONS: () => VERCEL_CONFIG_EXTENSIONS,
92409
+ compileVercelConfig: () => compileVercelConfig,
92410
+ findSourceVercelConfigFile: () => findSourceVercelConfigFile,
92411
+ getVercelConfigPath: () => getVercelConfigPath
92412
+ });
92413
+ async function fileExists(filePath) {
92414
+ try {
92415
+ await (0, import_promises.access)(filePath);
92416
+ return true;
92417
+ } catch {
92418
+ return false;
92419
+ }
92420
+ }
92421
+ async function findAllVercelConfigFiles(workPath) {
92422
+ const foundFiles = [];
92423
+ for (const ext of VERCEL_CONFIG_EXTENSIONS) {
92424
+ const configPath = (0, import_path11.join)(workPath, `vercel.${ext}`);
92425
+ if (await fileExists(configPath)) {
92426
+ foundFiles.push(configPath);
92427
+ }
92428
+ }
92429
+ return foundFiles;
92430
+ }
92431
+ async function findSourceVercelConfigFile(workPath) {
92432
+ for (const ext of VERCEL_CONFIG_EXTENSIONS) {
92433
+ const configPath = (0, import_path11.join)(workPath, `vercel.${ext}`);
92434
+ if (await fileExists(configPath)) {
92435
+ return (0, import_path11.basename)(configPath);
92436
+ }
92437
+ }
92438
+ return null;
92439
+ }
92440
+ async function findVercelConfigFile(workPath) {
92441
+ const foundFiles = await findAllVercelConfigFiles(workPath);
92442
+ if (foundFiles.length > 1) {
92443
+ throw new ConflictingConfigFiles(
92444
+ foundFiles,
92445
+ "Multiple vercel config files found. Please use only one configuration file.",
92446
+ "https://vercel.com/docs/projects/project-configuration"
92447
+ );
92448
+ }
92449
+ return foundFiles[0] || null;
92450
+ }
92451
+ function parseConfigLoaderError(stderr) {
92452
+ if (!stderr.trim()) {
92453
+ return "";
92454
+ }
92455
+ const moduleNotFoundMatch = stderr.match(
92456
+ /Error \[ERR_MODULE_NOT_FOUND\]: Cannot find package '([^']+)'/
92457
+ );
92458
+ if (moduleNotFoundMatch) {
92459
+ const packageName2 = moduleNotFoundMatch[1];
92460
+ return `Cannot find package '${packageName2}'. Make sure it's installed in your project dependencies.`;
92461
+ }
92462
+ const syntaxErrorMatch = stderr.match(/SyntaxError: (.+?)(?:\n|$)/);
92463
+ if (syntaxErrorMatch) {
92464
+ return `Syntax error: ${syntaxErrorMatch[1]}`;
92465
+ }
92466
+ const errorMatch = stderr.match(
92467
+ /^(?:Error|TypeError|ReferenceError): (.+?)(?:\n|$)/m
92468
+ );
92469
+ if (errorMatch) {
92470
+ return errorMatch[1];
92471
+ }
92472
+ return stderr.trim();
92473
+ }
92474
+ async function compileVercelConfig(workPath) {
92475
+ const vercelJsonPath = (0, import_path11.join)(workPath, "vercel.json");
92476
+ const nowJsonPath = (0, import_path11.join)(workPath, "now.json");
92477
+ const hasVercelJson = await fileExists(vercelJsonPath);
92478
+ const hasNowJson = await fileExists(nowJsonPath);
92479
+ if (hasVercelJson && hasNowJson) {
92480
+ throw new ConflictingConfigFiles([vercelJsonPath, nowJsonPath]);
92481
+ }
92482
+ const vercelConfigPath = await findVercelConfigFile(workPath);
92483
+ const vercelDir = (0, import_path11.join)(workPath, VERCEL_DIR);
92484
+ const compiledConfigPath = (0, import_path11.join)(vercelDir, "vercel.json");
92485
+ if (vercelConfigPath && hasNowJson) {
92486
+ throw new ConflictingConfigFiles(
92487
+ [vercelConfigPath, nowJsonPath],
92488
+ `Both ${(0, import_path11.basename)(vercelConfigPath)} and now.json exist in your project. Please use only one configuration method.`,
92489
+ "https://vercel.com/docs/projects/project-configuration"
92490
+ );
92491
+ }
92492
+ if (vercelConfigPath && hasVercelJson) {
92493
+ throw new ConflictingConfigFiles(
92494
+ [vercelConfigPath, vercelJsonPath],
92495
+ `Both ${(0, import_path11.basename)(vercelConfigPath)} and vercel.json exist in your project. Please use only one configuration method.`,
92496
+ "https://vercel.com/docs/projects/project-configuration"
92497
+ );
92498
+ }
92499
+ if (!vercelConfigPath) {
92500
+ if (hasVercelJson) {
92501
+ return {
92502
+ configPath: vercelJsonPath,
92503
+ wasCompiled: false
92504
+ };
92505
+ }
92506
+ if (hasNowJson) {
92507
+ return {
92508
+ configPath: nowJsonPath,
92509
+ wasCompiled: false
92510
+ };
92511
+ }
92512
+ if (await fileExists(compiledConfigPath)) {
92513
+ return {
92514
+ configPath: compiledConfigPath,
92515
+ wasCompiled: true,
92516
+ sourceFile: await findSourceVercelConfigFile(workPath) ?? void 0
92517
+ };
92518
+ }
92519
+ return {
92520
+ configPath: null,
92521
+ wasCompiled: false
92522
+ };
92523
+ }
92524
+ (0, import_dotenv.config)({ path: (0, import_path11.join)(workPath, ".env") });
92525
+ (0, import_dotenv.config)({ path: (0, import_path11.join)(workPath, ".env.local") });
92526
+ const tempOutPath = (0, import_path11.join)(vercelDir, "vercel-temp.mjs");
92527
+ const loaderPath = (0, import_path11.join)(vercelDir, "vercel-loader.mjs");
92528
+ try {
92529
+ const { build: build2 } = await import("esbuild");
92530
+ await (0, import_promises.mkdir)(vercelDir, { recursive: true });
92531
+ await build2({
92532
+ entryPoints: [vercelConfigPath],
92533
+ bundle: true,
92534
+ platform: "node",
92535
+ format: "esm",
92536
+ outfile: tempOutPath,
92537
+ packages: "external",
92538
+ target: "node20",
92539
+ sourcemap: "inline"
92540
+ });
92541
+ const loaderScript = `
92542
+ import { pathToFileURL } from 'url';
92543
+ const configModule = await import(pathToFileURL(process.argv[2]).href);
92544
+ const config = ('default' in configModule) ? configModule.default : ('config' in configModule) ? configModule.config : configModule;
92545
+ process.send(config);
92546
+ `;
92547
+ await (0, import_promises.writeFile)(loaderPath, loaderScript, "utf-8");
92548
+ const config2 = await new Promise((resolve13, reject) => {
92549
+ const child = (0, import_child_process3.fork)(loaderPath, [tempOutPath], {
92550
+ stdio: ["pipe", "pipe", "pipe", "ipc"]
92551
+ });
92552
+ let stderrOutput = "";
92553
+ let stdoutOutput = "";
92554
+ if (child.stderr) {
92555
+ child.stderr.on("data", (data) => {
92556
+ stderrOutput += data.toString();
92557
+ });
92558
+ }
92559
+ if (child.stdout) {
92560
+ child.stdout.on("data", (data) => {
92561
+ stdoutOutput += data.toString();
92562
+ });
92563
+ }
92564
+ const timeout = setTimeout(() => {
92565
+ child.kill();
92566
+ reject(new Error("Config loader timed out after 10 seconds"));
92567
+ }, 1e4);
92568
+ child.on("message", (message2) => {
92569
+ clearTimeout(timeout);
92570
+ child.kill();
92571
+ resolve13(message2);
92572
+ });
92573
+ child.on("error", (err) => {
92574
+ clearTimeout(timeout);
92575
+ reject(err);
92576
+ });
92577
+ child.on("exit", (code2) => {
92578
+ clearTimeout(timeout);
92579
+ if (code2 !== 0) {
92580
+ if (stderrOutput.trim()) {
92581
+ output_manager_default.log(stderrOutput);
92582
+ }
92583
+ if (stdoutOutput.trim()) {
92584
+ output_manager_default.log(stdoutOutput);
92585
+ }
92586
+ const parsedError = parseConfigLoaderError(stderrOutput);
92587
+ if (parsedError) {
92588
+ reject(new Error(parsedError));
92589
+ } else if (stdoutOutput.trim()) {
92590
+ reject(new Error(stdoutOutput.trim()));
92591
+ } else {
92592
+ reject(new Error(`Config loader exited with code ${code2}`));
92593
+ }
92594
+ }
92595
+ });
92596
+ });
92597
+ await (0, import_promises.writeFile)(
92598
+ compiledConfigPath,
92599
+ JSON.stringify(config2, null, 2),
92600
+ "utf-8"
92601
+ );
92602
+ output_manager_default.debug(`Compiled ${vercelConfigPath} -> ${compiledConfigPath}`);
92603
+ return {
92604
+ configPath: compiledConfigPath,
92605
+ wasCompiled: true,
92606
+ sourceFile: await findSourceVercelConfigFile(workPath) ?? void 0
92607
+ };
92608
+ } catch (error3) {
92609
+ throw new import_build_utils5.NowBuildError({
92610
+ code: "vercel_ts_compilation_failed",
92611
+ message: `Failed to compile ${vercelConfigPath}: ${error3.message}`,
92612
+ link: "https://vercel.com/docs/projects/project-configuration"
92613
+ });
92614
+ } finally {
92615
+ await Promise.all([
92616
+ (0, import_promises.unlink)(tempOutPath).catch((err) => {
92617
+ if (err.code !== "ENOENT") {
92618
+ output_manager_default.debug(`Failed to cleanup temp file: ${err}`);
92619
+ }
92620
+ }),
92621
+ (0, import_promises.unlink)(loaderPath).catch((err) => {
92622
+ if (err.code !== "ENOENT") {
92623
+ output_manager_default.debug(`Failed to cleanup loader file: ${err}`);
92624
+ }
92625
+ })
92626
+ ]);
92627
+ }
92628
+ }
92629
+ async function getVercelConfigPath(workPath) {
92630
+ const vercelJsonPath = (0, import_path11.join)(workPath, "vercel.json");
92631
+ const nowJsonPath = (0, import_path11.join)(workPath, "now.json");
92632
+ const compiledConfigPath = (0, import_path11.join)(workPath, VERCEL_DIR, "vercel.json");
92633
+ if (await fileExists(vercelJsonPath)) {
92634
+ return vercelJsonPath;
92635
+ }
92636
+ if (await fileExists(nowJsonPath)) {
92637
+ return nowJsonPath;
92638
+ }
92639
+ if (await fileExists(compiledConfigPath)) {
92640
+ return compiledConfigPath;
92641
+ }
92642
+ return nowJsonPath;
92643
+ }
92644
+ var import_promises, import_path11, import_child_process3, import_dotenv, import_build_utils5, VERCEL_CONFIG_EXTENSIONS, DEFAULT_VERCEL_CONFIG_FILENAME;
92645
+ var init_compile_vercel_config = __esm({
92646
+ "src/util/compile-vercel-config.ts"() {
92647
+ "use strict";
92648
+ import_promises = require("fs/promises");
92649
+ import_path11 = require("path");
92650
+ import_child_process3 = require("child_process");
92651
+ import_dotenv = __toESM3(require_main());
92652
+ init_output_manager();
92653
+ import_build_utils5 = require("@vercel/build-utils");
92654
+ init_link2();
92655
+ init_errors_ts();
92656
+ VERCEL_CONFIG_EXTENSIONS = [
92657
+ "ts",
92658
+ "mts",
92659
+ "js",
92660
+ "mjs",
92661
+ "cjs"
92662
+ ];
92663
+ DEFAULT_VERCEL_CONFIG_FILENAME = "Vercel config";
92664
+ }
92665
+ });
92666
+
92349
92667
  // src/util/config/files.ts
92350
92668
  function getConfigFilePath() {
92351
92669
  return CONFIG_FILE_PATH;
@@ -92389,31 +92707,30 @@ function readLocalConfig(prefix = process.cwd()) {
92389
92707
  if (!config2) {
92390
92708
  return;
92391
92709
  }
92392
- const isCompiledConfig = process.env.VERCEL_TS_CONFIG_ENABLED && (0, import_path11.basename)(target) === "vercel.json" && (0, import_path11.basename)((0, import_path11.dirname)(target)) === VERCEL_DIR;
92710
+ const isCompiledConfig = (0, import_path12.basename)(target) === "vercel.json" && (0, import_path12.basename)((0, import_path12.dirname)(target)) === VERCEL_DIR;
92393
92711
  if (isCompiledConfig) {
92394
- const workPath = (0, import_path11.dirname)((0, import_path11.dirname)(target));
92395
- const VERCEL_CONFIG_EXTENSIONS2 = ["ts", "mts", "js", "mjs", "cjs"];
92712
+ const workPath = (0, import_path12.dirname)((0, import_path12.dirname)(target));
92396
92713
  let sourceFile = null;
92397
- for (const ext of VERCEL_CONFIG_EXTENSIONS2) {
92398
- const configPath = (0, import_path11.join)(workPath, `vercel.${ext}`);
92714
+ for (const ext of VERCEL_CONFIG_EXTENSIONS) {
92715
+ const configPath = (0, import_path12.join)(workPath, `vercel.${ext}`);
92399
92716
  try {
92400
92717
  (0, import_fs5.accessSync)(configPath, import_fs5.constants.F_OK);
92401
- sourceFile = (0, import_path11.basename)(configPath);
92718
+ sourceFile = (0, import_path12.basename)(configPath);
92402
92719
  break;
92403
92720
  } catch {
92404
92721
  }
92405
92722
  }
92406
- config2[import_client.fileNameSymbol] = sourceFile || "vercel.ts";
92723
+ config2[import_client.fileNameSymbol] = sourceFile || DEFAULT_VERCEL_CONFIG_FILENAME;
92407
92724
  } else {
92408
- config2[import_client.fileNameSymbol] = (0, import_path11.basename)(target);
92725
+ config2[import_client.fileNameSymbol] = (0, import_path12.basename)(target);
92409
92726
  }
92410
92727
  return config2;
92411
92728
  }
92412
- var import_path11, import_load_json_file, import_write_json_file, import_fs5, import_client, import_error_utils6, VERCEL_DIR2, CONFIG_FILE_PATH, AUTH_CONFIG_FILE_PATH, readConfigFile, writeToConfigFile, readAuthConfigFile, writeToAuthConfigFile;
92729
+ var import_path12, import_load_json_file, import_write_json_file, import_fs5, import_client, import_error_utils6, VERCEL_DIR2, CONFIG_FILE_PATH, AUTH_CONFIG_FILE_PATH, readConfigFile, writeToConfigFile, readAuthConfigFile, writeToAuthConfigFile;
92413
92730
  var init_files = __esm({
92414
92731
  "src/util/config/files.ts"() {
92415
92732
  "use strict";
92416
- import_path11 = require("path");
92733
+ import_path12 = require("path");
92417
92734
  import_load_json_file = __toESM3(require_load_json_file());
92418
92735
  import_write_json_file = __toESM3(require_write_json_file());
92419
92736
  import_fs5 = require("fs");
@@ -92424,10 +92741,11 @@ var init_files = __esm({
92424
92741
  init_highlight();
92425
92742
  import_error_utils6 = __toESM3(require_dist2());
92426
92743
  init_link2();
92744
+ init_compile_vercel_config();
92427
92745
  init_output_manager();
92428
92746
  VERCEL_DIR2 = global_path_default();
92429
- CONFIG_FILE_PATH = (0, import_path11.join)(VERCEL_DIR2, "config.json");
92430
- AUTH_CONFIG_FILE_PATH = (0, import_path11.join)(VERCEL_DIR2, "auth.json");
92747
+ CONFIG_FILE_PATH = (0, import_path12.join)(VERCEL_DIR2, "config.json");
92748
+ AUTH_CONFIG_FILE_PATH = (0, import_path12.join)(VERCEL_DIR2, "auth.json");
92431
92749
  readConfigFile = () => {
92432
92750
  const config2 = import_load_json_file.default.sync(CONFIG_FILE_PATH);
92433
92751
  return config2;
@@ -92838,315 +93156,6 @@ var init_read_json_file = __esm({
92838
93156
  }
92839
93157
  });
92840
93158
 
92841
- // ../../node_modules/.pnpm/dotenv@4.0.0/node_modules/dotenv/lib/main.js
92842
- var require_main = __commonJS2({
92843
- "../../node_modules/.pnpm/dotenv@4.0.0/node_modules/dotenv/lib/main.js"(exports2, module2) {
92844
- "use strict";
92845
- var fs15 = require("fs");
92846
- function parse11(src) {
92847
- var obj = {};
92848
- src.toString().split("\n").forEach(function(line) {
92849
- var keyValueArr = line.match(/^\s*([\w\.\-]+)\s*=\s*(.*)?\s*$/);
92850
- if (keyValueArr != null) {
92851
- var key = keyValueArr[1];
92852
- var value = keyValueArr[2] ? keyValueArr[2] : "";
92853
- var len = value ? value.length : 0;
92854
- if (len > 0 && value.charAt(0) === '"' && value.charAt(len - 1) === '"') {
92855
- value = value.replace(/\\n/gm, "\n");
92856
- }
92857
- value = value.replace(/(^['"]|['"]$)/g, "").trim();
92858
- obj[key] = value;
92859
- }
92860
- });
92861
- return obj;
92862
- }
92863
- function config2(options) {
92864
- var path11 = ".env";
92865
- var encoding = "utf8";
92866
- if (options) {
92867
- if (options.path) {
92868
- path11 = options.path;
92869
- }
92870
- if (options.encoding) {
92871
- encoding = options.encoding;
92872
- }
92873
- }
92874
- try {
92875
- var parsedObj = parse11(fs15.readFileSync(path11, { encoding }));
92876
- Object.keys(parsedObj).forEach(function(key) {
92877
- process.env[key] = process.env[key] || parsedObj[key];
92878
- });
92879
- return { parsed: parsedObj };
92880
- } catch (e2) {
92881
- return { error: e2 };
92882
- }
92883
- }
92884
- module2.exports.config = config2;
92885
- module2.exports.load = config2;
92886
- module2.exports.parse = parse11;
92887
- }
92888
- });
92889
-
92890
- // src/util/compile-vercel-config.ts
92891
- var compile_vercel_config_exports = {};
92892
- __export3(compile_vercel_config_exports, {
92893
- compileVercelConfig: () => compileVercelConfig,
92894
- findSourceVercelConfigFile: () => findSourceVercelConfigFile,
92895
- getVercelConfigPath: () => getVercelConfigPath
92896
- });
92897
- async function fileExists(filePath) {
92898
- try {
92899
- await (0, import_promises.access)(filePath);
92900
- return true;
92901
- } catch {
92902
- return false;
92903
- }
92904
- }
92905
- async function findAllVercelConfigFiles(workPath) {
92906
- const foundFiles = [];
92907
- for (const ext of VERCEL_CONFIG_EXTENSIONS) {
92908
- const configPath = (0, import_path12.join)(workPath, `vercel.${ext}`);
92909
- if (await fileExists(configPath)) {
92910
- foundFiles.push(configPath);
92911
- }
92912
- }
92913
- return foundFiles;
92914
- }
92915
- async function findSourceVercelConfigFile(workPath) {
92916
- for (const ext of VERCEL_CONFIG_EXTENSIONS) {
92917
- const configPath = (0, import_path12.join)(workPath, `vercel.${ext}`);
92918
- if (await fileExists(configPath)) {
92919
- return (0, import_path12.basename)(configPath);
92920
- }
92921
- }
92922
- return null;
92923
- }
92924
- async function findVercelConfigFile(workPath) {
92925
- const foundFiles = await findAllVercelConfigFiles(workPath);
92926
- if (foundFiles.length > 1) {
92927
- throw new ConflictingConfigFiles(
92928
- foundFiles,
92929
- "Multiple vercel config files found. Please use only one configuration file.",
92930
- "https://vercel.com/docs/projects/project-configuration"
92931
- );
92932
- }
92933
- return foundFiles[0] || null;
92934
- }
92935
- function parseConfigLoaderError(stderr) {
92936
- if (!stderr.trim()) {
92937
- return "";
92938
- }
92939
- const moduleNotFoundMatch = stderr.match(
92940
- /Error \[ERR_MODULE_NOT_FOUND\]: Cannot find package '([^']+)'/
92941
- );
92942
- if (moduleNotFoundMatch) {
92943
- const packageName2 = moduleNotFoundMatch[1];
92944
- return `Cannot find package '${packageName2}'. Make sure it's installed in your project dependencies.`;
92945
- }
92946
- const syntaxErrorMatch = stderr.match(/SyntaxError: (.+?)(?:\n|$)/);
92947
- if (syntaxErrorMatch) {
92948
- return `Syntax error: ${syntaxErrorMatch[1]}`;
92949
- }
92950
- const errorMatch = stderr.match(
92951
- /^(?:Error|TypeError|ReferenceError): (.+?)(?:\n|$)/m
92952
- );
92953
- if (errorMatch) {
92954
- return errorMatch[1];
92955
- }
92956
- return stderr.trim();
92957
- }
92958
- async function compileVercelConfig(workPath) {
92959
- const vercelJsonPath = (0, import_path12.join)(workPath, "vercel.json");
92960
- const nowJsonPath = (0, import_path12.join)(workPath, "now.json");
92961
- const hasVercelJson = await fileExists(vercelJsonPath);
92962
- const hasNowJson = await fileExists(nowJsonPath);
92963
- if (hasVercelJson && hasNowJson) {
92964
- throw new ConflictingConfigFiles([vercelJsonPath, nowJsonPath]);
92965
- }
92966
- if (!process.env.VERCEL_TS_CONFIG_ENABLED) {
92967
- return {
92968
- configPath: hasVercelJson ? vercelJsonPath : hasNowJson ? nowJsonPath : null,
92969
- wasCompiled: false
92970
- };
92971
- }
92972
- const vercelConfigPath = await findVercelConfigFile(workPath);
92973
- const vercelDir = (0, import_path12.join)(workPath, VERCEL_DIR);
92974
- const compiledConfigPath = (0, import_path12.join)(vercelDir, "vercel.json");
92975
- if (vercelConfigPath && hasNowJson) {
92976
- throw new ConflictingConfigFiles(
92977
- [vercelConfigPath, nowJsonPath],
92978
- `Both ${(0, import_path12.basename)(vercelConfigPath)} and now.json exist in your project. Please use only one configuration method.`,
92979
- "https://vercel.com/docs/projects/project-configuration"
92980
- );
92981
- }
92982
- if (vercelConfigPath && hasVercelJson) {
92983
- throw new ConflictingConfigFiles(
92984
- [vercelConfigPath, vercelJsonPath],
92985
- `Both ${(0, import_path12.basename)(vercelConfigPath)} and vercel.json exist in your project. Please use only one configuration method.`,
92986
- "https://vercel.com/docs/projects/project-configuration"
92987
- );
92988
- }
92989
- if (!vercelConfigPath) {
92990
- if (hasVercelJson) {
92991
- return {
92992
- configPath: vercelJsonPath,
92993
- wasCompiled: false
92994
- };
92995
- }
92996
- if (hasNowJson) {
92997
- return {
92998
- configPath: nowJsonPath,
92999
- wasCompiled: false
93000
- };
93001
- }
93002
- if (await fileExists(compiledConfigPath)) {
93003
- return {
93004
- configPath: compiledConfigPath,
93005
- wasCompiled: true,
93006
- sourceFile: await findSourceVercelConfigFile(workPath) ?? void 0
93007
- };
93008
- }
93009
- return {
93010
- configPath: null,
93011
- wasCompiled: false
93012
- };
93013
- }
93014
- (0, import_dotenv.config)({ path: (0, import_path12.join)(workPath, ".env") });
93015
- (0, import_dotenv.config)({ path: (0, import_path12.join)(workPath, ".env.local") });
93016
- const tempOutPath = (0, import_path12.join)(vercelDir, "vercel-temp.mjs");
93017
- const loaderPath = (0, import_path12.join)(vercelDir, "vercel-loader.mjs");
93018
- try {
93019
- const { build: build2 } = await import("esbuild");
93020
- await (0, import_promises.mkdir)(vercelDir, { recursive: true });
93021
- await build2({
93022
- entryPoints: [vercelConfigPath],
93023
- bundle: true,
93024
- platform: "node",
93025
- format: "esm",
93026
- outfile: tempOutPath,
93027
- packages: "external",
93028
- target: "node20",
93029
- sourcemap: "inline"
93030
- });
93031
- const loaderScript = `
93032
- import { pathToFileURL } from 'url';
93033
- const configModule = await import(pathToFileURL(process.argv[2]).href);
93034
- const config = ('default' in configModule) ? configModule.default : ('config' in configModule) ? configModule.config : configModule;
93035
- process.send(config);
93036
- `;
93037
- await (0, import_promises.writeFile)(loaderPath, loaderScript, "utf-8");
93038
- const config2 = await new Promise((resolve13, reject) => {
93039
- const child = (0, import_child_process3.fork)(loaderPath, [tempOutPath], {
93040
- stdio: ["pipe", "pipe", "pipe", "ipc"]
93041
- });
93042
- let stderrOutput = "";
93043
- let stdoutOutput = "";
93044
- if (child.stderr) {
93045
- child.stderr.on("data", (data) => {
93046
- stderrOutput += data.toString();
93047
- });
93048
- }
93049
- if (child.stdout) {
93050
- child.stdout.on("data", (data) => {
93051
- stdoutOutput += data.toString();
93052
- });
93053
- }
93054
- const timeout = setTimeout(() => {
93055
- child.kill();
93056
- reject(new Error("Config loader timed out after 10 seconds"));
93057
- }, 1e4);
93058
- child.on("message", (message2) => {
93059
- clearTimeout(timeout);
93060
- child.kill();
93061
- resolve13(message2);
93062
- });
93063
- child.on("error", (err) => {
93064
- clearTimeout(timeout);
93065
- reject(err);
93066
- });
93067
- child.on("exit", (code2) => {
93068
- clearTimeout(timeout);
93069
- if (code2 !== 0) {
93070
- if (stderrOutput.trim()) {
93071
- output_manager_default.log(stderrOutput);
93072
- }
93073
- if (stdoutOutput.trim()) {
93074
- output_manager_default.log(stdoutOutput);
93075
- }
93076
- const parsedError = parseConfigLoaderError(stderrOutput);
93077
- if (parsedError) {
93078
- reject(new Error(parsedError));
93079
- } else if (stdoutOutput.trim()) {
93080
- reject(new Error(stdoutOutput.trim()));
93081
- } else {
93082
- reject(new Error(`Config loader exited with code ${code2}`));
93083
- }
93084
- }
93085
- });
93086
- });
93087
- await (0, import_promises.writeFile)(
93088
- compiledConfigPath,
93089
- JSON.stringify(config2, null, 2),
93090
- "utf-8"
93091
- );
93092
- output_manager_default.debug(`Compiled ${vercelConfigPath} -> ${compiledConfigPath}`);
93093
- return {
93094
- configPath: compiledConfigPath,
93095
- wasCompiled: true,
93096
- sourceFile: await findSourceVercelConfigFile(workPath) ?? void 0
93097
- };
93098
- } catch (error3) {
93099
- throw new import_build_utils5.NowBuildError({
93100
- code: "vercel_ts_compilation_failed",
93101
- message: `Failed to compile ${vercelConfigPath}: ${error3.message}`,
93102
- link: "https://vercel.com/docs/projects/project-configuration"
93103
- });
93104
- } finally {
93105
- await Promise.all([
93106
- (0, import_promises.unlink)(tempOutPath).catch((err) => {
93107
- if (err.code !== "ENOENT") {
93108
- output_manager_default.debug(`Failed to cleanup temp file: ${err}`);
93109
- }
93110
- }),
93111
- (0, import_promises.unlink)(loaderPath).catch((err) => {
93112
- if (err.code !== "ENOENT") {
93113
- output_manager_default.debug(`Failed to cleanup loader file: ${err}`);
93114
- }
93115
- })
93116
- ]);
93117
- }
93118
- }
93119
- async function getVercelConfigPath(workPath) {
93120
- const vercelJsonPath = (0, import_path12.join)(workPath, "vercel.json");
93121
- const nowJsonPath = (0, import_path12.join)(workPath, "now.json");
93122
- const compiledConfigPath = (0, import_path12.join)(workPath, VERCEL_DIR, "vercel.json");
93123
- if (await fileExists(vercelJsonPath)) {
93124
- return vercelJsonPath;
93125
- }
93126
- if (await fileExists(nowJsonPath)) {
93127
- return nowJsonPath;
93128
- }
93129
- if (await fileExists(compiledConfigPath)) {
93130
- return compiledConfigPath;
93131
- }
93132
- return nowJsonPath;
93133
- }
93134
- var import_promises, import_path12, import_child_process3, import_dotenv, import_build_utils5, VERCEL_CONFIG_EXTENSIONS;
93135
- var init_compile_vercel_config = __esm({
93136
- "src/util/compile-vercel-config.ts"() {
93137
- "use strict";
93138
- import_promises = require("fs/promises");
93139
- import_path12 = require("path");
93140
- import_child_process3 = require("child_process");
93141
- import_dotenv = __toESM3(require_main());
93142
- init_output_manager();
93143
- import_build_utils5 = require("@vercel/build-utils");
93144
- init_link2();
93145
- init_errors_ts();
93146
- VERCEL_CONFIG_EXTENSIONS = ["ts", "mts", "js", "mjs", "cjs"];
93147
- }
93148
- });
93149
-
93150
93159
  // src/util/get-update-command.ts
93151
93160
  async function getConfigPrefix() {
93152
93161
  const paths = [
@@ -147532,10 +147541,7 @@ async function writeBuildResult(args2) {
147532
147541
  standalone,
147533
147542
  workPath
147534
147543
  } = args2;
147535
- let version2 = builder.version;
147536
- if ((0, import_build_utils12.isExperimentalBackendsEnabled)() && "output" in buildResult) {
147537
- version2 = 2;
147538
- }
147544
+ const version2 = builder.version;
147539
147545
  if (typeof version2 !== "number" || version2 === 2) {
147540
147546
  return writeBuildResultV2({
147541
147547
  repoRootPath,
@@ -147700,33 +147706,46 @@ async function writeBuildResultV3(args2) {
147700
147706
  } = args2;
147701
147707
  const { output: output2 } = buildResult;
147702
147708
  const routesJsonPath = (0, import_path23.join)(workPath, ".vercel", "routes.json");
147703
- if (((0, import_build_utils12.isBackendBuilder)(build2) || build2.use === "@vercel/python") && (0, import_fs_extra13.existsSync)(routesJsonPath)) {
147704
- try {
147705
- const newOutput = {
147706
- index: output2
147707
- };
147708
- const routesJson = await import_fs_extra13.default.readJSON(routesJsonPath);
147709
- if (routesJson && typeof routesJson === "object" && "routes" in routesJson && Array.isArray(routesJson.routes)) {
147710
- for (const route of routesJson.routes) {
147711
- if (route.source === "/") {
147712
- continue;
147713
- }
147714
- if (route.source) {
147715
- newOutput[route.source] = output2;
147709
+ if ((0, import_build_utils12.isBackendBuilder)(build2) || build2.use === "@vercel/python") {
147710
+ if ((0, import_fs_extra13.existsSync)(routesJsonPath)) {
147711
+ try {
147712
+ const newOutput = {
147713
+ index: output2
147714
+ };
147715
+ const routesJson = await import_fs_extra13.default.readJSON(routesJsonPath);
147716
+ if (routesJson && typeof routesJson === "object" && "routes" in routesJson && Array.isArray(routesJson.routes)) {
147717
+ for (const route of routesJson.routes) {
147718
+ if (route.source === "/") {
147719
+ continue;
147720
+ }
147721
+ if (route.source) {
147722
+ newOutput[route.source] = output2;
147723
+ }
147716
147724
  }
147717
147725
  }
147726
+ return writeBuildResultV2({
147727
+ repoRootPath,
147728
+ outputDir,
147729
+ buildResult: { output: newOutput, routes: buildResult.routes },
147730
+ build: build2,
147731
+ vercelConfig,
147732
+ standalone,
147733
+ workPath
147734
+ });
147735
+ } catch (error3) {
147736
+ output_manager_default.error(`Failed to read routes.json: ${error3}`);
147718
147737
  }
147738
+ }
147739
+ if ((0, import_build_utils12.isBackendBuilder)(build2) && (0, import_build_utils12.isExperimentalBackendsEnabled)() && "routes" in buildResult) {
147719
147740
  return writeBuildResultV2({
147720
147741
  repoRootPath,
147721
147742
  outputDir,
147722
- buildResult: { output: newOutput, routes: buildResult.routes },
147743
+ buildResult,
147723
147744
  build: build2,
147724
147745
  vercelConfig,
147725
147746
  standalone,
147726
147747
  workPath
147727
147748
  });
147728
- } catch (error3) {
147729
- output_manager_default.error(`Failed to read routes.json: ${error3}`);
147730
147749
  }
147731
147750
  }
147732
147751
  const src = build2.src;
@@ -148835,25 +148854,14 @@ var init_edit_project_settings = __esm({
148835
148854
  // src/util/config/read-config.ts
148836
148855
  async function readConfig(dir) {
148837
148856
  let pkgFilePath;
148838
- if (process.env.VERCEL_TS_CONFIG_ENABLED) {
148839
- try {
148840
- const compileResult = await compileVercelConfig(dir);
148841
- pkgFilePath = compileResult.configPath || getLocalPathConfig(dir);
148842
- } catch (err) {
148843
- if (err instanceof Error) {
148844
- return err;
148845
- }
148846
- throw err;
148847
- }
148848
- } else {
148849
- try {
148850
- pkgFilePath = getLocalPathConfig(dir);
148851
- } catch (err) {
148852
- if (err instanceof Error) {
148853
- return err;
148854
- }
148855
- throw err;
148857
+ try {
148858
+ const compileResult = await compileVercelConfig(dir);
148859
+ pkgFilePath = compileResult.configPath || getLocalPathConfig(dir);
148860
+ } catch (err) {
148861
+ if (err instanceof Error) {
148862
+ return err;
148856
148863
  }
148864
+ throw err;
148857
148865
  }
148858
148866
  const result = await readJSONFile(pkgFilePath);
148859
148867
  if (result instanceof CantParseJSONFile) {
@@ -149562,7 +149570,7 @@ async function doBuild(client2, project, buildsJson, cwd, outputDir, span, stand
149562
149570
  const workPath = (0, import_path28.join)(cwd, project.settings.rootDirectory || ".");
149563
149571
  const sourceConfigFile = await findSourceVercelConfigFile(workPath);
149564
149572
  let corepackShimDir;
149565
- if (sourceConfigFile && process.env.VERCEL_TS_CONFIG_ENABLED) {
149573
+ if (sourceConfigFile) {
149566
149574
  corepackShimDir = await initCorepack({ repoRootPath: cwd });
149567
149575
  const installCommand2 = project.settings.installCommand;
149568
149576
  if (typeof installCommand2 === "string") {
@@ -149609,7 +149617,7 @@ async function doBuild(client2, project, buildsJson, cwd, outputDir, span, stand
149609
149617
  process.env.VERCEL_TRACING_DISABLE_AUTOMATIC_FETCH_INSTRUMENTATION = "1";
149610
149618
  }
149611
149619
  if (vercelConfig) {
149612
- vercelConfig[import_client6.fileNameSymbol] = "vercel.json";
149620
+ vercelConfig[import_client6.fileNameSymbol] = compileResult.wasCompiled ? compileResult.sourceFile || DEFAULT_VERCEL_CONFIG_FILENAME : "vercel.json";
149613
149621
  } else if (nowConfig) {
149614
149622
  nowConfig[import_client6.fileNameSymbol] = "now.json";
149615
149623
  }
@@ -149668,7 +149676,8 @@ async function doBuild(client2, project, buildsJson, cwd, outputDir, span, stand
149668
149676
  ...localConfig,
149669
149677
  projectSettings,
149670
149678
  ignoreBuildScript: true,
149671
- featHandleMiss: true
149679
+ featHandleMiss: true,
149680
+ workPath
149672
149681
  });
149673
149682
  if (detectedBuilders.errors && detectedBuilders.errors.length > 0) {
149674
149683
  throw detectedBuilders.errors[0];
@@ -173179,7 +173188,7 @@ Please ensure that ${cmd(err.path)} is properly installed`;
173179
173188
  return defaults;
173180
173189
  }
173181
173190
  }
173182
- if ((0, import_build_utils18.isExperimentalBackendsEnabled)()) {
173191
+ if ((0, import_build_utils18.shouldUseExperimentalBackends)(frameworkSlug)) {
173183
173192
  return "npx @vercel/cervel dev";
173184
173193
  }
173185
173194
  }
@@ -173245,7 +173254,8 @@ Please ensure that ${cmd(err.path)} is properly installed`;
173245
173254
  projectSettings: projectSettings || this.projectSettings,
173246
173255
  featHandleMiss,
173247
173256
  cleanUrls,
173248
- trailingSlash
173257
+ trailingSlash,
173258
+ workPath: this.cwd
173249
173259
  });
173250
173260
  if (errors) {
173251
173261
  output_manager_default.error(errors[0].message);
@@ -190511,7 +190521,6 @@ init_humanize_path();
190511
190521
  init_read_json_file();
190512
190522
  var import_error_utils10 = __toESM3(require_dist2());
190513
190523
  init_output_manager();
190514
- init_compile_vercel_config();
190515
190524
  var config;
190516
190525
  async function getConfig(configFile) {
190517
190526
  if (config) {
@@ -190544,33 +190553,6 @@ async function getConfig(configFile) {
190544
190553
  }
190545
190554
  const vercelFilePath = import_path13.default.resolve(localPath, "vercel.json");
190546
190555
  const nowFilePath = import_path13.default.resolve(localPath, "now.json");
190547
- if (process.env.VERCEL_TS_CONFIG_ENABLED) {
190548
- let compileResult;
190549
- try {
190550
- compileResult = await compileVercelConfig(localPath);
190551
- } catch (err) {
190552
- if (err instanceof Error) {
190553
- return err;
190554
- }
190555
- throw err;
190556
- }
190557
- if (compileResult.configPath) {
190558
- const localConfig = await readJSONFile(
190559
- compileResult.configPath
190560
- );
190561
- if (localConfig instanceof CantParseJSONFile) {
190562
- return localConfig;
190563
- }
190564
- if (localConfig !== null) {
190565
- const fileName = import_path13.default.basename(compileResult.configPath);
190566
- output_manager_default.debug(`Found config in file "${compileResult.configPath}"`);
190567
- config = localConfig;
190568
- config[import_client2.fileNameSymbol] = compileResult.wasCompiled ? compileResult.sourceFile || "vercel.ts" : fileName;
190569
- return config;
190570
- }
190571
- }
190572
- return new CantFindConfig([vercelFilePath, nowFilePath].map(humanizePath));
190573
- }
190574
190556
  const [vercelConfig, nowConfig] = await Promise.all([
190575
190557
  readJSONFile(vercelFilePath),
190576
190558
  readJSONFile(nowFilePath)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vercel",
3
- "version": "50.1.2",
3
+ "version": "50.1.4",
4
4
  "preferGlobal": true,
5
5
  "license": "Apache-2.0",
6
6
  "description": "The command-line interface for Vercel",
@@ -27,25 +27,25 @@
27
27
  "esbuild": "0.27.0",
28
28
  "form-data": "^4.0.0",
29
29
  "jose": "5.9.6",
30
- "@vercel/backends": "0.0.17",
31
- "@vercel/build-utils": "13.2.3",
32
- "@vercel/elysia": "0.1.14",
33
- "@vercel/fastify": "0.1.17",
34
- "@vercel/express": "0.1.20",
30
+ "@vercel/build-utils": "13.2.4",
35
31
  "@vercel/detect-agent": "1.0.0",
36
- "@vercel/go": "3.2.4",
37
- "@vercel/h3": "0.1.23",
38
- "@vercel/hono": "0.2.17",
32
+ "@vercel/elysia": "0.1.15",
33
+ "@vercel/backends": "0.0.17",
34
+ "@vercel/express": "0.1.21",
35
+ "@vercel/fastify": "0.1.18",
36
+ "@vercel/go": "3.3.0",
37
+ "@vercel/h3": "0.1.24",
38
+ "@vercel/hono": "0.2.18",
39
39
  "@vercel/hydrogen": "1.3.3",
40
- "@vercel/nestjs": "0.2.18",
41
- "@vercel/next": "4.15.9",
42
- "@vercel/python": "6.1.4",
40
+ "@vercel/nestjs": "0.2.19",
41
+ "@vercel/next": "4.15.10",
42
+ "@vercel/node": "5.5.16",
43
+ "@vercel/python": "6.1.6",
43
44
  "@vercel/redwood": "2.4.6",
44
45
  "@vercel/remix-builder": "5.5.6",
45
- "@vercel/ruby": "2.2.3",
46
+ "@vercel/ruby": "2.2.4",
46
47
  "@vercel/rust": "1.0.4",
47
- "@vercel/static-build": "2.8.14",
48
- "@vercel/node": "5.5.15"
48
+ "@vercel/static-build": "2.8.15"
49
49
  },
50
50
  "devDependencies": {
51
51
  "@alex_neo/jest-expect-message": "1.0.5",
@@ -171,11 +171,11 @@
171
171
  "yauzl-promise": "2.1.3",
172
172
  "@vercel-internals/constants": "1.0.4",
173
173
  "@vercel-internals/get-package-json": "1.0.0",
174
- "@vercel/client": "17.2.17",
175
- "@vercel-internals/types": "3.0.6",
174
+ "@vercel/client": "17.2.18",
176
175
  "@vercel/error-utils": "2.0.3",
177
176
  "@vercel/frameworks": "3.15.4",
178
- "@vercel/fs-detectors": "5.7.10",
177
+ "@vercel-internals/types": "3.0.6",
178
+ "@vercel/fs-detectors": "5.7.11",
179
179
  "@vercel/routing-utils": "5.3.1"
180
180
  },
181
181
  "scripts": {