|
@@ -0,0 +1,83 @@
|
|
|
|
+<?php
|
|
|
|
+
|
|
|
|
+namespace FD3;
|
|
|
|
+
|
|
|
|
+use Symfony\Component\Console\Command\Command;
|
|
|
|
+use Symfony\Component\Console\Input\InputInterface;
|
|
|
|
+use Symfony\Component\Console\Input\InputArgument;
|
|
|
|
+use Symfony\Component\Console\Input\InputOption;
|
|
|
|
+use Symfony\Component\Console\Output\OutputInterface;
|
|
|
|
+
|
|
|
|
+class UpdateFlowdatModulesCommand extends Command
|
|
|
|
+{
|
|
|
|
+ protected function configure()
|
|
|
|
+ {
|
|
|
|
+ $this
|
|
|
|
+ ->setName('ik:update:modules')
|
|
|
|
+ ->setDescription('Update flowdat modules to some release.')
|
|
|
|
+ ->setHelp('Update flowdat modules to some release.')
|
|
|
|
+ ->addArgument('ini_module_file', InputArgument::REQUIRED, 'The ini file from where to get the source code config.')
|
|
|
|
+ ->addArgument('version', InputArgument::REQUIRED, 'Use the version expression.')
|
|
|
|
+ ->addArgument('remote', InputArgument::OPTIONAL, 'Remote repository.', 'origin')
|
|
|
|
+ ->addArgument('tag', InputArgument::OPTIONAL, 'If release is tag then true.', 'TRUE')
|
|
|
|
+ ;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ protected function execute(InputInterface $input, OutputInterface $output)
|
|
|
|
+ {
|
|
|
|
+ $file = $input->getArgument("ini_module_file");
|
|
|
|
+ $version = $input->getArgument("version");
|
|
|
|
+ $remote = $input->getArgument("remote");
|
|
|
|
+ $tag = strtolower($input->getArgument("tag")) === 'true';
|
|
|
|
+
|
|
|
|
+ if ($tag) {
|
|
|
|
+ $values = explode('.', $version);
|
|
|
|
+ unset ($values[count($values) - 1]);
|
|
|
|
+ $versionOnly = implode ('.', $values);
|
|
|
|
+ } else {
|
|
|
|
+ $versionOnly = $version;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ $realpath = realpath($file);
|
|
|
|
+ $dirname = dirname($realpath);
|
|
|
|
+ if (!chdir($dirname)) {
|
|
|
|
+ throw new \Exception("Can't change working directory to " . $dirname);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ $realpathModule = realpath(".");
|
|
|
|
+ $dirnameModule = dirname($realpathModule);
|
|
|
|
+
|
|
|
|
+ $content = parse_ini_file($realpath, true);
|
|
|
|
+ $error = '';
|
|
|
|
+ foreach ($content as $sec => $conf) {
|
|
|
|
+ try {
|
|
|
|
+ $output->writeln('-------------------------------------------------------------------------------------');
|
|
|
|
+ $output->writeln('Module: ' . $sec);
|
|
|
|
+ if ($tag) {
|
|
|
|
+ $command = 'cd ' . $sec . ' && git stash && git checkout -B ' . $versionOnly . ' && git fetch ' . $remote .
|
|
|
|
+ ' ' . $versionOnly . ':refs/tags/' . $versionOnly . ' && git merge -X theirs ' . $version;
|
|
|
|
+ } else {
|
|
|
|
+ $command = 'cd ' . $sec . ' && git stash && git checkout -B ' . $versionOnly . ' && git fetch ' . $remote . ' ' . $version;
|
|
|
|
+ }
|
|
|
|
+ $output->writeln("\tComando: " . $command);
|
|
|
|
+ $resp = shell_exec ($command);
|
|
|
|
+ $output->writeln($resp);
|
|
|
|
+
|
|
|
|
+ $command = "docker-compose exec " . $sec . " composer install";
|
|
|
|
+ $output->writeln("\tComando: " . $command);
|
|
|
|
+ $resp = shell_exec ($command);
|
|
|
|
+ $output->writeln($resp);
|
|
|
|
+ } catch (\Throwable $t) {
|
|
|
|
+ $error .= $t->getTraceAsString() . "\n";
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (strlen($error) > 0) {
|
|
|
|
+ $output->writeln("SE PRODUJERON LOS SIGUIENTES ERRORES: \n" . $error);
|
|
|
|
+ /**
|
|
|
|
+ * SE PUEDEN PARAR LOS DOCKERS, BORRAR LOS DIRECTORIOS DE LOS MÓDULOS Y COPIARLOS DESDE EL BACKUP.
|
|
|
|
+ * TENER CUIDADO CON LOS DIRECTORIOS mysql, mongo y extra PORQUE PUEDE AVANZAR DESDE EL BACKUP.
|
|
|
|
+ */
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|