Stream notes to console
This commit is contained in:
parent
4d1bec860d
commit
25bcc35020
|
|
@ -31,11 +31,15 @@ class UpdateManager
|
|||
use \October\Rain\Support\Traits\Singleton;
|
||||
|
||||
/**
|
||||
* The notes for the current operation.
|
||||
* @var array
|
||||
* @var array The notes for the current operation.
|
||||
*/
|
||||
protected $notes = [];
|
||||
|
||||
/**
|
||||
* @var \Illuminate\Console\OutputStyle
|
||||
*/
|
||||
protected $notesOutput;
|
||||
|
||||
/**
|
||||
* @var string Application base path.
|
||||
*/
|
||||
|
|
@ -365,9 +369,11 @@ class UpdateManager
|
|||
$this->migrator->run(base_path() . '/modules/'.strtolower($module).'/database/migrations');
|
||||
|
||||
$this->note($module);
|
||||
|
||||
foreach ($this->migrator->getNotes() as $note) {
|
||||
$this->note(' - '.$note);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
|
@ -466,13 +472,17 @@ class UpdateManager
|
|||
return;
|
||||
}
|
||||
|
||||
$this->versionManager->resetNotes();
|
||||
$this->note($name);
|
||||
|
||||
$this->versionManager->resetNotes()->setNotesOutput($this->notesOutput);
|
||||
|
||||
if ($this->versionManager->updatePlugin($plugin) !== false) {
|
||||
$this->note($name);
|
||||
|
||||
foreach ($this->versionManager->getNotes() as $note) {
|
||||
$this->note(' - '.$note);
|
||||
$this->note($note);
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
|
@ -689,11 +699,17 @@ class UpdateManager
|
|||
/**
|
||||
* Raise a note event for the migrator.
|
||||
* @param string $message
|
||||
* @return void
|
||||
* @return self
|
||||
*/
|
||||
protected function note($message)
|
||||
{
|
||||
$this->notes[] = $message;
|
||||
if ($this->notesOutput !== null) {
|
||||
$this->notesOutput->writeln($message);
|
||||
}
|
||||
else {
|
||||
$this->notes[] = $message;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
|
@ -708,11 +724,26 @@ class UpdateManager
|
|||
|
||||
/**
|
||||
* Resets the notes store.
|
||||
* @return array
|
||||
* @return self
|
||||
*/
|
||||
public function resetNotes()
|
||||
{
|
||||
$this->notesOutput = null;
|
||||
|
||||
$this->notes = [];
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets an output stream for writing notes.
|
||||
* @param Illuminate\Console\Command $output
|
||||
* @return self
|
||||
*/
|
||||
public function setNotesOutput($output)
|
||||
{
|
||||
$this->notesOutput = $output;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -36,6 +36,11 @@ class VersionManager
|
|||
*/
|
||||
protected $notes = [];
|
||||
|
||||
/**
|
||||
* @var \Illuminate\Console\OutputStyle
|
||||
*/
|
||||
protected $notesOutput;
|
||||
|
||||
/**
|
||||
* Cache of plugin versions as files.
|
||||
*/
|
||||
|
|
@ -85,7 +90,7 @@ class VersionManager
|
|||
|
||||
// No updates needed
|
||||
if ($currentVersion == $databaseVersion) {
|
||||
$this->note('<info>Nothing to update.</info>');
|
||||
$this->note('- <info>Nothing to update.</info>');
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -150,7 +155,7 @@ class VersionManager
|
|||
|
||||
$this->setDatabaseVersion($code, $version);
|
||||
|
||||
$this->note(sprintf('<info>v%s: </info> %s', $version, $comment));
|
||||
$this->note(sprintf('- <info>v%s: </info> %s', $version, $comment));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -471,7 +476,13 @@ class VersionManager
|
|||
*/
|
||||
protected function note($message)
|
||||
{
|
||||
$this->notes[] = $message;
|
||||
if ($this->notesOutput !== null) {
|
||||
$this->notesOutput->writeln($message);
|
||||
}
|
||||
else {
|
||||
$this->notes[] = $message;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
|
@ -486,11 +497,26 @@ class VersionManager
|
|||
|
||||
/**
|
||||
* Resets the notes store.
|
||||
* @return array
|
||||
* @return self
|
||||
*/
|
||||
public function resetNotes()
|
||||
{
|
||||
$this->notesOutput = null;
|
||||
|
||||
$this->notes = [];
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets an output stream for writing notes.
|
||||
* @param Illuminate\Console\Command $output
|
||||
* @return self
|
||||
*/
|
||||
public function setNotesOutput($output)
|
||||
{
|
||||
$this->notesOutput = $output;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,7 +15,6 @@ use Symfony\Component\Console\Input\InputArgument;
|
|||
*/
|
||||
class OctoberDown extends Command
|
||||
{
|
||||
|
||||
use \Illuminate\Console\ConfirmableTrait;
|
||||
|
||||
/**
|
||||
|
|
@ -45,11 +44,10 @@ class OctoberDown extends Command
|
|||
return;
|
||||
}
|
||||
|
||||
$manager = UpdateManager::instance()->resetNotes()->uninstall();
|
||||
|
||||
foreach ($manager->getNotes() as $note) {
|
||||
$this->output->writeln($note);
|
||||
}
|
||||
UpdateManager::instance()
|
||||
->setNotesOutput($this->output)
|
||||
->uninstall()
|
||||
;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -291,7 +291,11 @@ class OctoberInstall extends Command
|
|||
|
||||
try {
|
||||
Db::purge();
|
||||
UpdateManager::instance()->resetNotes()->update();
|
||||
|
||||
UpdateManager::instance()
|
||||
->setNotesOutput($this->output)
|
||||
->update()
|
||||
;
|
||||
}
|
||||
catch (Exception $ex) {
|
||||
$this->error($ex->getMessage());
|
||||
|
|
|
|||
|
|
@ -15,7 +15,6 @@ use Symfony\Component\Console\Input\InputArgument;
|
|||
*/
|
||||
class OctoberUp extends Command
|
||||
{
|
||||
|
||||
/**
|
||||
* The console command name.
|
||||
*/
|
||||
|
|
@ -39,13 +38,12 @@ class OctoberUp extends Command
|
|||
*/
|
||||
public function fire()
|
||||
{
|
||||
$manager = UpdateManager::instance()->resetNotes()->update();
|
||||
|
||||
$this->output->writeln('<info>Migrating application and plugins...</info>');
|
||||
|
||||
foreach ($manager->getNotes() as $note) {
|
||||
$this->output->writeln($note);
|
||||
}
|
||||
UpdateManager::instance()
|
||||
->setNotesOutput($this->output)
|
||||
->update()
|
||||
;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ class OctoberUpdate extends Command
|
|||
public function fire()
|
||||
{
|
||||
$this->output->writeln('<info>Updating October...</info>');
|
||||
$manager = UpdateManager::instance()->resetNotes();
|
||||
$manager = UpdateManager::instance()->setNotesOutput($this->output);
|
||||
$forceUpdate = $this->option('force');
|
||||
|
||||
/*
|
||||
|
|
@ -66,7 +66,7 @@ class OctoberUpdate extends Command
|
|||
* Perform update
|
||||
*/
|
||||
$updateList = $manager->requestUpdateList($forceUpdate);
|
||||
$updates = (int)array_get($updateList, 'update', 0);
|
||||
$updates = (int) array_get($updateList, 'update', 0);
|
||||
|
||||
if ($updates == 0) {
|
||||
$this->output->writeln('<info>No new updates found</info>');
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ class PluginInstall extends Command
|
|||
public function fire()
|
||||
{
|
||||
$pluginName = $this->argument('name');
|
||||
$manager = UpdateManager::instance()->resetNotes();
|
||||
$manager = UpdateManager::instance()->setNotesOutput($this->output);
|
||||
|
||||
$pluginDetails = $manager->requestPluginDetails($pluginName);
|
||||
|
||||
|
|
@ -64,10 +64,6 @@ class PluginInstall extends Command
|
|||
$this->output->writeln(sprintf('<info>Migrating plugin...</info>', $code));
|
||||
PluginManager::instance()->loadPlugins();
|
||||
$manager->updatePlugin($code);
|
||||
|
||||
foreach ($manager->getNotes() as $note) {
|
||||
$this->output->writeln($note);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -45,26 +45,27 @@ class PluginRefresh extends Command
|
|||
*/
|
||||
public function fire()
|
||||
{
|
||||
/*
|
||||
* Lookup plugin
|
||||
*/
|
||||
$pluginName = $this->argument('name');
|
||||
$pluginName = PluginManager::instance()->normalizeIdentifier($pluginName);
|
||||
if (!PluginManager::instance()->exists($pluginName)) {
|
||||
throw new \InvalidArgumentException(sprintf('Plugin "%s" not found.', $pluginName));
|
||||
}
|
||||
|
||||
$manager = UpdateManager::instance()->resetNotes();
|
||||
$manager = UpdateManager::instance()->setNotesOutput($this->output);
|
||||
|
||||
/*
|
||||
* Rollback plugin
|
||||
*/
|
||||
$manager->rollbackPlugin($pluginName);
|
||||
foreach ($manager->getNotes() as $note) {
|
||||
$this->output->writeln($note);
|
||||
}
|
||||
|
||||
$manager->resetNotes();
|
||||
/*
|
||||
* Update plugin
|
||||
*/
|
||||
$this->output->writeln('<info>Reinstalling plugin...</info>');
|
||||
$manager->updatePlugin($pluginName);
|
||||
|
||||
foreach ($manager->getNotes() as $note) {
|
||||
$this->output->writeln($note);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -63,13 +63,9 @@ class PluginRemove extends Command
|
|||
/*
|
||||
* Rollback plugin
|
||||
*/
|
||||
$manager = UpdateManager::instance()->resetNotes();
|
||||
$manager = UpdateManager::instance()->setNotesOutput($this->output);
|
||||
$manager->rollbackPlugin($pluginName);
|
||||
|
||||
foreach ($manager->getNotes() as $note) {
|
||||
$this->output->writeln($note);
|
||||
}
|
||||
|
||||
/*
|
||||
* Delete from file system
|
||||
*/
|
||||
|
|
|
|||
Loading…
Reference in New Issue