Giter Site home page Giter Site logo

main-bower-files's Introduction

main-bower-files

status

Usage

var mainBowerFiles = require('main-bower-files');
var files = mainBowerFiles([[filter, ]options][, callback]);

If first argument is type of String, Array or RegExp it will be used as a filter, otherwise it will be used as options.

This will read your bower.json, iterate through your dependencies and returns an array of files defined in the main property of the packages bower.json.

You can override the behavior if you add an overrides property to your own bower.json.

Usage with gulp

var gulp = require('gulp');
var mainBowerFiles = require('main-bower-files');

gulp.task('TASKNAME', function() {
    return gulp.src(mainBowerFiles())
        .pipe(/* what you want to do with the files */)
});

You've got a flat folder/file structure after .pipe(gulp.dest('my/dest/path'))?

mainBowerFiles returns an array of files where each file is a absolute path without any globs (** or *). gulp requires globs in these paths to apply the base path. Because of this, you always have to tell gulp your bower base path (the path to the bower_components directory) explicitly.

Here is an example:

var gulp = require('gulp');
var mainBowerFiles = require('main-bower-files');

gulp.task('TASKNAME', function() {
    return gulp.src(mainBowerFiles(/* options */), { base: 'path/to/bower_components' })
        .pipe(/* what you want to do with the files */)
});

Now you should get something like my/dest/path/jquery/jquery.js if you have jquery installed.

Usage with grunt

Install this plugin with the following command:

npm install --save-dev main-bower-files

Once that's done, add this line to your project's Gruntfile:

grunt.loadNpmTasks('main-bower-files');

In your project's Gruntfile, add a section named bower to the data object passed into grunt.initConfig(), like so:

grunt.initConfig({
    bower: {
        dev: {
            base: 'bower_components', /* the path to the bower_components directory */
            dest: 'web/bower_components',
            options: {
                checkExistence: true,
                debugging: true,
                paths: {
                    bowerDirectory: 'bower_components',
                    bowerrc: '.bowerrc',
                    bowerJson: 'bower.json'
                }
            }
        },
        flat: { /* flat folder/file structure */
            dest: 'public/vendor',
            options: {
                debugging: true
            }
        }
    }
});

Options

Overrides Options

These options can be set directly in your bower.json file, e.g.:

{
    "name": "your-package-name",
    "dependencies": {
        "BOWER-PACKAGE": "*"
    },
    "overrides": {
        "BOWER-PACKAGE": {
            // Here you can override the main files or ignoring this package, for more info see options
        }
    }
}

main

Type: String or Array or Object

You can specify which files should be selected. You can main-bower-files select files based on the process.env.NODE_ENV if you provide an Object with keys as the environment, e.g.:

{
    "overrides": {
        "BOWER-PACKAGE": {
            "main": {
                "development": "file.js",
                "production": "file.min.js"
            }
        }
    }
}

You can also use glob pattern to select files, e.g.:

{
    "overrides": {
        "BOWER-PACKAGE": {
            "main": "**/*.js"
        }
    }
}

ignore

Type: Boolean Default: false

Set to true if you want to ignore this package.

dependencies

Type: Object

You can override the dependencies of a package. Set to null to ignore the dependencies.

Common Options

These options can be passed to this plugin, e.g: mainBowerFiles(/* options*/)

debugging

Type: boolean Default: false

Set to true to enable debugging output.

main

Type: String or Array or Object Default: null

You can specify for all packages a default main property which will be used if the package does not provide a main property.

env

Type: String Default: process.env.NODE_ENV

If process.env.NODE_ENV is not set you can use this option.

paths

Type: Object or String

You can specify the paths where the following bower specific files are located:

bower_components, .bowerrc and bower.json

For example:

mainBowerFiles({
    paths: {
        bowerDirectory: 'path/for/bower_components',
        bowerrc: 'path/for/.bowerrc',
        bowerJson: 'path/for/bower.json'
    }
})
.pipe(gulp.dest('client/src/lib'));

If a String is supplied instead, it will become the basepath for default paths.

For example:

mainBowerFiles({ paths: 'path/for/project' });
/*
    {
        bowerDirectory: 'path/for/project/bower_components',
        bowerrc: 'path/for/project/.bowerrc',
        bowerJson: 'path/for/project/bower.json'
    }
*/

checkExistence

Type: boolean Default: false

Set this to true if you want that the plugin checks every file for existence.

If enabled and a file does not exists, the plugin will throw an exception.

includeDev

Type: mixed Default: false

You can include your devDependencies in two ways:

  • Set this option to inclusive or true to add the devDependencies to your dependencies
  • or use exclusive to exclude your dependencies

includeSelf

