scaffolder icon indicating copy to clipboard operation
scaffolder copied to clipboard

Custom Transformers don't work

Open fhanggi opened this issue 2 years ago • 8 comments

Hello

I put this into my scaffolder.config

module.exports = { transformers: { toUpperCaseNew: (parameterValue, context) => parameterValue.toUpperCase(), }, functions: { etc.

Then inside my scaffolder file i try to use toUpperCaseNew

export const {{tableName | toUpperCaseNew}} = (props) => {

When i run this

scaff create redux tableName=Fabian --folder MyCoolRedux

i get this error

Error while trying to apply the following transformation "toUpperCaseNew". You are probably missing a definition for the "toUpperCaseNew" transformer in your scaffolder.config.js file For more information about transformers check this out https://github.com/galElmalah/scaffolder#getting-started

I know i have toUpperCaseNew in my scaffolder.config.js file. I placed that file into the scaffolder folder.

It looks like it's not reading it or finding it.

Any tips would be appreciated.

Thank you

Fabian

fhanggi avatar Mar 23 '22 05:03 fhanggi

Hey @fhanggi , can you share with me a reproducible example?

galElmalah avatar Mar 23 '22 21:03 galElmalah

Ok I attached a zip file with a folder where you can reproduce this. i am opening the folder in vs code and in a terminal i run scaff create component componentName=CoolAFComponent --folder MyCoolComp

i then see this error

Error while trying to apply the following transformation "toUpperCaseNew". You are probably missing a definition for the "toUpperCaseNew" transformer in your scaffolder.config.js fil scaffTest.zip e

fhanggi avatar Mar 23 '22 22:03 fhanggi

seems like you got some invalid values in your scaffolder.config.js, in the bottom of the config you still got some left overs from the getting started guide

      transformers: {...},
      functions: {...},
      parametersOptions: {...}

galElmalah avatar Mar 23 '22 22:03 galElmalah

Removing that faulty code seems to be resolving the issue for me and the custom transformer is applied as expected

galElmalah avatar Mar 23 '22 22:03 galElmalah

I removed everything except these lines but still get the same error

module.exports = { transformers: { toUpperCaseNew: (parameterValue, context) => parameterValue.toUpperCase() } };

i'm running node 12.13.1 and npm 6.14.8. Hope that is ok

fhanggi avatar Mar 23 '22 23:03 fhanggi

Should be ok, ill take a closer look later today Which version of scaffolder are you running?

galElmalah avatar Mar 24 '22 06:03 galElmalah

Hello

I am running 1.10.1. Installed in my global npm cache.

Thank you.

fhanggi avatar Mar 24 '22 15:03 fhanggi

Hello, it's been a while. Could you please let me know if you found a solution for this issue?

fhanggi avatar Jul 20 '22 00:07 fhanggi