Switch to double quotes and reformat codebase with Biome

This commit is contained in:
Mohamed Boudra
2026-03-21 20:22:15 +07:00
parent ab40786882
commit f6579dbeb4
805 changed files with 38132 additions and 40175 deletions
@@ -1,111 +1,111 @@
#!/usr/bin/env npx tsx
import assert from 'node:assert'
import { mkdtempSync, mkdirSync, rmSync, writeFileSync } from 'node:fs'
import os from 'node:os'
import path from 'node:path'
import assert from "node:assert";
import { mkdtempSync, mkdirSync, rmSync, writeFileSync } from "node:fs";
import os from "node:os";
import path from "node:path";
import {
getDaemonHost,
normalizeDaemonHost,
resolveDaemonTarget,
resolveDefaultDaemonHosts,
} from '../src/utils/client.js'
} from "../src/utils/client.js";
console.log('=== CLI IPC Target Helpers ===\n')
console.log("=== CLI IPC Target Helpers ===\n");
{
console.log('Test 1: unix hosts resolve to ws+unix URLs')
const target = resolveDaemonTarget('unix:///tmp/paseo.sock')
console.log("Test 1: unix hosts resolve to ws+unix URLs");
const target = resolveDaemonTarget("unix:///tmp/paseo.sock");
assert.deepStrictEqual(target, {
type: 'ipc',
url: 'ws+unix:///tmp/paseo.sock:/ws',
socketPath: '/tmp/paseo.sock',
})
console.log('✓ unix hosts resolve to ws+unix URLs\n')
type: "ipc",
url: "ws+unix:///tmp/paseo.sock:/ws",
socketPath: "/tmp/paseo.sock",
});
console.log("✓ unix hosts resolve to ws+unix URLs\n");
}
{
console.log('Test 2: pipe hosts preserve the Node socketPath transport form')
const target = resolveDaemonTarget('pipe://\\\\.\\pipe\\paseo-managed-test')
console.log("Test 2: pipe hosts preserve the Node socketPath transport form");
const target = resolveDaemonTarget("pipe://\\\\.\\pipe\\paseo-managed-test");
assert.deepStrictEqual(target, {
type: 'ipc',
url: 'ws://localhost/ws',
socketPath: '\\\\.\\pipe\\paseo-managed-test',
})
console.log('✓ pipe hosts preserve Node socketPath transport form\n')
type: "ipc",
url: "ws://localhost/ws",
socketPath: "\\\\.\\pipe\\paseo-managed-test",
});
console.log("✓ pipe hosts preserve Node socketPath transport form\n");
}
{
console.log('Test 3: local unix socket paths normalize into IPC daemon targets')
assert.strictEqual(normalizeDaemonHost('/tmp/paseo.sock'), 'unix:///tmp/paseo.sock')
console.log('✓ local unix socket paths normalize into IPC daemon targets\n')
console.log("Test 3: local unix socket paths normalize into IPC daemon targets");
assert.strictEqual(normalizeDaemonHost("/tmp/paseo.sock"), "unix:///tmp/paseo.sock");
console.log("✓ local unix socket paths normalize into IPC daemon targets\n");
}
{
console.log('Test 4: default host resolution tries local IPC first, then localhost fallback')
const paseoHome = mkdtempSync(path.join(os.tmpdir(), 'paseo-client-targets-'))
console.log("Test 4: default host resolution tries local IPC first, then localhost fallback");
const paseoHome = mkdtempSync(path.join(os.tmpdir(), "paseo-client-targets-"));
try {
mkdirSync(paseoHome, { recursive: true })
mkdirSync(paseoHome, { recursive: true });
writeFileSync(
path.join(paseoHome, 'paseo.pid'),
JSON.stringify({ pid: process.pid, listen: '/tmp/paseo-from-pid.sock' })
)
path.join(paseoHome, "paseo.pid"),
JSON.stringify({ pid: process.pid, listen: "/tmp/paseo-from-pid.sock" }),
);
assert.deepStrictEqual(resolveDefaultDaemonHosts({ PASEO_HOME: paseoHome }), [
'unix:///tmp/paseo-from-pid.sock',
'localhost:6767',
])
const previousHome = process.env.PASEO_HOME
const previousHost = process.env.PASEO_HOST
process.env.PASEO_HOME = paseoHome
delete process.env.PASEO_HOST
assert.strictEqual(getDaemonHost(), 'unix:///tmp/paseo-from-pid.sock')
if (previousHome === undefined) delete process.env.PASEO_HOME
else process.env.PASEO_HOME = previousHome
if (previousHost === undefined) delete process.env.PASEO_HOST
else process.env.PASEO_HOST = previousHost
"unix:///tmp/paseo-from-pid.sock",
"localhost:6767",
]);
const previousHome = process.env.PASEO_HOME;
const previousHost = process.env.PASEO_HOST;
process.env.PASEO_HOME = paseoHome;
delete process.env.PASEO_HOST;
assert.strictEqual(getDaemonHost(), "unix:///tmp/paseo-from-pid.sock");
if (previousHome === undefined) delete process.env.PASEO_HOME;
else process.env.PASEO_HOME = previousHome;
if (previousHost === undefined) delete process.env.PASEO_HOST;
else process.env.PASEO_HOST = previousHost;
} finally {
rmSync(paseoHome, { recursive: true, force: true })
rmSync(paseoHome, { recursive: true, force: true });
}
console.log('✓ default host resolution tries local IPC first, then localhost fallback\n')
console.log("✓ default host resolution tries local IPC first, then localhost fallback\n");
}
{
console.log('Test 5: configured TCP host is preserved before the localhost fallback')
const paseoHome = mkdtempSync(path.join(os.tmpdir(), 'paseo-client-targets-tcp-'))
console.log("Test 5: configured TCP host is preserved before the localhost fallback");
const paseoHome = mkdtempSync(path.join(os.tmpdir(), "paseo-client-targets-tcp-"));
try {
assert.deepStrictEqual(
resolveDefaultDaemonHosts({
PASEO_HOME: paseoHome,
PASEO_LISTEN: '127.0.0.1:7777',
PASEO_LISTEN: "127.0.0.1:7777",
}),
['127.0.0.1:7777', 'localhost:6767']
)
["127.0.0.1:7777", "localhost:6767"],
);
} finally {
rmSync(paseoHome, { recursive: true, force: true })
rmSync(paseoHome, { recursive: true, force: true });
}
console.log('✓ configured TCP host is preserved before the localhost fallback\n')
console.log("✓ configured TCP host is preserved before the localhost fallback\n");
}
{
console.log('Test 6: local IPC still takes priority over configured TCP hosts')
const paseoHome = mkdtempSync(path.join(os.tmpdir(), 'paseo-client-targets-order-'))
console.log("Test 6: local IPC still takes priority over configured TCP hosts");
const paseoHome = mkdtempSync(path.join(os.tmpdir(), "paseo-client-targets-order-"));
try {
mkdirSync(paseoHome, { recursive: true })
mkdirSync(paseoHome, { recursive: true });
writeFileSync(
path.join(paseoHome, 'paseo.pid'),
JSON.stringify({ pid: process.pid, listen: '/tmp/paseo-priority.sock' })
)
path.join(paseoHome, "paseo.pid"),
JSON.stringify({ pid: process.pid, listen: "/tmp/paseo-priority.sock" }),
);
assert.deepStrictEqual(
resolveDefaultDaemonHosts({
PASEO_HOME: paseoHome,
PASEO_LISTEN: '127.0.0.1:7777',
PASEO_LISTEN: "127.0.0.1:7777",
}),
['unix:///tmp/paseo-priority.sock', '127.0.0.1:7777', 'localhost:6767']
)
["unix:///tmp/paseo-priority.sock", "127.0.0.1:7777", "localhost:6767"],
);
} finally {
rmSync(paseoHome, { recursive: true, force: true })
rmSync(paseoHome, { recursive: true, force: true });
}
console.log('✓ local IPC still takes priority over configured TCP hosts\n')
console.log("✓ local IPC still takes priority over configured TCP hosts\n");
}
console.log('=== All CLI IPC target tests passed ===')
console.log("=== All CLI IPC target tests passed ===");