Update the root required packages.

@param array $packages
@param int   $type

@return void
355280
protected function updateRootPackageRequire(array $packages, int $type): void
    {
        $requires = $this->manipulateRootPackage(
            $packages,
            $type,
            $this->rootPackage->getRequires()
        );

        $this->rootPackage->setRequires($requires);
    }
1259713
protected function addRunonces(PackageInterface $package, array $files)
    {
        $rootDir = $this->getInstallPath($package);

        foreach ($files as $file) {
            $this->runonceManager->addFile($this->filesystem->normalizePath($rootDir . '/' . $file));
        }
    }
275392
public function updateEntry($package, $theme)
    {
        $this->verifyCommand($package);

        $lines  = file($this->config);
        $config = $this->compactConfig($package);

        $lines = $this->updateConfigDetails($theme, $lines, $config);

        $this->file->delete($this->config);
        $this->file->put($this->config, implode($lines));
    }
667942
public function push($type, $state = []) {
        if (isset($this->_defaults[$type])) {
            $state = array_merge($this->_defaults[$type], $state);
        }
        array_push($this->_states, [$type, $state]);
    }
237136
protected function replaceSelfVersionDependencies(
        $type,
        array $links,
        RootPackageInterface $root
    ) {
        $linkType = BasePackage::$supportedLinkTypes[$type];
        $version = $root->getVersion();
        $prettyVersion = $root->getPrettyVersion();
        $vp = $this->versionParser;

        $method = 'get' . ucfirst($linkType['method']);
        $packages = $root->$method();

        return array_map(
            function ($link) use ($linkType, $version, $prettyVersion, $vp, $packages) {
                if ('self.version' === $link->getPrettyConstraint()) {
                    if (isset($packages[$link->getSource()])) {
                        /** @var Link $package */
                        $package = $packages[$link->getSource()];
                        return new Link(
                            $link->getSource(),
                            $link->getTarget(),
                            $vp->parseConstraints($package->getConstraint()->getPrettyString()),
                            $linkType['description'],
                            $package->getPrettyConstraint()
                        );
                    }

                    return new Link(
                        $link->getSource(),
                        $link->getTarget(),
                        $vp->parseConstraints($version),
                        $linkType['description'],
                        $prettyVersion
                    );
                }
                return $link;
            },
            $links
        );
    }
1081968
public function set($type, $messages)
    {
        foreach((array) $messages as $message) {
            parent::set($type, $message);
        }

        return $this;
    }
618519
private function UpdateBundleVersions()
    {
        $this->ClearInstalledBundles();
        $bundles = PathUtil::Bundles();
        foreach ($bundles as $bundle)
        {
            if (!array_key_exists($bundle, $this->failedBundles))
            {
                $this->UpdateBundleVersion($bundle);
            }    
        }
    }
1033410
protected function requireMigrations($package)
    {
        $files = $this->container['files'];

        //
        $path = $this->getMigrationPath($package);

        $migrations = $files->glob($path.'*_*.php');

        foreach ($migrations as $migration) {
            $files->requireOnce($migration);
        }
    }
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;
    }
805554
public static function installComposerPackage($project, $type='master')
    {
        $path = static ::getPackagePath($project);

        self::copyAssets($project);
        self::runMigrations($project, ['blend_modx_migration_dir' => $path], 'up', $type);
    }
1289907
protected static function updatePackages($dev = true)
    {
        if (! file_exists(base_path('package.json'))) {
            return;
        }

        $configurationKey = $dev ? 'devDependencies' : 'dependencies';

        $packages = json_decode(file_get_contents(base_path('package.json')), true);

        $packages[$configurationKey] = static::updatePackageArray(
            array_key_exists($configurationKey, $packages) ? $packages[$configurationKey] : [],
            $configurationKey
        );

        ksort($packages[$configurationKey]);

        file_put_contents(
            base_path('package.json'),
            json_encode($packages, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT).PHP_EOL
        );
    }
1348640
protected function addFiles(Package $package, array $files)
    {
        foreach ($files as $name => $paths) {
            $paths = (array) $paths;
            if ('defines' === $name) {
                $paths = array_reverse($paths);
            }
            foreach ($paths as $path) {
                $this->addFile($package, $name, $path);
            }
        }
    }
147835
public function registerPackages(array $packages)
    {
        foreach ($packages as $alias => $package) {
            $this->addPackage($alias, $package);
        }

        return $this;
    }
1330057
public function install()
    {
        $type = $this->typeResolver->resolve();
        if (!isset($this->mapping[$type])) {
            return;
        }

        foreach ($this->mapping[$type] as $package) {
            if (!$this->isPackageRequired($package['name'])) {
                $this->io->write(
                    sprintf('Requiring package %s', $package['name'])
                );

                $this->installer->installPackage(
                    $package['name'],
                    $package['version']
                );
            }
        }
    }
147292
public function add($type)
    {
        $this->stateStorage->incrementBucket($this->commandKey, $type, $this->getCurrentBucketIndex());
    }
739033
public function setPackage($package)
    {
        if ($package === $this->package) {
            return;
        }

        $this->package = $package;
        $this->packageOverridden = false;
    }
1141503
public function optionUpdate($type = null)
    {
        if (in_array($type, ['modules', 'languages'])) {
            switch ($type) {
                case 'modules':
                    modules()->updateRegistry();
                    break;

                case 'languages':
                    language()->updateRegistry();
                    break;
            }
        } else {
            modules()->updateRegistry();
            language()->updateRegistry();
        }

        exit(EXIT_SUCCESS);
    }