/merge-package-dependencies

Merge NPM or Bower package dependencies into one package, with semvar rules respected.

Primary LanguageJavaScriptMIT LicenseMIT

merge-package-dependencies

Branch Builds
master AppVeyor Build Status Travis Build Status
develop AppVeyor Build Status Travis Build Status

A simple tool that can merge the dependency and devDependency dependency types for npm/yarn package.jsons or bower bower.jsons into a single package.json or bower.json object (and optionally file). To properly support frontend scenarios, this tool also merges resolutions, and ignores unnecessary field recommendations for private npm/yarn packages. Perfect for projects like UserFrosting where plugins (Sprinkles) provide virtually all functionality.

NOTE: While non-semver values are supported, they will act as an override and emit a warning (even if logging is disabled). This override behavior only applies to 'incoming' values. This behavior does not match npm, yarn or bower.

NOTE: This is currently an offline tool, and as such conflicts further down the dependency chain are not evaluated. There is however a duplicate dependency detection tool for yarn to allow the creation of work arounds in the meantime (see docs/API.md)

NOTE: Any dependencies with a path specified as the version will not be adjusted, even if an output location is specified.

Installation

npm install @userfrosting/merge-package-dependencies --save-dev
yarn add @userfrosting/merge-package-dependencies --dev

Example

To merge multiple package.json's into a single object, and save to a specified location...

let mergePackages = require("@userfrosting/merge-package-dependencies");

let template = {
    name: "pkg",
    version: "1.7.2"
};
let pkgPaths = [
    "../app/sprinkles/core/",
    "../app/sprinkles/account/",
    "../app/sprinkles/admin/"
];

let result = mergePackages.yarn(template, pkgPaths, "../app/assets/");

API

See docs/API.md.

Contributing

Contributions are always welcomed, but:

  • Try to match the existing coding style.
  • New features and fixes must be covered by unit tests (if appropriate).

Its more work, but it greatly helps with flushing out bugs and keeping everything maintainable.