This commit is contained in:
Билай Станислав 2024-10-23 15:03:06 +03:00
parent a00f6566b2
commit 76d090febf
2 changed files with 37 additions and 29 deletions

View File

@ -26,39 +26,43 @@ class KernelController extends ConsoleController
} }
if (file_exists(ROOT_DIR . $this->argv['path'])) { if (file_exists(ROOT_DIR . $this->argv['path'])) {
$tmpKernelDirFull = RESOURCES_DIR . '/tmp/ad/app/kernel'; $tmpKernelDirFull = RESOURCES_DIR . '/tmp/ad/kernel/kernel';
$this->files->copy_folder(KERNEL_DIR, $tmpKernelDirFull); $this->files->copy_folder(KERNEL_DIR, $tmpKernelDirFull);
$this->out->r("Ядро скопировано во временную папку", 'green'); $this->out->r("Ядро скопировано во временную папку", 'green');
} else { } else {
$this->out->r("Ядро не найдено", 'red'); $this->out->r("Ядро не найдено", 'red');
} }
if (isset($this->argv['bootstrap'])) { if (file_exists(ROOT_DIR . '/bootstrap')) {
if (file_exists(ROOT_DIR . '/bootstrap')) { $tmpBootstrapDirFull = RESOURCES_DIR . '/tmp/ad/kernel/bootstrap';
$tmpBootstrapDirFull = RESOURCES_DIR . '/tmp/ad/app/bootstrap'; $this->files->copy_folder(ROOT_DIR . '/bootstrap', $tmpBootstrapDirFull);
$this->files->copy_folder(ROOT_DIR . '/bootstrap', $tmpBootstrapDirFull); $this->out->r("/bootstrap скопирован во временную папку", 'green');
$this->out->r("/bootstrap скопирован во временную папку", 'green'); } else {
} else { $this->out->r("/bootstrap не найден", 'red');
$this->out->r("/bootstrap не найден", 'red');
}
} }
if (isset($this->argv['.env'])) { if (file_exists(ROOT_DIR . '/.env.example')) {
if (file_exists(ROOT_DIR . '/.env.example')) { $tmpEnvDirFull = RESOURCES_DIR . '/tmp/ad/kernel/env.example';
$tmpEnvFull = RESOURCES_DIR . '/tmp/ad/app/env.example'; copy(ROOT_DIR . '/.env.example', $tmpEnvDirFull);
copy(ROOT_DIR . '/.env.example', $tmpEnvFull); $this->out->r("/.env.example скопирован во временную папку", 'green');
$this->out->r("/.env.example скопирован во временную папку", 'green'); } else {
} else { $this->out->r("/.env.example не найден", 'red');
$this->out->r("/.env.example не найден", 'red'); }
}
if (file_exists(ROOT_DIR . '/composer.json')) {
$tmpComposerDirFull = RESOURCES_DIR . '/tmp/ad/kernel/composer.json';
copy(ROOT_DIR . '/composer.json', $tmpComposerDirFull);
$this->out->r("/composer.json скопирован во временную папку", 'green');
} else {
$this->out->r("/composer.json не найден", 'red');
} }
if (!is_dir(RESOURCES_DIR . '/tmp/app')) { if (!is_dir(RESOURCES_DIR . '/tmp/app')) {
mkdir(RESOURCES_DIR . '/tmp/app'); mkdir(RESOURCES_DIR . '/tmp/app');
} }
$this->files->pack(RESOURCES_DIR . '/tmp/ad/app/', RESOURCES_DIR . '/tmp/app/app.iga'); $this->files->pack(RESOURCES_DIR . '/tmp/ad/kernel/', RESOURCES_DIR . '/tmp/kernel/kernel.igk');
$this->files->recursiveRemoveDir(RESOURCES_DIR . '/tmp/ad/app/'); $this->files->recursiveRemoveDir(RESOURCES_DIR . '/tmp/ad/kernel/');
} }
/** /**
@ -72,26 +76,30 @@ class KernelController extends ConsoleController
$zip = new ZipArchive; $zip = new ZipArchive;
if (file_exists(ROOT_DIR . $this->argv['path'])) { if (file_exists(ROOT_DIR . $this->argv['path'])) {
$tmpAppDir = md5(time()); $tmpKernelDir = md5(time());
$res = $zip->open(ROOT_DIR . $this->argv['path']); $res = $zip->open(ROOT_DIR . $this->argv['path']);
if ($res === TRUE) { if ($res === TRUE) {
$tmpAppDirFull = RESOURCES_DIR . '/tmp/app/' . $tmpAppDir . "/"; $tmpKernelDirFull = RESOURCES_DIR . '/tmp/kernel/' . $tmpKernelDir . "/";
$zip->extractTo($tmpAppDirFull); $zip->extractTo($tmpKernelDirFull);
$zip->close(); $zip->close();
$this->files->recursiveRemoveKernelDir(); $this->files->recursiveRemoveKernelDir();
$this->files->copy_folder($tmpAppDirFull . 'kernel' , ROOT_DIR . "/kernel"); $this->files->copy_folder($tmpKernelDirFull . 'kernel' , ROOT_DIR . "/kernel");
if (isset($this->argv['bootstrap'])) { if (isset($this->argv['bootstrap'])) {
$this->files->recursiveRemoveDir(ROOT_DIR . '/bootstrap'); $this->files->recursiveRemoveDir(ROOT_DIR . '/bootstrap');
$this->files->copy_folder($tmpAppDirFull . 'bootstrap' , ROOT_DIR . '/bootstrap'); $this->files->copy_folder($tmpKernelDirFull . 'bootstrap' , ROOT_DIR . '/bootstrap');
} }
if (isset($this->argv['.env'])) { if (isset($this->argv['env'])) {
copy($tmpAppDirFull . 'env.example', ROOT_DIR . '/.env.example'); copy($tmpKernelDirFull . 'env.example', ROOT_DIR . '/.env.example');
} }
$this->files->recursiveRemoveDir($tmpAppDirFull); if (isset($this->argv['composer'])) {
$this->out->r('Приложение обновлено.', 'green'); copy($tmpKernelDirFull . 'composer.json', ROOT_DIR . '/composer.json');
}
$this->files->recursiveRemoveDir($tmpKernelDirFull);
$this->out->r('Ядро обновлено.', 'green');
} else { } else {
$this->out->r('unable to open zip archive', 'red'); $this->out->r('unable to open zip archive', 'red');
} }

View File

@ -50,5 +50,5 @@ class SecureRestController extends RestController
$this->renderApi($res); $this->renderApi($res);
} }
} }