npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

nesto-grunt-generate-configs

v1.0.4

Published

CLI to generate separate grunt configuration files automatically

Downloads

7

Readme

grunt-generate-configs

npm version Build Status Dependency Status

CLI to generate separate grunt configuration files automatically

This command will take your big, fat grunt configuration object and automatically generate separate files to store the task configuration objects in. It's a one time operation to be done before you start using load-grunt-configs

Generates config files in following formats:

  • json (default)
  • js module
  • coffee module
  • cson
  • yaml

Getting Started

This plugin requires Grunt ~0.4.2

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-generate-configs -g

We install it globally, so you can reuse it for all your projects. Once the plugin has been installed, you can run it from the command line in the directory of your project:

generate_configs

The command will parse your grunt configuration object and automatically create files for each task.

Command line options

  • --target=<dir> you can specify the output directory using the target-flag. E.g.: grunt generate_configs --target=foo will create a foo directory instead of config.
  • --type=[js|json|coffee|cson|yaml|yml] allows you to output the configuration objects as json, yaml, cson, coffee or js files.
  • --json, --coffee, --cson, --js, --yaml and --yml as shorthand for type=<type>. The type flag will always override any shorthands.
  • --no-prompt allows you to skip the default prompt about overwriting and already existing directory.

Examples

For example, if this is your grunt configuration inside Gruntfile.js:

grunt.initConfig({
    jshint   : {
        all     : [
            'Gruntfile.js', 'tasks/*.js', '<%=nodeunit.tests%>'
        ],
        options : {
            jshintrc : '.jshintrc',
        },
    },

    // Before generating any new files, remove any previously-created files.
    clean    : {
        config : ['config'],
    },

    // Unit tests.
    nodeunit : {
        tests : ['tests/*_test.js'],
    },
});

It will create the files jshint.json, clean.json and nodeunit.json inside a config directory, containing the configuration objects:

//file: config/jshint.json
{
  "all": [
    "Gruntfile.js",
    "tasks/*.js",
    "<%=nodeunit.tests%>"
  ],
  "options": {
    "jshintrc": ".jshintrc"
  }
}
//file: config/clean.json
{
  "config": [
    "config"
  ]
}
//file: config/nodeunit.json
{
  "tests": [
    "tests/*_test.js"
  ]
}

Once these files are generated, use the load-grunt-configs module to automatically load all configuration files:

npm install load-grunt-configs --save-dev

and inside your Gruntfile.js replace the grunt configuration object with:

var configs = require('load-grunt-configs')(grunt);
grunt.initConfig(configs);

See the project for more information, options and examples: load-grunt-configs

Example output

Changelog

  • v0.6.1: Update dependencies
  • v0.6.0: Switch to safe cson
  • v0.5.2: Add --no-prompt flag
  • v0.5.1:
    • Use util.inspect for js generation
    • Add cson support
    • Fix incorrect testing
    • Update .travis.yml to test all branches
    • Remove support for node < v0.10
  • v0.5.0:
    • Update unit tests to include all flags
    • Expose main method for parsing of grunt config obj
    • Add js, coffee, yaml, json flags
    • Separate filegen to lib and add removal of config dir upon overwrite
  • v0.4.1: Makes the command global
  • v0.4.0: adds cli
  • v0.3.0:
    • Adds demos
    • Adds yaml support
    • Adds Coffeescript support
  • v0.2.0:
    • Test all possibilities, idiot!
    • fixes #2, incorrect ext for js files
  • v0.1.2: Fixes #1, moved inquirer from devDeps to deps
  • v0.1.1: keywords, keywords, keywords, sigh
  • v0.1.0:
    • Fixes CLI options examples
    • creates task grunt-generate-configs

License

Copyright (c) 2014 Camille Reynders Licensed under the MIT license.

Analytics