Make Eve onboarding one executable path
This commit is contained in:
parent
44abedfc9f
commit
3c19e54d91
8 changed files with 157 additions and 29 deletions
|
|
@ -1,5 +1,6 @@
|
|||
import assert from "node:assert/strict";
|
||||
import { spawn } from "node:child_process";
|
||||
import { existsSync } from "node:fs";
|
||||
import { createServer as createHttpServer } from "node:http";
|
||||
import { mkdtemp, readFile, rm } from "node:fs/promises";
|
||||
import { createServer as createNetServer } from "node:net";
|
||||
|
|
@ -45,7 +46,12 @@ try {
|
|||
const bundle = await readFile(bundlePath, "utf8");
|
||||
assert.doesNotMatch(bundle, /(?:from\s*["']node:|require\(["']node:)/u, "browser bundle contains a Node builtin import");
|
||||
|
||||
await run("dotnet", ["build", join(sampleRoot, "EveBrowserNetworkSample.csproj"), "--verbosity", "quiet"]);
|
||||
await run("dotnet", [
|
||||
"build",
|
||||
join(sampleRoot, "EveBrowserNetworkSample.csproj"),
|
||||
"--verbosity", "quiet",
|
||||
"-p:NoWarn=1591%3BCS8632",
|
||||
]);
|
||||
const providerPort = await freePort();
|
||||
const replacementProviderPort = await freePort();
|
||||
const odinPort = await freePort();
|
||||
|
|
@ -58,8 +64,7 @@ try {
|
|||
await headless.waitFor("HEADLESS_READY ");
|
||||
httpServer = await serve(httpPort, sampleRoot, bundlePath);
|
||||
|
||||
const executablePath = process.env.CHROME_PATH || "C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe";
|
||||
browser = await chromium.launch({ executablePath, headless: true });
|
||||
browser = await chromium.launch({ executablePath: resolveChromiumExecutable(), headless: true });
|
||||
let page = await browser.newPage();
|
||||
const url = `http://127.0.0.1:${httpPort}/?odin=${encodeURIComponent(odinEndpoint)}&token=${token}`;
|
||||
await page.goto(url);
|
||||
|
|
@ -221,3 +226,36 @@ async function stop(process) {
|
|||
]);
|
||||
if (process.exitCode === null) process.kill("SIGKILL");
|
||||
}
|
||||
|
||||
function resolveChromiumExecutable() {
|
||||
const candidates = [process.env.CHROME_PATH];
|
||||
if (process.platform === "win32") {
|
||||
for (const root of [process.env.ProgramFiles, process.env["ProgramFiles(x86)"], process.env.LOCALAPPDATA]) {
|
||||
if (!root) continue;
|
||||
candidates.push(
|
||||
join(root, "Google", "Chrome", "Application", "chrome.exe"),
|
||||
join(root, "Microsoft", "Edge", "Application", "msedge.exe"),
|
||||
);
|
||||
}
|
||||
} else if (process.platform === "darwin") {
|
||||
candidates.push(
|
||||
"/Applications/Google Chrome.app/Contents/MacOS/Google Chrome",
|
||||
"/Applications/Microsoft Edge.app/Contents/MacOS/Microsoft Edge",
|
||||
);
|
||||
} else {
|
||||
candidates.push(
|
||||
"/usr/bin/google-chrome",
|
||||
"/usr/bin/google-chrome-stable",
|
||||
"/usr/bin/chromium",
|
||||
"/usr/bin/chromium-browser",
|
||||
"/opt/google/chrome/chrome",
|
||||
);
|
||||
}
|
||||
candidates.push(chromium.executablePath());
|
||||
const executablePath = candidates.find(candidate => candidate && existsSync(candidate));
|
||||
if (executablePath) return executablePath;
|
||||
throw new Error(
|
||||
"No Chromium-family browser was found. Set CHROME_PATH or run "
|
||||
+ "'node node_modules/playwright-core/cli.js install chromium'.",
|
||||
);
|
||||
}
|
||||
|
|
|
|||
29
scripts/verify-eve-getting-started.ps1
Normal file
29
scripts/verify-eve-getting-started.ps1
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
param(
|
||||
[string] $EveRoot = (Join-Path (Split-Path -Parent $PSScriptRoot) "..\Eve"),
|
||||
[switch] $SkipDependencyInstall
|
||||
)
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
$cultLibRoot = Split-Path -Parent $PSScriptRoot
|
||||
$EveRoot = [IO.Path]::GetFullPath($EveRoot)
|
||||
|
||||
& (Join-Path $PSScriptRoot "verify-eve-two-runtime-sample.ps1") `
|
||||
-EveRoot $EveRoot `
|
||||
-SkipDependencyInstall:$SkipDependencyInstall
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
throw "The clean package-consumer checkpoint failed."
|
||||
}
|
||||
|
||||
$nodeCommand = Get-Command node -ErrorAction Stop
|
||||
$playwrightCli = Join-Path $cultLibRoot "node_modules\playwright-core\cli.js"
|
||||
if (-not (Test-Path -LiteralPath $playwrightCli -PathType Leaf)) {
|
||||
throw "playwright-core is missing after dependency setup: $playwrightCli"
|
||||
}
|
||||
|
||||
& $nodeCommand.Source (Join-Path $PSScriptRoot "verify-eve-browser-network.mjs") `
|
||||
--eve-root $EveRoot
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
throw "The real browser/C# network checkpoint failed."
|
||||
}
|
||||
|
||||
Write-Host "Eve getting-started verification passed: clean artifacts, DOM and headless convergence, real Chromium and C# clients, Odin discovery, receipts, persistence, and route replacement."
|
||||
Loading…
Reference in a new issue