Type: boolean Default: false

Set this to true to add the main files to your dependencies

filter

Type: RegExp or function or glob Default: null

You can filter the list of files by a regular expression, glob or callback function (the first and only argument is the file path).

overrides

Type: object Default: {}

Set default overrides option which can be overridden in the overrides section of the bower.json

group

Type: String or Array Default: null

You can specify a group of dependencies you want to read from bower.json

For example:

{
    "dependencies": {
        "BOWER-PACKAGE-1": "*",
        "BOWER-PACKAGE-2": "*",
        "BOWER-PACKAGE-3": "*",
        "BOWER-PACKAGE-4": "*"
    },
    "group": {
        "home": [ "BOWER-PACKAGE-1" ],
        "contact": [ "BOWER-PACKAGE-4" ],
        "admin": [ "BOWER-PACKAGE-1", "BOWER-PACKAGE-2", "BOWER-PACKAGE-3" ]
    }
}
mainBowerFiles({ paths: 'path/for/project', group: 'home' });

You can select multiple groups with an array.

mainBowerFiles({ paths: 'path/for/project', group: ['home', 'contact'] });

You can include all packages except for those listed in a group with the ! operator.

mainBowerFiles({ paths: 'path/for/project', group: '!home' });

LICENSE

(MIT License)

Copyright (c) 2013 Christopher Knötschke [email protected]

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

main-bower-files's People

Contributors

bunyk avatar cheton avatar ck86 avatar codeorganic avatar ficik avatar gkoychev avatar jetpackjarrett avatar kaishuu0123 avatar martynovs avatar mef79 avatar pwang6417 avatar red2678 avatar shinnn avatar trysound avatar vially 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  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  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  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

main-bower-files's Issues

What about the order of the packages?

The order is really important if I am including files like the following

  • angular.js
  • ui-bootstrap-tpls.js

I would like to make sure angular is in the list before ui bootstrap. Is there a way I can do that?

Thanks.

Custom destination path for each vendor package

Pardon my ignorance here. Does this plugin support custom destination files? I know I can override the main and have custom Main package files like:
"overrides": {
"jquery": {
"main": "/dist/jquery."
}
}
This gives me 3 main files all nested under "dist" directory. I want to achieve something similar to "bower-installer" npm module wherein not only I can customize the main files from source package but also destination folder hierarchy. So in this example I can extract all files (3 in this example) under "js" sub-directory instead of "dist".

preserve bower directories

gulp-bower-files would preserve the directory structure. This was useful for css files that reference images. Can there be an option to achieve this?

Invalid glob argument

When I add main-bower-files to my gulpfile, using your example:


gulp.task('bower', function() {
    return gulp.src(mainBowerFiles())
        .pipe(gulp.dest('lib'));
});

I am getting an "invalid glob argument".

Here's what it looks like.

Error: Invalid glob argument
    at Gulp.src (/Users/bryce/repo/jf/client/node_modules/gulp/node_modules/vinyl-fs/lib/src/index.js:17:11)
    at Gulp.<anonymous> (/Users/bryce/repo/jf/client/gulpfile.js:31:17)
    at module.exports (/Users/bryce/repo/jf/client/node_modules/gulp/node_modules/orchestrator/lib/runTask.js:33:7)
    at Gulp.Orchestrator._runTask (/Users/bryce/repo/jf/client/node_modules/gulp/node_modules/orchestrator/index.js:273:3)
    at Gulp.Orchestrator._runStep (/Users/bryce/repo/jf/client/node_modules/gulp/node_modules/orchestrator/index.js:214:10)
    at Gulp.Orchestrator.start (/Users/bryce/repo/jf/client/node_modules/gulp/node_modules/orchestrator/index.js:134:8)
    at /usr/local/lib/node_modules/gulp/bin/gulp.js:121:20
    at process._tickCallback (node.js:415:13)
    at Function.Module.runMain (module.js:499:11)
    at startup (node.js:119:16)

Any idea what's going on?

[feature] file name transform for override

some packages could share the same filename (index.js)

would be cool if i could set the desired filename in bower.json overrides section, like

{
  "overrides" : {
    "library" : {
      "main" : {
        "lib/index.js" : "more-meaningful-name.js"
      }
    }
  }
}

SyntaxError: unexpected string

I'm having a dependency entry like "some-name": "ssh://[email protected]:443/user/reponame.git#~2.3.1-1234"

in bower.json. With it, it fails with SyntaxError: unexpected string, without all goes fine.
The line is a valid entry.

Full msg:

SyntaxError: Unexpected string
  at Object.parse (native)
  at Object.PackageCollection.collectPackages (/app/node_modules/main-bower-files/lib/package_collection.js:72:30)
  at Object.PackageCollection (/app/node_modules/main-bower-files/lib/package_collection.js:29:10)
  at module.exports (/app/node_modules/main-bower-files/lib/index.js:60:22)
  at Object.<anonymous> (/app/test.coffee:2:9)
  at Object.<anonymous> (/app/test.coffee:1:1)
  at Module._compile (module.js:456:26)

Full (coffee) code to test it:

mainBowerFiles = require 'main-bower-files'
files = mainBowerFiles()
util = require 'util'

console.log util.inspect files

crashing even before any debug output!

I used main-bower-files just fine in a previous angular project.. and now i was trying to use ionic.. so i started off using this start-up skeleton. Initially they saved all the bower components into the ./www/lib directory.. so i changed the contents of .bowerrc to

{
  "directory": "bower_components"
}

instead.. and so after running bower install all the bower folders got installed in the ./bower_components directory

for reference this is the contents of my bower.json file:

{
  "name": "HelloIonic",
  "private": "true",
  "devDependencies": {
    "ionic": "driftyco/ionic-bower#1.0.0-beta.10",
    "jquery": "~1.10.x",
    "angular": "1.2.18",
    "angular-sanitize": "1.2.5",
    "angular-route": "1.2.5",
    "angular-cookies": "1.2.5",
    "angular-resource": "1.2.5",
    "restangular": "1.4.0",
    "angular-animate": "~1.2.x",
    "angular-ui-slider": "~0.0.2",
    "angular-google-maps": "https://github.com/nlaplante/angular-google-maps/archive/1832e420bd60d6f42c860f44ae40ccaf6e66aec8.zip",
    "angular-easyfb": "~1.1.0",
    "bootstrap-multiselect": "~0.9.x"
  },
  "resolutions": {
    "angular-sanitize": "1.2.5",
    "angular": "1.2.18",
    "jquery": "~1.10.x"
  }
}

I got this in my gulpfile.coffee

gulp.task 'bower_js', (done) ->
  gulp.src(mainBowerFiles({debugging: true}), {base: './bower_components'})

but then I get this error when running gulp bower_js:

[18:52:42] Using gulpfile ~/dev/js/beit_ionic/gulpfile.js
[18:52:42] Starting 'bower_js'...
[18:52:42] 'bower_js' errored after 1.12 ms
[18:52:42] Error: Invalid glob argument: 
  at Gulp.src (~/dev/js/beit_ionic/node_modules/gulp/node_modules/vinyl-fs/lib/src/index.js:19:11)
  at Gulp.gulp.task.gulp.src.pipe.$.ngClassify.appName (/Users/abdullah/dev/js/beit_ionic/gulpfile.coffee:46:8)
  at module.exports (/Users/abdullah/dev/js/beit_ionic/node_modules/gulp/node_modules/orchestrator/lib/runTask.js:34:7)
  at Gulp.Orchestrator._runTask (/Users/abdullah/dev/js/beit_ionic/node_modules/gulp/node_modules/orchestrator/index.js:273:3)
  at Gulp.Orchestrator._runStep (/Users/abdullah/dev/js/beit_ionic/node_modules/gulp/node_modules/orchestrator/index.js:214:10)
  at Gulp.Orchestrator.start (/Users/abdullah/dev/js/beit_ionic/node_modules/gulp/node_modules/orchestrator/index.js:134:8)
  at /usr/local/lib/node_modules/gulp/bin/gulp.js:121:20
  at process._tickCallback (node.js:415:13)
  at Function.Module.runMain (module.js:499:11)
  at startup (node.js:119:16)
  at node.js:902:3

the thing is i don't even get any debugging output before it crashes although i put the debbuging:true flag.. any ideas why?

Making 'main' configurable to pull out stylesheets, etc.

Thank you for writing this! Along with gulp-order, this is a very useful addition to my gulp setup.

Are there any plans to make 'main' configurable? It would be nice to be able to use this package to pull out stylesheets from installed packages.

If not, I'd be happy to write a PR when I get a free moment.

-R

Throws an error when reading folder name with a dot

Happens to me when trying to use bower package ngAnimate-animate.css which creates folder bower_components/animate.css

stream.js:94
      throw er; // Unhandled stream error in pipe.
            ^
Error: EISDIR, open '/Users/oclement/Documents/phoenix/MedifastCerBrokenDown/MedifastWeb/build/WebContent/bower_components/animate.css'

change output path with gulp

I have a gulp task:

gulp.task('bower-install', function(){
  gulp.src('./public/index.html')
    .pipe(inject(gulp.src(bowerFiles(), {read: false}), {name: 'bower'}))
    .pipe(gulp.dest('./public/'))
})

where the folders are located in public/bower_components/ My issue is that when this gulp task injects the scripts it outputs /public/bower_components/angular-resource/angular-resource.js where I'd like it to be bower_components/... (no /public/ in the output)

Is there an option where I can change what the string paths look like?

Override functionality is not working

I added the overrides property to my bower.json, but instead of overriding, it is ignoring the package entirely in the output.

{
  "overrides": {
    "kendo-ui-core": {
      "main": {
        "production": "src/js/kendo.ui.core.min.js"
        "development": "src/js/kendo.ui.core.min.js"
      }
    }
  }
}


PackageCollection add            kendo-ui-core d:\Projects\frontend\app\bower_components\kendo-ui-core
Package          overriding depedependencies     kendo-ui-core undefined

Even copy/pasting the main field from kendo-ui-core's .bower.json file gives me the same result.

Also--is "overriding depdependencies" a typo? :)

Thanks

Add packages' own dependencies to the returned stream

Some packages depends on other libraries as well; These packages are also copied to bower_components folder but when using main-bower-files in conjunction with gulp-inject, we have no holds of these extra libs

For instance, doing bower install angular-gridster --save will install the package mentioned, as well as jquery-ui and some other libs in the bower_components folder.

main-bower-files doesn't take jquery-ui into account in that scenario

Error: Invalid glob argument

I keep getting the following error

C:\Program Files\WAMP\www\gulp-starter>gulp bower
[11:36:55] Using gulpfile C:\Program Files\WAMP\www\gulp-starter\gulpfile.js
[11:36:55] Starting 'bower'...
[11:36:55] 'bower' errored after 1.65 ms
[11:36:55] Error: Invalid glob argument
    at Gulp.src (C:\Users\com265\AppData\Roaming\npm\node_modules\gulp\node_modu
les\vinyl-fs\lib\src\index.js:17:11)
    at Gulp.gulp.task.gulp.src.read (C:\Program Files\WAMP\www\gulp-starter\gulp
file.js:192:17)
    at module.exports (C:\Users\com265\AppData\Roaming\npm\node_modules\gulp\nod
e_modules\orchestrator\lib\runTask.js:33:7)
    at Gulp.Orchestrator._runTask (C:\Users\com265\AppData\Roaming\npm\node_modu
les\gulp\node_modules\orchestrator\index.js:273:3)
    at Gulp.Orchestrator._runStep (C:\Users\com265\AppData\Roaming\npm\node_modu
les\gulp\node_modules\orchestrator\index.js:214:10)
    at Gulp.Orchestrator.start (C:\Users\com265\AppData\Roaming\npm\node_modules
\gulp\node_modules\orchestrator\index.js:134:8)
    at C:\Users\com265\AppData\Roaming\npm\node_modules\gulp\bin\gulp.js:126:20
    at process._tickCallback (node.js:419:13)
    at Function.Module.runMain (module.js:499:11)
    at startup (node.js:119:16)

When I try and run gulp bower

var gulp = require('gulp'),
    mainBowerFiles = require('main-bower-files');

gulp.task('bower', function(){
    return gulp.src(mainBowerFiles())
        .pipe(gulp.dest('app/scripts'))
    ;
});

With the following folder structure

/app
    /scripts
/bower_components
bower.json
gulpfile.js

What am I doing wrong? I've also tried adding {base: 'bower_components'} but the same error occurs.

SyntaxError: Unexpected string

Both of these tasks:

gulp.task('mainbower-test', function(){
    gulp.log(mainBower());
});

gulp.task('js-lib', function(){
    return gulp.src(mainBower(), {main: 'src/bower_components/'})
        .pipe(plumber({errorHandler: onError}))
        .pipe(filter('*.js'))
        .pipe(concat('main.js'))
        .pipe(uglify())
        .pipe(gulp.dest(paths.js.dest))
});

throw this error:

SyntaxError: Unexpected string
at Object.parse (native)
at Object.PackageCollection.collectPackages (/Users/mhallinan/Sites/gulp-test/node_modules/main-bower-files/lib/package_collection.js:72:30)
at Object.PackageCollection (/Users/mhallinan/Sites/gulp-test/node_modules/main-bower-files/lib/package_collection.js:29:10)
at module.exports (/Users/mhallinan/Sites/gulp-test/node_modules/main-bower-files/lib/index.js:60:22)
at Gulp.gulp.task.gulp.src.main (/Users/mhallinan/Sites/gulp-test/gulpfile.js:60:14)
at module.exports (/Users/mhallinan/Sites/gulp-test/node_modules/gulp/node_modules/orchestrator/lib/runTask.js:34:7)
at Gulp.Orchestrator._runTask (/Users/mhallinan/Sites/gulp-test/node_modules/gulp/node_modules/orchestrator/index.js:273:3)
at Gulp.Orchestrator._runStep (/Users/mhallinan/Sites/gulp-test/node_modules/gulp/node_modules/orchestrator/index.js:214:10)
at Gulp.Orchestrator.start (/Users/mhallinan/Sites/gulp-test/node_modules/gulp/node_modules/orchestrator/index.js:134:8)
at /usr/local/lib/node_modules/gulp/bin/gulp.js:129:20

[bug] script fails if .bowerrc exists and doesn't define "directory"

as in description, if .bowerrc file exists and doesn't have "directory" defined, script will fail with:

TypeError: Arguments to path.join must be strings
    at path.js:360:15
    at Array.filter (native)
    at Object.exports.join (path.js:358:36)
    at module.exports (node_modules/main-bower-files/lib/index.js:33:42)

source:

        opts.paths.bowerDirectory = path.join(opts.paths.bowerDirectory, "/", (JSON.parse(fs.readFileSync(opts.paths.bowerrc))).directory);

Please explain how to switch from gulp-bower-files

I was using the gulp-bower-files package and kept getting the message that it was deprecated and I should be using this package instead. Unfortunately it doesn't seem to just be a simple replacement of the 2. Can you please add some details to the README that explains how to switch from gulp-bower-files to main-bower-files?

Here is a task I'm using with the gulp-bower-files:

gulp.task('fonts', function () {
    var streamqueue = require('streamqueue');
    return streamqueue({objectMode: true},
        $.bowerFiles(),
        gulp.src(['app/fonts/**/*', 'bower_components/foundation-icon-fonts/**/*'])
    )
        .pipe($.filter('**/*.{eot,svg,ttf,woff}'))
        .pipe($.flatten())
        .pipe(gulp.dest('dist/fonts'))
        .pipe($.size());
});

Error when attempting to set a basepath

When invoking with a basepath

mainBowerFiles({ paths: 'path/for/project' });

an error is thrown:

Error: bower.json file does not exist at undefined

Maybe an older version of Node allowed you to set properties to strings, but it doesn't seem to be allowed in v0.10.28.

Filter not filtering

Or I'm doing something wrong?

gulp.task('bowerStyles', function() {
    gulp.src(mainBowerFiles({
        filter: /\.js$/i,
        debugging: true
    }))
    .pipe(gulp.dest(paths.styles.libs))
});

This gives me all the files, .js and .css.

Added Angular-Cookies but main-bower-files will not move it

The dependency was added to the bower.json file and I also added the Override as follows 👍
But even after restarting my computer main-bower-files will not copy out to my destination. I even deleted my entire dest. folder and it replaced every other folder in my overides except angular-cookies. I have verified spelling and format with no resolution.
"overrides": {
"angular-cookies": {
"main": [
"./angular-cookies.js",
"./angular-cookies.min.js"
]
}
}

Add whitelist and blacklist to select specific packages

I have to separate my bower dependencies in a couple of files, so it would be nice if I could have something like this:

var bower  = require('main-bower-files');
gulp.task('lib1', function() {
    return gulp.src(bower({whitelist: ['angular','jquery']}))
            .pipe(concat('lib1.js'))
            // ...
});

gulp.task('lib2', function() {
    return gulp.src(bower({whitelist: ['pack1','pack2']}))
            .pipe(concat('lib2.js'))
            // ...
});

gulp.task('the-rest', function() {
    return gulp.src(bower({blacklist: ['angular','jquery','pack1','pack2']}))
            .pipe(concat('the-rest.js'))
            // ...
});

Get files with structure saving

Bower components directory has structure like this:

- bootstrap
-- dist
-- fonts
-- ...
- jquery
-- dist
-- src

How I can get files with saving structure folder like this:

vendors
- bootstrap
-- somefile.less
- jquery
-- jquery.js 

Now I configure all but I get this:

vendors
- somefile.less
- jquery.js 

Error handling checkExistence

Is there anyway we can add error handling to the checkExistence option to provide a more useful message on what command to run if the file doesn't exist?

Doesn't locate angular-bootstrap-ui

I've been trying to get main-bower-files working with angular-ui-bootstrap and for some reason it seems to completely ignore that directory.

My task is similar to this

var bowerFiles = require('main-bower-files')

var files = bowerFiles() # called inside of a gulp task
console.log(files)

My bower file looks like this:

