Giter VIP home page Giter VIP logo

nuget-deps-tree's Introduction

Test

NuGet Dependency Tree

This npm package reads the NuGet dependencies of a .NET project, and generates a dependency tree. This package was developed by JFrog, and is used by the JFrog VS-Code Extension to generate the dependency tree for projects using NuGet dependencies. You may use this package for other purposes and applications as well, either by running via command line or by importing to your project.

Installation

npm install -g nuget-deps-tree

Usage

Prerequisites

nuget (or nuget.exe) should be available in $PATH.

Command Line

nuget-deps-tree [path to sln file], it will print dependencies in json.

or

nuget-deps-tree --text [path to sln file], it will print dependencies in plain text as below:

plaintext

Project Dependency

import { NugetDepsTree } from 'nuget-deps-tree';
let tree = NugetDepsTree.generate(pathToSlnFile);

Tree Structure

{
  "projects": [
    {
      "name": "First.Project",
      "dependencies": [
        {
          "id": "dependency.One",
          "version": "1.0.0",
          "dependencies": [
            {
              "id": "dependency.Child",
              "version": "4.0.0",
              "dependencies": []
            }
          ]
        },
        {
          "id": "dependency.Two",
          "version": "2.0.0",
          "dependencies": []
        }
      ]
    },
    {
      "name": "Second.Project",
      "dependencies": [
        {
          "id": "dependency.Three",
          "version": "3.0.0",
          "dependencies": []
        }
      ]
    }
  ]
}

Building and Testing the Sources

Preconditions

  • npm 10 or above
  • Node 18 or above

To build the plugin sources, please follow these steps:

  • Clone the code from git.
  • Install and pack the nuget-deps-tree dependency locally, by running the following npm commands:
npm i && npm pack

If you'd like run the nuget-deps-tree tests, run the following command:

npm t

Pull requests

We welcome pull requests from the community.

Guidelines

  • If the existing tests do not already cover your changes, please add tests.
  • Please run npm run format for formatting the code before submitting the pull request.

nuget-deps-tree's People

Contributors

badsyntax avatar or-geva avatar robinino avatar tomerm12 avatar yahavi avatar younthu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

nuget-deps-tree's Issues

Unicode path to NuGet cache

Describe the bug
Seems this tools is not working when the NuGet cache path contains unicode symbols.

To Reproduce
Install the NuGet cache into a folder with unicode characters in the path.

Expected behavior
I expect it to work.

Screenshots
image

Versions

  • NuGet dependencies tree version: 0.2.2

Additional context
In the screenshot there are squares on the path, but the real path is not squares, it has Cyrillic letters.

Missing nuget.exe from pre-requisites

When running this on windows I was getting the folllowing output:

'locals' is not recognized as an internal or external command,
operable program or batch file.
{
  "projects": []
}

After much digging I found this was caused because I do not have nuget.exe available in any of the path locations

When you don't find mono or nuget on non-windows environments you display an error message saying what is missing, but there isn't anything similar for windows environments

It would probably be a good idea to list nuget.exe as a pre-requisite in the readme and it wouldn't hurt to add an error message similar to the non-windows environments.

Also of note is that nuget.exe is itself is not included with any version of Visual Studio and has to be downloded from https://www.nuget.org/downloads

Missing types

Describe the bug

When using TypeScript, NugetDepsTree.generate returns any.

Expected behavior

NugetDepsTree.generate should return Tree and I should be able to consume the Tree and Project types in my project.

Package Improvements

  1. Change the output tree structure:
    a. Replace the 'id' field of every level with the 'id' field from the 'dependency' struct.
    b. Remove the 'dependency' struct in every level.
    c. Make the naming of fields on every level of the tree the same (currently the 'dependencies' in the first level are later called 'direct dependencies'.
  2. Add an enhanced description on how to use the package output.
  3. Support running the package from the command line.
  4. Improve the tests coverage.
  5. Consider changing the handling of JSON objects if a suitable unmarshalling package is found (one that can unmarshall complex types like Map<string, M<string, CustomStruct>>).

Filter to hide/ignore some redundent dependencies

Is your feature request related to a problem? Please describe.
Trying to generate a tree for a set of large solutions, It can get to over 2mil lines of json mostly due to System.* and Microsoft.* dependency graphs. Those are really redundent most of the time, So it would be nice to have some kind of a filter to remove that noise out of the way.

Describe the solution you'd like to see
A filter argument, possibly regex or just a wildcard is enough as a start, that will determine where to "cut off" the dependency tree at. I.e., --ignore System.*|Microsoft.* will let me denoise my generated tree by orders of magnitude, i think.

Describe alternatives you've considered
None, Save writing a wrapper around the results and removing those sub-tree myself, But that seemed pointless.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.