Install a module.
@param  string $src
@param  boolean $suggest
@param  boolean $migrate
@param  boolean $updateComposer
@param  string $root
@param  array $modules
@param  array $containerComposer
763908
protected function install($src, $suggest, $migrate, $updateComposer, $root, &$modules, &$containerComposer) {
		$tmp = $root.'/tmp/'.\Asgard\Common\Tools::randstr(10);

		list($src, $tag) = explode('=', $src.'=');

		if(!$this->gitInstall($src, $tmp) || ($tag && !$this->gitCheckout($tmp, $tag))) {
			$this->error('The files could not be downloaded.');
			return;
		}

		if(!file_exists($tmp.'/asgard.json')) {
			$this->error('asgard.json is missing for '.$src.'.');
			return;
		}

		if(file_exists($tmp.'/asgard.json'))
			$asgard = json_decode(file_get_contents($tmp.'/asgard.json'), true);
		else
			$asgard = [];
		if(!isset($asgard['name'])) {
			$this->error('Name missing for '.$src.'.');
			return;
		}
		else
			$name = $asgard['name'];

		if(in_array($name, $modules)) {
			$this->comment($name.' has already been installed.');
			return;
		}

		#asgard deps
		if(isset($asgard['require'])) {
			foreach($asgard['require'] as $requireName=>$requireSrc) {
				if(!in_array($requireName, $modules))
					$this->install($requireSrc, $suggest, $migrate, $updateComposer, $root, $modules, $containerComposer);
			}
		}
		if($suggest && isset($asgard['suggest'])) {
			foreach($asgard['suggest'] as $requireName=>$requireSrc) {
				if(!in_array($requireName, $modules))
					$this->install($requireSrc, $suggest, $migrate, $updateComposer, $root, $modules, $containerComposer);
			}
		}

		$publisher = new Publisher($this->db, $this->schema, $this->output, $this->getContainer());

		$publisher->publish($tmp.'/app', $root.'/app');
		$publisher->publish($tmp.'/config', $root.'/config');
		$publisher->publishTests($tmp.'/tests', $root.'/tests');
		$publisher->publish($tmp.'/web', $root.'/web');
		$publisher->publishMigrations($tmp.'/migrations', $root.'/migrations', $migrate);

		#composer
		if($updateComposer && $containerComposer && file_exists($tmp.'/composer.json')) {
			$modComposer = json_decode(file_get_contents($tmp.'/composer.json'), true);
			if(isset($modComposer['require']))
				$containerComposer['require'] = array_merge($modComposer['require'], $containerComposer['require']);
			if(isset($modComposer['autoload']))
				$containerComposer['autoload'] = array_merge_recursive($modComposer['autoload'], $containerComposer['autoload']);
			$version = isset($asgard['version']) ? $asgard['version']:'@dev';
			$containerComposer['replace'][$name] = $version;
		}

		#scripts
		if(isset($asgard['scripts'])) {
			foreach($asgard['scripts'] as $script)
				include $tmp.'/'.$script;
		}

		#attempt to delete temporary files
		try {
			\Asgard\File\FileSystem::delete($tmp);
		}
		catch(\Exception $e) {}
		catch(\Throwable $e) {}

		$modules[] = $name;

		$this->info('Module "'.$name.'" added with success.');
	}
701738
public function addModule($module) {
        $this->registerModule($module);
        if (is_object($module)) $module = $module->name;
        $this->userModules[] = $module;
    }
1170895
function(exists, cb) {
          if(!exists) {
            fs.mkdir(rootDir + '/node_modules', function(error) {
              cb(error);
            });
          } else {
            cb(null);
          }
        }
263703
public function addMigration(string $module, string $path)
    {
        $module = self::normalizeModule($module);
        if (isset($this->modules[$module]))
            throw new MigrationException("Duplicate module: " . $module);

        $instance = new Module($module, $path, $this->db);
        $this->modules[$module] = $instance;
        return $instance;
    }
