nimble icon indicating copy to clipboard operation
nimble copied to clipboard

[POC] Implement 'nimble depsTree'

Open yyoncho opened this issue 1 year ago • 3 comments

I am open on suggestion for better/different representation of the tree. Once we agree on the format, I will update the documentation and add tests

Here it is sample output for langserver project

nimlangserver
  nim >= 1.0.0
  asynctools #non-blocking(resolved 0.1.1)
    nim >= 0.19.4
  json_rpc #notif-changes(resolved 0.0.2)
    nim >= 1.2.0
    stew@any(resolved 0.1.0)
      nim >= 1.2.0
    nimcrypto@any(resolved 0.5.4)
      nim > 0.18.0
    stint@any(resolved 0.0.1)
      nim >= 0.19
      stew@any(resolved 0.1.0)
        nim >= 1.2.0
    chronos@any(resolved 3.0.11)
      nim > 1.2.0
      stew@any(resolved 0.1.0)
        nim >= 1.2.0
      bearssl@any(resolved 0.1.5)
        nim >= 1.2.0
        unittest2@any(resolved 0.0.4)
          nim >= 0.19.4
      httputils@any(resolved 0.3.0)
        nim >= 0.17.3
        stew@any(resolved 0.1.0)
          nim >= 1.2.0
      unittest2 #head(resolved 0.0.4)
        nim >= 0.19.4
    httputils@any(resolved 0.3.0)
      nim >= 0.17.3
      stew@any(resolved 0.1.0)
        nim >= 1.2.0
    chronicles@any(resolved 0.10.2)
      nim >= 1.2.0
      testutils@any(resolved 0.5.0)
        nim >= 1.2.0
        unittest2@any(resolved 0.0.4)
          nim >= 0.19.4
      json_serialization@any(resolved 0.1.0)
        nim >= 0.17.0
        serialization@any(resolved 0.1.0)
          nim >= 1.2.0
          faststreams@any(resolved 0.3.0)
            nim >= 1.2.0
            stew@any(resolved 0.1.0)
              nim >= 1.2.0
            testutils@any(resolved 0.5.0)
              nim >= 1.2.0
              unittest2@any(resolved 0.0.4)
                nim >= 0.19.4
            chronos@any(resolved 3.0.11)
              nim > 1.2.0
              stew@any(resolved 0.1.0)
                nim >= 1.2.0
              bearssl@any(resolved 0.1.5)
                nim >= 1.2.0
                unittest2@any(resolved 0.0.4)
                  nim >= 0.19.4
              httputils@any(resolved 0.3.0)
                nim >= 0.17.3
                stew@any(resolved 0.1.0)
                  nim >= 1.2.0
              unittest2 #head(resolved 0.0.4)
                nim >= 0.19.4
            unittest2@any(resolved 0.0.4)
              nim >= 0.19.4
          unittest2@any(resolved 0.0.4)
            nim >= 0.19.4
          stew@any(resolved 0.1.0)
            nim >= 1.2.0
        stew@any(resolved 0.1.0)
          nim >= 1.2.0
    news #status(resolved 0.5)
      nim >= 0.19.0
    websock@any(resolved 0.1.0)
      nim >= 1.2.0
      chronos >= 3.0.0(resolved 3.0.11)
        nim > 1.2.0
        stew@any(resolved 0.1.0)
          nim >= 1.2.0
        bearssl@any(resolved 0.1.5)
          nim >= 1.2.0
          unittest2@any(resolved 0.0.4)
            nim >= 0.19.4
        httputils@any(resolved 0.3.0)
          nim >= 0.17.3
          stew@any(resolved 0.1.0)
            nim >= 1.2.0
        unittest2 #head(resolved 0.0.4)
          nim >= 0.19.4
      httputils >= 0.2.0(resolved 0.3.0)
        nim >= 0.17.3
        stew@any(resolved 0.1.0)
          nim >= 1.2.0
      chronicles >= 0.10.2(resolved 0.10.2)
        nim >= 1.2.0
        testutils@any(resolved 0.5.0)
          nim >= 1.2.0
          unittest2@any(resolved 0.0.4)
            nim >= 0.19.4
        json_serialization@any(resolved 0.1.0)
          nim >= 0.17.0
          serialization@any(resolved 0.1.0)
            nim >= 1.2.0
            faststreams@any(resolved 0.3.0)
              nim >= 1.2.0
              stew@any(resolved 0.1.0)
                nim >= 1.2.0
              testutils@any(resolved 0.5.0)
                nim >= 1.2.0
                unittest2@any(resolved 0.0.4)
                  nim >= 0.19.4
              chronos@any(resolved 3.0.11)
                nim > 1.2.0
                stew@any(resolved 0.1.0)
                  nim >= 1.2.0
                bearssl@any(resolved 0.1.5)
                  nim >= 1.2.0
                  unittest2@any(resolved 0.0.4)
                    nim >= 0.19.4
                httputils@any(resolved 0.3.0)
                  nim >= 0.17.3
                  stew@any(resolved 0.1.0)
                    nim >= 1.2.0
                unittest2 #head(resolved 0.0.4)
                  nim >= 0.19.4
              unittest2@any(resolved 0.0.4)
                nim >= 0.19.4
            unittest2@any(resolved 0.0.4)
              nim >= 0.19.4
            stew@any(resolved 0.1.0)
              nim >= 1.2.0
          stew@any(resolved 0.1.0)
            nim >= 1.2.0
      stew >= 0.1.0(resolved 0.1.0)
        nim >= 1.2.0
      nimcrypto@any(resolved 0.5.4)
        nim > 0.18.0
      bearssl@any(resolved 0.1.5)
        nim >= 1.2.0
        unittest2@any(resolved 0.0.4)
          nim >= 0.19.4
      zlib@any(resolved 0.1.0)
        nim >= 1.2.0
        stew >= 0.1.0(resolved 0.1.0)
          nim >= 1.2.0
    asynctools #non-blocking(resolved 0.1.1)
      nim >= 0.19.4
    faststreams@any(resolved 0.3.0)
      nim >= 1.2.0
      stew@any(resolved 0.1.0)
        nim >= 1.2.0
      testutils@any(resolved 0.5.0)
        nim >= 1.2.0
        unittest2@any(resolved 0.0.4)
          nim >= 0.19.4
      chronos@any(resolved 3.0.11)
        nim > 1.2.0
        stew@any(resolved 0.1.0)
          nim >= 1.2.0
        bearssl@any(resolved 0.1.5)
          nim >= 1.2.0
          unittest2@any(resolved 0.0.4)
            nim >= 0.19.4
        httputils@any(resolved 0.3.0)
          nim >= 0.17.3
          stew@any(resolved 0.1.0)
            nim >= 1.2.0
        unittest2 #head(resolved 0.0.4)
          nim >= 0.19.4
      unittest2@any(resolved 0.0.4)
        nim >= 0.19.4
    json_serialization@any(resolved 0.1.0)
      nim >= 0.17.0
      serialization@any(resolved 0.1.0)
        nim >= 1.2.0
        faststreams@any(resolved 0.3.0)
          nim >= 1.2.0
          stew@any(resolved 0.1.0)
            nim >= 1.2.0
          testutils@any(resolved 0.5.0)
            nim >= 1.2.0
            unittest2@any(resolved 0.0.4)
              nim >= 0.19.4
          chronos@any(resolved 3.0.11)
            nim > 1.2.0
            stew@any(resolved 0.1.0)
              nim >= 1.2.0
            bearssl@any(resolved 0.1.5)
              nim >= 1.2.0
              unittest2@any(resolved 0.0.4)
                nim >= 0.19.4
            httputils@any(resolved 0.3.0)
              nim >= 0.17.3
              stew@any(resolved 0.1.0)
                nim >= 1.2.0
            unittest2 #head(resolved 0.0.4)
              nim >= 0.19.4
          unittest2@any(resolved 0.0.4)
            nim >= 0.19.4
        unittest2@any(resolved 0.0.4)
          nim >= 0.19.4
        stew@any(resolved 0.1.0)
          nim >= 1.2.0
      stew@any(resolved 0.1.0)
        nim >= 1.2.0
  with@any(resolved 0.4.0)
    nim >= 0.19.0
  itertools@any(resolved 0.4.0)
    nim >= 0.18.0
  chronicles@any(resolved 0.10.2)
    nim >= 1.2.0
    testutils@any(resolved 0.5.0)
      nim >= 1.2.0
      unittest2@any(resolved 0.0.4)
        nim >= 0.19.4
    json_serialization@any(resolved 0.1.0)
      nim >= 0.17.0
      serialization@any(resolved 0.1.0)
        nim >= 1.2.0
        faststreams@any(resolved 0.3.0)
          nim >= 1.2.0
          stew@any(resolved 0.1.0)
            nim >= 1.2.0
          testutils@any(resolved 0.5.0)
            nim >= 1.2.0
            unittest2@any(resolved 0.0.4)
              nim >= 0.19.4
          chronos@any(resolved 3.0.11)
            nim > 1.2.0
            stew@any(resolved 0.1.0)
              nim >= 1.2.0
            bearssl@any(resolved 0.1.5)
              nim >= 1.2.0
              unittest2@any(resolved 0.0.4)
                nim >= 0.19.4
            httputils@any(resolved 0.3.0)
              nim >= 0.17.3
              stew@any(resolved 0.1.0)
                nim >= 1.2.0
            unittest2 #head(resolved 0.0.4)
              nim >= 0.19.4
          unittest2@any(resolved 0.0.4)
            nim >= 0.19.4
        unittest2@any(resolved 0.0.4)
          nim >= 0.19.4
        stew@any(resolved 0.1.0)
          nim >= 1.2.0
      stew@any(resolved 0.1.0)
        nim >= 1.2.0

