|
@@ -3,8 +3,8 @@
|
|
|
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\InputInterface;
|
|
|
use Symfony\Component\Console\Input\InputOption;
|
|
|
use Symfony\Component\Console\Output\OutputInterface;
|
|
|
|
|
@@ -18,9 +18,9 @@ class ComposerRequireCommand extends Command
|
|
|
->setHelp('This command allows you to tag and change the required code on the composer.json file...')
|
|
|
->addArgument('ini_file', InputArgument::REQUIRED, 'The ini file from where to get the source code config.')
|
|
|
->addArgument('packages', InputArgument::REQUIRED, 'Tag the required packages (suggested value : ik/*).')
|
|
|
- ->addArgument('version', InputArgument::REQUIRED, 'Use the version expression.')
|
|
|
- ->addOption('composer_update', null, InputOption::VALUE_OPTIONAL, 'If true, run "docker-compose run ... bin/composer-update.sh" to generate composer.lock', 'true')
|
|
|
- ->addOption('pull', null, InputOption::VALUE_OPTIONAL, 'Indicates branch to pull for every modules', '');
|
|
|
+ ->addArgument('version', InputArgument::REQUIRED, 'Use the version expression.')
|
|
|
+ ->addOption('composer_update', null, InputOption::VALUE_OPTIONAL, 'If true, run "docker-compose run ... bin/composer-update.sh" to generate composer.lock', 'true')
|
|
|
+ ->addOption('pull', null, InputOption::VALUE_OPTIONAL, 'Indicates branch to pull for every modules', '');
|
|
|
}
|
|
|
|
|
|
protected function execute(InputInterface $input, OutputInterface $output)
|
|
@@ -43,54 +43,55 @@ class ComposerRequireCommand extends Command
|
|
|
$output->writeln("----------------------------------------------------------------------");
|
|
|
$output->writeln($sec);
|
|
|
$composer_data = json_decode(file_get_contents($composer_file), true);
|
|
|
- try {
|
|
|
+ try {
|
|
|
foreach (array("require", "require-dev") as $k) {
|
|
|
- $output->writeln('Ejecutando:');
|
|
|
- $command = 'cd ' . $sec . '; git stash; git fetch; git checkout master; git pull origin master';
|
|
|
- $output->writeln("\t" . $command);
|
|
|
+ $output->writeln('Ejecutando:');
|
|
|
+ $command = 'cd ' . $sec . '; git stash; git fetch; git checkout master; git pull origin master';
|
|
|
+ $output->writeln("\t" . $command);
|
|
|
shell_exec($command);
|
|
|
if (strlen($pull) > 0) {
|
|
|
- $command = 'cd ' . $sec . '; git pull origin ' . $pull;
|
|
|
- $output->writeln("\t" . $command);
|
|
|
+ $command = 'cd ' . $sec . '; git pull origin ' . $pull;
|
|
|
+ $output->writeln("\t" . $command);
|
|
|
shell_exec($command);
|
|
|
}
|
|
|
- $output->writeln("\t" . 'Reemplazo composer.json');
|
|
|
+ $output->writeln("\t" . 'Reemplazo composer.json');
|
|
|
foreach ($composer_data[$k] as $package => $version) {
|
|
|
if (strpos($packages, "*") !== false) {
|
|
|
$preg = "|^" . str_replace("*", "[^\b]*", $packages) . "$|";
|
|
|
if (preg_match($preg, $package)) {
|
|
|
- $composer_data[$k][$package] = (string)$new_version;
|
|
|
+ $composer_data[$k][$package] = (string) $new_version;
|
|
|
$output->writeln("\t\t" . $package . " = " . $new_version);
|
|
|
}
|
|
|
- } else {
|
|
|
+ } else {
|
|
|
if (strcmp($packages, $package) === 0) {
|
|
|
- $composer_data[$k][$package] = (string)$new_version;
|
|
|
- $output->writeln("\t\t" . $package . " = " . $new_version);
|
|
|
+ $composer_data[$k][$package] = (string) $new_version;
|
|
|
+ $output->writeln("\t\t" . $package . " = " . $new_version);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
file_put_contents($composer_file, json_encode($composer_data, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));
|
|
|
- if ($dockerCompose) {
|
|
|
- $output->writeln('Composer update');
|
|
|
- $command = 'docker-compose exec ' . $sec . ' bin/composer-update.sh';
|
|
|
- $output->writeln("\t" . $command);
|
|
|
- $resp = shell_exec($command);
|
|
|
- if ($resp) {
|
|
|
- $output->writeln("\tSalida comando.");
|
|
|
- $output->writeln("\t\t" . $resp);
|
|
|
- }
|
|
|
+ $output->writeln('Composer update');
|
|
|
+ if ($dockerCompose) {
|
|
|
+ $command = 'docker-compose exec ' . $sec . ' bin/composer-update.sh';
|
|
|
+ } else {
|
|
|
+ $command = 'bash bin/composer-update.sh';
|
|
|
}
|
|
|
- } catch (Throwable $t) {
|
|
|
- $output->writeln('Se produjo un error. Reestableciendo datos.');
|
|
|
- $command = 'cd ' . $sec . '; git reset';
|
|
|
- $output->writeln("\t" . $command);
|
|
|
+ $output->writeln("\t" . $command);
|
|
|
+ $resp = shell_exec($command);
|
|
|
+ if ($resp) {
|
|
|
+ $output->writeln("\tSalida comando.");
|
|
|
+ $output->writeln("\t\t" . $resp);
|
|
|
+ }
|
|
|
+ } catch (Throwable $t) {
|
|
|
+ $output->writeln('Se produjo un error. Reestableciendo datos.');
|
|
|
+ $command = 'cd ' . $sec . '; git reset';
|
|
|
+ $output->writeln("\t" . $command);
|
|
|
$shell_exec($command);
|
|
|
- }
|
|
|
+ }
|
|
|
} else {
|
|
|
$output->writeln($sec . " no composer.json found");
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|