1315234
public function install(SchemaSetupInterface $setup, ModuleContextInterface $context)
    {
        $installer = $setup;

        $installer->startSetup();

        /*
         * Create table 'wk_grid_records'
         */

        $table = $installer->getConnection()->newTable(
            $installer->getTable('worldnettps_securecard_records')
        )->addColumn(
            'entity_id',
            \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER,
            null,
            ['identity' => true, 'nullable' => false, 'primary' => true],
            'Grid Record Id'
        )->addColumn(
            'merchant_ref',
            \Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
            50,
            ['nullable' => false],
            'Merchant Ref'
        )->addColumn(
            'terminal_id',
            \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER,
            null,
            ['nullable' => false],
            'Terminal Id'
        )->addColumn(
            'card_expiry',
            \Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
            4,
            ['nullable' => false],
            'Card Expiry'
        )->addColumn(
            'card_type',
            \Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
            10,
            ['nullable' => false],
            'Card Type'
        )->addColumn(
            'card_holder_name',
            \Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
            255,
            ['nullable' => false],
            'Card Holder Name'
        )->addColumn(
            'card_reference',
            \Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
            50,
            ['nullable' => false],
            'Card Reference'
        )->addColumn(
            'customer_id',
            \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER,
            null,
            ['nullable' => false],
            'Customer Id'
        )->addColumn(
            'obfuscated_card_number',
            \Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
            16,
            ['nullable' => false],
            'Card Number'
        )->addColumn(
            'created_at',
            \Magento\Framework\DB\Ddl\Table::TYPE_TIMESTAMP,
            null,
            [],
            'Creation Time'
        )->addColumn(
            'update_time',
            \Magento\Framework\DB\Ddl\Table::TYPE_TIMESTAMP,
            null,
            [],
            'Modification Time'
        )->addIndex(
            $installer->getIdxName(
                'worldnettps_securecard_records',
                ['merchant_ref'],
                \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE
            ),
            'merchant_ref',
            ['type' => \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE]
        )->addIndex(
            $installer->getIdxName(
                'worldnettps_securecard_records',
                ['card_reference'],
                \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE
            ),
            'card_reference',
            ['type' => \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE]
        )->setComment(
            'Row Data Table'
        );

        $installer->getConnection()->createTable($table);
        $installer->endSetup();
    }
