@wix/evalforge-evaluator 0.192.0 → 0.194.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.
package/build/index.js CHANGED
@@ -7372,8 +7372,30 @@ var import_fs = require("fs");
7372
7372
  var import_crypto = require("crypto");
7373
7373
  var import_path2 = __toESM(require("path"));
7374
7374
  var import_child_process = require("child_process");
7375
- var INSTALL_TIMEOUT_MS = 9e4;
7375
+ var INSTALL_TIMEOUT_MS = 1e5;
7376
+ var BUN_BOOTSTRAP_TIMEOUT_MS = 6e4;
7376
7377
  var HEARTBEAT_INTERVAL_MS = 5e3;
7378
+ function reportRegistry(workDir, onProgress) {
7379
+ try {
7380
+ const registry = (0, import_child_process.execFileSync)("npm", ["config", "get", "registry"], {
7381
+ cwd: workDir,
7382
+ encoding: "utf8"
7383
+ }).trim();
7384
+ onProgress(`[diag] npm registry = ${registry}`);
7385
+ } catch (err) {
7386
+ onProgress(
7387
+ `[diag] npm registry = <unreadable: ${err instanceof Error ? err.message : String(err)}>`
7388
+ );
7389
+ }
7390
+ }
7391
+ function reportNodeModules(workDir, onProgress) {
7392
+ try {
7393
+ const nm = import_path2.default.join(workDir, "node_modules");
7394
+ const count = (0, import_fs.existsSync)(nm) ? (0, import_fs.readdirSync)(nm).length : 0;
7395
+ onProgress(`[diag] node_modules top-level entries: ${count}`);
7396
+ } catch {
7397
+ }
7398
+ }
7377
7399
  function defaultExec(cmd, args, opts) {
7378
7400
  return new Promise((resolve3, reject) => {
7379
7401
  const child = (0, import_child_process.spawn)(cmd, args, {
@@ -7440,33 +7462,74 @@ function cloneDirectory(src, dest) {
7440
7462
  (0, import_fs.cpSync)(src, dest, { recursive: true });
7441
7463
  }
7442
7464
  }
7443
- async function runInstall(exec, pm, workDir, onProgress) {
7444
- onProgress(`[diag] npm install starting: ${pm.cmd} ${pm.args.join(" ")}`);
7465
+ async function runCommand(exec, cmd, args, workDir, onProgress, label, timeoutMs) {
7466
+ onProgress(`[diag] ${label} starting: ${cmd} ${args.join(" ")}`);
7445
7467
  const startedAt = Date.now();
7446
7468
  const heartbeat = setInterval(() => {
7447
7469
  onProgress(
7448
- `[diag] npm install still running: ${Math.round(
7470
+ `[diag] ${label} still running: ${Math.round(
7449
7471
  (Date.now() - startedAt) / 1e3
7450
7472
  )}s elapsed`
7451
7473
  );
7452
7474
  }, HEARTBEAT_INTERVAL_MS);
7453
7475
  try {
7454
- await exec(pm.cmd, pm.args, {
7476
+ await exec(cmd, args, {
7455
7477
  cwd: workDir,
7456
- timeoutMs: INSTALL_TIMEOUT_MS,
7478
+ timeoutMs,
7457
7479
  env: { ...process.env, NODE_ENV: "development" }
7458
7480
  });
7459
- onProgress(`[diag] npm install finished in ${Date.now() - startedAt}ms`);
7481
+ onProgress(`[diag] ${label} finished in ${Date.now() - startedAt}ms`);
7460
7482
  return true;
7461
7483
  } catch (err) {
7462
7484
  onProgress(
7463
- `[diag] npm install FAILED after ${Date.now() - startedAt}ms: ${err instanceof Error ? err.message : String(err)}`
7485
+ `[diag] ${label} FAILED after ${Date.now() - startedAt}ms: ${err instanceof Error ? err.message : String(err)}`
7464
7486
  );
7465
7487
  return false;
7466
7488
  } finally {
7467
7489
  clearInterval(heartbeat);
7468
7490
  }
7469
7491
  }
7492
+ async function runInstall(exec, pm, workDir, onProgress) {
7493
+ reportRegistry(workDir, onProgress);
7494
+ const bunReady = await runCommand(
7495
+ exec,
7496
+ "npm",
7497
+ ["install", "-g", "bun"],
7498
+ workDir,
7499
+ onProgress,
7500
+ "bun bootstrap",
7501
+ BUN_BOOTSTRAP_TIMEOUT_MS
7502
+ );
7503
+ if (bunReady) {
7504
+ const bunOk = await runCommand(
7505
+ exec,
7506
+ "bun",
7507
+ ["install", "--ignore-scripts"],
7508
+ workDir,
7509
+ onProgress,
7510
+ "bun install",
7511
+ INSTALL_TIMEOUT_MS
7512
+ );
7513
+ if (bunOk) {
7514
+ reportNodeModules(workDir, onProgress);
7515
+ return true;
7516
+ }
7517
+ onProgress("[diag] bun install failed \u2014 falling back to npm");
7518
+ } else {
7519
+ onProgress("[diag] bun bootstrap failed \u2014 falling back to npm");
7520
+ }
7521
+ const ok = await runCommand(
7522
+ exec,
7523
+ pm.cmd,
7524
+ pm.args,
7525
+ workDir,
7526
+ onProgress,
7527
+ "npm install",
7528
+ INSTALL_TIMEOUT_MS
7529
+ );
7530
+ reportNodeModules(workDir, onProgress);
7531
+ return ok;
7532
+ }
7470
7533
  async function installWithCache(workDir, exec, cacheBase, pm, onProgress) {
7471
7534
  const sourceContent = (0, import_fs.readFileSync)(
7472
7535
  import_path2.default.join(workDir, pm.cacheSourceFile),