{
  "name": "package",
  "version": "0.0.0",
  "dependencies": {
    "json3": "~3.3.1",
    "es5-shim": "~3.1.0",
    "lodash": "~2.4.1",
    "angular": "1.2.x",
    "angular-animate": "1.2.x",
    "angular-ui-bootstrap": "0.11.x",
    "angular-cookies": "1.2.x",
    "angular-ui-router": "0.2.x",
    "angular-classy": "~0.4.2"
  }
}

And My output from the console.log is similar to this:

[ 'json3/lib/json3.js',
  'es5-shim/es5-shim.js',
  'lodash/dist/lodash.compat.js',
  'angular/angular.js',
  'angular-animate/angular-animate.js',
  'angular-cookies/angular-cookies.js',
  'angular-ui-router/release/angular-ui-router.js',
  'angular-classy/angular-classy.js' ]

I've run it through debugging mode and gotten the following output
PackageCollection add angular-ui-bootstrap
But it never selects files from that directory.

Incorrect path replacing in files structure with subfolder

Basically main-bower-files works just fine! Thank you guys!

But I've met a buggy situation. Lets say we have installed fontawesome bower component. Apart from CSS-files we have also font-files there that was copied, and it's good. But they were located in separate folder then CSS.

So, in resulting CSS-file we have removed bower_components, that's good, and mentioned files are also located there, but reference in CSS-file is still:

src: url('../fonts/fontawesome-webfont.eot?v=4.2.0');

Distinguish between dependencies and devdependencies

Is there a way I can specify it to work on DEV only dependencies as specified in bower.json file?

Also, another one is the "paths" option throwing errors. I have a simple task:

gulp.task('main-bower-files', function () {
return gulp.src(mainBowerFiles({
paths: {
bowerDirectory: './bower_components', bowerrc: '.bowerrc', bowerJson: './bower-local/bower.json'
}
}))
.pipe(gulp.dest('./lib/'))
});
I have bower.json under bower-local folder instead of root.

Invalid Glob Argument when using Node Env Variable

I've setup my overrides object in bower.json as follows:

"overrides": {
      "angular-resource": {
        "dependencies": null,
        "main": {
          "dev": "angular-resource.js",

          "prod": "angular-resource.min.js",

          "test": "angular-resource.min.js"
        }
      },

      "ionic": {
        "dependencies": null,
        "main": {
          "dev": [
            "release/js/ionic.bundle.js",
            "release/fonts/*"
          ],

          "prod": [
            "release/js/ionic.bundle.min.js",
            "release/fonts/*"
          ],

          "test": [
            "release/js/ionic.bundle.min.js",
            "release/fonts/*"
          ]
        }
      }
    },

And receive this error:

"overrides": {
      "angular-resource": {
        "dependencies": null,
        "main": {
          "dev": "angular-resource.js",

          "prod": "angular-resource.min.js",

          "test": "angular-resource.min.js"
        }
      },

      "ionic": {
        "dependencies": null,
        "main": {
          "dev": [
            "release/js/ionic.bundle.js",
            "release/fonts/*"
          ],

          "prod": [
            "release/js/ionic.bundle.min.js",
            "release/fonts/*"
          ],

          "test": [
            "release/js/ionic.bundle.min.js",
            "release/fonts/*"
          ]
        }
      }
    },

If i simplify things, and just use main without the env properties (dev, prod, test) everything works fine.

"overrides": {
      "angular-resource": {
        "dependencies": null,
        "main": "angular-resource.js"
      },

      "ionic": {
        "dependencies": null,
        "main": [
            "release/js/ionic.bundle.js",
            "release/fonts/*"
          ]
      }
    },

Filename collision issue

Hi @ck86 ,

I'm trying to solve this issue:
I need all less files from the bootstrap library to be selected (and then saved) so I used this override in my bower.json file:
"overrides": {
"bootstrap": {
"main": "*/.less"
}
}
The issue I have is that there are couples of files with the same name (like alert.less) situated in different folders.
Now I could probably use some filter and deal with the folders, but I don't want to be specific this way and expect particular folder structure in my gulpfile.
It would be far better if I could set destination folder structure somehow in the override section of my bower.json.

Any thoughts?

includeSelf option

How about includeSelf option?

Like includeDev option, sometimes I want to include the main file of current project.

If you prefer that, I can create a PR :)

string paths doesn't work

You can create attributes on string object:

if (typeof opts.paths === 'string'){
  opts.paths.bowerJson        = path.join(opts.paths, defaults.paths.bowerJson);
  opts.paths // => undefined;
}

Breaking change between 1.0.3 and 1.0.4

Prior to 1.0.4 when invoking main-bower-files with default options the paths returned were relative to the current working direction. Now with 1.0.4 the paths returned are instead absolute. I'm not sure if this is by design, or due to a bug, but I wouldn't expect such changes from a bump of just the semver patch version. This broke our build process.

