1.2.0 • Published 6 years ago

@cthru/jafar v1.2.0

Weekly downloads
2
License
ISC
Repository
-
Last release
6 years ago

Jafar

Easy folder-level templating

Jafar will prompt you for some values, then replace those values via handlebars in a duplicate folder. You could think of it as Yeoman-lite. It serves the purpose of providing skeleton projects based on template folders.

Installation

It is preferable to install this as a global utilty

npm install -g @chru/jafar

Usage

Jafar takes two arguments -- the source folder and the destination folder. It will look for .jafar.js configuration in the root of the source folder.

module.exports = {
    prompts : [
        { 
            type: 'input', 
            name: 'variable.name', 
            message: 'Please input the variable value',
            default: 'default value'
        }
    ]
}

This will produce an hashmap of values that gets replaced using handlebars in each file found in /src/**/* and copy the resultant file to /dest/**/*

Example Usage

// src/package.json
{
  "name": "{{package.name}}",
  "version": "{{package.version}}",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "rmdir": "^1.2.0"
  }
}
// src/.jafar.js
module.exports = {
    prompts : [
        { 
            type: 'input', 
            name: 'package.name', 
            message: 'What is your package name',
            default: 'default value'
        }
    ]
}

jafar src/ dest/

// dest/package.json
{
  "name": "{{package.name}}",
  "version": "{{package.version}}",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "rmdir": "^1.2.0"
  }
}