Giter Club home page Giter Club logo

microgen's Introduction

microgen NPM version Build Status Dependency Status

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
  • no data files required (like other handlebars cli's)
    • you'll be prompted to fill in the data at runtime

Installation

$ npm install microgen # --global

Usage

$ microgen --help

  Usage: microgen <template-file> [output-file]

  Options:

    -h, --help      show usage help
    -p, --pipe      pipe output to stdout, instead of writing to file

    output-file     if not specified, it will be $PWD/<template-file>
                    * if <template-file> 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. 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 display

For example, say you have a package.json template file:

{{!
== 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:

== Let the Good Times Roll ==

name: smile
owner: busterc
description: writes :) to stdout

Include 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:

{
  "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

If you need heavy weight project scaffolding generators, then look into plop and yo

License

ISC © Buster Collings

microgen's People

Contributors

busterc avatar ungoldman avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

Forkers

lawrenceue

microgen's Issues

Pipe to stdout

Is there a way to pipe the output to stdout instead of saving it to a file?

add node.js api

Would be cool to be able to use this module programmatically too! Is that something you're open to?

No programatic access

This looks really cool, but I was wondering what you think of making it both command line, and programmatic with an exported function.

It's not a huge problem. I haven't even tried it yet. :)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.