update include update env file

This commit is contained in:
xiaomlove
2024-12-30 01:35:05 +08:00
parent 3cf7b36ad6
commit 0f88ab8d82
8 changed files with 38 additions and 165 deletions

View File

@@ -137,6 +137,12 @@ class NexusUpdate extends Command
$this->doLog("Error: Redis version: {$mysqlInfo['version']} is too low, please use 2.0.0 or above.", 'error');
return 0;
}
if ($includeComposer) {
$this->doLog("going to update .env file ...");
$this->update->updateEnvFile();
$this->doLog("update .env file done!");
}
$this->doLog("going to createSymbolicLinks...");
$this->update->createSymbolicLinks($symbolicLinks);
$this->doLog("createSymbolicLinks done!");

View File

@@ -104,8 +104,8 @@ class Test extends Command
$str = "1.abc.de";
$ext = "png";
$str = "202404/20240403215909f58f38ddd968a0e8a4bdd30690a9e92e.png";
$res = substr($str, 0,-1*strlen($ext)-1);
dd($res);
$ext = pathinfo($str, PATHINFO_EXTENSION);
dd(basename($str), $ext);
}
}

View File

@@ -54,7 +54,6 @@
},
"require-dev": {
"fakerphp/faker": "^1.9.1",
"filament/upgrade": "^3.2",
"kitloong/laravel-migrations-generator": "^7.0",
"laravel-lang/lang": "^15.10",
"laravel-lang/publisher": "^16.0",

159
composer.lock generated
View File

@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "11ad77956fab261081967fcfef0872f7",
"content-hash": "91ed67735b2cfade134e539b43ba5796",
"packages": [
{
"name": "anourvalar/eloquent-serialize",
@@ -10369,46 +10369,6 @@
},
"time": "2024-11-21T13:46:39+00:00"
},
{
"name": "filament/upgrade",
"version": "v3.2.131",
"source": {
"type": "git",
"url": "https://github.com/filamentphp/upgrade.git",
"reference": "dc43f5c1fe24d1849a4a434dc6441d7bff69c9c9"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/filamentphp/upgrade/zipball/dc43f5c1fe24d1849a4a434dc6441d7bff69c9c9",
"reference": "dc43f5c1fe24d1849a4a434dc6441d7bff69c9c9",
"shasum": ""
},
"require": {
"nunomaduro/termwind": "^1.0|^2.0",
"php": "^8.1",
"rector/rector": "^1.0"
},
"bin": [
"bin/filament-v3"
],
"type": "library",
"autoload": {
"psr-4": {
"Filament\\Upgrade\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"description": "Upgrade Filament v2 code to Filament v3.",
"homepage": "https://github.com/filamentphp/filament",
"support": {
"issues": "https://github.com/filamentphp/filament/issues",
"source": "https://github.com/filamentphp/filament"
},
"time": "2024-12-11T09:06:04+00:00"
},
{
"name": "filp/whoops",
"version": "2.16.0",
@@ -11538,64 +11498,6 @@
},
"time": "2022-02-21T01:04:05+00:00"
},
{
"name": "phpstan/phpstan",
"version": "1.12.13",
"source": {
"type": "git",
"url": "https://github.com/phpstan/phpstan.git",
"reference": "9b469068840cfa031e1deaf2fa1886d00e20680f"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/9b469068840cfa031e1deaf2fa1886d00e20680f",
"reference": "9b469068840cfa031e1deaf2fa1886d00e20680f",
"shasum": ""
},
"require": {
"php": "^7.2|^8.0"
},
"conflict": {
"phpstan/phpstan-shim": "*"
},
"bin": [
"phpstan",
"phpstan.phar"
],
"type": "library",
"autoload": {
"files": [
"bootstrap.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"description": "PHPStan - PHP Static Analysis Tool",
"keywords": [
"dev",
"static analysis"
],
"support": {
"docs": "https://phpstan.org/user-guide/getting-started",
"forum": "https://github.com/phpstan/phpstan/discussions",
"issues": "https://github.com/phpstan/phpstan/issues",
"security": "https://github.com/phpstan/phpstan/security/policy",
"source": "https://github.com/phpstan/phpstan-src"
},
"funding": [
{
"url": "https://github.com/ondrejmirtes",
"type": "github"
},
{
"url": "https://github.com/phpstan",
"type": "github"
}
],
"time": "2024-12-17T17:00:20+00:00"
},
{
"name": "phpunit/php-code-coverage",
"version": "10.1.16",
@@ -12018,65 +11920,6 @@
],
"time": "2024-12-21T05:49:06+00:00"
},
{
"name": "rector/rector",
"version": "1.2.10",
"source": {
"type": "git",
"url": "https://github.com/rectorphp/rector.git",
"reference": "40f9cf38c05296bd32f444121336a521a293fa61"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/rectorphp/rector/zipball/40f9cf38c05296bd32f444121336a521a293fa61",
"reference": "40f9cf38c05296bd32f444121336a521a293fa61",
"shasum": ""
},
"require": {
"php": "^7.2|^8.0",
"phpstan/phpstan": "^1.12.5"
},
"conflict": {
"rector/rector-doctrine": "*",
"rector/rector-downgrade-php": "*",
"rector/rector-phpunit": "*",
"rector/rector-symfony": "*"
},
"suggest": {
"ext-dom": "To manipulate phpunit.xml via the custom-rule command"
},
"bin": [
"bin/rector"
],
"type": "library",
"autoload": {
"files": [
"bootstrap.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"description": "Instant Upgrade and Automated Refactoring of any PHP code",
"keywords": [
"automation",
"dev",
"migration",
"refactoring"
],
"support": {
"issues": "https://github.com/rectorphp/rector/issues",
"source": "https://github.com/rectorphp/rector/tree/1.2.10"
},
"funding": [
{
"url": "https://github.com/tomasvotruba",
"type": "github"
}
],
"time": "2024-11-08T13:59:10+00:00"
},
{
"name": "sebastian/cli-parser",
"version": "2.0.1",

View File

@@ -34,7 +34,6 @@ abstract class Storage {
throw new \Exception("Failed to move uploaded file.");
}
$url = $this->upload($newFilepath);
@unlink($filepath);
@unlink($newFilepath);
} else {
$url = $this->upload($filepath);

View File

@@ -13,7 +13,7 @@ class Install
{
protected $currentStep;
protected $minimumPhpVersion = '8.0.3';
protected $minimumPhpVersion = '8.2.0';
protected $progressKeyPrefix = '__step';
@@ -32,7 +32,10 @@ class Install
'UID_STARTS',
];
protected array $requiredExtensions = ['ctype', 'curl', 'fileinfo', 'json', 'mbstring', 'openssl', 'pdo_mysql', 'tokenizer', 'xml', 'mysqli', 'bcmath', 'redis', 'gd', 'gmp', 'Zend OPcache', 'pcntl', 'posix', 'sockets'];
protected array $requiredExtensions = [
'ctype', 'curl', 'fileinfo', 'json', 'mbstring', 'openssl', 'pdo_mysql', 'tokenizer', 'xml',
'mysqli', 'bcmath', 'redis', 'gd', 'gmp', 'Zend OPcache', 'pcntl', 'posix', 'sockets', 'zip', 'intl'
];
protected array $optionalExtensions = [
// ['name' => 'swoole', 'desc' => "If use swoole for Octane, make sure 'current' shows 1"],
];

View File

@@ -536,6 +536,29 @@ class Update extends Install
return false;
}
public function updateEnvFile()
{
$envFile = ROOT_PATH . '.env';
$envExample = ROOT_PATH . '.env.example';
$envData = readEnvFile($envFile);
$envExampleData = readEnvFile($envExample);
foreach ($envExampleData as $key => $value) {
if (!isset($envData[$key])) {
$envData[$key] = $value;
}
}
$fp = @fopen($envFile, 'w');
if ($fp === false) {
throw new \RuntimeException("can't create env file, make sure php has permission to create file at: " . ROOT_PATH);
}
$content = "";
foreach ($envData as $key => $value) {
$content .= "{$key}={$value}\n";
}
fwrite($fp, $content);
fclose($fp);
}

View File

@@ -157,7 +157,7 @@ if ($currentStep == 4) {
$tableRows = $settingTableRows['table_rows'];
$pass = $settingTableRows['pass'];
$mysqlInfo = $update->getMysqlVersionInfo();
$redisInfo = $update->getREdisVersionInfo();
$redisInfo = $update->getRedisVersionInfo();
while ($isPost) {
set_time_limit(300);
try {