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

refactor(unstable): deno info --json output #7417

Merged
merged 20 commits into from
Sep 16, 2020

Conversation

bartossh
Copy link
Contributor

@bartossh bartossh commented Sep 10, 2020

Fixes #7379
Fixes #7491

@CLAassistant
Copy link

CLAassistant commented Sep 10, 2020

CLA assistant check
All committers have signed the CLA.

@bartossh
Copy link
Contributor Author

bartossh commented Sep 10, 2020

I will lint it asap and push fix.

@bartossh
Copy link
Contributor Author

I think "file:https://[WILDCARD]/subdir/mod1.ts" key is not matching properly, I will try to figure it out but if anyone have an idea of how to fix it I will appreciate it very much. thx

cli/info.rs Outdated Show resolved Hide resolved
@bartlomieju
Copy link
Member

I think "file:https://[WILDCARD]/subdir/mod1.ts" key is not matching properly, I will try to figure it out but if anyone have an idea of how to fix it I will appreciate it very much. thx

I think the problem is that files are not ordered. See #7417 (comment)

@bartossh
Copy link
Contributor Author

I have left deps field in ModuleDepInfo structure unchanged: here just in case its needed / will be needed. I marked to not serialize this field. It looks like deps is not used anywhere after this PR changes, so please let me know if I have to remove it.

