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() { $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() { $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); } }