Given that bower support installing items that do not technically exist in the global bower namespace the following problem can arise.
Bower install https://github.com/bitovi/canjs.com/archive/v1.1.6.zip
results in
Components
|- v1.1.6
|--bower.json
|-- (complete installation of all required pieces here).
This can lead to potential confusion and maintenance problems down the road as it is now on the developer to recall that "can.js" lives in v1.1.6. Clearly there are fixes that one can implement (i.e. pointing all items using can.js to this directory) but this doesn't solve the core problem.
bower.json looks like this:
{
"name": "v1.1.6",
"main" : "",
"version": "0.0.0",
"repository": {
"type": "asset",
"url": "https://github.com/bitovi/canjs.com/archive/v1.1.6.zip"
}
}
Is renaming the directory and updating the bower.json enough or is there another resource that needs to be updated as well?
Yes updating bower.json is enough. In the next bower major release (1.0.0), you can name a package when installing. In your case you would so something like this:
bower install canjs=git://github.com/bitovi/canjs.com.git#~1.1.6
You can try out this new feature by installing bower-canary: npm install -g -f bower-canary
Related
I want to use bower add manage my library, my question is along with the js files, it always comes with some extra json or git related files. I don't want to push those files to the client, is there a recommended way rather than extract js filed manually?
Bower allows you define in your bower.json file a list of files it will ignore when installing your package:
ignore
Recommended Type: Array of String
A list of files for Bower to ignore when installing your package.
Note: README (all variants of case, .md, .text) and bower.json will
never be ignored.
The ignore rules follow the same rules specified in the gitignore pattern spec.
For example:
{
"name": "my-project",
"version": "1.0.0",
"main": "path/to/main.css",
"ignore": [
".jshintrc",
"**/*.txt"
],
...
}
Another option is keeping only the files you want to distribute in the Git tags which represents you package versions.
I've got a project which depends on another project which and both use Bower. I'd like bower install to also run on that component when I run it on the parent project. So far I haven't found anything in the configuration spec, the man page or the online docs which hint at this, so I've simply navigated to the child project directory and ran bower install a second time. With a lot of dependencies, this wouldn't be feasible, so having bower install -R would be nice.
I could not figure out how to do it using the 'bower' command in the terminal.
However I could successfully use grunt auto_install for this purpose.
grunt.initConfig({
"auto_install": {
options: {
recursive: true,
exclude: [
".git",
"node_modules",
"components",
"grunt-tasks",
".sass-cache"
]
}
}
}};
I'm trying to override bower's component folder following the answers in this question: How to change bower's default components folder?
this is my bower.json file (with all the things I've tried)
{
"name": "sample-app",
"version": "1.0.0",
"directory": "public/libs/",
"componentsDirectory": "public/libs/",
"dependencies": {
"jquery": "latest"
}
}
and this is my .bowerrc:
{
"directory": "public/libs/",
"componentsDirectory": "public/libs/"
}
I've tried a couple more things, but the settings just seems to be ignored, and the components are installed to bower_components
these are the versions I'm using:
$ bower -v
1.2.8
$ npm -v
1.3.24
$ node -v
v0.10.25
I have a github of this working. It's not the identical code you have above, but if you can get this to work, you should be able to iterate from there.
If you are running Bower on Windows, you should make sure that you have selected Run Git from the Windows Command Prompt(second option) during GIT Installation. Then it'll work!!
Refer link here
I need to force bower to override a locally-defined dependency with a fresh copy. I assumed that bower update <package> would do the trick (even with a little extra --force). However, it stubbornly prefers whatever copy is installed under bower_components.
Consider the following layout (all in one codebase for now, sadly):
shared/bower.json
{
"name": "mysharedstuff",
"version": "0.0.1",
...
}
client1/bower.json
{
...
"dependencies": {
"mysharedstuff": "../shared"
}
}
The only way I can get a fresh copy of shared/ is to explicitly delete the copy installed under bower_components. For example:
client1$> rm -rf bower_components/mysharedstuff
client1$> bower install
Is this a bug with how bower handles versioning of local dependencies? Or am I missing something simple?
Just to update from the github issue you referenced.
bower --force update
will force update any packages in your bower.json.
Works in Bower > v1.3.6
Because bower looking for latest TAG name in your repo. Specify your last commit with git tag.
I am trying to install some js files via bower. My repo has a bower.json with a main property, however the whole repo gets installed to components/, not just the files in the dist/custom/ dir.
Here is what my bower.rc looks like
{
"name": "jquery-m",
"version": "2.0.2mup",
"description": "Meetup custom build of jQuery 2.0, used on mobile",
"main": [ "./dist/custom/" ],
"license": "MIT"
}
Is this the way bower is supposed to work? I thought it was possible just to specify certain files with your main property.
Yes, this is how Bower is meant to work. Bower-installer looks like a more lightweight solution than Grunt to solve the exact requirement you're describing and get just the files you need to be deployed to production.
Yes, that's how Bower works.
It always look for the matching tag on the repo; if cannot find one, it goes with the default branch, and download it.
The unique usage I've seen so far for the main property of a bower.json file is for integration, for example with build tools, like Grunt (there are lots of other bower related tasks, just Google around) and others.
This is a common misconception.
As stated in Bower documentation, the main property is a string/array listing the primary endpoints of your package.
Bower package maintainers (and maybe users, using the overrides property) can use the ignore property, which is an array of paths not needed in production that you want Bower to ignore when installing your package.
Example:
{
"name": "stackoverflow",
"version": "1.0.0",
"ignore": [
"test/**",
".jshintrc"
],
"dependencies": {
"foo": "~1.1"
}
}