Git Product home page Git Product logo

grunt-bower-install-simple's Introduction

grunt-bower-install-simple

Grunt Task for Installing Bower Dependencies

ATTENTION: Bower is deprecated and obsolete! Use this Grunt task only for legacy purposes, please!

Getting Started

This plugin requires Grunt ~0.4.0

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-bower-install-simple --save-dev

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

grunt.loadNpmTasks("grunt-bower-install-simple");

Task Options

  • color (default true): Whether output is colorized. The equivalent of bower --config.color=<value>.

  • cwd (default process.cwd()): The directory from which Bower should run. All relative paths in Bower will be calculated according to this. The equivalent of bower --config.cwd=`pwd` .

  • forceLatest (default false): Force latest dependency version on conflict. The equivalent of bower install --force-latest.

  • production (default false): Do not install project devDependencies. The equivalent of bower install --production.

  • interactive (default true): Makes Bower interactive, prompting whenever necessary. The equivalent of bower --config.interactive=true.

  • directory (default undefined): The path in which installed components should be saved. This defaults to bower_components. The equivalent of bower --config.directory=<dir>.

  • command (default install): Provide the bower command it should run. Setting this to update will run bower update instead of bower install.

Task Calling

Run this task with the grunt bower-install-simple command.

Task targets, files and options may be specified according to the Grunt Configuring tasks guide.

Usage Example

Assuming we have the following build environment:

  • Gruntfile.js:
// [...]
grunt.initConfig({
    "bower-install-simple": {
        options: {
            color: true,
            directory: "lib"
        },
        "prod": {
            options: {
                production: true
            }
        },
        "dev": {
            options: {
                production: false
            }
        }
    }
});
grunt.registerTask("bower-install", [ "bower-install-simple" ]);
// [...]
  • bower.json:
{
    "name": "sample",
    "version": "0.0.0",
    "devDependencies": {
        "componentjs":    "~1.2.7",
        "jquery":         "~2.1.4",
        "lodash":         "~3.10.1"
    }
}

Then running grunt bower-install is functionality-wise equivalent to running bower --config.color=false --config.directory=lib install --production. It will read the bower.json and install ComponentJS, jQuery and Lo-Dash into the local lib directory.

grunt-bower-install-simple's People

Contributors

dalelane avatar rse avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

grunt-bower-install-simple's Issues

update:true is not working.

Hello,

According to the documentation you can do an update instead of an install by setting the update options to true.
However this option doesn't work.

Workaround: set the command options.

option: {
command: "update"
}

1.0.3 doesn't respect directory in .bowerrc

This seems to have broken recently.

If I have a directory in my .bowerrc that's not bower_components this task doesn't respect that.

e.g. .bowerrc:

{
   "directory": "components"
}

I would expect grunt-bower-install to use that as the default and I wouldn't expect to have to specify directory in the task options (which I have to right now).

Not respecting cwd option

Hi,

I'm trying to use the cwd option, as my project has multiple bower.json files. However, it does not seem like this option is respected (I modified bower to output its options and I only see my own specified directory). It does work with the following patch. Is this a bug?

--- a/grunt-bower-install-simple.js 2014-07-28 13:36:50.091479137 +0200
+++ b/grunt-bower-install-simple.js 2014-07-28 13:36:47.151479103 +0200
@@ -67,7 +67,8 @@
             production:     options.production
         }, {
             interactive:    options.interactive,
-            directory:      options.directory
+            directory:      options.directory,
+            cwd:            options.cwd
         })
         .on("log", function (log) {
             renderer.log(log);

No "bower-install-simple" targets found

I put bower-install-simple in my package.json and already made a npm install.
My GruntFile.js looks like this:

grunt.registerTask('default', ['npm-install', 'bower-install-simple', 'sass', 'uncss']);

It gives me the following error:

>> No "bower-install-simple" targets found.
Warning: Task "bower-install-simple" failed. Use --force to continue.
Aborted due to warnings.

I just want to make a plain bower install. So the default parameters are fine, so I don't have to add any options for that.

Why it doesn't work?

Multi-Task

Great Grunt plugin, but would be nice if developers could configure multiple tasks with separate options.

Usecase: multiple directories that contain bower.json and .bowerrc files (Symfony2) and require bower install at each of those directories.

provided configuration does not work

Gruntfile.js

require('load-grunt-tasks')(grunt);

grunt.initConfig({
        "bower-install-simple": {
        options: {
            "dev": {
                options: {
                    production: false
                }
            }
        }
    }
})

grunt.loadNpmTasks('grunt-bower-install-simple');

grunt.registerTask('bower-install',['bower-install-simple']);

bower.json

{
    "name": "projectName",
    "version": "0.0.1",
    "devDependencies": {
        "component": "^0.0.1"
    }
}

After running grunt bower-install, it does absolutely nothing. I see nothing in the bower components folder

Unable to downgrade version even with update option set to true

I wanted to downgrade the jquery version after I had already deployed it but I am not able to do so. My bower.json looked like this:

"dependencies": { "jquery": ">=1.11.2" }

which caused it to fetch the ver 2.0 of jquery but after realizing my problem I changed it to:

"dependencies": {
"jquery": "~1.11.2"
}

and in my gruntfile.js I have bower set up like this:

"bower-install-simple": { options: { update: true }, dist: { options: { production: true } }, dev: { options: { production: false } } }

I assumed that when update is set to true, it will run bower update but I don't think it is doing so. If I run bower update in my local machine, it is updating the library version correctly to 1.11.2, but when I run it via grunt, it doesn't update the version of jquery to 1.11.2. Is there anything I can do to remedy my situation?

Thanks.

Default value for options.directory

It looks like in a recent update to bower passing options.directory = undefined as the argument for bower.commands.install causes an error inside of grunt, specifically it throws TypeError: Arguments to path.join must be strings, since it is trying to join that value, which is undefined.

I am not sure if this is intended behavior of grunt or not, but it caused some of my stuff to break. A simple fix to this would be to make the default for directory be 'bower_components', but I am not sure that is the best course of action.

Seems to ignore the directory option

Thank you for grunt-bower-install-simple.

It seems to ignore my directory option al always use bower's default bower_components.

Can you reproduce? Perhaps bower API has changed or this is a bug in bower?

Thanks.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.