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

mayan

v0.3.4

Published

Polyrepo helper tool to manage multiple repositories at once

Downloads

14

Readme

Mayan

npm downloads license

Mayan speeds up multi-repository workflows by providing commands that manage all repositories in the workspace at once. Compared to monorepos, Mayan fully embraces a poly-repository environment. It significantly reduces the overhead of adding changes to a large number of repositories and allows for a more streamlined workflow.

Mayan is specifically designed for NPM packaged projects. Mayan currently relies on NPM Workspace for linking (Yarn support to come).

NB! Currently, mayan does not yet calculate the dependency graph for the workspace, so it will not recursively version up affected packages. Therefore, NPM package versioning and publishing should still be done manually.

Table of contents

Installation

npm install -g mayan

Setup

1. Set up .mayan.js

Define your repositories in .mayan.js in the root of your workspace

module.exports = {
    repositories: [
        // Microservice applications in apps/
        {
            url: "[email protected]:example-org-name/example-microservice-name.git",
            branch: "main",
            path: "apps/microservice-service"
        },

        // Shared package libraries in packages/
        {
            url: "[email protected]:example-org-name/example-package-name.git",
            branch: "main",
            path: "packages/package-name",
        }
    ]
}

| Property | Description | |---|---| | url | URL of the git repository | | branch | This is the branch that the repository will be checked out to when you run mayan init and mayan reset. This is usually main. | | path | Relative path to the repository. |

2. Set up package.json

In the workspace root: npm init

This will create a package.json file in the root of your workspace. It is mainly used to define the "workspace" paths for npm linking by NPM Workspaces.

3. Clone repositories

mayan init

This will clone the repositories defined in .mayanrc.js into the directories defined in the path properties.

Commands

| Command | Description | |---|---| | help | Shows a list of all commands. | | add | Runs git add in all the repositories. Simple alias of mayan run 'git add' | | check [-a] | Checks the compatibility of dependencies compared to the local packages. Incompatible packages are unlinked, compatible packages are linked. If the package is red, it will be unlinked. If it is green or orange, it will be linked. | | checkout | Runs git checkout in all the repositories. Simple alias of mayan run 'git checkout' | | commit | Runs git commit in repositories with staged, unstaged and/or tracked changes. | | init | Initialises repositories defined in .mayanrc.js, populates "workspaces" and runs npm i in the root of the workspace. | | link | Refreshes the workspace root package.json "workspaces" value. | | list | Lists the projects. | | pull | Runs git pull in all the repositories. | | push | Runs git push in all the repositories which are ahead of the base branch at least with one commit. | | reset | Discards all changes (staged, unstaged and untracked) and resets to the latest base branch. | | run '<command>' | Runs the command in all repositories. Notice the upticks. | | status | Quick overview of the changed repositories. It will show you any repositories that are ahead of the base branch or that have uncommited changes. | | switch <branch-name> | Switches to the branch in all repositories. | | upgrade <package-name> | Upgrades the package in all repositories. Runs npm i package-name@<version> in all repositories dependent on the package. The <version> will match the value in the local workspace, but it will pull it from the remote registry. |

Usage

Starting a new feature branch

Implementing a feature is symmetric to git commands. A workflow example:

  1. mayan reset makes sure we have the latest changes and are on the base branch
  2. mayan checkout -b new-branch-name creates a new branch in all repositories
  3. Implement the required changes
  4. Commit the changes: mayan add . and mayan commit -m "Implement feature"
  5. Push the changes of the affected repositories: mayan push

Publishing the packages

mayan does not yet support a way to automatically publish all affected packages.

It is currently expected that you version and publish the packages manually with npm version and npm publish in the affected repositories.

Upgrading packages

Once the packages are upgraded with npm version major/minor/patch and published with npm publish, use:

mayan upgrade @org-name/package-name

This will update the version in all repositories that use the package to the version that is currently on your local machine.

Use:

mayan check

To check that all your repositories use the compatible package version. If not, they will show up either yellow or red with the required version numbers defined.

You can then use

  1. mayan add .
  2. mayan commit -m "Upgrade package"
  3. mayan push

To push the changes to all services.

Deploying services

It is expected that you use your own deployment flow to deploy the services. mayan does not restrict you to using a specific deployment flow and will not do so in the future.

Roadmap and issues

In no particular order

  • [ ] Support for -a in mayan commit -am "Commit message". When -a is detected, git commit will run in repositories that have unstaged changes, too.
  • [ ] Show unpushed commits in mayan status
  • [ ] mayan prune or similar to clean up unused branches and old merged branches.
  • [ ] mayan pull should not fail when remote is not tracked or when remote is already merged/deleted
  • [ ] mayan push should not push branch which has been deleted in remote
  • [ ] Migrate code to TypeScript for better code scaling
  • [ ] mayan reset should show the changes that are going to be discarded and ask the user for confirmation before continuing
  • [ ] mayan snap should create a snapshot of the current state of the workspace. This includes the branch state, stashed and unstanshed changes