mirror of
https://github.com/torrentpier/torrentpier
synced 2025-08-20 21:33:54 -07:00
misc(installer): Added cleanup step (for master builds) (#1838)
* misc(installer): Added cleanup step (for master builds) * Update _cleanup.php * Update install.php * Update install.php * Update install.php * Update install.php
This commit is contained in:
parent
b954815f5d
commit
dd721367c7
2 changed files with 29 additions and 8 deletions
15
_cleanup.php
15
_cleanup.php
|
@ -7,12 +7,15 @@
|
||||||
* @license https://github.com/torrentpier/torrentpier/blob/master/LICENSE MIT License
|
* @license https://github.com/torrentpier/torrentpier/blob/master/LICENSE MIT License
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
if (!defined('BB_ROOT')) {
|
||||||
|
define('BB_ROOT', __DIR__ . DIRECTORY_SEPARATOR);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check CLI mode
|
||||||
if (php_sapi_name() !== 'cli') {
|
if (php_sapi_name() !== 'cli') {
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
define('BB_ROOT', __DIR__ . DIRECTORY_SEPARATOR);
|
|
||||||
|
|
||||||
$items = [
|
$items = [
|
||||||
'.github',
|
'.github',
|
||||||
'.editorconfig',
|
'.editorconfig',
|
||||||
|
@ -47,9 +50,9 @@ foreach ($items as $item) {
|
||||||
function removeFile(string $file): void
|
function removeFile(string $file): void
|
||||||
{
|
{
|
||||||
if (unlink($file)) {
|
if (unlink($file)) {
|
||||||
echo "[INFO] File removed: $file" . PHP_EOL;
|
echo "- File removed: $file" . PHP_EOL;
|
||||||
} else {
|
} else {
|
||||||
echo "[ERROR] File cannot be removed: $file" . PHP_EOL;
|
echo "- File cannot be removed: $file" . PHP_EOL;
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -73,9 +76,9 @@ function removeDir(string $dir): void
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rmdir($dir)) {
|
if (rmdir($dir)) {
|
||||||
echo "[INFO] Folder removed: $dir" . PHP_EOL;
|
echo "- Folder removed: $dir" . PHP_EOL;
|
||||||
} else {
|
} else {
|
||||||
echo "[ERROR] Folder cannot be removed: $dir" . PHP_EOL;
|
echo "- Folder cannot be removed: $dir" . PHP_EOL;
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
22
install.php
22
install.php
|
@ -7,7 +7,7 @@
|
||||||
* @license https://github.com/torrentpier/torrentpier/blob/master/LICENSE MIT License
|
* @license https://github.com/torrentpier/torrentpier/blob/master/LICENSE MIT License
|
||||||
*/
|
*/
|
||||||
|
|
||||||
define('BB_ROOT', __DIR__ . '/');
|
define('BB_ROOT', __DIR__ . DIRECTORY_SEPARATOR);
|
||||||
|
|
||||||
// Check CLI mode
|
// Check CLI mode
|
||||||
if (php_sapi_name() !== 'cli') {
|
if (php_sapi_name() !== 'cli') {
|
||||||
|
@ -185,7 +185,7 @@ if (!defined('EXTENSIONS_NOT_INSTALLED')) {
|
||||||
if (is_file(BB_ROOT . '.env')) {
|
if (is_file(BB_ROOT . '.env')) {
|
||||||
out('- TorrentPier already installed', 'warning');
|
out('- TorrentPier already installed', 'warning');
|
||||||
echo 'Are you sure want to re-install TorrentPier? [y/N]: ';
|
echo 'Are you sure want to re-install TorrentPier? [y/N]: ';
|
||||||
if (str_starts_with(mb_strtolower(readline()), 'y')) {
|
if (str_starts_with(mb_strtolower(trim(readline())), 'y')) {
|
||||||
out("\n- Re-install process started...", 'info');
|
out("\n- Re-install process started...", 'info');
|
||||||
// environment
|
// environment
|
||||||
if (is_file(BB_ROOT . '.env')) {
|
if (is_file(BB_ROOT . '.env')) {
|
||||||
|
@ -415,5 +415,23 @@ if (!empty($DB_HOST) && !empty($DB_DATABASE) && !empty($DB_USERNAME)) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Cleanup...
|
||||||
|
if (is_file(BB_ROOT . '_cleanup.php')) {
|
||||||
|
out("\n--- Finishing installation (Cleanup) ---\n", 'info');
|
||||||
|
out('The cleanup process will remove:');
|
||||||
|
out('- Development documentation (README, CHANGELOG)', 'debug');
|
||||||
|
out('- Git configuration files', 'debug');
|
||||||
|
out('- CI/CD pipelines and code analysis tools', 'debug');
|
||||||
|
out('- Translation and contribution guidelines', 'debug');
|
||||||
|
echo 'Do you want to delete these files permanently? [y/N]: ';
|
||||||
|
if (str_starts_with(mb_strtolower(trim(readline())), 'y')) {
|
||||||
|
out("\n- Cleanup...", 'info');
|
||||||
|
require_once BB_ROOT . '_cleanup.php';
|
||||||
|
unlink(BB_ROOT . '_cleanup.php');
|
||||||
|
} else {
|
||||||
|
out('- Skipping...', 'info');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
out("\n- Voila! Good luck & have fun!", 'success');
|
out("\n- Voila! Good luck & have fun!", 'success');
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue