1.0.0 • Published 2 years ago

@muraldevkit/ds-semrel-manager v1.0.0

Weekly downloads
-
License
https://www.mural...
Repository
-
Last release
2 years ago

Mural design system Semantic Release Dependency Manager

We use Semantic Release for version management and the package release workflow. This package ensures that the monorepo's packages are kept in sync with their current published version. When coding locally, you will see a wildcard (*) version in the package.json of each of the monorepo's packages. However, in production, each package.json will use the most recently published version instead.

Table of contents

  1. Prerequisites
  2. Usage
  3. How it works

Prerequisites

This package requires that you have a Semantic Release configuration setup. If you're configuration is a separate NPM package, it needs to be a peerDependency in the package.json file:

"peerDependencies": {
	"@muraldevkit/ds-semrel-config": "*"
}

Usage

In order to use this plugin, you will need to add it to your Semantic Release configuration and pass it an array of packages to maintain.

const plugins = [
	[
		'@muraldevkit/ds-semrel-manager', {
			wildcards: [
				'@muraldevkit/ds-component-button',
				'@muraldevkit/ds-semrel-config'
				// ... the rest of the packages you wish to manage
			]
		}
	]
];

If you are managing your monorepo with Lerna, we have also added a function that you can import into your configuration file to get all of the packages in your monorepo:

const { getLernaPackages } = require('@muraldevkit/ds-semrel-manager');

const plugins = [
	[
		'@muraldevkit/ds-semrel-manager', {
			wildcards: getLernaPackages()
		}
	]
];

Once this is configured, in each package.json file, you will want to change the dependency, devDependency, and peerDependency references of each monorepo sub-packages to a wildcard (*):

"dependencies": {
	"@muraldevkit/ds-component-button": "*"
	// ... your additional dependencies
},
"devDependencies": {
	"@muraldevkit/ds-utilities": "*"
	// ... your additional devDependencies
}

How it works

This plugin iterates over each package.json file in the monorepo and ensures that the configured packages are updated to their most recent version when we prepare to publish a release. When you use this plugin in your Semantic Release configuration, the prepare script is where all the magic happens. A basic summary of the steps in this function are as follows:

  1. It makes a couple of checks to make sure that the context and configuration are acceptable.
  2. Once everything is ready, it gets all of the releases (and thus tags) of the configured packages.
  3. It gets the package contents of each package in the monorepo to find wildcards.
  4. It updates the package.json to add the next release version.

Once the prepare script is finished, Semantic Release is ready to run!