cli/info.rs Outdated
#[serde(rename_all = "camelCase")]
struct FileInfoVertex {
size: usize,
total_size: Option<usize>,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't show total size of vertex in terminal output and I think we should skip it in JSON as well. It's useful to have total size of all dependencies in top level structure, but calculating sizes of subdependencies should be left to implementors. @lucacasonato WDYT?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup I agree

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bartossh let's remove total_size then. Otherwise LGTM and we can land this PR

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bartlomieju Curious about this. I requested the original feature and noticed that the total size of each dependency was left out in the end. I thought this a useful feature to see how big your dependencies were. Of course, you can compute this manually by running deno info against each dependency but that's a bit of a pain. I agree that these should be consistent, just curious about the reasoning behind leaving out the total size of dependencies.

Copy link
Contributor Author

@bartossh bartossh Sep 15, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have implemented the change for total_size that @bartlomieju and @lucacasonato agreed on, removing it from vertex of a flat graph, and added total_sizeto module info on the top level so only total size of module will be shown.
But if you think @cknight suggestion should be applied I will cherry pic previous implementation and push changes back again.

this will look like this

Thanks

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that these should be consistent, just curious about the reasoning behind leaving out the total size of dependencies.

Circular dependencies can be really confusing, especially if they show up multiple times. Showing only the size of singular dependency is what browsers do. If there will be huge demand for "total" size we can revisit the topic, but for now I think we should go only with size of the concrete module without it's deps.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @bartlomieju, makes sense

@bartlomieju bartlomieju changed the title deno info json flat graph refactor(unstable): deno info --json output Sep 14, 2020
cli/info.rs Outdated Show resolved Hide resolved
@@ -374,7 +430,7 @@ mod test {
}

#[test]
fn get_new_prefix_adds_a_vertial_bar_if_not_is_last() {
fn get_new_prefix_adds_a_vertical_bar_if_not_is_last() {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

spelling correction , not part of this feature

Copy link
Member

@bartlomieju bartlomieju left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thank you @bartossh

@bartlomieju
Copy link
Member

@bartossh could you fix #7491 in this PR as well? That should be a minimal change

@bartossh
Copy link
Contributor Author

bartossh commented Sep 15, 2020

After change It isn't causing the issue but not all dependencies are printed:

local: /home/bartossh/.cache/deno/deps/https/deno.land/46b808b8747ed75c4be741a37f6b10130ff7de51f37b58ee9b920d0a76aa6cf9
type: TypeScript
deps: 12 unique (total 63.31KB)
https://deno.land/[email protected]/http/server.ts (10.23KB)
├── https://deno.land/[email protected]/encoding/utf8.ts (433B)
├─┬ https://deno.land/[email protected]/io/bufio.ts (21.15KB)
│ ├── https://deno.land/[email protected]/bytes/mod.ts (4.34KB)
│ └── https://deno.land/[email protected]/_util/assert.ts (405B)
├── https://deno.land/[email protected]/_util/assert.ts *
├─┬ https://deno.land/[email protected]/async/mod.ts (202B)

It contains cyclic dependencies https://deno.land/std/http/server.ts redirected to https://deno.land/[email protected]/http/server.ts, so I suppose this should to be ended like so.

@bartossh
Copy link
Contributor Author

If submodule that main module is linking to contains cyclic dependencies, maybe the best way to handle the issue of not going in to a loop, is to return some informative message to the user and then end the print of a dependency tree in some nice way?

Shall We open an issue for this and sort it out in a new PR or shall I sort it out in this PR?

@bartlomieju
Copy link
Member

If submodule that main module is linking to contains cyclic dependencies, maybe the best way to handle the issue of not going in to a loop, is to return some informative message to the user and then end the print of a dependency tree in some nice way?

@bartossh this has already been handled in #6786

@bartossh
Copy link
Contributor Author

Yup. I wrote it being not specific enough. Sorry and thanks @bartlomieju for pointing this out for me with related PR example. As you see in the above example the dependency tree finishes in an ugly way. I can manage to solve this. I just have no idea what is the expected outcome.

@bartlomieju
Copy link
Member

Yup. I wrote it being not specific enough. Sorry and thanks @bartlomieju for pointing this out for me with related PR example. As you see in the above example the dependency tree finishes in an ugly way. I can manage to solve this. I just have no idea what is the expected outcome.

@bartossh it's unexpected that it stopped working - I have no problem to see whole dep tree in 1.4.0. I will investigate tomorrow.

@bartossh
Copy link
Contributor Author

@bartossh it's unexpected that it stopped working - I have no problem to see whole dep tree in 1.4.0. I will investigate tomorrow.

@bartlomieju it is my mistake. In the last example I have blindly copy pasted the command with | head, getting last 10 lines. 🤦 , It looks alright:

./deno info https://deno.land/[email protected]/http/server.ts
local: /home/bartossh/.cache/deno/deps/https/deno.land/46b808b8747ed75c4be741a37f6b10130ff7de51f37b58ee9b920d0a76aa6cf9
type: TypeScript
deps: 12 unique (total 63.31KB)
https://deno.land/[email protected]/http/server.ts (10.23KB)
├── https://deno.land/[email protected]/encoding/utf8.ts (433B)
├─┬ https://deno.land/[email protected]/io/bufio.ts (21.15KB)
│ ├── https://deno.land/[email protected]/bytes/mod.ts (4.34KB)
│ └── https://deno.land/[email protected]/_util/assert.ts (405B)
├── https://deno.land/[email protected]/_util/assert.ts *
├─┬ https://deno.land/[email protected]/async/mod.ts (202B)
│ ├── https://deno.land/[email protected]/async/deferred.ts (1.03KB)
│ ├── https://deno.land/[email protected]/async/delay.ts (279B)
│ ├─┬ https://deno.land/[email protected]/async/mux_async_iterator.ts (1.98KB)
│ │ └── https://deno.land/[email protected]/async/deferred.ts *
│ └── https://deno.land/[email protected]/async/pool.ts (1.58KB)
└─┬ https://deno.land/[email protected]/http/_io.ts (11.25KB)
  ├── https://deno.land/[email protected]/io/bufio.ts *
  ├─┬ https://deno.land/[email protected]/textproto/mod.ts (4.52KB)
  │ ├── https://deno.land/[email protected]/io/bufio.ts *
  │ ├── https://deno.land/[email protected]/bytes/mod.ts *
  │ └── https://deno.land/[email protected]/encoding/utf8.ts *
  ├── https://deno.land/[email protected]/_util/assert.ts *
  ├── https://deno.land/[email protected]/encoding/utf8.ts *
  ├── https://deno.land/[email protected]/http/server.ts *
  └── https://deno.land/[email protected]/http/http_status.ts (5.93KB)

Sorry for the confusion.

@bartlomieju
Copy link
Member

@bartossh no worries, glad it's not broken after all. I will review and land your PR today.

Copy link
Member

@bartlomieju bartlomieju left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thank you @bartossh

@bartlomieju bartlomieju merged commit 81ca709 into denoland:master Sep 16, 2020
@bartossh bartossh deleted the deno_info_json_flat_graph branch September 16, 2020 18:23
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 this pull request may close these issues.

deno info | head panics Change JSON output of "deno info" subcommand
5 participants