Install a node package.

@param  string          $directory
@param  OutputInterface $output
@param  string          $package
@param  string|null     $version
@param  boolean         $dev
@return void
355314
protected function installNodePackage( $directory, OutputInterface $output, $package, $version = null, $dev = false ) {
		$package_manager = new Proxy();

		if ( $package_manager->installed( $directory, $package ) ) {
			throw new RuntimeException( 'Package is already installed.' );
		}

		$package_manager->install( $directory, $output, $package, $version, $dev );
	}
283426
private function updateLanguagesFor(array $installedOutdated, Package $package = null)
    {
        $result = 0;
        if (empty($installedOutdated)) {
            if ($this->output->getVerbosity() > OutputInterface::VERBOSITY_NORMAL) {
                if ($package === null) {
                    $this->output->writeln('  > no updates for concrete5 core');
                } else {
                    $this->output->writeln(sprintf('  > no updates for package %s', $package->getPackageHandle()));
                }
            }
        } else {
            if ($this->output->getVerbosity() > OutputInterface::VERBOSITY_NORMAL) {
                if ($package === null) {
                    $this->output->writeln('  > updating concrete5 core');
                } else {
                    $this->output->writeln(sprintf('> updating package %s', $package->getPackageHandle()));
                }
            }
            foreach ($installedOutdated as $localeID => $rl) {
                if ($this->output->getVerbosity() > OutputInterface::VERBOSITY_NORMAL) {
                    $this->output->write('    - ' . $localeID . '... ');
                }
                if ($package === null) {
                    $this->translationsInstaller->installCoreTranslations($localeID);
                } else {
                    $this->translationsInstaller->installPackageTranslations($package, $localeID);
                }
                $this->shouldClearLocalizationCache = true;
                ++$result;
                if ($this->output->getVerbosity() > OutputInterface::VERBOSITY_NORMAL) {
                    $this->output->writeln('done.');
                }
            }
        }

        return $result;
    }
937764
private function installTranslations($localeID, Package $package = null)
    {
        if ($package === null) {
            $localStats = $this->localFactory->getCoreStats($localeID);
            $shownDirectoryName = '/' . DIRNAME_APPLICATION . '/' . DIRNAME_LANGUAGES;
        } else {
            $localStats = $this->localFactory->getPackageStats($package, $localeID);
            $shownDirectoryName = '/' . DIRNAME_PACKAGES . '/' . $package->getPackageHandle() . '/' . DIRNAME_LANGUAGES;
        }
        $directory = dirname($localStats->getFilename());
        if (!$this->fs->isDirectory($directory)) {
            if ($this->fs->makeDirectory($directory, DIRECTORY_PERMISSIONS_MODE_COMPUTED, true, true) !== true) {
                throw new Exception(t('Failed to create the directory for the language file. Please be sure that the %s directory is writable', $shownDirectoryName));
            }
        }
        if (!$this->fs->isWritable($directory)) {
            throw new Exception(t('Please be sure that the %s directory is writable', $shownDirectoryName));
        }
        if ($package === null) {
            $coreVersion = $this->config->get('concrete.version_installed');
            $translations = $this->remoteProvider->fetchCoreTranslations($coreVersion, $localeID);
        } else {
            $translations = $this->remoteProvider->fetchPackageTranslations($package->getPackageHandle(), $package->getPackageVersion(), $localeID);
        }
        $saved = @$this->fs->put($localStats->getFilename(), $translations, true) !== false;
        unset($translations);
        if ($saved === false) {
            throw new Exception(t('Failed to save the language file: please be sure that PHP can write files in the directory %s', $shownDirectoryName));
        }
    }
99977
public function execute(InputInterface $input, OutputInterface $output)
    {
        $excluded = [];

        if ($input->getOption('exclude')) {
            $excluded = explode(',', $input->getOption('exclude'));
        }

        $io = new OutputStyle($input, $output);

        $composerPath = $this->getComposerPathFromInput($input);

        $ladder = new Ladder($composerPath);

        $packages = $ladder->getOutdatedPackages($excluded);

        $io->newLine();

        $statusCode = 0;

        if (!count($packages)) {
            $io->writeln('All dependencies match the latest package versions <fg=green>:)</>');
            $io->newLine();

            return $statusCode;
        }

        $outdated = [];
        $upgradable = [];

        foreach ($packages as $package) {
            $diff = $io->versionDiff($package->getVersion(), $package->getLatestVersion());

            if ($package->isUpgradable()) {
                $upgradable[] = [$package->getName(), $package->getVersion(), '→', $diff];
            } else {
                $outdated[] = [$package->getName(), $package->getVersion(), '→', $diff];
            }
        }

        if (count($outdated) && !$input->getOption('upgradable')) {
            $statusCode = 1;

            $io->columns($outdated);
            $io->newLine();
        }

        if (count($upgradable) && !$input->getOption('outdated')) {
            $statusCode = 1;

            $io->writeln('The following dependencies are satisfied by their declared version constraint, but the installed versions are behind. You can install the latest versions without modifying your composer.json file by using <fg=blue>composer update</>.');
            $io->newLine();
            $io->columns($upgradable);
            $io->newLine();
        }

        return $statusCode;
    }
