Templates and other ideas (implemented in fork)
See original GitHub issueI had some requirements in a project recently that needed some finer control over the creation of the different components. I’ve got the working code in a fork https://github.com/Daveawb/create-react-component-folder.
I wondered if this would be of any use to you, it does add a dependency on handlebars to manage templates but abstracts a lot of logic away from the main index and creation scripts.
-
Added a configuration
namedexports
to remove default exports and export named variables only. -
Added Typescript propTypes (removed {{name}}.propTypes) and added a TS type instead when typescript is in the configuration.
-
Added Typescript types to functional components
-
All options have default values that are passed in from cosmiconfig
-
Run time configuration values are merged with the defaults to provide a consistent config array throughout the script.
-
A minor configuration helper added to get items from a config store
-
Templates are rendered using handlebars rather than JS. This could potentially allow for the templates to be published into a project allowing for finer control over how components etc. are rendered.
-
Removed all the generation functions in favour of one
createReactComponent
function. -
Fixed ESLint and TSLint problems with current template layouts.
Let me know if this is of any use to you and I’ll clean it up and put in a PR.
Additional
- Refactored config to use a global store with a frozen API that is available as a require in any script that needs it without passing it around in arguments.
- Config is an object with two keys,
flags
andvalues
, these are not directly accessible. - Config exposes a simple API to check, get and merge values.
- Config is an object with two keys,
- Added
--output <directory> | -o <directory>
to options to allow configuring default output location - Cleaned up templates and fixed a few bugs with prop types
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:10 (3 by maintainers)
Top GitHub Comments
This looks great. I will have a better look at it soon and let you know what I think, and then you could probably make a PR 👍
Ok, added the PR for you to review. #38