Flutter Pub私有仓库搭建
目标
将自己的package/plugin推到私有pub仓库中。
关键步骤
完成该目标有两个关键步骤需要处理:
第一,部署pub_server服务端;
第二,去除pub publish命令中的google权限校验。
具体方法
1.部署pub_server
按照如下命令下载pub_server源代码,拉取依赖库后运行程序。
git clone https://github.com/dart-archive/pub_server.git
...
cd pub_server/
...
pub get
...
dart example/example.dart -d /tmp/package-db
因为pub_server是使用Dart语言编写,因此该服务的启动需要依赖dart环境,所以请先确保Dart运行环境已正确安装。
其中dart example/example.dart -d /tmp/package-db
命令中的/tmp/package-db
是存放上传package和plugin的地址,可以按照自己的要求确定。
当在终端中看到以下内容,说明pub_server运行正常:
Listening on http://localhost:8080
To make the pub client use this repository configure your shell via:
$ export PUB_HOSTED_URL=http://localhost:8080