@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 +71 -8
- package/build/index.js.map +3 -3
- package/build/index.mjs +81 -11
- package/build/index.mjs.map +3 -3
- package/package.json +2 -2
package/build/index.mjs
CHANGED
|
@@ -7390,12 +7390,41 @@ async function writeFilesToDirectory(targetDir, files) {
|
|
|
7390
7390
|
}
|
|
7391
7391
|
|
|
7392
7392
|
// src/run-scenario/install-dependencies.ts
|
|
7393
|
-
import {
|
|
7393
|
+
import {
|
|
7394
|
+
mkdirSync,
|
|
7395
|
+
existsSync,
|
|
7396
|
+
readFileSync,
|
|
7397
|
+
readdirSync,
|
|
7398
|
+
copyFileSync,
|
|
7399
|
+
cpSync
|
|
7400
|
+
} from "fs";
|
|
7394
7401
|
import { createHash } from "crypto";
|
|
7395
7402
|
import path from "path";
|
|
7396
7403
|
import { spawn, execFileSync } from "child_process";
|
|
7397
|
-
var INSTALL_TIMEOUT_MS =
|
|
7404
|
+
var INSTALL_TIMEOUT_MS = 1e5;
|
|
7405
|
+
var BUN_BOOTSTRAP_TIMEOUT_MS = 6e4;
|
|
7398
7406
|
var HEARTBEAT_INTERVAL_MS = 5e3;
|
|
7407
|
+
function reportRegistry(workDir, onProgress) {
|
|
7408
|
+
try {
|
|
7409
|
+
const registry = execFileSync("npm", ["config", "get", "registry"], {
|
|
7410
|
+
cwd: workDir,
|
|
7411
|
+
encoding: "utf8"
|
|
7412
|
+
}).trim();
|
|
7413
|
+
onProgress(`[diag] npm registry = ${registry}`);
|
|
7414
|
+
} catch (err) {
|
|
7415
|
+
onProgress(
|
|
7416
|
+
`[diag] npm registry = <unreadable: ${err instanceof Error ? err.message : String(err)}>`
|
|
7417
|
+
);
|
|
7418
|
+
}
|
|
7419
|
+
}
|
|
7420
|
+
function reportNodeModules(workDir, onProgress) {
|
|
7421
|
+
try {
|
|
7422
|
+
const nm = path.join(workDir, "node_modules");
|
|
7423
|
+
const count = existsSync(nm) ? readdirSync(nm).length : 0;
|
|
7424
|
+
onProgress(`[diag] node_modules top-level entries: ${count}`);
|
|
7425
|
+
} catch {
|
|
7426
|
+
}
|
|
7427
|
+
}
|
|
7399
7428
|
function defaultExec(cmd, args, opts) {
|
|
7400
7429
|
return new Promise((resolve3, reject) => {
|
|
7401
7430
|
const child = spawn(cmd, args, {
|
|
@@ -7462,33 +7491,74 @@ function cloneDirectory(src, dest) {
|
|
|
7462
7491
|
cpSync(src, dest, { recursive: true });
|
|
7463
7492
|
}
|
|
7464
7493
|
}
|
|
7465
|
-
async function
|
|
7466
|
-
onProgress(`[diag]
|
|
7494
|
+
async function runCommand(exec, cmd, args, workDir, onProgress, label, timeoutMs) {
|
|
7495
|
+
onProgress(`[diag] ${label} starting: ${cmd} ${args.join(" ")}`);
|
|
7467
7496
|
const startedAt = Date.now();
|
|
7468
7497
|
const heartbeat = setInterval(() => {
|
|
7469
7498
|
onProgress(
|
|
7470
|
-
`[diag]
|
|
7499
|
+
`[diag] ${label} still running: ${Math.round(
|
|
7471
7500
|
(Date.now() - startedAt) / 1e3
|
|
7472
7501
|
)}s elapsed`
|
|
7473
7502
|
);
|
|
7474
7503
|
}, HEARTBEAT_INTERVAL_MS);
|
|
7475
7504
|
try {
|
|
7476
|
-
await exec(
|
|
7505
|
+
await exec(cmd, args, {
|
|
7477
7506
|
cwd: workDir,
|
|
7478
|
-
timeoutMs
|
|
7507
|
+
timeoutMs,
|
|
7479
7508
|
env: { ...process.env, NODE_ENV: "development" }
|
|
7480
7509
|
});
|
|
7481
|
-
onProgress(`[diag]
|
|
7510
|
+
onProgress(`[diag] ${label} finished in ${Date.now() - startedAt}ms`);
|
|
7482
7511
|
return true;
|
|
7483
7512
|
} catch (err) {
|
|
7484
7513
|
onProgress(
|
|
7485
|
-
`[diag]
|
|
7514
|
+
`[diag] ${label} FAILED after ${Date.now() - startedAt}ms: ${err instanceof Error ? err.message : String(err)}`
|
|
7486
7515
|
);
|
|
7487
7516
|
return false;
|
|
7488
7517
|
} finally {
|
|
7489
7518
|
clearInterval(heartbeat);
|
|
7490
7519
|
}
|
|
7491
7520
|
}
|
|
7521
|
+
async function runInstall(exec, pm, workDir, onProgress) {
|
|
7522
|
+
reportRegistry(workDir, onProgress);
|
|
7523
|
+
const bunReady = await runCommand(
|
|
7524
|
+
exec,
|
|
7525
|
+
"npm",
|
|
7526
|
+
["install", "-g", "bun"],
|
|
7527
|
+
workDir,
|
|
7528
|
+
onProgress,
|
|
7529
|
+
"bun bootstrap",
|
|
7530
|
+
BUN_BOOTSTRAP_TIMEOUT_MS
|
|
7531
|
+
);
|
|
7532
|
+
if (bunReady) {
|
|
7533
|
+
const bunOk = await runCommand(
|
|
7534
|
+
exec,
|
|
7535
|
+
"bun",
|
|
7536
|
+
["install", "--ignore-scripts"],
|
|
7537
|
+
workDir,
|
|
7538
|
+
onProgress,
|
|
7539
|
+
"bun install",
|
|
7540
|
+
INSTALL_TIMEOUT_MS
|
|
7541
|
+
);
|
|
7542
|
+
if (bunOk) {
|
|
7543
|
+
reportNodeModules(workDir, onProgress);
|
|
7544
|
+
return true;
|
|
7545
|
+
}
|
|
7546
|
+
onProgress("[diag] bun install failed \u2014 falling back to npm");
|
|
7547
|
+
} else {
|
|
7548
|
+
onProgress("[diag] bun bootstrap failed \u2014 falling back to npm");
|
|
7549
|
+
}
|
|
7550
|
+
const ok = await runCommand(
|
|
7551
|
+
exec,
|
|
7552
|
+
pm.cmd,
|
|
7553
|
+
pm.args,
|
|
7554
|
+
workDir,
|
|
7555
|
+
onProgress,
|
|
7556
|
+
"npm install",
|
|
7557
|
+
INSTALL_TIMEOUT_MS
|
|
7558
|
+
);
|
|
7559
|
+
reportNodeModules(workDir, onProgress);
|
|
7560
|
+
return ok;
|
|
7561
|
+
}
|
|
7492
7562
|
async function installWithCache(workDir, exec, cacheBase, pm, onProgress) {
|
|
7493
7563
|
const sourceContent = readFileSync(
|
|
7494
7564
|
path.join(workDir, pm.cacheSourceFile),
|
|
@@ -11344,7 +11414,7 @@ var simpleAgentAdapter = new SimpleAgentAdapter();
|
|
|
11344
11414
|
defaultRegistry.register(simpleAgentAdapter);
|
|
11345
11415
|
|
|
11346
11416
|
// src/run-scenario/file-diff.ts
|
|
11347
|
-
import { readdirSync, readFileSync as readFileSync3, statSync, existsSync as existsSync3 } from "fs";
|
|
11417
|
+
import { readdirSync as readdirSync2, readFileSync as readFileSync3, statSync, existsSync as existsSync3 } from "fs";
|
|
11348
11418
|
import { join as join10, relative } from "path";
|
|
11349
11419
|
|
|
11350
11420
|
// ../../node_modules/diff/lib/index.mjs
|
|
@@ -11968,7 +12038,7 @@ function snapshotDirectory(dir, baseDir) {
|
|
|
11968
12038
|
if (!existsSync3(dir)) {
|
|
11969
12039
|
return snapshot;
|
|
11970
12040
|
}
|
|
11971
|
-
const entries =
|
|
12041
|
+
const entries = readdirSync2(dir, { withFileTypes: true });
|
|
11972
12042
|
for (const entry of entries) {
|
|
11973
12043
|
const fullPath = join10(dir, entry.name);
|
|
11974
12044
|
const relativePath = relative(base, fullPath);
|