|
1 | 1 | 'use strict';
|
2 |
| -var yeoman = require('yeoman-generator'); |
3 |
| -var chalk = require('chalk'); |
4 |
| -var yosay = require('yosay'); |
| 2 | +const Generator = require('yeoman-generator'); |
| 3 | +const yosay = require('yosay'); |
5 | 4 |
|
6 |
| -module.exports = yeoman.generators.Base.extend({ |
7 |
| - initializing: function() { |
8 |
| - this.templatedata = {}; |
| 5 | +module.exports = class extends Generator { |
9 | 6 |
|
10 |
| - this.log(yosay('Welcome to the classy ' + chalk.yellow('ASP.NET OAuth Provider') + ' generator!')); |
11 |
| - }, |
12 |
| - |
13 |
| - prompting: function () { |
14 |
| - var done = this.async(); |
| 7 | + initializing() { |
| 8 | + this.templateData = {}; |
| 9 | + this.log(yosay('Welcome to the classy ASP.NET OAuth Provider generator!')); |
| 10 | + } |
15 | 11 |
|
16 |
| - var prompts = [{ |
| 12 | + async prompting() { |
| 13 | + const prompts = [{ |
17 | 14 | type: 'input',
|
18 | 15 | name: 'name',
|
19 | 16 | message: 'What is the name of the provider you want to create?',
|
@@ -44,25 +41,23 @@ module.exports = yeoman.generators.Base.extend({
|
44 | 41 | store: true
|
45 | 42 | }];
|
46 | 43 |
|
47 |
| - this.prompt(prompts, function (props) { |
48 |
| - this.templatedata.name = props.name; |
49 |
| - this.templatedata.authorname = props.authorname; |
50 |
| - this.templatedata.authorizationendpoint = props.authorizationendpoint; |
51 |
| - this.templatedata.tokenendpoint = props.tokenendpoint; |
52 |
| - this.templatedata.userinformationendpoint = props.userinformationendpoint; |
| 44 | + const answers = await this.prompt(prompts); |
53 | 45 |
|
54 |
| - this.name = props.name; |
55 |
| - this.applicationname = 'AspNet.Security.OAuth.' + props.name |
| 46 | + this.templateData.name = answers.name; |
| 47 | + this.templateData.authorname = answers.authorname; |
| 48 | + this.templateData.authorizationendpoint = answers.authorizationendpoint; |
| 49 | + this.templateData.tokenendpoint = answers.tokenendpoint; |
| 50 | + this.templateData.userinformationendpoint = answers.userinformationendpoint; |
56 | 51 |
|
57 |
| - done(); |
58 |
| - }.bind(this)); |
59 |
| - }, |
| 52 | + this.name = answers.name; |
| 53 | + this.applicationName = 'AspNet.Security.OAuth.' + answers.name; |
| 54 | + } |
60 | 55 |
|
61 |
| - writing: function() { |
62 |
| - this.fs.copyTpl(this.templatePath('Project.csproj'), this.applicationname + '/' + this.applicationname + '.csproj', this.templatedata) |
63 |
| - this.fs.copyTpl(this.templatePath('AuthenticationDefaults.cs'), this.applicationname + '/' + this.name + 'AuthenticationDefaults.cs', this.templatedata) |
64 |
| - this.fs.copyTpl(this.templatePath('AuthenticationExtensions.cs'), this.applicationname + '/' + this.name + 'AuthenticationExtensions.cs', this.templatedata) |
65 |
| - this.fs.copyTpl(this.templatePath('AuthenticationHandler.cs'), this.applicationname + '/' + this.name + 'AuthenticationHandler.cs', this.templatedata) |
66 |
| - this.fs.copyTpl(this.templatePath('AuthenticationOptions.cs'), this.applicationname + '/' + this.name + 'AuthenticationOptions.cs', this.templatedata) |
| 56 | + writing() { |
| 57 | + this.fs.copyTpl(this.templatePath('Project.csproj'), this.applicationName + '/' + this.applicationName + '.csproj', this.templateData) |
| 58 | + this.fs.copyTpl(this.templatePath('AuthenticationDefaults.cs'), this.applicationName + '/' + this.name + 'AuthenticationDefaults.cs', this.templateData) |
| 59 | + this.fs.copyTpl(this.templatePath('AuthenticationExtensions.cs'), this.applicationName + '/' + this.name + 'AuthenticationExtensions.cs', this.templateData) |
| 60 | + this.fs.copyTpl(this.templatePath('AuthenticationHandler.cs'), this.applicationName + '/' + this.name + 'AuthenticationHandler.cs', this.templateData) |
| 61 | + this.fs.copyTpl(this.templatePath('AuthenticationOptions.cs'), this.applicationName + '/' + this.name + 'AuthenticationOptions.cs', this.templateData) |
67 | 62 | }
|
68 |
| -}); |
| 63 | +}; |
0 commit comments