style: format

This commit is contained in:
Derrick Hammer 2023-07-20 16:13:36 -04:00
parent daaa338854
commit d477417ff6
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
3 changed files with 18 additions and 19 deletions

View File

@ -1,42 +1,42 @@
import * as path from 'path';
import * as kernel from '@lumeweb/libkernel/kernel';
import * as path from "path";
import * as kernel from "@lumeweb/libkernel/kernel";
// @ts-ignore
import StaticServer from 'static-server';
import { Page } from 'puppeteer';
import { bufToHex, ed25519, ErrTuple } from '@lumeweb/libkernel';
import StaticServer from "static-server";
import { Page } from "puppeteer";
import { bufToHex, ed25519, ErrTuple } from "@lumeweb/libkernel";
import * as url from 'url';
import * as url from "url";
const __dirname = url.fileURLToPath(new URL('.', import.meta.url));
const __dirname = url.fileURLToPath(new URL(".", import.meta.url));
export function generateSeedPhrase() {
return ed25519.utils.randomPrivateKey();
}
export async function login(page: Page, seed = generateSeedPhrase()) {
await page.goto('http://kernel.lumeweb.com');
await page.goto("http://kernel.lumeweb.com");
let seedHex = bufToHex(seed);
await page.evaluate((seed: string) => {
window.localStorage.setItem('v1-key', seed);
window.localStorage.setItem("v1-key", seed);
}, seedHex);
}
export async function loadTester(page: Page, port = 8080) {
const server = new StaticServer({
rootPath: path.resolve(__dirname, '..', 'public'),
rootPath: path.resolve(__dirname, "..", "public"),
port,
host: 'localhost',
host: "localhost",
});
await new Promise((resolve) => {
server.start(resolve);
});
const stop = () => server.stop();
process.on('SIGTERM', stop);
page.browser().on('disconnected', stop);
process.on("SIGTERM", stop);
page.browser().on("disconnected", stop);
await page.goto(`http://localhost:${port}/`);
await page.evaluate(() => {

View File

@ -1,8 +1,8 @@
#!/usr/bin/env node
// @ts-ignore
import { loadTester, login } from '../build/index.js';
import { loadTester, login } from "../build/index.js";
import puppeteer, { Browser, Page, ProtocolError } from 'puppeteer';
import puppeteer, { Browser, Page, ProtocolError } from "puppeteer";
let browser: Browser;
@ -14,10 +14,10 @@ let browser: Browser;
await loadTester(page);
})();
process.on('SIGTERM', async () => {
process.on("SIGTERM", async () => {
await browser.close();
});
process.on('uncaughtException', (e) => {
process.on("uncaughtException", (e) => {
if (!(e instanceof ProtocolError)) {
throw e;
}

View File

@ -1,5 +1,4 @@
import * as kernel from "@lumeweb/libkernel";
import * as kernel from "@lumeweb/libkernel/kernel";
// @ts-ignore
window.kernel = kernel;