swift-dependency-graph
swift-dependency-graph copied to clipboard
Use for local and private packages
This is a great project! I was looking for exactly this tool but for generating a graph of local dependencies on a private repo.
It seems dependencies are of type String which has to be a valid URL. How about extending it and support all types of dependencies?
E.g.
.package(name: "APIClient", path: "../APIClient")
It wouldn't break the primary intend of using it on https://swiftpackageindex.com, but could as well be run locally on private repos.
@timstudt I'm ready to accept a PR if you want to implement.
will try my best
+1!
I'll investigate the complexity to implement this. @adam-fowler any leads/pointers would be highly appreciated 😊
@rogerluan First thing you'll need to do it support loading private repos. Currently the url load is basic GET without any authentication. You'll need to add authentication details here if you want to access private repos.
Then you'll need to support the loading of both local filesystem packages as well as ones found on GitHub/gitlab. Looking at the package dependency type PackageDependencyDescription in the SPM code it looks like you check if the requirement is set to .localPackage to identify a local package.
This is really two different tasks
- private repo access
- local package parsing
So if you do some of this work, please separate it out into 2 PRs cheers
Thanks for the tips @adam-fowler ! I agree it makes sense to separate in two different PRs 👍 I'll see what I can do 😊
sorry, I got a bit stuck with this, and then put it on hold..
maybe it's easier to start with local packages w/o having to deal with authentication. if I run it locally on a project, I assume I have access to other local packages (e.g. .package(name: "APIClient", path: "../APIClient"))
-> check for .localPackage then read file from local path.
the PackageLoader's func load(url: String, packages: Packages) needs to be extended to handle local package files
like
} else if /* is local package */ {
let data = try Data(contentsOf: URL(fileURLWithPath: url))
... // parse file
@timstudt Yeah I don't know how the authentication works you'd need to spend some time with the GitHub documentation for that. Local packages should be easier. What you describe above seems about right.