twitter/bower — pull request #235 by desandro (2013-02-03 23:06:22+00:00)
Title: list --sources for easier source listing

I'm curious to get your thoughts on this.

For those of us not using a module loader like RequireJS, you probably just want a list of the various file sources, in proper order of dependencies. This command does that

``` bash
bower list --sources
```

`bower list --map` returns a full dependency map. Here's an abbreviated version of my current output (conflating `source` with `main`):

``` JSON
{
"classie": {
"source": "components/classie/classie.js"
},
"draggabilly": {
"source": "components/draggabilly/draggabilly.js",
"dependencies": {
"classie": {
"source": "components/classie/classie.js"
},
"eventEmitter": {
"source": [
"components/eventEmitter/EventEmitter.js",
"components/eventEmitter/EventEmitter.min.js"
]
}
},
"eventie": {
"source": "components/eventie/eventie.js"
},
"get-size": {
"source": "components/get-size/get-size.js",
"dependencies": {
"get-style-property": {
"source": "components/get-style-property/get-style-property.js"
}
}
},
"get-style-property": {
"source": "components/get-style-property/get-style-property.js"
}
}
},
"eventEmitter": {
"source": [
"components/eventEmitter/EventEmitter.js",
"components/eventEmitter/EventEmitter.min.js"
]
},
"eventie": {
"source": "components/eventie/eventie.js"
},
"get-size": {
"source": "components/get-size/get-size.js",
"dependencies": {
"get-style-property": {
"source": "components/get-style-property/get-style-property.js"
}
}
},
"get-style-property": {
"source": "components/get-style-property/get-style-property.js"
},
"matches-selector-helper": {
"source": "components/matches-selector-helper/matches-selector.js"
}
}
```

You can see there's lots of duplication and plenty of complexity. This list command removes duplicates, and puts each source path in order of dependency, yielding:

``` JSON
{
".js": [
"components/classie/classie.js",
"components/eventEmitter/EventEmitter.js",
"components/eventEmitter/EventEmitter.min.js",
"components/eventie/eventie.js",
"components/get-style-property/get-style-property.js",
"components/get-size/get-size.js",
"components/draggabilly/draggabilly.js",
"components/matches-selector-helper/matches-selector.js"
]
}
```

Note that these files are grouped by file extension. So you have different collections for CSS (or SASS or whatever), HTML, and images. With that, you can use that array to list out all the `