Giter VIP home page Giter VIP logo

requirey's Introduction

npm version Build Status Windows Build Status

Logo

Intelligent multi-version dependency management for npm packages.

Install

npm install --save requirey

Usage

  • Initialize

const ry = require('requirey')(config, options);

config - object of module names mapped to arrays of supported versions
options - extra options to override default behaviors like strict

Default behavior is strict mode enabled which will always use config to determine which versions can be installed and required

Strict mode will ignore version overrides for require calls

eg:

{
  "lodash": ['1.0.0', '2.1.2'],
  ...
}
  • Install

ry.installAll();

or

ry.install('lodash');
// or
ry.install('lodash', '1.0.0');
ry.install('lodash', '2.0.0');
  • Require

const requirer = new ry.Requirer(pkgJson);

requirer.require('lodash'); // ==> highest possible version supported
requirer.require('[email protected]'); // ==> version 1.0.0
requirer.require('lodash', '^2.0.0'); // ==> highest version in the range between 2.0.0 and 3.0.0
requirer.require('lodash', '~2.2.0'); // ==> highest version in the range between 2.2.0 to 2.3.0
requirer.require('lodash/fp/curry'); // ==> require sub-paths from auto-detected version
requirer.require('[email protected]/array/chunk'); // ==> require sub-paths from particular version

The require method also takes an optional third parameter:

force - boolean ==> Forces a require call for a particular version

requirer.require('lodash', '4.0.0', true);

Built Using

requirey's People

Contributors

debopamsengupta avatar matteofigus avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

Forkers

matteofigus

requirey's Issues

add License

I think we would be interested about using this in https://github.com/opentable/oc but we would need to ensure we have a compatible license for it. We go MIT for all the oc related stuff, would MIT be good for you too here? I can do a PR for that if you want

add windows support

For integrating requirey to https://github.com/opentable/oc we would need to ensure the tests run on windows too. For OC, we use appveyor, which is free for open source, and allows to run all the tests in a windows platform too. Would you be in favour of integrating something like that here too?

Make installs and requires stricter

Right now, it is possible to initialize requirey with an empty config like

const ry = require('requirey')();

and install any module

ry.install('react') //will install react@latest

also, it's possible to force a require call to a version like

new ry.Requirer().require('react', 'latest', true) //using the {force} param

It might be a good idea to have a strict mode where all installs and requires must follow the initial config which becomes the single source of truth

Question: install automatically skips the install if dep already installed?

The main reason I ask, is that I know npm by default, is able to perform a quicker operation during npm install if the dep is already installed.

Is requirey able to do the same?

The reason I ask, is I would like to use requirey for OC. I think the integration there will include a step, during the registry start, to install the deps, but I also think we'll develop a step to perform a install separately (as a post npm install step for your registry app) - so that the install step should just be quick and the registry able to start quicker (useful for when developing multiple instances with a docker container that already contains the installed dependencies).

Allow config to have both "module" or [modules]

We would like to use this module both for a config that supports for each module an array or a specific version (for both "classic" installs or "multi" installs).

Example:

const ry = require('requirey')({ lodash: '3.4.5' });
const ry2 = require('requirey')({ lodash: ['1.2.3', '4.5.6'] });

ry.installAll();
ry2.installAll();

const l3 = require('lodash');
const l1 = ry2.require('lodash@1');
const l4 = ry2.require('lodash@4');

If it's ok, we can make a PR

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.