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