4
4
*/
5
5
6
6
'use strict' ;
7
- var yeoman = require ( 'yeoman-generator' ) ;
8
- var chalk = require ( 'chalk' ) ;
9
- var yosay = require ( 'yosay' ) ;
10
- var str = require ( 'underscore.string' ) ;
11
7
12
- module . exports = yeoman . generators . Base . extend ( {
13
- initializing : function ( ) {
14
- this . pkg = require ( '../package.json ' ) ;
15
- } ,
8
+ const Generator = require ( 'yeoman-generator' ) ;
9
+ const chalk = require ( 'chalk' ) ;
10
+ const yosay = require ( 'yosay ' ) ;
11
+ const str = require ( 'underscore.string' ) ;
16
12
17
- prompting : function ( ) {
18
- var done = this . async ( ) ;
13
+ module . exports = class extends Generator {
14
+ constructor ( args , opts ) {
15
+ super ( args , opts ) ;
16
+ this . pkg = require ( '../package.json' ) ;
17
+ }
19
18
19
+ async prompting ( ) {
20
20
this . log (
21
21
yosay (
22
22
'Welcome to the riveting ' +
23
23
chalk . red ( 'Fluxible' ) +
24
24
' generator!'
25
25
)
26
26
) ;
27
-
28
- var prompts = [
27
+ this . answers = await this . prompt ( [
29
28
{
30
29
type : 'input' ,
31
30
name : 'name' ,
@@ -35,48 +34,20 @@ module.exports = yeoman.generators.Base.extend({
35
34
return ! ! input ;
36
35
} ,
37
36
} ,
38
- ] ;
39
-
40
- this . prompt (
41
- prompts ,
42
- function ( props ) {
43
- this . displayName = props . name ;
44
- this . name = str . slugify ( props . name ) ;
45
- this . buildSystem = str . slugify ( props . buildSystem ) ;
46
- done ( ) ;
47
- } . bind ( this )
37
+ ] ) ;
38
+
39
+ this . displayName = this . answers . name ;
40
+ this . name = str . slugify ( this . answers . name ) ;
41
+ this . buildSystem = str . slugify ( this . answers . buildSystem ) ;
42
+ }
43
+
44
+ writing ( ) {
45
+ this . fs . copyTpl (
46
+ this . templatePath ( ) ,
47
+ this . destinationRoot ( ) ,
48
+ this ,
49
+ null ,
50
+ { globOptions : { dot : true } }
48
51
) ;
49
- } ,
50
-
51
- writing : {
52
- config : function ( ) {
53
- this . template ( 'babel.config.js' , 'babel.config.js' , this . context ) ;
54
- // .gitignore is renamed by npm to .npmignore, so use underscore
55
- this . template ( '_gitignore' , '.gitignore' , this . context ) ;
56
- this . template ( 'package.json' , 'package.json' , this . context ) ;
57
- } ,
58
-
59
- projectfiles : function ( ) {
60
- this . template ( 'app.js' , 'app.js' , this . context ) ;
61
- this . template ( 'client.js' , 'client.js' , this . context ) ;
62
- this . template ( 'server.js' , 'server.js' , this . context ) ;
63
- this . template (
64
- 'webpack.config.js' ,
65
- 'webpack.config.js' ,
66
- this . context
67
- ) ;
68
- this . directory ( 'actions' , 'actions' , this . context ) ;
69
- this . directory ( 'components' , 'components' , this . context ) ;
70
- this . directory ( 'configs' , 'configs' , this . context ) ;
71
- this . directory ( 'stores' , 'stores' , this . context ) ;
72
- } ,
73
- } ,
74
-
75
- install : function ( ) {
76
- this . installDependencies ( {
77
- npm : true ,
78
- bower : false ,
79
- skipInstall : this . options [ 'skip-install' ] ,
80
- } ) ;
81
- } ,
82
- } ) ;
52
+ }
53
+ } ;
0 commit comments