genapp

0.2.3 • Public • Published

genapp

A customizable generator application using fgen.

You can use genapp to generate project structures, files, and all sorts of templates. It's easy to use, and it's customizable. E.g. you can create a bundle (set of templates) for Node.js projects, and a bundle for Java projects, etc.

genapp is bundled with a node bundle for Node.js projects, see the Quick Examples section.

Installation

$ [sudo] npm install genapp -g

Quick Examples

To generate a new Node.js project, you can do:

# generate in the current directory. 
gen node
 
# generate myproj. 
gen node -o myproj

To see a list of sub-bundles of the node bundle, you can do:

gen node -l

To generate sub-bundles of the node bundle, you can do:

# generate the server sub-bundle in the current directory. 
gen node server
 
# generate the server sub-bundle to folder servers. 
gen node server -o servers

Usage

The node bundle that comes with genapp has nothing special, you can create your own bundle just like the node one by following a set of rules.

First, you have to know that there is a configuration file named .genappconfig that you can have in your home folder, in it, you can specify all the root folders in where a set of bundles are found. Take a look at an sample .genappconfig:

{
  "roots": [
    "~/projects/templates/",
    "~/java/projects/templates/"
  ]
}

In this sample config, we have 2 roots, each of them can contain bundles. e.g. we may have the following 2 folders in ~/projects/templates/:

csharp
node

This means, we have 2 bundles, a csharp bundle and a node bundle. Note that root folders are prioritized, those are placed on the top take precedence over those below them. And the built-in bundles' root is just appended to your roots, making bundles within it easily overridden by your own bundles. So, the node bundle in ~/projects/templates/ will override the built-in node bundle.

NOTE: Folders starting with a dot or double underscores are ignored by genapp, so folders with names like __async and .git are not treated like bundles.

Within each bundle, you place all the templates that you want to generate. We use mustache based templates. A bundle can also contain sub-bundles, and sub-bundles can contain sub-bundles, and so on.

NOTE: ___ folder within a bundle is especial, it is the sub-bundles' root of the current bundle. It doesn't get generated.

Alongside the bundle folder, you place a file named [bundle].js, like this:

java
java.js
csharp
csharp.js
node
node.js

This js file defines the context for the bundle and how to get the values for the context during template rendering process. To understand how it works, you can refer to the built-in node bundle's implementation.

License

(The MIT License)

Copyright (c) 2013 Seth Yuan

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Readme

Keywords

none

Package Sidebar

Install

npm i genapp

Weekly Downloads

1

Version

0.2.3

License

MIT

Last publish

Collaborators

  • sethyuan