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