Skip to content

Commit

Permalink
BC break: removed deprecated `PackageVersions\Versions::ROOT_PACKAGE_…
Browse files Browse the repository at this point in the history
…NAME` constant

This simplifies the tool to no longer be a plugin: `PackageVersions\Versions` is now a much simpler
class that is no longer generated/written to disk at installation, and `ocramius/package-versions`
is no longer a `"type": "composer-plugin"`, but rather a more usual `"type": "library"` package.

This:

 * Fixes #138 - this library no longer changes `vendor` post-installation
 * Fixes #142 - the `rootPackage` version is now detected via composer, and no longer leads to
   changes in `vendor/ocramius/package-versions/src/PackageVersions/Versions.php` at each change
   of source root in a project
 * Fixes #152 - when `"lock": false` is used in composer, since we no longer access lock file
   information from sources of this package
 * Fixes #107 - writing to `vendor` is no longer happening from this library, so no file access
   rights should be needed.
  • Loading branch information
Ocramius committed Aug 21, 2020
1 parent f51ff2b commit b6d9c31
Show file tree
Hide file tree
Showing 5 changed files with 1 addition and 1,265 deletions.
20 changes: 0 additions & 20 deletions src/PackageVersions/ComposerV2Plugin.php

This file was deleted.

234 changes: 0 additions & 234 deletions src/PackageVersions/Installer.php

This file was deleted.

21 changes: 0 additions & 21 deletions src/PackageVersions/Versions.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,8 @@
use Composer\InstalledVersions;
use OutOfBoundsException;

/**
* This is a stub class: it is in place only for scenarios where PackageVersions
* is installed with a `--no-scripts` flag, in which scenarios the Versions class
* is not being replaced.
*
* If you are reading this docBlock inside your `vendor/` dir, then this means
* that PackageVersions didn't correctly install, and is in "fallback" mode.
*/
final class Versions
{
/**
* @deprecated please use {@see self::rootPackageName()} instead.
* This constant will be removed in version 2.0.0.
*/
public const ROOT_PACKAGE_NAME = 'unknown/root-package@UNKNOWN';

private function __construct()
{
}
Expand All @@ -48,13 +34,6 @@ public static function rootPackageName() : string
*/
public static function getVersion(string $packageName) : string
{
/** @psalm-suppress DeprecatedConstant */
if ($packageName === self::ROOT_PACKAGE_NAME) {
$rootPackage = InstalledVersions::getRootPackage();

return $rootPackage['pretty_version'] . '@' . $rootPackage['reference'];
}

return InstalledVersions::getPrettyVersion($packageName)
. '@' . InstalledVersions::getReference($packageName);
}
Expand Down
Loading

0 comments on commit b6d9c31

Please sign in to comment.