@@ -39,6 +39,7 @@ const customHookGenerator = () => ({
3939 type : 'input' ,
4040 name : 'name' ,
4141 message : 'hook name' ,
42+
4243 } ,
4344 ] ,
4445 actions : function ( ) {
@@ -166,19 +167,19 @@ const apiActionsGenerator = () => ({
166167 type : 'modify' ,
167168 path : 'src/api/actions/index.ts' ,
168169 pattern : getPlaceholderPattern ( 'API_COLLECTION_QUERIES' ) ,
169- template : '...{{camelCase name}}Queries,\n\t $1' ,
170+ template : '...{{camelCase name}}Queries,\n $1' ,
170171 } ,
171172 {
172173 type : 'modify' ,
173174 path : 'src/api/actions/index.ts' ,
174175 pattern : getPlaceholderPattern ( 'API_COLLECTION_MUTATIONS' ) ,
175- template : '...{{camelCase name}}Mutations,\n\t $1' ,
176+ template : '...{{camelCase name}}Mutations,\n $1' ,
176177 } ,
177178 ] ;
178179 } ,
179180} ) ;
180181
181- const apiQueryGenerator = ( ) => ( {
182+ const apiQueryGenerator = ( toKebabCase ) => ( {
182183 description : componentTypes . API_QUERY ,
183184 prompts : [
184185 {
@@ -197,6 +198,7 @@ const apiQueryGenerator = () => ({
197198 type : 'input' ,
198199 name : 'path' ,
199200 message : 'API query action path?' ,
201+ default : ( answers ) => `/${ answers . collection } /${ toKebabCase ( answers . name ) } ` ,
200202 } ,
201203 ] ,
202204 actions : function ( ) {
@@ -211,7 +213,7 @@ const apiQueryGenerator = () => ({
211213 type : 'modify' ,
212214 path : 'src/api/actions/{{collection}}/{{collection}}.queries.ts' ,
213215 pattern : getPlaceholderPattern ( 'QUERY_TYPE_IMPORTS' ) ,
214- template : '{{pascalCase name}}Payload,\n\t {{pascalCase name}}Response,\n\t $1' ,
216+ template : '{{pascalCase name}}Payload,\n {{pascalCase name}}Response,\n $1' ,
215217 } ,
216218 {
217219 type : 'modify' ,
@@ -223,7 +225,7 @@ const apiQueryGenerator = () => ({
223225 }
224226} ) ;
225227
226- const apiMutationGenerator = ( ) => ( {
228+ const apiMutationGenerator = ( toKebabCase ) => ( {
227229 description : componentTypes . API_MUTATION ,
228230 prompts : [
229231 {
@@ -242,6 +244,7 @@ const apiMutationGenerator = () => ({
242244 type : 'input' ,
243245 name : 'path' ,
244246 message : 'API query action path?' ,
247+ default : ( answers ) => `/${ answers . collection } /${ toKebabCase ( answers . name ) } ` ,
245248 } ,
246249 {
247250 type : "list" ,
@@ -268,7 +271,7 @@ const apiMutationGenerator = () => ({
268271 type : 'modify' ,
269272 path : 'src/api/actions/{{collection}}/{{collection}}.mutations.ts' ,
270273 pattern : getPlaceholderPattern ( 'MUTATION_TYPE_IMPORTS' ) ,
271- template : '{{pascalCase name}}Payload,\n\t {{pascalCase name}}Response,\n\t $1' ,
274+ template : '{{pascalCase name}}Payload,\n {{pascalCase name}}Response,\n $1' ,
272275 } ,
273276 {
274277 type : 'modify' ,
@@ -333,11 +336,13 @@ const reactContextGenerator = () => (
333336) ;
334337
335338module . exports = function ( plop ) {
339+ const toKebabCase = plop . getHelper ( 'kebabCase' ) ;
340+
336341 plop . setPrompt ( 'directory' , promptDirectory ) ;
337342 plop . setGenerator ( componentTypes . REACT_COMPONENT , reactComponentGenerator ( ) ) ;
338343 plop . setGenerator ( componentTypes . CUSTOM_HOOK , customHookGenerator ( ) ) ;
339344 plop . setGenerator ( componentTypes . API_ACTIONS , apiActionsGenerator ( ) ) ;
340- plop . setGenerator ( componentTypes . API_QUERY , apiQueryGenerator ( ) ) ;
341- plop . setGenerator ( componentTypes . API_MUTATION , apiMutationGenerator ( ) ) ;
345+ plop . setGenerator ( componentTypes . API_QUERY , apiQueryGenerator ( toKebabCase ) ) ;
346+ plop . setGenerator ( componentTypes . API_MUTATION , apiMutationGenerator ( toKebabCase ) ) ;
342347 plop . setGenerator ( componentTypes . REACT_CONTEXT , reactContextGenerator ( ) ) ;
343348} ;
0 commit comments