gs

grunt-smoothie

Create template based Class files for your javascript projects. Then make yourself a smoothie.

Showing:

Popularity

Downloads/wk

23

GitHub Stars

1

Maintenance

Last Commit

6yrs ago

Contributors

1

Package

Dependencies

3

License

Type Definitions

Tree-Shakeable

No?

Categories

Readme

npm version Build Status

Delicious Smoothies

grunt-smoothie

Auto generate modules and tests for your javascript projects. A Template metaprogramming framework for javascript.

Features

  • Auto generate javascript module js file and a Mocha Test js file for the module.
  • Define your own custom templates (docs required)
  • Inquirer prompt for module name
  • Inquirer prompt for package name
  • Predefined module template for Browserify Custom Type Modules - based on the node-way https://github.com/FredKSchott/the-node-way
  • JSDoc meta data added automatically (YUIDoc friendly format)

Getting Started

This plugin requires Grunt ~0.4.1

If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:

npm install grunt-smoothie --save-dev

Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:

grunt.loadNpmTasks('grunt-smoothie');

Usage

Run the task then follow the instructions.

grunt smoothie

Templates:

  • Using packaged templates (aka flavours)

    Define path to the template which by default are inside './node_modules/grunt-smoothie/tasks/flavours/node/specs/classModule.js' If you define a specTemplate, a Spec file (or Test Suite file for your module) is also created.

  • Adding Custom Templates

    See making templates at https://github.com/hayesmaker/grunt-smoothie/tree/master/tasks/flavours/

Options

options.prompt

Type: Boolean Default value: true

When set to true the user is given a prompt to enter their module name, and packageName if packageMap option is present. Should be set to false, when testing tasks.

options.src

Type: String Default value: 'app/src'

The default directory you would like new files to be added to

options.test

Type: String Default value: 'app/test'

The default directory you would like new files to be added to

options.moduleTemplate

Type: String Example value: './node_modules/grunt-smoothie/tasks/flavours/node/specs/classModule.js'

The path to the moduleTemplate, you can use this template, or create your own

options.specTemplate

Type: String Example value: './node_modules/grunt-smoothie/tasks/flavours/node/specs/classModuleSpec.js' Default value: None

The path to the specTemplate, you can use this template, or create your own

options.packageMap

Type: 'Array', Default value: Empty Array

If you'd like to support packages in your app, (currently only 1 level of packages inside your app are supported) Then provide a packageMap. When running the smoothie task, you can choose a package from this list or the 'Top Level'. See Example 3 below.

Usage Examples

Example 1:

Your project code has source js files inside app/src

smoothie: {
    default_task: {
        options: {
            src: "app/src/",
            moduleTemplate: './node_modules/grunt-smoothie/tasks/flavours/node/specs/classModule.js'
        }
    }
}

Example 2:

Your project code has source js files inside app/src/ Your project tests are inside app/test/ and you'd like a test (mocha / jasmine style) generated based on templateDir/classModuleSpec.js

smoothie: {
    default_task: {
        options: {
           src: "app/src/",
           test: "app/test/",
           moduleTemplate: './node_modules/grunt-smoothie/tasks/flavours/node/specs/classModule.js',
           specTemplate: './node_modules/grunt-smoothie/tasks/flavours/node/specs/classModuleSpec.js',
        }
    }
}

Example 3:

Your project code has source js files inside app/src/ and packages(folders): core, components, states and utils.

smoothie: {
    default_task: {
        options: {
            src: "app/src/",
            test: "app/test/",
            moduleTemplate: './node_modules/grunt-smoothie/tasks/flavours/node/specs/classModule.js',
            specTemplate: './node_modules/grunt-smoothie/tasks/flavours/node/specs/classModuleSpec.js',
            packageMap: [
                {
                    name: 'Top Level',
                    value: ''
                },
                'core',
                'components',
                'states',
                'utils'
            ]
        }
    }
}

grunt-smoothie

Contributing

Release History

v1.3.0

  • Simplified template generation
  • Only Custom paths supported now
  • Package links respected in Spec require.

v1.2.0

  • Packages supported

v1.1.0

  • custom template paths supported

v1.0.0

  • initial project inception
  • creates "Class" style node modules

#todos

  • Provide more custom templates for common module patterns in js
  • Provide some ES6 templates
  • Find a better way to reference packaged flavours

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100