0.0.2 • Published 2 years ago

scaffr v0.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

Scaffr

A simple code scaffolding tool to speed up repetitive coding tasks.

Installation

Install globally

npm install -g scaffr

Use without installing

npx scaffr /path/to/template/folder /path/to/destination

Usage

# Using templates from local machine
scaffr /path/to/template/folder /path/to/destination

# Or using zip files over HTTP
scaffr https://example.com/my-template.zip /path/to/destination

# Example:
# scaffr ~/templates/project-template ./HelloWorld

Creating a template

A template can have any number/kind of files. Scaffr will then interpret contents and file names when it encounters template syntax.

For example:

scaffr ~/templates/project-template ./HelloWorld

will result in:

Source fileDestination file
~/templates/project-template/{{name}}.js./HelloWorld/HelloWorld.js

The templating engine

Scaffr uses Lodash's _.template function to process templates. Variables use {{ and }} for interpolation.

Example:

// {{name}}.js
const hello = () => 'Hello, from {{name}}!';

export default hello;

will be compiled into:

// HelloWorld.js
const hello = () => 'Hello, from HelloWorld!';

export default hello;

For more informations on templating please refer to Lodash documentation.

Variables

The following list of variables is available for every file:

VariableDescription
nameFolder name. Example: if destination path is /path/to/MyProject, name would be MyProject
destPathDestination full path
templatePathTemplate full path
_Lodash library passed in for convenience

Example templates

A sample template can be found in the /examples folder.