Registering a Bower Package with Remote Repository in Artifactory isn't saving - bower

Having some trouble registering a bower package to a remote repository which should be possible with the version I have (artifactory.version: 4.9.1)
So there is a repo there thats setup and it has a URL of http://mygetserver.domain.com/git which hits the gitolite page for browsing the git repos (which seems odd)
The registry url is pointing at the default of https://bower.herokuapp.com/
With the Bower Settings pointing to Custom and a default URL of {0}/{1}/archive/{2}.{3} - Again that feels weird but I have no idea whats expected in there
So when I try and register a package with
bower register nh-styles git#mygetserver.domain.com:nh-styles.git --verbose
I get an error to say
Error: Unknown error: 404 - Unable to determine coordinates from url git#mygetserver.domain.com:nh-styles.git
If I change that to use ssh:// first then it works
C:\Dev>bower register nh-styles
ssh://git#mygetserver.domain.com/nh-styles.git --verbose bower
nh-styles#* resolve
ssh://git#mygetserver.domain.com/nh-styles.git#* bower nh-styles#*
checkout v0.0.4 bower nh-styles#* old-git It seems you
are using an old version of git, it will be slower and propitious to
errors! bower nh-styles#* invalid-meta nh-styles is missing
"ignore" entry in bower.json bower nh-styles#* resolved
ssh://git#mygetserver.domain.com/nh-styles.git#0.0.4 ? Registering a
package will make it installable via the registry
(http://myart.artifactorydomain.com:8081/artifactory/api/bower/bower-nh-git
? Registering a package will make it installable via the registry
(http://myart.artifactorydomain.com:8081/artifactory/api/bower/bower-nh-git
), continue? Yes bower nh-styles register
ssh://git#mygetserver.domain.com/nh-styles.git
Package nh-styles registered successfully! All valid semver tags on
ssh://git#mygetserver.domain.com/nh-styles.git will be available as
versions. To publish a new version, just release a valid semver tag.
Run bower info nh-styles to list the available versions.
C:\Dev>bower info nh-styles bower nh-styles#* not-cached
art://nh-styles/nh-styles#* bower nh-styles#* resolve
art://nh-styles/nh-styles#* bower EREQUEST
Request to
http://myart.artifactorydomain.com:8081/artifactory/api/bower/bower-nh-git/refs/nh-styles/n
h-styles returned 404 status code.
Additional error details: [object Object]
Yet when I try and Info nothing shows. Every time I resubmit I'm getting a 201 rather than a package exists issue. So basically why is it not being saved? Artifactory logs are showing nothing I can see. Anything else I can look at?

The reason you must include ssh:// is that the bower resolver need to know what protocol it has to use when accessing the specified url, this is also documented here. Also I noticed you used domain.com:nh-styles.git this is not a valid url, because of the : -- it might also work like this without the ssh:// part i'm not sure.
The way registering a package with Artifactory works is that it simply acts as the registry in a sense that it simply keeps a mapping of the package name to the git url you gave it. That's also why registering a package will have no other apparent effect (except for the 201 response).
The behavior is pretty much identical to the bower public registry in this aspect.
The error itself you're getting is because Artifactory can't find the git repo you're referring to in the registered git repository - check that the repo at the url you gave is accessible - you can also turn on debug logs on org.artifactory.addon.bower to see the exact error Artifactory encountered if it's not already printing something to the log about this.

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

How to install Bower component from Stash repo with JSPM

My client uses Stash (which it seems has been renamed Bitbucket Server) to host project repositories. We use a private Bower registry for our private libraries.
In this new project I am building, I am using JSPM. I have used jspm-git to create a stash registry. Getting the public libraries such as jQuery, Angular and Lodash obviously works fine.
I get into an issue when I run this:
jspm install mapped-name=stash:project-name/lib-name
Obviously the actual lib names are redacted to respect my client's intellectual property.
This is the error I get:
warn Error on build
TypeError: undefined is not a function
at Object.posix.isAbsolute (path.js:479:15)
at Object.posix.normalize (path.js:461:26)
at GitLocation.build ([REDACTED]/node_modules/jspm-git/git.js:426:17)
at [REDACTED]/node_modules/jspm/lib/registry.js:117:30
at lib$rsvp$$internal$$tryCatch ([REDACTED]/node_modules/jspm/node_modules/rsvp/dist/rsvp.js:493:16)
at lib$rsvp$$internal$$invokeCallback ([REDACTED]/node_modules/jspm/node_modules/rsvp/dist/rsvp.js:505:17)
at [REDACTED]/node_modules/jspm/node_modules/rsvp/dist/rsvp.js:1001:13
at lib$rsvp$asap$$flush ([REDACTED]/node_modules/jspm/node_modules/rsvp/dist/rsvp.js:1198:9)
at process._tickCallback (node.js:355:11)
I do not know if I forgot a step, or if I misconfigured something, or if there is even a bug with JSPM or jspm-git. Any guidances to help me debug this would be appreciated.
It turned out to be a missing publishConfig entry in the package.json file.
I had asked this question as well in the jspm-git repo, and a collaborator seems to agree that improving the error message could provide guidance. Some improvement to look forward to?
I hope this thread is of use to anyone that faces a similar issue.

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.

Bower install without ssl

I have trouble connecting to sites with ssl, i.e. https. It can successfully download artifacts from the internet if the url begins with http.
bower install will download dependencies via https. Is there anyway make it download via http?
I had troubles with this too, and I couldn't find an elegant way to fix it. My workaround was:
Go to your global npm folder and find the "bower" folder (on Windows 7 that is "C:\Users\\AppData\Roaming\npm\node_modules").
In that folder, search the default.js file placed in node_modules\bower-config\lib\util\default.js
Inside that file you will find a "var defaults". Replace the "registry" url property from "https" to "http".
Yes, I know. This shouldn't be done like this, but at least help me to bypass the connection error.
Hope that helps!
You can change the registry used by Bower in the .bowerrc file. The default registry is: https://bower.herokuapp.com and is defined in node_modules/bower-config/lib/util/default.js (as described by Jean Manuel Arias in his answer).
To override for your project, add a value for the registry setting in .bowerrc. An example file might be:
{
"directory": "<YOUR LIBRARY INSTALL DIRECTORY>",
"registry":"http://bower.herokuapp.com"
}
In the above example, the default https registry is being overridden with the http version. A full list of the available .bowerrc settings can be found at: Bower Spec.
You can do a global override for the current user by creating a %USERPROFILE%\.bowerrc file (for windows, in Linux it is: ~/.bowerrc). Bower follows a similar search path when applying settings to NPM (see npmrc settings). This is probably a better route as it avoids cluttering your project with local settings.

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