Skip to content

Commit

Permalink
Ensured filename and class names are the same + hostname fix
Browse files Browse the repository at this point in the history
  • Loading branch information
wictorwilen committed Apr 15, 2019
1 parent 0c039bb commit 25a9e9f
Show file tree
Hide file tree
Showing 20 changed files with 39 additions and 37 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
* Improved auto generated class names formatting
* Updated all npm references
* Updated instructions for Git deployment to Azure (in README file)
* Consistency in file names and class names


### Added

Expand All @@ -35,6 +37,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
* Fixed the issue where the description of message extensions was miscalculated
* Fixed an issue where message extension code was added when externally hosted
* Fixed an issue where Connectors could not properly be configured
* Bug fixes: #55, #54, #53, #52

## [*2.5.0*] - <*2018-08-17*>

Expand Down
4 changes: 2 additions & 2 deletions src/app/GeneratorTeamsApp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ export class GeneratorTeamsApp extends Generator {
});
this.option('telemetry', {
type: Boolean,
default: false,
description: 'Does not pass usage telemetry'
default: true,
description: 'Pass usage telemetry, use --no-telemetry to not send telemetry. Note, no personal data is sent.'
});
if (this.options['no-telemetry']) {
AppInsights.setup('6d773b93-ff70-45c5-907c-8edae9bf90eb');
Expand Down
2 changes: 1 addition & 1 deletion src/app/GeneratorTeamsAppOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export class GeneratorTeamsAppOptions {
websitePrefix: string;
/* Bots */
botid: string = '';
staticTab: boolean;
staticTab: boolean = false;
staticTabName: string;
staticTabTitle: string;
staticTabClassName: string;
Expand Down
21 changes: 12 additions & 9 deletions src/bot/BotGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,14 +149,12 @@ export class BotGenerator extends Generator {

this.sourceRoot()
let templateFiles = [];

if (this.options.staticTab) {
templateFiles.push(
"src/app/scripts/{botName}/{staticTabName}Tab.tsx",
"src/app/web/{botName}/{staticTabName}.html",
"src/app/{botName}/dialogs/HelpDialog.ts",
"src/app/{botName}/dialogs/WelcomeCard.json",
"src/app/{botName}/dialogs/WelcomeDialog.ts"
);
"src/app/scripts/{botName}/{staticTabClassName}Tab.tsx",
"src/app/web/{botName}/{staticTabName}.html",
);

manifest.staticTabs.push({
entityId: Guid.raw(),
Expand All @@ -178,8 +176,13 @@ export class BotGenerator extends Generator {
this.fs.writeJSON(manifestPath, manifest);

if (this.options.botType != 'existing') {
templateFiles.push('src/app/{botName}/{botClassName}.ts')
templateFiles.push('README-{botName}.md')
templateFiles.push(
"README-{botName}.md",
"src/app/{botName}/{botClassName}.ts",
"src/app/{botName}/dialogs/HelpDialog.ts",
"src/app/{botName}/dialogs/WelcomeCard.json",
"src/app/{botName}/dialogs/WelcomeDialog.ts"
);
}
templateFiles.forEach(t => {
this.fs.copyTpl(
Expand All @@ -192,7 +195,7 @@ export class BotGenerator extends Generator {
if (this.options.staticTab) {
Yotilities.insertTsExportDeclaration(
"src/app/scripts/client.ts",
`./${this.options.botName}/${this.options.staticTabName}Tab`,
`./${this.options.botName}/${this.options.staticTabClassName}Tab`,
`Automatically added for the ${this.options.staticTabName} bot tab`,
this.fs
);
Expand Down
4 changes: 2 additions & 2 deletions src/bot/templates/src/app/{botName}/dialogs/WelcomeCard.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"body": [
{
"type": "Image",
"url": "<%=hostname%>/assets/icon.png",
"url": "https://<%=hostname%>/assets/icon.png",
"size": "stretch"
},
{
Expand Down Expand Up @@ -35,7 +35,7 @@
{
"type": "Action.OpenUrl",
"title": "<%=title%>",
"url": "<%=hostname%>"
"url": "https://<%=hostname%>"
}
]
}
15 changes: 6 additions & 9 deletions src/bot/templates/src/app/{botName}/{botClassName}.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@ import { BotDeclaration, MessageExtensionDeclaration, IBot, PreventIframe } from
import * as debug from "debug";
import { DialogSet, DialogState } from "botbuilder-dialogs";
import { StatePropertyAccessor, CardFactory, TurnContext, MemoryStorage, ConversationState, ActivityTypes } from "botbuilder";
<% if (staticTab) { %>
import HelpDialog from "./dialogs/HelpDialog";
import WelcomeCard from "./dialogs/WelcomeDialog";<% } %>
import WelcomeCard from "./dialogs/WelcomeDialog";
import { TeamsContext, TeamsActivityProcessor } from "botbuilder-teams";

// Initialize debug logging module
Expand All @@ -28,14 +27,13 @@ export class <%= botClassName %> implements IBot {

/**
* The constructor
* @param conversationState
* @param conversationState
*/
public constructor(conversationState: ConversationState) {
this.conversationState = conversationState;
this.dialogState = conversationState.createProperty("dialogState");
this.dialogs = new DialogSet(this.dialogState);
<% if (staticTab) { %>
this.dialogs.add(new HelpDialog("help"));<% } %>
this.dialogs.add(new HelpDialog("help"));

// Set up the Activity processing

Expand All @@ -55,14 +53,13 @@ export class <%= botClassName %> implements IBot {
if (text.startsWith("hello")) {
await context.sendActivity("Oh, hello to you as well!");
return;
} <% if (staticTab) { %>else if (text.startsWith("help")) {
} else if (text.startsWith("help")) {
const dc = await this.dialogs.createContext(context);
await dc.beginDialog("help");
}<% } %> else {
} else {
await context.sendActivity(`I\'m terribly sorry, but my master hasn\'t trained me to do anything yet...`);
}
break;
<% if (staticTab) { %>
case ActivityTypes.ConversationUpdate:
log("Conversation update");
// Display a welcome card when the bot is added to a conversation
Expand All @@ -74,7 +71,7 @@ export class <%= botClassName %> implements IBot {
}
}
}
break;<% } %>
break;
default:
break;
}
Expand Down
4 changes: 2 additions & 2 deletions src/connector/ConnectorGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export class ConnectorGenerator extends Generator {
if (this.options.connectorType != 'existing') {
let templateFiles = [
"README-{connectorName}.md",
"src/app/scripts/{connectorName}Config.tsx",
"src/app/scripts/{connectorName}/{connectorComponentName}Config.tsx",
"src/app/web/{connectorName}/config.html",
"src/app/{connectorName}/{connectorComponentName}.ts",
];
Expand Down Expand Up @@ -124,7 +124,7 @@ export class ConnectorGenerator extends Generator {
// update client.ts
Yotilities.insertTsExportDeclaration(
"src/app/scripts/client.ts",
`./${this.options.connectorName}Config`,
`./${this.options.connectorName}/${this.options.connectorComponentName}Config`,
`Automatically added for the ${this.options.connectorName} connector`,
this.fs
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export class <%=connectorComponentName%> implements IConnector {
{
activityTitle: "Ping",
activityText: "Sample ping ",
activityImage: "<%=hostname%>/assets/icon.png",
activityImage: `https://${process.env.HOSTNAME}/assets/icon.png`,
facts: [
{
name: "Generator",
Expand Down
5 changes: 2 additions & 3 deletions src/messageExtension/MessageExtensionGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ export class MessageExtensionGenerator extends Generator {
}
]
).then((answers: any) => {
this.options.staticTab = false;
this.options.messageExtensionId = answers.messageExtensionId;
this.options.messageExtensionType = answers.messageExtensionType;
this.options.messageExtensionTitle = answers.messageExtensionName;
Expand Down Expand Up @@ -245,7 +244,7 @@ export class MessageExtensionGenerator extends Generator {

templateFiles.push(
"src/app/{messageExtensionName}/{messageExtensionClassName}.ts",
"src/app/scripts/{messageExtensionClassName}Config.tsx",
"src/app/scripts/{messageExtensionName}/{messageExtensionClassName}Config.tsx",
"src/app/web/{messageExtensionName}/config.html",
);
templateFiles.forEach(t => {
Expand All @@ -267,7 +266,7 @@ export class MessageExtensionGenerator extends Generator {

Yotilities.insertTsExportDeclaration(
"src/app/scripts/client.ts",
`./${this.options.messageExtensionName}Config`,
`./${this.options.messageExtensionName}/${this.options.messageExtensionClassName}Config`,
`Automatically added for the ${this.options.messageExtensionName} message extension`,
this.fs
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const log = debug("msteams");
export default class <%= messageExtensionClassName%> implements IMessagingExtensionMiddlewareProcessor {

public async onQuery(context: TurnContext, query: MessagingExtensionQuery): Promise<MessagingExtensionResult> {
const card = CardFactory.heroCard("Test", "Test", ["<%=host%>/assets/icon.png"]);
const card = CardFactory.heroCard("Test", "Test", [`https://${process.env.HOSTNAME}/assets/icon.png`]);

if (query.parameters && query.parameters[0] && query.parameters[0].name === "initialRun") {
// initial run
Expand Down Expand Up @@ -40,7 +40,7 @@ export default class <%= messageExtensionClassName%> implements IMessagingExtens
public async onQuerySettingsUrl(context: TurnContext): Promise<{ title: string, value: string }> {
return Promise.resolve({
title: "<%=messageExtensionTitle%> Configuration",
value: "<%= host %>/<%= messageExtensionName %>/config.html"
value: `https://${process.env.HOSTNAME}/<%= messageExtensionName %>/config.html`
});
}

Expand Down
12 changes: 6 additions & 6 deletions src/tab/TabGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,12 @@ export class TabGenerator extends Generator {
public writing() {
if (this.options.tab) {
let templateFiles = [
"src/app/scripts/{tabName}/{tabName}Config.tsx",
"src/app/scripts/{tabName}/{tabName}.tsx",
"src/app/scripts/{tabName}/{tabName}Remove.tsx",
"src/app/scripts/{tabName}/__tests__/{tabName}Config.spec.tsx",
"src/app/scripts/{tabName}/__tests__/{tabName}.spec.tsx",
"src/app/scripts/{tabName}/__tests__/{tabName}Remove.spec.tsx",
"src/app/scripts/{tabName}/{tabReactComponentName}Config.tsx",
"src/app/scripts/{tabName}/{tabReactComponentName}.tsx",
"src/app/scripts/{tabName}/{tabReactComponentName}Remove.tsx",
"src/app/scripts/{tabName}/__tests__/{tabReactComponentName}Config.spec.tsx",
"src/app/scripts/{tabName}/__tests__/{tabReactComponentName}.spec.tsx",
"src/app/scripts/{tabName}/__tests__/{tabReactComponentName}Remove.spec.tsx",
"src/app/{tabName}/{tabReactComponentName}.ts",
"src/app/web/{tabName}/index.html",
"src/app/web/{tabName}/remove.html",
Expand Down

0 comments on commit 25a9e9f

Please sign in to comment.