mac Flutter 发布pub.dev 插件

准备

官方资料:https://dart.dev/tools/pub/publishing
Preparing to publish 之后有四点说明,必须需要一个google账号用来登陆pub.dev和发布认证,verified publisher可以不创建。

开发插件

android studio new flutter plugin 项目,会自动创建一个可以发布的插件,我开发的是一个叫sprite_chart折线图插件,功能开发完上传到github
执行

flutter packages pub publish --dry-run --server=https://pub.dartlang.org 
会出现让你在pubspec.yaml配置发布信息
name: sprite_chart
description: A new Flutter plugin.
version: 0.0.1
#author: 这个建议不用写了
homepage: https://github.com/xiake-chen/sprite_chart.git//项目github地址
成功后提示
Package has 0 warnings.
发布
flutter packages pub publish --server=https://pub.dartlang.org
成功的样子,第一次需要点击这个链接,做一次google 账户登陆认证。
Looks great! Are you ready to upload your package (y/n)? y
Pub needs your authorization to upload packages on your behalf.
In a web browser, go to https://accounts.google.com/o/oauth2/auth?access_type=offline&approval_prompt=force&response_type=code&client_id=818368855108-8grd2eg9tj9f38os6f1urbcvsq399u8n.apps.googleusercontent.com&redirect_uri=http%3A%2F%2Flocalhost%3A60995&scope=openid+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.email
Then click "Allow access".

Waiting for your authorization...
Authorization received, processing...
Successfully authorized.
Uploading...
Successfully uploaded package.

然后会在邮箱中收到一封发布成功的邮件

has published a new version (0.0.1) of the
sprite_chart package to the Dart package site (pub.dev).

For details, go to https://pub.dev/packages/sprite_chart/versions/0.0.1

If you have any concerns about this package, file an issue at
https://github.com/dart-lang/pub-dev/issues

Thanks for your contributions to the Dart community!

With appreciation, the Dart package site admin

遇到的问题

Waiting for your authorization...
Authorization received, processing...
。。。
pub finished with exit code 69

之后会报账户认证错误,发布之前验证终端能不能墙,

~%: curl  google.com

301 Moved

301 Moved

The document has moved here.

删除 国内代理配置
export PUB_HOSTED_URL=https://pub.flutter-io.cn
export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn

命令行翻墙工具:mac端可使用proxifier + ss
proxifier配置教程:http://blackwolfsec.cc/2016/09/19/Proxifier_Shadowshocks/
我的是https

企业微信截图_a7b7fd45-ff9b-49ea-80ee-beaa309053ae.png

参考:https://juejin.im/post/6844903886923235342#heading-10

你可能感兴趣的:(mac Flutter 发布pub.dev 插件)