public function run() { $config = $this->client->getConfig(); $library = new Hymn_Module_Library(); foreach ($config->sources as $sourceId => $source) { $active = !isset($source->active) || $source->active; $library->addShelf($sourceId, $source->path, $active); } $relation = new Hymn_Module_Graph($this->client, $library); $modules = array(); // prepare list of modules to update $listInstalled = $library->listInstalledModules($config->application->uri); // get list of installed modules if (!$listInstalled) { // application has no installed modules return Hymn_Client::out("No installed modules found"); } $outdatedModules = array(); // foreach ($listInstalled as $installedModule) { $source = $installedModule->installSource; $availableModule = $library->getModule($installedModule->id, $source, FALSE); if ($availableModule) { if (version_compare($availableModule->version, $installedModule->version, '>')) { $outdatedModules[$installedModule->id] = (object) array('id' => $installedModule->id, 'installed' => $installedModule->version, 'available' => $availableModule->version, 'source' => $installedModule->installSource); } } } foreach ($outdatedModules as $update) { $message = "- %s: %s -> %s"; $message = sprintf($message, $update->id, $update->installed, $update->available); Hymn_Client::out($message); } }
public function run() { $this->dry = $this->client->arguments->getOption('dry'); $this->force = $this->client->arguments->getOption('force'); $this->quiet = $this->client->arguments->getOption('quiet'); $this->verbose = $this->client->arguments->getOption('verbose'); if ($this->dry) { Hymn_Client::out("## DRY RUN: Simulated actions - no changes will take place."); } // $start = microtime( TRUE ); $config = $this->client->getConfig(); $library = new Hymn_Module_Library(); foreach ($config->sources as $sourceId => $source) { $active = !isset($source->active) || $source->active; $library->addShelf($sourceId, $source->path, $active); } $relation = new Hymn_Module_Graph($this->client, $library); $modules = array(); // prepare list of modules to update $moduleId = trim($this->client->arguments->getArgument()); // is there a specific module ID is given $listInstalled = $library->listInstalledModules($config->application->uri); // get list of installed modules if (!$listInstalled) { // application has no installed modules return Hymn_Client::out("No installed modules found"); } $outdatedModules = array(); // foreach ($listInstalled as $installedModule) { $source = $installedModule->installSource; $availableModule = $library->getModule($installedModule->id, $source, FALSE); if ($availableModule) { if (version_compare($availableModule->version, $installedModule->version, '>')) { $outdatedModules[$installedModule->id] = (object) array('id' => $installedModule->id, 'installed' => $installedModule->version, 'available' => $availableModule->version, 'source' => $installedModule->installSource); } } } if ($moduleId) { if (!array_key_exists($moduleId, $listInstalled)) { return Hymn_Client::out("Module '" . $moduleId . "' is not installed and cannot be updated"); } if (!array_key_exists($moduleId, $outdatedModules)) { return Hymn_Client::out("Module '" . $moduleId . "' is not outdated and cannot be updated"); } $outdatedModules = array($moduleId => $outdatedModules[$moduleId]); } foreach ($outdatedModules as $update) { $module = $library->getModule($update->id); $installType = $this->client->getModuleInstallType($module->id, $this->installType); /* $relation->addModule( $module, $installType ); */ $message = "Updating module '%s' (%s -> %s) ..."; $message = sprintf($message, $module->id, $update->installed, $update->available); Hymn_Client::out($message); $installer = new Hymn_Module_Installer($this->client, $library, $this->quiet); $installer->update($module, $installType, $this->verbose, $this->dry); } }
public function run() { $this->dry = $this->client->arguments->getOption('dry'); $this->force = $this->client->arguments->getOption('force'); $this->quiet = $this->client->arguments->getOption('quiet'); $this->verbose = $this->client->arguments->getOption('verbose'); if ($this->dry) { Hymn_Client::out("## DRY RUN: Simulated actions - no changes will take place."); } $config = $this->client->getConfig(); $library = new Hymn_Module_Library(); foreach ($config->sources as $sourceId => $source) { $active = !isset($source->active) || $source->active; $library->addShelf($sourceId, $source->path, $active); } $relation = new Hymn_Module_Graph($this->client, $library); $moduleId = trim($this->client->arguments->getArgument()); if ($moduleId) { $module = $library->getModule($moduleId); if ($module) { $installType = $this->client->getModuleInstallType($moduleId, $this->installType); $relation->addModule($module, $installType); } } else { foreach ($config->modules as $moduleId => $module) { if (preg_match("/^@/", $moduleId)) { continue; } if (!isset($module->active) || $module->active) { $module = $library->getModule($moduleId); $installType = $this->client->getModuleInstallType($moduleId, $this->installType); $relation->addModule($module, $installType); } } } $installer = new Hymn_Module_Installer($this->client, $library, $this->quiet); $modules = $relation->getOrder(); foreach ($modules as $module) { $listInstalled = $library->listInstalledModules($config->application->uri); $isInstalled = array_key_exists($module->id, $listInstalled); $isCalledModule = $moduleId && $moduleId == $module->id; $isForced = $this->force && ($isCalledModule || !$moduleId); if ($isInstalled && !$isForced) { Hymn_Client::out("Module '" . $module->id . "' is already installed"); } else { Hymn_Client::out("Installing module '" . $module->id . "' ..."); $installType = $this->client->getModuleInstallType($module->id, $this->installType); $installer->install($module, $installType, $this->verbose, $this->dry); } } /* // todo: custom install mode: define SQL to import in hymn file if( isset( $config->database->import ) ){ foreach( $config->database->import as $import ){ if( file_exists( $import ) ) $installer->executeSql( file_get_contents( $import ) ); // broken on this point since extraction to Hymn_Module_SQL } }*/ }
public function run() { $config = $this->client->getConfig(); $library = new Hymn_Module_Library(); $modules = $library->listInstalledModules($config->application->uri); ksort($modules); Hymn_Client::out(count($modules) . " modules installed:"); foreach ($modules as $module) { Hymn_Client::out("- " . $module->id . ' (' . $module->version . ')'); } }
public function run() { $config = $this->client->getConfig(); $library = new Hymn_Module_Library(); $sources = (array) $config->sources; foreach ($sources as $sourceId => $source) { $active = !isset($source->active) || $source->active; $library->addShelf($sourceId, $source->path, $active); } Hymn_Client::out(count($sources) . " module sources:"); foreach ($library->getShelves() as $shelf) { $status = $shelf->active ? '+' : '-'; Hymn_Client::out("- [" . $status . "] " . $shelf->id . " -> " . $shelf->path); } }
public function run() { $config = $this->client->getConfig(); $moduleId = $this->client->arguments->getArgument(0); // $shelfId = $this->client->arguments->getArgument( 1 ); if ($moduleId) { $library = new Hymn_Module_Library(); foreach ($config->sources as $sourceId => $source) { $active = !isset($source->active) || $source->active; $library->addShelf($sourceId, $source->path, $active); } $modulesAvailable = $library->getModules(); $modulesInstalled = $library->listInstalledModules($config->application->uri); // get list of installed modules foreach ($modulesAvailable as $availableModule) { if ($moduleId !== $availableModule->id) { continue; } Hymn_Client::out('Module: ' . $availableModule->title); if ($availableModule->description) { Hymn_Client::out($availableModule->description); } Hymn_Client::out('Category: ' . $availableModule->category); Hymn_Client::out('Source: ' . $availableModule->sourceId); Hymn_Client::out('Version: ' . $availableModule->version); if (array_key_exists($moduleId, $modulesInstalled)) { $installedModule = $modulesInstalled[$moduleId]; Hymn_Client::out('Installed: ' . $installedModule->version); if (version_compare($availableModule->version, $installedModule->version, '>')) { $message = 'Update available: %s -> %s'; $message = sprintf($message, $installedModule->version, $availableModule->version); Hymn_Client::out($message); } } return; } Hymn_Client::out('Module ' . $moduleId . ' not available.'); } else { Hymn_Client::out("Application Settings:"); foreach ($config->application as $key => $value) { if (is_object($value)) { $value = json_encode($value, JSON_PRETTY_PRINT); } Hymn_Client::out("- " . $key . " => " . $value); } } }
public function run() { $this->dry = $this->client->arguments->getOption('dry'); $this->force = $this->client->arguments->getOption('force'); $this->quiet = $this->client->arguments->getOption('quiet'); $this->verbose = $this->client->arguments->getOption('verbose'); if ($this->dry) { Hymn_Client::out("## DRY RUN: Simulated actions - no changes will take place."); } $config = $this->client->getConfig(); $library = new Hymn_Module_Library(); foreach ($config->sources as $sourceId => $source) { $active = !isset($source->active) || $source->active; $library->addShelf($sourceId, $source->path, $active); } $relation = new Hymn_Module_Graph($this->client, $library); $moduleId = trim($this->client->arguments->getArgument()); $listInstalled = $library->listInstalledModules($config->application->uri); $isInstalled = array_key_exists($moduleId, $listInstalled); if (!$moduleId) { Hymn_Client::out("No module id given"); } else { if (!$isInstalled) { Hymn_Client::out("Module '" . $moduleId . "' is not installed"); } else { $module = $listInstalled[$moduleId]; $neededBy = array(); foreach ($listInstalled as $installedModuleId => $installedModule) { if (in_array($moduleId, $installedModule->relations->needs)) { $neededBy[] = $installedModuleId; } } if ($neededBy && !$this->force) { $list = implode(', ', $neededBy); $msg = "Module '%s' is needed by %d other modules (%s)"; Hymn_Client::out(sprintf($msg, $module->id, count($neededBy), $list)); } else { $module->path = 'not_relevant/'; $installer = new Hymn_Module_Installer($this->client, $library, $this->quiet); $installer->uninstall($module, $this->verbose, $this->dry); } } } }
public function run() { $config = $this->client->getConfig(); $library = new Hymn_Module_Library(); foreach ($config->sources as $sourceId => $source) { $active = !isset($source->active) || $source->active; $library->addShelf($sourceId, $source->path, $active); } $shelfId = $this->client->arguments->getArgument(0); if ($shelfId) { $modules = $library->getModules($shelfId); Hymn_Client::out(count($modules) . " modules available in module source '" . $shelfId . "':"); foreach ($modules as $moduleId => $module) { Hymn_Client::out("- " . $module->id); } } else { $modules = $library->getModules(); Hymn_Client::out(count($modules) . " modules available:"); foreach ($modules as $moduleId => $module) { Hymn_Client::out("- " . $module->id . ' (' . $module->version . ')'); } } }
public function run() { if (!(file_exists("config") && is_writable("config"))) { return Hymn_Client::out("Configuration folder is either not existing or not writable"); } $force = $this->client->arguments->getOption('force'); $verbose = $this->client->arguments->getOption('verbose'); $quiet = $this->client->arguments->getOption('quiet'); if (!$quiet && $verbose) { Hymn_Client::out("Loading all needed modules into graph…"); } $config = $this->client->getConfig(); $library = new Hymn_Module_Library(); foreach ($config->sources as $sourceId => $source) { $active = !isset($source->active) || $source->active; $library->addShelf($sourceId, $source->path); } $relation = new Hymn_Module_Graph($this->client, $library, $quiet); foreach ($config->modules as $moduleId => $module) { if (preg_match("/^@/", $moduleId)) { continue; } if (!isset($module->active) || $module->active) { $module = $library->getModule($moduleId); $installType = $this->client->getModuleInstallType($moduleId, $this->installType); $relation->addModule($module, $installType); } } $targetFileGraph = "config/modules.graph"; $targetFileImage = "config/modules.graph.png"; $graph = $relation->renderGraphFile($targetFileGraph, $verbose); // if( !$quiet ) // Hymn_Client::out( "Saved graph file to ".$targetFileGraph."." ); $image = $relation->renderGraphImage($graph, $targetFileImage, $verbose); // if( !$quiet ) // Hymn_Client::out( "Saved graph image to ".$targetFileImage."." ); }
public static function listInstalledModules($pathApp = "") { if (self::$useCache && self::$listModulesInstalled !== NULL) { return self::$listModulesInstalled; } $list = array(); if (file_exists($pathApp . '/config/modules/')) { $iterator = new RecursiveDirectoryIterator($pathApp . '/config/modules/'); $index = new RecursiveIteratorIterator($iterator, RecursiveIteratorIterator::SELF_FIRST); foreach ($index as $entry) { if (!$entry->isFile() || !preg_match("/\\.xml\$/", $entry->getFilename())) { continue; } $key = pathinfo($entry->getFilename(), PATHINFO_FILENAME); $module = self::readInstalledModule($pathApp, $key); $list[$key] = $module; } } ksort($list); self::$listModulesInstalled = $list; return $list; }