zengenti-make-component
v1.7.1
Published
Generates component boilerplate.
Downloads
29
Readme
Install
Globally for command line usage
npm i -g zengenti-make-component
Locally as a module in your project
npm i zengenti-make-component
TLDRs
Set
COMPONENT_MAKER_OUTPUT_DIR
env var in .env or environmental variables, to set the default output directory.3 arguments in order: component-name, output-dir, input-dir
make-component 2nd and 3rd arguments are in a confusing order, with output folder being the 2nd argument, and input folder the 3rd.
Usage
As a command line tool
make-component
It will then ask you to enter the component name. Make sure to enter it the same way you would write a React component name.
It will then ask you for the input directory. This is the folder which is copied as the boilerplate code, with 'COMPONENT_NAME_HERE' being replaced by the given component name. Press enter for the default structure.
Then it will ask for the output directory. It will pick up the value of COMPONENT_MAKER_OUTPUT_DIR
from your .env file or in the environmental variables, otherwise it defaults to the current working directory (cwd). You can type a directory relative to your cwd. Press enter to begin the script.
It should then create the component in the chosen directory with the given component name, using the boilerplate specified by the input folder (defaults to ./bin/structure
).
You could alternatively pass the ComponentName, path/to/input, and path/to/output as the first, second, and third arguments to make-component
respectively. The component name is required. This is a slightly faster method.
As a node module
const makeComponent = require('zengenti-make-component').default;
makeComponent('NameOfComponent', 'path/to/output');
Output path is optional, it defaults to the cwd.
Troubleshooting
- Ensure you have homebrew
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
- Make sure to install gnu-sed and alias gsed to sed with:
brew install gnu-sed && PATH="$(brew --prefix)/opt/gnu-sed/libexec/gnubin:$PATH"
Make sure to run
PATH="$(brew --prefix)/opt/gnu-sed/libexec/gnubin:$PATH"
if the foldername being output is wrong e.g. asLHelloWorld
instead ofhelloWorld
- Give yourself permission to execute the bash script:
chmod u+x ./bin/maker.sh
- Install
rename
:
brew install rename
- Install npm dependencies
npm install
This should install dotenv and any other npm packages if they are specified in this package.json
Todo
Write tests
Make it look for a ./structure folder in the cwd and use that as the input folder. Otherwise do default behaviour.
Add a --help command
Add .env.example
Swap input/output arguments of command line version