Skip to content

Commit

Permalink
feat: azure publish plugin (#2733)
Browse files Browse the repository at this point in the history
* split the configuration as object

* fix deployment script, change settings path

* fix bugs in deploy script and change credential type:

* finish gethistory, getstatus, update history and status after publish

* add some code comments for clarity
add many TODOs in code

* more code comments

* more code comments for clarity

* add login script and hash the config as folder name

* add bot deploy package build into lib build

* split the provision part out of composer

* fix luis appid unfound error

* fix typo

* polish

* use bot root to config the path of settings

* differ bot to different layer

* change the order of loading settings

* update schema

* change login and provision script, from save file to output to console

* add comment

* fix merge conflict

* format resulting profile

* add comment about security

* use Bearer token auth when doing zipdeploy
remove use of websiteclient

* move provision out of composer, and make sure it not depend on internal package

* add provision subfields schema

* use token replace the credential

* fix output of token

* change the error message when token expire

* add provision error details, add configurable

* update schema require and log message return

* fix parse

* fix template

* update schema and provision script

* fix provision luis configurable

* detail the token's error handle

* Add support for using the ejected runtime code instead of the built in template when publishing to Azure

* Make it optional to persist the history to disk.
Keep it in memory instead.

* move provision script into shared asset folder that is copied into all new projets
change hashing to include bot name to avoid possible overlap when using shared resources

* add to readme

* more readme

* more readme

* clean up tmp folder after publish completes or fails

* remove empty config in provision and appPassword in provision result, Change provision default to true

* add token error handle when zipdeploy fail

* improve output of provision script:
* add usage if missing parameters
* colorize and format output
* add some additional error formatting

* improve output

* remove webManagerClient and use token instead

* clean up the order of fields, remove unused fields from profile
update schema with full form

* use publisher description rather than package name

* feat: Runtime refactor, new directory structure and Azure Function introduction phase 1 (#2855)

* Runtime: new folder structure, refactor common c# code into core, create function runtime

* Remove deprecated Bot Project

* Runtime: Fix tests

* Update runtime code owners

* Runtime: Part 1 of updating composer server to honor new runtime paths

* Runtime: tweaks for local publish to run prior to merge

* Runtime: fixes post merge

* Update azure publish to use the azure web app template.

* Azure publish: update bot project deploy to new directory structure

* Fix codeowners alias mistake

* Revert "Merge branch 'master' of https://github.com/microsoft/BotFramework-Composer into wenyluo/azure"

This reverts commit 76251ec, reversing
changes made to 7d83253.

* WebApp + new runtime: deployment and local runtime all working

* Runtime: move nuget.config to dotnet runtime root

* Asset manager: add mock folder to reflect new runtime structure

* Local publish: remove unnecessary space

* Runtime: Add copyright header to all missing files

* Fix bad merge

* Runtime: rename js -> node and update readmes

* add an optional instructions field to the publish plugin so we ca nexplain how to get a config

* merge master

* fix linter warning

* handle errors in kill procss

* remove unnecessary dupe fields from schema

* fix for modified schema path

Co-authored-by: Wenyi Luo <wenyluo@microsoft.com>
Co-authored-by: Qi Kang <qika@microsoft.com>
Co-authored-by: Chris Whitten <christopher.whitten@microsoft.com>
Co-authored-by: Carlos Castro <carlosscastro@users.noreply.github.com>
  • Loading branch information
5 people committed May 5, 2020
1 parent 252be71 commit 21a0f8f
Show file tree
Hide file tree
Showing 106 changed files with 4,763 additions and 415 deletions.
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

* @cwhitten @boydc2014 @a-b-r-o-w-n

/BotProject/ @boydc2014 @luhan2017
/runtime/ @boydc2014 @luhan2017 @carlosscastro @benbrown

/Composer/ @cwhitten @boydc2014 @a-b-r-o-w-n @corinagum @beyackle @srinaath @tonyanziano

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,10 @@ jobs:
dotnet-version: "3.1.102" # SDK Version to use.
- name: dotnet build
run: dotnet build
working-directory: BotProject/Templates/CSharp
working-directory: runtime/dotnet
- name: dotnet test
run: dotnet test
working-directory: BotProject/Templates/CSharp
working-directory: runtime/dotnet/tests

docker-build:
name: Docker Build
Expand Down
1 change: 0 additions & 1 deletion BotProject/Node/README.md

This file was deleted.

31 changes: 0 additions & 31 deletions BotProject/Templates/CSharp/BotProject.sln

This file was deleted.

44 changes: 0 additions & 44 deletions BotProject/Templates/CSharp/README.md

This file was deleted.

19 changes: 0 additions & 19 deletions BotProject/Templates/CSharp/Tests/Tests.csproj

This file was deleted.

6 changes: 3 additions & 3 deletions Composer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@
"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/localPublish && yarn install && yarn build",
"build:plugins": "concurrently \"cd plugins/localPublish && yarn install && yarn build\" \"cd plugins/azurePublish && yarn install && yarn build\" ",
"start": "cross-env NODE_ENV=production PORT=3000 yarn start:server",
"startall": "node scripts/update.js && yarn start",
"start:dev": "concurrently \"npm:start:client\" \"npm:start:server:dev\"",
"start:client": "yarn workspace @bfc/client start",
"start:server": "yarn workspace @bfc/server start",
"start:server:dev": "yarn workspace @bfc/server start:dev",
"runtime": "cd ../BotProject/CSharp/ && dotnet build && dotnet run",
"runtime": "cd ../runtime/dotnet/azurewebapp && dotnet build && dotnet run",
"test": "yarn typecheck && jest",
"test:watch": "yarn typecheck && jest --watch",
"test:coverage": "yarn test --coverage --no-cache --reporters=default",
Expand Down Expand Up @@ -113,4 +113,4 @@
"dependencies": {
"cross-env": "^6.0.3"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const CreatePublishTarget: React.FC<CreatePublishTargetProps> = props => {
const [errorMessage, setErrorMsg] = useState('');

const targetTypes = useMemo(() => {
return props.types.map(t => ({ key: t.name, text: t.name }));
return props.types.map(t => ({ key: t.name, text: t.description }));
}, [props.targets]);

const updateType = (_e, option?: IDropdownOption) => {
Expand All @@ -57,6 +57,10 @@ const CreatePublishTarget: React.FC<CreatePublishTargetProps> = props => {
}
};

const instructions: string | undefined = useMemo((): string | undefined => {
return targetType ? props.types.find(t => t.name === targetType)?.instructions : '';
}, [props.targets, targetType]);

const schema = useMemo(() => {
return targetType ? props.types.find(t => t.name === targetType)?.schema : undefined;
}, [props.targets, targetType]);
Expand Down Expand Up @@ -99,6 +103,7 @@ const CreatePublishTarget: React.FC<CreatePublishTargetProps> = props => {
defaultSelectedKey={props.current ? props.current.type : null}
onChange={updateType}
/>
{instructions && <p>{instructions}</p>}
<div css={label}>{formatMessage('Publish Configuration')}</div>
<JsonEditor key={targetType} onChange={updateConfig} height={200} value={config} schema={schema} />
<button type="submit" hidden disabled={isDisable()} />
Expand Down
4 changes: 2 additions & 2 deletions Composer/packages/client/src/pages/publish/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ const Publish: React.FC<PublishPageProps> = props => {
actions.getPublishHistory(projectId, _selected);
}
}
}, [settings.publishTargets, selectedTargetName]);
}, [projectId, selectedTargetName]);

