Giter Site home page Giter Site logo

bower-npm-resolver's Introduction

bower-npm-resolver

Greenkeeper badge

Build Status

Get it on npm

A custom Bower resolver supporting installation of NPM packages. This resolver should be used if the package (or the version of the package you want to use) is not available on default resolvers (bower registry, github, etc.).

Installation

npm install -g bower-npm-resolver

Or, if you use bower locally:

npm install bower-npm-resolver

Configuration and usage

.bowerrc

Add the resolver in your .bowerrc file:

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

Usage

Once configured, your bower.json files may reference packages using npm: prefix:

{
  "dependencies": {
    "jquery": "npm:jquery#1.0.0",
    "lodash": "4.0.0"
  }
}

The resolver will match packages with npm: prefix. In the example above, jquery will be fetched from npm. lodash will not be matched by this resolver.

Note that you can also specify scope package:

{
  "dependencies": {
    "angular-core": "npm:@angular/core#~2.0.0"
  }
}

The resolver will download the scope package on npm and extract the tarball in the bower_components directory named [scope]-[name] (in the example above, scope is angular, name is core).

Alternative usage

As of v0.2.0, matching were made using npm+ prefix, such as:

{
  "dependencies": {
    "npm+jquery": "jquery",
    "lodash": "4.0.0"
  }
}

The resolver will match packages with npm+ prefix, and strip the prefix prior to fetching from npm repo. In the example above, jquery will be fetched from npm, lodash will not be matched by this resolver.

If this is not what you want, you can pass configuration parameters in .bowerrc.

If you use a private npm repository for all your company's packages, and they all start with a shared prefix, you can change the prefix:

{
  "resolvers": [
    "bower-npm-resolver"
  ],
  "bowerNpmResolver": {
    "matchPrefix": "mycompanynpmpackages-",
    "stripPrefix": false
  }
}

Then in your bower.json:

{
  "dependencies": {
    "mycompanynpmpackages-foobar": "1.0.0",
    "other": "1.0.0"
  }
}

In the example above, mycompanynpmpackages-foobar will be fetched from npm. other will not be matched by this resolver.

Features

This resolver will:

  • Use NPM commands to get the version (and the list of available versions) to download.
  • Download the tarball associated with the package and the version (you can see the tarball URL that will be used by typing: npm view pkg@version dist.tarball).
  • Use NPM proxy configuration to download the tarball.
  • Extract the tarball, this directory will be used by bower.

Notes

If the package you download on NPM does not contains bower.json, you will not get the transitive dependencies (and you will have to explicitly add then to your bower.json file).

License

MIT License (MIT)

Changelogs

  • 0.8.0
    • Fix an incompatibility with NPM >= 5.0.0
  • 0.7.0
    • Fix a bug with requireg module.
    • Remove cwd update side effect.
  • 0.6.0
    • Use global npm instead of local module.
  • 0.5.0
    • Fix a bug with temporary directory being removed between two downloads.
  • 0.4.0
    • Use npm pack command to download packages (using npm proxy settings).
  • 0.3.0
    • Use npm: prefix.
    • Support scope packages.
  • 0.2.0
    • Allow custom prefixes (instead of default npm+).
  • 0.1.0 - Initial release
    • Use npm+ prefix to match packages.

Contributing

If you find a bug or think about enhancement, feel free to contribute and submit an issue or a pull request.

To work in TDD mode, just run: npm run tdd.

Credits

Special thanks to @mhofman & @jakub-g for their contributions!

bower-npm-resolver's People

Contributors

arc311 avatar greenkeeper[bot] avatar jakub-g avatar mhofman avatar mjeanroy avatar nfriend avatar qlonik avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.