Skip to main content

A tool create a detailed CSV analyzing your project's dependencies

Project description

depster

Overview

This Python package converts a package-lock.json file into a CSV file containing detailed information about project dependencies, including their versions, integrity, and metadata. It also fetches the latest versions of the packages from the NPM registry.


Features

  • Parse JSON: Reads and processes package-lock.json into a structured DataFrame using Pandas.
  • Extract Key Information: Captures current version, integrity hash, requirements, and nested dependencies.
  • Check Dependencies: Identifies if a package has dependencies.
  • Fetch Latest Versions: Uses the NPM registry API to get the most recent version of each package.
  • Export to CSV: Outputs the cleaned and enriched data to package-lock.csv.

Prerequisites

Before running the script, ensure you have:

  1. Python 3.x installed.
  2. Required libraries:
    pip install pandas requests
    

How It Works

1. Load the JSON File

The script reads the package-lock.json file and parses it into a Pandas DataFrame for easy manipulation.

2. Clean and Prepare Data

  • Renames columns for better readability:
    • nameProject
    • versionCurrent Version
    • dependenciesdict
  • Adds new columns to store additional information:
    • Latest Version
    • Integrity
    • Requires
    • Dependencies
    • hasDependencies (boolean flag indicating whether a dependency has its own dependencies)

3. Process Dependency Information

Extracts and processes data from the dependencies dictionary:

  • Current Version: Retrieves the version of each package.
  • Integrity Hash: Captures the package's integrity value if available.
  • Nested Dependencies: Lists any nested dependencies along with their versions.
  • Required Versions: Lists required versions of dependencies.

4. Query NPM Registry

For each package, the script queries the NPM registry API (https://registry.npmjs.org/:package) to fetch the latest available version and populates the Latest Version column.

5. Export to CSV

The final DataFrame is saved as a CSV file named package-lock.csv.


Usage

  1. Run the script:
    depster path/to/package-lock.json
    

Output

Generated File

The output file, dependencies.csv, will be created in the same directory as the script.

Example Output

The resulting CSV file will include the following columns:

Packages Project Current Version Latest Version Integrity Requires Dependencies hasDependencies
1 Example1 1.0.0 1.2.0 abc123... dep1: ^1.0.0, dep2: dep3: 1.1.0, dep4: True

Notes

Performance Considerations

  • The script sends a separate request to the NPM registry for each package. This can slow down processing for projects with a large number of dependencies.
  • Optimization Suggestions:
    • Use bulk queries if supported by the API.
    • Implement caching for frequently queried packages.

Warning Suppression

  • Warnings are suppressed in the script for a cleaner execution log.

Limitations

  1. The script assumes a specific structure for the package-lock.json file.
  2. An active internet connection is required to fetch the latest package versions.

License

This project is open-source and available under the MIT License.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

depster-1.0.1.tar.gz (34.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

depster-1.0.1-py3-none-any.whl (8.6 kB view details)

Uploaded Python 3

File details

Details for the file depster-1.0.1.tar.gz.

File metadata

  • Download URL: depster-1.0.1.tar.gz
  • Upload date:
  • Size: 34.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.9.21

File hashes

Hashes for depster-1.0.1.tar.gz
Algorithm Hash digest
SHA256 5ae7370d31ed6edf428bc1df6b536b59da38dc6bc48d5a7fea56e5a2d0cd0768
MD5 9859d841bbbc5ee700d86233269936b9
BLAKE2b-256 623bb7be6e8709d6ac99a9bd57e2634088379ecf82fa27aa471ade0ab06700af

See more details on using hashes here.

File details

Details for the file depster-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: depster-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 8.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.9.21

File hashes

Hashes for depster-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 08a27f26c1c98ab925d4c6ab132619f567b022b8630ef8cfba69dbfa09186ad9
MD5 d710d3ec106425387d1d0221f69f51ae
BLAKE2b-256 60ad8f3d29973cb3d01f16fac0e728bf66240559575cdffa999b0695b8ec19d0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page