Closed helizabethwhite closed 5 years ago
@helizabethwhite I will look at this in the next couple of days.
@helizabethwhite I just tried this and you can do this with the current version (v2.1.0). Let me know if this satisfies you needs?
generateTemplateFiles([
{
option: 'All',
defaultCase: '(pascalCase)',
entry: {
folderPath: './tools/templates/DotNet',
},
stringReplacers: ['{{ServiceName}}', 'new-service-cs-api', 'new-service-js-class'],
output: {
path: './src/',
pathAndFileNameDefaultCase: '(noCase)',
},
},
{
option: 'Create new JS class',
defaultCase: '(pascalCase)',
entry: {
folderPath: './tools/templates/DotNet/new-service-js-class',
},
stringReplacers: ['{{ServiceName}}'],
output: {
path: './src/scripts/',
pathAndFileNameDefaultCase: '(noCase)',
},
},
{
option: 'Create new C# API',
defaultCase: '(pascalCase)',
entry: {
folderPath: './tools/templates/DotNet/new-service-cs-api',
},
stringReplacers: ['{{ServiceName}}'],
output: {
path: './src/API/controllers/',
pathAndFileNameDefaultCase: '(noCase)',
},
},
]);
Also if you don't want the user to type in the paths for 'new-service-cs-api', 'new-service-js-class'
then you can name the folders:
@codeBelt but this solution requires that the templates exist under the same parent directory (DotNet), right? in my case, i wanted the templates to spawn under different directories, so preserving the individual configs (each with their own output.path
) seemed like the way to do that.
thoughts?
You could put them under templates
. I put it under (DotNet)
so the option didn't bring my angular
, react
or vue
folders in.
I think I understand what you are trying to do. The library gets you 99% there. How about making the folders dynamic like show below?
✔ What do you want to generate? · All
✔ Replace {{ServiceName}} with: · NewService
✔ Replace {{scriptsFolder}} with: · something
✔ Replace {{controllersFolder}} with: · API/controllers/somthing
✔ Output path: · ./src/
✔ Overwrite files, continue? (y/N) · true
At this point I feel the library provides you with the functionality you need. If need some thing more. You can check out https://yeoman.io or https://slushjs.github.io
rather than prompting the user to select from the list of template options provided in the config,
generateAll
allows users to process all of the options in one batch.example config:
note the extra argument to the function
experience:
@codeBelt - please let me know if this potential enhancement makes sense to you. my inspiration was wanting to generate files in multiple directories with the same
stringReplacer
value(s), as this was all part of the same boilerplate step~ 🙂