npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

heinzelmannchen-cli

v1.0.13

Published

This is the cli for the heinzelmannchen codegeneration tool.

Downloads

20

Readme

heinzelmannchen-cli

logo

Heinzelmannchen is a little helper for your daily work. It is used to create code from your templates and a datasource (i.e. a database). You have full control over the templates you'd like to use for your projects. This is the cli for the heinzelmannchen codegeneration tool.

Usage

Systemrequirements

  • Nodejs installed (http://nodejs.org)

Installation

$ npm install heinzelmannchen-cli --global

How to use the CLI

Once installed you can use heinzel in the terminal.

$ heinzel [commando] --help

I need some help

Just enter --help.

$ heinzel --help
$ heinzel create --help

Setting up Heinzelmännchen

Heinzelmännchen needs a .heinzelrc file to know what you want to do. You can easily create one, by running the init command. Or just run:

$ cd to/your/project
$ touch .heinzelrc

The .heinzelrc contains domains, which define a template and a datasource from a generator for creation. If you want to use your own template for your .heinzelrc file checkout (creating your own .heinzelrc.tpl).

Domains

A domain is defines a template and a generator which creates data for processing the template. Domains are defined in the .heinzelrc file and can be grouped for easier creation.

The .heinzelrc file contains an object domains which contains domainsdefinitions.

{
    "domains": {
        "express": {
            "routes": {
                "template": "express/route.js.tpl",
                "output": "./backend/routes/<%= name %>.js"
            },
            "appjs": {
                "template": "express/app.js.tpl",
                "output": "./backend/app.js"
            }
        },
        "angular": {
            // angular templates...
        }
    }    
}

Templates

You can use templates from a repository or a folder on your system. If you want to use templates from a repository you need to specify there location in the .heinzelrc.

{
    /// ..domains
    "templates": {
        "express": "git+https://github.com/USER/heinzelmannchen-tpl-express.git#1.0.1",
        "angular": "git+http://yourrepo.com/heinzelmannchen-tpl-angular.git#1.0.1"
    }
}

You can reference the templates in the templaterepo by the name defined name. If you want to maintain the templates in a folder you can directly reference them in a domain.

{
    "domains": {
        "appjs": {
            "template": "express/app.js.tpl"
        },
        "anotherdomain": {
            "template": "/Users/Anton/mytemplates/foo.tpl"
        }
    }
    // ..templates
}
Creating a template

To get going you need some templates. Templates can be writen in ERB-Style or you can set your own delimiters in the .heinzelrc. Heinzelmännchen uses underscore to process the templates. So you can use the hole functionality from underscore, and additionaly the functionality from underscore.string. Placeholders with a = will be evaluated by underscore,

Hallo <%= name %> // if name = 'Anton' -> Hallo Anton

without a = it will be interpolated.

<% var age = 109 %>
You are <%= age %> // -> You are 109

Generators

Finally your templates need some data. Heinzelmännchen uses generators, which create data from a source. You can create your own data if you don't find one in the npm reqistry (check out how to create a generator).

$ heinzel search -g keyword

To install a generator you can run install in the terminal.

$ heinzel install -g ask

This will install heinzelmannchen-gen-ask in the nearest node_packages folder and add it to the .heinzelrc file.

To checkout what a generator does or what datastructur it returns run the following commands in your terminal.

$ heinzel explain ask

To setup your domains to use a generator just refer to the name. Some generators need a little of configuration. Take heinzelmannchen-gen-ask without configuration ask doesn't know what to do. The ask-generator takes your config and prompts it to set some values when you create a domain.

{
    "domains": {
        "express": {
            "routes": {
                "template": "express/route.js.tpl",
                "output": "./backend/routes/<%= name %>.js",
                "generator": {
                    "npm": "ask",
                    "config": {
                        "ask": [{
                            "type": "input",
                            "name": "name",
                            "message": "Enter a name for your route",
                            "errorMessage": "Enter a valid name.",
                            "validation": "value.length > 0"
                        }]
                    }
                }
            }
        }
    },
    "generators": {
        "ask": "heinzelmannchen-gen-ask"
    }
    // ... templates
}

Creating code

If your .heinzerc is all setup, you can create code for a specific domain. Just run heinzel or heinzel create DOMAIN in the folder containing your .heinzelrc.

$ heinzel create express