@@ -30,6 +30,19 @@ export default class LightningComponentGenerator extends SfdxGenerator<
30
30
throw new Error ( nls . localize ( 'MissingAuraDir' ) ) ;
31
31
}
32
32
}
33
+
34
+ if (
35
+ CreateUtil . getCommandTemplatesInSubdirs ( 'lightningcomponent' , {
36
+ subdir : this . options . type
37
+ } ) . indexOf ( this . options . template ) < 0
38
+ ) {
39
+ throw new Error (
40
+ nls . localize ( 'MissingLightningComponentTemplate' , [
41
+ this . options . template ,
42
+ this . options . type
43
+ ] )
44
+ ) ;
45
+ }
33
46
}
34
47
35
48
public writing ( ) {
@@ -41,14 +54,21 @@ export default class LightningComponentGenerator extends SfdxGenerator<
41
54
type,
42
55
internal
43
56
} = this . options ;
44
- // tslint:disable-next-line:no-unused-expression
57
+
45
58
if ( type === 'aura' ) {
46
59
this . sourceRoot (
47
- path . join ( __dirname , '..' , 'templates' , 'lightningcomponent' , 'aura' )
60
+ path . join (
61
+ __dirname ,
62
+ '..' ,
63
+ 'templates' ,
64
+ 'lightningcomponent' ,
65
+ 'aura' ,
66
+ template
67
+ )
48
68
) ;
49
69
if ( ! internal ) {
50
70
this . fs . copyTpl (
51
- this . templatePath ( '_auradefinitionbundle .cmp-meta.xml' ) ,
71
+ this . templatePath ( ` ${ template } .cmp-meta.xml` ) ,
52
72
this . destinationPath (
53
73
path . join ( outputdir , componentname , `${ componentname } .cmp-meta.xml` )
54
74
) ,
@@ -60,63 +80,62 @@ export default class LightningComponentGenerator extends SfdxGenerator<
60
80
) ;
61
81
}
62
82
this . fs . copyTpl (
63
- this . templatePath ( 'DefaultLightningAuradoc .auradoc' ) ,
83
+ this . templatePath ( ` ${ template } .auradoc` ) ,
64
84
this . destinationPath (
65
85
path . join ( outputdir , componentname , `${ componentname } .auradoc` )
66
86
) ,
67
87
{ }
68
- ) ,
69
- this . fs . copyTpl (
70
- this . templatePath ( `${ template } .cmp` ) ,
71
- this . destinationPath (
72
- path . join ( outputdir , componentname , `${ componentname } .cmp` )
73
- ) ,
74
- { }
88
+ ) ;
89
+ this . fs . copyTpl (
90
+ this . templatePath ( `${ template } .cmp` ) ,
91
+ this . destinationPath (
92
+ path . join ( outputdir , componentname , `${ componentname } .cmp` )
75
93
) ,
76
- this . fs . copyTpl (
77
- this . templatePath ( 'DefaultLightningCss.css' ) ,
78
- this . destinationPath (
79
- path . join ( outputdir , componentname , `${ componentname } .css` )
80
- ) ,
81
- { }
94
+ { }
95
+ ) ;
96
+ this . fs . copyTpl (
97
+ this . templatePath ( `${ template } .css` ) ,
98
+ this . destinationPath (
99
+ path . join ( outputdir , componentname , ` ${ componentname } .css` )
82
100
) ,
83
- this . fs . copyTpl (
84
- this . templatePath ( 'DefaultLightningDesign.design' ) ,
85
- this . destinationPath (
86
- path . join ( outputdir , componentname , `${ componentname } .design` )
87
- ) ,
88
- { }
101
+ { }
102
+ ) ;
103
+ this . fs . copyTpl (
104
+ this . templatePath ( `${ template } .design` ) ,
105
+ this . destinationPath (
106
+ path . join ( outputdir , componentname , ` ${ componentname } .design` )
89
107
) ,
90
- this . fs . copyTpl (
91
- this . templatePath ( 'DefaultLightningSVG.svg' ) ,
92
- this . destinationPath (
93
- path . join ( outputdir , componentname , `${ componentname } .svg` )
94
- ) ,
95
- { }
108
+ { }
109
+ ) ;
110
+ this . fs . copyTpl (
111
+ this . templatePath ( `${ template } .svg` ) ,
112
+ this . destinationPath (
113
+ path . join ( outputdir , componentname , ` ${ componentname } .svg` )
96
114
) ,
97
- this . fs . copyTpl (
98
- this . templatePath ( 'DefaultLightningController.js' ) ,
99
- this . destinationPath (
100
- path . join ( outputdir , componentname , `${ componentname } Controller.js` )
101
- ) ,
102
- { }
115
+ { }
116
+ ) ;
117
+ this . fs . copyTpl (
118
+ this . templatePath ( `${ template } Controller.js` ) ,
119
+ this . destinationPath (
120
+ path . join ( outputdir , componentname , ` ${ componentname } Controller.js` )
103
121
) ,
104
- this . fs . copyTpl (
105
- this . templatePath ( 'DefaultLightningHelper.js' ) ,
106
- this . destinationPath (
107
- path . join ( outputdir , componentname , `${ componentname } Helper.js` )
108
- ) ,
109
- { }
122
+ { }
123
+ ) ;
124
+ this . fs . copyTpl (
125
+ this . templatePath ( `${ template } Helper.js` ) ,
126
+ this . destinationPath (
127
+ path . join ( outputdir , componentname , ` ${ componentname } Helper.js` )
110
128
) ,
111
- this . fs . copyTpl (
112
- this . templatePath ( 'DefaultLightningRenderer.js' ) ,
113
- this . destinationPath (
114
- path . join ( outputdir , componentname , `${ componentname } Renderer.js` )
115
- ) ,
116
- { }
117
- ) ;
129
+ { }
130
+ ) ;
131
+ this . fs . copyTpl (
132
+ this . templatePath ( `${ template } Renderer.js` ) ,
133
+ this . destinationPath (
134
+ path . join ( outputdir , componentname , `${ componentname } Renderer.js` )
135
+ ) ,
136
+ { }
137
+ ) ;
118
138
}
119
- // tslint:disable-next-line:no-unused-expression
120
139
if ( type === 'lwc' ) {
121
140
// lwc requires first letter of filename to be lowercase
122
141
const fileName = `${ componentname
@@ -129,23 +148,30 @@ export default class LightningComponentGenerator extends SfdxGenerator<
129
148
. toUpperCase ( ) } ${ componentname . substring ( 1 ) } `;
130
149
131
150
this . sourceRoot (
132
- path . join ( __dirname , '..' , 'templates' , 'lightningcomponent' , 'lwc' )
151
+ path . join (
152
+ __dirname ,
153
+ '..' ,
154
+ 'templates' ,
155
+ 'lightningcomponent' ,
156
+ 'lwc' ,
157
+ template
158
+ )
133
159
) ;
134
160
this . fs . copyTpl (
135
- this . templatePath ( 'DefaultLightningLWC .js' ) ,
161
+ this . templatePath ( ` ${ template } .js` ) ,
136
162
this . destinationPath ( path . join ( outputdir , fileName , `${ fileName } .js` ) ) ,
137
163
{ className }
138
- ) ,
139
- this . fs . copyTpl (
140
- this . templatePath ( '_ .html' ) ,
141
- this . destinationPath (
142
- path . join ( outputdir , fileName , `${ fileName } .html` )
143
- ) ,
144
- { }
145
- ) ;
164
+ ) ;
165
+ this . fs . copyTpl (
166
+ this . templatePath ( ` ${ template } .html` ) ,
167
+ this . destinationPath (
168
+ path . join ( outputdir , fileName , `${ fileName } .html` )
169
+ ) ,
170
+ { }
171
+ ) ;
146
172
if ( ! internal ) {
147
173
this . fs . copyTpl (
148
- this . templatePath ( '_js -meta.xml' ) ,
174
+ this . templatePath ( ` ${ template } .js -meta.xml` ) ,
149
175
this . destinationPath (
150
176
path . join ( outputdir , fileName , `${ fileName } .js-meta.xml` )
151
177
) ,
0 commit comments