Once you have signed up for a Gemfury account,
you can upload and install Bower packages
individually via command-line or as a dependency in bower.json
.
Uploading packages to your account
To upload a package, use Git to push it to Gemfury:
$ git remote add fury https://git.fury.io/username/package-name.git
$ git push --tags fury master
Once Gemfury detects your repository as a Bower package, individual versions of the package will be added to your Gemfury account. Given that Bower is a Git-based package manager, be sure to add and push SemVer compatible tags as shown above to enable access to all package versions.
With Javascript’s versatility, some of you may choose to build both npm and
Bower packages from a single repository. You can do so by adding .fury.yml
in the root of your repository to configure your build.
Initial set-up to install packages from Gemfury
To install Bower packages from a Gemfury account, please install Bower (1.5.0+) along with our package resolver:
npm install -g fury-bower-resolver
You will also update your .bowerrc
file to
enable this resolver. This can be done globally or per-project:
{
"resolvers": [
"fury-bower-resolver"
]
}
That’s it! You can now install Bower packages from Gemfury.
Installing packages and dependencies
Once you’ve enabled this resolver, you can install packages individually:
bower install fury://username/pkg-name
Or include them as a dependency in your project’s bower.json
:
{
"dependencies": {
"pkg-name": "fury://username/pkg-name#1.1.*"
}
}
Authenticating to install private packages
Without authentication, this resolver allow you to install public packages
from any Gemfury account. To install private packages, you need to provide
your secret Gemfury token. You can get this token from your Gemfury dashboard,
and pass it to the resolver using the FURY_TOKEN
environment variable:
FURY_TOKEN=mY-sEcRet-token bower install
If it’s not possible for you to modify the environment of your Bower
installation, or you would like to save your token during development, you
can specify it via ~/.bowerrc
:
{
"furyResolver": {
"authToken": "mY-sEcRet-token"
}
}
We only recommend using .bowerrc
authentication for local development.
Please do not commit your secrets/passwords into your SCM or into your packages.
Advanced: Enabling cascading auto-discovery
This resolver has two modes of operation: implicit and explicit. As shown
above, explicit mode allows you to choose which packages will come from a
Gemfury account by specifying a fury://
source. Alternatively, implicit
mode, when enabled, will try to install all packages from your Gemfury account,
falling back on the default public registry for packages not found in Gemfury.
Explicit sources can be used with or without enabling implicit mode.
Explicitly specifying Gemfury packages
Explicit mode lets you specify which packages come from your account by using a Gemfury-specific URL as package source. The URL format is as follows:
fury://<account-username>/<package-name>
So your dependencies in bower.json
will look as follows. In this case,
moment
will be installed from my-org
Gemfury account, while jquery
will
come from the public registry:
{
"dependencies": {
"moment": "fury://my-org/moment#2.0.*",
"jquery": "^2.0.0"
}
}
Implicitly overriding packages with Gemfury
Implicit mode allows you to keep your existing bower.json
, while this
resolver checks your Gemfury account for existence of each package by name,
falling back on the default public registry for those not found in your
account.
Implicit mode is disabled by default. To enable it, please specify
which account to search in your .bowerrc
:
{
"furyResolver": {
"locateInAccount": "my-gemfury-username"
}
}
Example: Putting it all together
For example, let’s say that my personal Gemfury username is johnny
, and I
work at an organization fury-org
. Our main package is fury-unleashed
, and
we have our own patched version of moment
- both in fury-org
account.
I will set up ~/.bowerrc
on my laptop as follows:
{
"resolvers": [
"fury-bower-resolver"
],
"furyResolver": {
"authToken": "my-personal-token",
"locateInAccount": "fury-org"
}
}
Now, I can have the following dependencies in my bower.json
:
{
"dependencies": {
"my-fury-hacks": "fury://johnny/my-fury-hacks",
"fury-unleashed": null,
"moment": "^2.11.0",
"jquery": "^2.0.0"
}
}
Here’s what will happen with each of those packages, given the configuration:
my-fury-hacks: installed from my personal account johnny
fury-unleashed: implicitly found and installed from fury-org
moment: implicitly found and installed from fury-org
jquery: installed from public registry (not found in fury-org)
Install packages with older Bower (pre-1.5)
Your secret Repository URL
The secret repository URL is the Bower endpoint for package in your Gemfury account:
https://TOKEN@bower.fury.io/USERNAME/
Setting up Bower with Gemfury
To install your packages, you’ll need to configure Bower to access your Gemfury
repository by adding the following to your .bowerrc
file:
{
"registry": {
"search": [
"https://TOKEN@bower.fury.io/USERNAME/",
"https://bower.herokuapp.com:443"
]
}
}
Once this config is in place for your project, you can use regular Bower commands to install your private packages:
$ bower install <package>