From cf75e8f10bbd7edc60c9500931bc01b15c8fad30 Mon Sep 17 00:00:00 2001 From: Deepa Date: Fri, 16 Nov 2018 11:05:52 +0530 Subject: [PATCH] Task #37 fix: Update extension version and date --- build/bump.php | 400 ++++++++++++++++++ src/com_tjnotifications/tjnotifications.xml | 6 +- .../tjnotification/tjnotification.php | 14 +- .../tjnotification/tjnotification.xml | 8 +- .../privacy/tjnotification/tjnotification.php | 16 +- .../privacy/tjnotification/tjnotification.xml | 6 +- 6 files changed, 425 insertions(+), 25 deletions(-) create mode 100644 build/bump.php diff --git a/build/bump.php b/build/bump.php new file mode 100644 index 00000000..5db2fc0c --- /dev/null +++ b/build/bump.php @@ -0,0 +1,400 @@ + -c + * + * Examples: + * - php build/bump.php -v 3.6.0-dev + * - php build/bump.php -v 3.6.0-beta1 + * - php build/bump.php -v 3.6.0-beta1-dev + * - php build/bump.php -v 3.6.0-beta2 + * - php build/bump.php -v 3.6.0-rc1 + * - php build/bump.php -v 3.6.0 + * - php build/bump.php -v 3.6.0 -c Unicorn + * - php build/bump.php -v 3.6.0 -c "Custom Codename" + * - /usr/bin/php /path/to/joomla-cms/build/bump.php -v 3.7.0 + * + * @package Techjoomla.Build + * + * @author Techjoomla + * @copyright Copyright (C) 2015 - 2018 Techjoomla. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +/** + * Display the use of command + * + * @param string $command The command name + * + * @return void + */ +function usage($command) +{ + echo PHP_EOL; + echo 'Usage: php ' . $command . ' [options]' . PHP_EOL; + echo PHP_TAB . '[options]:' . PHP_EOL; + echo PHP_TAB . PHP_TAB . '-v :' . PHP_TAB . 'Version (ex: 3.6.0-dev, 3.6.0-beta1, 3.6.0-beta1-dev, 3.6.0-rc1, 3.6.0)' . PHP_EOL; + echo PHP_TAB . PHP_TAB . '-c :' . PHP_TAB . 'Codename [optional] (ex: Unicorn)' . PHP_EOL; + echo PHP_EOL; +} + +// Constants. +const PHP_TAB = "\t"; + +// File paths. THe version file path (If applicable) +$versionFile = 'PATH_OF_VERSION_FILE'; + +// This file will vary from component to component +$coreXmlFiles = array( + '/src/com_tjnotifications/tjnotifications.xml', + '/src/plugins/actionlog/tjnotification/tjnotification.xml', + '/src/plugins/privacy/tjnotification/tjnotification.xml', +); + +$antJobFile = '/build.xml'; + +$readMeFiles = array( + '/README.md', + '/README.txt', +); + +// Change copyright date exclusions. Some systems may try to scan the .git directory, exclude it. +$directoryLoopExcludeDirectories = array( + '/.git', + '/.gitlab', + '/scripts/gulp' +); + +$directoryLoopExcludeFiles = array( + '.gitignore', + '/build/bump.php', +); + +// Check arguments (exit if incorrect cli arguments). +$opts = getopt("v:c:"); + +if (empty($opts['v'])) +{ + usage($argv[0]); + die(); +} + +// Check version string (exit if not correct). +$versionParts = explode('-', $opts['v']); + +if (!preg_match('#^[0-9]+\.[0-9]+\.[0-9]+$#', $versionParts[0])) +{ + usage($argv[0]); + die(); +} + +if (isset($versionParts[1]) && !preg_match('#(dev|alpha|beta|rc)[0-9]*#', $versionParts[1])) +{ + usage($argv[0]); + die(); +} + +if (isset($versionParts[2]) && $versionParts[2] !== 'dev') +{ + usage($argv[0]); + die(); +} + +// Make sure we use the correct language and timezone. +setlocale(LC_ALL, 'en_GB'); +date_default_timezone_set('Asia/Kolkata'); + +// Make sure file and folder permissions are set correctly. +umask(022); + +// Get version dev status. +$dev_status = 'Stable'; + +if (!isset($versionParts[1])) +{ + $versionParts[1] = ''; +} +else +{ + if (preg_match('#^dev#', $versionParts[1])) + { + $dev_status = 'Development'; + } + elseif (preg_match('#^alpha#', $versionParts[1])) + { + $dev_status = 'Alpha'; + } + elseif (preg_match('#^beta#', $versionParts[1])) + { + $dev_status = 'Beta'; + } + elseif (preg_match('#^rc#', $versionParts[1])) + { + $dev_status = 'Release Candidate'; + } +} + +if (!isset($versionParts[2])) +{ + $versionParts[2] = ''; +} +else +{ + $dev_status = 'Development'; +} + +// Set version properties. +$versionSubParts = explode('.', $versionParts[0]); + +$version = array( + 'main' => $versionSubParts[0] . '.' . $versionSubParts[1], + 'major' => $versionSubParts[0], + 'minor' => $versionSubParts[1], + 'patch' => $versionSubParts[2], + 'extra' => (!empty($versionParts[1]) ? $versionParts[1] : '') . + (!empty($versionParts[2]) ? (!empty($versionParts[1]) ? '-' : '') . $versionParts[2] : ''), + 'release' => $versionSubParts[0] . '.' . $versionSubParts[1] . '.' . $versionSubParts[2], + 'dev_devel' => $versionSubParts[2] . (!empty($versionParts[1]) ? '-' . + $versionParts[1] : '') . (!empty($versionParts[2]) ? '-' . $versionParts[2] : ''), + 'dev_status' => $dev_status, + 'build' => '', + 'reldate' => date('j-F-Y'), + 'reltime' => date('H:i'), + 'reltz' => 'GMT', + 'credate' => date('jS M Y') + ); + +// Version Codename. +if (!empty($opts['c'])) +{ + $version['codename'] = trim($opts['c']); +} + +// Prints version information. +echo PHP_EOL; +echo 'Version data:' . PHP_EOL; +echo '- Main:' . PHP_TAB . PHP_TAB . PHP_TAB . $version['main'] . PHP_EOL; +echo '- Release:' . PHP_TAB . PHP_TAB . $version['release'] . PHP_EOL; +echo '- Full:' . PHP_TAB . PHP_TAB . PHP_TAB . $version['main'] . '.' . $version['dev_devel'] . PHP_EOL; +echo '- Build:' . PHP_TAB . PHP_TAB . $version['build'] . PHP_EOL; +echo '- Dev Level:' . PHP_TAB . PHP_TAB . $version['dev_devel'] . PHP_EOL; +echo '- Dev Status:' . PHP_TAB . PHP_TAB . $version['dev_status'] . PHP_EOL; +echo '- Release date:' . PHP_TAB . PHP_TAB . $version['reldate'] . PHP_EOL; +echo '- Release time:' . PHP_TAB . PHP_TAB . $version['reltime'] . PHP_EOL; +echo '- Release timezone:' . PHP_TAB . $version['reltz'] . PHP_EOL; +echo '- Creation date:' . PHP_TAB . $version['credate'] . PHP_EOL; + +if (!empty($version['codename'])) +{ + echo '- Codename:' . PHP_TAB . PHP_TAB . $version['codename'] . PHP_EOL; +} + +echo PHP_EOL; + +$rootPath = dirname(__DIR__); + +// Updates the version in version class. +if (file_exists($rootPath . $versionFile)) +{ + $fileContents = file_get_contents($rootPath . $versionFile); + $fileContents = preg_replace("#MAJOR_VERSION\s*=\s*[^;]*#", "MAJOR_VERSION = " . $version['major'], $fileContents); + $fileContents = preg_replace("#MINOR_VERSION\s*=\s*[^;]*#", "MINOR_VERSION = " . $version['minor'], $fileContents); + $fileContents = preg_replace("#PATCH_VERSION\s*=\s*[^;]*#", "PATCH_VERSION = " . $version['patch'], $fileContents); + $fileContents = preg_replace("#EXTRA_VERSION\s*=\s*'[^\']*'#", "EXTRA_VERSION = '" . $version['extra'] . "'", $fileContents); + $fileContents = preg_replace("#RELEASE\s*=\s*'[^\']*'#", "RELEASE = '" . $version['main'] . "'", $fileContents); + $fileContents = preg_replace("#DEV_LEVEL\s*=\s*'[^\']*'#", "DEV_LEVEL = '" . $version['dev_devel'] . "'", $fileContents); + $fileContents = preg_replace("#DEV_STATUS\s*=\s*'[^\']*'#", "DEV_STATUS = '" . $version['dev_status'] . "'", $fileContents); + $fileContents = preg_replace("#BUILD\s*=\s*'[^\']*'#", "BUILD = '" . $version['build'] . "'", $fileContents); + $fileContents = preg_replace("#RELDATE\s*=\s*'[^\']*'#", "RELDATE = '" . $version['reldate'] . "'", $fileContents); + $fileContents = preg_replace("#RELTIME\s*=\s*'[^\']*'#", "RELTIME = '" . $version['reltime'] . "'", $fileContents); + $fileContents = preg_replace("#RELTZ\s*=\s*'[^\']*'#", "RELTZ = '" . $version['reltz'] . "'", $fileContents); + + if (!empty($version['codename'])) + { + $fileContents = preg_replace("#CODENAME\s*=\s*'[^\']*'#", "CODENAME = '" . $version['codename'] . "'", $fileContents); + } + + file_put_contents($rootPath . $versionFile, $fileContents); +} + +// + TJ - chanages +// Prints TJ specific information. +$author = 'Techjoomla'; +$authorEmail = 'extensions@techjoomla.com'; +$authorUrl = 'https://techjoomla.com'; +$license = 'http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL'; +$copyright = 'Copyright (C) 2016 - 2018 Techjoomla. All rights reserved.'; + +echo PHP_EOL; + +echo 'Techjoomla copyright info to be added in xml:' . PHP_EOL; +echo '- author:' . PHP_TAB . PHP_TAB . PHP_TAB . $author . PHP_EOL; +echo '- authorEmail:' . PHP_TAB . PHP_TAB . PHP_TAB . $authorEmail . PHP_EOL; +echo '- authorUrl:' . PHP_TAB . PHP_TAB . PHP_TAB . $authorUrl . PHP_EOL; +echo '- license:' . PHP_TAB . PHP_TAB . PHP_TAB . $license . PHP_EOL; +echo '- copyright:' . PHP_TAB . PHP_TAB . PHP_TAB . $copyright . PHP_EOL; + +echo PHP_EOL; + +// + TJ - chanages - end + +// Updates the version and creation date in core xml files. +foreach ($coreXmlFiles as $coreXmlFile) +{ + if (file_exists($rootPath . $coreXmlFile)) + { + // @echo 'Processed xml file: ' .$rootPath . $coreXmlFile . PHP_EOL; + + $fileContents = file_get_contents($rootPath . $coreXmlFile); + + $fileContents = preg_replace('#[^<]*#', '' . $version['main'] . + '.' . $version['dev_devel'] . '', $fileContents + ); + + $fileContents = preg_replace('#[^<]*#', '' . + $version['credate'] . '', $fileContents + ); + + // + TJ - chanages + $fileContents = preg_replace('#[^<]*#', '' . + $author . '', $fileContents + ); + + $fileContents = preg_replace('#[^<]*#', '' . + $authorEmail . '', $fileContents + ); + + $fileContents = preg_replace('#[^<]*#', '' . + $authorUrl . '', $fileContents + ); + + $fileContents = preg_replace('#[^<]*#', '' . + $license . '', $fileContents + ); + + $fileContents = preg_replace('#[^<]*#', '' . + $copyright . '', $fileContents + ); + + // + TJ - chanages - end + + file_put_contents($rootPath . $coreXmlFile, $fileContents); + } +} + +// Updates the version for the `phpdoc` task in the Ant job file. +if (file_exists($rootPath . $antJobFile)) +{ + $fileContents = file_get_contents($rootPath . $antJobFile); + $fileContents = preg_replace('##', '', $fileContents + ); + file_put_contents($rootPath . $antJobFile, $fileContents); +} + +// Updates the version in readme files. +foreach ($readMeFiles as $readMeFile) +{ + if (file_exists($rootPath . $readMeFile)) + { + $fileContents = file_get_contents($rootPath . $readMeFile); + $fileContents = preg_replace('#Joomla! [0-9]+\.[0-9]+ (|\[)version#', 'Joomla! ' . $version['main'] . ' $1version', $fileContents); + $fileContents = preg_replace('#Joomla_[0-9]+\.[0-9]+_version#', 'Joomla_' . $version['main'] . '_version', $fileContents); + file_put_contents($rootPath . $readMeFile, $fileContents); + } +} + +// Updates the copyright date in core files. +$changedFilesCopyrightDate = 0; +$changedFilesSinceVersion = 0; +$year = date('Y'); +$directory = new \RecursiveDirectoryIterator($rootPath); +$iterator = new \RecursiveIteratorIterator($directory, RecursiveIteratorIterator::SELF_FIRST); + +foreach ($iterator as $file) +{ + if ($file->isFile()) + { + $filePath = $file->getPathname(); + $relativePath = str_replace($rootPath, '', $filePath); + + // Exclude certain extensions. + if (preg_match('#\.(png|jpeg|jpg|gif|bmp|ico|webp|svg|woff|woff2|ttf|eot)$#', $filePath)) + { + continue; + } + + // Exclude certain files. + if (in_array($relativePath, $directoryLoopExcludeFiles)) + { + continue; + } + + // Exclude certain directories. + $continue = true; + + foreach ($directoryLoopExcludeDirectories as $excludeDirectory) + { + if (preg_match('#^' . preg_quote($excludeDirectory) . '#', $relativePath)) + { + $continue = false; + break; + } + } + + if ($continue) + { + $changeSinceVersion = false; + $changeCopyrightDate = false; + + // Load the file. + $fileContents = file_get_contents($filePath); + + // Check if need to change the copyright date. + if (preg_match('#2016\s+-\s+[0-9]{4}\s+Techjoomla.\s+All\s+rights#', $fileContents) + && !preg_match('#2016\s+-\s+' . $year . '\s+Techjoomla.\s+All\s+rights#', $fileContents)) + { + $changeCopyrightDate = true; + $fileContents = preg_replace('#2016\s+-\s+[0-9]{4}\s+Techjoomla.\s+All\s+rights#', '2016 - ' . + $year . ' Techjoomla. All rights', $fileContents + ); + $changedFilesCopyrightDate++; + } + + // Check if need to change the since version. + if ($relativePath !== '/build/bump.php' && preg_match('#__DEPLOY_VERSION__#', $fileContents)) + { + $changeSinceVersion = true; + $fileContents = preg_replace('#__DEPLOY_VERSION__#', $version['release'], $fileContents); + $changedFilesSinceVersion++; + } + + // Save the file. + if ($changeCopyrightDate || $changeSinceVersion) + { + file_put_contents($filePath, $fileContents); + } + + // @echo 'Processed file: ' . $filePath . PHP_EOL; + } + } +} + +if ($changedFilesCopyrightDate > 0 || $changedFilesSinceVersion > 0) +{ + if ($changedFilesCopyrightDate > 0) + { + echo '- Copyright Date changed in ' . $changedFilesCopyrightDate . ' files.' . PHP_EOL; + } + + if ($changedFilesSinceVersion > 0) + { + echo '- Since Version changed in ' . $changedFilesSinceVersion . ' files.' . PHP_EOL; + } + + echo PHP_EOL; +} + +echo 'Version bump complete!' . PHP_EOL; diff --git a/src/com_tjnotifications/tjnotifications.xml b/src/com_tjnotifications/tjnotifications.xml index 05b8b3be..ed83f49e 100644 --- a/src/com_tjnotifications/tjnotifications.xml +++ b/src/com_tjnotifications/tjnotifications.xml @@ -4,10 +4,10 @@ Techjoomla extensions@techjoomla.com https://techjoomla.com - Copyright (C) 2009-2018 Techjoomla. All rights reserved. + Copyright (C) 2016 - 2018 Techjoomla. All rights reserved. http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL - 25th June 2018 - 1.0.1 + 16th Nov 2018 + 1.0.2 sql/install.mysql.utf8.sql diff --git a/src/plugins/actionlog/tjnotification/tjnotification.php b/src/plugins/actionlog/tjnotification/tjnotification.php index 6e30ab62..e2a16283 100644 --- a/src/plugins/actionlog/tjnotification/tjnotification.php +++ b/src/plugins/actionlog/tjnotification/tjnotification.php @@ -17,7 +17,7 @@ /** * TJ Notification Actions Logging Plugin. * - * @since __DEPLOY_VERSION__ + * @since 1.0.2 */ class PlgActionlogTjnotification extends JPlugin { @@ -25,7 +25,7 @@ class PlgActionlogTjnotification extends JPlugin * Load plugin language file automatically so that it can be used inside component * * @var boolean - * @since __DEPLOY_VERSION__ + * @since 1.0.2 */ protected $autoloadLanguage = true; @@ -38,7 +38,7 @@ class PlgActionlogTjnotification extends JPlugin * * @return void * - * @since __DEPLOY_VERSION__ + * @since 1.0.2 */ public function tjnOnAfterUnsubscribeNotification($data) { @@ -85,7 +85,7 @@ public function tjnOnAfterUnsubscribeNotification($data) * * @return void * - * @since __DEPLOY_VERSION__ + * @since 1.0.2 */ protected function addLog($messages, $messageLanguageKey, $context, $userId = null) @@ -108,7 +108,7 @@ protected function addLog($messages, $messageLanguageKey, $context, $userId = nu * * @return void * - * @since __DEPLOY_VERSION__ + * @since 1.0.2 */ public function tjnOnAfterSaveNotificationTemplate($data, $recordId, $isNew) @@ -158,7 +158,7 @@ public function tjnOnAfterSaveNotificationTemplate($data, $recordId, $isNew) * * @return void * - * @since __DEPLOY_VERSION__ + * @since 1.0.2 */ public function tjnOnAfterDeleteNotificationTemplate($data) @@ -201,7 +201,7 @@ public function tjnOnAfterDeleteNotificationTemplate($data) * * @return void * - * @since __DEPLOY_VERSION__ + * @since 1.0.2 */ public function tjnOnAfterResubscribeNotification($data) { diff --git a/src/plugins/actionlog/tjnotification/tjnotification.xml b/src/plugins/actionlog/tjnotification/tjnotification.xml index 00f269fd..f449bb10 100644 --- a/src/plugins/actionlog/tjnotification/tjnotification.xml +++ b/src/plugins/actionlog/tjnotification/tjnotification.xml @@ -2,12 +2,12 @@ plg_actionlog_tjnotification Techjoomla - 1st October 2018 - Copyright (C) 2005 - 2018 Techjoomla. All rights reserved. - GNU General Public License version 2 or later; see LICENSE.txt + 16th Nov 2018 + Copyright (C) 2016 - 2018 Techjoomla. All rights reserved. + http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL extensions@techjoomla.com https://techjoomla.com - __DEPLOY_VERSION__ + 1.0.2 PLG_ACTIONLOG_TJNOTIFICATION_XML_DESCRIPTION tjnotification.php diff --git a/src/plugins/privacy/tjnotification/tjnotification.php b/src/plugins/privacy/tjnotification/tjnotification.php index 5c3019e5..004c0e87 100644 --- a/src/plugins/privacy/tjnotification/tjnotification.php +++ b/src/plugins/privacy/tjnotification/tjnotification.php @@ -19,7 +19,7 @@ /** * Privacy plugin managing TJNotifications user data * - * @since __DEPLOY_VERSION__ + * @since 1.0.2 */ class PlgPrivacyTjnotification extends PrivacyPlugin { @@ -28,7 +28,7 @@ class PlgPrivacyTjnotification extends PrivacyPlugin * * @var boolean * - * @since __DEPLOY_VERSION__ + * @since 1.0.2 */ protected $autoloadLanguage = true; @@ -36,7 +36,7 @@ class PlgPrivacyTjnotification extends PrivacyPlugin * Database object * * @var JDatabaseDriver - * @since __DEPLOY_VERSION__ + * @since 1.0.2 */ protected $db; @@ -45,7 +45,7 @@ class PlgPrivacyTjnotification extends PrivacyPlugin * * @return array * - * @since __DEPLOY_VERSION__ + * @since 1.0.2 */ public function onPrivacyCollectAdminCapabilities() { @@ -70,7 +70,7 @@ public function onPrivacyCollectAdminCapabilities() * * @return PrivacyExportDomain[] * - * @since __DEPLOY_VERSION__ + * @since 1.0.2 */ public function onPrivacyExportRequest(PrivacyTableRequest $request, JUser $user = null) { @@ -98,7 +98,7 @@ public function onPrivacyExportRequest(PrivacyTableRequest $request, JUser $user * * @return PrivacyExportDomain * - * @since __DEPLOY_VERSION__ + * @since 1.0.2 */ private function createTJNotificationsUnsubscriptionDomain(JTableUser $user) { @@ -133,7 +133,7 @@ private function createTJNotificationsUnsubscriptionDomain(JTableUser $user) * * @return PrivacyRemovalStatus * - * @since __DEPLOY_VERSION__ + * @since 1.0.2 */ public function onPrivacyCanRemoveData(PrivacyTableRequest $request, JUser $user = null) { @@ -157,7 +157,7 @@ public function onPrivacyCanRemoveData(PrivacyTableRequest $request, JUser $user * * @return void * - * @since __DEPLOY_VERSION__ + * @since 1.0.2 */ public function onPrivacyRemoveData(PrivacyTableRequest $request, JUser $user = null) { diff --git a/src/plugins/privacy/tjnotification/tjnotification.xml b/src/plugins/privacy/tjnotification/tjnotification.xml index 66ea90c2..7925b3fd 100644 --- a/src/plugins/privacy/tjnotification/tjnotification.xml +++ b/src/plugins/privacy/tjnotification/tjnotification.xml @@ -1,12 +1,12 @@ plg_privacy_tjnotification - __DEPLOY_VERSION__ - 5th October 2018 + 1.0.2 + 16th Nov 2018 Techjoomla extensions@techjoomla.com https://techjoomla.com - Copyright (c) 2009-2018 Techjoomla. All rights reserved. + Copyright (C) 2016 - 2018 Techjoomla. All rights reserved. http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL PLG_PRIVACY_TJNOTIFICATION_XML_DESCRIPTION