npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

bower-nexus-resolver

v0.4.0

Published

Almost a Nexus Bower resolver

Downloads

8

Readme

bower-nexus-resolver

Important

If you are using NEXUS 3, please consider using the official bower-nexus3-resolver

Problematic

Nexus 2.x does not integrate Bower. Bower 1.5 offers pluggable resolvers which could make it possible.

The future Nexus behavior should mimic the default bower registry behavior.

For nexus to properly integrate Bower, it needs to respond some JSON info to this URL:

http://<domain>/nexus/content/repositories/<bower-repo>/packages/<package-name>

This JSON should be formed as (url below is a suggestion)

{
  "name" : "angular",
  "url" : "nexus://angular/angular"
}

Thus bower, thanks to the resolver, can recognise it's talking to a Nexus registry.

Today, Nexus doesn't implement this functionality, so we need to fake it with a fake server. Any server responding some JSON is fine. I recommend express.

You will also need to add in the .bowerrc a new entry nexusRegistry which is the URL of your Nexus registry. The default registry key is taken by your fake express server.

A typical .bowerrc would be

{
  "directory": "bower_components",
  "registry": "http://localhost:8082/nexus-bower/",
  "nexusRegistry": "http://localhost:8081/nexus/content/repositories/my-bower-repository/",
  "resolvers": [
    "bower-nexus-resolver"
  ]
}

Installation

npm install -g bower-nexus-resolver

In order to use Bower with Nexus you need:

  1. bower - Bower version 1.5.0 and above: npm install -g bower
  2. bower-nexus-resolver: npm install -g bower-nexus-resolver (if bower is installed globally)
  3. express - To mimic default repo responses

Client Configuration

Edit your ~/.bowerrc and add Nexus Bower Resolver

{
  "resolvers": [
    "bower-nexus-resolver"
  ]
}

You will need an interface between Nexus and this resolver. Since Nexus doesn't implement bower registry features, you need to mimic it. To do so, create a node.js (or whatever else) server that respond a JSON like (example with angular):

{
  "name":"angular",
  "url":"nexus://angular/angular"
}

to a request like http://<YOUR_SERVER>/<SOME_REPO_NAME>/packages/<PACKAGE-NAME>.

Minic the bower registry response

This example depends on express to create the server.

var express = require('express'),
    json = require('express-json'),
    http = require('http'),

    config = {
      port: 8082,
      context: 'nexus-bower',
      prefix: 'nexus://'
    },

    app = express(),
    server = http.createServer(app).listen( process.env.PORT || config.port);

app.use( json() );

// wait for a request as: 
// http://<hostname>/<context>/packages/<package-name> 
// respond a simple JSON 
app.get('/' + config.context + '/packages/:name', function(req, res){
    res.json({
        "name": req.params.name,
        "url": config.prefix + req.params.name + '/' +req.params.name
    });
});

console.log("STARTUP:: Express Bower registry simulator server listening on port::", server.address().port, ", environment:: ", app.settings.env);

Once, done, edit your ~/.bowerrc and point the registry to your brand new server

{
  "registry": "`http://<YOUR_SERVER>/<SOME_REPO_NAME>/"
}

Then tell bower the real URL of your Nexus npm repository

{
  "nexusRegistry": "http://<domain>/nexus/content/repositories/<npm-repo>"
}

Nexus Configuring

NPM remote repository for bower components

  1. Simply create a new npm repository
  2. Run the node.js server that respond JSON

Usage

Use the client to install packages from Nexus, e.g. bower install bootstrap