Archived
1
0

Getting the client to run (#12)

* Clean up workbench and integrate initialization data

* Uncomment Electron fill

* Run server & client together

* Clean up Electron fill & patch

* Bind fs methods

This makes them usable with the promise form:
`promisify(access)(...)`.

* Add space between tag and title to browser logger

* Add typescript dep to server and default __dirname for path

* Serve web files from server

* Adjust some dev options

* Rework workbench a bit to use a class and catch unexpected errors

* No mkdirs for now, fix util fill, use bash with exec

* More fills, make general client abstract

* More fills

* Fix cp.exec

* Fix require calls in fs fill being aliased

* Create data and storage dir

* Implement fs.watch

Using exec for now.

* Implement storage database fill

* Fix os export and homedir

* Add comment to use navigator.sendBeacon

* Fix fs callbacks (some args are optional)

* Make sure data directory exists when passing it back

* Update patch

* Target es5

* More fills

* Add APIs required for bootstrap-fork to function (#15)

* Add bootstrap-fork execution

* Add createConnection

* Bundle bootstrap-fork into cli

* Remove .node directory created from spdlog

* Fix npm start

* Remove unnecessary comment

* Add webpack-hot-middleware if CLI env is not set

* Add restarting to shared process

* Fix starting with yarn
This commit is contained in:
Asher
2019-01-18 15:46:40 -06:00
committed by Kyle Carberry
parent 05899b5edf
commit 72bf4547d4
80 changed files with 5183 additions and 9697 deletions

View File

@ -1,3 +1,5 @@
import * as net from "net";
import * as os from "os";
import * as path from "path";
import { TextEncoder, TextDecoder } from "text-encoding";
import { createClient } from "./helpers";
@ -5,7 +7,7 @@ import { createClient } from "./helpers";
(<any>global).TextDecoder = TextDecoder;
(<any>global).TextEncoder = TextEncoder;
describe("Command", () => {
describe("spawn", () => {
const client = createClient();
it("should execute command and return output", (done) => {
@ -129,4 +131,60 @@ describe("Command", () => {
});
proc.on("exit", () => done());
});
});
describe("createConnection", () => {
const client = createClient();
const tmpPath = path.join(os.tmpdir(), Math.random().toString());
let server: net.Server;
beforeAll(async () => {
await new Promise((r) => {
server = net.createServer().listen(tmpPath, () => {
r();
});
});
});
afterAll(() => {
server.close();
});
it("should connect to socket", (done) => {
const socket = client.createConnection(tmpPath, () => {
socket.end();
socket.addListener("close", () => {
done();
});
});
});
it("should get data from server", (done) => {
server.once("connection", (socket: net.Socket) => {
socket.write("hi how r u");
});
const socket = client.createConnection(tmpPath);
socket.addListener("data", (data) => {
expect(data.toString()).toEqual("hi how r u");
socket.end();
socket.addListener("close", () => {
done();
});
});
});
it("should send data to server", (done) => {
const clientSocket = client.createConnection(tmpPath);
clientSocket.write(Buffer.from("bananas"));
server.once("connection", (socket: net.Socket) => {
socket.addListener("data", (data) => {
expect(data.toString()).toEqual("bananas");
socket.end();
clientSocket.addListener("end", () => {
done();
});
});
});
});
});

View File

@ -9,10 +9,10 @@ describe("Server", () => {
});
it("should get init msg", (done) => {
client.onInitData((data) => {
client.initData.then((data) => {
expect(data.dataDirectory).toEqual(dataDirectory);
expect(data.workingDirectory).toEqual(workingDirectory);
done();
});
});
});
});