dart-lang / pub

The pub command line tool
https://dart.dev/tools/pub/cmd
BSD 3-Clause "New" or "Revised" License
1.05k stars 230 forks source link

pub publish should respect nested .gitignore #3394

Open aeb-dev opened 2 years ago

aeb-dev commented 2 years ago

Environment

Problem

https://github.com/aeb-dev/flame_steamworks

I have created a simple desktop package with windows enabled. When I try to publish it, I get a package size error. The reason for the error is the files under example/windows/flutter/ephemeral. These files currently, automatically ignored for git, since when enabling windows the appropriate git ignore file is created (example/windows/.gitignore). The problem is pub does not respect that nested .gitignore files. Only the root .gitignore is respected.

Note that this is not related to example folder, I tested this also in a application with windows enabled, same thing happens.

If you need more information, happy to provide.

Expected behavior

pub should respect nested .gitignore. This could be not feasible/easy to do, in that case, when creating a package, .pubignore file should be created with default values known that should not go to the pub.dev

Actual behavior

The publish process failed, please check trace.

--trace output

Publishing flame_steamworks 0.2.0 to https://pub.dartlang.org: |-- CHANGELOG.md |-- LICENSE |-- README.md |-- analysis_options.yaml |-- example | |-- README.md | |-- analysis_options.yaml | |-- lib | | |-- game.dart | | '-- main.dart | |-- pubspec.yaml | |-- test | | '-- widget_test.dart | '-- windows | |-- CMakeLists.txt | |-- flutter | | |-- CMakeLists.txt | | |-- ephemeral | | | |-- cpp_client_wrapper | | | | |-- README | | | | |-- binary_messenger_impl.h | | | | |-- byte_buffer_streams.h | | | | | (5 more...) | | | | |-- plugin_registrar.cc | | | | |-- standard_codec.cc | | | | '-- texture_registrar_impl.h | | | |-- flutter_export.h | | | |-- flutter_messenger.h | | | | (6 more...) | | | |-- flutter_windows.h | | | |-- generated_config.cmake | | | '-- icudtl.dat | | |-- generated_plugin_registrant.cc | | |-- generated_plugin_registrant.h | | '-- generated_plugins.cmake | '-- runner | |-- CMakeLists.txt | |-- Runner.rc | |-- flutter_window.cpp | | (6 more...) | |-- utils.h | |-- win32_window.cpp | '-- win32_window.h |-- lib | |-- flame_steamworks.dart | '-- src | |-- has_steam_client.dart | '-- has_steam_server.dart |-- pubspec.yaml '-- test '-- flame_steamworks_test.dart

Publishing is forever; packages cannot be unpublished. Policy details are available at https://pub.dev/policy

Do you want to publish flame_steamworks 0.2.0 (y/N)? y Uploading... Uncompressed package archive is too large (size > 104857600). pub finished with exit code 1

JKRhb commented 2 years ago

I think it would nice in general if you could specify that you want to ignore files in addition to the ones listed in .gitignore files. I encountered a similar problem and including the contents of all .gitignore files in .pubignore is a bit tedious.

sigurdm commented 2 years ago

It should respect nested gitignores.

Can you try to create a minimal example.

sigurdm commented 2 years ago

I think it would nice in general if you could specify that you want to ignore files in addition to the ones listed in .gitignore files. I encountered a similar problem and including the contents of all .gitignore files in .pubignore is a bit tedious.

@JKRhb yeah - a bit tedious - not sure if its a big enough issue though. If you feel strongly about it, please open a new issue.

aeb-dev commented 2 years ago

You can use this: https://github.com/aeb-dev/flame_steamworks/tree/main/example

sigurdm commented 2 years ago

I get:

$ dart pub publish 
Publishing flame_steamworks 0.2.0 to https://pub.dartlang.org:
|-- CHANGELOG.md
|-- LICENSE
|-- README.md
|-- analysis_options.yaml
|-- lib
|   |-- flame_steamworks.dart
|   '-- src
|       |-- has_steam_client.dart
|       '-- has_steam_server.dart
|-- pubspec.yaml
'-- test
    '-- flame_steamworks_test.dart

Publishing is forever; packages cannot be unpublished.
Policy details are available at https://pub.dev/policy

Do you want to publish flame_steamworks 0.2.0 (y/N)? y

There is a .pubignore at the root ignoring the whole example folder.

If a folder is ignored, all ignores inside of it are also ignored. This is a bit confusing, but standard gitignore behavior:

Git doesn’t list excluded directories for performance reasons, so any patterns on contained files have no effect, no matter where they are defined.

aeb-dev commented 2 years ago

Step 1: Clone this repo: https://github.com/aeb-dev/dart_pub_gitignore_nested Step 2: Run example once Step 3: flutter pub publish --dry-run

sigurdm commented 2 years ago

Sorry - I don't have a windows machine with flutter ready - any chance you could try boiling this down to a minimal example?

aeb-dev commented 2 years ago

Here, extract the zip and put it under example. This is what step 2 does above. windows.zip