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
47 stars 23 forks source link

Version only read from plugins, not from theme's `style.css` #50

Closed kraftner closed 2 years ago

kraftner commented 2 years ago

Bug Report

Describe the current, buggy behavior

The command currently only parses the version from PHP files, hence not getting the version of a theme in style.css hence not including it in the archive filename.

Describe how other contributors can replicate this bug

Run the dist-archive command on a theme

Describe what you would expect as the correct outcome

An archive that includes the theme version in the filename.

Let us know what environment you are running this on

> wp cli info
OS:     Linux 5.4.0-100-generic #113~18.04.1-Ubuntu SMP Mon Feb 7 15:02:59 UTC 2022 x86_64
Shell:  
PHP binary:     /usr/local/bin/php
PHP version:    7.4.28
php.ini used:   /usr/local/etc/php/php.ini
MySQL binary:   /usr/bin/mysql
MySQL version:  mysql  Ver 15.1 Distrib 10.5.12-MariaDB, for debian-linux-gnu (x86_64) using  EditLine wrapper
SQL modes:      
WP-CLI root dir:        /var/www/html/wp-content/themes/foo/vendor/wp-cli/wp-cli
WP-CLI vendor dir:      /var/www/html/wp-content/themes/foo/vendor
WP_CLI phar path:       
WP-CLI packages dir:    /home/wordpress/.wp-cli/packages/
WP-CLI global config:   
WP-CLI project config:  
WP-CLI version: 2.6.0

Provide a possible solution

This probably should also parse style.css, the regex could stay the same I suppose.

https://github.com/wp-cli/dist-archive-command/blob/d6d01445433c59b63f1a6b2bd60a14b62ff6948e/src/Dist_Archive_Command.php#L95-L102

Provide additional context/Screenshots

kraftner commented 2 years ago

Temporary workaround for others that hit this:

wp dist-archive . ./foo-$(wp theme get foo --field=version).zip

janw-me commented 2 years ago

A candidate for good-first-issue ?

danielpost commented 2 years ago

I'm working on this 👍🏼

kjohnson commented 2 years ago

Not seeing any updates since June (presumably WordCamp Europe), so I'm going to take a look.

kjohnson commented 2 years ago

Getting the version from the docblock is using token_get_all, which specifically produces PHP tokens.

Another method for getting a theme's version will be required.