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

@cdr0/polyrepo

v1.0.4

Published

The evil-opposite of monorepos, because almost all tooling assumes one github repo is one 'thing'.

Downloads

3

Readme

CDR0 polyrepo

The idea of monorepos is great, but it is swimming against the tide in today's software ecosystem. Virtually all tooling nowadays assumes that one Github repo holds one and only one 'thing'. So, polyrepo can give some of the benefits of monorepos, but still allow your repos to fit into the mold of one project per Github repo.

Incantations

Assuming you have @mygreat/library and @mygreat/app.

All the Repos Must be Siblings

dev will be the parent of all your repos:

cd
mkdir dev && cd $_
mkdir library
mkdir app

# ... Lots of other work to setup the repos.

In each repo, add polyrepo, and prepare the magic directory for your proxy scripts:

cd
cd library
npm i -S @cdr0/polyrepo
mkdir polyrepo

cd
cd app
npm i -S @cdr0/polyrepo
mkdir polyrepo
touch polyrepo/mygreat-library.js
touch polyrepo/mygreat-other-thing.js
# ... touch more libs / packages ...

cd
cd somewhereelse
# ... npm, mkdir, touch ...

# ... other repos as siblings of `library` and `app`

Each proxy file will look similar to these:

// app/polyrepo/mygreat-library.js

// Build the prequire (poly-require) function
const polyrepoRequire   = require('@cdr0/polyrepo')(__dirname);

// The proxy function.
const prequire  = function (name) {
  return polyrepoRequire(name) || require(name);
};

module.exports = prequire('@mygreat/library');
// app/polyrepo/mygreat-other-thing.js

// Build the prequire (poly-require) function
const polyrepoRequire   = require('@cdr0/polyrepo')(__dirname);

// The proxy function.
const prequire  = function (name) {
  return polyrepoRequire(name) || require(name);
};

module.exports = prequire('@mygreat/other-thing');

Then, to bring one into a file:

// app/index.js

const greatLibrary  = require('./polyrepo/mygreat-library');

When running on your development workstation, greatLibrary will be the repo that is a sibling to the app package, and will be the package from NPM otherwise.

Optional (Other Locations)

polyrepo will look at sibling directories by default. You can also define CDR0_POLYREPO_ROOT and point it to a directory that will be assumed to hold packages to look for.

export CDR0_POLYREPO_ROOT="$HOME/dev"

Some Work Required

polyrepo is a small project, so some of the work is left for the reader.

  • Create one .js file for each item in the multi-project-repo, in the <root>/polyrepo/ directory.
  • Require it instead of the general name.
  • Keep the entry in package.json for it, that's what will get pulled in outside your active-development environment.

Gotchas / Limitations

  • All of the repos must be checked out to sibling directories.
  • You must use the env var: CDR0_POLYREPO_ROOT to point to the parent directory.
  • You do not get bin linking for your development workstation.

TODO

  • [ ] Scripts to manage the .../polyrepo/ directory, and package.json
  • [ ] Scripts to allow installed packages' binaries to be called via the NPM scripts mechanism.
  • [ ] A mo-betta way to organize all of the repos on your development workstation.
  • [ ] Scripts to link bin items into your path.
  • [ ] Scripts to cross-link bin items