Installs plugins and themes.

@param array    $options      Options for installing packages
@param string[] $packageNames List of packages

@throws RuntimeException If any problem occurs while resolving dependencies
195048
public function install(array $options = [], array $packageNames = [])
    {
        $options = $this->getInstallResolver()->resolve($options);
        $installer = $this->buildInstaller($options);
        $installer->setUpdateWhitelist($packageNames);
        $status = $installer->run();

        if ($status !== 0) {
            throw new \RuntimeException(sprintf(
                'An error has been occurred with code: %s while resolving dependencies.',
                $status
            ));
        }
    }
639130
private function parseBundles(array $bundles, array &$configs): void
    {
        foreach ($bundles as $options) {
            // Only one value given, must be class name
            if (!\is_array($options)) {
                $options = ['bundle' => $options];
            }

            if (!isset($options['bundle'])) {
                throw new \RuntimeException(
                    sprintf('Missing class name for bundle config (%s)', json_encode($options))
                );
            }

            if (!empty($options['optional']) && !class_exists($options['bundle'])) {
                continue;
            }

            $config = new BundleConfig($options['bundle']);

            if (isset($options['replace'])) {
                $config->setReplace($options['replace']);
            }

            if (isset($options['development'])) {
                if (true === $options['development']) {
                    $config->setLoadInProduction(false);
                } elseif (false === $options['development']) {
                    $config->setLoadInDevelopment(false);
                }
            }

            if (isset($options['load-after'])) {
                $config->setLoadAfter($options['load-after']);
            }

            $configs[] = $config;
        }
    }
261655
public function updatePackageDependencies($options = [])
    {
        $process = $this->getProcess();

        $processCommand = trim($this->findComposer() . ' update ' .
                               $this->prepareOptions($options, ['--no-progress', '--no-ansi']));

        $process->setCommandLine($processCommand);

        chdir($this->workingPath);
        $this->log->info('Changing working directory for Composer update', ['directory' => $this->workingPath]);
        $this->log->info('Running Composer command', ['command' => $processCommand]);
        $process->run();

        if ($process->isSuccessful() == false) {
            $this->restoreWorkingDirectory();
            $composerError = $process->getErrorOutput();

            $this->log->error('Composer update process failure', ['composer' => $composerError]);

            throw new PackageInstallationException($process->getErrorOutput(),
                "There was an error updating the dependencies." . PHP_EOL .
                'Composer is reporting the following error(s):' . PHP_EOL . '--> ' . $composerError);
        }

        $this->restoreWorkingDirectory();
        $this->log->info('Package template dependencies updated', ['directory' => $this->workingPath]);
        return true;
    }
710716
public function setOptions(array $options)
    {
        foreach ($options as $name => $value) {
            $this->setOption($name, $value);
        }
    }
1323263
public function add(array $assets)
    {
        if (! file_exists($this->file)) {
            throw new RuntimeException("Could not add assets, `app.json` file do not exists.");
        }

        $packages = json_decode(file_get_contents($this->file), true);

        $packages['assets'] = $assets + $packages['assets'];

        ksort($packages['assets']);

        file_put_contents($this->file, json_encode($packages, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT).PHP_EOL);
    }
1129293
public static function load($files = [], $options = null)
    {
        if (! self::$configurator instanceof ConfiguratorClass) {
            self::$configurator = new ConfiguratorClass($files, $options);
        } else {
            self::$configurator->load($files, $options);
        }
    }
163817
public function addOptions(array $options)
    {
        $this->options = array_merge($this->options, $options);

        $this->getDefinitionLoader()->setOptions($options);
    }
778827
public function addOptions(array $options): void
	{
		foreach ($options as $key => $option) {
			$this->addOption($key, $option);
		}
	}
361075
public function installPackage(PackageEvent $event)
    {
        $package = $this->getOperationPackage($event);
        if ($package) {
            $installer = new RecipeInstaller($event->getIO(), $event->getComposer());
            $installer->installLibrary($package);
        }
    }
