4

Is there a way to set up a company-wide cache for pub.dev packages, without needing to mirror the entire pub.dev repo?

I've seen there is a community-contributed pub_mirror package. But that one downloads the entire pub.dev, which is complete overkill.

There seemed to be a pub_server package from Google itself, which has an example.dart that seemed to do what I want:

An experimental pub server based on a file system can be found in example/example.dart. It uses a filesystem-based PackageRepository for storing packages and has a read-only fallback to the real pub.dartlang.org site, if a package is not available locally. This allows one to use all pub.dartlang.org packages and have additional ones, on top of the publicly available packages, available only locally.

But that one is archived, experimental, and not contributed to anymore. So how do I cache pub packages company-wide then?

Thanks a lot for your help! :-)

mreichelt
  • 12,359
  • 6
  • 56
  • 70

1 Answers1

1

Only thing I can think of that comes close is this.

You can host your packages privately on GitHub and give everybody who needs them access.

Put something like this in your pubspec.yaml.

dependencies:
  kittens:
    git:
      url: git://github.com/munificent/kittens.git
      ref: some-branch
jeroen-meijer
  • 2,664
  • 2
  • 13
  • 16
  • 2
    Thanks for the reply! This seems to be a good solution for referencing private packages in our project. But what I actually meant: caching/mirroring *all* the packages referenced in every pubspec.yaml in our project - including the transitive ones. How can I solve that, without mirroring the whole pub.dev? – mreichelt May 27 '20 at 10:59