@wix/evalforge-evaluator 0.222.0 → 0.223.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 +23 -87
- package/build/index.js.map +3 -3
- package/build/index.mjs +11 -82
- package/build/index.mjs.map +3 -3
- package/build/types/run-scenario/install-dependencies.d.ts +1 -6
- package/package.json +2 -2
package/build/index.mjs
CHANGED
|
@@ -7411,7 +7411,7 @@ import {
|
|
|
7411
7411
|
} from "@wix/eval-assertions";
|
|
7412
7412
|
|
|
7413
7413
|
// src/run-scenario/environment.ts
|
|
7414
|
-
import { mkdirSync
|
|
7414
|
+
import { mkdirSync, existsSync as existsSync2, rmSync, readFileSync, writeFileSync } from "fs";
|
|
7415
7415
|
import { mkdir as mkdir2, writeFile as writeFile2 } from "fs/promises";
|
|
7416
7416
|
import { tmpdir } from "os";
|
|
7417
7417
|
import path2, { sep as sep2 } from "path";
|
|
@@ -7438,15 +7438,7 @@ async function writeFilesToDirectory(targetDir, files) {
|
|
|
7438
7438
|
}
|
|
7439
7439
|
|
|
7440
7440
|
// src/run-scenario/install-dependencies.ts
|
|
7441
|
-
import {
|
|
7442
|
-
mkdirSync,
|
|
7443
|
-
existsSync,
|
|
7444
|
-
readFileSync,
|
|
7445
|
-
readdirSync,
|
|
7446
|
-
copyFileSync,
|
|
7447
|
-
cpSync
|
|
7448
|
-
} from "fs";
|
|
7449
|
-
import { createHash } from "crypto";
|
|
7441
|
+
import { existsSync, readdirSync } from "fs";
|
|
7450
7442
|
import path from "path";
|
|
7451
7443
|
import { spawn, execFileSync } from "child_process";
|
|
7452
7444
|
var INSTALL_TIMEOUT_MS = 18e4;
|
|
@@ -7545,18 +7537,16 @@ function detectPackageManager(workDir) {
|
|
|
7545
7537
|
if (existsSync(path.join(workDir, "pnpm-lock.yaml"))) {
|
|
7546
7538
|
return {
|
|
7547
7539
|
cmd: "pnpm",
|
|
7548
|
-
args: ["install", "--frozen-lockfile"]
|
|
7549
|
-
cacheSourceFile: "pnpm-lock.yaml"
|
|
7540
|
+
args: ["install", "--frozen-lockfile"]
|
|
7550
7541
|
};
|
|
7551
7542
|
}
|
|
7552
7543
|
if (existsSync(path.join(workDir, "package-lock.json"))) {
|
|
7553
|
-
return { cmd: "npm", args: ["ci"]
|
|
7544
|
+
return { cmd: "npm", args: ["ci"] };
|
|
7554
7545
|
}
|
|
7555
7546
|
if (existsSync(path.join(workDir, "yarn.lock"))) {
|
|
7556
7547
|
return {
|
|
7557
7548
|
cmd: "yarn",
|
|
7558
|
-
args: ["install", "--frozen-lockfile"]
|
|
7559
|
-
cacheSourceFile: "yarn.lock"
|
|
7549
|
+
args: ["install", "--frozen-lockfile"]
|
|
7560
7550
|
};
|
|
7561
7551
|
}
|
|
7562
7552
|
return {
|
|
@@ -7567,17 +7557,9 @@ function detectPackageManager(workDir) {
|
|
|
7567
7557
|
"--prefer-offline",
|
|
7568
7558
|
"--no-fund",
|
|
7569
7559
|
"--no-audit"
|
|
7570
|
-
]
|
|
7571
|
-
cacheSourceFile: "package.json"
|
|
7560
|
+
]
|
|
7572
7561
|
};
|
|
7573
7562
|
}
|
|
7574
|
-
function cloneDirectory(src, dest) {
|
|
7575
|
-
if (process.platform === "darwin") {
|
|
7576
|
-
execFileSync("cp", ["-rc", src, dest]);
|
|
7577
|
-
} else {
|
|
7578
|
-
cpSync(src, dest, { recursive: true });
|
|
7579
|
-
}
|
|
7580
|
-
}
|
|
7581
7563
|
async function runInstall(exec, pm, workDir, onProgress) {
|
|
7582
7564
|
reportRegistry(workDir, onProgress);
|
|
7583
7565
|
onProgress(`[diag] npm install starting: ${pm.cmd} ${pm.args.join(" ")}`);
|
|
@@ -7608,64 +7590,13 @@ async function runInstall(exec, pm, workDir, onProgress) {
|
|
|
7608
7590
|
clearInterval(heartbeat);
|
|
7609
7591
|
}
|
|
7610
7592
|
}
|
|
7611
|
-
async function installWithCache(workDir, exec, cacheBase, pm, onProgress) {
|
|
7612
|
-
const sourceContent = readFileSync(
|
|
7613
|
-
path.join(workDir, pm.cacheSourceFile),
|
|
7614
|
-
"utf-8"
|
|
7615
|
-
);
|
|
7616
|
-
const cacheKey = createHash("sha256").update(sourceContent).digest("hex").slice(0, 16);
|
|
7617
|
-
const cachedNodeModules = path.join(cacheBase, cacheKey, "node_modules");
|
|
7618
|
-
const targetNodeModules = path.join(workDir, "node_modules");
|
|
7619
|
-
const cacheDir = path.dirname(cachedNodeModules);
|
|
7620
|
-
const cachedYarnLock = path.join(cacheDir, "yarn.lock");
|
|
7621
|
-
if (existsSync(cachedNodeModules)) {
|
|
7622
|
-
console.log(
|
|
7623
|
-
`[environment] Restoring node_modules from cache (key: ${cacheKey})`
|
|
7624
|
-
);
|
|
7625
|
-
onProgress(`[diag] node_modules cache HIT (key: ${cacheKey}) \u2014 restoring`);
|
|
7626
|
-
if (!existsSync(targetNodeModules)) {
|
|
7627
|
-
cloneDirectory(cachedNodeModules, targetNodeModules);
|
|
7628
|
-
}
|
|
7629
|
-
if (existsSync(cachedYarnLock)) {
|
|
7630
|
-
copyFileSync(cachedYarnLock, path.join(workDir, "yarn.lock"));
|
|
7631
|
-
}
|
|
7632
|
-
onProgress("[diag] node_modules cache restore complete");
|
|
7633
|
-
return;
|
|
7634
|
-
}
|
|
7635
|
-
onProgress(`[diag] node_modules cache MISS (key: ${cacheKey})`);
|
|
7636
|
-
const ok = await runInstall(exec, pm, workDir, onProgress);
|
|
7637
|
-
if (!ok) {
|
|
7638
|
-
return;
|
|
7639
|
-
}
|
|
7640
|
-
console.log(
|
|
7641
|
-
"[environment] Dependency installation complete \u2014 saving to cache"
|
|
7642
|
-
);
|
|
7643
|
-
try {
|
|
7644
|
-
mkdirSync(cacheDir, { recursive: true });
|
|
7645
|
-
const yarnLockPath = path.join(workDir, "yarn.lock");
|
|
7646
|
-
if (existsSync(yarnLockPath)) {
|
|
7647
|
-
copyFileSync(yarnLockPath, cachedYarnLock);
|
|
7648
|
-
}
|
|
7649
|
-
cloneDirectory(targetNodeModules, cachedNodeModules);
|
|
7650
|
-
} catch (err) {
|
|
7651
|
-
console.error(
|
|
7652
|
-
"[environment] Failed to save to cache (installation still succeeded):",
|
|
7653
|
-
err instanceof Error ? err.message : String(err)
|
|
7654
|
-
);
|
|
7655
|
-
}
|
|
7656
|
-
}
|
|
7657
7593
|
async function installDependencies(workDir, onProgress, options = {}) {
|
|
7658
7594
|
if (!existsSync(path.join(workDir, "package.json"))) {
|
|
7659
7595
|
return;
|
|
7660
7596
|
}
|
|
7661
7597
|
const exec = options.exec ?? defaultExec;
|
|
7662
|
-
const cacheBase = options.cacheBase;
|
|
7663
7598
|
onProgress("Installing dependencies...");
|
|
7664
7599
|
const pm = detectPackageManager(workDir);
|
|
7665
|
-
if (cacheBase) {
|
|
7666
|
-
await installWithCache(workDir, exec, cacheBase, pm, onProgress);
|
|
7667
|
-
return;
|
|
7668
|
-
}
|
|
7669
7600
|
await runInstall(exec, pm, workDir, onProgress);
|
|
7670
7601
|
}
|
|
7671
7602
|
|
|
@@ -7793,7 +7724,7 @@ function writeWixEnvFile(workDir) {
|
|
|
7793
7724
|
return;
|
|
7794
7725
|
}
|
|
7795
7726
|
try {
|
|
7796
|
-
const config = JSON.parse(
|
|
7727
|
+
const config = JSON.parse(readFileSync(configPath, "utf-8"));
|
|
7797
7728
|
if (config.appId) {
|
|
7798
7729
|
writeFileSync(
|
|
7799
7730
|
path2.join(workDir, ".env"),
|
|
@@ -7810,7 +7741,6 @@ function writeWixEnvFile(workDir) {
|
|
|
7810
7741
|
async function prepareWorkingDirectory(config, evalRunId2, targetId, scenarioId, onProgress, options = {}) {
|
|
7811
7742
|
const template = options.template;
|
|
7812
7743
|
const baseDir = config.evaluationsDir ?? path2.join(tmpdir(), "evalforge-evaluations");
|
|
7813
|
-
const nodeModulesCacheDir = path2.join(baseDir, "_node_modules_cache");
|
|
7814
7744
|
if (template) {
|
|
7815
7745
|
if (!config.evaluationsDir) {
|
|
7816
7746
|
console.warn(
|
|
@@ -7821,7 +7751,7 @@ async function prepareWorkingDirectory(config, evalRunId2, targetId, scenarioId,
|
|
|
7821
7751
|
if (existsSync2(workDir2)) {
|
|
7822
7752
|
rmSync(workDir2, { recursive: true });
|
|
7823
7753
|
}
|
|
7824
|
-
|
|
7754
|
+
mkdirSync(workDir2, { recursive: true });
|
|
7825
7755
|
onProgress("Fetching template files...");
|
|
7826
7756
|
await fetchAndWriteTemplateFiles(template, workDir2, onProgress);
|
|
7827
7757
|
console.log(`Template files written to ${workDir2}`);
|
|
@@ -7829,7 +7759,6 @@ async function prepareWorkingDirectory(config, evalRunId2, targetId, scenarioId,
|
|
|
7829
7759
|
writeWixEnvFile(workDir2);
|
|
7830
7760
|
onProgress("[diag] entering installDependencies");
|
|
7831
7761
|
await installDependencies(workDir2, onProgress, {
|
|
7832
|
-
cacheBase: nodeModulesCacheDir,
|
|
7833
7762
|
exec: createLoggingInstallExec(onProgress)
|
|
7834
7763
|
});
|
|
7835
7764
|
onProgress("[diag] installDependencies returned");
|
|
@@ -7840,7 +7769,7 @@ async function prepareWorkingDirectory(config, evalRunId2, targetId, scenarioId,
|
|
|
7840
7769
|
if (existsSync2(workDir)) {
|
|
7841
7770
|
rmSync(workDir, { recursive: true });
|
|
7842
7771
|
}
|
|
7843
|
-
|
|
7772
|
+
mkdirSync(workDir, { recursive: true });
|
|
7844
7773
|
console.log(`Empty working directory created at ${workDir}`);
|
|
7845
7774
|
return workDir;
|
|
7846
7775
|
}
|
|
@@ -11632,7 +11561,7 @@ var simpleAgentAdapter = new SimpleAgentAdapter();
|
|
|
11632
11561
|
defaultRegistry.register(simpleAgentAdapter);
|
|
11633
11562
|
|
|
11634
11563
|
// src/run-scenario/file-diff.ts
|
|
11635
|
-
import { readdirSync as readdirSync2, readFileSync as
|
|
11564
|
+
import { readdirSync as readdirSync2, readFileSync as readFileSync2, statSync, existsSync as existsSync3 } from "fs";
|
|
11636
11565
|
import { join as join10, relative } from "path";
|
|
11637
11566
|
|
|
11638
11567
|
// ../../node_modules/diff/lib/index.mjs
|
|
@@ -12275,7 +12204,7 @@ function snapshotDirectory(dir, baseDir) {
|
|
|
12275
12204
|
if (stats.size > MAX_FILE_SIZE) {
|
|
12276
12205
|
continue;
|
|
12277
12206
|
}
|
|
12278
|
-
const content =
|
|
12207
|
+
const content = readFileSync2(fullPath, "utf-8");
|
|
12279
12208
|
snapshot[relativePath] = content;
|
|
12280
12209
|
} catch {
|
|
12281
12210
|
continue;
|