psck module

This commit is contained in:
2024-10-09 15:12:30 +03:00
parent 77933cdd9e
commit fa2676ddb2
32 changed files with 36 additions and 924 deletions

View File

@ -34,13 +34,14 @@ class ModuleController extends ConsoleController
$this->out->r('Message: Ошибка чтения архива', 'red');
}
if (file_exists($tmpModuleDirFull . "manifest.json")){
$manifestJson = getConst(file_get_contents($tmpModuleDirFull . "manifest.json"));
if (file_exists($tmpModuleDirFull . "/app/manifest.json")){
$manifestJson = getConst(file_get_contents($tmpModuleDirFull . "/app/manifest.json"));
$manifest = Manifest::getWithVars($manifestJson);
$this->out->r('manifest.json инициализирован', 'green');
$fileHelper = new Files();
$fileHelper->copy_folder($tmpModuleDirFull, $manifest['module_path']);
$fileHelper->copy_folder($tmpModuleDirFull . '/app', $manifest['app_module_path']);
$fileHelper->copy_folder($tmpModuleDirFull . '/kernel', $manifest['kernel_module_path']);
$this->out->r("Удаляем временные файлы", 'green');
$fileHelper->recursiveRemoveDir($tmpModuleDirFull);
@ -60,18 +61,21 @@ class ModuleController extends ConsoleController
if (file_exists(ROOT_DIR . $this->argv['path'])) {
$moduleService = new ModuleService();
$moduleInfo = $moduleService->getModuleInfo(ROOT_DIR . $this->argv['path']);
$moduleInfo = $moduleService->getModuleInfo(APP_DIR . '/modules/' . basename($this->argv['path']));
if ($moduleService->isActive($moduleInfo['slug'])) {
$moduleService->setActiveModule($moduleInfo['slug']);
}
$fileHelper = new Files();
$fileHelper->recursiveRemoveDir(ROOT_DIR . $this->argv['path']);
if (file_exists(APP_DIR . '/modules/' . $moduleInfo['slug'])) {
$fileHelper->recursiveRemoveDir(APP_DIR . '/modules/'. $moduleInfo['slug']);
}
if (file_exists(KERNEL_APP_MODULES_DIR . '/' . $moduleInfo['slug'])) {
$fileHelper->recursiveRemoveDir(KERNEL_APP_MODULES_DIR . '/' . $moduleInfo['slug']);
}
$this->out->r("Модуль удален", 'green');
} else {
var_dump($this->argv['path']);
$this->out->r("Модуль не найден", 'red');
}
}
@ -91,17 +95,13 @@ class ModuleController extends ConsoleController
$fileHelper->copy_folder(APP_DIR . '/modules/' . $moduleName, $tmpModuleDirFull . 'app/');
$fileHelper->copy_folder(KERNEL_APP_MODULES_DIR . '/' . $moduleName, $tmpModuleDirFull . 'kernel/');
$this->out->r("Модуль собран в одну папку", 'green');
$this->out->r("Модуль собран во временную папку", 'green');
// $fileHelper->pack($zip, RESOURCES_DIR . '/tmp/modules/' . $moduleName . '.zip');
$fileHelper->pack($tmpModuleDirFull, RESOURCES_DIR . '/tmp/modules/' . $moduleName . '.zip');
// $zip->addEmptyDir($moduleName);
// $zip->close();
// $this->out->r("zip закрыт", 'green');
$fileHelper->pack($tmpModuleDirFull, RESOURCES_DIR . '/tmp/modules/' . $moduleName . '.itguild');
$this->out->r("Архив создан", 'green');
$fileHelper->recursiveRemoveDir($tmpModuleDirFull);
$this->out->r("Временная папка удалена", 'green');
}
}