prepare beta12

This commit is contained in:
xiaomlove
2021-06-22 12:56:03 +08:00
parent c5326513a1
commit 142e18bed0
7 changed files with 43 additions and 22 deletions
+17
View File
@@ -268,6 +268,7 @@ class Install
public function gotoStep($step)
{
nexus_redirect(getBaseUrl() . "?step=$step");
die(0);
}
public function maxStep()
@@ -537,4 +538,20 @@ class Install
}
return true;
}
public function runMigrate()
{
if (!WITH_LARAVEL) {
throw new \RuntimeException('Laravel is not avaliable.');
}
$command = "php " . ROOT_PATH . "artisan migrate --force";
$result = exec($command, $output, $result_code);
$this->doLog(sprintf('command: %s, result_code: %s, result: %s', $command, $result_code, $result));
$this->doLog("output: " . json_encode($output));
if ($result_code != 0) {
throw new \RuntimeException(json_encode($output));
} else {
$this->doLog("[MIGRATE] success.");
}
}
}
+1 -1
View File
@@ -20,7 +20,7 @@ use Nexus\Database\NexusDB;
class Update extends Install
{
protected $steps = ['环境检测', '选择版本安装', '更新 .env 文件', '更新配置'];
protected $steps = ['环境检测', '获取更新', '更新 .env 文件', '执行更新'];
public function getLogFile()
+1 -11
View File
@@ -124,18 +124,8 @@ if ($currentStep == 4) {
while ($isPost) {
try {
$install->createSymbolicLinks($symbolicLinks);
$install->runMigrate();
$install->saveSettings($settings);
// $install->importInitialData();
//use seed
$command = "php " . ROOT_PATH . "artisan db:seed";
$result = exec($command, $output, $result_code);
$install->doLog(sprintf('command: %s, result_code: %s, result: %s', $command, $result_code, $result));
$install->doLog("output: " . json_encode($output));
if ($result_code != 0) {
throw new \RuntimeException(json_encode($output));
} else {
$install->doLog("[INIT DATA] success.");
}
$install->nextStep();
} catch (\Exception $e) {
$error = $e->getMessage();
+18 -8
View File
@@ -27,22 +27,28 @@ if ($currentStep == 2) {
$versionTable = $versions = [];
$cacheKkey = '__versions_' . date('Ymd_H');
try {
if (!empty($_SESSION[$cacheKkey])) {
$update->doLog("get versions from session.");
$versions = $_SESSION[$cacheKkey];
} else {
$versions = $update->listVersions();
}
$versions = $update->listVersions();
// if (!empty($_SESSION[$cacheKkey])) {
// $update->doLog("get versions from session.");
// $versions = $_SESSION[$cacheKkey];
// } else {
// $_SESSION[$cacheKkey] = $versions;
// }
} catch (\Exception $exception) {
$error = $exception->getMessage();
}
$_SESSION[$cacheKkey] = $versions;
$versionHeader = [
'checkbox' => '选择',
'tag_name' => '版本(标签)',
'name' => '名称',
'published_at' => '发布时间',
];
$tableRows[] = [
'checkbox' => sprintf('<input type="radio" name="version_url" value="manual"/>'),
'tag_name' => '手动更新',
'name' => '如若有改动不宜全量覆盖,请勾选此选项并确保已经手动更新了代码',
'published_at' => '---',
];
foreach ($versions as $version) {
if ($version['draft']) {
continue;
@@ -58,11 +64,15 @@ if ($currentStep == 2) {
'published_at' => $time->format('Y-m-d H:i:s'),
];
}
// dd($tableRows);
while ($isPost) {
try {
if (empty($_REQUEST['version_url'])) {
throw new \RuntimeException("没有选择版本");
}
if ($_REQUEST['version_url'] == 'manual') {
$update->nextStep();
}
$versionUrlArr = explode('|', $_REQUEST['version_url']);
$version = strtolower($versionUrlArr[0]);
$downloadUrl = $versionUrlArr[1];
@@ -129,6 +139,7 @@ if ($currentStep == 4) {
while ($isPost) {
try {
$update->createSymbolicLinks($symbolicLinks);
$update->runMigrate();
$update->saveSettings($settings);
$update->runExtraQueries();
$update->nextStep();
@@ -176,7 +187,6 @@ if (!empty($error)) {
echo $update->renderForm($envFormControls);
} elseif ($currentStep == 2) {
echo '<h1 class="mb-4 text-lg font-bold">选择目标版本(注意必须选择比当前版本(' . VERSION_NUMBER. ')高的)</h1>';
if (empty($tableRows)) {
echo '<div class="text-green-600 text-center">抱歉,暂无任何版可以选择!</div>';
} else {