yyoncho avatar Jul 25 '22 10:07 yyoncho

Output JSON?

Araq avatar Jul 25 '22 10:07 Araq

I am fine with using json. Something like that:

{
    "name": "foobar",
    "version": ">= 1.0",
    "resolvedTo": "1.1",
    "depedencies": [{
        "name": "foobar-dep",
        "version": ">= 1.0",
        "resolvedTo": "1.1",
        "error": "xx",
        "depedencies": [...]
    }]
}

we may include also the path to the download dir.

yyoncho avatar Jul 25 '22 10:07 yyoncho

DOT, and GraphML are other potentially interesting output formats.

zah avatar Jul 25 '22 15:07 zah

The previous format was a bit more human-friendly and I think it should be the default. Supporting an option like --format:json and possibly other formats in the future sounds like a good way to cater to all audiences.

zah avatar Aug 25 '22 20:08 zah

Also, @dom96 do you think we should use a shorter name for this (e.g. nimble deps)?

zah avatar Aug 25 '22 20:08 zah

Yeah, I prefer nimble deps.

dom96 avatar Aug 25 '22 21:08 dom96

@Araq WDYT about @zah's proposal: having the human-readable format as default and then at some point add machine-readable (json). ATM it seems like the primary use case is to run this command manually and inspect the output.

yyoncho avatar Aug 26 '22 15:08 yyoncho

I'm fine either way but I think the JSON is readable enough so that it could be the only supported format.

Araq avatar Aug 26 '22 15:08 Araq

The latest version of the code implements the --format: parameter and it looks like everyone is happy with this approach.

zah avatar Aug 30 '22 13:08 zah

Sure, looks good. Can we also put the source code into its own module before merging?

dom96 avatar Aug 30 '22 16:08 dom96

@dom96 it won't be simply putting the functions into a separate module - that would require restructuring the whole file. deps functionality uses processFreeDependencies which is nimble.nim which then uses dozens of functions from nimble.nim.

yyoncho avatar Aug 31 '22 10:08 yyoncho

I can put depsRecursive and printDepsHumanReadable

yyoncho avatar Aug 31 '22 10:08 yyoncho

I think keeping depsTree in there makes sense, Nimble should probably contain mostly procedures that take a Options object as input and then call out into different modules that implement the logic for each command. So if you could move the depsRecursive and printDepsHumanReadable procs to a module that would be perfect.

dom96 avatar Aug 31 '22 10:08 dom96