register bower packages in nexus oss - bower

I have configured bower and nexus using this tut:
https://books.sonatype.com/nexus-book/3.0/reference/bower.html
I have bowerrc.json like below:
{
"registry" : {
"search" : [
"http://localhost:8081/repository/bower-all/"
],
"register" : "http://localhost:8081/repository/bower-internal"
},
"resolvers" : [ "bower-nexus3-resolver" ]
}
and i use bower-nexus3-resolver as resolver integrating bower and nexus.
this config installs bower packages and packages are cached in nexus but i cant register my own bower package locally in nexus ?

Registering your own packages is documented here. Following the steps there should work just fine. Keep in mind that bower registries point back to a git server typically so you have to have that running as well.

Related

Bower using old registry instead of new

My bower has just started giving errors when I do a grunt build. In particular, I am seeing errors like:
Warning: Request to https://bower.herokuapp.com/packages/angular failed with 502 Use --force to continue.
Doing some research, it looks like the registry server has changed from bower.herokuapp.com to registry.bower.io. However, my bower is still hitting the old server.
My bower is updated to the latest version: 1.8.4.
I've cleared my bower cache, just in case.
Not sure what to do next.
UPDATE:
I was able to specify the registry locally in my .bowerrc file, but I would still like to know how to get it to hit the new registry by default.
{
"directory": "app/bower_components",
"registry": {
"search": [
"https://registry.bower.io"
]
}
}

Private bitbucket repository in package.json with version

I am trying to include a private BitBucket repository to my package.json, but I also would like to manage the version, as a normal module.
currently I am using this
"package-name": "git+https://<user>:<password>#<url-repository>.git"
I already tried it, but it didn't work.
"package-name": "git+https://<user>:<password>#<url-repository>.git#v1.0"
Any idea?
Login to your bitbucket account and under user settings add an app password:
Add package dependency to your package.json as:
"dependencies": {
"my-module": "git+https://Xaqron:pwd#bitbucket.org/Xaqron/my-module.git#*"
}
Replace Xaqron with your own username and pwd with app password from step one.
to install specific version add #v.v.v (i.e. #1.0.0) to the end of dependency URL.
I am currently using this and it works:
{
"dependencies": {
"package-name": "git+ssh://git#<url-repository>.git#v0.1.0"
}
}
I am using npm version 4.1.2 and self hosted bitbucket version 4.14.6
You have to git tag the version you want to install in the module repo. The repo url can be found in the module's package.json file, e.g.
"repository": {
"type": "git",
"url": "git+https://github.com/repo-owner-name/my-module.git" // <-- This line!
},
When you've added a tag (e.g. git tag -a 0.0.1 -m "auto release") to a release, it can be installed using:
"my-module": "git+https://bitbucket.org/repo-owner-name/my-module.git#0.0.1"

bower register new version

I register a version of my "angular-backstrech-adrr" to bower:
bower register angular-backstrech-adrr git#github.com:AladdinMhaimeed/angular-backstrech-adrr.git
this is bower.json:
{
"author": "Aladdin Mhaimeed",
"name": "angular-backstrech-adrr",
"version": "1.0.4",
"main": "angular-backstretch.js",
"dependencies": {
"jquery": ">2.0.0",
"jquery-backstretch": "https://raw.github.com/srobbin/jquery-backstretch/master/jquery.backstretch.min.js"
}
}
Bower says it is successfully registered, but when I use:
bower info angular-backstretch-adrr
It says there is no version available.
If I change the version and try to register again, I get: EDUPLICATE
Is there something wrong in the bower.json? Anything wrong with the syntax?
Your package only needs to be registered once. The versions are drawn from your Git tags. From the Bower documentation:
Your package must be available at a Git endpoint (e.g., GitHub);
remember to push your Git tags!
Not to worry, I had no idea what this meant either. After poking around a bit, I stumbled across this.
Here's the quick and easy way to solve your problem... from your project's root directory run:
% git tag v1.0.4
If you type:
% git tag
you'll see the version you just created. Now push your Git tags:
% git push origin v1.0.4
Now when you run bower info angular-backstretch-adrr, you'll see the version you just pushed.
Above answer is correct except v in front of version is incorrect.
//Incorrect
% git tag v1.0.4
//Correct
% git tag 1.0.4
Now push it. Github also complains when try to put v in front of tag.
Live log of bower
bower not-cached git://github.com/speedovation/Inventive.git#*
bower resolve git://github.com/speedovation/Inventive.git#*
bower download https://github.com/speedovation/Inventive/archive/0.9.6.tar.gz
bower progress inventive#* received 0.4MB
bower progress inventive#* received 0.5MB
See 0.9.6 in log. If v used it will fail.

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

Install component zf2 using composer

I try to install zf2 component using composer but can't do it because composer always
download all framework, what am i doing wrong?
Composer version 1beccf9
{
...
"repositories": [
{
"type": "composer",
"url": "http://packages.zendframework.com/"
}
],
"require": {
"zendframework/zend-http" : "2.0.*"
}
}
I enabled php_intl extension and that solved the problem
I cannot reproduce the issue. I have tried with both the "http" and "https" schema, and in both cases, received only the zend-http package and its dependencies. The only possible issue I can see is that if you're not using the "https" schema, and do not have openssl compiled into your PHP version, it's possible that Composer is unable to reach our repository, and thus defaults to the packagist repository, which will only ever give you the full ZF distribution.

Resources