mirror of
https://github.com/torrentpier/torrentpier
synced 2025-08-21 13:54:02 -07:00
misc(cliff): Added automated script for releases creation (#1930)
* misc(cliff): Added automated script for releases creation * Updated * Update functions_cli.php * Updated * Updated * Update functions_cli.php * Updated * Update _release.php * Update cliff.toml * Update _release.php * Update _release.php * Update _release.php * Update _release.php * Update _release.php * Update _release.php * Update _release.php * Update _release.php * Update _release.php * Update _release.php * Update _release.php * Update _release.php * Update _release.php
This commit is contained in:
parent
c9aff2a152
commit
6adde35849
5 changed files with 297 additions and 164 deletions
51
_cleanup.php
51
_cleanup.php
|
@ -9,6 +9,7 @@
|
|||
|
||||
if (!defined('BB_ROOT')) {
|
||||
define('BB_ROOT', __DIR__ . DIRECTORY_SEPARATOR);
|
||||
define('BB_PATH', BB_ROOT);
|
||||
}
|
||||
|
||||
// Check CLI mode
|
||||
|
@ -16,12 +17,21 @@ if (php_sapi_name() !== 'cli') {
|
|||
exit;
|
||||
}
|
||||
|
||||
if (!function_exists('removeFile')) {
|
||||
// Get all constants
|
||||
require_once BB_ROOT . 'library/defines.php';
|
||||
|
||||
// Include CLI functions
|
||||
require INC_DIR . '/functions_cli.php';
|
||||
}
|
||||
|
||||
$items = [
|
||||
'.github',
|
||||
'.cliffignore',
|
||||
'.editorconfig',
|
||||
'.gitignore',
|
||||
'.styleci.yml',
|
||||
'_release.php',
|
||||
'CHANGELOG.md',
|
||||
'cliff.toml',
|
||||
'CODE_OF_CONDUCT.md',
|
||||
|
@ -41,44 +51,3 @@ foreach ($items as $item) {
|
|||
removeDir($path);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove target file
|
||||
*
|
||||
* @param string $file Path to file
|
||||
*/
|
||||
function removeFile(string $file): void
|
||||
{
|
||||
if (unlink($file)) {
|
||||
echo "- File removed: $file" . PHP_EOL;
|
||||
} else {
|
||||
echo "- File cannot be removed: $file" . PHP_EOL;
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove folder (recursively)
|
||||
*
|
||||
* @param string $dir Path to folder
|
||||
*/
|
||||
function removeDir(string $dir): void
|
||||
{
|
||||
$it = new RecursiveDirectoryIterator($dir, FilesystemIterator::SKIP_DOTS);
|
||||
$files = new RecursiveIteratorIterator($it, RecursiveIteratorIterator::CHILD_FIRST);
|
||||
|
||||
foreach ($files as $file) {
|
||||
if ($file->isDir()) {
|
||||
removeDir($file->getPathname());
|
||||
} else {
|
||||
removeFile($file->getPathname());
|
||||
}
|
||||
}
|
||||
|
||||
if (rmdir($dir)) {
|
||||
echo "- Folder removed: $dir" . PHP_EOL;
|
||||
} else {
|
||||
echo "- Folder cannot be removed: $dir" . PHP_EOL;
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue