diff --git a/CHANGELOG.md b/CHANGELOG.md index 490f8a7..cb15fd1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,7 @@ system for each contributed module, theme and layout. - An implementation of Backdrop's telemetry function. - A config-clear command. - A new command to enable and disable the theme debug setting. +- A changelog command to display the current CHANGELOG for the installed version of Bee. ### Changed - Call the install script using the PHP_BINARY constant to avoid issues if the @@ -32,6 +33,7 @@ execute permissions have not been added to the file. - The Wiki is now edited via the `docs` folder of the main repo. Pages can be edited as part of a pull request. - Added 'context' of 'Bee' to any translatable strings passed to `t()`. - Moved 'theme' commands and tests from 'projects' to dedicated files. +- Changed the version command to include the latest "Unreleased" date for dev versions. ### Fixed - Unhandled Error if the executables called in the database commands does diff --git a/box.json b/box.json index 214d820..d15447c 100644 --- a/box.json +++ b/box.json @@ -3,6 +3,9 @@ "commands", "includes" ], + "files": [ + "CHANGELOG.md" + ], "compactors": [ "KevinGH\\Box\\Compactor\\Php" ], diff --git a/commands/version.bee.inc b/commands/version.bee.inc index ca3756d..d3e3c7a 100644 --- a/commands/version.bee.inc +++ b/commands/version.bee.inc @@ -4,6 +4,11 @@ * The command for displaying the current version of Bee. */ +/** + * Define the path for the CHANGELOG. + */ +define('BEE_CHANGELOG_PATH', __DIR__ . '/../CHANGELOG.md'); + /** * Implements hook_bee_command(). */ @@ -17,16 +22,48 @@ function version_bee_command() { 'bee version' => bt('Output the current version.'), ), ), + 'changelog' => array( + 'description' => bt('Display the current CHANGELOG of Bee.'), + 'callback' => 'changelog_bee_callback', + 'group' => 'information', + 'examples' => array( + 'bee changelog' => bt('Output the current CHANGELOG.'), + ), + ), ); } /** - * Command callback: Run cron. + * Command callback: Version. */ function version_bee_callback($arguments, $options) { $current_version = BEE_VERSION; $latest_release = BEE_LATEST_RELEASE; + // If the version is the dev version, then we also want the date of the last + // change. + $dev_version = FALSE; + // Current version will only match latest release for the actual release + // packages so any difference will indicate the dev version is in use. + if ($current_version != $latest_release) { + $dev_version = TRUE; + // Get the CHANGELOG lines as an array so we can check each line. + $changelog_lines = file(BEE_CHANGELOG_PATH); + // Define the search string to identify the line. + $search_string = "## [Unreleased] - "; + // Loop through each line and look for the search string. + foreach ($changelog_lines as $line) { + if (strpos($line, $search_string) !== FALSE) { + // Extract the latest date from this line. + $unreleased_date = substr($line, 18, 10); + // Append it to the current version. + $current_version .= ' - ' . $unreleased_date; + // Stop processing more lines. + break; + } + } + } + $output = array(); $output[] = array( 'type' => 'text', @@ -48,3 +85,10 @@ function version_bee_callback($arguments, $options) { ); return $output; } + +/** + * Command callback: Changelog. + */ +function changelog_bee_callback($arguments, $options) { + echo file_get_contents(BEE_CHANGELOG_PATH); +}