Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Publish] Using a custom tagVersionPrefix, lerna publish fails to identify publish-able packages. #2195

Closed
darkobits opened this issue Jul 23, 2019 · 4 comments · May be fixed by adamlaska/scatter-js#3

Comments

@darkobits
Copy link

Expected Behavior

lerna publish from-git using a custom tagVersionPrefix (in my case, something with a / in it, like foo/v) correctly identifies packages that need to be published.

Note: I am not sure, at this time, if the / in the tag prefix is the culprit or if merely using any tagVersionPrefix is sufficient to trigger this behavior.

Current Behavior

lerna publish from-git using a custom tagVersionPrefix indicates that there are no packages that need to be published.

Possible Solution

I have been able to trace this issue back to this line in get-current-tags.js that makes a call out to npm-package-arg. When using the default tag prefix of v, this call returns the expected result and the publish command proceeds as expected.

However, npm-package-arg seems to think that non-standard tags (ie: ones using a custom tag prefix) are invalid, and returns an object with an undefined name property, causing the publish command to incorrectly report that there are no packages eligible for publishing.

If npm-package-arg is unable to parse tags with custom prefixes, perhaps it is not a suitable fit for Lerna.

Steps to Reproduce (for bugs)

  1. Set the same tagVersionPrefix option for the version and publish commands in lerna.json or use the same --tag-version-prefix flag when executing lerna version and lerna publish below.

  2. With 1 or more commits representing changes to at least 1 package, run lerna version. Lerna should correctly create a new tagged commit using the desired tag prefix.

  3. Running lerna publish from-git reports the following:

    lerna notice cli v3.16.2
    lerna notice from-git No tagged release found
    lerna success No changed packages to publish
    

If, however, the function containing the line referenced above is updated to return a standard v1.2.3-formatted string:

function listPackageNames(result) {
  return result.stdout
    .split("\n")
    .map(tag => {
      // return tag && npa(tag).name;

      // Return 'v' (the default prefix) + the version you're
      // intending to publish.
      return 'v1.2.4';
    })
    .filter(Boolean);
}

... then lerna publish works as expected.

lerna.json

{
  "version": "1.2.3",
  "packages": [
    "packages/*"
  ],
  "command": {
    "bootstrap": {
      "ci": false,
      "hoist": true
    },
    "version": {
      "message": "chore(release): %v",
      "conventionalCommits": true,
      "gitTagVersion": true,
      "push": false,
      "tagVersionPrefix": "foo/v"
    },
    "publish": {
      "verifyAccess": false,
      "gitTagVersion": false,
      "push": false,
      "tagVersionPrefix": "foo/v"
    }
  }
}

Context

I am currently unable to publish packages in a repository where custom tagVersionPrefix-es are used.

Your Environment

Executable Version
lerna --version 3.16.2
npm --version 6.10.1
node --version 10.16.0
OS Version
NAME VERSION
macOS Mojave 10.14.5
@evocateur
Copy link
Member

You've hit the nail on the head! Thanks for the clear explanation. This is definitely a bug.

@evocateur
Copy link
Member

Fixed in v3.16.3

@darkobits
Copy link
Author

Confirming this has been fixed in 3.16.3.

Thank you for the prompt reply+patch, Daniel! 💯

@evocateur
Copy link
Member

@darkobits I appreciate your well-written issue!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants