1
- var Generator = require ( ' yeoman-generator' ) ;
2
- var chalk = require ( ' chalk' ) ;
3
- var yosay = require ( ' yosay' ) ;
4
- var path = require ( ' path' ) ;
5
- var config = require ( path . resolve ( '.' , ' package.json' ) ) ;
1
+ var Generator = require ( " yeoman-generator" ) ;
2
+ var chalk = require ( " chalk" ) ;
3
+ var yosay = require ( " yosay" ) ;
4
+ var path = require ( " path" ) ;
5
+ var config = require ( path . resolve ( "." , " package.json" ) ) ;
6
6
7
7
config . vfConfig = config . vfConfig || [ ] ;
8
8
vfName = config . vfConfig . vfName || "Visual Framework 2.0" ;
9
9
vfNamespace = config . vfConfig . vfNamespace || "vf-" ;
10
- vfComponentPath = config . vfConfig . vfComponentPath || path . resolve ( __dirname , ' ../../components' ) ;
10
+ vfComponentPath = config . vfConfig . vfComponentPath || path . resolve ( __dirname , " ../../components" ) ;
11
11
12
12
function camelize ( str , upperCaseFirst ) {
13
13
var upperCaseFirst = upperCaseFirst || false ;
@@ -17,26 +17,26 @@ function camelize(str,upperCaseFirst) {
17
17
} else {
18
18
return index === 0 ? word . toLowerCase ( ) : word . toUpperCase ( ) ;
19
19
}
20
- } ) . replace ( / \s + / g, '' ) . replace ( / - / g, '' ) ;
20
+ } ) . replace ( / \s + / g, "" ) . replace ( / - / g, "" ) ;
21
21
}
22
22
23
23
module . exports = class extends Generator {
24
24
prompting ( ) {
25
25
this . log ( (
26
- chalk . blue . bold ( "_______ _______ __ __ _______ _______ __ _ _______ __ _ _______ \n" ) +
27
- chalk . blue . bold ( "| || || |_| || || || | | || || | | || | \n" ) +
28
- chalk . blue . bold ( "| || _ || || _ || _ || |_| || ___|| |_| ||_ _| \n" ) +
29
- chalk . blue . bold ( "| || | | || || |_| || | | || || |___ | | | | \n" ) +
30
- chalk . blue . bold ( "| _|| |_| || || ___|| |_| || _ || ___|| _ | | | \n" ) +
31
- chalk . blue . bold ( "| |_ | || ||_|| || | | || | | || |___ | | | | | | \n" ) +
32
- chalk . blue . bold ( "|_______||_______||_| |_||___| |_______||_| |__||_______||_| |__| |___| \n" ) +
33
- chalk . red . bold ( "_______ _______ __ _ _______ ______ _______ _______ _______ ______ \n" ) +
34
- chalk . red . bold ( "| || || | | || || _ | | _ || || || _ | \n" ) +
35
- chalk . red . bold ( "| ___|| ___|| |_| || ___|| | || | |_| ||_ _|| _ || | || \n" ) +
36
- chalk . red . bold ( "| | __ | |___ | || |___ | |_||_ | | | | | | | || |_||_ \n" ) +
37
- chalk . red . bold ( "| || || ___|| _ || ___|| __ || | | | | |_| || __ |\n" ) +
38
- chalk . red . bold ( "| |_| || |___ | | | || |___ | | | || _ | | | | || | | |\n" ) +
39
- chalk . red . bold ( "|_______||_______||_| |__||_______||___| |_||__| |__| |___| |_______||___| |_|\n" )
26
+ chalk . blue . bold ( "_______ _______ __ __ _______ _______ __ _ _______ __ _ _______ \n" ) +
27
+ chalk . blue . bold ( "| || || |_| || || || | | || || | | || | \n" ) +
28
+ chalk . blue . bold ( "| || _ || || _ || _ || |_| || ___|| |_| ||_ _| \n" ) +
29
+ chalk . blue . bold ( "| || | | || || |_| || | | || || |___ | | | | \n" ) +
30
+ chalk . blue . bold ( "| _|| |_| || || ___|| |_| || _ || ___|| _ | | | \n" ) +
31
+ chalk . blue . bold ( "| |_ | || ||_|| || | | || | | || |___ | | | | | | \n" ) +
32
+ chalk . blue . bold ( "|_______||_______||_| |_||___| |_______||_| |__||_______||_| |__| |___| \n" ) +
33
+ chalk . red . bold ( "_______ _______ __ _ _______ ______ _______ _______ _______ ______ \n" ) +
34
+ chalk . red . bold ( "| || || | | || || _ | | _ || || || _ | \n" ) +
35
+ chalk . red . bold ( "| ___|| ___|| |_| || ___|| | || | |_| ||_ _|| _ || | || \n" ) +
36
+ chalk . red . bold ( "| | __ | |___ | || |___ | |_||_ | | | | | | | || |_||_ \n" ) +
37
+ chalk . red . bold ( "| || || ___|| _ || ___|| __ || | | | | |_| || __ |\n" ) +
38
+ chalk . red . bold ( "| |_| || |___ | | | || |___ | | | || _ | | | | || | | |\n" ) +
39
+ chalk . red . bold ( "|_______||_______||_| |__||_______||___| |_||__| |__| |___| |_______||___| |_|\n" )
40
40
) ) ;
41
41
42
42
this . log ( (
@@ -45,35 +45,35 @@ module.exports = class extends Generator {
45
45
chalk . white ( "https://stable.visual-framework.dev/developing/#components" )
46
46
) ) ;
47
47
48
- var componentType = [ ' element' , ' block' , ' container' , ' layout' , ' utility' ] ;
49
- if ( vfNamespace != ' vf-' ) {
50
- var DepartmentType = [ vfName , ' VF Global' ] ;
48
+ var componentType = [ " element" , " block" , " container" , " layout" , " utility" ] ;
49
+ if ( vfNamespace != " vf-" ) {
50
+ var DepartmentType = [ vfName , " VF Global" ] ;
51
51
} else {
52
52
var DepartmentType = [ vfName ] ;
53
53
}
54
54
55
55
var prompts = [ {
56
- type : ' list' ,
57
- name : ' dept' ,
56
+ type : " list" ,
57
+ name : " dept" ,
58
58
required : true ,
59
- message : ' Who\ 's the component for?' ,
59
+ message : " Who's the component for?" ,
60
60
choices : DepartmentType
61
61
} , {
62
- type : ' list' ,
63
- name : ' type' ,
62
+ type : " list" ,
63
+ name : " type" ,
64
64
required : true ,
65
- message : ' What type of component is this?' ,
65
+ message : " What type of component is this?" ,
66
66
choices : componentType
67
67
} , {
68
- type : ' input' ,
69
- name : ' componentName' ,
68
+ type : " input" ,
69
+ name : " componentName" ,
70
70
required : true ,
71
- message : ' What\ 's the name of your component? (all lowercase, a hyphen instead of space, will be prefixed with your project\ 's namespace.)' ,
72
- description : ' Component name'
71
+ message : " What's the name of your component? (all lowercase, a hyphen instead of space, will be prefixed with your project's namespace.)" ,
72
+ description : " Component name"
73
73
} , {
74
- type : ' confirm' ,
75
- name : ' npm' ,
76
- message : ' Will this be published to npm?' ,
74
+ type : " confirm" ,
75
+ name : " npm" ,
76
+ message : " Will this be published to npm?" ,
77
77
default : true
78
78
} ] ;
79
79
@@ -85,68 +85,68 @@ module.exports = class extends Generator {
85
85
writing ( ) {
86
86
87
87
switch ( this . props . dept ) {
88
- case vfName :
88
+ case vfName :
89
89
var namespace = vfNamespace ;
90
90
break ;
91
- case "VF Global" :
91
+ case "VF Global" :
92
92
var namespace = "vf-" ;
93
93
break ;
94
94
}
95
95
var patternType = this . props . type ;
96
- var totalPath = vfComponentPath + '/' + namespace + this . props . componentName + "/" ;
96
+ var totalPath = vfComponentPath + "/" + namespace + this . props . componentName + "/" ;
97
97
var fileName = namespace + this . props . componentName ;
98
98
99
- var outputFile = fileName + ' .njk' ;
99
+ var outputFile = fileName + " .njk" ;
100
100
this . fs . copyTpl (
101
- this . templatePath ( ' _component.njk' ) ,
101
+ this . templatePath ( " _component.njk" ) ,
102
102
this . destinationPath ( totalPath + outputFile ) ,
103
103
{
104
104
componentName : fileName
105
105
}
106
106
) ;
107
107
108
- var outputFile = fileName + ' .scss' ;
108
+ var outputFile = fileName + " .scss" ;
109
109
this . fs . copyTpl (
110
- this . templatePath ( ' _component.scss' ) ,
110
+ this . templatePath ( " _component.scss" ) ,
111
111
this . destinationPath ( totalPath + outputFile ) ,
112
112
{
113
113
isNpmComponent : this . props . npm ,
114
114
componentName : fileName
115
115
}
116
116
) ;
117
117
118
- var outputFile = fileName + ' .variables.scss' ;
118
+ var outputFile = fileName + " .variables.scss" ;
119
119
this . fs . copyTpl (
120
- this . templatePath ( ' _component.variables.scss' ) ,
120
+ this . templatePath ( " _component.variables.scss" ) ,
121
121
this . destinationPath ( totalPath + outputFile ) ,
122
122
{
123
123
componentName : fileName
124
124
}
125
125
) ;
126
126
127
- var outputFile = fileName + ' .js' ;
127
+ var outputFile = fileName + " .js" ;
128
128
this . fs . copyTpl (
129
- this . templatePath ( ' _component.js' ) ,
129
+ this . templatePath ( " _component.js" ) ,
130
130
this . destinationPath ( totalPath + outputFile ) ,
131
131
{
132
132
componentNameJs : camelize ( fileName ) , // JS friendly name
133
133
componentName : fileName
134
134
}
135
135
) ;
136
136
137
- var outputFile = fileName + ' .react.js' ;
137
+ var outputFile = fileName + " .react.js" ;
138
138
this . fs . copyTpl (
139
- this . templatePath ( ' _component.react.js' ) ,
139
+ this . templatePath ( " _component.react.js" ) ,
140
140
this . destinationPath ( totalPath + outputFile ) ,
141
141
{
142
142
componentNameReact : camelize ( fileName , true ) , // React JS friendly name
143
143
componentName : fileName
144
144
}
145
145
) ;
146
146
147
- var outputFile = fileName + ' .config.yml' ;
147
+ var outputFile = fileName + " .config.yml" ;
148
148
this . fs . copyTpl (
149
- this . templatePath ( ' _component.config.yml' ) ,
149
+ this . templatePath ( " _component.config.yml" ) ,
150
150
this . destinationPath ( totalPath + outputFile ) ,
151
151
{
152
152
componentType : patternType ,
@@ -155,45 +155,45 @@ module.exports = class extends Generator {
155
155
) ;
156
156
157
157
this . fs . copyTpl (
158
- this . templatePath ( ' _README.md' ) ,
159
- this . destinationPath ( totalPath + ' README.md' ) ,
158
+ this . templatePath ( " _README.md" ) ,
159
+ this . destinationPath ( totalPath + " README.md" ) ,
160
160
{
161
161
componentName : fileName
162
162
}
163
163
) ;
164
164
165
165
this . fs . copyTpl (
166
- this . templatePath ( ' _.npmignore' ) ,
167
- this . destinationPath ( totalPath + ' .npmignore' ) ,
166
+ this . templatePath ( " _.npmignore" ) ,
167
+ this . destinationPath ( totalPath + " .npmignore" ) ,
168
168
{
169
169
componentName : fileName
170
170
}
171
171
) ;
172
172
173
173
this . fs . copyTpl (
174
- this . templatePath ( ' _CHANGELOG.md' ) ,
175
- this . destinationPath ( totalPath + ' CHANGELOG.md' ) ,
174
+ this . templatePath ( " _CHANGELOG.md" ) ,
175
+ this . destinationPath ( totalPath + " CHANGELOG.md" ) ,
176
176
{
177
177
componentName : fileName
178
178
}
179
179
) ;
180
180
181
181
if ( this . props . npm ) {
182
182
this . fs . copyTpl (
183
- this . templatePath ( ' _package.json' ) ,
184
- this . destinationPath ( totalPath + ' package.json' ) ,
183
+ this . templatePath ( " _package.json" ) ,
184
+ this . destinationPath ( totalPath + " package.json" ) ,
185
185
{
186
186
componentName : fileName ,
187
187
componentHomepage : config . vfConfig . vfHomepage ,
188
- componentStylesheet : fileName + ' .scss'
188
+ componentStylesheet : fileName + " .scss"
189
189
}
190
190
) ;
191
191
}
192
192
193
193
if ( this . props . npm ) {
194
194
this . fs . copyTpl (
195
- this . templatePath ( ' _index.scss' ) ,
196
- this . destinationPath ( totalPath + ' index.scss' ) ,
195
+ this . templatePath ( " _index.scss" ) ,
196
+ this . destinationPath ( totalPath + " index.scss" ) ,
197
197
{
198
198
componentName : fileName
199
199
}
0 commit comments