Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/busterc/microgen
:recycle: micro-generator for individual files, easy like sunday morning :sunrise:
https://github.com/busterc/microgen
generator plop scaffolding templates yeoman yo
Last synced: 6 days ago
JSON representation
:recycle: micro-generator for individual files, easy like sunday morning :sunrise:
- Host: GitHub
- URL: https://github.com/busterc/microgen
- Owner: busterc
- License: isc
- Created: 2016-04-21T01:06:11.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-08-25T21:49:14.000Z (about 6 years ago)
- Last Synced: 2024-10-31T10:51:39.519Z (13 days ago)
- Topics: generator, plop, scaffolding, templates, yeoman, yo
- Language: JavaScript
- Size: 56.6 KB
- Stars: 88
- Watchers: 6
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# microgen [![NPM version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Dependency Status][daviddm-image]][daviddm-url]
> micro-generator for individual files, easy like sunday morning
## Yet another generator; how's it different?
- any **file**, anywhere on disk can be a template
- no need to _install_ templates (like heavy weight project generators)
- easiest way to fill in templates, using simple [handlebars placeholders](http://handlebarsjs.com/)
- no data files required (like other handlebars cli's)
- you'll be prompted to fill in the data at runtime## Installation
```sh
$ npm install microgen # --global
```## Usage
```sh
$ microgen --helpUsage: microgen [output-file]
Options:
-h, --help show usage help
-p, --pipe pipe output to stdout, instead of writing to fileoutput-file if not specified, it will be $PWD/
* if has an ".hbs" extension,
it will be removed from the output-file name```
## How does it work?
A microgen template is any **file** that can have [handlebars placeholders](http://handlebarsjs.com/). Microgen will scan the template for placeholders and prompt you to fill in a value for each one.
Supported placeholders:
- Variable `{{some-value}}`
- Block `{{#some-boolean}}something{{else}}something else{{/some-boolean}}`
- `{{^}}` is the same as `{{else}}`
- You can use string literals, e.g. `{{#"Are you happy"}}great{{/"Are you happy"}}`
- Comment `{{!some string to display when prompting}}`
- `{{!--x--}}` is the same as `{{!x}}`
- `{{!}}` just adds a newline to the displayFor example, say you have a `package.json` _template_ file:
```js
{{!
== Let the Good Times Roll ==
}}
{
"name": "{{name}}",
"repository": "{{owner}}/{{name}}",
"description": "{{description}}",
{{!}}{{#"Include Dependencies"}}
"dependencies": {
{{#assert-dotenv}}
"assert-dotenv": "3.0.0",{{/assert-dotenv}}{{!}}{{#"Use a CLI Helper [meow, inquirer, commander]"}}{{#meow}}
"meow": "^3.0.0",{{else}}{{#inquirer}}
"inquirer": "^1.0.2",{{^}}{{#commander}}
"commander": "^2.9.0",{{/commander}}{{/inquirer}}{{/meow}}{{/"Use a CLI Helper [meow, inquirer, commander]"}}
}
{{/"Include Dependencies"}}
}
```Microgen will prompt you like so:
```sh
== Let the Good Times Roll ==
name: smile
owner: busterc
description: writes :) to stdoutInclude Dependencies (Y/n): y
assert-dotenv (Y/n): y
Use a CLI Helper [meow, inquirer, commander] (Y/n): y
meow (Y/n): n
inquirer (Y/n): n
commander (Y/n): y
```...and the resulting output file will contain:
```json
{
"name": "smile",
"repository": "busterc/smile",
"description": "writes :) to stdout","dependencies": {
"assert-dotenv": "3.0.0",
"commander": "^2.9.0",
}
}
```## Respect
**microgen** was inspired by [`khaos`](https://github.com/segmentio/khaos)
_If you need heavy weight project scaffolding generators, then look into [`plop`](https://github.com/amwmedia/plop) and [`yo`](https://github.com/yeoman/yo)_
## License
ISC © [Buster Collings](https://about.me/buster)
[npm-image]: https://badge.fury.io/js/microgen.svg
[npm-url]: https://npmjs.org/package/microgen
[travis-image]: https://travis-ci.org/busterc/microgen.svg?branch=master
[travis-url]: https://travis-ci.org/busterc/microgen
[daviddm-image]: https://david-dm.org/busterc/microgen.svg?theme=shields.io
[daviddm-url]: https://david-dm.org/busterc/microgen