Release of v3.1.3-alpha1

Improve the removeFolder method in the install script.
This commit is contained in:
Robot 2024-07-15 17:17:39 +02:00
parent a5d86a255b
commit 615a7e0cef
Signed by: Robot
GPG Key ID: 14DECD44E7E1BB95
7 changed files with 111 additions and 86 deletions

View File

@ -1,4 +1,8 @@
# v3.1.2
# v3.1.3-alpha1
- Improve the removeFolder method in the install script
# v3.1.3-alpha
- Refactored the API classes
- Add table schema checker

View File

@ -1,4 +1,4 @@
# Get Bible (3.1.2)
# Get Bible (3.1.3-alpha1)
![Get Bible image](https://git.vdm.dev/getBible/joomla-component/raw/branch/master/admin/assets/images/vdm-component.jpg "GetBible")
@ -19,23 +19,23 @@ In essence, The Bible for Joomla is designed to transform how the Word of God is
+ *Name*: [Get Bible](https://getbible.net)
+ *First Build*: 3rd December, 2015
+ *Last Build*: 15th July, 2024
+ *Version*: 3.1.2
+ *Version*: 3.1.3-alpha1
+ *Copyright*: Copyright (C) 2015. All Rights Reserved
+ *License*: GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html
## Build Time
**625 Hours** or **78 Eight Hour Days** (actual time the author saved -
**626 Hours** or **78 Eight Hour Days** (actual time the author saved -
due to [Automated Component Builder](https://www.joomlacomponentbuilder.com))
> (if creating a folder and file took **5 seconds** and writing one line of code took **10 seconds**,
> never making one mistake or taking any coffee break.)
+ *Line count*: **224135**
+ *File count*: **1895**
+ *Line count*: **224160**
+ *File count*: **1896**
+ *Folder count*: **154**
**413 Hours** or **52 Eight Hour Days** (the actual time the author spent)
**412 Hours** or **52 Eight Hour Days** (the actual time the author spent)
> (with the following break down:
> **debugging @156hours** = codingtime / 4;

View File

@ -1,4 +1,4 @@
# Get Bible (3.1.2)
# Get Bible (3.1.3-alpha1)
![Get Bible image](https://git.vdm.dev/getBible/joomla-component/raw/branch/master/admin/assets/images/vdm-component.jpg "GetBible")
@ -19,23 +19,23 @@ In essence, The Bible for Joomla is designed to transform how the Word of God is
+ *Name*: [Get Bible](https://getbible.net)
+ *First Build*: 3rd December, 2015
+ *Last Build*: 15th July, 2024
+ *Version*: 3.1.2
+ *Version*: 3.1.3-alpha1
+ *Copyright*: Copyright (C) 2015. All Rights Reserved
+ *License*: GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html
## Build Time
**625 Hours** or **78 Eight Hour Days** (actual time the author saved -
**626 Hours** or **78 Eight Hour Days** (actual time the author saved -
due to [Automated Component Builder](https://www.joomlacomponentbuilder.com))
> (if creating a folder and file took **5 seconds** and writing one line of code took **10 seconds**,
> never making one mistake or taking any coffee break.)
+ *Line count*: **224135**
+ *File count*: **1895**
+ *Line count*: **224160**
+ *File count*: **1896**
+ *Folder count*: **154**
**413 Hours** or **52 Eight Hour Days** (the actual time the author spent)
**412 Hours** or **52 Eight Hour Days** (the actual time the author spent)
> (with the following break down:
> **debugging @156hours** = codingtime / 4;

View File

@ -0,0 +1 @@

View File

@ -7,9 +7,9 @@
<authorUrl>https://getbible.net</authorUrl>
<copyright>Copyright (C) 2015. All Rights Reserved</copyright>
<license>GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html</license>
<version>3.1.2</version>
<version>3.1.3-alpha1</version>
<description><![CDATA[
<h1>Get Bible (v.3.1.2)</h1>
<h1>Get Bible (v.3.1.3-alpha1)</h1>
<div style="clear: both;"></div>
<p>Welcome to the next level of scripture engagement - The Bible for Joomla! Our purpose is to bring the Word of God to every person, in their native language, entirely free. This isn't just a typical extension; it's a groundbreaking tool developed to span language divides and deliver a rich, customizable Bible study experience to users worldwide.

View File

@ -1000,6 +1000,9 @@ class Com_GetbibleInstallerScript
return false;
}
// Check that the required configuration are set for PHP
$this->phpConfigurationCheck($app);
// all things to clear out
$removeFolders = [];
$removeFolders[] = JPATH_LIBRARIES . '/jcb_powers/VDM.Joomla.GetBible';
@ -1007,14 +1010,12 @@ class Com_GetbibleInstallerScript
$removeFolders[] = JPATH_LIBRARIES . '/vendor_getbible/TrueChristianChurch.Joomla.GetBible';
$removeFolders[] = JPATH_LIBRARIES . '/vendor_getbible/TrueChristianChurch.Joomla.Gitea';
$removeFolders[] = JPATH_LIBRARIES . '/vendor_getbible/TrueChristianChurch.Joomla.Openai';
$removeFolders[] = JPATH_LIBRARIES . '/vendor_getbible/TrueChristianBible.Joomla/src/GetBible';
foreach ($removeFolders as $folder)
{
$this->removeFolder($folder);
}
// Check that the required configuration are set for PHP
$this->phpConfigurationCheck($app);
}
// do any install needed
if ($type === 'install')
@ -1580,7 +1581,7 @@ class Com_GetbibleInstallerScript
echo '<div style="background-color: #fff;" class="alert alert-info"><a target="_blank" href="https://getbible.net" title="Get Bible">
<img src="components/com_getbible/assets/images/vdm-component.jpg"/>
</a>
<h3>Upgrade to Version 3.1.2 Was Successful! Let us know if anything is not working as expected.</h3></div>';
<h3>Upgrade to Version 3.1.3-alpha1 Was Successful! Let us know if anything is not working as expected.</h3></div>';
// Set db if not set already.
if (!isset($db))
@ -2017,76 +2018,77 @@ class Com_GetbibleInstallerScript
}
/**
* Remove folders with files
* Remove folders with files (with ignore options)
*
* @param string $dir The path to folder to remove
* @param boolean $ignore The folders and files to ignore and not remove
* @param string $dir The path to the folder to remove.
* @param array|null $ignore The folders and files to ignore and not remove.
*
* @return boolean True in all is removed
* @since 3.2.1
* @return bool True if all specified files/folders are removed, false otherwise.
* @since 3.2.2
*/
protected function removeFolder($dir, $ignore = false)
protected function removeFolder(string $dir, ?array $ignore = null): bool
{
if (Folder::exists($dir))
if (!Folder::exists($dir))
{
$it = new RecursiveDirectoryIterator($dir);
$it = new RecursiveIteratorIterator($it, RecursiveIteratorIterator::CHILD_FIRST);
// remove ending /
$dir = rtrim($dir, '/');
// now loop the files & folders
foreach ($it as $file)
{
if ('.' === $file->getBasename() || '..' === $file->getBasename()) continue;
// set file dir
$file_dir = $file->getPathname();
// check if this is a dir or a file
if ($file->isDir())
{
$keeper = false;
if ($this->checkArray($ignore))
{
foreach ($ignore as $keep)
{
if (strpos($file_dir, $dir.'/'.$keep) !== false)
{
$keeper = true;
}
}
}
if ($keeper)
{
continue;
}
Folder::delete($file_dir);
}
else
{
$keeper = false;
if ($this->checkArray($ignore))
{
foreach ($ignore as $keep)
{
if (strpos($file_dir, $dir.'/'.$keep) !== false)
{
$keeper = true;
}
}
}
if ($keeper)
{
continue;
}
File::delete($file_dir);
}
}
// delete the root folder if not ignore found
if (!$this->checkArray($ignore))
{
return Folder::delete($dir);
}
return true;
return false;
}
return false;
$it = new \RecursiveDirectoryIterator($dir, \FilesystemIterator::SKIP_DOTS);
$it = new \RecursiveIteratorIterator($it, \RecursiveIteratorIterator::CHILD_FIRST);
// Remove trailing slash
$dir = rtrim($dir, '/');
foreach ($it as $file)
{
$filePath = $file->getPathname();
$relativePath = str_replace($dir . '/', '', $filePath);
if ($ignore !== null && in_array($relativePath, $ignore, true))
{
continue;
}
if ($file->isDir())
{
Folder::delete($filePath);
}
else
{
File::delete($filePath);
}
}
// Delete the root folder if there are no ignored files/folders left
if ($ignore === null || $this->isDirEmpty($dir, $ignore))
{
return Folder::delete($dir);
}
return true;
}
/**
* Check if a directory is empty considering ignored files/folders.
*
* @param string $dir The path to the folder to check.
* @param array $ignore The folders and files to ignore.
*
* @return bool True if the directory is empty or contains only ignored items, false otherwise.
* @since 3.2.1
*/
protected function isDirEmpty(string $dir, array $ignore): bool
{
$it = new \RecursiveDirectoryIterator($dir, \FilesystemIterator::SKIP_DOTS);
foreach ($it as $file)
{
$relativePath = str_replace($dir . '/', '', $file->getPathname());
if (!in_array($relativePath, $ignore, true))
{
return false;
}
}
return true;
}
/**

View File

@ -761,10 +761,10 @@
<element>pkg_getbible</element>
<type>package</type>
<client>site</client>
<version>3.1.2</version>
<version>3.1.3-alpha</version>
<infourl title="Get Bible!">https://getbible.net</infourl>
<downloads>
<downloadurl type="full" format="zip">https://git.vdm.dev/api/v1/repos/getBible/joomla-pkg/archive/v3.1.2.zip</downloadurl>
<downloadurl type="full" format="zip">https://git.vdm.dev/api/v1/repos/getBible/joomla-pkg/archive/v3.1.3-alpha1.zip</downloadurl>
</downloads>
<tags>
<tag>stable</tag>
@ -773,4 +773,22 @@
<maintainerurl>https://getbible.net</maintainerurl>
<targetplatform name="joomla" version="3.*"/>
</update>
<update>
<name>Get Bible</name>
<description>The Bible for Joomla</description>
<element>pkg_getbible</element>
<type>package</type>
<client>site</client>
<version>3.1.3-alpha1</version>
<infourl title="Get Bible!">https://getbible.net</infourl>
<downloads>
<downloadurl type="full" format="zip">https://git.vdm.dev/api/v1/repos/getBible/joomla-pkg/archive/v3.1.3-alpha1.zip</downloadurl>
</downloads>
<tags>
<tag>alpha</tag>
</tags>
<maintainer>Llewellyn van der Merwe</maintainer>
<maintainerurl>https://getbible.net</maintainerurl>
<targetplatform name="joomla" version="3.*"/>
</update>
</updates>