question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[proposal] lerna publish with uncommitted changes

See original GitHub issue

Hi, I would like to propose a new option for lerna publish command, which would allow us to run lerna publish with uncommitted changes to the packages.

We need this behaviour for our benchmark test, where we publish all monorepo packages to temporary private registry, then install all these published packages to our skeleton web application. Then we build and run this web application and run simple performance tests to check, that we did not cause some critical performance issues. We run this test in CI and don’t want to push, or create any commits.

Pseudo Script

# Example Repository Structure
# packages/package-a
# packages/package-b
# packages/skeleton (private)
# package.json

# Benchmark Test Script
npm install
npx lerna version prerelease --no-push --no-commit-hooks --no-git-tag-version --allow-branch '*'
npx lerna publish from-package --registry "$PRIVATE_REGISTRY" --no-push --no-git-reset # + some option to ignore uncommitted changes error

# Prepare Skeleton Website
cd $WEB_APPLICATION_PATH
npm install --registry "$PRIVATE_REGISTRY"
npm run build
npm start &

# Run Test Against Our Website
autocannon localhost:3001

I found a solution to use git update-index --assume-unchanged ., that we could use in CI, but it seems a little bit dangerous and ugly and if somebody tries to run the script locally, it can have some horrible consequences.

I also tried to simply run lerna bootstrap to link all the packages together, but I ran into another issue with our gulp tasks package, which is used by skeleton web app. Since all the linked dependencies are just symlinks and can use only its own dependencies, it makes a problem when a gulp task requires some project file, which requires some project dependency, which is not a dependency of the gulp task package (I hope its understandable 😄 ). This could be solved by installing all the required packages as dev dependency also to the gulp task package, but it seems rather ugly solution. Also, it is more reliable test, if I try to install actually published packages, since this would also test correctly set dev/production dependencies.

I could not think of any other solution for our use case, but to create custom script to publish all the packages. But it seems unnecessarily complicated solution, because I would expect, that there should be some option for the lerna publish command, which would allow us to ignore uncommitted changes to the project.

Proposal

lerna publish --skip-check-working-tree

The option --skip-check-working-tree would skip the check-working-tree and the command would not fail, when there are some uncommitted changes in the project, when trying to publish the packages.

Another solution would be to attach this behaviour to --no-git-reset, but I am not sure, if I understand this option correctly.

Related Issues

#1581


Thank you for your attention and keep up the great work!

Filip

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:61
  • Comments:7

github_iconTop GitHub Comments

13reactions
diminutivesloopcommented, May 29, 2020

This would also be useful for our project where we want to enforce usage of an internal npm registry for package installs via .npmrc but we can’t commit .npmrc because npm login modifies it right before we run lerna publish. Alternatively lerna publish could support an --ignore option.

2reactions
ciobanudanncommented, Nov 24, 2021

This would also be useful for our project where we want to enforce usage of an internal npm registry for package installs via .npmrc but we can’t commit .npmrc because npm login modifies it right before we run lerna publish. Alternatively lerna publish could support an --ignore option.

You can just use this in you CI/CD
    - name: Setting Up NPM
      run: |
          npm set @organization:registry=https://npm.pkg.github.com/organization
          npm set "//npm.pkg.github.com/:_authToken=${{ secrets.GITHUB_TOKEN }}"
Read more comments on GitHub >

github_iconTop Results From Across the Web

Troubleshooting | Lerna
Failing when git tree has uncommitted changes​. You will receive fatal: ambiguous argument 'HEAD': error, when the current project has uncommitted changes.
Read more >
JavaScript Monorepos with Lerna - Semaphore CI
Publishing a package is a two-step process. First, Lerna pushes all the changes to the remote repository and creates a Git tag.
Read more >
How to ignore changed files when publishing with Lerna
You can use the --ignore-changes flag to prevent lerna from publishing new versions when it finds changes in specific file types.
Read more >
JS monorepos in prod 2: project versioning and publishing
The lerna publish command only publish packages with changes. It can go a step further by not taking into account changes in some...
Read more >
Bump version and publish packages from one branch but ...
Lerna's core developer says that Lerna doesn't suit well to work with Gitflow workflow. To say more, it's prohibited to publish packages ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found