Skip to content

Commit

Permalink
v-frgome generators (#4554)
Browse files Browse the repository at this point in the history
* Initial commit

* Changes after review

* Initial commit

* cleanup

* Fix memory storage warning

* Fixed Bot storage warning in .ts sample

* deleted not used samples. Renamed package

* Included .bot file

* Added .bot file

* Refactoring

* Reverted name

* missing bits

* bump version to 3.x.x

* Updated links and email

* After cleanup
  • Loading branch information
FranciscoPonceGomez authored and Tom Laird-McConnell committed May 4, 2018
1 parent 187c32a commit e1d8d02
Show file tree
Hide file tree
Showing 12 changed files with 66 additions and 25 deletions.
14 changes: 14 additions & 0 deletions CSharp/Generator/BotApplication/$safeprojectname$.bot
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"name": "$safeprojectname$",
"secretKey": "",
"services": [
{
"appId": "",
"id": "http://localhost:3978/api/messages",
"type": "endpoint",
"appPassword": "",
"endpoint": "http://localhost:3978/api/messages",
"name": "$safeprojectname$"
}
]
}
6 changes: 4 additions & 2 deletions CSharp/Generator/BotApplication/BotApplication.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Content Include="%24safeprojectname%24.bot" />
<None Include="App_Start\WebApiConfig.cs" />
<None Include="Controllers\MessagesController.cs" />
<None Include="Dialogs\RootDialog.cs" />
Expand All @@ -174,10 +175,11 @@
<None Include="packages.config">
<SubType>Designer</SubType>
</None>
<None Include="ProjectTemplate.csproj" />
<None Include="ProjectTemplate.csproj">
<SubType>Designer</SubType>
</None>
<Content Include="default.htm" />
<Content Include="Web.config" />
<Content Include="TestBot.bot" />
<None Include="Web.Debug.config">
<DependentUpon>Web.config</DependentUpon>
</None>
Expand Down
2 changes: 1 addition & 1 deletion CSharp/Generator/BotApplication/BotApplication.vstemplate
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<ProjectItem ReplaceParameters="true" TargetFileName="Global.asax.cs">Global.asax.cs</ProjectItem>
<ProjectItem ReplaceParameters="true" TargetFileName="packages.config">packages.config</ProjectItem>
<ProjectItem ReplaceParameters="true" TargetFileName="ProjectTemplate.csproj">ProjectTemplate.csproj</ProjectItem>
<ProjectItem ReplaceParameters="true" TargetFileName="TestBot.bot">TestBot.bot</ProjectItem>
<ProjectItem ReplaceParameters="true" TargetFileName="$safeprojectname$.bot">$safeprojectname$.bot</ProjectItem>
<ProjectItem ReplaceParameters="true" TargetFileName="BotApplication.vstemplate">BotApplication.vstemplate</ProjectItem>
<Folder Name="Properties" TargetFolderName="Properties">
<ProjectItem ReplaceParameters="true" TargetFileName="AssemblyInfo.cs">AssemblyInfo.cs</ProjectItem>
Expand Down
25 changes: 15 additions & 10 deletions CSharp/Generator/BotApplication/Global.asax.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using Microsoft.Bot.Builder.Dialogs.Internals;
using Autofac;
using Microsoft.Bot.Connector;
using System.Reflection;

