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.

JSON output for `lerna publish`

See original GitHub issue

Expected Behavior

When I run lerna publish, I would like to get a machine-readable output alongside the regular logging.

Current Behavior

There is no JSON output.

Possible Solution

lerna publish --summary-file lerna-publish.json

This would write the following to lerna-publish.json:

{
  "published": [
    { "name": "@scope/module-a", "version": "1.2.3", "tag": "latest" },
    { "name": "@scope/module-b", "version": "1.1.1", "tag": "latest" }
  ]
}

Context

The use case for this file is to kick off deployments in CI pipelines that depend on the packages that were just published.

Here is the horrible bash script that I want to kill! 🔥

lerna publish | tee lerna-output.log

# Extract published packages from the output log
published_packages=$(grep -A 1000 'Successfully published' lerna-output.log \
  | grep -e '^ - @[a-z]\+/' \
  | sed 's/^ - //' \
  | sed 's/@\([0-9].*\)$/ \1/'
)

while read -r module_name version; do
  echo "Do something with ${module_name}@${version}."
done <<< "${published_packages}"

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
azzcommented, Apr 24, 2019

Closing this as I’m happy enough with reading git tags. Feel free to re-open if you think there’s wider value.

1reaction
creatyvtypecommented, Mar 17, 2020

+1 to this. Also for CI and updating comments in PRs, trying to get a result of publishing beta versions right now requires ugly code to reduce the output of lerna publish into something meaningful.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Version and Publish - Lerna
json file at the root of your project under the version key. When you run lerna publish , if a module has been...
Read more >
@lerna/output - npm
An internal Lerna tool. Latest version: 6.0.1, last published: 13 days ago. Start using @lerna/output in your project by running `npm i ...
Read more >
Top 5 lerna Code Examples - Snyk
mkdirsSync(outputDir); const packages = lerna. ... function main(argv) { // For lerna publication to work, the NPM token must be stored in the...
Read more >
lerna/changed - NPM Package Overview - Socket.dev
The output of lerna changed is a list of packages that would be the subjects ... Note: lerna.json configuration for lerna publish and...
Read more >
Setting up a monorepo with Lerna for a TypeScript project
Also, create an npm organization so that you can publish the project ... This command will create a lerna.json file with a default...
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