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-maven-resolver

v1.0.7

Published

Resolves Bower resources from a maven 3 repository; published under the Apache License 2.0

Downloads

8

Readme

Zero Wait-State

bower-maven-resolver

Allows you to serve Bower resources from a maven 3 repository. Unlike resolvers for specific repository implementations, bower-maven-resolver does not need to have any special plugins installed in the server to locate and fetch packages. This allows Bower packages deployed to a maven repository to be accessed anywhere in an enterprise for deployment or build.

The interactions with the repository are done without the use of the mvn command line utility. Only http and https maven repository protocols are supported.

Credentials can be pulled from the bower configuration, or alternatively from the local maven settings.xml. Placing the credentials in the settings.xml allows you to not have to publish the credentials for the repository in your source code.

Published under the Apache License 2.0.

Set Up your Project

  • Create your bower project, including specification of your bower.json

  • Install this resolver into your project

    npm install bower-maven-resolver --save-dev

  • Add an entry for bower-maven-resolver to your .bowerrc configuration file.

      {
        "resolvers": [
          "bower-maven-resolver"
        ]
      }
  • Add the dependency to your bower.json

    'maven3+http://myserver/hexus/repox/mygroup/myartifact' : '1.0.0'

Publishing

All of the files of your Bower package are archived into a single file, for example dist.tar.gz, and published into the maven repository (Nexus, Artifactory, etc). The format of the file that is uploaded to the repository must be either a gzipped tar package with a .tar.gz suffix or a zip file with a .zip suffix. This file is then published under a desired group ID, artifact ID, and version as any maven artifact would be.

  • Generate package of your project. Following is an example of creating this file assuming your build process puts files into a dist/ subdirectory in your project.

    cp file1 file2 ... dist/  # (i.e. putting the files into 'dist' directory)
    cd dist
    tar cvfz dist.tar.gz .

    Note: it is recommended NOT to name your package file 'package.tar.gz' or 'package.zip' so that, while cleaning up, you do not accidentally delete your package.json file.

    Note: you can probably also figure out a nifty way of getting your build process to create the dist.tar.gz file for you that will work across platforms. The above gives you the idea how it should work. Here is an example using Grunt.

    Note: an easier and more integrated way to create your distribution file and deploy it into your Maven respository is to use the grunt-maven-tasks plugin. The following example provides a Gruntfile.js excerpt showing how to generate a .tar.gz and .zip distribution using this plugin.

  • Deploy the archive file into maven repository

      mvn deploy:deploy-file \
       -DgroupId=myGroup -DartifactId=myArtifact -Dversion=1.0 \
       -Dfile=dist.tar.gz \
       -Durl=http://myserver/hexus/repox \
       -DrepositoryId=MY_REPO

    Presumably you're using maven and know how to get artifacts into it. You could use the command line given here, or deploy manually with the web client for your repository. For the short term, I use a quick and dirty shell script for this. Or use the grunt-maven-tasks plugin as shown in this example.

Accessing your Package with Bower

Now anywhere you need to build the project, you can do so independently of maven utilities.

git clone http://github.com/my-kewl-repo.git
npm install
bower install

And your package will be added to bower_components.

Configuration

Repository Authentication

The main configuration is for the authentication to the maven repository server. You can configure the credentials in one of two ways. Only username / password authentication is supported.

  1. First in order or precedence is to use the bower configuration. Include a maven section in your bower configuration:
  {
    config: {
      maven: {
          'http://myserver/hexus/repox/mygroup/myartifact/myversion': {
            username: 'myusername',
            password: 'mypassword'
          }
      }
    }
  }
  1. If there is no maven section in the configuration, bower-maven-resolver can also do some simple lookup in your maven configuration. It will look for a ~/.m2 directory, then a directory from M2_HOME environment variable, then a directory from MAVEN_HOME environment variable - in that order.

If a directory is found and contains a settings.xml file, settings.xml will be scanned for a settings.mirrors.mirror element with 'url' matching the URL of the bower package (just the URL to the repository: no maven3+ prefix should go in the settings.xml). If one is found, then the settings.servers.server with the matching ID is located to extract username and password sub-elements. See maven documentation for more information on how these should be configured. See the unit tests for an example of a settings.xml file that will work.