forked from microsoft/botframework-solutions
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Virtual Assistant Template][TypeScript] Create Virtual Assistant Gen…
…erator (microsoft#1056) * Add generator-botbuilder-assistant * Fix homepage of package json
- Loading branch information
Showing
11 changed files
with
4,320 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
5 changes: 5 additions & 0 deletions
5
...es/Virtual-Assistant-Template/src/typescript/generator-botbuilder-assistant/.eslintignore
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Generator's templates | ||
/generators/app/templates | ||
|
||
# Generator's tests | ||
/test |
16 changes: 16 additions & 0 deletions
16
templates/Virtual-Assistant-Template/src/typescript/generator-botbuilder-assistant/.eslintrc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"extends": [ | ||
"xo", | ||
"prettier" | ||
], | ||
"env": { | ||
"mocha": true, | ||
"node": true | ||
}, | ||
"rules": { | ||
"prettier/prettier": "error" | ||
}, | ||
"plugins": [ | ||
"prettier" | ||
] | ||
} |
8 changes: 8 additions & 0 deletions
8
...lates/Virtual-Assistant-Template/src/typescript/generator-botbuilder-assistant/.npmignore
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# node.js dependencies folder | ||
node_modules/ | ||
|
||
# Bot Files | ||
*.bot | ||
|
||
#generator tests | ||
test/ |
21 changes: 21 additions & 0 deletions
21
templates/Virtual-Assistant-Template/src/typescript/generator-botbuilder-assistant/LICENSE
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2019 Microsoft <[email protected]> (http://dev.botframework.com) | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. |
164 changes: 164 additions & 0 deletions
164
...-Assistant-Template/src/typescript/generator-botbuilder-assistant/generators/app/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,164 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
"use strict"; | ||
const Generator = require("yeoman-generator"); | ||
const chalk = require("chalk"); | ||
const path = require("path"); | ||
const pkg = require("../../package.json"); | ||
const _pick = require("lodash/pick"); | ||
const _camelCase = require("lodash/camelCase"); | ||
const _upperFirst = require("lodash/upperFirst"); | ||
const fs = require("fs"); | ||
|
||
const bigBot = | ||
" ╭─────────────────────────────────╮\n" + | ||
" " + | ||
chalk.blue.bold("//") + | ||
" " + | ||
chalk.blue.bold("\\\\") + | ||
" │ Welcome to the │\n" + | ||
" " + | ||
chalk.blue.bold("//") + | ||
" () () " + | ||
chalk.blue.bold("\\\\") + | ||
" │ BotBuilder Virtual Assistant │\n" + | ||
" " + | ||
chalk.blue.bold("\\\\") + | ||
" " + | ||
chalk.blue.bold("//") + | ||
" /│ generator! │\n" + | ||
" " + | ||
chalk.blue.bold("\\\\") + | ||
" " + | ||
chalk.blue.bold("//") + | ||
" ╰─────────────────────────────────╯\n" + | ||
` v${pkg.version}`; | ||
|
||
const tinyBot = | ||
" " + chalk.blue.bold("<") + " ** " + chalk.blue.bold(">") + " "; | ||
|
||
var assistantGenerationPath = process.cwd(); | ||
var isAlreadyCreated = false; | ||
|
||
module.exports = class extends Generator { | ||
constructor(args, opts) { | ||
super(args, opts); | ||
|
||
this.option("assistantName", { | ||
description: "The name you want to give to your assistant.", | ||
type: String, | ||
default: "customAssistant", | ||
alias: "n" | ||
}); | ||
|
||
this.option("assistantDesc", { | ||
description: "A brief bit of text used to describe what your assistant does.", | ||
type: String, | ||
alias: "d" | ||
}); | ||
|
||
this.option("assistantGenerationPath", { | ||
description: "The path where the assistant will be generated.", | ||
type: String, | ||
default: process.cwd(), | ||
alias: "p" | ||
}); | ||
|
||
this.option("noPrompt", { | ||
description: "Do not prompt for any information or confirmation.", | ||
type: Boolean, | ||
default: false | ||
}); | ||
} | ||
|
||
prompting() { | ||
this.log(bigBot); | ||
// Generate the main prompts | ||
const prompts = [ | ||
// Name of the assistant | ||
{ | ||
type: "input", | ||
name: "assistantName", | ||
message: "What's the name of your assistant?", | ||
default: this.options.assistantName ? this.options.assistantName : "customAssistant" | ||
}, | ||
// Description of the assistant | ||
{ | ||
type: "input", | ||
name: "assistantDesc", | ||
message: "What will your assistant do?", | ||
default: this.options.assistantDesc ? this.options.assistantDesc : "" | ||
}, | ||
// Path of the assistant | ||
{ | ||
type: "confirm", | ||
name: "pathConfirmation", | ||
message: "Do you want to change the new assistant's location?", | ||
default: false | ||
}, | ||
{ | ||
when: function(response) { | ||
return response.pathConfirmation === true; | ||
}, | ||
type: "input", | ||
name: "assistantGenerationPath", | ||
message: "Where do you want to generate the assistant?", | ||
default: this.options.assistantGenerationPath | ||
? this.options.assistantGenerationPath | ||
: process.cwd(), | ||
validate: path => { | ||
if (fs.existsSync(path)) { | ||
return true; | ||
} | ||
|
||
this.log( | ||
chalk.red( | ||
"\n", | ||
"ERROR: This is not a valid path. Please try again." | ||
) | ||
); | ||
} | ||
}, | ||
// Final confirmation of the assistant | ||
{ | ||
type: "confirm", | ||
name: "finalConfirmation", | ||
message: "Looking good. Shall I go ahead and create your new assistant?", | ||
default: true | ||
} | ||
]; | ||
|
||
// Check that if it was generated with CLI commands | ||
if (this.options.noPrompt) { | ||
this.props = _pick(this.options, [ | ||
"assistantName", | ||
"assistantDesc", | ||
"assistantGenerationPath" | ||
]); | ||
|
||
// Validate we have what we need, or we'll need to throw | ||
if (!this.props.assistantName) { | ||
this.log.error( | ||
"ERROR: Must specify a name for your assistant when using --noPrompt argument. Use --assistantName or -n option." | ||
); | ||
process.exit(1); | ||
} | ||
|
||
this.props.finalConfirmation = true; | ||
return; | ||
} | ||
|
||
return this.prompt(prompts).then(props => { | ||
this.props = props; | ||
}); | ||
} | ||
|
||
writing() { | ||
|
||
} | ||
|
||
end() { | ||
|
||
} | ||
} |
Empty file.
Oops, something went wrong.