guilder

builder for g's

guilder

A project builder for g's

$ npm install guilder

For the image resizing you need ImageMagick on your system

guilder is a toolkit for scaffolding and building projects using source template folders.

It has tools for the following jobs:

  • folder copy/initialization
  • image resizing
  • writing data to template pages (using ejs)
  • installing/building components

You use it as a library in custom build scripts:

var Guilder = require('guilder')
 
// where does the app template live 
var source = __dirname + '/gametemplate'
 
// where are we building the app 
var dest = __dirname + '/dist/test'
 
// create a project from the source template and the destination folder 
// everything from here becomes relative 
var project = Guilder(source, dest)
 
// handle logging 
project.on('log', function(st){
    console.log(st)
})
 
// run through build steps in series 
Guilder.series([
 
    function(next){
        // do something custom 
        next()
    },
 
    // install the component in the source folder with autoReset = true 
    project.installComponent(true),
 
    // install the component in the source folder with autoReset = true 
    project.buildComponent(true),
 
    // this will create the destination folder with autoRemove = true 
    project.ensureFolder(true),
 
    // copy files using globs 
    project.copy('css/**', function(path){
        // you can alter the copy path here 
        return path
    }),
 
    // resize images 
    project.resizeImages('img/*.png', '590x600', function(path){
        // you can alter the copy path here 
        return path
    }),
 
    // write data - this can be .html pages or any other text file 
    project.write('config.json', JSON.stringify({}))
 
], function(error){
    if(error){
        console.error(error)
        process.exit(1)
    }
    else{
        process.exit()  
    }
})

Create a new project from a source template

Proxy to async.parallel

Proxy to async.series

Static version of copy where you can pass the source and destination folders explicitly

Ensure the destination folder exists - autoRemove will delete if it exists

Install the component in the source folder - autoReset will remove the components folder before component install

Build the component in the source folder - autoReset will remove the build folder before component build

Copy each file matching the srcGlob into the dest folder

processPath is a map function that lets you change the target location of each file

The same as copy but you get to specific the source and destination folders

Resize images matching the glob into the destination location

Size is an object with width and height properties or a string of the format [width]x[height]

processPath is an optional function that can remap the destination path for the image

project.resizeImages('img/**', '100x100', function(path){
    if(path.match(/car/)){
        return 'otherfolder/car.jpg'
    }
    else{
        return path
    }
})

Write a 'utf8' encoded text file to the file at dest/[path]

This is useful for writing templates and other data

Render an ejs template loaded from src (in the source folder) and using data, then write the output to target (in the destination folder)

The logs are emitted to be handled in a custom way

MIT