Dart 的 .pubignore 中应该忽略什么?

What should be ignored in Dart's .pubignore?

随着 Dart 2.14 版本的发布,pub 现在支持类似于 .gitignore.pubignore 文件。

文档似乎没有提到适合包含在其中的内容...有任何指南吗?

我的直接想法是我不应该包含测试,这些测试目前与我的包一起发布。可能还需要编译生产代码时不需要的其他与开发相关的东西?!

这是正确的吗?还有其他可以忽略的事情吗?

我在 dart pub 上工作,简短的回答是:大多数开发人员可能不需要使用 .pubignore

如果您有不想发布的本地文件(缓存或凭据),您可能也不想将它们提交给 git。所以在大多数情况下,简单地使用 .gitignore.

是最简单的

如果您不使用 git,或者您在 git 中有一些您想要的文件,但没有发布到 pub.dev, then .pubignore is useful. Maybe you have a private repository that includes files with proprietary code that is only used for development / testing, or something like that. Or maybe your repository includes huge data files used for testing, which hits the size limitations when publishing to pub.dev

大多数时候,如果您不介意制作一个文件 public,并且该文件与包有有意义的关系,那么我建议您包含它。 即使您的软件包的用户不太可能从 pub.dev and run tests, it is IMO nice that the tests are included. This makes the package more complete and self-contained. We could even imagine a future where tests from a package are analyzed on pub.dev.

下载它

我认为如果 Dart 团队认为在发布包时不应包含 test/ 中的文件,那么 Dart 团队应该修改 dart pub publish 命令默认不发布此类文件(或至少警告用户不要这样做)。