modugen
Simple micro generator for simple needs!
Usage
-
Add modugen to your project
yarn add modugen --dev
-
Create
templates/CoreModule.[pascalCase].js
file at root of your project.templates
directory is the default home for your all module templates.;{return <button>$titleCase</button>;}$pascalCase; -
Execute following command and your
BaseButton.js
module will be generated at your project root.yarn run modugen CoreModule.BaseButton
Install Globally
Install modugen globally for easy access.
npm i modugen -g
Generating module directory
-
Create a module template directory structure like the following. Now your CoreModule template directory is inside src directory including all the related files.
├── templates │ └── src │ └── CoreModule.[dashCase] │ ├── [camelCase].todo │ ├── [pascalCase].jsx │ ├── [pascalCase].test.js │ └── index.js
-
Run following command to generate
BaseButton
module.modugen src.CoreModule.BaseButton
The
BaseButton
module will be generated at your project rootsrc
directory like following.│── src │ └── base-button │ ├── baseButton.todo │ ├── BaseButton.jsx │ ├── BaseButton.test.js │ └── index.js
Supported Case Formats
- camelCase: exampleFormatOfThis
- snakeCase: example_format_of_this
- dashCase/hyphenatedCase/kebabCase: example-format-of-this
- dotCase: example.format.of.this
- pascalCase/properCase: ExampleFormatOfThis
- lowerCase: example format of this
- constantCase: EXAMPLE_FORMAT_OF_THIS
- titleCase: Example Format Of This
CLI Usage
```
Usage
$ modugen <path-to-template>.<module-name>
Options
--cwd current working directory
--templateFilesDir templates directory to look for. Default is ./templates
--destPath destination directory for output.
Examples
Look for template file name starting with 'CoreModule' inside 'templates/' and generate BaseButton module.
$ modugen CoreModule.BaseButton
Look for template file name starting with 'CoreModule' inside 'templates/src/' and generate BaseButton module.
$ modugen src.CoreModule.BaseButton
Look for template file name starting with 'PageModule' inside 'templates/src/pages' and generate HomePage module at 'src/pages/'.
$ modugen src.pages.PageModule.HomePage
```
API Usage
; /* Look for template file name starting with 'CoreModule' * inside './templates/' and generate BaseButton module. */await ; // With options to override defaultOptionsawait ;
options
Type: object
templateFilesDir
Type: string
Default: ./templates
templates directory to look for.
destPath
Type: string
Default: ``
Output destination.
License
MIT ©