Skip to content

Commit

Permalink
update include update env file
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaomlove committed Dec 29, 2024
1 parent 3cf7b36 commit 0f88ab8
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 165 deletions.
6 changes: 6 additions & 0 deletions app/Console/Commands/NexusUpdate.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,12 @@ public function handle()
$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!");
Expand Down
4 changes: 2 additions & 2 deletions app/Console/Commands/Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ public function handle()
$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);
}

}
1 change: 0 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
159 changes: 1 addition & 158 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion nexus/Attachment/Storage.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ public function uploadGetLocation(string $filepath, string $originalName): strin
throw new \Exception("Failed to move uploaded file.");
}
$url = $this->upload($newFilepath);
@unlink($filepath);
@unlink($newFilepath);
} else {
$url = $this->upload($filepath);
Expand Down
7 changes: 5 additions & 2 deletions nexus/Install/Install.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class Install
{
protected $currentStep;

protected $minimumPhpVersion = '8.0.3';
protected $minimumPhpVersion = '8.2.0';

protected $progressKeyPrefix = '__step';

Expand All @@ -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"],
];
Expand Down
23 changes: 23 additions & 0 deletions nexus/Install/Update.php
Original file line number Diff line number Diff line change
Expand Up @@ -536,6 +536,29 @@ private function isSnatchedTableTorrentUserUnique(): bool
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);
}




Expand Down
2 changes: 1 addition & 1 deletion nexus/Install/update/update.php
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@
$tableRows = $settingTableRows['table_rows'];
$pass = $settingTableRows['pass'];
$mysqlInfo = $update->getMysqlVersionInfo();
$redisInfo = $update->getREdisVersionInfo();
$redisInfo = $update->getRedisVersionInfo();
while ($isPost) {
set_time_limit(300);
try {
Expand Down

0 comments on commit 0f88ab8

Please sign in to comment.