dart/flutter 酒吧的 credentials.json 的新位置是什么

What's the new location of credentials.json for dart/flutter pub

我注意到在切换到 beta 通道(Flutter 2.9.0-0.1.pre)后,~/.pub-cache/credentials.json 不再存在。我使用这个文件来设置 CI 作业来部署我的 Flutter 包。它去哪儿了?

看起来它已移至以下位置:

On Linux:

  • If $XDG_CONFIG_HOME is defined:
    • $XDG_CONFIG_HOME/dart/pub-credentials.json
  • else
    • $HOME/.config/dart/pub-credentials.json

On Mac OS:

  • ~/Library/Application Support/dart/pub-credentials.json

On Windows:

  • %APPDATA%/dart/pub-credentials.json

(来源:dart-lang/pub#2999 - Do not store credentials in PUB_CACHE

(相关代码:https://github.com/dart-lang/cli_util/blob/master/lib/cli_util.dart#L88)


在 GitHub 操作中,定义了 $XDG_CONFIG_HOME,所以我执行以下操作:

- name: Prepare pub credentials
  run: echo '${{ secrets.PUB_CREDENTIALS }}' > "$XDG_CONFIG_HOME/dart/pub-credentials.json"