grunt-jquery-json

0.2.1 • Public • Published

grunt-jquery-json

Build Status

Grunt plugin that builds and validates a jquery.json package manifest, which is used by the jQuery Plugin Registry to identify jQuery plugins.

Requirements

  • Grunt ~0.3.17

Installation

In the same directory as your project's grunt.js file, install the package via npm:

npm install grunt-jquery-json

Then load the jquery-json task in your grunt.js file:

grunt.loadNpmTasks('grunt-jquery-json');

And, optionally, add it to the default task (or any other):

grunt.registerTask('default', '[...] jquery-json');

Getting Started

To start, make sure your grunt.js file has a pkg config object that has loaded package.json:

grunt.initConfig({
  pkg: '<json:package.json>',
  ...
});

This is a standard Grunt practice, and grunt-jquery-json uses this pkg config object to build your jquery.json.

Next, run the following grunt command in the same directory as your grunt.js file:

grunt jquery-json

If everything was successful, there should now be a yourplugin.jquery.json manifest file in that same directory, where yourplugin is the name of your jQuery plugin. All of the fields used by the jQuery Plugin Registry have been pulled in from your package.json.

To add or overwrite any fields specific to your jquery.json, simply add a jqueryjson object with the desired values to your Grunt config:

grunt.initConfig({
  ...
  jqueryjson: {
    dependencies: {
      jquery: '>=1.4.3'
    },
    docs: 'https://github.com/jstayton/jquery-plugin/blob/master/README.md',
    demo: 'http://jstayton.github.com/jquery-plugin'
  }
});

In addition to the jquery-json task, there is a validate-jquery-json task for validation only, as well as various helper methods.

Tasks

  • jquery-json

    Builds and validates a jquery.json package manifest file from package.json and jqueryjson config values.

  • validate-jquery-json

    Validates a jquery.json package manifest file in the directory where grunt.js resides.

Helpers

  • build-jquery-json

    Builds a package manifest using a combination of package.json and jqueryjson config values.

    Parameters:

    • pkg object package.json values.
    • config object, null jqueryjson config values.
    • stringify boolean Whether to JSON stringify.

    Returns: object or JSON encoded package manifest.

    Example:

    grunt.helper('build-jquery-json', grunt.config('pkg'), grunt.config('jqueryjson'));
    
  • build-jquery-json-file

    Builds and writes a package manifest to a jquery.json file using a combination of package.json and jqueryjson config values.

    Parameters:

    • pkg object package.json values.
    • config object, null jqueryjson config values.

    Returns: boolean of whether the file was written.

    Example:

    grunt.helper('build-jquery-json-file', grunt.config('pkg'), grunt.config('jqueryjson'));
    
  • validate-jquery-json

    Validates a package manifest.

    Parameters:

    • manifest JSON Package manifest to validate.
    • log boolean Whether to output the results to the console.

    Returns: true if valid, object if invalid, with each invalid field as a key and an array of errors as the value.

    Example:

    grunt.helper('validate-jquery-json', manifest, false);
    
  • validate-jquery-json-file

    Validates a jquery.json package manifest file.

    Parameters:

    • fileName string, null File name to read and validate, null to look in directory where grunt.js resides.
    • log boolean Whether to output the results to the console.

    Returns: true if valid, object if invalid, with each invalid field as a key and an array of errors as the value. false if no file or more than one was found.

    Example:

    grunt.helper('validate-jquery-json-file', 'yourplugin.jquery.json', false);
    

Feedback

Please open an issue to request a feature or submit a bug report. Or even if you just want to provide some feedback, I'd love to hear. I'm also available on Twitter as @jstayton.

Contributing

  1. Fork it.
  2. Create your feature branch (git checkout -b my-new-feature).
  3. Commit your changes (git commit -am 'Added some feature').
  4. Push to the branch (git push origin my-new-feature).
  5. Create a new Pull Request.

Readme

Keywords

none

Package Sidebar

Install

npm i grunt-jquery-json

Weekly Downloads

2

Version

0.2.1

License

none

Last publish

Collaborators

  • jstayton