bootstrap, .env.ezample to add update add
This commit is contained in:
parent
ffa659ea1d
commit
a00f6566b2
@ -26,59 +26,78 @@ class KernelController extends ConsoleController
|
||||
}
|
||||
|
||||
if (file_exists(ROOT_DIR . $this->argv['path'])) {
|
||||
|
||||
$tmpKernelDirFull = RESOURCES_DIR . '/tmp/ad/kernel/';
|
||||
|
||||
$fileHelper = new Files();
|
||||
$fileHelper->copy_folder(KERNEL_DIR, $tmpKernelDirFull);
|
||||
|
||||
if (!is_dir(RESOURCES_DIR . '/tmp/kernel')) {
|
||||
mkdir(RESOURCES_DIR . '/tmp/kernel');
|
||||
}
|
||||
$fileHelper->pack($tmpKernelDirFull, RESOURCES_DIR . '/tmp/kernel/kernel.igk');
|
||||
|
||||
$fileHelper->recursiveRemoveDir($tmpKernelDirFull);
|
||||
$this->out->r("Ядро заархивировано", 'green');
|
||||
$tmpKernelDirFull = RESOURCES_DIR . '/tmp/ad/app/kernel';
|
||||
$this->files->copy_folder(KERNEL_DIR, $tmpKernelDirFull);
|
||||
$this->out->r("Ядро скопировано во временную папку", 'green');
|
||||
} else {
|
||||
$this->out->r("Ядро не найдено", 'red');
|
||||
}
|
||||
|
||||
if (isset($this->argv['bootstrap'])) {
|
||||
if (file_exists(ROOT_DIR . '/bootstrap')) {
|
||||
$tmpBootstrapDirFull = RESOURCES_DIR . '/tmp/ad/app/bootstrap';
|
||||
$this->files->copy_folder(ROOT_DIR . '/bootstrap', $tmpBootstrapDirFull);
|
||||
$this->out->r("/bootstrap скопирован во временную папку", 'green');
|
||||
} else {
|
||||
$this->out->r("/bootstrap не найден", 'red');
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($this->argv['.env'])) {
|
||||
if (file_exists(ROOT_DIR . '/.env.example')) {
|
||||
$tmpEnvFull = RESOURCES_DIR . '/tmp/ad/app/env.example';
|
||||
copy(ROOT_DIR . '/.env.example', $tmpEnvFull);
|
||||
$this->out->r("/.env.example скопирован во временную папку", 'green');
|
||||
} else {
|
||||
$this->out->r("/.env.example не найден", 'red');
|
||||
}
|
||||
}
|
||||
|
||||
if (!is_dir(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->recursiveRemoveDir(RESOURCES_DIR . '/tmp/ad/app/');
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function actionUpdateKernel()
|
||||
public function actionUpdateKernel(): void
|
||||
{
|
||||
if (!isset($this->argv['path'])) {
|
||||
throw new \Exception('Missing kernel path "--path" specified');
|
||||
}
|
||||
|
||||
$path = $this->argv['path'];
|
||||
|
||||
if (file_exists(ROOT_DIR . $path)) {
|
||||
$zip = new ZipArchive;
|
||||
$tmpKernelDir = md5(time());
|
||||
$res = $zip->open(ROOT_DIR . $path);
|
||||
$zip = new ZipArchive;
|
||||
if (file_exists(ROOT_DIR . $this->argv['path'])) {
|
||||
$tmpAppDir = md5(time());
|
||||
$res = $zip->open(ROOT_DIR . $this->argv['path']);
|
||||
if ($res === TRUE) {
|
||||
$tmpKernelDirFull = RESOURCES_DIR . '/tmp/kernel/' . $tmpKernelDir . "/";
|
||||
$zip->extractTo($tmpKernelDirFull);
|
||||
$tmpAppDirFull = RESOURCES_DIR . '/tmp/app/' . $tmpAppDir . "/";
|
||||
$zip->extractTo($tmpAppDirFull);
|
||||
$zip->close();
|
||||
$this->files->recursiveRemoveKernelDir();
|
||||
$this->files->copy_folder($tmpKernelDirFull , ROOT_DIR . "/kernel");
|
||||
$this->files->recursiveRemoveDir($tmpKernelDirFull);
|
||||
$this->out->r('Ядро обновлено.', 'green');
|
||||
$this->files->copy_folder($tmpAppDirFull . 'kernel' , ROOT_DIR . "/kernel");
|
||||
|
||||
if (isset($this->argv['bootstrap'])) {
|
||||
$this->files->recursiveRemoveDir(ROOT_DIR . '/bootstrap');
|
||||
$this->files->copy_folder($tmpAppDirFull . 'bootstrap' , ROOT_DIR . '/bootstrap');
|
||||
}
|
||||
|
||||
if (isset($this->argv['.env'])) {
|
||||
copy($tmpAppDirFull . 'env.example', ROOT_DIR . '/.env.example');
|
||||
}
|
||||
|
||||
$this->files->recursiveRemoveDir($tmpAppDirFull);
|
||||
$this->out->r('Приложение обновлено.', 'green');
|
||||
} else {
|
||||
$this->out->r('unable to open zip archive', 'red');
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
$this->out->r("Модуль не найден", 'red');
|
||||
$this->out->r("archive not found", 'red');
|
||||
}
|
||||
}
|
||||
|
||||
public function test()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -47,14 +47,15 @@ class Files
|
||||
{
|
||||
$includes = new FilesystemIterator(KERNEL_DIR);
|
||||
foreach ($includes as $include) {
|
||||
if(is_dir($include) && !is_link($include) && $include->getFilename() !== 'app_modules') {
|
||||
if ($include->getFilename() === 'app_modules') continue;
|
||||
|
||||
if(is_dir($include) && !is_link($include)) {
|
||||
$this->recursiveRemoveDir($include);
|
||||
}
|
||||
else {
|
||||
unlink($include);
|
||||
}
|
||||
}
|
||||
rmdir(KERNEL_DIR);
|
||||
}
|
||||
|
||||
public function pack(string $source, string $destination/*, bool $include_source = true*/): void
|
||||
|
@ -49,6 +49,6 @@ class SecureRestController extends RestController
|
||||
}
|
||||
|
||||
$this->renderApi($res);
|
||||
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user