-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathUpgradeProject.php
More file actions
52 lines (48 loc) · 2.44 KB
/
UpgradeProject.php
File metadata and controls
52 lines (48 loc) · 2.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<?php
namespace PSFS\Command;
use Symfony\Component\Console\Application;
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
if (!isset($console)) {
$console = new Application();
}
$console
->register('psfs:update:project')
->setDescription(t('Actualización de configuraciones de proyectos en PSFS'))
->setCode(function (InputInterface $input, OutputInterface $output) use ($console) {
// Clean up config files...
if(file_exists(CONFIG_DIR . DIRECTORY_SEPARATOR . 'domains.json')) {
rename(CONFIG_DIR . DIRECTORY_SEPARATOR . 'domains.json', CONFIG_DIR . DIRECTORY_SEPARATOR . 'domains.json.bak');
}
if(file_exists(CONFIG_DIR . DIRECTORY_SEPARATOR . 'urls.json')) {
rename(CONFIG_DIR . DIRECTORY_SEPARATOR . 'urls.json', CONFIG_DIR . DIRECTORY_SEPARATOR . 'urls.json.bak');
}
$modules = \PSFS\base\Router::getInstance()->getDomains();
$output->writeln("Hay un total de " . (count($modules) - 1) . " ha actualizar");
foreach ($modules as $module => $config) {
$clean_module = str_replace(['@', '\\', '/'], '', $module);
if ($clean_module !== 'ROOT') {
$output->write("\t- Actualizando módulo {$clean_module}");
$configPath = $config['base'] . DIRECTORY_SEPARATOR . 'Config';
// Cleaning up config files and autoloader
if(file_exists($configPath . DIRECTORY_SEPARATOR . 'domains.json')) {
rename($configPath . DIRECTORY_SEPARATOR . 'config.php', $configPath . DIRECTORY_SEPARATOR . 'config.php.bak');
}
if(file_exists($configPath . DIRECTORY_SEPARATOR . 'propel.yml')) {
unlink($configPath . DIRECTORY_SEPARATOR . 'propel.yml');
}
\PSFS\services\GeneratorService::getInstance()->generateConfigurationTemplates($clean_module, $config['base']);
$output->writeln("\tDONE!");
}
}
$router = \PSFS\base\Router::getInstance();
$router->hydrateRouting();
$router->simpatize();
$output->writeln(t("Rutas del proyecto actualizadas con éxito"));
// Run the deployment command
$commandInput = new ArrayInput([
'command' => 'psfs:deploy:project',
]);
$console->run($commandInput, $output);
});