1300098
private function publish_packages($packages)
    {
        if (empty($packages)) {
            return;
        }

        foreach ($packages as $package => $directories_to_publish) {
            if (empty($directories_to_publish)) {
                $this->output->writeln("<comment>$package has no files to publish!</comment>");
                continue;
            }

            $this->publish_directories($directories_to_publish);
        }
    }
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);
                }
            }
        }
    }
782397
public function create(Package $package, $path, $plain = true)
	{
		$directory = $this->createDirectory($package, $path);

		// To create the package, we will spin through a list of building blocks that
		// make up each package. We'll then call the method to build that block on
		// the class, which keeps the actual building of stuff nice and cleaned.
		foreach ($this->getBlocks($plain) as $block)
		{
			$this->{"write{$block}"}($package, $directory, $plain);
		}

		return $directory;
	}
941048
private static function file_set_version($package, \Datetime $version) {
		self::get_version($package);

		if (file_exists(Config::$migration_directory . '/db_version')) {
			$version_file = trim(file_get_contents(Config::$migration_directory . '/db_version'));
			$versions = json_decode($version_file, true);
		} else {
			$versions = [];
		}

		$versions[$package] = $version->format('Ymd His');
		file_put_contents(Config::$migration_directory . '/db_version', json_encode($versions));
	}
517853
public function update(
        InstalledRepositoryInterface $repo,
        PackageInterface $initial,
        PackageInterface $target
    ) {
        $installPath = $this->getInstallPath($target);
        $junglist = new FileJunglist;
        $junglist->saveModifiedFiles($installPath);
        DebugPrinter::log('Updating package');
        parent::update($repo, $initial, $target);
        DebugPrinter::log('Post-update file rotate');
        $junglist->rotateInstalledFiles($installPath);
        $junglist->restoreModifiedFiles($installPath);
        DebugPrinter::log('Finished updating');
    }
883259
protected function writeProviderStub(Package $package, $directory, $stub)
	{
		$path = $this->createClassDirectory($package, $directory);

		// The primary source directory where the package's classes will live may not
		// exist yet, so we will need to create it before we write these providers
		// out to that location. We'll go ahead and create now here before then.
		$file = $path.'/'.$package->name.'ServiceProvider.php';

		$this->files->put($file, $stub);
	}
155485
public function resetPackage(WritableRepositoryInterface $repository, PackageInterface $package)
    {
        $verbosityLevel = OutputUtils::resetVerbosity($this->appIO, OutputInterface::VERBOSITY_QUIET);

        $operation = new ResetOperation($package, 'Package reset due to changes in patches configuration');

        if (!$this->packageResetStrategy->shouldAllowReset($package)) {
            OutputUtils::resetVerbosity($this->appIO, $verbosityLevel);

            throw new \Vaimo\ComposerPatches\Exceptions\PackageResetException(
                sprintf('Package reset halted due to encountering local changes: %s', $package->getName())
            );
        }

        try {
            $this->installer->install($repository, $operation);
        } catch (\Exception $exception) {
            OutputUtils::resetVerbosity($this->appIO, $verbosityLevel);

            throw $exception;
        }

        OutputUtils::resetVerbosity($this->appIO, $verbosityLevel);
    }
143025
public function download($package, $version = null, $noInstall = false)
    {
        $package = !empty($version) ? $package . ':' . $version : $package;

        $args = $noInstall === true ? self::NO_PROGRESS . self::NO_UPDATE . self::DEFAULT_ARGS : self::DEFAULT_ARGS;

        return $this->runCommand(self::DOWNLOAD, $package, $args);
    }
1337944
public function writeSupportDirectories(Package $package, $directory)
	{
		foreach (array('config', 'controllers', 'lang', 'migrations', 'views') as $support)
		{
			$this->writeSupportDirectory($package, $support, $directory);
		}
	}
895088
protected function createClassDirectory(Package $package, $directory)
	{
		$path = $directory.'/src/'.$package->vendor.'/'.$package->name;

		if ( ! $this->files->isDirectory($path))
		{
			$this->files->makeDirectory($path, 0777, true);
		}

		return $path;
	}
660029
public function writePublicDirectory(Package $package, $directory, $plain)
	{
		if ($plain) return;

		$this->files->makeDirectory($directory.'/public');

		$this->files->put($directory.'/public/.gitkeep', '');
	}
608745
public static function registerPackage(PackageInterface $package, $target, AssetsInstallerInterface $installer = null)
    {
        self::$__autoloader->registerPackage($package, $target, $installer);
    }
430566
public function writeServiceProvider(Package $package, $directory, $plain)
	{
		// Once we have the service provider stub, we will need to format it and make
		// the necessary replacements to the class, namespaces, etc. Then we'll be
		// able to write it out into the package's workbench directory for them.
		$stub = $this->getProviderStub($package, $plain);

		$this->writeProviderStub($package, $directory, $stub);
	}