npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@domestika/mono

v1.9.0

Published

Commit and release manager

Downloads

16

Readme

mono

Simple CLI for monorepo/multipackage.

mono is a tool that aims to simplify management for monorepo/multipackage projects but it also works with monopackage projects.

mono provides:

  • Commit template → mono commit
  • Release manager (parses commits to publish packages according to their changes) → mono check, mono release
  • Run commands inside each package → mono run npm install, mono run-parallel npm install

We use:

mono provides, among other things, a standard template for commit messages (mono commit) and is able to decide what needs to be released for you (mono check & mono release).

Installation

$ npm install @domestika/mono --save-dev

Usage

run command on all packages

You can run a single command on each package of the monorepo (each subfolder with its own package.json), in series

$ mono run <command>
$ mono run npx rimraf node_modules
$ mono run npm install

You can also run them in parallel

$ mono run-parallel <command>
$ mono run-parallel npx rimraf node_modules
$ mono run-parallel npm install

phoenix

To reset your project and all its contained packages.

mono phoenix

Equivalent to npx rimraf node_modules && npm i but it works on any environment and mono phoenix executes it concurrently on each package (and/or on your project root folder).

By default commands will be executed on chunks of 20 packages, but you can change it with -c, --chunk option:

mono phoenix -c 5

So, if executing many commands as the same time in your machine is too heavy, you can adjust it. You can also disable the chunks with 0 value and always execute all commands in parallel:

mono phoenix -c 0

If you don't want a fancy progress output (for instance in CI env), you can force a plain text output:

mono phoenix --no-progress

Reinstalls all scope packages but ignores the node_modules folder and package-lock.json file at the root level of your project

mono phoenix --no-root

Ables you to just reinstall the dependencies from a single scope

mono phoenix --no-root --scope atom/button

commit

You do your normal git workflow, but when commiting you should use:

mono commit

It will prompt you with questions regarding your changes and will generate a standard commit message for you

commit-all commit for all contained packages

You can commit the same message for all packages that actually contained stageable files.

mono commit-all -t "feat" -m "Refactor of dependencies"

The precommit will be executed only for the first commit.

check & release

In order to release the steps are:

Preview what will be released

mono check

Release all the packages

mono release

In case you want to release a single package use the --scope param

mono release --scope "packages/test"

Your packages must implement script npm run build or npm run prepublish that will be executed before any release.

👉 mono creates a new MINOR version for the package only when fix, perf or feat commits are detected, and a new MAJOR version if there is some commit marked as BREAKING CHANGES. Otherwise (any other types of commits detected), no new version will be generated and nothing will be released

Automatic release (only CI)

In case you want to release via CI the --github-user --github-email and --github-token must be passed by like follows:

mono release --github-user [username] --github-email [user email] --github-token [TOKEN]

How to configure your project

First you need to install the @domestika/mono package in your project

npm i --save-dev @domestika/mono

Then, you can configure your package.json to suit your needs

mono allows you to configure some parts of its functioning, but it also defines a few defaults for convenience.

Here'domestikafull example of the options

"private": true,
"config": {
  "mono": {
    "access": "public",
    "packagesFolder": "test/components",
    "deepLevel": 2,
    "customScopes": [
      "cz-config",
      "check",
      "release"
    ]
  },
  "validate-commit-msg": {
    "types": "@domestika/mono/src/types"
  },
}

private

If you specify that your package is private ("private": true,), it will not get pushed to npm repository

access

By default packages will be published as restricted in npm. If you want them to be public you will need to set "access": "public"

Scope (packagesFolder, deepLevel, customScopes)

👉 Setting the proper scope in the commit message is important, because this is used for mono check and mono release to assign changes to specific packages and release them to the proper packages

We provide a simple tool to automate the way the scopes are retrieved. If you follow a structure where do you have:

  • a main folder and
  • inside this folder you have all the packages (subfolders, each one of them with its own package.jsonscopes)

...this configuration will work for you

In order to specify the main folder you need to provide packagesFolder by default its value is src By default we check only 1 level inside the main folder, but if you have categories for each package and inside the packages you can configure deepLevel

This information will be used for releases and commitizen scopes.

Examples

Project Example

So, if you have a project like this:

src/
  i18n/
  users/
  search/
  ...

The default options will give you a list of scopes like this one for your commit:

i18n
users
search
Case studio

In the case of studio, which generates a folder like this one:

components/
 ads/
  big/
  small/
 card/
  featured/
  normal/

If you set the configuration of your project like this:

"packagesFolder": "components"
"deepLevel": 2

You will have a list of scopes like this one when performing a commit:

ads/big
ads/small
card/featured
card/normal

Manual scopes

There may be cases that you may want to add scopes for informative purposes but not related in any way with the releases

Take in care that this scopes will not be relevant for the release, and if you commit to one package that has his own scope, but you use a custom scope, a release will not be generated. Custom scopes are for a very rare cases and you may not need it most of the times.

Use customScopes in this cases like in the example. The scopes will be added to the automatically generated ones.