Skip to content

Commit

Permalink
feat: enable js runtime (preview) (microsoft#3198)
Browse files Browse the repository at this point in the history
* add js runtime

* set copy button disable when copying

* updated js runtime to load settings correctly

* updated js runtime to load settings correctly

* add js runtime publish

* add runtime config

* fixed sample templates

* read folder path from settings

* change publish folder for js runtime

* exlucde *.zip from archived files

* fixed appsettings path for deployment

* added web.config as well as iisnode.yml configuration files for deployment

* compiled js runtime

* merge settings

* enum value to lower case

* fixed zip deployment issue

* deploy js runtime without eject

* js runtime lib files

* fix restart

* fix lint

* fix zip runtime

* fix bot-deploy package can not update in azurepublish plugin

* fix copy runtime everytime when local publish

* updated configuration files for deployment

* add yarn install in first time clicking start

* bump runtime dependencies' version

* fix deploy absolute url and include .deployment into zip

* decouple platform in localpublish plugin

* move some code into nodejs runtime core

* merge master

* fix profile edit and save not saving to settings

* Remove language specific features from core and into runtime plugin (microsoft#3453)

* Remove language specific features from core and into runtime plugin

* cleanup a bit of the azurepublish plugin for readability

* move some code, add some comments

* refactor bot project deploy and split into several sub-classes. move this from inside composer into the plugin

* remove bot-deploy package
combine azurePublish and azureFunctionsPublish
refine buildDeploy api method to allow for knowledge of what target is being built for

* remove azureFunctionsPublish (replaced by azureFunctions)

* fix to node runtime

* allow start bot button to be async

* clean up dependencies, paths

* remove rimraf yarn.lock in package.json and catch error during setBot

* merge settings and write once inside the runtime plugin

* make sure to use exec instead of execSync

* make sure everything happens in the right order
don't use console.log

* identify runtime by name field

* update luis package in azurePublish plugin and fix getRuntimeByProject

* remove lib folder in azurePublish

* test: increase 'adaptive-flow' test coverage to 77% (microsoft#3530)

* + UT: adaptive-flow-renderer/widgets

* + UT: adaptive-flow-editor/utils

* remove unref hook: useWindowDimension

* + UT: KeyboardZone

* + UT: cursorTracker

* + UT: adaptive-flow-editor/constants

* +UT: AdaptiveFlowEditor

* + UT: adaptive-flow-editor/contexts

* + UT: useEditorEventApi

* fix CI error

* + UT: NodeWrapper

* + UT: EdgeMenu

* KeyboardZone behavioror test

* change the test file structure of cursorTracker

* update a test case (microsoft#3531)

Co-authored-by: Chris Whitten <christopher.whitten@microsoft.com>

* fix lgWorker test failure (microsoft#3529)

Co-authored-by: Chris Whitten <christopher.whitten@microsoft.com>

* chore: adds webpack bundle analyzer (microsoft#3542)

* issues#3309

* fixes lints

* Default to bot settings if no route cache

* fix: microsoft#3485

* fix: microsoft#3486 Debug/Fix HMR support

* webpack bundle analyzer

Co-authored-by: Soroush <sorgh@microsoft.com>
Co-authored-by: Chris Whitten <christopher.whitten@microsoft.com>
Co-authored-by: Andy Brown <asbrown002@gmail.com>

* refactor: split some actions off setSettings (microsoft#3525)

* split some actions off setSettings

* add more actions - eject still not working

* fix arguments in eject

* split some actions off setSettings

* add more actions - eject still not working

* fix arguments in eject

* Update setting.ts

* fix some tests

* Update index.ts

* move logo-clicking to commands.ts

* Update commands.ts

* fix: Dialog validate throw error when delete an action (microsoft#3537)

* fix: Dialog validate throw error when delete an action

* use optional chaining and more explicit length check

* fix lint

Co-authored-by: Chris Whitten <christopher.whitten@microsoft.com>
Co-authored-by: Andy Brown <asbrown002@gmail.com>

* use const instead of raw http status values

* rename js runtime to node-azurewebapp

Co-authored-by: Wenyi Luo <wenyluo@microsoft.com>
Co-authored-by: zeye <2295905420@qq.com>
Co-authored-by: liweitian <liweitian93@outlook.com>
Co-authored-by: Chris Whitten <christopher.whitten@microsoft.com>
Co-authored-by: Zhixiang Zhan <zhixzhan@microsoft.com>
Co-authored-by: Soroush <hatpick@gmail.com>
Co-authored-by: Soroush <sorgh@microsoft.com>
Co-authored-by: Andy Brown <asbrown002@gmail.com>
Co-authored-by: Ben Yackley <61990921+beyackle@users.noreply.github.com>
Co-authored-by: leileizhang <leilzh@microsoft.com>

* fix js runtime in core

* fix js runtime local publish

* fix exclude paths not working in copyDir

* delete bot-deploy in lib

* merge nodejs runtime packages into one and fix deploy path error

* fix yarn to install lu 4.10.0

* fix merge conflict

* enable switch runtime in managed mode

* add npmrc to set registry in azure, make sure daily build version package can be install

* fix several comments

* fix comments

* fix luisbot deploy endpointKey issue and send 202 response before runtime template copy

* fix luisbot deploy endpointKey issue and send 202 response before runtime template copy

* fix ut in eject

* move DialogSetting interface into shared folder

* fix build error

* fix e2e test fail

* add test for js runtime

* dotnet runtime luis settings refactor, remove duplicate settings file (microsoft#3677)

* remove appsettings.deployment.json and appsettings.development.json

* fix get publish status after merge main

* some updates to the plugins README to include new functionality

* additional docs for the plugin APIs

* upgrade dependency

* support skills

* optimized structure of js runtime

* to get correct project root

* added manifest support in js runtime

* ignored lib folder in js runtime

* updated docs of js runtime

* fix some comments

* removed skills validation

* remove appsettings.json in dotnet

* fixed case issue of microsoft app id

* increased param length limit of web server

* shared skill conversation id factory

* remove listener before stop bot, move manifest saving into runtime plugin

* fix unit test

* modify node runtime actions test, add node runtime test into CI

* modify all node runtime tests

* add working directory in ci yml

* add preview in js eject and update restify package version

* add ts into dev dep

* build after eject

* added test cases for skill conversation id factory

* fix npm build involve jest in production environment

* polish

* fix some comments

* add eslint and fix lint

* updated set output target of typescript to es6

* use lodash merge instead object assign

* change method parameter to object, move botStatusInterval from recoil to component

* remove templatePath in publish api call and get it in plugins by runtime type in project

* azure functions in js runtime

* polish exec in runtime plugin, use lodash mergeWith to replace original mergeDeep

* polish runtime plugin

* make console log in azure publish plugin to logger

* fix mkdir error in runtime plugin; popup confirm dialog instead error when customized runtime existed

* stop bot before switch eject runtime

* ignore warning and error in npm install, modify schema folder into Schema folder in eject, in case linux eject

* add doc for js runtime

* polish

* polish

* modify readme

* merge multi parameter into object

Co-authored-by: Zichuan Ma <zim@microsoft.com>
Co-authored-by: Qi Kang <qika@microsoft.com>
Co-authored-by: Ben Brown <benbro@microsoft.com>
Co-authored-by: zeye <2295905420@qq.com>
Co-authored-by: liweitian <liweitian93@outlook.com>
Co-authored-by: Chris Whitten <christopher.whitten@microsoft.com>
Co-authored-by: Zhixiang Zhan <zhixzhan@microsoft.com>
Co-authored-by: Soroush <hatpick@gmail.com>
Co-authored-by: Soroush <sorgh@microsoft.com>
Co-authored-by: Andy Brown <asbrown002@gmail.com>
Co-authored-by: Ben Yackley <61990921+beyackle@users.noreply.github.com>
Co-authored-by: leileizhang <leilzh@microsoft.com>
Co-authored-by: Qi Kang <kangqidev@gmail.com>
Co-authored-by: Lu Han <32191031+luhan2017@users.noreply.github.com>
  • Loading branch information
15 people authored Aug 19, 2020
1 parent 181da83 commit d87825b
Show file tree
Hide file tree
Showing 119 changed files with 13,381 additions and 2,073 deletions.
24 changes: 22 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ jobs:
base-path: ./Composer

botproject:
name: BotProject
name: BotProject-dotnet
runs-on: windows-latest
timeout-minutes: 20

Expand All @@ -67,11 +67,31 @@ jobs:
run: dotnet test
working-directory: runtime/dotnet/tests

nodejs:
name: BotProject-nodejs
runs-on: ubuntu-latest
timeout-minutes: 20

steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set Node Version
uses: actions/setup-node@v1
with:
node-version: 12.13.0
- name: npm install
run: npm install
working-directory: runtime/node
- name: npm build
run: npm run build
working-directory: runtime/node
- name: npm test
run: npm run test
working-directory: runtime/node
# docker-build:
# name: Docker Build
# timeout-minutes: 20
# runs-on: ubuntu-latest

# steps:
# - name: Checkout
# uses: actions/checkout@v2
Expand Down
28 changes: 8 additions & 20 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
],
"sourceMaps": true,
"cwd": "${workspaceFolder}/Composer/packages/tools/language-servers/language-understanding/demo/src",
"protocol": "inspector",
"protocol": "inspector"
},
{
"name": "LG LSP Server",
Expand All @@ -38,20 +38,16 @@
],
"sourceMaps": true,
"cwd": "${workspaceFolder}/Composer/packages/tools/language-servers/language-generation/demo/src",
"protocol": "inspector",
"protocol": "inspector"
},
{
"type": "node",
"request": "launch",
"name": "Server: Launch",
"args": [
"./build/server.js"
],
"args": ["./build/server.js"],
"preLaunchTask": "server: build",
"restart": true,
"outFiles": [
"./build/*"
],
"outFiles": ["./build/*"],
"envFile": "${workspaceFolder}/Composer/packages/server/.env",
"outputCapture": "std",
"cwd": "${workspaceFolder}/Composer/packages/server"
Expand All @@ -63,14 +59,8 @@
"name": "Jest Debug",
"program": "${workspaceRoot}/Composer/node_modules/jest/bin/jest",
"stopOnEntry": false,
"args": [
"--runInBand",
"--env=jsdom",
"--config=jest.config.js"
],
"runtimeArgs": [
"--inspect-brk"
],
"args": ["--runInBand", "--env=jsdom", "--config=jest.config.js"],
"runtimeArgs": ["--inspect-brk"],
"cwd": "${workspaceRoot}/Composer/packages/server",
"sourceMaps": true,
"console": "integratedTerminal"
Expand All @@ -87,11 +77,9 @@
"request": "launch",
"name": "Electron Main Process",
"runtimeExecutable": "${workspaceRoot}/Composer/node_modules/.bin/electron",
"args": [
"${workspaceRoot}/Composer/packages/electron-server",
],
"args": ["${workspaceRoot}/Composer/packages/electron-server"],
"env": {
"NODE_ENV": "development",
"NODE_ENV": "development"
},
"outputCapture": "std"
},
Expand Down
1 change: 1 addition & 0 deletions Composer/.npmrc
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
@bfcomposer:registry=https://botbuilder.myget.org/F/botbuilder-declarative/npm/
scripts-prepend-node-path=true
4 changes: 2 additions & 2 deletions Composer/cypress/integration/LuisDeploy.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
context('Luis Deploy', () => {
beforeEach(() => {
cy.server();
cy.route('POST', '/api/publish/*/publish/default', { endpointURL: 'anything' });
cy.route('POST', '/api/publish/*/publish/default', { endpointURL: 'anything', status: 202 });
cy.route('POST', '/api/projects/*/settings', 'OK');
cy.route('GET', '/api/publish/*/status/default', { endpointURL: 'anything' });
cy.route('GET', '/api/publish/*/status/default', { endpointURL: 'anything', status: 200 });
cy.visit('/home');
cy.createBot('ToDoBotWithLuisSample');
});
Expand Down
6 changes: 5 additions & 1 deletion Composer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,11 @@
"build:server": "yarn workspace @bfc/server build",
"build:client": "yarn workspace @bfc/client build",
"build:tools": "yarn workspace @bfc/tools build:all",
"build:plugins": "cd plugins && yarn install && yarn build:all",
"build:plugins": "yarn build:plugins:localpublish && yarn build:plugins:samples && yarn build:plugins:azurePublish && yarn build:plugins:runtimes",
"build:plugins:localpublish": "cd plugins/localPublish && yarn install && yarn build",
"build:plugins:samples": "cd plugins/samples && yarn install && yarn build",
"build:plugins:azurePublish": "cd plugins/azurePublish && yarn install && yarn build",
"build:plugins:runtimes": "cd plugins/runtimes && yarn install && yarn build",
"start": "cross-env NODE_ENV=production PORT=3000 yarn start:server",
"startall": "yarn start",
"start:dev": "concurrently \"npm:start:client\" \"npm:start:server:dev\"",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import { jsx, css } from '@emotion/core';
import { PrimaryButton } from 'office-ui-fabric-react/lib/Button';
import formatMessage from 'format-message';
import { useRecoilValue } from 'recoil';
import { defaultPublishConfig } from '@bfc/shared';

import { DefaultPublishConfig } from '../../constants';
import {
botNameState,
botStatusState,
Expand Down Expand Up @@ -49,10 +49,12 @@ export const botButton = css`
`;

// -------------------- TestController -------------------- //

const POLLING_INTERVAL = 2500;
export const TestController: React.FC = () => {
const [modalOpen, setModalOpen] = useState(false);
const [calloutVisible, setCalloutVisible] = useState(false);
const [botStatusInterval, setBotStatusInterval] = useState<NodeJS.Timeout | undefined>(undefined);

const botActionRef = useRef(null);
const notifications = useNotifications();
const botName = useRecoilValue(botNameState);
Expand Down Expand Up @@ -82,20 +84,34 @@ export const TestController: React.FC = () => {

useEffect(() => {
if (projectId) {
getPublishStatus(projectId, DefaultPublishConfig);
getPublishStatus(projectId, defaultPublishConfig);
}
}, [projectId]);

useEffect(() => {
switch (botStatus) {
case BotStatus.failed:
openCallout();
stopPollingRuntime();
setBotStatus(BotStatus.pending);
break;
case BotStatus.published:
stopPollingRuntime();
handleLoadBot();
break;
case BotStatus.reloading:
startPollingRuntime();
break;
default:
case BotStatus.connected:
stopPollingRuntime();
break;
}
// return the stoppolling function so the component will clean up
return () => {
stopPollingRuntime();
return;
};
}, [botStatus]);

function dismissDialog() {
Expand All @@ -114,6 +130,23 @@ export const TestController: React.FC = () => {
setCalloutVisible(true);
}

function startPollingRuntime() {
if (!botStatusInterval) {
const cancelInterval = setInterval(() => {
// get publish status
getPublishStatus(projectId, defaultPublishConfig);
}, POLLING_INTERVAL);
setBotStatusInterval(cancelInterval);
}
}

function stopPollingRuntime() {
if (botStatusInterval) {
clearInterval(botStatusInterval);
setBotStatusInterval(undefined);
}
}

async function handlePublishLuis(luisConfig) {
setBotStatus(BotStatus.publishing);
dismissDialog();
Expand All @@ -124,7 +157,7 @@ export const TestController: React.FC = () => {
async function handleLoadBot() {
setBotStatus(BotStatus.reloading);
const sensitiveSettings = settingsStorage.get(projectId);
await publishToTarget(projectId, DefaultPublishConfig, { comment: '' }, sensitiveSettings);
await publishToTarget(projectId, defaultPublishConfig, { comment: '' }, sensitiveSettings);
}

function isLuisConfigComplete(config) {
Expand Down
5 changes: 0 additions & 5 deletions Composer/packages/client/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,11 +179,6 @@ export enum AppUpdaterStatus {
UPDATE_SUCCEEDED,
}

export const DefaultPublishConfig = {
name: 'default',
type: 'localpublish',
};

export const EmptyBotTemplateId = 'EmptyBot';

export const nameRegex = /^[a-zA-Z0-9-_]+$/;
4 changes: 2 additions & 2 deletions Composer/packages/client/src/pages/publish/Publish.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import { RouteComponentProps } from '@reach/router';
import formatMessage from 'format-message';
import { Dialog, DialogType } from 'office-ui-fabric-react/lib/Dialog';
import { TextField } from 'office-ui-fabric-react/lib/TextField';
import { useRecoilValue } from 'recoil';
import { PublishTarget } from '@bfc/shared';
import { useRecoilValue } from 'recoil';

import settingsStorage from '../../utils/dialogSettingStorage';
import { projectContainer } from '../design/styles';
Expand Down Expand Up @@ -224,7 +224,7 @@ const Publish: React.FC<PublishPageProps> = (props) => {
},
]);
}
}, [publishHistory, selectedTargetName]);
}, [publishHistory, selectedTargetName, settings.publishTargets]);

// check history to see if a 202 is found
useEffect(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
dispatcherState,
ejectRuntimeSelector,
boilerplateVersionState,
isEjectRuntimeExistState,
} from '../../../recoilModel';
import { OpenConfirmModal } from '../../../components/Modal/ConfirmDialog';
import { LoadingSpinner } from '../../../components/LoadingSpinner';
Expand All @@ -33,17 +34,22 @@ export const RuntimeSettings: React.FC<RouteComponentProps> = () => {
const settings = useRecoilValue(settingsState);
const projectId = useRecoilValue(projectIdState);
const boilerplateVersion = useRecoilValue(boilerplateVersionState);

const { setCustomRuntime, setRuntimeField, getBoilerplateVersion, updateBoilerplate } = useRecoilValue(
dispatcherState
);
const isEjectRuntimeExist = useRecoilValue(isEjectRuntimeExistState);
const {
setCustomRuntime,
setRuntimeField,
getBoilerplateVersion,
updateBoilerplate,
stopPublishBot,
} = useRecoilValue(dispatcherState);
const runtimeEjection = useRecoilValue(ejectRuntimeSelector);

const [formDataErrors, setFormDataErrors] = useState({ command: '', path: '' });
const [ejectModalVisible, setEjectModalVisible] = useState(false);
const [working, setWorking] = useState(false);
const [ejecting, setEjecting] = useState(false);
const [needsUpdate, setNeedsUpdate] = useState(false);
const [templateKey, setTemplateKey] = useState('');

useEffect(() => {
// check the status of the boilerplate material and see if it requires an update
Expand All @@ -54,6 +60,13 @@ export const RuntimeSettings: React.FC<RouteComponentProps> = () => {
setNeedsUpdate(boilerplateVersion.updateRequired || false);
}, [boilerplateVersion.updateRequired]);

useEffect(() => {
if (isEjectRuntimeExist && templateKey) {
confirmReplaceEject(templateKey);
setTemplateKey('');
}
}, [isEjectRuntimeExist, templateKey]);

const handleChangeToggle = (_, isOn = false) => {
setCustomRuntime(projectId, isOn);
};
Expand Down Expand Up @@ -104,6 +117,7 @@ export const RuntimeSettings: React.FC<RouteComponentProps> = () => {
closeEjectModal();
await runtimeEjection?.onAction(projectId, templateKey);
setEjecting(false);
setTemplateKey(templateKey);
};

const callUpdateBoilerplate = async () => {
Expand All @@ -125,6 +139,20 @@ export const RuntimeSettings: React.FC<RouteComponentProps> = () => {
}
};

const confirmReplaceEject = async (templateKey: string) => {
const title = formatMessage('Runtime already exists');
const msg = formatMessage('Are you sure you want to stop current runtime and replace them?');
const res = await OpenConfirmModal(title, msg);
if (res) {
setEjecting(true);
// stop runtime
await stopPublishBot(projectId);
// replace the runtime
await runtimeEjection?.onAction(projectId, templateKey, true);
setEjecting(false);
}
};

return botName ? (
<div css={runtimeSettingsStyle}>
{header()}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export interface EjectModalProps {

export const EjectModal: React.FC<EjectModalProps> = (props) => {
const [selectedTemplate, setSelectedTemplate] = useState<string | undefined>();

const runtimeTemplates = useRecoilValue(runtimeTemplatesState);
const { fetchRuntimeTemplates } = useRecoilValue(dispatcherState);

Expand Down
6 changes: 5 additions & 1 deletion Composer/packages/client/src/recoilModel/atoms/botState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import { BotLoadError, DesignPageLocation } from '../../recoilModel/types';

import { PublishType, BreadcrumbItem } from './../../recoilModel/types';
import { BotStatus } from './../../constants';

const getFullyQualifiedKey = (value: string) => {
return `Bot_${value}_State`;
};
Expand Down Expand Up @@ -204,3 +203,8 @@ export const onDelLanguageDialogCompleteState = atom<any>({
key: getFullyQualifiedKey('onDelLanguageDialogComplete'),
default: { func: undefined },
});

export const isEjectRuntimeExistState = atom<boolean>({
key: getFullyQualifiedKey('isEjectRuntimeExist'),
default: false,
});
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,14 @@ describe('setting dispatcher', () => {

it('should update RuntimeSettings', async () => {
await act(async () => {
await dispatcher.setRuntimeSettings('', 'path', 'command');
await dispatcher.setRuntimeSettings('', { path: 'path', command: 'command', key: 'key', name: 'name' });
});

expect(renderedComponent.current.settings.runtime.customRuntime).toBeTruthy();
expect(renderedComponent.current.settings.runtime.path).toBe('path');
expect(renderedComponent.current.settings.runtime.command).toBe('command');
expect(renderedComponent.current.settings.runtime.key).toBe('key');
expect(renderedComponent.current.settings.runtime.name).toBe('name');
});

it('should update customRuntime', async () => {
Expand Down
Loading

0 comments on commit d87825b

Please sign in to comment.