A simple TypeScript library that extracts dependency URLs from various package managers in Git repositories.
-
Python (Pip): handles Python projects with
requirements.txtfiles. It extracts package info from thePyPIAPI. -
Ruby (Gems): handles Ruby projects with
Gemfilefiles. It extracts package info from theRubyGemsAPI. -
JavaScript (NPM): handles JavaScript projects with
package.jsonfiles. It extracts package info from theNPMAPI. -
.NET (NuGet): handles .NET projects with
*.csprojfiles. It extracts package info from theNuGetAPI. -
Rust (Cargo): handles Rust projects with
Cargo.tomlfiles. It extracts package info from theCratesAPI. -
Java (Maven): handles Java projects with
pom.xmlfiles. It extracts package info fromMavenCentral Repository.
Install the package via npm:
npm install git-dep-urlHere's a basic example of how to use the library:
import { DepUrlExtractor } from 'git-dep-url';
const depUrlExtractor = new DepUrlExtractor();
(async () => {
const dependencies = await depUrlExtractor.discoverUrls('https://github.com/your-project.git');
console.log(JSON.stringify(dependencies, null, 2));
})();Example response:
{
"npm": [
{
"name": "dependency-1",
"urls": {
"packageUrl": "https://www.npmjs.com/package/dependency-1",
"repoUrl": "https://github.com/user/dependency-1"
}
},
{
"name": "dependency-2",
"urls": {
"packageUrl": "https://www.npmjs.com/package/dependency-2",
"repoUrl": "https://github.com/user/dependency-2"
}
}
],
"nuget": [
{
"name": "SomeNuGetPackage",
"urls": {
"packageUrl": "https://www.nuget.org/packages/SomeNuGetPackage",
"repoUrl": "https://github.com/user/SomeNuGetPackage"
}
}
]
}The API is pretty simple:
The DepUrlExtractor class exposes a
discoverUrls(gitUrl: string): Promise<PackageManagerDependencies>method that fetches and returns the dependency information from a Git repository.
Feel free to contribute by submitting pull requests or opening issues. Any feedback is appreciated!
This project is licensed under the Apache License 2.0.