@hackage rob0.0.5

Simple projects generator

rob logo

Simple projects generator written in Haskell


Call on me in the day of trouble, and I will deliver, and thou shalt glorify me.

Daniel Defoe, Robinson Crusoe

Installation

$ cabal install rob

Usage

Before using Rob you need to create your projects templates. If for example you work often with nodejs you can create your nodejs template from scratch. Let's see then how to create a new Rob template.

New Project Template Creation

Create a folder anywhere on your machine. Put in this folder all the files/folders you want to use anytime you will chose this template. For example for the nodejs template you may have a folder structure that might look like this:

nodejs
│--package.json
│--README.md
│--travis.yml
│--.gitignore
└───src
│   │--index.js
└───test
    │--runner.js
    │--expect.js

The project.yml file

Rob relies on a single file that you must include in the root of your templates folders. This file is called project.yml

For example, the nodejs template must also contain an additional project.yml file:

nodejs
│--project.yml
│--package.json
│--README.md
...

The project.yml file will contain all the questions needed to copy and render your template files when you will chose that specific template. Depending on your answers to these questions Rob will be able to generate a (key, value) data map that will be used to shape your project files via its template engine

A typical project.yml might look like this:

questions:
  name:
    question: What's the name of the project?
    type: input
    default: foo

  description:
    question: Project description?

  test_framework:
    question: Which test framework do you want to use?
    type: select
    default: mocha
    answers:
      - mocha
      - jasmine
      - tap

  babel_preset:
    question: Which babel preset do you want to use?
    type: multiselect
    default:
      - babel-preset-env
    answers:
      - babel-preset-env
      - babel-preset-es2015
      - babel-preset-es2016
      - babel-preset-es2017

  is_public:
    question: Is it public?
    type: confirm

  password:
    question: What's your password?
    type: password

The kind of answers types supported are only input, confirm, select, multiselect and password. The questionnaire prompt are powered by fortytwo

Template engine

Rob uses EDE as template engine. Any time you will create a new project with Rob, all the files of the template selected will be parsed rendered via EDE using the answers provided with the project.yml. For example the package.json in your nodejs template might be:

{
  "name": "{{name}}",
  {% if is_public %}
    "public": true,
  {% endif %}
  ...
}

Please check the EDE to see all the available expression. However if you have already used Liquid or Jinja it shouldn't be such a big deal

Add the template to rob

Once you have set up your new template you can link it to Rob via rob add template-name path/to/the/template Pay attention: the path to your template should be absolute! For example:

rob add simple-node-js `/Users/WhoAmI/Projects/rob-templates/nodejs`

The command above will store the template in a file called .rob in your home directory.

Create a new project

Run rob new from any folder on your machine and if you have Rob templates available, it will create your project running the questionnaire and copying the files of the template chosen in the current directory

Autoignore files

Rob will automatically parse any .gitignore recursively in your selected template folders to ignore specific files that you don't want to copy over when you create a new project

Todo

  • Unit test!
  • Improve performance
  • Improve the documentation
  • Write Documentation
  • Refactor the code and cleanup