Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/fcouceiro/nutiljs
A node.js command-line tool for generating boilerplate (controllers, services, models and resources) based on placeholders provided by the user.
https://github.com/fcouceiro/nutiljs
boilerplate cli generator nodejs placeholder utility
Last synced: about 2 months ago
JSON representation
A node.js command-line tool for generating boilerplate (controllers, services, models and resources) based on placeholders provided by the user.
- Host: GitHub
- URL: https://github.com/fcouceiro/nutiljs
- Owner: fcouceiro
- License: mit
- Created: 2018-03-27T22:18:52.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2018-04-05T14:05:48.000Z (almost 7 years ago)
- Last Synced: 2024-11-23T17:43:37.464Z (2 months ago)
- Topics: boilerplate, cli, generator, nodejs, placeholder, utility
- Language: JavaScript
- Homepage:
- Size: 50.8 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Code of conduct: .github/CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# nutil - Node Utility
A command-line tool for generating boilerplate (controllers, services, models and resources) based on placeholders provided by the user.
## Installation
### Globally:
* `yarn global add nutiljs`or
* `npm i -g nutiljs`You will then be able to run `nutil` from the command line.
### Locally:
* `yarn add nutiljs`or
* `npm i nutiljs`Use a package runner like [npx](https://www.npmjs.com/package/npx) to run locally installed packages.
You will then be able to run `npx nutil` from the command line.
## Usage
Create a controller based on the [provided placeholder](https://github.com/fcouceiro/nutil/tree/master/placeholders/controllers):
nutil --controller (-c)
Create a service based on [provided placeholder](https://github.com/fcouceiro/nutil/tree/master/placeholders/services):
nutil --service (-s)
Create a model based on [provided placeholder](https://github.com/fcouceiro/nutil/tree/master/placeholders/models):
nutil --model (-m)
Create a resource based on [provided placeholder](https://github.com/fcouceiro/nutil/tree/master/placeholders/resources):
nutil --resource (-r)
Multiple generations can take place with a single command, by concatenatig different options. Example: create both a controller and a service:nutil -s -c
__Note:__ Generated files will be created in the directory where you run `nutil` from (cwd)
## How it works
There is a pre-defined set of placeholder keys, as represented in the following table:Key | Meaning
--- | ---
[name] | Singular lower case
[NAME] | Singular upper case
[Name] | Singular pascal case
[names] | Plural lower case
[NAMES] | Plural upper case
[Names] | Plural pascal caseWhen the user requests the generation of a certain type, the generator spawns a process that "search and replace" the corresponding type placeholders (both in file name and file content). It substitutes all found keys with the appropriate casing (e.g. [name] would be replaced by the controller name in singular lower case; [Names] in plural pascal case; etc).
Case representations are generated by the great [inflection package](https://www.npmjs.com/package/inflection).
## Placeholders
All boilerplate is generated based on placeholders provided by the user.
Feel free to use different placeholder keys in both file name and content, as described in [How it works](#how-it-works) section.Placeholders must be placed inside `placeholders/` folder.
A few basic placeholders are included by default (using mongoose for model generation and [Joi](https://www.npmjs.com/package/joi) for model validation).