Switch to double quotes and reformat codebase with Biome
This commit is contained in:
@@ -45,7 +45,8 @@ async function measurePings(
|
||||
}
|
||||
|
||||
const results: number[] = [];
|
||||
const serverTimings: { serverReceivedAt: number; serverSentAt: number; clientSentAt: number }[] = [];
|
||||
const serverTimings: { serverReceivedAt: number; serverSentAt: number; clientSentAt: number }[] =
|
||||
[];
|
||||
|
||||
for (let i = 0; i < count; i++) {
|
||||
const result = await client.ping({ timeoutMs: 10_000 });
|
||||
@@ -117,7 +118,9 @@ async function main() {
|
||||
for (let i = 0; i < 5; i++) {
|
||||
const start = Date.now();
|
||||
const { WebSocket } = await import("ws");
|
||||
const ws = new WebSocket(`wss://relay.paseo.sh/ws?serverId=latency_probe_${Date.now()}&role=client&clientId=probe_${i}`);
|
||||
const ws = new WebSocket(
|
||||
`wss://relay.paseo.sh/ws?serverId=latency_probe_${Date.now()}&role=client&clientId=probe_${i}`,
|
||||
);
|
||||
await new Promise<void>((resolve, reject) => {
|
||||
ws.on("open", () => {
|
||||
wsConnectTimes.push(Date.now() - start);
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -67,7 +67,7 @@ try {
|
||||
if (localTagCommit !== headCommit) {
|
||||
throw new Error(
|
||||
`Local tag ${tag} points to ${localTagCommit}, but HEAD is ${headCommit}. ` +
|
||||
"Create a new release commit before pushing this tag."
|
||||
"Create a new release commit before pushing this tag.",
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -95,7 +95,7 @@ function parseChangelog(changelogText) {
|
||||
|
||||
if (headings.length === 0) {
|
||||
throw new Error(
|
||||
"No release headings found in CHANGELOG.md. Expected headings like `## 0.1.14 - 2026-02-19`."
|
||||
"No release headings found in CHANGELOG.md. Expected headings like `## 0.1.14 - 2026-02-19`.",
|
||||
);
|
||||
}
|
||||
|
||||
@@ -150,9 +150,7 @@ function main() {
|
||||
const targetEntry = entries.find((entry) => entry.tag === targetTag);
|
||||
|
||||
if (!targetEntry) {
|
||||
throw new Error(
|
||||
`No matching changelog section found for ${targetTag}.`
|
||||
);
|
||||
throw new Error(`No matching changelog section found for ${targetTag}.`);
|
||||
}
|
||||
|
||||
const tempDir = mkdtempSync(path.join(tmpdir(), "paseo-release-notes-"));
|
||||
@@ -161,22 +159,14 @@ function main() {
|
||||
|
||||
try {
|
||||
if (hasRelease(targetTag, args.repo)) {
|
||||
runGh([
|
||||
"release",
|
||||
"edit",
|
||||
targetTag,
|
||||
"--repo",
|
||||
args.repo,
|
||||
"--notes-file",
|
||||
notesPath,
|
||||
]);
|
||||
runGh(["release", "edit", targetTag, "--repo", args.repo, "--notes-file", notesPath]);
|
||||
console.log(`Updated release notes for ${targetTag}.`);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!args.createIfMissing) {
|
||||
console.log(
|
||||
`Release ${targetTag} not found. Skipping because --create-if-missing was not provided.`
|
||||
`Release ${targetTag} not found. Skipping because --create-if-missing was not provided.`,
|
||||
);
|
||||
return;
|
||||
}
|
||||
@@ -198,17 +188,9 @@ function main() {
|
||||
console.log(`Created release ${targetTag} with changelog notes.`);
|
||||
} catch (createError) {
|
||||
console.warn(
|
||||
`Release creation failed for ${targetTag}; attempting edit in case another workflow created it concurrently.`
|
||||
`Release creation failed for ${targetTag}; attempting edit in case another workflow created it concurrently.`,
|
||||
);
|
||||
runGh([
|
||||
"release",
|
||||
"edit",
|
||||
targetTag,
|
||||
"--repo",
|
||||
args.repo,
|
||||
"--notes-file",
|
||||
notesPath,
|
||||
]);
|
||||
runGh(["release", "edit", targetTag, "--repo", args.repo, "--notes-file", notesPath]);
|
||||
console.log(`Updated release notes for ${targetTag} after create race.`);
|
||||
|
||||
if (createError instanceof Error) {
|
||||
|
||||
@@ -1,73 +1,73 @@
|
||||
import { existsSync, readFileSync, writeFileSync } from 'node:fs'
|
||||
import path from 'node:path'
|
||||
import { fileURLToPath } from 'node:url'
|
||||
import { existsSync, readFileSync, writeFileSync } from "node:fs";
|
||||
import path from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url))
|
||||
const rootDir = path.resolve(__dirname, '..')
|
||||
const rootPackagePath = path.join(rootDir, 'package.json')
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||
const rootDir = path.resolve(__dirname, "..");
|
||||
const rootPackagePath = path.join(rootDir, "package.json");
|
||||
|
||||
const rootPackage = JSON.parse(readFileSync(rootPackagePath, 'utf8'))
|
||||
const rootVersion = rootPackage.version
|
||||
const workspacePaths = Array.isArray(rootPackage.workspaces) ? rootPackage.workspaces : []
|
||||
const rootPackage = JSON.parse(readFileSync(rootPackagePath, "utf8"));
|
||||
const rootVersion = rootPackage.version;
|
||||
const workspacePaths = Array.isArray(rootPackage.workspaces) ? rootPackage.workspaces : [];
|
||||
|
||||
if (typeof rootVersion !== 'string' || rootVersion.length === 0) {
|
||||
throw new Error('Root package.json must contain a valid "version"')
|
||||
if (typeof rootVersion !== "string" || rootVersion.length === 0) {
|
||||
throw new Error('Root package.json must contain a valid "version"');
|
||||
}
|
||||
|
||||
const dependencySections = [
|
||||
'dependencies',
|
||||
'devDependencies',
|
||||
'peerDependencies',
|
||||
'optionalDependencies',
|
||||
]
|
||||
"dependencies",
|
||||
"devDependencies",
|
||||
"peerDependencies",
|
||||
"optionalDependencies",
|
||||
];
|
||||
|
||||
const touched = []
|
||||
const touched = [];
|
||||
|
||||
for (const workspacePath of workspacePaths) {
|
||||
const packagePath = path.join(rootDir, workspacePath, 'package.json')
|
||||
const packagePath = path.join(rootDir, workspacePath, "package.json");
|
||||
if (!existsSync(packagePath)) {
|
||||
continue
|
||||
continue;
|
||||
}
|
||||
|
||||
const pkg = JSON.parse(readFileSync(packagePath, 'utf8'))
|
||||
let changed = false
|
||||
const pkg = JSON.parse(readFileSync(packagePath, "utf8"));
|
||||
let changed = false;
|
||||
|
||||
if (pkg.version !== rootVersion) {
|
||||
pkg.version = rootVersion
|
||||
changed = true
|
||||
pkg.version = rootVersion;
|
||||
changed = true;
|
||||
}
|
||||
|
||||
for (const section of dependencySections) {
|
||||
const deps = pkg[section]
|
||||
if (!deps || typeof deps !== 'object') {
|
||||
continue
|
||||
const deps = pkg[section];
|
||||
if (!deps || typeof deps !== "object") {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (const name of Object.keys(deps)) {
|
||||
if (!name.startsWith('@getpaseo/')) {
|
||||
continue
|
||||
if (!name.startsWith("@getpaseo/")) {
|
||||
continue;
|
||||
}
|
||||
if (name === pkg.name) {
|
||||
continue
|
||||
continue;
|
||||
}
|
||||
if (deps[name] !== rootVersion) {
|
||||
deps[name] = rootVersion
|
||||
changed = true
|
||||
deps[name] = rootVersion;
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (changed) {
|
||||
writeFileSync(packagePath, `${JSON.stringify(pkg, null, 2)}\n`)
|
||||
touched.push(path.relative(rootDir, packagePath))
|
||||
writeFileSync(packagePath, `${JSON.stringify(pkg, null, 2)}\n`);
|
||||
touched.push(path.relative(rootDir, packagePath));
|
||||
}
|
||||
}
|
||||
|
||||
if (touched.length === 0) {
|
||||
console.log(`Workspace versions and internal deps already synced to ${rootVersion}`)
|
||||
console.log(`Workspace versions and internal deps already synced to ${rootVersion}`);
|
||||
} else {
|
||||
console.log(`Synced to ${rootVersion}:`)
|
||||
console.log(`Synced to ${rootVersion}:`);
|
||||
for (const file of touched) {
|
||||
console.log(`- ${file}`)
|
||||
console.log(`- ${file}`);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user