mirror of
https://git.code.sf.net/p/seeddms/code
synced 2025-11-27 18:10:42 +00:00
output number in updatable, installable extensions, code cleanup
This commit is contained in:
parent
886a5eaf62
commit
929a2acd25
|
|
@ -68,23 +68,21 @@ class UpdateextensionCommand extends Command
|
|||
$installs = [];
|
||||
/* Get a list of available extensions from the repository */
|
||||
if($ret = $extmgr->updateExtensionList('', true)) {
|
||||
// $output->writeln(sprintf("<info>Updated extension list from repository.</info>"));
|
||||
// list of installed extensions
|
||||
$extconfs = $extmgr->getExtensionConfiguration();
|
||||
// list of extensions in repository, this will just return the
|
||||
// latest version of an extension
|
||||
$list = $extmgr->getExtensionList();
|
||||
// print_r($list);
|
||||
foreach($list as $extname=>$data) {
|
||||
$extversions = $extmgr->getExtensionListByName($extname);
|
||||
// print_r($extversions);
|
||||
$updates[$extname] = [];
|
||||
$installs[$extname] = [];
|
||||
$allowedversions = [];
|
||||
// $updates[$extname] = [];
|
||||
// $installs[$extname] = [];
|
||||
foreach($extversions as $version=>$extversion) {
|
||||
/* Only version which pass the check will be offered for
|
||||
* update or install.
|
||||
*/
|
||||
$check = $extmgr->checkExtensionByName($extname, $extversion);
|
||||
if ($check) {
|
||||
$allowedversions[] = '<info>'.$version.'</info>';
|
||||
if (isset($extconfs[$extname])) {
|
||||
if (\Seeddms\Seeddms\ExtensionMgr::cmpVersion($version, $extconfs[$extname]['version']) > 0) {
|
||||
$updates[$extname][$version] = $extversion;
|
||||
|
|
@ -92,60 +90,64 @@ class UpdateextensionCommand extends Command
|
|||
} else {
|
||||
$installs[$extname][$version] = $extversion;
|
||||
}
|
||||
} else {
|
||||
$allowedversions[] = '<error>'.$version.'</error>';
|
||||
}
|
||||
}
|
||||
}
|
||||
$helper = new QuestionHelper();
|
||||
foreach($updates as $extname=>$update) {
|
||||
$availableversions = array_keys($update);
|
||||
if ($update) {
|
||||
$output->writeln(sprintf("<comment>Extension '%s' can be updated from %s to %s.</comment>", $extname, $extconfs[$extname]['version'], implode(', ', $availableversions)));
|
||||
$question = new Question(sprintf("<question>Enter version to update:</question> "), '');
|
||||
if ($answer = $helper->ask($input, $output, $question)) {
|
||||
if (in_array($answer, $availableversions)) {
|
||||
$output->writeln(sprintf("<info>Update extension '%s' to version %s.</info>", $extname, $answer));
|
||||
if ($tmpfile = $extmgr->getExtensionFromRepository($update[$answer]['filename'])) {
|
||||
if($updates) {
|
||||
$output->writeln(sprintf("<options=bold>%d extensions can be updated.</>", count($updates)));
|
||||
foreach($updates as $extname=>$update) {
|
||||
$availableversions = array_keys($update);
|
||||
if ($update) {
|
||||
$output->writeln(sprintf("<comment>Extension '%s' can be updated from %s to %s.</comment>", $extname, $extconfs[$extname]['version'], implode(', ', $availableversions)));
|
||||
$question = new Question(sprintf("<question>Enter version to update:</question> "), '');
|
||||
if ($answer = $helper->ask($input, $output, $question)) {
|
||||
if (in_array($answer, $availableversions)) {
|
||||
$output->writeln(sprintf("<info>Update extension '%s' to version %s.</info>", $extname, $answer));
|
||||
if ($tmpfile = $extmgr->getExtensionFromRepository($update[$answer]['filename'])) {
|
||||
|
||||
if (0&&!$extmgr->updateExtension($tmpfile)) {
|
||||
foreach ($extmgr->getErrorMsgs() as $msg) {
|
||||
$output->writeln(sprintf("<error>%s</error>", $msg));
|
||||
if (0&&!$extmgr->updateExtension($tmpfile)) {
|
||||
foreach ($extmgr->getErrorMsgs() as $msg) {
|
||||
$output->writeln(sprintf("<error>%s</error>", $msg));
|
||||
}
|
||||
unlink($tmpfile);
|
||||
return Command::FAILURE;
|
||||
} else {
|
||||
unlink($tmpfile);
|
||||
}
|
||||
unlink($tmpfile);
|
||||
return Command::FAILURE;
|
||||
} else {
|
||||
unlink($tmpfile);
|
||||
}
|
||||
} else {
|
||||
$output->writeln(sprintf("<error>Invalid version %s.</error>", $answer));
|
||||
}
|
||||
} else {
|
||||
$output->writeln(sprintf("<error>Invalid version %s.</error>", $answer));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach($installs as $extname=>$install) {
|
||||
$availableversions = array_keys($install);
|
||||
if ($install) {
|
||||
$output->writeln(sprintf("<comment>Extension '%s' can be installed as version %s.</comment>", $extname, implode(', ', $availableversions)));
|
||||
$question = new Question(sprintf("<question>Enter version to install:</question> "), '');
|
||||
if ($answer = $helper->ask($input, $output, $question)) {
|
||||
if (in_array($answer, $availableversions)) {
|
||||
$output->writeln(sprintf("<info>Install extension '%s' to version %s.</info>", $extname, $answer));
|
||||
if ($tmpfile = $extmgr->getExtensionFromRepository($install[$answer]['filename'])) {
|
||||
if($installs) {
|
||||
$output->writeln(sprintf("<options=bold>%d extensions can be installed.</>", count($installs)));
|
||||
foreach($installs as $extname=>$install) {
|
||||
$availableversions = array_keys($install);
|
||||
if ($install) {
|
||||
$output->writeln(sprintf("<comment>Extension '%s' can be installed as version %s.</comment>", $extname, implode(', ', $availableversions)));
|
||||
$question = new Question(sprintf("<question>Enter version to install:</question> "), '');
|
||||
if ($answer = $helper->ask($input, $output, $question)) {
|
||||
if (in_array($answer, $availableversions)) {
|
||||
$output->writeln(sprintf("<info>Install extension '%s' to version %s.</info>", $extname, $answer));
|
||||
if ($tmpfile = $extmgr->getExtensionFromRepository($install[$answer]['filename'])) {
|
||||
|
||||
if (0&&!$extmgr->updateExtension($tmpfile)) {
|
||||
foreach ($extmgr->getErrorMsgs() as $msg) {
|
||||
$output->writeln(sprintf("<error>%s</error>", $msg));
|
||||
if (0&&!$extmgr->updateExtension($tmpfile)) {
|
||||
foreach ($extmgr->getErrorMsgs() as $msg) {
|
||||
$output->writeln(sprintf("<error>%s</error>", $msg));
|
||||
}
|
||||
unlink($tmpfile);
|
||||
return Command::FAILURE;
|
||||
} else {
|
||||
unlink($tmpfile);
|
||||
}
|
||||
unlink($tmpfile);
|
||||
return Command::FAILURE;
|
||||
} else {
|
||||
unlink($tmpfile);
|
||||
}
|
||||
} else {
|
||||
$output->writeln(sprintf("<error>Invalid version %s.</error>", $answer));
|
||||
}
|
||||
} else {
|
||||
$output->writeln(sprintf("<error>Invalid version %s.</error>", $answer));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user