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

@wmfs/lerna-sync

v1.30.0

Published

A package to synchronize distributed GitHub repos inside a Lerna monorepo.

Downloads

74

Readme

lerna-sync

CircleCI

A package to synchronize distributed GitHub repos inside a Lerna monorepo.

Use Case

If the following sounds familiar, then lerna-sync may be of interest:

  • You're building lots of Node.js packages.
  • You're using a Lerna monorepo to help manage all your packages.
  • You really need Lerna's ability to link together all your package dependencies.
  • But you're also missing all the things that distinct GitHub repos gave you:
    • Mixing private/public repos
    • A place for focused issues
    • Dedicated wikis
    • Simple commit histories
    • Custom build-shenanigans
    • Etc.

This is the situation lerna-sync is designed to help with. :smiley:

Install Lerna

You'll need to have Node.js installed and Lerna available globally:

npm install lerna -g

The monorepo husk

Create an empty husk of a Lerna Monorepo (our tymly repo is an example).

Some things:

  • Note that the directories you'd ordinarily expect Lerna packages to be living inside, are empty.
  • The lerna.json file is pretty basic stuff.

This is the the empty husk of your monorepo, it should be committed and pretty much forgotten about after this point.

GitHub Credentials

Lerna-sync will take-on the work to clone/pull your separate GitHub repos and keep them in-sync within your monorepo.

You'll need to provide some GitHub credentials to hand, namely:

  • Your GitHub username.
  • A GitHub Access Token associated with the provided username. Giving your token a description of "Lerna Sync Access" will be fine. This is necessary to avoid certain rate-limits and access private repos. Remember to keep tokens private and treat them as if they were passwords.
  • A name of a GitHub organization that your Lerna packages will be synchronized with (for example wmfs).

Routing function

You may have many GitHub repos in the organization you specify that shouldn't come anywhere near your monorepo. Also, you might like to take advantage of Lerna's support for multiple-package directories to help structure things a bit better.

In lerna-sync this filtering/routing can be achieved via a simple Javascript function. Here's an example:

// Here we use look at the keywords array in the repo's package.json
// to decide which monorepo package directory (if any) it should belong.

function (gitHubPackageObj) {
  // [string-in-keywords, monorepo-directory-name]
  const keywordToPackageMap = [
    ['package', 'packages'],
    ['plugin', 'plugins'],
    ['blueprint', 'blueprints'],
    ['cardscript', 'cardscript'],
    ['app', 'apps']
  ]
  if (gitHubPackageObj.hasOwnProperty('keywords') && gitHubPackageObj.keywords.indexOf('tymly') !== -1) {
    let lernaPackageName = null
    const keywords = gitHubPackageObj.keywords
    keywordToPackageMap.forEach(
      tuple => {
        if (keywords.indexOf(tuple[0]) !== -1) {
          lernaPackageName = tuple[1]
        }
      }
    )
    return lernaPackageName
  }
}

Lerna-sync will call this function with the package.json content (already parsed as a JavaScript object) of each repo in the source GitHub organization.

  • Any repos with no package.json will be skipped entirely due to not being a suitable candidate for a Lerna Monorepo.

The function should return the name of a directory registered in the packages array in the monorepo's lerna.json file.

  • If no value is returned by this function, then lerna-sync will know not to route the repo to any package directory (i.e. it's filtered out).

WIP

Environment variables

| Variable | Notes | | -------- | ----- | | LERNA_SYNC_MONOREPO_PATH | Should be set to a directory where a lerna.json can be found. | | LERNA_SYNC_GITHUB_TOKEN | Generate a new GitHub token here, a description of "lerna-sync connection" will do. | LERNA_SYNC_GITHUB_ORG | Name of the GitHub organization holding all your repos. | | LERNA_SYNC_GITHUB_USER | Your GitHub username (used in conjunction with LERNA_SYNC_GITHUB_TOKEN to fetch/pull repos. |

Installation

npm install @wmfs/lerna-sync --save

Usage

License

MIT