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.jsoninto 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
dependencies.csv.
Prerequisites
Before running the script, ensure you have:
- Python 3.x installed.
- 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:
name→Projectversion→Current Versiondependencies→dict
- Adds new columns to store additional information:
Latest VersionIntegrityRequiresDependencieshasDependencies(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 dependencies.csv.
Usage
- 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.
Warning Suppression
- Warnings are suppressed in the script for a cleaner execution log.
Limitations
- The script assumes a specific structure for the
package-lock.jsonfile. - An active internet connection is required to fetch the latest package versions.
License
This project is open-source and available under the MIT License.
Metadata
Release files for depster 1.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| depster-1.1.1.tar.gz | 34.8 kB | Without provenance | Details for depster-1.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| depster-1.1.1-py3-none-any.whl | Python 3 | none | any | Details for depster-1.1.1-py3-none-any.whl |
Total release size: 43.4 kB
Release files / depster-1.1.1.tar.gz
| Download URL | depster-1.1.1.tar.gz |
|---|---|
| Size | 34.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4308b4fd4e89181a9ccd769029f465930c15b82992a05dd1494172b009dac79b
|
|
BLAKE2b-256 checksum How to use checksums |
b32dbe80044fccf87f4667942eda41d5385464d397402004e5105747c43634a3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.9.21
|
Release files / depster-1.1.1-py3-none-any.whl
| Download URL | depster-1.1.1-py3-none-any.whl |
|---|---|
| Size | 8.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b9e255d89823a09142be96786621f6556896f72bc40667171773cbd15da60024
|
|
BLAKE2b-256 checksum How to use checksums |
39635dc86e595c748b7667b2f911c6ffa3697d5a28cd7ac7826f8741d482d237
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.9.21
|
Security for depster 1.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.