Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: improve the user experience about lg editor #3337

Merged
merged 31 commits into from
Jun 17, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
2e5be0a
move lg api into worker
a-b-r-o-w-n Jun 4, 2020
095631a
output worker files with readable names
a-b-r-o-w-n Jun 4, 2020
cc78eb9
update the version of botbuild-lg
lei9444 Jun 5, 2020
173b91c
Merge branch 'master' into lgperf
lei9444 Jun 5, 2020
837eaa0
remove promise in parse event
a-b-r-o-w-n Jun 5, 2020
4cbdb2a
refacotr lg worker to catch all errors
a-b-r-o-w-n Jun 5, 2020
db22978
Merge branch 'master' into lgperf
lei9444 Jun 8, 2020
402279d
add worker for lg lsp
lei9444 Jun 10, 2020
0eab492
Merge branch 'master' of https://github.com/microsoft/BotFramework-Co…
lei9444 Jun 10, 2020
16f9779
Merge branch 'master' into lgperf
a-b-r-o-w-n Jun 10, 2020
59a6739
add a null check when rejecting
a-b-r-o-w-n Jun 10, 2020
561d488
dissallow node integration in worker threads
a-b-r-o-w-n Jun 10, 2020
c0342ff
remove request_light
a-b-r-o-w-n Jun 10, 2020
a2c1169
update worker file naming
a-b-r-o-w-n Jun 10, 2020
9bb6ebc
Merge branch 'master' into lgperf
cwhitten Jun 10, 2020
e8c290f
fix unit test
lei9444 Jun 11, 2020
018d051
Merge branch 'master' into lgperf
lei9444 Jun 11, 2020
7c23a4a
set asar = false
lei9444 Jun 11, 2020
dd56752
Merge branch 'lgperf' of https://github.com/lei9444/BotFramework-Comp…
lei9444 Jun 11, 2020
ccf1b65
add force exit for jest
lei9444 Jun 11, 2020
b9f2c12
move node_module to unpack folder
lei9444 Jun 12, 2020
7f3b3e5
Merge branch 'master' into lgperf
lei9444 Jun 12, 2020
5df881b
Swapped out server side worker with child process.
tonyanziano Jun 16, 2020
1e54b47
Merge branch 'master' into lgperf
lei9444 Jun 17, 2020
16558cd
fix unit tests in lg lsp
lei9444 Jun 17, 2020
b025ada
clean the code
lei9444 Jun 17, 2020
4b59439
Merge branch 'master' of https://github.com/microsoft/BotFramework-Co…
lei9444 Jun 17, 2020
576a3af
only support test env in lg lsp
lei9444 Jun 17, 2020
9dcd837
fix some comments
lei9444 Jun 17, 2020
b377257
update the dev dependency
lei9444 Jun 17, 2020
6fc46a5
Merge branch 'master' into lgperf
lei9444 Jun 17, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,13 @@ function jsonEscape(str) {
const content = jsonEscape(lgFile);

describe('LG LSP server test', () => {
beforeEach(() => {
process.env.NODE_ENV = 'test';
});

afterEach(() => {
delete process.env.NODE_ENV;
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why isn't the node env already test when running tests? This doesn't seem right.

lei9444 marked this conversation as resolved.
Show resolved Hide resolved
const server = startServer();
beforeAll(async () => {
await new Promise((resolve) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import fs from 'fs';
import path from 'path';
import * as http from 'http';
import * as url from 'url';
import * as net from 'net';
Expand All @@ -13,16 +11,6 @@ import express from 'express';

import { LGServer } from '../../src';

// eslint-disable-next-line security/detect-non-literal-fs-filename
const lgFile = fs.readFileSync(path.join(__dirname, '../mocks/greeting.lg'), 'utf-8');

const lgImportResolver = (_source, id) => {
return {
id,
content: lgFile,
};
};

const memoryResolver = () => {
return ['this.value', 'this.turnCount'];
};
Expand Down Expand Up @@ -59,7 +47,7 @@ function launchLanguageServer(socket: rpc.IWebSocket) {
const reader = new rpc.WebSocketMessageReader(socket);
const writer = new rpc.WebSocketMessageWriter(socket);
const connection: IConnection = createConnection(reader, writer);
return new LGServer(connection, lgImportResolver, memoryResolver);
return new LGServer(connection, (projectId?: string) => [], memoryResolver);
}

export function startServer() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ function launchLanguageServer(socket: rpc.IWebSocket) {
const reader = new rpc.WebSocketMessageReader(socket);
const writer = new rpc.WebSocketMessageWriter(socket);
const connection: IConnection = createConnection(reader, writer);
const server = new LGServer(connection);
const server = new LGServer(connection, (projectId?: string) => []);
server.start();
return server;
}

attachLSPServer(wss, server, '/lg-language-server', webSocket => {
attachLSPServer(wss, server, '/lg-language-server', (webSocket) => {
if (webSocket.readyState === webSocket.OPEN) {
launchLanguageServer(webSocket);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"build:demo": "cd demo && tsc --build tsconfig.json",
"prepublishOnly": "npm run build",
"clean": "rimraf lib demo/dist",
"start": "cd demo && ts-node ./src/server.ts",
"start": "cd demo && set NODE_ENV=development&& ts-node ./src/server.ts",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't cross platform friendly.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@a-b-r-o-w-n this got fixed already with cross-env

lei9444 marked this conversation as resolved.
Show resolved Hide resolved
"test": "jest",
"lint": "eslint --quiet ./src ./__tests__",
"lint:fix": "yarn lint --fix",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ import path from 'path';
import { ResolverResource } from '@bfc/shared';
import uniqueId from 'lodash/uniqueId';

const devEnvs = ['test', 'development'];
const isDev = process.env.NODE_ENV && devEnvs.indexOf(process.env.NODE_ENV) > -1;

export interface WorkerMsg {
id: string;
error?: any;
Expand All @@ -20,8 +23,10 @@ export class LgParser {
private rejects = {};

constructor() {
const workerScriptPath = path.join(__dirname, 'lgWorker.js');
this.worker = fork(workerScriptPath);
const fileName = isDev ? 'lgWorker.ts' : 'lgWorker.js';
const execArgv = isDev ? ['-r', 'ts-node/register'] : [];
lei9444 marked this conversation as resolved.
Show resolved Hide resolved
const workerScriptPath = path.join(__dirname, fileName);
this.worker = fork(workerScriptPath, [], { execArgv });
this.worker.on('message', this.handleMsg.bind(this));
}

Expand Down