pub
pub copied to clipboard
"hosted" definition for all dependencies instead of PUB_HOSTED_URL env variable.
Could you add support for a hosted
field in root of pubspec.yaml
?
Similar to publish_to but this one would override default pub server for all dependencies (basically what PUB_HOSTED_URL
does, but only for one pubspec) ?
REASON:
In my usecase I need to get all dependencies from a private pub server (even the public ones).
I found only 2 ways to define a private/custom pub server for dependecies:
- define a
hosted
field for a dependency:
dependencies:
example:
hosted: https://some.other.pub
version: x.y.z
- define a
PUB_HOSTED_URL
env variable to override the default one (= pub.dev).
If I used 1.
then I would have to define hosted
for every dependency, which is tedious and therefore not a good solution. And if I used 2.
then I would override the default pub server for all projects on my system, therefore not a good solution.
I found a command direnv that allows me to define env variables for a directory. Using it I'm able to define PUB_HOSTED_URL
for projects that need it separatelly. BUT flutter plugin for AndroidStudio ignores env variables defined this way - so I would have to use terminal only, which is not good.
Please correct me if I'm wrong, but I didn't find any other solution. Are there any workarounds that I missed?
Yeah - it would be nice with more ergonomics around using third-party package repositories
Related issue: https://github.com/dart-lang/pub/issues/3518