Recursive bower install - bower

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"
]
}
}
}};

Related

Bower install from URL gives blank folder

I'm using bower (v. 1.3.5) to pull in my Front-End JS dependencies, and I want to depend on this: https://github.com/dcneiner/Downloadify
It doesn't have its own bower.json so I'm referencing by URL in MY bower.json:
"dependencies": {
"jspdf": "~1.0.272",
"downloadify": "https://github.com/dcneiner/Downloadify.git"
}
But all I get is the named folder containing only a .bower.json file, but none of the code or anything else in the GH repo.
Running bower install directly on the cmd line gave (once I'd cleared out the bower cache):
E:/My/Path>bower install https://github.com/dcneiner/Downloadify.git
bower Downloadify#* not-cached https://github.com/dcneiner/Downloadify.git#*
bower Downloadify#* resolve https://github.com/dcneiner/Downloadify.git#*
bower Downloadify#* checkout 0.2.1
bower Downloadify#* resolved https://github.com/dcneiner/Downloadify.git#0.2.1
bower Downloadify#~0.2.1 install Downloadify#0.2.1
I previously did the same thing with jQuery.fileDownload which worked perfectly, so I don't think it's anything I've done to my machine?
QUESTION:
Have I done something wrong?
Has Downloadify been set up wrong?
Or is it an inexplicable mystery?
In either of the first 2 cases, what is the problem and how do I fix it?
NOTE: Currently I'm working around it by having downloaded the source code manually and having it hard-coded into my project.

Stop bower from asking for statistics when installing

I'm trying to set up an automated package build for an app which uses bower. When it gets to bower install in the postinstall, bower prompts:
[?] May bower anonymously report usage statistics to improve the tool
over time? (Y/n)
This is screwing up the automated scripts. I could write an expect script to deal with this but I'd rather not if I don't have to. Is there a way to get it to shut up?
As was noted in a comment, this was raised as an issue at github. At the end of that issue there's reference to a minor note at the end of the CHANGELOG comments:
NOTE: It's advisable that users use --config.interactive=false on automated scripts.
You can create a ~/.bowerrc file, which is useful when using bower to install components in a Docker environment:
{
"interactive": false
}
Another option is setting an environment variable (source):
export CI=true
It seems that you could use
bower --config.analytics=false install
to disable only Analytics question.
#see https://github.com/bower/bower/pull/1470
In addition to the existing answers, note that when you are running bower from grunt (e.g. with grunt bower-install-simple, you'll have to add this not into any .bowerrc file, but into the Gruntfile.js. I recently added this line to prevent our CI getting stuck due to unresolvable dependencies:
grunt.initConfig({
...,
/**
* Downloads and installs library dependencies via bower
* defined in bower.json.
*/
'bower-install-simple': {
options: {
...,
+ interactive: false
}
}
});
General way to bypass input for most commands: yes.
yes | bower install
yes | grunt build

cannot change bower components folder

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

Bower: force update of local package

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.

Installing a dependency with Bower from URL and specify version

I am trying to install a dependency with Bower using a URL. As of Bower documentation:
Bower offers several ways to install packages:
# Using the dependencies listed in the current directory's bower.json
bower install
# Using a local or remote package
bower install <package>
# Using a specific version of a package
bower install <package>#<version>
# Using a different name and a specific version of a package
bower install <name>=<package>#<version>
Where <package> can be any one of the following:
A name that maps to a package registered with Bower, e.g, jquery.
A remote Git endpoint, e.g., git://github.com/someone/some-package.git.
Can be public or private.
A local endpoint, i.e., a folder that's a Git repository.
A shorthand endpoint, e.g., someone/some-package
(defaults to GitHub).
A URL to a file, including zip and tar files.
Its contents will be extracted.
However, then it says, that all the types except the URL allow to specify a version.
How do I specify a version for a URL downloaded dependency?
Use a git endpoint instead of a package name:
bower install https://github.com/jquery/jquery.git#2.0.3
If you use bower.json file to specify your dependencies:
{
"dependencies": {
...
"photo-swipe": "git#github.com:dimsemenov/PhotoSwipe.git#v3.0.x",
#bower 1.4 (tested with that version) can read repositorios with uri format
"photo-swipe": "git://github.com/dimsemenov/PhotoSwipe.git#v3.0.x",
}
}
Just remember bower also searches for released versions and tags so you can point to almost everything, and can interprate basic query patterns like previous example. that will fetch latest minor update of version 3.0 (tested from bower 1.3.5)
Update, as the question description also mention using only a URL and no mention of a github repository.
Another example is to execute this command using the desired url, like:
bower install gmap3MarkerWithLabel=http://google-maps-utility-library-v3.googlecode.com/svn/tags/markerwithlabel/1.0/src/markerwithlabel.js -S
that command downloads your js library puts in {your destination path}/gmap3MarkerWithLabel/index.js and automatically creates an entry in your bower.json file called gmap3MarkerWithLabel: "..." After that, you can only execute bower update gmap3MarkerWithLabel if needed.
Funny thing if you do the process backwars (add manually the entry in bower.json, an then bower install entryName) it doesn't work, you get a
bower ENOTFOUND Package
gmapV3MarkerWithLabel not found
Targeting a specific commit
Remote (github)
When using github, note that you can also target a specific commit (for example, of a fork you've made and updated) by appending its commit hash to the end of its clone url. For example:
"dependencies": {
"example": "https://github.com/owner_name/repo_name.git#9203e6166b343d7d8b3bb638775b41fe5de3524c"
}
Locally (filesystem)
Or you can target a git commit in your local file system if you use your project's .git directory, like so (on Windows; note the forward slashes):
"dependencies": {
"example": "file://C:/Projects/my-project/.git#9203e6166b343d7d8b3bb638775b41fe5de3524c"
}
This is one way of testing library code you've committed locally but not yet pushed to the repo.
Use the following:
bower install --save git://github.com/USER/REPOS_NAME.git
More here:
http://bower.io/#getting-started
Just an update.
Now if it's a github repository then using just a github shorthand is enough if you do not mind the version of course.
GitHub shorthand
$ bower install desandro/masonry
Here's a handy short-hand way to install a specific tag or commit from GitHub via bower.json.
{
"dependencies": {
"your-library-name": "<GITHUB-USERNAME>/<REPOSITORY-NAME>#<TAG-OR-COMMIT>"
}
}
For example:
{
"dependencies": {
"custom-jquery": "jquery/jquery#2.0.3"
}
}
Just specifying the uri endpoint worked for me, bower 1.3.9
"dependencies": {
"jquery.cookie": "latest",
"everestjs": "http://www.everestjs.net/static/st.v2.js"
}
Running bower install, I received following output:
bower new version for http://www.everestjs.net/static/st.v2.js#*
bower resolve http://www.everestjs.net/static/st.v2.js#*
bower download http://www.everestjs.net/static/st.v2.js
You could also try updating bower
npm update -g bower
According to documentation: the following types of urls are supported:
http://example.com/script.js
http://example.com/style.css
http://example.com/package.zip (contents will be extracted)
http://example.com/package.tar (contents will be extracted)
I believe that specifying version works only for git-endpoints. And not for folder/zip ones. As when you point bower to a js-file/folder/zip you already specified package and version (except for js indeed). Because a package has bower.json with version in it.
Specifying a version in 'bower install' makes sense when you're pointing bower to a repository which can have many versions of a package. It can be only git I think.
Try bower install git://github.com/urin/jquery.balloon.js.git#1.0.3 --save where 1.0.3 is the tag number which you can get by reading tag under releases. Also for URL replace by git:// in order for system to connect.
Installs package from git and save to your bower.json dependency block.
bower register package-name git-endpoint#version
install package-name --save
(--save will save the package name version in the bower.json file inside the dependency block).
Reference

Resources