Closed edhine closed 5 years ago
stringReplacers
only accepts an array of strings. It should be:
stringReplacers: ['__name__', '__model__'],
I see that you are trying to use an object {slot:'__name__', slotValue: 'asdasdada'}
. This is wrong. You will only see that structure in the onComplate callback.
Is there any way to define the variables in any file or other way without having to enter them by console?
Not at the moment but I could add that in. So you want some like this:
const someVarData = 'Dude!';
generateTemplateFiles([
// Angular
{
option: "Angular Ngrx Store",
defaultCase: '(pascalCase)',
entry: {
folderPath: './tools/templates/angular/ngrx-store/',
},
stringReplacers: [{slot:'__name__', slotValue: someVarData}, '__model__'],
output: {
path: './src/app/stores/__name__(lowerCase)',
pathAndFileNameDefaultCase: '(kebabCase)',
},
},
]);
I am going to assume that the only question that will be asked is for __model__
because __name__
will already have a value. Anywhere in your templates __name__
will be replaced with Dude!
. Does that sound correct?
yes, basically the objective is to define them both in a file or directly in the generator, since I want to upload the templates to git and to encode a process that downloads the git template and applies the already defined variables
I think I will create a new property dynamicReplacers
. I will try to work on in the next day or two.
const someVarData = 'Dude!';
generateTemplateFiles([
// Angular
{
option: "Angular Ngrx Store",
defaultCase: '(pascalCase)',
entry: {
folderPath: './tools/templates/angular/ngrx-store/',
},
stringReplacers: ['__model__'],
dynamicReplacers: [{slot:'__name__', slotValue: someVarData}],
output: {
path: './src/app/stores/__name__(lowerCase)',
pathAndFileNameDefaultCase: '(kebabCase)',
},
},
]);
Thank you very much, I know it will help several people, I love how it is done, very good job: D! I'm sorry for the English I use because my native language is Spanish.
@Edhine check out my changes: https://github.com/codeBelt/generate-template-files/pull/24/files
Pull that branch down and do a yarn && yarn build
. Then cd
in to the examples
folder and do yarn generate
. If you look at the templates/angular/ngrx-store/__name__.reducer.spec.ts
you can see I added
// Version: __version__(noCase)
// Description: __description__(noCase)
Here I am using data from the package.json
file.
const config = require('../package.json');
generateTemplateFiles([
// Angular
{
option: "Angular Ngrx Store",
defaultCase: '(pascalCase)',
entry: {
folderPath: './tools/templates/angular/ngrx-store/',
},
stringReplacers: ['__name__', '__model__'],
dynamicReplacers: [
{slot:'__version__', slotValue: config.version},
{slot:'__description__', slotValue: config.description}
],
output: {
path: './src/app/stores/__name__(lowerCase)',
pathAndFileNameDefaultCase: '(kebabCase)',
},
}
]);
Let me know if this is what you wanted
It is exactly what I mentioned !!!
Ok, I will try to get a new build out tomorrow.
@Edhine This feature is now in version 2.1.0
// Angular
√ What do you want to generate? · Angular Ngrx Store (node:19132) UnhandledPromiseRejectionWarning: TypeError: prop.split is not a function