559820
public function updatePackage(PackageInterface $package, InstallerInterface $installer)
    {
        if (!$this->isPackageInstalled($package)) {
            throw new RuntimeException(sprintf('Package %s is not installed.', $package->getName()));
        }
        if (is_null($package->getRequiredVersion())) {
            $decode = $this->config->getBowerFileContent();
            if (empty($decode['dependencies']) || empty($decode['dependencies'][$package->getName()])) {
                throw new InvalidArgumentException(sprintf('Package %s not found in bower.json', $package->getName()));
            }
            $package->setRequiredVersion($decode['dependencies'][$package->getName()]);
        }

        $bower = $this->config->getPackageBowerFileContent($package);
        $package->setInfo($bower);
        $package->setVersion($bower['version']);
        $package->setRequires(isset($bower['dependencies']) ? $bower['dependencies'] : null);

        $packageTag = $this->getPackageTag($package);
        $this->output->writelnInfoPackage($package, 'validate', sprintf('%s against %s#%s', $packageTag, $package->getName(), $package->getRequiredVersion()));

        $package->setRepository($this->repository);
        if ($packageTag == $package->getVersion()) {
            // if version is fully matching, there's no need to update
            return;
        }
        $package->setVersion($packageTag);

        $this->cachePackage($package);

        $this->output->writelnUpdatingPackage($package);
        $installer->update($package);

        $overrides = $this->config->getOverrideFor($package->getName());
        if (array_key_exists('dependencies', $overrides)) {
            $dependencies = $overrides['dependencies'];
        } else {
            $dependencies = $package->getRequires();
        }
        if (!empty($dependencies)) {
            foreach ($dependencies as $name => $requiredVersion) {
                $depPackage = new Package($name, $requiredVersion);
                if (!$this->isPackageInstalled($depPackage)) {
                    $this->installPackage($depPackage, $installer, true);
                } elseif ($this->isNeedUpdate($depPackage)) {
                    $this->updatePackage($depPackage, $installer);
                }
            }
        }
    }
1019047
public function bootstrap(array $args, array $options = [])
    {
        if (false === class_exists('\Phinx\Config\Config')) {
            throw new \RuntimeException('please use `composer require linhecheng/cmlphp-ext-phinx` cmd to install phinx.');
        }

        if (!$this->getConfig()) {
            $this->loadConfig($options);
        }

        $this->loadManager($args, $options);
        // report the paths
        Output::writeln(
            'using migration path ' .
            Colour::colour(str_replace(Cml::getApplicationDir('secure_src'), '{secure_src}', $this->getConfig()->getMigrationPath()), Colour::GREEN)
        );
        Output::writeln(
            'using seed path ' .
            Colour::colour(str_replace(Cml::getApplicationDir('secure_src'), '{secure_src}', $this->getConfig()->getSeedPath()), Colour::GREEN)
        );

        $exportPath = false;
        if (isset($options['e'])) {
            $exportPath = $options['e'];
        } else if (isset($options['export'])) {
            $exportPath = $options['export'];
        }
        if ($exportPath) {
            is_dir($exportPath) || $exportPath = $this->getConfig()->getExportPath();
            is_dir($exportPath) || mkdir($exportPath, 0700, true);
            Output::writeln(
                'using export path:' .
                Colour::colour(str_replace(Cml::getApplicationDir('secure_src'), '{secure_src}', $exportPath), Colour::GREEN)
            );
            $merge = (isset($options['m']) || isset($options['merge'])) ? 'merge_export_' . date('Y-m-d-H-i-s') . '.sql' : false;
            $this->getManager()->getEnvironment()->setExportPath($exportPath, $merge);
        }

        $this->getConfig()->echoAdapterInfo();
    }
1148006
protected function runDeployies(array $deployies, array $options = [])
    {
        if (count($deployies) == 0) {
            $this->note('<info>Nothing to deploy.</info>');

            return;
        }

        foreach ($deployies as $file) {
            $this->runDeploy($file);
        }
    }
590173
public function setOptions(array $options, array $defaults = [])
    {
        $options = array_merge($defaults, $options);
        $this->options = $options;

        return $this;
    }
279055
public function setOptions($options)
    {
        $this->package->setParsedOptions($options);
        $this->inputCollector->setOptions($options);
    }
391786
public function runPending(array $migrations, array $options = [])
    {
        // First we will just make sure that there are any migrations to run. If there
        // aren't, we will just make a note of it to the developer so they're aware
        // that all of the migrations have been run against this database system.
        if (count($migrations) == 0) {
            $this->note('<info>Nothing to migrate.</info>');

            return;
        }

        foreach ($migrations as $file) {
            $this->runUp($file);
        }
    }
467041
public void process(String packageNames) {

		if (packageNames == null) {
			processPackage("", true);
			return;
		}

		String[] pkgs = packageNames.split(",");
		for (int i = 0; i < pkgs.length; i++) {

			String pkg = pkgs[i].trim().replace('.', '/');

			boolean recurse = false;
			if (pkg.endsWith("**")) {
				recurse = true;
				pkg = pkg.substring(0, pkg.length() - 2);
			} else if (pkg.endsWith("*")) {
				recurse = true;
				pkg = pkg.substring(0, pkg.length() - 1);
			}
			
			pkg = trimSlash(pkg);

			processPackage(pkg, recurse);
		}
	}
197867
protected function updateDependencies($preferLock, $preferSource, $noScripts)
    {
        $pmOptions = [
            'prefer-source' => $preferSource,
            'prefer-dist' => !$preferSource,
            'no-scripts' => $noScripts,
        ];

        if ($preferLock === true) {
            $this->packageManager->install($pmOptions);
        } else {
            $this->packageManager->update($pmOptions);
        }
    }