rob: Simple projects generator

[ cli, library, mit, program ] [ Propose Tags ]
Versions [RSS] 0.0.1, 0.0.2, 0.0.3, 0.0.4, 0.0.5
Dependencies ansi-terminal (<=0.8.2), base (>=4.7 && <5), bytestring (<=0.10.8.2), cmdargs (>=0.10.17 && <=0.10.20), directory (<=1.3.3.2), ede (==0.2.9), filepath (<=1.4.2.1), fortytwo (<=1.0.5), Glob (<=0.10.0), pathwalk (<=0.3.1.2), rob, text (<=1.2.3.1), time (<=1.8.0.2), unordered-containers (<=0.2.9.0), vector (==0.12.0.2), yaml (<=0.11.0.0) [details]
License MIT
Copyright Gianlua Guarini
Author Gianluca Guarini
Maintainer gianluca.guarini@gmail.com
Category CLI
Home page https://github.com/gianlucaguarini/rob#readme
Source repo head: git clone https://github.com/gianlucaguarini/rob
Uploaded by gianlucaguarini at 2019-01-20T18:02:36Z
Distributions
Executables rob
Downloads 2164 total (12 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2019-01-20 [all 1 reports]

Readme for rob-0.0.4

[back to package description]

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