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

lerna-subtree-publish

v1.4.2

Published

tools to publish packages with lerna and git subtree

Downloads

12

Readme

Lerna-subtree-publish

What you need

For use in a lerna mono repository with the following set-up:

Usually every package is in a separate sub-repository configured as described here.

We also assume that you want to use the independent version schema for your lerna packages.

TODO:

  • [ ] Support sub-trees in local folders other than those of the form packages/name

What it does

The lerna-publish script from this module does the following:

  1. Runs the regular lerna publish command that

    • bumps version numbers of sub-packages,
    • tags the root mono-repository with git tags and
    • creates a changelog in changed packages if configured to do so.
  2. For each subtree repository in subtrees.json that has a new version number due to the current publish command:

    • Pushes the changes in this subtree repository to the remote repository.
    • Creates and pushes a tag with the version number to the remote repository. This way you have your versions tagged in GitHub, GitLab or wherever you host them.

How to use it

  • Add the package to the root of your mono repository:

    npm install -D lerna-subtree-publish git-subtree

    or with yarn

    yarn add -D lerna-subtree-publish git-subtree
  • Configure your subtrees.json and initialize the sub repositories

    ./node_modules/.bin/lerna-subtree init
  • Use ./node_modules/.bin/lerna-publish whenever you want to publish some of your changes in sub-tree repositories.

Creating and importing more packages

You can also add existing repositories with the command

./node_modules/.bin/lerna-import packageName --repository repositoryUrl

or create a new subtree-repository with the command

./node_modules/.bin/lerna-create packagename --repository
repositoryUrl

The latter command assumes that you can push to the repositoryUrl either because it will be created on push or because it hosts an empty repository.

Update the subtrees

lerna-subtree push pushes one or all subtree repositories. This skips all the lerna publish magic and can be used if you want to contribute upstream to a sub-repository without changing the package version.

lerna-subtree push pulls changes downstream from a sub-repository.

TODO:

  • [ ] If the version changes during a lerna-subtree pull operation, tags should be updated in the root repository.
  • [ ] lerna-subtree pull should enable to pull a specific version.

Troubleshooting

Missing tag error

You might get the following error when running lerna publish or lerna updated:

lerna ERR! initialize caught error
lerna ERR! Error: fatal: No tags can describe '72e520ee3e663694d92c21ac8cb3dfa0fa1b00fb'.
lerna ERR! Try --always, or create some tags.

This happens, as with git-subtree repositories, you are usually not importing all the tags from your sub-repositories. So, you simply have no git-tags at all in your root repository. Simply run

git tag v1.0.0

once and you are done.

Local tags in sub-tree repositories do not show up

This needs to be this way. Git does not allow multiple tags with the same name in one local repository. Therefore, git-subtree does not import the tags from your remote repositories as they might conflict, and lerna-subtree-publish deletes the tags locally after it pushes them to the remote repository.

However, the lerna publish command will create tags of the format [email protected] in the root repository. These tags only show up, if you create the versions with lerna.