Skip to content

Allow publishing with uncommitted changes in working tree #1581

Closed

Description

@ovidiuch

This might be a feature request, but I'm no longer able to use Lerna in react-cosmos since this check has been introduced.

$ lerna publish --no-git-tag-version --no-push --npm-tag=next
lerna notice cli v3.1.1
lerna ERR! EUNCOMMIT Working tree has uncommitted changes, please commit or remove changes before continuing.

Here are the publishing steps I follow:

  • Context: In our monorepo all packages point to src by default
  • Before publishing, a custom script builds all packages and changes entry points to dist
  • Publish to npm via Lerna --no-git-tag-version --no-push (with uncommitted changes) --- Except this doesn't work anymore
  • Run custom script to point packages to src again (clean working tree)
  • Git commit and push via Lerna version

Is there a way to keep maintaining this flow with the latest API (v3.1.1.)? Maybe an option to skip the clean working tree check?

Feel free to propose alternative workflows that meet this criteria: Code published slightly differs from code pushed to git repo (ie. code published points to dist while code versioned points to src).


PS: I appreciate all the work you've put into making v3 solid!

Is there any blog post or changelog entry where I can read about all the changes from v2 to v3, to understand the migration better?

Activity

  1. evocateur commented on Aug 19, 2018

    @evocateur
    Member

    You should use the root npm script lifecycle prepublishOnly to build all packages and modify the entries, then use a root postpublish to reset them. You can then allow lerna to do the git commit/tag/push, which now always happens before any npm publish is called.

    I really should write a blog post on that subject...

  2. ovidiuch commented on Aug 19, 2018

    @ovidiuch
    Author

    A blog post on this would be great. Do you know any public repo that does something similar to get inspiration from? Thanks!

  3. evocateur commented on Aug 19, 2018

    @evocateur
    Member

    It's a little odd that you consider it necessary to modify the main property like this in the first place. Set to "dist" in the first place, it shouldn't need to change if you're properly building all the packages from the root.

  4. ovidiuch commented on Aug 19, 2018

    @ovidiuch
    Author

    It's a little odd that you consider it necessary to modify the main property like this in the first place.

    It's a bit different. The main property is set to index.js. But inside index.js there are some require calls that point to either src or dist, transformed by a customed script. Same concept, though.

    Set to "dist" in the first place, it shouldn't need to change if you're properly building all the packages from the root.

    The reason why paths point to src by default is for Flow types to... flow across packages in development, and for test coverage to be calculated properly from integration tests (locally and in CI).

    Not sure what you mean by "properly building all the packages from the root".

  5. evocateur commented on Aug 19, 2018

    @evocateur
    Member
  6. djskinner commented on Aug 21, 2018

    @djskinner

    Also having issues with the new uncommitted changes check. The problem is that we generate a .npmrc file on CI with the relevant credentials (we don't want committed to source control).

  7. djskinner commented on Aug 21, 2018

    @djskinner

    This little known feature of git did the trick for us: git update-index --assume-unchanged .npmrc

  8. evocateur commented on Aug 21, 2018

    @evocateur
    Member

    Or just add it to the .gitignore, like a normal file you want to ignore?

  9. djskinner commented on Aug 21, 2018

    @djskinner

    Yeah that would also work in my case since the committed version will rarely change. Not ideal for package file though. The approach of modularising everything is great. I’m amazed how many different approaches there are to version, release and publish.

  10. ovidiuch commented on Aug 28, 2018

    @ovidiuch
    Author

    I worked around this constraint by publishing files exactly as they are versioned. The exact solution is specific to Cosmos and can be found here: react-cosmos/react-cosmos#823

    If it's not a desireable feature to "allow publishing with uncommitted changes in working tree" then feel free to close this issue. At the moment I'm good.

  11. lock commented on Dec 27, 2018

    @lock

    This thread has been automatically locked because there has not been any recent activity after it was closed. Please open a new issue for related bugs.

  12. locked as resolved and limited conversation to collaborators on Dec 27, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions