getInstalledVersion

@param   string $package

@return  string
427181
public static function getInstalledVersion($package)
    {
        $composer = ComposerInformation::getLock();

        $data = ArrayHelper::query($composer['packages'], ['name' => $package]);

        if (isset($data[0]['version'])) {
            return $data[0]['version'];
        }

        return null;
    }
1228187
public function alreadyPublished($package)
    {
        $path = $this->getDestinationPath($package);

        return $this->files->isDirectory($path);
    }
1105723
public function getInstallPath(PackageInterface $package)
	{
		$prefix = mb_substr($package->getPrettyName(), 0, 23);
		if ('myadmin/template-' !== $prefix) {
			throw new \InvalidArgumentException(
				'Unable to install template, myadmin templates '
				.'should always start their package name with '
				.'"myadmin/template-"'
			);
		}
		return 'data/templates/'.mb_substr($package->getPrettyName(), 23);
	}
172970
public function appendPackage($package) {
		$package = $this->handlePackage($package);
		
		$this->packages[] = $package;
		return $package;
	}
1109795
private function download($package)
    {
        $tmp_dir = Grav::instance()['locator']->findResource('tmp://', true, true);
        $this->tmp = $tmp_dir . '/Grav-' . uniqid('', false);
        $output = Response::get($package['download'], [], [$this, 'progress']);

        Folder::create($this->tmp);

        $this->output->write("\x0D");
        $this->output->write("  |- Downloading upgrade [{$this->formatBytes($package['size'])}]...   100%");
        $this->output->writeln('');

        file_put_contents($this->tmp . DS . $package['name'], $output);

        return $this->tmp . DS . $package['name'];
    }
213916
private function installPath($package) {
    if (isset($this->paths['package'][$package['package']]['path'])){

      return $this->paths['package'][$package['package']]['path'];
    } elseif (isset($this->paths['vendor'][$package['vendor']]['path'])){

      return $this->paths['vendor'][$package['vendor']]['path'];
    } elseif (isset($this->paths['type'][$package['type']]['path'])){

      return $this->paths['type'][$package['type']]['path'];
    } else {
      return false;
    }
  }
654019
private function getSuluVersion($dir)
    {
        $version = '_._._';

        /** @var SplFileInfo $composerFile */
        $composerFile = new SplFileInfo($dir . '/composer.lock', '', '');
        if (!$composerFile->isFile()) {
            return $version;
        }

        $composer = json_decode($composerFile->getContents(), true);
        foreach ($composer['packages'] as $package) {
            if ('sulu/sulu' === $package['name']) {
                return $package['version'];
            }
        }

        return $version;
    }
1286889
public function createPackageResults(array $package)
    {
        $created = array();

        if (isset($package['maintainers']) && $package['maintainers']) {
            foreach ($package['maintainers'] as $key => $maintainer) {
                $package['maintainers'][$key] = $this->createResult('Packagist\Api\Result\Package\Maintainer', $maintainer);
            }
        }

        if (isset($package['downloads']) && $package['downloads']) {
            $package['downloads'] = $this->createResult('Packagist\Api\Result\Package\Downloads', $package['downloads']);
        }

        foreach ($package['versions'] as $branch => $version) {
            if (isset($version['authors']) && $version['authors']) {
                foreach ($version['authors'] as $key => $author) {
                    $version['authors'][$key] = $this->createResult('Packagist\Api\Result\Package\Author', $author);
                }
            }
            if ($version['source']) {
                $version['source'] = $this->createResult('Packagist\Api\Result\Package\Source', $version['source']);
            }
            if (isset($version['dist']) && $version['dist']) {
                $version['dist'] = $this->createResult('Packagist\Api\Result\Package\Dist', $version['dist']);
            }

            $package['versions'][$branch] = $this->createResult('Packagist\Api\Result\Package\Version', $version);
        }

        $created = new Package();
        $created->fromArray($package);

        return $created;
    }
1326639
public function getInstallPath(PackageInterface $package)
    {
        $textpattern = new Textpattern();
        $path = $textpattern->getRelativePath();
        $themes = $path . '/admin-themes';

        // Textpattern <= 4.5.x uses 'theme' directory.
        if (!file_exists($themes)) {
            $themes = $path . '/theme';
        }

        return $themes . '/' . basename($package->getPrettyName());
    }
872790
public function setPackage($package)
    {
        if ($package instanceof AbstractPackage) {
            $this->package = $package;
        } else {
            $this->package = PackageHelper::getPackage($package);
        }

        return $this;
    }
108321
public function getDeployInfo($package) {
    $deployInfoFile = $package->getRootDirectory()->getFile('deploy-info.json');

    $deployInfo = new \stdClass;
    if ($deployInfoFile->exists()) {
      $deployInfo = JSONConverter::create()->parseFile($deployInfoFile);
    }

    if (!isset($deployInfo->isStaging)) {
      $deployInfo->isStaging = NULL;
    }

    if (!isset($deployInfo->isDevelopment)) {
      $deployInfo->isDevelopment = NULL;
    }

    if (!isset($deployInfo->isBuilt)) {
      $deployInfo->isBuilt = NULL;
    }

    return $deployInfo;
  }
1315787
private function getMappedPackageList(array $packages): array
    {
        $groupedPackages = $this->groupPackagesByName($packages);

        $mappedPackages = [];
        foreach ($groupedPackages as $name => $packages) {
            $highest = $this->getHighestVersion($packages);

            $mappedPackages[$name] = [
                'highest' => $highest,
                'abandoned' => $highest instanceof CompletePackageInterface ? $highest->isAbandoned() : false,
                'replacement' => $highest instanceof CompletePackageInterface ? $highest->getReplacementPackage() : null,
                'versions' => $this->getDescSortedVersions($packages),
            ];
        }

        return $mappedPackages;
    }
1352166
public function publishPackage($package)
    {
        $source = $this->getSource($package);

        return $this->publish($package, $source);
    }
218368
public function subscribeTo($package)
    {
        if (!$this->hasSubscription(false)) {
            $this->_mixer->subscription = $this->getService('repos:subscriptions.subscription')
            ->getEntity(array(
                'data' => array(
                    'package' => $package,
                  ),
            ));
            $this->_mixer->verified = 1;
        }

        return $this->_mixer->subscription;
    }
783683
public function prependPackage($package) {
		$package = $this->handlePackage($package);
		
		$this->packages->unshift($package);
		return $package;
	}
953992
public function getPackageJsonFile($package)
    {
        // We get the project vendor path
        $vendorPath = $this->getVendorPath();
        // We get the target dir of the iterated package
        $targetDir = $package->getTarget();
        $jsonPath = $vendorPath . $targetDir . "/composer.json";
        if (method_exists($package, 'getJsonFile')) {
            $jsonFile = $package->getJsonFile($jsonPath);
        } else {
            // @codeCoverageIgnoreStart
            $jsonFile = new JsonFile($jsonPath);
            // @codeCoverageIgnoreEnd
        }

        return $this->fs->exists($jsonPath) ? $jsonFile->read() : null;
    }
581527
protected function getPackageName($package)
    {
        if (strpos($package, '/') === false) {
            return $package;
        }

        list($vendor, $namespace) = explode('/', $package);

        return $namespace;
    }