SourceMaps support

Can't get gulp-sourcemaps to work with this.
Something is wrong with the paths/globs ... don't know gulp enough to figure it out myself.

Here is a task using mainBowerFiles and sourcemaps:

var gulp = require('gulp');
var mainBowerFiles = require('main-bower-files');
var concat = require('gulp-concat');
var sourcemaps = require( 'gulp-sourcemaps' );
var jsFilter = gulpFilter( '*.js' );

gulp.task( 'bower_js_dev', [ 'bower_install' ], function() {
    var scripts = mainBowerFiles();
    scripts.push( 'src/main.js' ); // Add local script
    return gulp.src( scripts )
        .pipe( jsFilter )
        .pipe( sourcemaps.init( { loadMaps: true } ) )
          .pipe( concat( 'scripts.js' ) )
        .pipe( sourcemaps.write( './', { includeContent: true } ) )
        .pipe( gulp.dest( 'public/js' ) );
} );

I get the following output during the build:

gulp-sourcemap-write: source file not found:/home/paul/src/bulb/bower_components/jquery/dist/angular.js
gulp-sourcemap-write: source file not found:/home/paul/src/bulb/bower_components/jquery/dist/angular-route.js
gulp-sourcemap-write: source file not found:/home/paul/src/bulb/bower_components/jquery/dist/angular-sanitize.js
gulp-sourcemap-write: source file not found:/home/paul/src/bulb/bower_components/jquery/dist/angular-resource.js
gulp-sourcemap-write: source file not found:/home/paul/src/bulb/bower_components/jquery/dist/jsoneditor.js
gulp-sourcemap-write: source file not found:/home/paul/src/bulb/bower_components/jquery/dist/bootstrap.js
gulp-sourcemap-write: source file not found:/home/paul/src/bulb/bower_components/jquery/dist/main.js

The resulting sourcemap is obviously wrong.

Tell me if you need more data.

Cheers

How to combine main-bower-files with app source files?

I can't seem to figure out how to get all bower files returned by main-bower-files() concatenated before my source JS files. Seems like you need to combine two gulp.src commands but I can't seem to find away to make it work right. I have tried event-stream merge, but it seems you cannot count on all bower files to precede the JS files since the merge pipes them into the src as them become available. Also tried gulp-order, but this doesn't seem to work with your plugin very well.

Any ideas on how best to ensure that all bower files will precede my JS source files in which are in a separate 'app' directory?

Bootswatch broken due to missing "main" property

The bootswatch bower.json does not have a main property, causing this error:

[17:58:37] Error: Main property of package "bootswatch" is missing.
at Object.Package.collectData (/home/user/Projects/myproject/myproject/node_modules/main-bower-files/lib/package.js:75:19)
at Object.Package (/home/user/Projects/myproject/myproject/node_modules/main-bower-files/lib/package.js:31:10)
at Object.PackageCollection.add (/home/user/Projects/myproject/myproject/node_modules/main-bower-files/lib/package_collection.js:53:32)
at Object.PackageCollection.collectPackages (/home/user/Projects/myproject/myproject/node_modules/main-bower-files/lib/package_collection.js:77:18)
at Object.PackageCollection (/home/user/Projects/myproject/myproject/node_modules/main-bower-files/lib/package_collection.js:28:10)
at module.exports (/home/user/Projects/myproject/myproject/node_modules/main-bower-files/lib/index.js:57:22)
at Gulp. (/home/user/Projects/myproject/myproject/gulpfile.js:28:21)
at module.exports (/home/user/Projects/myproject/myproject/node_modules/gulp/node_modules/orchestrator/lib/runTask.js:34:7)
a

CSS file in a bower package is ignored.

My gulpfile is configured to inject the css and js references into the index.html file. But i observed that the css file of angular-ui-grid package is not injected.

When i put a console.log(mainBowerFiles()) into the vendors task function in my gulpfile.js, following is sent to output:

[ 'bower_components/angular/angular.js',
  'bower_components/angular-animate/angular-animate.js',
  'bower_components/angular-route/angular-route.js',
  'bower_components/angular-aria/angular-aria.js',
  'bower_components/hammerjs/hammer.js',
  'bower_components/angular-ui-grid/ui-grid.js',
  'bower_components/angular-material/angular-material.js',
  'bower_components/angular-material/angular-material.css' ]

I couldn't find out why angular-material.css is available, but ui-grid.css is not, even though all conditions (file existance, file types, mimetypes, encoding etc.) are same for those two packages.

Here is my bower.json:

{
  "name": "userinterface",
  "main": [
    "/dist/userinterface.min.js",
    "/dist/userinterface.min.css"
  ],
  "version": "0.1.1",
  "description": "TODO",
  "authors": [
    "TODO"
  ],
  "ignore": [
    "**/.*",
    "package.json",
    "klei.json",
    "gulpfile.js",
    "node_modules",
    "bower_components",
    "src"
  ],
  "dependencies": {
    "angular": "1.3.1",
    "angular-animate": "1.3.1",
    "angular-route": "1.3.1",
    "angular-aria": "1.3.1",
    "angular-material": "~0.4.2",
    "angular-ui-grid": "~3.0.0-rc.12"
  },
  "devDependencies": {
    "angular-mocks": "1.3.1"
  },
  "resolutions": {
    "angular-animate": "1.3.1",
    "angular-aria": "1.3.1",
    "angular": "1.3.1"
  }

Sugar

If first argument is string or array (solution from previous issue) add this to filter and use the second argument as options.

It could be elegant like gulp.src

Gulp error "please provide pattern"

I've updated to this plugin, after using the deprecated one.
I though it would be simple to switch, but I'm getting some errors.

gulp version : CLI version 3.8.7 Local version 3.8.7
node version : v0.10.30

    gulp.task("bower-move", function () {
  return   gulp.src(gulpBowerFiles({debugging: true}), {base: 'bower_components'})
        .pipe(gulp.dest(bowerDestination));
})

Nothing is changed in bower.json

{
  "name": "app-name",
  "version": "0.0.0",
  "authors": [
    "Ivan <>"
  ],
  "moduleType": [
    "globals"
  ],
  "license": "MIT",
  "private": true,
  "ignore": [
    "**/.*",
    "node_modules",
    "bower_components",
    "test",
    "tests"
  ],
  "devDependencies": {
    "bootstrap-sass-official": "~3.2.0",
    "bourbon": "3.1.8"
  },
  "dependencies": {
    "normalize-css": "~3.0.1",
    "velocity": "~0.9.0",
    "animo.js": "*",
    "pubsubjs": "~0.3.7",
    "jquery-sticky": "*",
    "bootstrap-sass": "~3.0.2"
  },
  "overrides": {
    "bourbon": {
      "main": [
        "./app/assets/stylesheets/**/*"
      ]
    },
    "jquery": {
      "main": [
        ""
      ]
    },
    "animo.js": {
      "main": [
        "animo.js"
      ]
    },
    "velocity": {
      "main": [
        "jquery.velocity.min.js"
      ]
    }
  }
}

This is the error I'm getting:

[gulp] 'bower-move' errored after 11 ms must provide pattern

    app_root/node_modules/gulp/node_modules/orchestrator/index.js:153
throw err;
^
Error: must provide pattern
at new Glob (app_root/node_modules/main-bower-files/node_modules/glob/glob.js:134:11)
at glob (app_root/node_modules/main-bower-files/node_modules/glob/glob.js:60:11)
at Function.globSync [as sync] (app_root/node_modules/main-bower-files/node_modules/glob/glob.js:79:10)
at Object.<anonymous> (app_root/node_modules/main-bower-files/lib/package.js:139:31)
at Array.forEach (native)
at Object.Package.getFiles (app_root/node_modules/main-bower-files/lib/package.js:138:14)
at Object.<anonymous> (app_root/node_modules/main-bower-files/lib/package_collection.js:114:39)
at Array.forEach (native)
at Object.PackageCollection.process (app_root/node_modules/main-bower-files/lib/package_collection.js:113:15)
at Object.PackageCollection.getFiles (app_root/node_modules/main-bower-files/lib/package_collection.js:91:21)

Request - select type of file to grab

It would be good if you could filter the type of file added to the files array ( say, for example, just css files). Currently i'm piping bowerfiles() into gulp-filter, but this would be nice built in functionality.

mainBowerFiles() returns empty array

In my case its always empty.
I have gulpfile.js in root of my project, and bower_components in this root. Maybe I'm doing something wrong, but I read your readme X times

Use git tags for versions?

Hey! I noticed that you've been using regular commit messages to keep track of versions, but that makes it virtually impossible to reference past versions in the codebase. It would be really helpful if you made a new git tag (or GitHub Release, as it makes a tag too) per version.

Thanks for making such a useful tool!

problem with bower package that doesn't have a bower.json file

I installed a bower package: bower install git://github.com/js-coder/cookie.js.git#gh-pages

This package is not picked up by "main-bower-files". Any ideas?

I also tried adding an override for it but still no go.

"cookie.js": {
  "main": "cookie.js"
}

usage example with bootstrap

Twitter bootstrap bower package provides multiple main files from which some must be ignored, is there a way to do this ?

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.