mirror of
https://github.com/getpaseo/paseo.git
synced 2026-07-29 12:01:31 +00:00
Switch to double quotes and reformat codebase with Biome
This commit is contained in:
@@ -1,14 +1,14 @@
|
||||
#!/usr/bin/env node
|
||||
import { chromium } from 'playwright';
|
||||
import { chromium } from "playwright";
|
||||
|
||||
function parseArgs(argv) {
|
||||
const args = {};
|
||||
for (let i = 2; i < argv.length; i += 1) {
|
||||
const part = argv[i];
|
||||
if (!part.startsWith('--')) continue;
|
||||
if (!part.startsWith("--")) continue;
|
||||
const key = part.slice(2);
|
||||
const next = argv[i + 1];
|
||||
if (!next || next.startsWith('--')) {
|
||||
if (!next || next.startsWith("--")) {
|
||||
args[key] = true;
|
||||
continue;
|
||||
}
|
||||
@@ -20,27 +20,30 @@ function parseArgs(argv) {
|
||||
|
||||
const args = parseArgs(process.argv);
|
||||
|
||||
const serverId = args['server-id'] ?? process.env.PASEO_SERVER_ID;
|
||||
const daemonPublicKeyB64 = args['daemon-public-key-b64'] ?? process.env.PASEO_DAEMON_PUBLIC_KEY_B64;
|
||||
const relayEndpoint = args['relay-endpoint'] ?? process.env.PASEO_RELAY_ENDPOINT ?? 'relay.paseo.sh:443';
|
||||
const baseUrl = args['base-url'] ?? process.env.PASEO_APP_URL ?? 'https://app.paseo.sh';
|
||||
const timeoutMs = Number(args['timeout-ms'] ?? process.env.PASEO_PROVE_TIMEOUT_MS ?? 60_000);
|
||||
const stabilityMs = Number(args['stability-ms'] ?? process.env.PASEO_PROVE_STABILITY_MS ?? 30_000);
|
||||
const serverId = args["server-id"] ?? process.env.PASEO_SERVER_ID;
|
||||
const daemonPublicKeyB64 = args["daemon-public-key-b64"] ?? process.env.PASEO_DAEMON_PUBLIC_KEY_B64;
|
||||
const relayEndpoint =
|
||||
args["relay-endpoint"] ?? process.env.PASEO_RELAY_ENDPOINT ?? "relay.paseo.sh:443";
|
||||
const baseUrl = args["base-url"] ?? process.env.PASEO_APP_URL ?? "https://app.paseo.sh";
|
||||
const timeoutMs = Number(args["timeout-ms"] ?? process.env.PASEO_PROVE_TIMEOUT_MS ?? 60_000);
|
||||
const stabilityMs = Number(args["stability-ms"] ?? process.env.PASEO_PROVE_STABILITY_MS ?? 30_000);
|
||||
|
||||
if (!serverId || typeof serverId !== 'string') {
|
||||
console.error('Missing server ID. Provide --server-id or PASEO_SERVER_ID.');
|
||||
if (!serverId || typeof serverId !== "string") {
|
||||
console.error("Missing server ID. Provide --server-id or PASEO_SERVER_ID.");
|
||||
process.exit(2);
|
||||
}
|
||||
if (!daemonPublicKeyB64 || typeof daemonPublicKeyB64 !== 'string') {
|
||||
console.error('Missing daemon public key. Provide --daemon-public-key-b64 or PASEO_DAEMON_PUBLIC_KEY_B64.');
|
||||
if (!daemonPublicKeyB64 || typeof daemonPublicKeyB64 !== "string") {
|
||||
console.error(
|
||||
"Missing daemon public key. Provide --daemon-public-key-b64 or PASEO_DAEMON_PUBLIC_KEY_B64.",
|
||||
);
|
||||
process.exit(2);
|
||||
}
|
||||
|
||||
const nowIso = new Date().toISOString();
|
||||
const daemon = {
|
||||
serverId,
|
||||
label: 'relay-daemon',
|
||||
connections: [{ id: `relay:${relayEndpoint}`, type: 'relay', relayEndpoint, daemonPublicKeyB64 }],
|
||||
label: "relay-daemon",
|
||||
connections: [{ id: `relay:${relayEndpoint}`, type: "relay", relayEndpoint, daemonPublicKeyB64 }],
|
||||
preferredConnectionId: `relay:${relayEndpoint}`,
|
||||
createdAt: nowIso,
|
||||
updatedAt: nowIso,
|
||||
@@ -50,24 +53,27 @@ const browser = await chromium.launch({ headless: true });
|
||||
const context = await browser.newContext();
|
||||
const page = await context.newPage();
|
||||
|
||||
page.on('console', (m) => console.log(`[browser:${m.type()}] ${m.text()}`));
|
||||
page.on('pageerror', (e) => console.error(`[browser:pageerror] ${e.message}`));
|
||||
page.on("console", (m) => console.log(`[browser:${m.type()}] ${m.text()}`));
|
||||
page.on("pageerror", (e) => console.error(`[browser:pageerror] ${e.message}`));
|
||||
|
||||
await page.addInitScript((seed) => {
|
||||
localStorage.setItem('@paseo:daemon-registry', JSON.stringify([seed.daemon]));
|
||||
localStorage.removeItem('@paseo:settings');
|
||||
}, { daemon });
|
||||
await page.addInitScript(
|
||||
(seed) => {
|
||||
localStorage.setItem("@paseo:daemon-registry", JSON.stringify([seed.daemon]));
|
||||
localStorage.removeItem("@paseo:settings");
|
||||
},
|
||||
{ daemon },
|
||||
);
|
||||
|
||||
await page.goto(`${baseUrl}/settings`, { waitUntil: 'domcontentloaded', timeout: timeoutMs });
|
||||
await page.goto(`${baseUrl}/settings`, { waitUntil: "domcontentloaded", timeout: timeoutMs });
|
||||
|
||||
const card = page.getByTestId(`daemon-card-${serverId}`);
|
||||
await card.waitFor({ timeout: timeoutMs });
|
||||
await card.getByText('Online', { exact: true }).waitFor({ timeout: timeoutMs });
|
||||
await card.getByText('Relay', { exact: true }).waitFor({ timeout: timeoutMs });
|
||||
await card.getByText("Online", { exact: true }).waitFor({ timeout: timeoutMs });
|
||||
await card.getByText("Relay", { exact: true }).waitFor({ timeout: timeoutMs });
|
||||
|
||||
// Stability window: ensure it doesn't flap.
|
||||
await page.waitForTimeout(stabilityMs);
|
||||
await card.getByText('Online', { exact: true }).waitFor({ timeout: 5_000 });
|
||||
await card.getByText("Online", { exact: true }).waitFor({ timeout: 5_000 });
|
||||
|
||||
console.log(
|
||||
JSON.stringify(
|
||||
@@ -79,8 +85,8 @@ console.log(
|
||||
stabilityMs,
|
||||
},
|
||||
null,
|
||||
2
|
||||
)
|
||||
2,
|
||||
),
|
||||
);
|
||||
|
||||
await browser.close();
|
||||
|
||||
Reference in New Issue
Block a user