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

Tracking install progress with ndjson reporter #3822

Closed
1 task
zardoy opened this issue Oct 3, 2021 · 7 comments
Closed
1 task

Tracking install progress with ndjson reporter #3822

zardoy opened this issue Oct 3, 2021 · 7 comments

Comments

@zardoy
Copy link

zardoy commented Oct 3, 2021

Describe the user story

Required for integration with third-party tools. For example yarn support --json flag for installation command:

{"type":"info","data":"No lockfile found."}
{"type":"step","data":{"message":"Resolving packages","current":1,"total":4}}
{"type":"activityStart","data":{"id":0}}
{"type":"activityTick","data":{"id":0,"name":"@actions/core@^1.6.0"}}

The main purpose for my tool is to know the progress of specifc action (installation / removing etc)

Describe the solution you'd like

Implement --json flag for every command.

Describe the drawbacks of your solution

Probably maintainability.

Describe alternatives you've considered

No alternatives or workarounds.

@zardoy
Copy link
Author

zardoy commented Oct 3, 2021

Related #2705

@zkochan
Copy link
Member

zkochan commented Oct 10, 2021

What would you use it for?

Some commands already support --json. And some work with --reporter ndjson.

@zardoy
Copy link
Author

zardoy commented Oct 11, 2021

Sorry for delayed response!

What would you use it for?

I just want to build some kind of extension that would automatically run pnpm i whenever you change package.json in editor or open just cloned project.
The main thing that I want to implement is showing approximate progress of the process. As I can see it is currently not possible with the ndjson reporter.

Some commands already support --json. And some work with --reporter ndjson.

Indeed, my feature request was too wide. I actually wanted to request something similar to #139.

@zkochan
Copy link
Member

zkochan commented Oct 11, 2021

You can create a custom reporter that will consume the ndjson output.

@zardoy
Copy link
Author

zardoy commented Oct 11, 2021

However, can ndjson reporter report the progress (of the installation for example)? Here is the Yarn v1 reporter for example:

{"type":"progressStart","data":{"id":0,"total":109}}
{"type":"progressTick","data":{"id":0,"current":1}}
...
{"type":"progressTick","data":{"id":0,"current":109}}
{"type":"progressFinish","data":{"id":0}}

With these data given, I can easily display the progress bar. In case of pnpm, it outputs pnpm:progress event only with the package being fetched / found_in_store. I just realized that I can compare the number of processed packages with the requested one. I think this would be enough for me.

@zkochan
Copy link
Member

zkochan commented Oct 11, 2021

No, pnpm doesn't know the percentage because unlike Yarn, which has separate installation stages, pnpm does all stages at the same time (that is why it is so fast). So pnpm does not know how many packages it will download
pnpm:
image

Yarn:
image

@zardoy
Copy link
Author

zardoy commented Oct 11, 2021

Thank you for quick reposnse! I will update the title and body for visibility.

@zardoy zardoy closed this as completed Oct 11, 2021
@zardoy zardoy changed the title json parsable output with --json flag Tracking install progress with ndjson reporter Oct 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants