swift-dependency-graph icon indicating copy to clipboard operation
swift-dependency-graph copied to clipboard

Use for local and private packages

Open timstudt opened this issue 4 years ago • 7 comments

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 avatar Jul 03 '21 12:07 timstudt

@timstudt I'm ready to accept a PR if you want to implement.

adam-fowler avatar Jul 04 '21 07:07 adam-fowler

will try my best

timstudt avatar Jul 05 '21 07:07 timstudt

+1!

I'll investigate the complexity to implement this. @adam-fowler any leads/pointers would be highly appreciated 😊

rogerluan avatar Aug 28 '21 17:08 rogerluan

@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

adam-fowler avatar Aug 29 '21 08:08 adam-fowler

Thanks for the tips @adam-fowler ! I agree it makes sense to separate in two different PRs 👍 I'll see what I can do 😊

rogerluan avatar Aug 29 '21 13:08 rogerluan

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 avatar Aug 30 '21 20:08 timstudt

@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.

adam-fowler avatar Aug 31 '21 07:08 adam-fowler