@vercel/introspection 0.0.8 → 0.0.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1,9 +1,9 @@
1
1
  import { createRequire } from "node:module";
2
- import { spawn } from "child_process";
3
- import { existsSync } from "fs";
4
- import { dirname, isAbsolute, join, relative } from "path";
5
- import { createRequire as createRequire$1 } from "module";
6
- import { fileURLToPath } from "url";
2
+ import { dirname, isAbsolute, join, relative } from "node:path";
3
+ import { createWriteStream, existsSync, mkdtempSync, readFileSync, rmSync, unlinkSync } from "node:fs";
4
+ import { spawn } from "node:child_process";
5
+ import { fileURLToPath } from "node:url";
6
+ import { tmpdir } from "node:os";
7
7
  import { z } from "zod";
8
8
 
9
9
  //#region rolldown:runtime
@@ -261,7 +261,7 @@ var require_dist$1 = /* @__PURE__ */ __commonJS$1({ "../build-utils/dist/index.j
261
261
  this.head = this.tail = null;
262
262
  this.length = 0;
263
263
  };
264
- BufferList.prototype.join = function join5(s) {
264
+ BufferList.prototype.join = function join6(s) {
265
265
  if (this.length === 0) return "";
266
266
  var p = this.head;
267
267
  var ret = "" + p.data;
@@ -2379,7 +2379,7 @@ var require_dist$1 = /* @__PURE__ */ __commonJS$1({ "../build-utils/dist/index.j
2379
2379
  polyfills(fs8);
2380
2380
  fs8.gracefulify = patch;
2381
2381
  fs8.createReadStream = createReadStream;
2382
- fs8.createWriteStream = createWriteStream;
2382
+ fs8.createWriteStream = createWriteStream$1;
2383
2383
  var fs$readFile = fs8.readFile;
2384
2384
  fs8.readFile = readFile4;
2385
2385
  function readFile4(path7, options, cb) {
@@ -2598,7 +2598,7 @@ var require_dist$1 = /* @__PURE__ */ __commonJS$1({ "../build-utils/dist/index.j
2598
2598
  function createReadStream(path7, options) {
2599
2599
  return new fs8.ReadStream(path7, options);
2600
2600
  }
2601
- function createWriteStream(path7, options) {
2601
+ function createWriteStream$1(path7, options) {
2602
2602
  return new fs8.WriteStream(path7, options);
2603
2603
  }
2604
2604
  var fs$open = fs8.open;
@@ -3810,7 +3810,7 @@ var require_dist$1 = /* @__PURE__ */ __commonJS$1({ "../build-utils/dist/index.j
3810
3810
  return obj;
3811
3811
  }
3812
3812
  var readFile4 = universalify.fromPromise(_readFile);
3813
- function readFileSync(file, options = {}) {
3813
+ function readFileSync$1(file, options = {}) {
3814
3814
  if (typeof options === "string") options = { encoding: options };
3815
3815
  const fs7 = options.fs || _fs;
3816
3816
  const shouldThrow = "throws" in options ? options.throws : true;
@@ -3838,7 +3838,7 @@ var require_dist$1 = /* @__PURE__ */ __commonJS$1({ "../build-utils/dist/index.j
3838
3838
  }
3839
3839
  module2.exports = {
3840
3840
  readFile: readFile4,
3841
- readFileSync,
3841
+ readFileSync: readFileSync$1,
3842
3842
  writeFile,
3843
3843
  writeFileSync
3844
3844
  };
@@ -54344,6 +54344,7 @@ ${error.message}`;
54344
54344
  NodeVersion: () => NodeVersion,
54345
54345
  NodejsLambda: () => NodejsLambda,
54346
54346
  NowBuildError: () => NowBuildError,
54347
+ PYTHON_FRAMEWORKS: () => PYTHON_FRAMEWORKS,
54347
54348
  Prerender: () => Prerender,
54348
54349
  Span: () => Span,
54349
54350
  Version: () => Version,
@@ -54356,6 +54357,7 @@ ${error.message}`;
54356
54357
  download: () => download,
54357
54358
  downloadFile: () => downloadFile,
54358
54359
  execCommand: () => execCommand,
54360
+ findPackageJson: () => findPackageJson,
54359
54361
  functionsSchema: () => functionsSchema,
54360
54362
  generateNodeBuilderFunctions: () => generateNodeBuilderFunctions,
54361
54363
  getDiscontinuedNodeVersions: () => getDiscontinuedNodeVersions,
@@ -54368,6 +54370,7 @@ ${error.message}`;
54368
54370
  getNodeBinPaths: () => getNodeBinPaths,
54369
54371
  getNodeVersion: () => getNodeVersion,
54370
54372
  getOsRelease: () => getOsRelease,
54373
+ getPackageJson: () => getPackageJson,
54371
54374
  getPathForPackageManager: () => getPathForPackageManager,
54372
54375
  getPlatformEnv: () => getPlatformEnv,
54373
54376
  getPrefixedEnvVars: () => getPrefixedEnvVars,
@@ -54388,10 +54391,12 @@ ${error.message}`;
54388
54391
  isExperimentalBackendsEnabled: () => isExperimentalBackendsEnabled,
54389
54392
  isExperimentalBackendsWithoutIntrospectionEnabled: () => isExperimentalBackendsWithoutIntrospectionEnabled$1,
54390
54393
  isPythonEntrypoint: () => isPythonEntrypoint,
54394
+ isPythonFramework: () => isPythonFramework,
54391
54395
  isSymbolicLink: () => isSymbolicLink,
54392
54396
  normalizePath: () => normalizePath,
54393
54397
  readConfigFile: () => readConfigFile,
54394
54398
  rename: () => rename,
54399
+ resetCustomInstallCommandSet: () => resetCustomInstallCommandSet,
54395
54400
  runBundleInstall: () => runBundleInstall,
54396
54401
  runCustomInstallCommand: () => runCustomInstallCommand,
54397
54402
  runNpmInstall: () => runNpmInstall,
@@ -54852,7 +54857,7 @@ ${error.message}`;
54852
54857
  (0, import_assert4.default)(typeof runtime === "string", "\"runtime\" is not a string");
54853
54858
  (0, import_assert4.default)(typeof environment === "object", "\"environment\" is not an object");
54854
54859
  if (architecture !== void 0) (0, import_assert4.default)(architecture === "x86_64" || architecture === "arm64", "\"architecture\" must be either \"x86_64\" or \"arm64\"");
54855
- if (runtimeLanguage !== void 0) (0, import_assert4.default)(runtimeLanguage === "rust", "\"runtimeLanguage\" must be \"rust\"");
54860
+ if (runtimeLanguage !== void 0) (0, import_assert4.default)(runtimeLanguage === "rust" || runtimeLanguage === "go", "\"runtimeLanguage\" is invalid. Valid options: \"rust\", \"go\"");
54856
54861
  if ("experimentalAllowBundling" in opts && opts.experimentalAllowBundling !== void 0) (0, import_assert4.default)(typeof opts.experimentalAllowBundling === "boolean", "\"experimentalAllowBundling\" is not a boolean");
54857
54862
  if (memory !== void 0) (0, import_assert4.default)(typeof memory === "number", "\"memory\" is not a number");
54858
54863
  if (maxDuration !== void 0) (0, import_assert4.default)(typeof maxDuration === "number", "\"maxDuration\" is not a number");
@@ -55137,7 +55142,7 @@ ${error.message}`;
55137
55142
  }
55138
55143
  var import_assert6 = __toESM(__require("assert"));
55139
55144
  var import_fs_extra7 = __toESM(require_lib());
55140
- var import_path5 = __toESM(__require("path"));
55145
+ var import_path6 = __toESM(__require("path"));
55141
55146
  var import_async_sema4 = __toESM(require_async_sema());
55142
55147
  var import_cross_spawn = __toESM(require_cross_spawn());
55143
55148
  var import_semver2 = __toESM(require_semver2());
@@ -55257,14 +55262,14 @@ ${error.message}`;
55257
55262
  return (0, import_semver.intersects)(o.range, engineRange) && (availableVersions?.length ? availableVersions.includes(o.major) : true);
55258
55263
  }))) throw new NowBuildError({
55259
55264
  code: "BUILD_UTILS_NODE_VERSION_INVALID",
55260
- link: "http://vercel.link/node-version",
55265
+ link: "https://vercel.link/node-version",
55261
55266
  message: `Found invalid Node.js Version: "${engineRange}". ${getHint(isAuto, availableVersions)}`
55262
55267
  });
55263
55268
  }
55264
55269
  if (!selection) selection = getLatestNodeVersion(availableVersions);
55265
55270
  if (selection.state === "discontinued") throw new NowBuildError({
55266
55271
  code: "BUILD_UTILS_NODE_VERSION_DISCONTINUED",
55267
- link: "http://vercel.link/node-version",
55272
+ link: "https://vercel.link/node-version",
55268
55273
  message: `${`Node.js Version "${selection.range}" is discontinued and must be upgraded.`} ${getHint(isAuto)}`
55269
55274
  });
55270
55275
  debug$1(`Selected Node.js ${selection.range}`);
@@ -55298,6 +55303,7 @@ ${error.message}`;
55298
55303
  var import_toml = __toESM(require_toml());
55299
55304
  var import_fs_extra6 = __toESM(require_lib());
55300
55305
  var import_error_utils = __toESM(require_dist());
55306
+ var import_path5 = __require("path");
55301
55307
  async function readFileOrNull(file) {
55302
55308
  try {
55303
55309
  return await (0, import_fs_extra6.readFile)(file);
@@ -55324,6 +55330,14 @@ ${error.message}`;
55324
55330
  }
55325
55331
  return null;
55326
55332
  }
55333
+ async function getPackageJson(dir) {
55334
+ const packagePath = (0, import_path5.join)(dir, "package.json");
55335
+ try {
55336
+ return JSON.parse(await (0, import_fs_extra6.readFile)(packagePath, "utf8"));
55337
+ } catch (err) {
55338
+ return {};
55339
+ }
55340
+ }
55327
55341
  var { hasOwnProperty: hasOwnProperty2 } = Object.prototype;
55328
55342
  function cloneEnv(...envs) {
55329
55343
  return envs.reduce((obj, env) => {
@@ -55381,12 +55395,12 @@ ${error.message}`;
55381
55395
  return true;
55382
55396
  }
55383
55397
  function* traverseUpDirectories({ start, base }) {
55384
- let current = import_path5.default.normalize(start);
55385
- const normalizedRoot = base ? import_path5.default.normalize(base) : void 0;
55398
+ let current = import_path6.default.normalize(start);
55399
+ const normalizedRoot = base ? import_path6.default.normalize(base) : void 0;
55386
55400
  while (current) {
55387
55401
  yield current;
55388
55402
  if (current === normalizedRoot) break;
55389
- const next = import_path5.default.join(current, "..");
55403
+ const next = import_path6.default.join(current, "..");
55390
55404
  current = next === current ? void 0 : next;
55391
55405
  }
55392
55406
  }
@@ -55396,24 +55410,24 @@ ${error.message}`;
55396
55410
  start,
55397
55411
  base
55398
55412
  })) {
55399
- const packageJsonPath = import_path5.default.join(dir, "package.json");
55413
+ const packageJsonPath = import_path6.default.join(dir, "package.json");
55400
55414
  if (await import_fs_extra7.default.pathExists(packageJsonPath)) curRootPackageJsonPath = packageJsonPath;
55401
55415
  }
55402
55416
  return curRootPackageJsonPath ? {
55403
55417
  packageJson: await import_fs_extra7.default.readJson(curRootPackageJsonPath),
55404
- rootDir: import_path5.default.dirname(curRootPackageJsonPath)
55418
+ rootDir: import_path6.default.dirname(curRootPackageJsonPath)
55405
55419
  } : void 0;
55406
55420
  }
55407
55421
  async function getNodeBinPath({ cwd }) {
55408
55422
  const { lockfilePath } = await scanParentDirs(cwd);
55409
- const dir = import_path5.default.dirname(lockfilePath || cwd);
55410
- return import_path5.default.join(dir, "node_modules", ".bin");
55423
+ const dir = import_path6.default.dirname(lockfilePath || cwd);
55424
+ return import_path6.default.join(dir, "node_modules", ".bin");
55411
55425
  }
55412
55426
  function getNodeBinPaths({ start, base }) {
55413
55427
  return Array.from(traverseUpDirectories({
55414
55428
  start,
55415
55429
  base
55416
- })).map((dir) => import_path5.default.join(dir, "node_modules/.bin"));
55430
+ })).map((dir) => import_path6.default.join(dir, "node_modules/.bin"));
55417
55431
  }
55418
55432
  async function chmodPlusX(fsPath) {
55419
55433
  const s = await import_fs_extra7.default.stat(fsPath);
@@ -55423,10 +55437,10 @@ ${error.message}`;
55423
55437
  await import_fs_extra7.default.chmod(fsPath, base8);
55424
55438
  }
55425
55439
  async function runShellScript(fsPath, args = [], spawnOpts) {
55426
- (0, import_assert6.default)(import_path5.default.isAbsolute(fsPath));
55427
- const destPath = import_path5.default.dirname(fsPath);
55440
+ (0, import_assert6.default)(import_path6.default.isAbsolute(fsPath));
55441
+ const destPath = import_path6.default.dirname(fsPath);
55428
55442
  await chmodPlusX(fsPath);
55429
- const command = `./${import_path5.default.basename(fsPath)}`;
55443
+ const command = `./${import_path6.default.basename(fsPath)}`;
55430
55444
  await spawnAsync(command, args, {
55431
55445
  ...spawnOpts,
55432
55446
  cwd: destPath,
@@ -55439,7 +55453,7 @@ ${error.message}`;
55439
55453
  if (isBunVersion(nodeVersion)) return opts;
55440
55454
  if (!meta.isDev) {
55441
55455
  let found = false;
55442
- const pathSegments = (opts.env.PATH || process.env.PATH || "").split(import_path5.default.delimiter).map((segment) => {
55456
+ const pathSegments = (opts.env.PATH || process.env.PATH || "").split(import_path6.default.delimiter).map((segment) => {
55443
55457
  if (/^\/node[0-9]+\/bin/.test(segment)) {
55444
55458
  found = true;
55445
55459
  return `/node${nodeVersion.major}/bin`;
@@ -55447,7 +55461,7 @@ ${error.message}`;
55447
55461
  return segment;
55448
55462
  });
55449
55463
  if (!found) pathSegments.unshift(`/node${nodeVersion.major}/bin`);
55450
- opts.env.PATH = pathSegments.filter(Boolean).join(import_path5.default.delimiter);
55464
+ opts.env.PATH = pathSegments.filter(Boolean).join(import_path6.default.delimiter);
55451
55465
  }
55452
55466
  return opts;
55453
55467
  }
@@ -55458,20 +55472,20 @@ ${error.message}`;
55458
55472
  latestVersion.runtime = "nodejs";
55459
55473
  return latestVersion;
55460
55474
  }
55461
- const { packageJson } = await scanParentDirs(destPath, true);
55475
+ const { packageJson } = await findPackageJson(destPath, true);
55462
55476
  const configuredVersion = config.nodeVersion || fallbackVersion;
55463
55477
  const packageJsonVersion = packageJson?.engines?.node;
55464
55478
  const supportedNodeVersion = await getSupportedNodeVersion(packageJsonVersion || configuredVersion, !packageJsonVersion, availableVersions);
55465
55479
  if (packageJson?.engines?.node) {
55466
55480
  const { node } = packageJson.engines;
55467
- if (configuredVersion && !(0, import_semver2.intersects)(configuredVersion, supportedNodeVersion.range)) console.warn(`Warning: Due to "engines": { "node": "${node}" } in your \`package.json\` file, the Node.js Version defined in your Project Settings ("${configuredVersion}") will not apply, Node.js Version "${supportedNodeVersion.range}" will be used instead. Learn More: http://vercel.link/node-version`);
55468
- if ((0, import_semver2.coerce)(node)?.raw === node) console.warn(`Warning: Detected "engines": { "node": "${node}" } in your \`package.json\` with major.minor.patch, but only major Node.js Version can be selected. Learn More: http://vercel.link/node-version`);
55469
- else if ((0, import_semver2.validRange)(node) && (0, import_semver2.intersects)(`${latestVersion.major + 1}.x`, node)) console.warn(`Warning: Detected "engines": { "node": "${node}" } in your \`package.json\` that will automatically upgrade when a new major Node.js Version is released. Learn More: http://vercel.link/node-version`);
55481
+ if (configuredVersion && !(0, import_semver2.intersects)(configuredVersion, supportedNodeVersion.range)) console.warn(`Warning: Due to "engines": { "node": "${node}" } in your \`package.json\` file, the Node.js Version defined in your Project Settings ("${configuredVersion}") will not apply, Node.js Version "${supportedNodeVersion.range}" will be used instead. Learn More: https://vercel.link/node-version`);
55482
+ if ((0, import_semver2.coerce)(node)?.raw === node) console.warn(`Warning: Detected "engines": { "node": "${node}" } in your \`package.json\` with major.minor.patch, but only major Node.js Version can be selected. Learn More: https://vercel.link/node-version`);
55483
+ else if ((0, import_semver2.validRange)(node) && (0, import_semver2.intersects)(`${latestVersion.major + 1}.x`, node)) console.warn(`Warning: Detected "engines": { "node": "${node}" } in your \`package.json\` that will automatically upgrade when a new major Node.js Version is released. Learn More: https://vercel.link/node-version`);
55470
55484
  }
55471
55485
  return supportedNodeVersion;
55472
55486
  }
55473
- async function scanParentDirs(destPath, readPackageJson = false, base = "/") {
55474
- (0, import_assert6.default)(import_path5.default.isAbsolute(destPath));
55487
+ async function findPackageJson(destPath, readPackageJson = false, base = "/") {
55488
+ (0, import_assert6.default)(import_path6.default.isAbsolute(destPath));
55475
55489
  const pkgJsonPath = await walkParentDirs({
55476
55490
  base,
55477
55491
  start: destPath,
@@ -55483,6 +55497,14 @@ ${error.message}`;
55483
55497
  } catch (err) {
55484
55498
  throw new Error(`Could not read ${pkgJsonPath}: ${err.message}.`);
55485
55499
  }
55500
+ return {
55501
+ packageJsonPath: pkgJsonPath || void 0,
55502
+ packageJson
55503
+ };
55504
+ }
55505
+ async function scanParentDirs(destPath, readPackageJson = false, base = "/") {
55506
+ (0, import_assert6.default)(import_path6.default.isAbsolute(destPath));
55507
+ const { packageJsonPath: pkgJsonPath, packageJson } = await findPackageJson(destPath, readPackageJson, base);
55486
55508
  const { paths: [yarnLockPath, npmLockPath, pnpmLockPath, bunLockTextPath, bunLockBinPath, vltLockPath], packageJsonPackageManager } = await walkParentDirsMulti({
55487
55509
  base,
55488
55510
  start: destPath,
@@ -55557,8 +55579,8 @@ ${error.message}`;
55557
55579
  }
55558
55580
  async function checkTurboSupportsCorepack(turboVersionRange, rootDir) {
55559
55581
  if (turboVersionSpecifierSupportsCorepack(turboVersionRange)) return true;
55560
- const turboJsonPath = import_path5.default.join(rootDir, "turbo.json");
55561
- const turboJsoncPath = import_path5.default.join(rootDir, "turbo.jsonc");
55582
+ const turboJsonPath = import_path6.default.join(rootDir, "turbo.json");
55583
+ const turboJsoncPath = import_path6.default.join(rootDir, "turbo.jsonc");
55562
55584
  const [turboJsonExists, turboJsoncExists] = await Promise.all([import_fs_extra7.default.pathExists(turboJsonPath), import_fs_extra7.default.pathExists(turboJsoncPath)]);
55563
55585
  let turboJson = null;
55564
55586
  let turboConfigPath = null;
@@ -55567,7 +55589,7 @@ ${error.message}`;
55567
55589
  if (turboConfigPath) try {
55568
55590
  turboJson = import_json5.default.parse(await import_fs_extra7.default.readFile(turboConfigPath, "utf8"));
55569
55591
  } catch (err) {
55570
- console.warn(`WARNING: Failed to parse ${import_path5.default.basename(turboConfigPath)}`);
55592
+ console.warn(`WARNING: Failed to parse ${import_path6.default.basename(turboConfigPath)}`);
55571
55593
  }
55572
55594
  return turboJson !== null && typeof turboJson === "object" && "globalPassThroughEnv" in turboJson && Array.isArray(turboJson.globalPassThroughEnv) && turboJson.globalPassThroughEnv.includes("COREPACK_HOME");
55573
55595
  }
@@ -55601,13 +55623,13 @@ ${error.message}`;
55601
55623
  return true;
55602
55624
  }
55603
55625
  async function walkParentDirs({ base, start, filename }) {
55604
- (0, import_assert6.default)(import_path5.default.isAbsolute(base), "Expected \"base\" to be absolute path");
55605
- (0, import_assert6.default)(import_path5.default.isAbsolute(start), "Expected \"start\" to be absolute path");
55626
+ (0, import_assert6.default)(import_path6.default.isAbsolute(base), "Expected \"base\" to be absolute path");
55627
+ (0, import_assert6.default)(import_path6.default.isAbsolute(start), "Expected \"start\" to be absolute path");
55606
55628
  for (const dir of traverseUpDirectories({
55607
55629
  start,
55608
55630
  base
55609
55631
  })) {
55610
- const fullPath = import_path5.default.join(dir, filename);
55632
+ const fullPath = import_path6.default.join(dir, filename);
55611
55633
  if (await import_fs_extra7.default.pathExists(fullPath)) return fullPath;
55612
55634
  }
55613
55635
  return null;
@@ -55618,10 +55640,10 @@ ${error.message}`;
55618
55640
  start,
55619
55641
  base
55620
55642
  })) {
55621
- const fullPaths = filenames.map((f) => import_path5.default.join(dir, f));
55643
+ const fullPaths = filenames.map((f) => import_path6.default.join(dir, f));
55622
55644
  const existResults = await Promise.all(fullPaths.map((f) => import_fs_extra7.default.pathExists(f)));
55623
55645
  const foundOneOrMore = existResults.some((b) => b);
55624
- const packageJsonPath = import_path5.default.join(dir, "package.json");
55646
+ const packageJsonPath = import_path6.default.join(dir, "package.json");
55625
55647
  const packageJson = await import_fs_extra7.default.readJSON(packageJsonPath).catch(() => null);
55626
55648
  if (packageJson?.packageManager) packageManager = packageJson.packageManager;
55627
55649
  if (foundOneOrMore) return {
@@ -55681,12 +55703,16 @@ ${error.message}`;
55681
55703
  };
55682
55704
  }
55683
55705
  var runNpmInstallSema = new import_async_sema4.default(1);
55706
+ var customInstallCommandSet;
55707
+ function resetCustomInstallCommandSet() {
55708
+ customInstallCommandSet = void 0;
55709
+ }
55684
55710
  async function runNpmInstall(destPath, args = [], spawnOpts, meta, projectCreatedAt) {
55685
55711
  if (meta?.isDev) {
55686
55712
  debug$1("Skipping dependency installation because dev mode is enabled");
55687
55713
  return false;
55688
55714
  }
55689
- (0, import_assert6.default)(import_path5.default.isAbsolute(destPath));
55715
+ (0, import_assert6.default)(import_path6.default.isAbsolute(destPath));
55690
55716
  try {
55691
55717
  await runNpmInstallSema.acquire();
55692
55718
  const { cliType, packageJsonPath, packageJson, lockfileVersion, packageJsonPackageManager, turboSupportsCorepackHome } = await scanParentDirs(destPath, true);
@@ -55698,6 +55724,12 @@ ${error.message}`;
55698
55724
  if (meta && packageJsonPath && defaultInstall) {
55699
55725
  const { alreadyInstalled, runNpmInstallSet } = checkIfAlreadyInstalled(meta.runNpmInstallSet, packageJsonPath);
55700
55726
  if (alreadyInstalled) return false;
55727
+ if (process.env.VERCEL_INSTALL_COMPLETED === "1") {
55728
+ debug$1(`Skipping dependency installation for ${packageJsonPath} because VERCEL_INSTALL_COMPLETED is set`);
55729
+ runNpmInstallSet.add(packageJsonPath);
55730
+ meta.runNpmInstallSet = runNpmInstallSet;
55731
+ return false;
55732
+ }
55701
55733
  meta.runNpmInstallSet = runNpmInstallSet;
55702
55734
  }
55703
55735
  if (cliType === "yarn") {
@@ -55753,11 +55785,11 @@ ${error.message}`;
55753
55785
  else debug$1(`Detected ${detectedPackageManager}. Added "${newPath}" to path. Based on assumed package manager "${cliType}", lockfile "${detectedLockfile}", and lockfileVersion "${lockfileVersion}"`);
55754
55786
  const newEnv = { ...env };
55755
55787
  const alreadyInPath = (newPath2) => {
55756
- return (env.PATH ?? "").split(import_path5.default.delimiter).includes(newPath2);
55788
+ return (env.PATH ?? "").split(import_path6.default.delimiter).includes(newPath2);
55757
55789
  };
55758
55790
  if (newPath && !alreadyInPath(newPath)) {
55759
55791
  const oldPath = env.PATH + "";
55760
- newEnv.PATH = `${newPath}${import_path5.default.delimiter}${oldPath}`;
55792
+ newEnv.PATH = `${newPath}${import_path6.default.delimiter}${oldPath}`;
55761
55793
  if (detectedLockfile && detectedPackageManager) {
55762
55794
  const detectedV9PnpmLockfile = detectedLockfile === "pnpm-lock.yaml" && lockfileVersion === 9;
55763
55795
  if (detectedPackageManager === "pnpm@10.x" && packageJsonPackageManager) {
@@ -55924,7 +55956,7 @@ To use ${otherVersion}, manually opt in using corepack (https://vercel.com/docs/
55924
55956
  });
55925
55957
  if (corepackEnabled) overrides = NO_OVERRIDE;
55926
55958
  const alreadyInPath = (newPath) => {
55927
- return (env.PATH ?? "").split(import_path5.default.delimiter).includes(newPath);
55959
+ return (env.PATH ?? "").split(import_path6.default.delimiter).includes(newPath);
55928
55960
  };
55929
55961
  switch (true) {
55930
55962
  case cliType === "yarn" && !env.YARN_NODE_LINKER: return {
@@ -55944,6 +55976,17 @@ To use ${otherVersion}, manually opt in using corepack (https://vercel.com/docs/
55944
55976
  }
55945
55977
  }
55946
55978
  async function runCustomInstallCommand({ destPath, installCommand, spawnOpts, projectCreatedAt }) {
55979
+ const normalizedPath = import_path6.default.normalize(destPath);
55980
+ const { alreadyInstalled, runNpmInstallSet } = checkIfAlreadyInstalled(customInstallCommandSet, normalizedPath);
55981
+ customInstallCommandSet = runNpmInstallSet;
55982
+ if (alreadyInstalled) {
55983
+ debug$1(`Skipping custom install command for ${normalizedPath} because it was already run`);
55984
+ return false;
55985
+ }
55986
+ if (process.env.VERCEL_INSTALL_COMPLETED === "1") {
55987
+ debug$1(`Skipping custom install command for ${normalizedPath} because VERCEL_INSTALL_COMPLETED is set`);
55988
+ return false;
55989
+ }
55947
55990
  console.log(`Running "install" command: \`${installCommand}\`...`);
55948
55991
  const { cliType, lockfileVersion, packageJson, packageJsonPackageManager, turboSupportsCorepackHome } = await scanParentDirs(destPath, true);
55949
55992
  const env = getEnvForPackageManager({
@@ -55961,9 +56004,10 @@ To use ${otherVersion}, manually opt in using corepack (https://vercel.com/docs/
55961
56004
  env,
55962
56005
  cwd: destPath
55963
56006
  });
56007
+ return true;
55964
56008
  }
55965
56009
  async function runPackageJsonScript(destPath, scriptNames, spawnOpts, projectCreatedAt) {
55966
- (0, import_assert6.default)(import_path5.default.isAbsolute(destPath));
56010
+ (0, import_assert6.default)(import_path6.default.isAbsolute(destPath));
55967
56011
  const { packageJson, cliType, lockfileVersion, packageJsonPackageManager, turboSupportsCorepackHome } = await scanParentDirs(destPath, true);
55968
56012
  const scriptName = getScriptName(packageJson, typeof scriptNames === "string" ? [scriptNames] : scriptNames);
55969
56013
  if (!scriptName) return false;
@@ -55997,7 +56041,7 @@ To use ${otherVersion}, manually opt in using corepack (https://vercel.com/docs/
55997
56041
  debug$1("Skipping dependency installation because dev mode is enabled");
55998
56042
  return;
55999
56043
  }
56000
- (0, import_assert6.default)(import_path5.default.isAbsolute(destPath));
56044
+ (0, import_assert6.default)(import_path6.default.isAbsolute(destPath));
56001
56045
  const opts = {
56002
56046
  ...spawnOpts,
56003
56047
  cwd: destPath,
@@ -56008,19 +56052,26 @@ To use ${otherVersion}, manually opt in using corepack (https://vercel.com/docs/
56008
56052
  async function runPipInstall(destPath, args = [], spawnOpts, meta) {
56009
56053
  if (meta && meta.isDev) {
56010
56054
  debug$1("Skipping dependency installation because dev mode is enabled");
56011
- return;
56055
+ return { installed: false };
56012
56056
  }
56013
- (0, import_assert6.default)(import_path5.default.isAbsolute(destPath));
56057
+ (0, import_assert6.default)(import_path6.default.isAbsolute(destPath));
56058
+ const targetDir = import_path6.default.join(destPath, ".vercel_python_packages");
56014
56059
  const opts = {
56015
56060
  ...spawnOpts,
56016
56061
  cwd: destPath,
56017
- prettyCommand: "pip3 install"
56062
+ prettyCommand: "uv pip install"
56018
56063
  };
56019
- await spawnAsync("pip3", [
56064
+ await spawnAsync("uv", [
56065
+ "pip",
56020
56066
  "install",
56021
- "--disable-pip-version-check",
56067
+ "--target",
56068
+ targetDir,
56022
56069
  ...args
56023
56070
  ], opts);
56071
+ return {
56072
+ installed: true,
56073
+ targetDir
56074
+ };
56024
56075
  }
56025
56076
  function getScriptName(pkg, possibleNames) {
56026
56077
  if (pkg?.scripts) {
@@ -56028,7 +56079,7 @@ To use ${otherVersion}, manually opt in using corepack (https://vercel.com/docs/
56028
56079
  }
56029
56080
  }
56030
56081
  var installDependencies = (0, import_util2.deprecate)(runNpmInstall, "installDependencies() is deprecated. Please use runNpmInstall() instead.");
56031
- var import_path6 = __toESM(__require("path"));
56082
+ var import_path7 = __toESM(__require("path"));
56032
56083
  var import_fs_extra8 = __toESM(require_lib());
56033
56084
  var import_ignore = __toESM(require_ignore());
56034
56085
  function isCodedError(error) {
@@ -56046,8 +56097,8 @@ To use ${otherVersion}, manually opt in using corepack (https://vercel.com/docs/
56046
56097
  throw error;
56047
56098
  }
56048
56099
  };
56049
- const vercelIgnorePath = import_path6.default.join(downloadPath, rootDirectory || "", ".vercelignore");
56050
- const nowIgnorePath = import_path6.default.join(downloadPath, rootDirectory || "", ".nowignore");
56100
+ const vercelIgnorePath = import_path7.default.join(downloadPath, rootDirectory || "", ".vercelignore");
56101
+ const nowIgnorePath = import_path7.default.join(downloadPath, rootDirectory || "", ".nowignore");
56051
56102
  const ignoreContents = [];
56052
56103
  try {
56053
56104
  ignoreContents.push(...(await Promise.all([readFile4(vercelIgnorePath), readFile4(nowIgnorePath)])).filter(Boolean));
@@ -56085,18 +56136,18 @@ To use ${otherVersion}, manually opt in using corepack (https://vercel.com/docs/
56085
56136
  }
56086
56137
  return newEnvs;
56087
56138
  }
56088
- var import_path7 = __toESM(__require("path"));
56139
+ var import_path8 = __toESM(__require("path"));
56089
56140
  var import_fs2 = __require("fs");
56090
56141
  async function hardLinkDir(src, destDirs) {
56091
56142
  if (destDirs.length === 0) return;
56092
- destDirs = destDirs.filter((destDir) => import_path7.default.relative(destDir, src) !== "");
56143
+ destDirs = destDirs.filter((destDir) => import_path8.default.relative(destDir, src) !== "");
56093
56144
  const files = await import_fs2.promises.readdir(src);
56094
56145
  await Promise.all(files.map(async (file) => {
56095
56146
  if (file === "node_modules") return;
56096
- const srcFile = import_path7.default.join(src, file);
56147
+ const srcFile = import_path8.default.join(src, file);
56097
56148
  if ((await import_fs2.promises.lstat(srcFile)).isDirectory()) {
56098
56149
  await hardLinkDir(srcFile, await Promise.all(destDirs.map(async (destDir) => {
56099
- const destSubdir = import_path7.default.join(destDir, file);
56150
+ const destSubdir = import_path8.default.join(destDir, file);
56100
56151
  try {
56101
56152
  await import_fs2.promises.mkdir(destSubdir, { recursive: true });
56102
56153
  } catch (err) {
@@ -56107,7 +56158,7 @@ To use ${otherVersion}, manually opt in using corepack (https://vercel.com/docs/
56107
56158
  return;
56108
56159
  }
56109
56160
  await Promise.all(destDirs.map(async (destDir) => {
56110
- const destFile = import_path7.default.join(destDir, file);
56161
+ const destFile = import_path8.default.join(destDir, file);
56111
56162
  try {
56112
56163
  await linkOrCopyFile(srcFile, destFile);
56113
56164
  } catch (err) {
@@ -56122,7 +56173,7 @@ To use ${otherVersion}, manually opt in using corepack (https://vercel.com/docs/
56122
56173
  await linkOrCopy(srcFile, destFile);
56123
56174
  } catch (err) {
56124
56175
  if (err.code === "ENOENT") {
56125
- await import_fs2.promises.mkdir(import_path7.default.dirname(destFile), { recursive: true });
56176
+ await import_fs2.promises.mkdir(import_path8.default.dirname(destFile), { recursive: true });
56126
56177
  await linkOrCopy(srcFile, destFile);
56127
56178
  return;
56128
56179
  }
@@ -56137,10 +56188,10 @@ To use ${otherVersion}, manually opt in using corepack (https://vercel.com/docs/
56137
56188
  await import_fs2.promises.copyFile(srcFile, destFile);
56138
56189
  }
56139
56190
  }
56140
- var import_path8 = __require("path");
56191
+ var import_path9 = __require("path");
56141
56192
  var import_promises = __require("fs/promises");
56142
56193
  async function validateNpmrc(cwd) {
56143
- if ((await (0, import_promises.readFile)((0, import_path8.join)(cwd, ".npmrc"), "utf-8").catch((err) => {
56194
+ if ((await (0, import_promises.readFile)((0, import_path9.join)(cwd, ".npmrc"), "utf-8").catch((err) => {
56144
56195
  if (err.code !== "ENOENT") throw err;
56145
56196
  }))?.match(/(?<!#.*)use-node-version/)) throw new Error("Detected unsupported \"use-node-version\" in your \".npmrc\". Please use \"engines\" in your \"package.json\" instead.");
56146
56197
  }
@@ -56181,12 +56232,12 @@ To use ${otherVersion}, manually opt in using corepack (https://vercel.com/docs/
56181
56232
  if (!os) return "provided.al2023";
56182
56233
  return os.PRETTY_NAME === "Amazon Linux 2" ? "provided.al2" : "provided.al2023";
56183
56234
  }
56184
- var import_path9 = __require("path");
56235
+ var import_path10 = __require("path");
56185
56236
  var shouldServe = ({ entrypoint, files, requestPath }) => {
56186
56237
  requestPath = requestPath.replace(/\/$/, "");
56187
56238
  entrypoint = entrypoint.replace(/\\/, "/");
56188
56239
  if (entrypoint === requestPath && hasProp(files, entrypoint)) return true;
56189
- const { dir, name } = (0, import_path9.parse)(entrypoint);
56240
+ const { dir, name } = (0, import_path10.parse)(entrypoint);
56190
56241
  if (name === "index" && dir === requestPath && hasProp(files, entrypoint)) return true;
56191
56242
  return false;
56192
56243
  };
@@ -56467,14 +56518,21 @@ ${entrypointsForMessage}`);
56467
56518
  "express",
56468
56519
  "hono",
56469
56520
  "h3",
56521
+ "koa",
56470
56522
  "nestjs",
56471
56523
  "fastify",
56472
56524
  "elysia"
56473
56525
  ];
56526
+ var PYTHON_FRAMEWORKS = [
56527
+ "fastapi",
56528
+ "flask",
56529
+ "python"
56530
+ ];
56474
56531
  var BACKEND_BUILDERS = [
56475
56532
  "@vercel/express",
56476
56533
  "@vercel/hono",
56477
56534
  "@vercel/h3",
56535
+ "@vercel/koa",
56478
56536
  "@vercel/nestjs",
56479
56537
  "@vercel/fastify",
56480
56538
  "@vercel/elysia"
@@ -56483,6 +56541,10 @@ ${entrypointsForMessage}`);
56483
56541
  if (!framework) return false;
56484
56542
  return BACKEND_FRAMEWORKS.includes(framework);
56485
56543
  }
56544
+ function isPythonFramework(framework) {
56545
+ if (!framework) return false;
56546
+ return PYTHON_FRAMEWORKS.includes(framework);
56547
+ }
56486
56548
  function isExperimentalBackendsWithoutIntrospectionEnabled$1() {
56487
56549
  return process.env.VERCEL_BACKENDS_BUILDS === "1";
56488
56550
  }
@@ -56498,12 +56560,12 @@ ${entrypointsForMessage}`);
56498
56560
  return isExperimentalBackendsEnabled() && isBackendFramework(framework);
56499
56561
  }
56500
56562
  var import_fs3 = __toESM(__require("fs"));
56501
- var import_path10 = __require("path");
56563
+ var import_path11 = __require("path");
56502
56564
  var import_execa = __toESM(require_execa());
56503
56565
  var isWin2 = process.platform === "win32";
56504
56566
  async function runStdlibPyScript(options) {
56505
56567
  const { scriptName, pythonPath, args = [], cwd } = options;
56506
- const scriptPath = (0, import_path10.join)(__dirname, "..", "lib", "python", `${scriptName}.py`);
56568
+ const scriptPath = (0, import_path11.join)(__dirname, "..", "lib", "python", `${scriptName}.py`);
56507
56569
  if (!import_fs3.default.existsSync(scriptPath)) throw new Error(`Python script not found: ${scriptPath}`);
56508
56570
  const pythonCmd = pythonPath ?? (isWin2 ? "python" : "python3");
56509
56571
  debug$1(`Running stdlib Python script: ${pythonCmd} ${scriptPath} ${args.join(" ")}`);
@@ -56541,9 +56603,14 @@ ${entrypointsForMessage}`);
56541
56603
  }) });
56542
56604
 
56543
56605
  //#endregion
56544
- //#region src/index.ts
56606
+ //#region src/util.ts
56545
56607
  var import_dist = require_dist$1();
56546
- const require$1 = createRequire$1(import.meta.url);
56608
+ const BEGIN_INTROSPECTION_RESULT = "\n__VERCEL_INTROSPECTION_BEGIN__\n";
56609
+ const END_INTROSPECTION_RESULT = "\n__VERCEL_INTROSPECTION_END__\n";
56610
+
56611
+ //#endregion
56612
+ //#region src/index.ts
56613
+ const require$1 = createRequire(import.meta.url);
56547
56614
  const introspectApp = async (args) => {
56548
56615
  if ((0, import_dist.isExperimentalBackendsWithoutIntrospectionEnabled)()) return defaultResult(args);
56549
56616
  const cjsLoaderPath = fileURLToPath(new URL("loaders/cjs.cjs", import.meta.url));
@@ -56567,6 +56634,7 @@ const introspectApp = async (args) => {
56567
56634
  let introspectionData;
56568
56635
  await new Promise((resolvePromise) => {
56569
56636
  try {
56637
+ (0, import_dist.debug)("Spawning introspection process");
56570
56638
  const child = spawn("node", [
56571
56639
  "-r",
56572
56640
  cjsLoaderPath,
@@ -56585,29 +56653,72 @@ const introspectApp = async (args) => {
56585
56653
  ...args.env
56586
56654
  }
56587
56655
  });
56588
- child.stdout?.on("data", (data) => {
56589
- try {
56590
- introspectionData = introspectionSchema.parse(JSON.parse(data.toString() || "{}"));
56591
- } catch (error) {}
56656
+ const tempDir = mkdtempSync(join(tmpdir(), "introspection-"));
56657
+ const tempFilePath = join(tempDir, "output.txt");
56658
+ const writeStream = createWriteStream(tempFilePath);
56659
+ let streamClosed = false;
56660
+ child.stdout?.pipe(writeStream);
56661
+ writeStream.on("error", (err) => {
56662
+ (0, import_dist.debug)(`Write stream error: ${err.message}`);
56592
56663
  });
56593
56664
  const timeout = setTimeout(() => {
56665
+ (0, import_dist.debug)("Introspection timeout, killing process with SIGTERM");
56594
56666
  child.kill("SIGTERM");
56595
- }, 2e3);
56667
+ }, 8e3);
56596
56668
  const timeout2 = setTimeout(() => {
56669
+ (0, import_dist.debug)("Introspection timeout, killing process with SIGKILL");
56597
56670
  child.kill("SIGKILL");
56598
- }, 3e3);
56671
+ }, 9e3);
56599
56672
  child.on("error", (err) => {
56600
56673
  clearTimeout(timeout);
56601
56674
  clearTimeout(timeout2);
56602
- console.log(`Loader error: ${err.message}`);
56603
- resolvePromise(void 0);
56675
+ (0, import_dist.debug)(`Loader error: ${err.message}`);
56676
+ if (!streamClosed) writeStream.end(() => {
56677
+ streamClosed = true;
56678
+ try {
56679
+ unlinkSync(tempFilePath);
56680
+ } catch (cleanupErr) {
56681
+ (0, import_dist.debug)(`Error deleting temp file on error: ${cleanupErr}`);
56682
+ }
56683
+ resolvePromise(void 0);
56684
+ });
56685
+ else resolvePromise(void 0);
56604
56686
  });
56605
56687
  child.on("close", () => {
56606
56688
  clearTimeout(timeout);
56607
56689
  clearTimeout(timeout2);
56608
- resolvePromise(void 0);
56690
+ (0, import_dist.debug)("Introspection process closed");
56691
+ if (!streamClosed) writeStream.end(() => {
56692
+ streamClosed = true;
56693
+ try {
56694
+ const stdoutBuffer = readFileSync(tempFilePath, "utf8");
56695
+ const beginIndex = stdoutBuffer.indexOf(BEGIN_INTROSPECTION_RESULT);
56696
+ const endIndex = stdoutBuffer.indexOf(END_INTROSPECTION_RESULT);
56697
+ if (beginIndex !== -1 && endIndex !== -1) {
56698
+ const introspectionString = stdoutBuffer.substring(beginIndex + BEGIN_INTROSPECTION_RESULT.length, endIndex);
56699
+ if (introspectionString) {
56700
+ introspectionData = introspectionSchema.parse(JSON.parse(introspectionString));
56701
+ (0, import_dist.debug)("Introspection data parsed successfully");
56702
+ }
56703
+ }
56704
+ } catch (error) {
56705
+ (0, import_dist.debug)(`Error parsing introspection data: ${error}`);
56706
+ } finally {
56707
+ try {
56708
+ rmSync(tempDir, {
56709
+ recursive: true,
56710
+ force: true
56711
+ });
56712
+ } catch (err) {
56713
+ (0, import_dist.debug)(`Error deleting temp directory: ${err}`);
56714
+ }
56715
+ resolvePromise(void 0);
56716
+ }
56717
+ });
56718
+ else resolvePromise(void 0);
56609
56719
  });
56610
56720
  } catch (error) {
56721
+ (0, import_dist.debug)("Introspection error", error);
56611
56722
  resolvePromise(void 0);
56612
56723
  }
56613
56724
  });