1367692
function install($dir = null, &$result)
    {
        // Get a database connector object
        $db = Factory::getDBO();
        $result['status'] = false;
        $result['name'] = null;
        if (!$dir && !is_dir(Path::clean($dir))) {
            $this->installer->abort(Text::_('INSTALL_INVALID_PATH'));
	        throw new RuntimeException(Text::_('INSTALL_INVALID_PATH'));
        } else {
            $this->installer->setPath('source', $dir);

            // Get the extension manifest object
            $manifest = $this->getManifest($dir);
            if (is_null($manifest)) {
                $this->installer->abort(Text::_('INSTALL_NOT_VALID_PLUGIN'));
	            throw new RuntimeException(Text::_('INSTALL_NOT_VALID_PLUGIN'));
            } else {
                $this->manifest = $manifest;

	            $framework = JFusionFramework::getComposerInfo();

	            $version = $this->getAttribute($this->manifest, 'version');

	            /**
	             * ---------------------------------------------------------------------------------------------
	             * Manifest Document Setup Section
	             * ---------------------------------------------------------------------------------------------
	             */
	            // Set the extensions name
	            /**
	             * Check that the plugin is an actual JFusion plugin
	             */
	            $name = $this->manifest->name;
	            $name = $this->filterInput->clean($name, 'string');

	            if (!$framework || !$version || version_compare($framework->version, $version) >= 0 || $framework->version == 'dev-master') {
		            $result['name'] = $name;
		            $this->name = $name;

		            // installation path
		            $this->installer->setPath('extension_root', JFusionFramework::getPluginPath($name));
		            // get files to copy

		            /**
		             * ---------------------------------------------------------------------------------------------
		             * Filesystem Processing Section
		             * ---------------------------------------------------------------------------------------------
		             */

		            // If the plugin directory does not exist, lets create it
		            $created = false;
		            if (!file_exists($this->installer->getPath('extension_root'))) {
			            if (!$created = Folder::create($this->installer->getPath('extension_root'))) {
				            $msg = Text::_('PLUGIN') . ' ' . Text::_('INSTALL') . ': ' . Text::_('INSTALL_FAILED_DIRECTORY') . ': "' . $this->installer->getPath('extension_root') . '"';
				            $this->installer->abort($msg);
				            throw new RuntimeException($name . ': ' . $msg);
			            }
		            }
		            /**
		             * If we created the plugin directory and will want to remove it if we
		             * have to roll back the installation, lets add it to the installation
		             * step stack
		             */
		            if ($created) {
			            $this->installer->pushStep(array('type' => 'folder', 'path' => $this->installer->getPath('extension_root')));
		            }
		            // Copy all necessary files
		            if ($this->installer->parseFiles($this->manifest->files[0], -1) === false) {
			            // Install failed, roll back changes
			            $this->installer->abort();
			            throw new RuntimeException($name . ': ' . Text::_('PLUGIN') . ' ' . $name . ' ' . Text::_('INSTALL') . ': ' . Text::_('FAILED'));
		            } else {
			            $vendor = $dir . '/vendor';
			            if (is_dir(Path::clean($vendor))) {
				            Folder::copy($vendor, $this->installer->getPath('extension_root') . '/vendor', '', true);
			            }
			            $language = $dir . '/language';
			            if (is_dir(Path::clean($language))) {
				            Folder::copy($language, $this->installer->getPath('extension_root') . '/language', '', true);
			            }
			            /**
			             * ---------------------------------------------------------------------------------------------
			             * Database Processing Section
			             * ---------------------------------------------------------------------------------------------
			             */
			            //let's check to see if a plugin with the same name is already installed
			            $query = $db->getQuery(true)
				            ->select('id')
				            ->from('#__jfusion')
				            ->where('name = ' . $db->quote($name));

			            $db->setQuery($query);

			            $plugin = $db->loadObject();
			            if (!empty($plugin)) {
				            if (!$this->installer->isOverwrite()) {
					            // Install failed, roll back changes
					            $msg = Text::_('PLUGIN') . ' ' . Text::_('INSTALL') . ': ' . Text::_('PLUGIN') . ' "' . $name . '" ' . Text::_('ALREADY_EXISTS');
					            $this->installer->abort($msg);
					            throw new RuntimeException($name . ': ' . $msg);
				            } else {
					            //set the overwrite tag
					            $result['overwrite'] = 1;
				            }
			            } else {
				            //prepare the variables
				            $result['overwrite'] = 0;
				            $plugin_entry = new stdClass;
				            $plugin_entry->id = null;
				            $plugin_entry->name = $name;
				            $plugin_entry->dual_login = 0;
				            //now append the new plugin data
				            try {
					            $db->insertObject('#__jfusion', $plugin_entry, 'id');
				            } catch (Exception $e) {
					            // Install failed, roll back changes
					            $msg = Text::_('PLUGIN') . ' ' . Text::_('INSTALL') . ' ' . Text::_('ERROR') . ': ' . $e->getMessage();
					            $this->installer->abort($msg);
					            throw new RuntimeException($name . ': ' . $msg);
				            }
				            $this->installer->pushStep(array('type' => 'plugin', 'id' => $plugin_entry->id));
			            }
			            /**
			             * ---------------------------------------------------------------------------------------------
			             * Finalization and Cleanup Section
			             * ---------------------------------------------------------------------------------------------
			             */

			            //check to see if this is updating a plugin that has been copied
			            $query = $db->getQuery(true)
				            ->select('name')
				            ->from('#__jfusion')
				            ->where('original_name = ' . $db->quote($name));

			            $db->setQuery($query);
			            $copiedPlugins = $db->loadObjectList();
			            foreach ($copiedPlugins as $plugin) {
				            //update the copied version with the new files
//				            $this->copy($name, $plugin->name, true);
			            }

			            if ($result['overwrite'] == 1) {
				            $msg = Text::_('PLUGIN') . ' ' . $name . ' ' . Text::_('UPDATE') . ': ' . Text::_('SUCCESS');
			            } else {
				            $msg = Text::_('PLUGIN') . ' ' . $name . ' ' . Text::_('INSTALL') . ': ' . Text::_('SUCCESS');
			            }
			            $result['message'] = $name . ': ' . $msg;
			            $result['status'] = true;
		            }
	            } else {
		            $msg = Text::_('PLUGIN') . ' ' . $name . ': ' . Text::_('FAILED') . ' ' . Text::_('NEED_JFUSION_VERSION') . ' "' . $version . '" ' . Text::_('OR_HIGHER');
		            $this->installer->abort($msg);
		            throw new RuntimeException($name . ': ' . $msg);
	            }
            }
        }
        return $result;
    }