namespace $safeprojectname$
{
Expand All @@ -16,18 +17,22 @@ protected void Application_Start()
Conversation.UpdateContainer(
builder =>
{
builder.RegisterModule(new AzureModule(Assembly.GetExecutingAssembly()));

// Bot Storage: Here we register the state storage for your bot.
// Default store: volatile in-memory store - Only for prototyping!
// We provide adapters for Azure Table, CosmosDb, SQL Azure, or you can implement your own!
// For samples and documentation, see: [https://github.com/Microsoft/BotBuilder-Azure](https://github.com/Microsoft/BotBuilder-Azure)
var store = new InMemoryDataStore();
builder.Register(c => store)
.Keyed<IBotDataStore<BotData>>(AzureModule.Key_DataStore)
.AsSelf()
.SingleInstance();
builder.Register(c => new CachingBotDataStore(store,
CachingBotDataStoreConsistencyPolicy
.ETagBasedConsistency))
.As<IBotDataStore<BotData>>()
.AsSelf()
.InstancePerLifetimeScope();

// Other storage options
// var store = new TableBotDataStore("...DataStorageConnectionString..."); // requires Microsoft.BotBuilder.Azure Nuget package
// var store = new DocumentDbBotDataStore("cosmos db uri", "cosmos db key"); // requires Microsoft.BotBuilder.Azure Nuget package

builder.Register(c => store)
.Keyed<IBotDataStore<BotData>>(AzureModule.Key_DataStore)
.AsSelf()
.SingleInstance();
});
}
}
Expand Down
2 changes: 1 addition & 1 deletion CSharp/Generator/BotApplication/ProjectTemplate.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@
<ItemGroup>
<Content Include="default.htm" />
<Content Include="Global.asax" />
<Content Include="TestBot.bot" />
<Content Include="$safeprojectname$.bot" />
<Content Include="Web.config">
<SubType>Designer</SubType>
</Content>
Expand Down
2 changes: 1 addition & 1 deletion Node/Generator/LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2017 Microsoft
Copyright (c) 2018 Microsoft

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 0 additions & 2 deletions Node/Generator/debug.log

This file was deleted.

7 changes: 6 additions & 1 deletion Node/Generator/generators/app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ module.exports = class extends Generator {
}
writing() {
const directoryName = _.kebabCase(this.props.botName);
const botName = this.props.botName;
const extension = this.props.language === 'JavaScript' ? 'js' : 'ts';
const launchSteps = extension === 'js' ? `node app.js` : `tsc\nnode app.js`;
const defaultDialog = this.props.dialog.split(' ')[0].toLowerCase();
Expand All @@ -35,7 +36,11 @@ module.exports = class extends Generator {
this.fs.copyTpl(this.templatePath('package.json'), this.destinationPath('package.json'), { botName: directoryName });
this.fs.copy(this.templatePath('_gitignore'), this.destinationPath('.gitignore'));
this.fs.copy(this.templatePath('_env'), this.destinationPath('.env'));

this.fs.copy(this.templatePath(`botName.bot`), this.destinationPath(`${this.props.botName}.bot`), {
process: function(content) {
var pattern = new RegExp('<%= botName %>','g');
return content.toString().replace(pattern, botName.toString());
}});

this.fs.copy(this.templatePath(`app.${extension}`), this.destinationPath(`app.${extension}`));
this.fs.copyTpl(this.templatePath(`bot.${extension}`), this.destinationPath(`bot.${extension}`), {
Expand Down
14 changes: 14 additions & 0 deletions Node/Generator/generators/app/templates/botName.bot
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"name": "<%= botName %>",
"secretKey": "",
"services": [
{
"appId": "",
"id": "http://localhost:3978/api/messages",
"type": "endpoint",
"appPassword": "",
"endpoint": "http://localhost:3978/api/messages",
"name": "<%= botName %>"
}
]
}
4 changes: 2 additions & 2 deletions Node/Generator/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions Node/Generator/package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"name": "generator-botbuilder-v3",
"version": "1.0.0",
"name": "generator-botbuilder",
"version": "3.0.0",
"description": "A yeoman generator for creating bots using Microsoft Bot Framework",
"homepage": "",
"homepage": "https://github.com/Microsoft/BotBuilder",
"author": {
"name": "Microsoft",
"email": "",
"url": ""
"email": "botframework@microsoft.com",
"url": "http://dev.botframework.com"
},
"files": [
"generators"
Expand Down
3 changes: 3 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit e1d8d02

Please sign in to comment.