// once history is loaded, display it
useEffect(() => {
Expand Down Expand Up @@ -197,7 +197,7 @@ const Publish: React.FC<PublishPageProps> = props => {
},
]);
}
}, [publishHistory, selectedTargetName, settings.publishTargets]);
}, [publishHistory, selectedTargetName]);

// check history to see if a 202 is found
useEffect(() => {
Expand Down
1 change: 1 addition & 0 deletions Composer/packages/client/src/store/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export interface StorageFolder extends File {
export interface PublishType {
name: string;
description: string;
instructions?: string;
schema?: JSONSchema7;
features: {
history: boolean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const fs = require('fs-extra');
const { resolve } = require('path');
const electronBuildConfig = require('../electron-builder-config.json');

const source = resolve(__dirname, '../../../../BotProject');
const source = resolve(__dirname, '../../../../runtime');

let destination;
switch (process.platform) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export function resolveRef(
): JSONSchema7 {
if (typeof schema?.$ref === 'string') {
const defName = schema.$ref.replace('#/definitions/', '');
const defSchema = typeof definitions[defName] === 'object' ? (definitions[defName] as JSONSchema7) : {};
const defSchema = typeof definitions?.[defName] === 'object' ? (definitions?.[defName] as JSONSchema7) : {};

const resolvedSchema = {
...defSchema,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,11 @@ export class ComposerPluginRegistration {
/**************************************************************************************
* Publish related features
*************************************************************************************/
public async addPublishMethod(plugin: PublishPlugin, schema?: JSONSchema7) {
public async addPublishMethod(plugin: PublishPlugin, schema?: JSONSchema7, instructions?: string) {
log('registering publish method', this.name);
this.loader.extensions.publish[this.name] = {
plugin: this,
instructions: instructions,
methods: plugin,
schema: schema,
};
Expand All @@ -77,9 +78,9 @@ export class ComposerPluginRegistration {
* to communicate with the Bot Framework Emulator.
* ```ts
* await composer.addRuntimeTemplate({
* key: 'csharp',
* key: 'azurewebapp',
* name: 'C#',
* path: __dirname + '/../../../../BotProject/Templates/CSharp',
* path: __dirname + '/../../../../runtime/dotnet/azurewebapp',
* startCommand: 'dotnet run',
* });
* ```
Expand Down
2 changes: 2 additions & 0 deletions Composer/packages/extensions/plugin-loader/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ export interface ExtensionCollection {
[key: string]: {
plugin: ComposerPluginRegistration;
methods: PublishPlugin;
/** (Optional instructions displayed in the UI) */
instructions?: string;
/** (Optional) Schema for publishing configuration. */
schema?: JSONSchema7;
};
Expand Down
2 changes: 2 additions & 0 deletions Composer/packages/lib/bot-deploy/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/node_modules
/lib
2 changes: 1 addition & 1 deletion Composer/packages/lib/bot-deploy/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
// The ARM template file path, default is 'DeploymentTemplates/template-with-preexisting-rg.json'
templatePath?: string

// Dotnet project path, default is 'BotProject.csproj'
// Dotnet project path, default is 'Microsoft.BotFramework.Composer.WebApp.csproj'
dotnetProjectPath?: string

// Lubuild generated folder path, default is 'generated'
Expand Down
5 changes: 3 additions & 2 deletions Composer/packages/lib/bot-deploy/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"description": "typescript version of bot deployment",
"main": "lib/index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"test": "echo \"Error: no test specified\" && exit 1",
"build": "tsc"
},
"author": "",
"license": "MIT",
Expand All @@ -28,4 +29,4 @@
"request": "^2.88.2",
"request-promise": "^4.2.5"
}
}
}
Loading

0 comments on commit 21a0f8f

Please sign in to comment.