Skip to content

Commit c840920

Browse files
Update yeoman and update JavaScript
- Update to the latest version of Yeoman. - Update the JavaScript code to use more modern language features. - Require Node.js 14.
1 parent 543fe6e commit c840920

File tree

4 files changed

+8713
-6798
lines changed

4 files changed

+8713
-6798
lines changed

generators/app/index.js

Lines changed: 25 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,16 @@
11
'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');
54

6-
module.exports = yeoman.generators.Base.extend({
7-
initializing: function() {
8-
this.templatedata = {};
5+
module.exports = class extends Generator {
96

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+
}
1511

16-
var prompts = [{
12+
async prompting() {
13+
const prompts = [{
1714
type: 'input',
1815
name: 'name',
1916
message: 'What is the name of the provider you want to create?',
@@ -44,25 +41,23 @@ module.exports = yeoman.generators.Base.extend({
4441
store: true
4542
}];
4643

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);
5345

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;
5651

57-
done();
58-
}.bind(this));
59-
},
52+
this.name = answers.name;
53+
this.applicationName = 'AspNet.Security.OAuth.' + answers.name;
54+
}
6055

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)
6762
}
68-
});
63+
};

0 commit comments

Comments
 (0)