966195
protected function runMigrationByApplication($command)
    {
        $app = $this->mockApplication();

        list($migrateController, $route) = $app->createController('migrate');

        if ($migrateController === null) {
            throw new ExtensionException(
              __CLASS__,
              "At least one of `migrationPath` or `migrationNamespaces` should be specified.\nOr describe migrations in your app config."
            );
        }

        if ($migrateController->interactive) {
            $this->writeln('Cannot run the migrate interactively, the interaction was disabled.');
            $migrateController->interactive = false;
        }

        $this->runMigration($migrateController, $command);

        $this->destroyApplication();
    }
679584
public function activateModule(
        $module,
        $defaultModules = ['MelisAssetManager', 'MelisComposerDeploy', 'MelisDbDeploy', 'MelisCore'],
        $excludeModule = ['MelisModuleConfig'])
    {
        // Default melis modules
        $activeModules = $this->getActiveModules($defaultModules);

        // Removing "MelisModuleConfig" if exist on activated modules
        foreach ($activeModules as $key => $mod) {
            if (in_array($mod, $excludeModule)) {
                unset($activeModules[$key]);
            }
        }

        array_push($activeModules, $module);

        // Creating/updating module.load.php including new module
        return $this->createModuleLoader('config/', $activeModules, $defaultModules);
    }
316012
public function setAssociations() : void
    {
        foreach (Utility::findDirs(Configure::read('CsvMigrations.modules.path')) as $module) {
            $this->setByModule($module);
        }
    }
894415
protected function installPackage()
    {
        if ($this->confirm('Do you want publish the pingpong/admin\'s migrations ?')) {
            $this->call('admin:migration');
        }

        if ($this->confirm('Do you want publish the pingpong/trusty\'s migrations ?')) {
            $this->call('vendor:publish', [
                '--provider' => 'Pingpong\Trusty\TrustyServiceProvider',
            ]);
        }

        if ($this->confirm('Do you want run all migrations now ?')) {
            $this->call('migrate');
        }

        if ($this->confirm('Do you want run the pingpong/admin\'s seeders now ?')) {
            $this->call('admin:seed');
        }

        if ($this->confirm('Do you want publish configuration files from pingpong/admin package ?')) {
            $this->call('vendor:publish', [
                '--provider' => 'Pingpong\Admin\AdminServiceProvider',
                ['--tag' => ['config']],
            ]);
        }

        if ($this->confirm('Do you want publish assets from pingpong/admin package ?')) {
            $this->call('vendor:publish', [
                '--provider' => 'Pingpong\Admin\AdminServiceProvider',
                ['--tag' => ['assets']],
            ]);
        }

        if ($this->confirm('Do you want create the app/menus.php file ?')) {
            $this->installMenus();
        }

        $this->call('optimize');
    }
