0.0.2 • Published 4 years ago
scaffr v0.0.2
Scaffr
A simple code scaffolding tool to speed up repetitive coding tasks.
Installation
Install globally
npm install -g scaffrUse without installing
npx scaffr /path/to/template/folder /path/to/destinationUsage
# 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 ./HelloWorldCreating 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 ./HelloWorldwill result in:
| Source file | Destination 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:
| Variable | Description | 
|---|---|
| name | Folder name. Example: if destination path is /path/to/MyProject, name would be MyProject | 
| destPath | Destination full path | 
| templatePath | Template full path | 
| _ | Lodash library passed in for convenience | 
Example templates
A sample template can be found in the /examples folder.