The rob package

[ Tags: cli, library, mit, program ] [ Propose Tags ]

See README at https://github.com/GianlucaGuarini/rob/blob/develop/README.md


[Skip to Readme]

Properties

Versions 0.0.1, 0.0.2
Dependencies ansi-terminal (<=0.6.3.1), base (>=4.7 && <5), bytestring (<=0.10.8.1), cmdargs (>=0.10.17 && <=0.10.18), directory (<=1.3.0.0), ede (==0.2.8.7), filepath (<=1.4.1.2), fortytwo (<=1.0.2), Glob (<=0.9.1), pathwalk (<=0.3.1.2), rob, text (<=1.2.2.2), time (<=1.6.0.1), unordered-containers (<=0.2.8.0), vector (<=0.12.0.1), yaml (<=0.8.23.3) [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 repository head: git clone https://github.com/gianlucaguarini/rob
Uploaded Sun Nov 26 09:18:07 UTC 2017 by gianlucaguarini
Distributions NixOS:0.0.2
Executables rob
Downloads 109 total (109 in the last 30 days)
Rating (no votes yet) [estimated by rule of succession]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2017-11-26 [all 1 reports]
Hackage Matrix CI

Modules

[Index]

Downloads

Maintainer's Corner

For package maintainers and hackage trustees


Readme for rob-0.0.2

[back to package description]
<p align="center"> <img src="https://cdn.rawgit.com/GianlucaGuarini/rob/develop/rob-logo.svg" alt="rob logo"/> </p> <p align="center"> Simple projects generator written in Haskell </p>

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
  • [x] Write Documentation
  • [ ] Refactor the code and cleanup