526728
function install()
    {
        $this->createConfigurationDirectory();
        $this->createDriversDirectory();
        $this->createSitesDirectory();
        $this->createExtensionsDirectory();
        $this->createLogDirectory();
        $this->createCertificatesDirectory();
        $this->writeBaseConfiguration();

        $this->files->chown($this->path(), user());
    }
435324
public function update(\Composer\Repository\InstalledRepositoryInterface $repo, \Composer\Package\PackageInterface $initial, 
			\Composer\Package\PackageInterface $target) {
		if (!$this->needsUpdate($initial)) {
			//add the new version of the module to the composer.lock
			$repo->removePackage($initial);
			if (!$repo->hasPackage($target)) {
				$repo->addPackage(clone $target);
			}
			return;
		}
				
    	$this->moveBackResources($initial);
				
		parent::update($repo, $initial, $target);
		
		$this->removeResources($target);
		$this->installResources($target);
	}
150106
function setModulesDir($modulesDir)
    {
        if (is_string($modulesDir))
            $modulesDir = array($modulesDir);

        $this->modulesDir = array_merge($this->modulesDir, $modulesDir);
        return $this;
    }
908568
public function add(Command $command)
    {
        if ($command instanceof ContainerAwareInterface) {
            $command->setContainer($this->container);
        }

        if ($command instanceof BasePhpcrCommand) {
            if ($this->showUnsupported || $command->isSupported()) {
                parent::add($command);
            }
        } else {
            parent::add($command);
        }
    }
1252384
public function addScript($handle, $src = null, $deps = array(), $ver = false, $inFooter = false)
	{
		$args = func_get_args();
		array_shift($args);
		return $this->add($handle, 'script', $args);
	}
167182
function installNodeModules(modules, callback) {
    // base case
    if (modules.length <= 0) {
      return callback();
    }

    // install one at a time
    const module = modules.pop();
    console.log(`BRANCH SDK: Installing node dependency ${module}`);

    const install = `npm install --prefix ./plugins/${SDK} -D ${module}`;
    exec(install, (err, stdout, stderr) => {
      // handle error
      if (err) {
        throw new Error(
          `BRANCH SDK: Failed to install Branch node dependency ${module}. Docs https://goo.gl/GijGKP`
        );
      } else {
        // next module
        installNodeModules(modules, callback);
      }
    });
  }
410858
protected function addComposerCommands()
    {
        $this->add(new ComposerCommand\AboutCommand());
        $this->add(new ComposerCommand\ConfigCommand());
        $this->add(new ComposerCommand\DependsCommand());
        $this->add(new ComposerCommand\InitCommand());
        $this->add(new ComposerCommand\InstallCommand());
        $this->add(new ComposerCommand\CreateProjectCommand());
        $this->add(new ComposerCommand\UpdateCommand());
        $this->add(new ComposerCommand\SearchCommand());
        $this->add(new ComposerCommand\ValidateCommand());
        $this->add(new ComposerCommand\ShowCommand());
        $this->add(new ComposerCommand\SuggestsCommand());
        $this->add(new ComposerCommand\RequireCommand());
        $this->add(new ComposerCommand\DumpAutoloadCommand());
        $this->add(new ComposerCommand\StatusCommand());
        $this->add(new ComposerCommand\ArchiveCommand());
        $this->add(new ComposerCommand\DiagnoseCommand());
        $this->add(new ComposerCommand\RunScriptCommand());
        $this->add(new ComposerCommand\LicensesCommand());
        $this->add(new ComposerCommand\GlobalCommand());
        $this->add(new ComposerCommand\ClearCacheCommand());
        $this->add(new ComposerCommand\RemoveCommand());
        $this->add(new ComposerCommand\HomeCommand());
    }