Bower again
For a while I think the bower support was working for me (I was referencing angular-ui/ui-router instead of the bower database).
Now, I'm getting strange behavior (whether I reference the bower repository with "angular-ui-router" or the ui-router repository with "angular-ui/ui-router"). The symptom is that the Gruntfile.js content is being copied into my distribution dependencies instead of the ui-router code. Below is the bower.json that I see, which is probably not what is intended.
I'm wondering whether this is a bug in bower. I know it has a bug dealing with multiple dots in filenames when referencing JS files directly in dependencies. Since the minified version of ui-router is listed as main, is it possible that bower is tripping on it? Just an idea.
The other possibility is that either grunt-bower or grunt-bower-task is causing the problem.
Is anybody else seeing strange bower behavior (as of now)?
I'll post back if I figure this out.
{
"name": "angular-ui-router",
"version": "0.0.1",
"main": "./release/angular-ui-router.min.js",
"dependencies": {
"angular": ">= 1.0.6"
},
"gitHead": "18af2c4404b5cdc435c427bbd668d075b4830bc0",
"readme": "[](https://travis-ci.org/angular-ui/ui-router)\r\n\r\n# UI-Router\r\n\r\n**Attention**: UI-Router uses <code>grunt >= 0.4.x</code> make sure to upgrade your environment and read the\r\n[Migration Guide](http://gruntjs.com/upgrading-from-0.3-to-0.4).\r\n\r\nFinally a de-facto solution to nested views and routing.\r\n\r\n\r\n## Main Goal\r\nTo evolve the concept of an Angular \"Route\" into a more general concept of a \"State\" for managing complex application UI states.\r\n\r\n## Main Features\r\n1. **Robust State Management**\r\n>`$state` and `$stateProvider`\r\n\r\n2. **More Powerful Views**\r\n>`ui-view` directive (used in place of `ng-view`)\r\n\r\n3. **Named Views**\r\n>`<div ui-view=\"chart\">`\r\n\r\n4. **Multiple Parallel Views**\r\n>\r\n```\r\n<div ui-view=\"chart1\">\r\n<div ui-view=\"chart2\">\r\n```\r\n5. **Nested Views**\r\n>load templates that contain nested `ui-view`s as deep as you'd like.\r\n\r\n6. **Routing**\r\n>States can map to URLs (though it's not required)\r\n\r\n\r\n*Basically, do whatever you want with states and routes.*\r\n\r\n\r\n## Resources\r\n\r\n* [In-Depth Overview](https://github.com/angular-ui/ui-router/wiki)\r\n* [FAQ](https://github.com/angular-ui/ui-router/wiki/Frequently-Asked-Questions)\r\n* [Sample App](http://angular-ui.github.com/ui-router/sample/) ([Source](https://github.com/angular-ui/ui-router/tree/master/sample))\r\n* [Generated Docs](http://angular-ui.github.com/ui-router/build/doc/)\r\n* Latest build: [angular-ui-states.min.js](http://angular-ui.github.com/ui-router/build/angular-ui-states.min.js)\r\n (uncompressed [angular-ui-states.js](http://angular-ui.github.com/ui-router/build/angular-ui-states.js))\r\n\r\n## Quick Start\r\n1. Add angular-ui-states.min.js to your index.html\r\n>\r\n```html\r\n<!doctype html>\r\n<html ng-app=\"myapp\">\r\n<head>\r\n <script src=\"https://ajax.googleapis.com/ajax/libs/angularjs/1.0.6/angular.min.js\"></script>\r\n <script src=\"angular-ui-states.js\"></script>\r\n```\r\n\r\n2. Add one or more `ui-view` to your app, give them names.\r\n>\r\n```html\r\n<body>\r\n <div ui-view=\"viewA\"></div>\r\n <div ui-view=\"viewB\"></div>\r\n <!-- Also a way to navigate -->\r\n <a href=\"#/route1\">Route 1</a>\r\n <a href=\"#/route2\">Route 2</a>\r\n</body>\r\n```\r\n\r\n3. Set `ui.state` as a dependency in your module\r\n>\r\n```javascript\r\nvar myapp = angular.module('myapp', ['ui.state']) \r\n```\r\n\r\n4. Set up your states in the module config\r\n>\r\n```javascript\r\nmyapp.config(function($stateProvider, $routeProvider){\r\n $stateProvider\r\n\t\t.state('index', {\r\n\t\t\turl: \"\", // root route\r\n\t\t\tviews: {\r\n\t\t\t\t\"viewA\": {\r\n\t\t\t\t\ttemplateUrl: \"index.viewA.html\"\r\n\t\t\t\t},\r\n\t\t\t\t\"viewB\": {\r\n\t\t\t\t\ttemplateUrl: \"index.viewB.html\"\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t})\r\n\t\t.state('route1', {\r\n\t\t\turl: \"/route1\",\r\n\t\t\tviews: {\r\n\t\t\t\t\"viewA\": {\r\n\t\t\t\t\ttemplateUrl: \"route1.viewA.html\"\r\n\t\t\t\t},\r\n\t\t\t\t\"viewB\": {\r\n\t\t\t\t\ttemplateUrl: \"route1.viewB.html\"\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t})\r\n\t\t.state('route2', {\r\n\t\t\turl: \"/route2\",\r\n\t\t\tviews: {\r\n\t\t\t\t\"viewA\": {\r\n\t\t\t\t\ttemplateUrl: \"route2.viewA.html\"\r\n\t\t\t\t},\r\n\t\t\t\t\"viewB\": {\r\n\t\t\t\t\ttemplateUrl: \"route2.viewB.html\"\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t})\r\n})\r\n```\r\n\r\n5. See this quick start example working. \r\n>**[Go to Quick Start Plunker](http://plnkr.co/edit/vDURUN?p=preview)**\r\n\r\n6. This only scratches the surface! You've only seen Named Views and Parallel Views. Learn more about `state()` options, Nested Views, URL routing options, backwards compatibility, and more! \r\n>**[Dive Deeper!](https://github.com/angular-ui/ui-router/wiki)**\r\n\r\n## Developing\r\n\r\nDependencies for building the solution and running tests:\r\n\r\n* [grunt-cli](https://github.com/gruntjs/grunt-cli) - run: `$ npm install -g grunt-cli`\r\n* Then install development dependencies with: `$ npm install`\r\n\r\nThere is a number of targets in the gruntfile that is used to building the solution, documents etc.\r\n\r\n* `grunt`: Perform a normal build, runs jshint and karma tests\r\n* `grunt build`: Perform a normal build\r\n* `grunt dist`: Perform a clean build and generate documentation\r\n* `grunt dev`: Run dev server (sample app) and watch for changes, builds and runs karma tests on changes.\r\n\r\n",
"readmeFilename": "README.md",
"_id": "[email protected]",
"description": "[](https://travis-ci.org/angular-ui/ui-router)",
"repository": {
"type": "git",
"url": "git://github.com/angular-ui/ui-router"
}
}
As I mentioned in https://github.com/angular-ui/ui-router/issues/169 , I was wondering whether I was referencing the master branch or the tagged version when trying to use bower to depend on ui-router. It turns out the same behavior in both cases.
I'm still seeing a wacky bower.json when I reference "angular-ui-router": "~0.0.1" -- and it's still treating the gruntfile.js as the "main file". This also happens if I reference the git repository directly (which should access the main branch).
I notice that in both the main branch and the 0.0.1 tag, the name property in bower.json is "ui-router". However, when I try to reference "ui-router": "~0.0.1" (i.e. use the bower repository) it is not found, so it seems like there may be a name mismatch between the name used to register it and the name it specifies in bower.json?
Is there anyone out there who has bower working with this project? I swear it worked for a while, but I don't have a record of when that was. So, I'm back to referencing a copy of the js in my source tree: "angular-ui-router": "./src/angular-ui-router.js"
hm... maybe the problem is the name mismatch. not sure what you mean exactly though... when I run bower install angular-ui-router I get the entire ui-router distribution under components/ui-router
I just looked into this further -- think either the name mismatch or the complexity/strangeness of the bower.json (i.e. having the entire readme and a githead property in it) may be tripping up grunt-bower-task.
Can you explain in some more detail what the broken behaviour is that you're seeing? As I said in my previous comment, what goes into components/ui-router when I call bower install angular-ui-router looks fine to me.
The readme is put there by bower itself during the install, it's not in the bower.json in our repo.
Symptoms:
- random stuff inserted into the bower.json file by the time it is installed using
bower install. - the Gruntfile.js content ends up in the distributed copy of the component -- INSTEAD of the actual router
Part 1 of my best guess is that something is tripping up grunt-bower-task, which normally copies a dependency from components for you into your distribution folder (or whever you want it).
Part 2 of my best guess is that it may be all of the random stuff that is sneaking its way into bower.json when you bower install that is causing grunt-bower-task to trip.
I'm at a loss for how that stuff is getting into bower.json. I'm ready to throw up my hands... it's easy enough to copy down the ui-router js file and depend on it locally. like this: https://github.com/afterglowtech/angular-couchPotato/blob/master/bower.json
Here's a minimal config that demonstrates. It is three files -- if you create them in a new projectspace and do npm install and grunt doBower you can see the result in the dist directory:
bower.json:
{
"version": "0.0.1",
"main": [
"dist/router-test-bower.js"
],
"description": "Testing ui-router as bower dependency",
"dependencies": {
},
"devDependencies": {
"angular-ui-router": "~0.0.1"
}
}
package.json:
{
"name": "router-test-bower",
"description": "Testing ui-router as bower dependency",
"version": "0.0.1",
"dependencies": {},
"devDependencies": {
"grunt": ">= 0.4.1",
"grunt-cli": ">= 0.1.7",
"grunt-bower": "~0.5.1",
"grunt-bower-task": "~0.2.3"
}
}
Gruntfile.js:
module.exports = function(grunt) {
grunt.loadNpmTasks('grunt-bower-task');
grunt.renameTask('bower', 'bowerInstall');
grunt.loadNpmTasks('grunt-bower');
grunt.registerTask('doBower', ['bowerInstall', 'bower']);
grunt.initConfig({
bower: {
dev: {
dest: './dist/dependencies'
}
},
bowerInstall: {
install: {
}
}
});
};
I wish I could help on this, but then again, I may be the only one who is experiencing meaningful problems if I'm the only one using grunt-bower-task and the stray stuff in bower.json isn't messing up basic bower install users/usage.
Hmm... does seem to be related to grunt-bower-task. I'll fix the 'name' issue for 0.0.2, and we'll see if that fixes it.
I tried fixing the name, no dice. It still populates bower.json with all of that extraneous stuff. I'm going to try taking out the ".min" in the filename. I know of at least one bug in bower that doesn't like multiple periods in filenames.
Hi,
I have the same issue running the following commands:
bower install angular-ui-router --save
bower install
Tracking down the issue:
bower install --verbose
throws the following exception:
C:\Users\Richard\AppData\Roaming\npm\node_modules\bower\node_modules\tmp\lib\tmp
.js:260
throw err;
^
Error: ui-router not found
at Request._callback (C:\Users\Richard\AppData\Roaming\npm\node_modules\bowe
r\lib\core\source.js:44:30)
at Request.self.callback (C:\Users\Richard\AppData\Roaming\npm\node_modules
bower\node_modules\request\main.js:122:22)
at Request.EventEmitter.emit (events.js:98:17)
at Request.
It looks like get request using the url: https://bower.herokuapp.com/packages/ui-router returns 404. But https://bower.herokuapp.com/packages/angular-ui-router returns something... Could it be the root cause of this issue?
Thanks, Richard.
I think I was having a similar problem; If I do the following (OS X, bash):
$ bower install angular-ui-router
Then I get bower_components/ui-router/* and doing a subsequent bower list call fails due to error.
However, if I add angular-ui-router: "~0.0.1" to my bower.json, then do a
$ bower install
Then I get bower_components/angular-ui-router/* and doing a subsequent bower list works as expected.
'angular-ui-router' is the correct name for the bower artifact, but the mismatch with bower.json might be causing the problem.
@ksperling you are correct. Once bower.json is updated to angular-ui-router instead of ui-router
Thanks.
@RCanine I got same behavior on Windows/cygwin. Thanks for your tip. Worked for me.
Is this resolved, do I need to modify the quickstart bower step to include the "~0.0.1"?