Git Product home page Git Product logo

one-version's Introduction

Release license: MIT Contributor Covenant Maintainer

@wayfair/one-version

One Version to rule them all, One Version to find them,

One Version to bring them all, and in the darkness bind them.1

Opinionated Monorepo Dependency Management CLI

🚨 Enforcement: Require all workspaces in a monorepo to conform to the One-Version rule.

📦 Supports multiple package managers: Support for yarn classic, yarn berry, and pnpm workspaces.

💥 Coordinated upgrades: Coming Soon!


Table Of Contents

One-Version Rule

This package implements a version of Google's One-Version Rule:

For every dependency in [a] repository, there must be only one version of that dependency to choose.2

Please refer to the implementation notes for our specific evaluation criteria.

There is some overlap between this tool and experimental yarn constraints, without requiring use of a particular package manager.

Getting Started

Install @wayfair/one-version at the workspace root using yarn:

yarn add --dev -w @wayfair/one-version

Or pnpm:

pnpm add -save-dev -w @wayfair/one-version

Add the following section to your package.json:

{
  "scripts": {
    "one-version:check": "one-version check"
  }
}

Run yarn one-version:check or pnpm run one-version:check.

If the repo is compliant, the tool will print this message:

✨ One Version Rule Success - found no version conflicts!

If the repo is not compliant, you will see a version of this message:

🚫 One Version Rule Failure - found multiple versions of the following dependencies:

prettier
  2.1.2
    dev: @wayfair/app-a, @wayfair/app-b
  ^2.3.2
    dev: @wayfair/app-c
  2.2.1
    dev: @wayfair/lib-a

Configuration

The behavior of @wayfair/one-version can be configured by a one-version.config.json at the root of the repository.

Supported Options

overrides (optional, object)

Overrides lets workspaces opt out of the one-version rule. This may be useful while performing major upgrades.

Examples

{
  "overrides": {
    "dependency": {
      "versionSpecifier": ["workspaceA", "workspaceB"]
    }
  }
}

For example, the below config will allow app-A and lib-L to specify react@^16.9, even if the rest of the repo specifies react@^17.

{
  "overrides": {
    "react": {
      "^16.9": ["app-A", "lib-L"]
    }
  }
}

Contributing

Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated 💜. For contributing guidelines, please see CONTRIBUTING.md

License

Distributed under the MIT License. See LICENSE for more information.


1: J.R.R. Tolkien, 1954. Mostly.

2: Software Engineering At Google - Winters, Manshreck and Wright, 2020, p. 341

one-version's People

Contributors

finn-orsini avatar erj826 avatar lelia avatar renovate[bot] avatar dependabot[bot] avatar helloitsjoe avatar michaelwclark 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.