snyk / snyk-paket-parser

Other
2 stars 4 forks source link

Feat: Lockfile Parser #16

Closed justshiv closed 5 years ago

justshiv commented 5 years ago

What does this PR do?

Adds a parseLockfile function to parse the lockfile and returns a PaketLock of groups indexed by group name. Paket lockfiles are split into separable groups with different settings, restrictions & dependencies.

Example input to parseLockfile:

IMPORT-TARGETS: FALSE
FRAMEWORK: NET452
NUGET
  remote: https://api.nuget.org/v3/index.json
    FSharp.Charting (0.90.14)

Current example output:

{
  "main": {
    "name": "main",
    "repositories": {
      "NUGET": [
        "https://api.nuget.org/v3/index.json"
      ]
    },
    "dependencies": [
      {
        "name": "FSharp.Charting",
        "options": {},
        "version": "0.90.14",
        "group": "main",
        "remote": "https://api.nuget.org/v3/index.json",
        "repository": "NUGET",
        "dependencies": []
      }
    ],
    "options": {
      "import-targets": "false",
      "framework": "net452"
    }
  }
}

It also adds the skeletons of parse which will generate the full tree to return to our plugin. As this is yet to be built out and requires the inclusion of paket.dependencies I haven't added tests for this section.

justshiv commented 5 years ago

It was requested that we add any meta to the main PaketLock returned object as discussed here: https://github.com/snyk/snyk-paket-parser/pull/17#discussion_r255164278.

I have done this by indexing the main return object by groups and then added the meta to each group as the meta is group specific. If you have any suggestions on how you can further collect meta information to send on the root object and you can add it within the scope of this PR please do.

justshiv commented 5 years ago

I've found 2 fixtures that we don't handle well:

Kirill89 commented 5 years ago

Small optional notes:

CLAassistant commented 5 years ago

CLA assistant check
All committers have signed the CLA.

snyksec commented 5 years ago

:tada: This PR is included in version 1.2.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket: