CVarisco / create-component-app

Tool to generate different types of React components from the terminal. 💻
MIT License
859 stars 58 forks source link

add the ability to choose in the config the file names #20

Closed CVarisco closed 7 years ago

CVarisco commented 7 years ago

Adds the ability to the user to insert the file name. Something like this in the config:

{
  ...
  file_name: {
    test: 'COMPONENT_NAME.test.js',
    etc
  }
}

thanks to @viktorbergehall

iagodahlem commented 7 years ago

Hey @CVarisco, that's a great feature that I will really appreciate to use. I will try to figure this out and open a PR.

But first, I have some suggestions. What do you think about pass just the prefix used in the file name to config? Like this:

{
  ...
  file_name: {
    test: 'test', //or
    test: 'spec', // or
    etc
  }
}

I think this way will be better to deal with the name and extension of the file, and just do something like this to generate the name of the file:

fs.outputFile(`${destination}/${name}.{testPrefix}.${jsExtension}`, generateTestTemplate(name))

What do you think?

CVarisco commented 7 years ago

Hi @iagodahlem, thanks to your support 🙂

What do you think if the user can choose in base the name and the testPrefix ? Example:

{
  ...
  file_name: {
    testPrefix: 'test', //or
    test: 'COMPONENT_NAME',
    etc
  }
}

And, what do you think if the user can use the constant COMPONENT_NAME to be replaced on the file_name config object ?

Example with component name = MyComponent

{
  ...
  file_name: {
    testPrefix: 'test', //or
    test: 'COMPONENT_NAME',
    component: 'Button',
    etc
  }
}

Results:

Understand what I mean ? Thanks again 🌮

iagodahlem commented 7 years ago

Hey @CVarisco! I thank you man.

I guess that I get it. So let's see, your idea is, let user pass some optional options to _filename property, being some of this options:

What do you think? Do you have any other option in mind? Let's try to get and document all possible options that we want to add.

Another suggestions that I have for the options name, tell me what you think:

So we use like this:

{
  "fileNames": {
    "testFileMatch": "spec"
  }
}
CVarisco commented 7 years ago

Yeah 🎉 And also the style file name is a good option to add.

So:

{
  "fileNames": {
    "testFileMatch": "spec",
    "testFileName": "myTest",  // default value to COMPONENT_NAME.
    "componentFileName": "component",  // default value to COMPONENT_NAME.
    "styleFileName": "styles", // default to COMPONENT_NAME.
  }
}

Is it ok for you ?

iagodahlem commented 7 years ago

Yes.

That's great to me.

Let's do this.

:metal: :metal: :metal:

CVarisco commented 7 years ago

Hi !

I'm working on it on filenames-feature branch 📇