Skip to content

Commit

Permalink
Added npm script to watch and auto-restart the main process.
Browse files Browse the repository at this point in the history
  • Loading branch information
tonyanziano committed Apr 23, 2019
1 parent 9af5a5d commit ccf5c84
Show file tree
Hide file tree
Showing 27 changed files with 438 additions and 351 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## Unreleased

## Added
- [main] Added npm script to watch and auto-restart the main process in PR [1450](https://github.com/Microsoft/BotFramework-Emulator/pull/1450)

## Fixed
- [luis / client] Fixed several styling issues within the LUIS inspector, and enabled log deep link to configure missing LUIS service in PR [#1399](https://github.com/Microsoft/BotFramework-Emulator/pull/1399)
- [client] Fixed secret prompt dialog's opaque background so that it is now transparent in PR [1407](https://github.com/Microsoft/BotFramework-Emulator/pull/1407)
Expand Down
7 changes: 3 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,13 @@ Open 2 terminals:
`packages/app/shared` and rebuild the `shared` package

- One in `packages/app/main` (will be responsible for the node process)
- run `npm run start:electron:dev`
- this starts a new instance of the electron app with the most recently compiled `packages/app/main` files
- **To see app/main file changes:** `Ctrl + C` to kill the electron app, `npm run build` to rebuild the main side, and then `npm start:electron:dev` to restart it with your reflected changes
- run `npm run start:watch`
- this starts a new instance of the electron app with the most recently compiled `packages/app/main` files, and will continue to watch for any changes before recompiling and restarting the electron instance

### Debugging

#### The Main Process
Running `npm run start:electron:dev` opens up port 7777 for debugging the main node process. Startup is non-blocking
Running `npm run start:watch` opens up port 7777 for debugging the main node process. Startup is non-blocking
by default which means code could be executed before you have time to attach your debugger and set breakpoints. To prevent this,
change `--inspect=7777` to `--inspect-brk=7777` in the `start:electron` script in the `package.json` located in `packages\app\main`.
This will prevent code from running until after a debug process has been attached and will require you to start
Expand Down
672 changes: 376 additions & 296 deletions package-lock.json

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions packages/app/client/src/data/sagas/azureAuthSaga.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
import { SharedConstants } from '@bfemulator/app-shared';
import { call, ForkEffect, put, select, takeEvery } from 'redux-saga/effects';

import { CommandServiceImpl } from '../../platform/commands/commandServiceImpl';
import { DialogService } from '../../ui/dialogs';
Expand All @@ -43,8 +44,6 @@ import {
import { AzureAuthState } from '../reducer/azureAuthReducer';
import { RootState } from '../store';

import { call, ForkEffect, put, select, takeEvery } from 'redux-saga/effects';

const getArmTokenFromState = (state: RootState) => state.azureAuth;

export function* getArmToken(action: AzureAuthAction<AzureAuthWorkflow>): IterableIterator<any> {
Expand Down
3 changes: 1 addition & 2 deletions packages/app/client/src/data/sagas/botSagas.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@

import { newNotification, SharedConstants } from '@bfemulator/app-shared';
import { BotConfigWithPath, ConversationService } from '@bfemulator/sdk-shared';
import { call, put, select, takeEvery, takeLatest } from 'redux-saga/effects';

import { ActiveBotHelper } from '../../ui/helpers/activeBotHelper';
import {
Expand All @@ -48,8 +49,6 @@ import { generateHash } from '../botHelpers';
import { botSagas, browseForBot, generateHashForActiveBot, openBotViaFilePath, openBotViaUrl } from './botSagas';
import { refreshConversationMenu } from './sharedSagas';

import { call, put, select, takeEvery, takeLatest } from 'redux-saga/effects';

jest.mock('../../ui/dialogs', () => ({}));

jest.mock('../store', () => ({
Expand Down
3 changes: 1 addition & 2 deletions packages/app/client/src/data/sagas/botSagas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@

import { newNotification, UserSettings } from '@bfemulator/app-shared';
import { ConversationService, StartConversationParams } from '@bfemulator/sdk-shared';
import { call, ForkEffect, put, select, takeEvery, takeLatest } from 'redux-saga/effects';

import { ActiveBotHelper } from '../../ui/helpers/activeBotHelper';
import { BotAction, BotActionType, BotConfigWithPathPayload, botHashGenerated } from '../action/botActions';
Expand All @@ -42,8 +43,6 @@ import { RootState } from '../store';

import { refreshConversationMenu } from './sharedSagas';

import { call, ForkEffect, put, select, takeEvery, takeLatest } from 'redux-saga/effects';

/** Opens up native open file dialog to browse for a .bot file */
export function* browseForBot(): IterableIterator<any> {
yield call([ActiveBotHelper, ActiveBotHelper.confirmAndOpenBotFromFile]);
Expand Down
3 changes: 1 addition & 2 deletions packages/app/client/src/data/sagas/chatSagas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import { diff } from 'deep-diff';
import { IEndpointService } from 'botframework-config/lib/schema';
import { createCognitiveServicesBingSpeechPonyfillFactory } from 'botframework-webchat';
import { createStore as createWebChatStore } from 'botframework-webchat-core';
import { call, ForkEffect, put, select, takeEvery, takeLatest } from 'redux-saga/effects';

import {
ChatAction,
Expand All @@ -56,8 +57,6 @@ import { CommandServiceImpl } from '../../platform/commands/commandServiceImpl';
import { RootState } from '../store';
import { isSpeechEnabled } from '../../utils';

import { call, ForkEffect, put, select, takeEvery, takeLatest } from 'redux-saga/effects';

const getConversationIdFromDocumentId = (state: RootState, documentId: string) => {
return (state.chat.chats[documentId] || {}).conversationId;
};
Expand Down
3 changes: 1 addition & 2 deletions packages/app/client/src/data/sagas/editorSagas.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,13 @@
//

import { SharedConstants } from '@bfemulator/app-shared';
import { call, put, select, takeEvery, takeLatest } from 'redux-saga/effects';

import { EditorActions, removeDocPendingChange } from '../action/editorActions';

import { checkActiveDocForPendingChanges, editorSagas, promptUserToReloadDocument } from './editorSagas';
import { refreshConversationMenu, editorSelector } from './sharedSagas';

import { call, put, select, takeEvery, takeLatest } from 'redux-saga/effects';

jest.mock('../store', () => ({
get store() {
return {};
Expand Down
3 changes: 1 addition & 2 deletions packages/app/client/src/data/sagas/editorSagas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,13 @@
//

import { isChatFile, isTranscriptFile, SharedConstants } from '@bfemulator/app-shared';
import { call, ForkEffect, put, select, takeEvery, takeLatest } from 'redux-saga/effects';

import { CommandServiceImpl } from '../../platform/commands/commandServiceImpl';
import { EditorActions, removeDocPendingChange } from '../action/editorActions';

import { editorSelector, refreshConversationMenu } from './sharedSagas';

import { call, ForkEffect, put, select, takeEvery, takeLatest } from 'redux-saga/effects';

export function* promptUserToReloadDocument(filename: string): IterableIterator<any> {
const { Commands } = SharedConstants;
const options = {
Expand Down
3 changes: 1 addition & 2 deletions packages/app/client/src/data/sagas/endpointSagas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import { SharedConstants } from '@bfemulator/app-shared';
import { IBotService, IEndpointService, ServiceTypes } from 'botframework-config/lib/schema';
import { ComponentClass } from 'react';
import { call, ForkEffect, put, select, takeEvery, takeLatest } from 'redux-saga/effects';

import { CommandServiceImpl } from '../../platform/commands/commandServiceImpl';
import { DialogService } from '../../ui/dialogs/service';
Expand All @@ -48,8 +49,6 @@ import {
} from '../action/endpointServiceActions';
import { RootState } from '../store';

import { call, ForkEffect, put, select, takeEvery, takeLatest } from 'redux-saga/effects';

const getConnectedAbs = (state: RootState, endpointAppId: string) => {
return (state.bot.activeBot.services || []).find(service => {
return service.type === ServiceTypes.Bot && (service as IBotService).appId === endpointAppId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import { SharedConstants, newNotification } from '@bfemulator/app-shared';
import { applyMiddleware, combineReducers, createStore } from 'redux';
import sagaMiddlewareFactory from 'redux-saga';
import { call, put, takeEvery, select } from 'redux-saga/effects';

import { CONTENT_TYPE_APP_SETTINGS, DOCUMENT_ID_APP_SETTINGS } from '../../constants';
import * as EditorActions from '../action/editorActions';
Expand All @@ -58,8 +59,6 @@ import {
saveFrameworkSettings,
} from './frameworkSettingsSagas';

import { call, put, takeEvery, select } from 'redux-saga/effects';

jest.mock(
'../../ui/dialogs/',
() =>
Expand Down
3 changes: 1 addition & 2 deletions packages/app/client/src/data/sagas/frameworkSettingsSagas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
import { frameworkDefault, FrameworkSettings, newNotification, SharedConstants } from '@bfemulator/app-shared';
import { call, ForkEffect, put, select, takeEvery } from 'redux-saga/effects';

import { CommandServiceImpl } from '../../platform/commands/commandServiceImpl';
import * as EditorActions from '../action/editorActions';
Expand All @@ -46,8 +47,6 @@ import { generateHash } from '../botHelpers';
import { Document } from '../reducer/editor';
import { RootState } from '../store';

import { call, ForkEffect, put, select, takeEvery } from 'redux-saga/effects';

export const normalizeSettingsData = async (settings: FrameworkSettings): Promise<FrameworkSettings> => {
// trim keys that do not belong and generate a hash
const keys = Object.keys(frameworkDefault).sort();
Expand Down
3 changes: 2 additions & 1 deletion packages/app/client/src/data/sagas/navBarSagas.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,14 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//

import { put } from 'redux-saga/effects';

import { select } from '../action/navBarActions';
import * as Constants from '../../constants';
import { markAllAsRead } from '../action/notificationActions';

import { markNotificationsAsRead } from './navBarSagas';

import { put } from 'redux-saga/effects';
jest.mock('../../ui/dialogs', () => ({
AzureLoginPromptDialogContainer: function mock() {
return undefined;
Expand Down
4 changes: 2 additions & 2 deletions packages/app/client/src/data/sagas/navBarSagas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//

import { ForkEffect, put, takeEvery } from 'redux-saga/effects';

import * as Constants from '../../constants';
import { NavBarActions, SelectNavBarAction } from '../action/navBarActions';
import { markAllAsRead } from '../action/notificationActions';

import { ForkEffect, put, takeEvery } from 'redux-saga/effects';

/** Marks all notifications as read if the notifications pane is opened */
export function* markNotificationsAsRead(action: SelectNavBarAction): IterableIterator<any> {
const navBarSelection = action.payload.selection;
Expand Down
3 changes: 1 addition & 2 deletions packages/app/client/src/data/sagas/notificationSagas.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,13 @@
//

import { newNotification, NotificationType } from '@bfemulator/app-shared';
import { put } from 'redux-saga/effects';

import { NotificationManager } from '../../notificationManager';
import { beginAdd, finishAdd, finishClear, beginRemove, finishRemove } from '../action/notificationActions';

import { addNotification, clearNotifications, removeNotification, markAllAsRead } from './notificationSagas';

import { put } from 'redux-saga/effects';

describe('Notification sagas', () => {
test('addNotification()', () => {
const notification = newNotification('someMessage', NotificationType.Info);
Expand Down
4 changes: 2 additions & 2 deletions packages/app/client/src/data/sagas/notificationSagas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//

import { ForkEffect, put, takeEvery } from 'redux-saga/effects';

import { NotificationManager } from '../../notificationManager';
import {
BeginAddNotificationAction,
Expand All @@ -41,8 +43,6 @@ import {
NotificationActions,
} from '../action/notificationActions';

import { ForkEffect, put, takeEvery } from 'redux-saga/effects';

/** Adds a notification to the notification manager then
* adds it to the state store
*/
Expand Down
3 changes: 1 addition & 2 deletions packages/app/client/src/data/sagas/resourcesSagas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import { BotInfo, isChatFile, isTranscriptFile, NotificationType, SharedConstant
import { newNotification } from '@bfemulator/app-shared/built';
import { IFileService } from 'botframework-config/lib/schema';
import { ComponentClass } from 'react';
import { ForkEffect, put, takeEvery } from 'redux-saga/effects';

import { CommandServiceImpl } from '../../platform/commands/commandServiceImpl';
import { DialogService } from '../../ui/dialogs/service';
Expand All @@ -47,8 +48,6 @@ import {
ResourcesAction,
} from '../action/resourcesAction';

import { ForkEffect, put, takeEvery } from 'redux-saga/effects';

function* openContextMenuForResource(action: ResourcesAction<IFileService>): IterableIterator<any> {
const menuItems = [{ label: 'Open file location', id: 0 }, { label: 'Rename', id: 1 }, { label: 'Delete', id: 2 }];

Expand Down
3 changes: 1 addition & 2 deletions packages/app/client/src/data/sagas/servicesExplorerSagas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import {
IQnAService,
ServiceTypes,
} from 'botframework-config/lib/schema';
import { ForkEffect, put, select, takeEvery, takeLatest } from 'redux-saga/effects';

import { CommandServiceImpl } from '../../platform/commands/commandServiceImpl';
import { DialogService } from '../../ui/dialogs/service';
Expand All @@ -64,8 +65,6 @@ import { RootState } from '../store';

import { getArmToken } from './azureAuthSaga';

import { ForkEffect, put, select, takeEvery, takeLatest } from 'redux-saga/effects';

declare interface ServicesPayload {
services: IConnectedService[];
code: ServiceCodes;
Expand Down
3 changes: 1 addition & 2 deletions packages/app/client/src/data/sagas/sharedSagas.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,12 @@
//

import { SharedConstants } from '@bfemulator/app-shared';
import { select } from 'redux-saga/effects';

import { RootState } from '../store';

import { editorSelector, refreshConversationMenu } from './sharedSagas';

import { select } from 'redux-saga/effects';

let mockRemoteCommandsCalled = [];
jest.mock('../../platform/commands/commandServiceImpl', () => ({
CommandServiceImpl: {
Expand Down
3 changes: 1 addition & 2 deletions packages/app/client/src/data/sagas/sharedSagas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,11 @@
//

import { SharedConstants } from '@bfemulator/app-shared';
import { select } from 'redux-saga/effects';

import { CommandServiceImpl } from '../../platform/commands/commandServiceImpl';
import { RootState } from '../store';

import { select } from 'redux-saga/effects';

export function editorSelector(state: RootState) {
return state.editor;
}
Expand Down
3 changes: 1 addition & 2 deletions packages/app/client/src/data/sagas/welcomePageSagas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,12 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
import { BotInfo, newNotification, SharedConstants } from '@bfemulator/app-shared';
import { ForkEffect, put, takeEvery } from 'redux-saga/effects';

import { CommandServiceImpl } from '../../platform/commands/commandServiceImpl';
import { beginAdd } from '../action/notificationActions';
import { OPEN_CONTEXT_MENU_FOR_BOT, WelcomePageAction } from '../action/welcomePageActions';

import { ForkEffect, put, takeEvery } from 'redux-saga/effects';

function* openContextMenuForBot(action: WelcomePageAction<BotInfo>): IterableIterator<any> {
const menuItems = [
{ label: 'Move...', id: 0 },
Expand Down
4 changes: 2 additions & 2 deletions packages/app/client/src/ui/helpers/activeBotHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ import { CommandServiceImpl } from '../../platform/commands/commandServiceImpl';

const { Bot, Electron, Telemetry } = SharedConstants.Commands;

export const ActiveBotHelper = new class {
export const ActiveBotHelper = new (class {
async confirmSwitchBot(): Promise<any> {
if (hasNonGlobalTabs()) {
return await CommandServiceImpl.remoteCall(Electron.ShowMessageBox, true, {
Expand Down Expand Up @@ -316,4 +316,4 @@ export const ActiveBotHelper = new class {
throw new Error(errMsg);
});
}
}();
})();
19 changes: 18 additions & 1 deletion packages/app/main/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"start:electron": "./node_modules/.bin/electron --inspect=7777 --remote-debugging-port=7778 .",
"start:electron:dev": "cross-env ELECTRON_TARGET_URL=http://localhost:3000/ npm run start:electron",
"start:react-app": "cd ../client && npm start",
"start:watch": "nodemon",
"test": "jest",
"typecheck": "tsc --noEmit"
},
Expand All @@ -35,6 +36,19 @@
"email": "[email protected]",
"url": "https://github.com/Microsoft/BotFramework-Emulator"
},
"nodemonConfig": {
"exec": "npm run build && npm run start:electron:dev",
"ext": "ts, tsx",
"ignore": [
"node_modules/**/*",
"main/app/**/*",
"main/dist/**/*"
],
"watch": [
"*"
],
"verbose": false
},
"jest": {
"rootDir": "./src",
"setupTestFrameworkScriptFile": "../../../../testSetup.js",
Expand Down Expand Up @@ -96,6 +110,7 @@
"jest": "^23.0.0",
"license-list": "^0.1.3",
"ncp": "2.0.0",
"nodemon": "1.18.11",
"npm-run-all": "^4.1.5",
"through2": "^2.0.3",
"typescript": "3.1.1",
Expand Down Expand Up @@ -261,7 +276,9 @@
"target": [
{
"target": "AppImage",
"arch": ["x64"]
"arch": [
"x64"
]
}
]
},
Expand Down
Loading

0 comments on commit ccf5c84

Please sign in to comment.