curist / grunt-bower

grunt task to copy bower installed packages to other folder(s)
MIT License
93 stars 27 forks source link

Unable to maintain folder structure from root of package directory #36

Closed adambiggs closed 9 years ago

adambiggs commented 10 years ago

Globbing currently maintains directory structure only if use inside one child directory. But I can't figure out how to copy a folder from the package root without flattening the structure...

Given the following bower package structure:

bower_components/

> package1/
>> js/
>>> main.js
>>> locales/
>>>> locale1.js
>>>> locale2.js

> package 2/
>> main.js
>> locales/
>>> locale1.js
>>> locale2.js

And a Gruntfile config of this (coffeescript):

bower:
  libs:
    dest: 'libs'
    options:
      expand: true
      stripAffix: true
      packageSpecific:
        package1:
          files: ['js/**']
        package2:
          files: ['**']

The directory structure ends up like this:

libs/

> package1/
>> main.js
>> locales/
>>> locale1.js
>>> locale2.js

> package 2/
>> main.js
>> locale1.js
>> locale2.js

I've tried different combinations of glob patterns and options, but I can't figure out how to copy a package's root directory structure un-altered...

curist commented 10 years ago

Hey there, thanks to @ertrzyiks , this is fixed in v0.14.1.

adambiggs commented 10 years ago

This is still no good... After updating to v0.14.2 I get the following directory structure:

libs/

> package1/
>> js/
>>> main.js
>>> locales/
>>>> locale1.js
>>>> locale2.js

> package 2/
>> main.js
>> locales/
>>> locale1.js
>>> locale2.js

If you set a glob as js/**, ** should be relative to the js/ directory.

The final result should look like this:

libs/

> package 1/
>> main.js
>> locales/
>>> locale1.js
>>> locale2.js

> package 2/
>> main.js
>> locales/
>>> locale1.js
>>> locale2.js
curist commented 10 years ago

Hi there, please check the new version, v0.15.0. And be sure to add stripGlobBase: true.

nmccready commented 9 years ago

Can you make this more obvious in the README ?

nmccready commented 9 years ago

Why can't the flattening be easy and just put the setting at the root of options. So all packages get flattened. The whole idea of this is to have less work for globing in bower. Otherwise I still need to do a lot more grunt work to get things flattened out. Checkout gulp-bower as it does exactly this.

nmccready commented 9 years ago

I keep getting:

vendor/scripts/angular-animate.js copied.
vendor/scripts/angular-cookies.js copied.
vendor/scripts/dist/angular-google-maps.js copied.
vendor/scripts/angular-highlightjs.js copied.
vendor/scripts/angular-resource.js copied.
vendor/scripts/angular-sanitize.js copied.
vendor/scripts/angular-scenario.js copied.
vendor/scripts/angular-semver-sort.js copied.
vendor/scripts/release/angular-ui-router.js copied.
vendor/scripts/angular.js copied.
vendor/scripts/js/browser/bluebird.js copied.
vendor/styles/dist/css/bootstrap.css copied.
vendor/scripts/dist/js/bootstrap.js copied.
vendor/dist/fonts/glyphicons-halflings-regular.eot copied.
vendor/dist/fonts/glyphicons-halflings-regular.svg copied.
vendor/dist/fonts/glyphicons-halflings-regular.ttf copied.
vendor/dist/fonts/glyphicons-halflings-regular.woff copied.
vendor/scripts/es5-shim.js copied.
vendor/scripts/highlight.pack.js copied.
vendor/styles/styles/default.css copied.
vendor/scripts/dist/jquery.js copied.
vendor/scripts/lib/json3.min.js copied.
vendor/scripts/dist/lodash.compat.js copied.
vendor/scripts/build/share.js copied.
vendor/scripts/underscore.js copied.

when I want:

vendor/scripts/angular-animate.js copied.
vendor/scripts/angular-cookies.js copied.
vendor/scripts/dist/angular-google-maps.js copied.
vendor/scripts/angular-highlightjs.js copied.
vendor/scripts/angular-resource.js copied.
vendor/scripts/angular-sanitize.js copied.
vendor/scripts/angular-scenario.js copied.
vendor/scripts/angular-semver-sort.js copied.
vendor/scripts/release/angular-ui-router.js copied.
vendor/scripts/angular.js copied.
vendor/scripts/bluebird.js copied.
vendor/styles/bootstrap.css copied.
vendor/scripts/bootstrap.js copied.
vendor/fonts/glyphicons-halflings-regular.eot copied.
vendor/fonts/glyphicons-halflings-regular.svg copied.
vendor/fonts/glyphicons-halflings-regular.ttf copied.
vendor/fonts/glyphicons-halflings-regular.woff copied.
vendor/scripts/es5-shim.js copied.
vendor/scripts/highlight.pack.js copied.
vendor/styles/default.css copied.
vendor/scripts/jquery.js copied.
vendor/scripts/json3.min.js copied.
vendor/scripts/lodash.compat.js copied.
vendor/scripts/build/share.js copied.
vendor/scripts/underscore.js copied.

using

  bower:
    dev:
      dest :'vendor/'
      fonts_dest:'vendor/fonts'
      js_dest: 'vendor/scripts'
      css_dest: 'vendor/styles'
      options:
        expand: false
        stripAffix: true
        #stripGlobBase: true
        ignorePackages: ['angular-mocks']
        packageSpecific:
          bootstrap:
            files: [
              'dist/css/bootstrap.css'
              'dist/js/bootstrap.js'
              'dist/fonts/*'
            ]
nmccready commented 9 years ago

Main issue is stuff like

vendor/scripts/dist/jquery.js copied.
vendor/scripts/lib/json3.min.js copied.

Why keep the lib and dist ? How can I do this without having to go through each dependency specifically?

curist commented 9 years ago

I'm not sure your questions really belong to this issue? For a simply flattened file structure, check keepExpandedHierarchy in README.

nmccready commented 9 years ago

@curist thanks, sorry at first I thought it was the same issue.

nmccready commented 9 years ago

@curist tight that worked great.

curist commented 9 years ago

Glad it works for you!