Git Product home page Git Product logo

smv's Introduction

SMV

Typed semantic versioner & diff module

Code quality Coverage Greenkeeper badge CricleCi badge

npm version Open issues Types: TypeScript License: MIT

Main features

  • tiny & easy to use: 1 powerful merge method, rest is plain old semver
  • returns descriptive merge conflict details
  • 1 dependency (for dist)
  • Typescript types included
  • exposes esm/cjs modules
  • always 100% test coverage

Guide

Installation

npm install --save smv

or

yarn add smv

or

pnpm --save smv

Basic usage

Doing it semver-style

SMV is a typed replacement for semver package as it proxies all semver-like methods to the semver. Full list of supported methods can be found on the semver github page.

const SMV = require('[email protected]').SMV;
const smv = new SMV();

const major = smv.major('1.2.3');
console.log('major', major);

const equal = smv.eq('1.2.3', '2.3.4');
console.log('equal?', equal);

const greater = smv.gt('1.2.3', '2.3.4');
console.log('greater?', greater);

const lower = smv.ltr('1.2.3', '^1.3.4');
console.log('lower than range?', lower);

Dependency merge

With SMV you can resolve dependencies from multiple sources.

Imagine how you would programmatically merge devDependencies from few package.json files?

const SMV = require('[email protected]').SMV;
const smv = new SMV();

const sourceA = {
    packageA: '1.2.3',
    packageB: '1.2.3',
    packageC: '0.0.1',
}
const sourceB = {
    packageA: '1.2.3',
    packageB: '1.2.3'
}

const digest = smv.merge({sourceA, sourceB});

console.log('Has conflicts?', digest.hasConflicts);
console.log('Final result', digest.result);
console.log('Conflicts', digest.conflicts);
console.log('Resolved digest', digest.resolved);

Un-conflicting dependencies are easy - you can deal with them using basic JS techniques.

How about conflicting dependencies?

const SMV = require('[email protected]').SMV;
const smv = new SMV();

const sourceA = {
    packageA: '1.2.3',
    packageB: '^1.2.3',
    packageC: '0.0.1',
}
const sourceB = {
    packageA: '1.2.3',
    packageB: '1.0.3'
}

const digest = smv.merge({sourceA, sourceB});

console.log('Has conflicts?', digest.hasConflicts);
console.log('Final result', digest.result);
console.log('Conflicts', digest.conflicts);
console.log('Resolved digest', digest.resolved);

Advanced usage

Forced dependency merge

There are situations when you don't want to waste time resolving conflicts. SMV allows you to enforce recommended versions (from resolved digest) as a final result.

const SMV = require('[email protected]').SMV;
const smv = new SMV();

const sourceA = {
    packageA: '1.2.3',
    packageB: '^1.2.3',
    packageC: '0.0.1',
}
const sourceB = {
    packageA: '1.2.3',
    packageB: '1.0.3'
}

// notice 2nd param passed to the merge method - thats forceRecommended flag
const digest = smv.merge({sourceA, sourceB}, true);

console.log('Has conflicts?', digest.hasConflicts);
console.log('Final result', digest.result);
console.log('Conflicts', digest.conflicts);
console.log('Resolved digest', digest.resolved);

Documentation

Full API documentation for this package can be found here

smv's People

Contributors

greenkeeper[bot] avatar thefill avatar

Watchers

 avatar

smv's Issues

[DepShield] (CVSS 7.4) Vulnerability due to usage of lodash.sortby:4.7.0

Vulnerabilities

DepShield reports that this application's usage of lodash.sortby:4.7.0 results in the following vulnerability(s):


Occurrences

lodash.sortby:4.7.0 is a transitive dependency introduced by the following direct dependency(s):

jest:24.8.0
        └─ jest-cli:24.8.0
              └─ jest-config:24.8.0
                    └─ jest-environment-jsdom:24.8.0
                          └─ jsdom:11.12.0
                                └─ data-urls:1.1.0
                                      └─ whatwg-url:7.0.0
                                            └─ lodash.sortby:4.7.0
                                └─ whatwg-url:6.5.0
                                      └─ lodash.sortby:4.7.0

This is an automated GitHub Issue created by Sonatype DepShield. Details on managing GitHub Apps, including DepShield, are available for personal and organization accounts. Please submit questions or feedback about DepShield to the Sonatype DepShield Community.

[DepShield] (CVSS 7.5) Vulnerability due to usage of debug:2.6.9

Vulnerabilities

DepShield reports that this application's usage of debug:2.6.9 results in the following vulnerability(s):


Occurrences

debug:2.6.9 is a transitive dependency introduced by the following direct dependency(s):

jest:24.8.0
        └─ jest-cli:24.8.0
              └─ @jest/core:24.8.0
                    └─ micromatch:3.1.10
                          └─ extglob:2.0.4
                                └─ expand-brackets:2.1.4
                                      └─ debug:2.6.9
                          └─ snapdragon:0.8.2
                                └─ debug:2.6.9

npm-watch:0.6.0
        └─ nodemon:1.19.0
              └─ undefsafe:2.0.2
                    └─ debug:2.6.9

This is an automated GitHub Issue created by Sonatype DepShield. Details on managing GitHub Apps, including DepShield, are available for personal and organization accounts. Please submit questions or feedback about DepShield to the Sonatype DepShield Community.

[DepShield] (CVSS 7.5) Vulnerability due to usage of mocha:5.2.0

Vulnerabilities

DepShield reports that this application's usage of mocha:5.2.0 results in the following vulnerability(s):


Occurrences

mocha:5.2.0 is a transitive dependency introduced by the following direct dependency(s):

codacy-coverage:3.4.0
        └─ jacoco-parse:2.0.1
              └─ mocha:5.2.0

This is an automated GitHub Issue created by Sonatype DepShield. Details on managing GitHub Apps, including DepShield, are available for personal and organization accounts. Please submit questions or feedback about DepShield to the Sonatype DepShield Community.

[DepShield] (CVSS 7.5) Vulnerability due to usage of marked:0.4.0

Vulnerabilities

DepShield reports that this application's usage of marked:0.4.0 results in the following vulnerability(s):


Occurrences

marked:0.4.0 is a transitive dependency introduced by the following direct dependency(s):

typedoc:0.14.2
        └─ marked:0.4.0

This is an automated GitHub Issue created by Sonatype DepShield. Details on managing GitHub Apps, including DepShield, are available for personal and organization accounts. Please submit questions or feedback about DepShield to the Sonatype DepShield Community.

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.