wp-cli / dist-archive-command

Create a distribution .zip or .tar.gz based on a plugin or theme's .distignore file
https://developer.wordpress.org/cli/commands/dist-archive/
MIT License
48 stars 24 forks source link

Show the size of the file when it creates #100

Closed davidperezgar closed 1 month ago

davidperezgar commented 2 months ago

Feature Request

Show the size of the zip file after finished. That helps to know if you forget to ignore a big folder like node_modules or you'd like to optimize the size of the zip for several reasons.

Describe the solution you'd like It could be something like this: Success: Created plugin-1.0.0.zip Size: 1,2MB

or even without the word size: Success: Created 1,2MB plugin-1.0.0.zip

swissspidy commented 2 months ago

I like the idea 👍

I think we could add this with a debug line though, e.g.

$size = (int) filesize( $archive_absolute_filepath );
WP_CLI::debug( "File size: {$filesize}", 'dist-archive' );

It would need a util à la size_format() in core though. From what I can see, we have a similar util in db-command at the moment:

https://github.com/wp-cli/db-command/blob/4cce2d5c6b8daffcea5d21490f36fdcc5101a5b6/src/DB_Command.php#L1073-L1146

We could make that util reusable and move it to https://github.com/wp-cli/wp-cli/blob/a177d5aa6ca228b90eb553b710b96b8fabc14a81/php/utils.php

davidperezgar commented 2 months ago

Thanks! But I'd add without debug mode, as you can see when the zip is created.

ernilambar commented 2 months ago

Thanks! But I'd add without debug mode, as you can see when the zip is created.

I agree. Size of zip would be very useful information generating the zip.