Pub: Can we ignore some files for publishing but include in the repo?

Created on 17 Jul 2020  路  8Comments  路  Source: dart-lang/pub

I'd like to leave some files in a package's repository on GitHub, but at the same time, make those files excluded when I publish a package on pub.dev.

The issue is that I'd like to add images or gifs to the README so that other developers immediately understand what the package is for. However, I don't want users of my package to have to download these images when they decide to add my package as a dependency.

Can we ignore some files for publishing but include in the repo?

enhancement

Most helpful comment

Is there any plans on supporting .pubignore or ingore: ["", ""] in pubspec?

I don't think it's a high priority for us at the moment. But if someone wants to work on it, I'll be happy to help define the feature, review and land it.

Otherwise, please upvote, and mention any novel use-cases you might have.

All 8 comments

I think we should have a .pubignore or similar file.
@jonasfj what do you think?

We already respect .gitignore I think, but I can see how that doesn't work here.

Other possible use-case in https://github.com/dart-lang/pub/issues/2222.

I imagine that if you have a .pubignore file, then we would not honor the .gitignore file.

It seems we can use git ls-files -X .pubignore --cached --others to interpret a .pubignore file.

That would however put a requirement on git - which might be acceptable if we still allow having no .pubignore file.

That would however put a requirement on git - which might be acceptable if we still allow having no .pubignore file.

External dependencies provided by the system, such as tar haven't exactly worked out well for us before, hehe

I suppose it works better for .gitignore, but ideally we would write this logic in Dart.

On the other hand, we can test if git is present, and we already use it.. so this might not be so bad..

ideally we would write this logic in Dart.

It is quite well specified: https://git-scm.com/docs/gitignore , but not trivial to implement.

Funnily enough we hardly ever get issues around our external dependency on git. I guess there is only one implementation that everybody shares.

Most of our tar issues seem to stem from the system tar being different for different systems.

Is there any plans on supporting .pubignore or ingore: ["", ""] in pubspec?
the suggested ways are just temporary workaround

like npm and package.json handles it.

Is there any plans on supporting .pubignore or ingore: ["", ""] in pubspec?

I don't think it's a high priority for us at the moment. But if someone wants to work on it, I'll be happy to help define the feature, review and land it.

Otherwise, please upvote, and mention any novel use-cases you might have.

Was this page helpful?
0 / 5 - 0 ratings