-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Add install-path and type to installedVersions.php and installed.php,… #9699
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add install-path and type to installedVersions.php and installed.php,… #9699
Conversation
c9d325b to
85fe2a9
Compare
|
Just had a look whats going on with phpstan issues. |
|
@ochorocho sorry for the trouble but could you rebase this on latest master? I merged other things which conflict with your PR. As for the phpstan error, you can ignore these, it's a quirk of the fact the InstalledVersions file used in CI does not yet contain the new methods until the PR gets merged. |
08e200f to
f4cbe78
Compare
|
@Seldaek rebase done :-) |
|
FYI, all packages defined with EDIT: Seems like a TYPO3 specific issue. Only relevant for development in the mono repo. |
I am not sure what you mean, if you have more details maybe we can figure out a solution or at least identify the root cause. |
example: composer.json of the TYPO3 project https://git.typo3.org/Packages/TYPO3.CMS.git/blob_plain/HEAD:/composer.json Thank you. Let me know if you need anything else. :-) |
|
Thanks for the fixes. The last thing open is #9699 (review) which definitely needs fixing but then it looks good to me. |
| 'pretty_version' => 'dev-master', | ||
| 'version' => 'dev-master', | ||
| 'type' => 'library', | ||
| 'install_path' => false, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
string|null is a better type than string|false IMO
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed to null
@Seldaek now using an array containing package name and its path and passing it to |
| 'pretty_version' => 'dev-master', | ||
| 'version' => 'dev-master', | ||
| 'type' => 'library', | ||
| 'install_path' => false, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is wrong
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed to 'install_path' => '',.
Thank you!
stof
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see any tests covering the generation of the install_path key
src/Composer/InstalledVersions.php
Outdated
| /** | ||
| * Initialize $installed array | ||
| */ | ||
| public static function __constructStatic() {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why __constructStatic ? names prefixed by __ are soft-reserved by PHP for magic methods, and this is not one of them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense, will rename it.
src/Composer/InstalledVersions.php
Outdated
| } | ||
| } | ||
|
|
||
| InstalledVersions::__constructStatic(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why ? this is a no-op
| } else { | ||
| $stringContent = str_replace(array('\\', '\''), array('\\\\', '\\\''), $value); | ||
| $folder = $key === 'install_path' ? '__DIR__ . DIRECTORY_SEPARATOR . ' : ''; | ||
| $lines .= $folder . '\'' . $stringContent . "',\n"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you should still be using var_export to export the string literal, rather than rebuilding it in userland (in an incomplete way)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, i need this to be able to write __DIR__ . DIRECTORY_SEPARATOR . to the PHP file and not the resulting path.
Happy to have any suggestions to avoid using my own method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your generated line is __DIR__ . DIRECTORY_SEPARATOR . followed by a string literal. I'm talking only about the string literal, not about the whole line.
| $reference = ($package->getSourceReference() ?: $package->getDistReference()) ?: null; | ||
| } | ||
|
|
||
| $installPath = $package instanceof RootPackageInterface ? '' : $installPaths[$package->getName()]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is wrong. the relative path from the location of the installed.php file to the root package is not the empty string.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the final result in InstalledVersions.php so i reckon the path correct:
self::$installed = array(
'root' => array(
'pretty_version' => 'dev-master',
'version' => 'dev-master',
'type' => 'library',
'install_path' => __DIR__ . DIRECTORY_SEPARATOR . '',
'aliases' => array(
0 => '2.1.x-dev',
),
'reference' => 'a614587ec91031b99ab23b385838f6d9641c847d',
'dev-requirement' => true,
'name' => 'composer/composer',
),
....There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
root should have an install_path of __DIR__ . '/../../' for composer, but the result should be dependent on the vendor-dir, so it should really compute the relative path from vendor-dir/composer to getcwd() to find the root install path.
| $config = $package->getConfig(); | ||
| $vendorDir = !empty($config['vendor-dir']) ? $config['vendor-dir'] : 'vendor'; | ||
| $to = getcwd(); | ||
| $from = $to . DIRECTORY_SEPARATOR . $vendorDir . DIRECTORY_SEPARATOR . 'composer'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no need to do your own processing of the vendor-dir config. The $from is the $repoDir that we have in ->write(), i.e. the folder in which we are generating the file. You only need to pass it as an argument in this private method
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for that hint. Changed it.
|
@Seldaek tried to fix Can you give me any advice to get this test running again? |
fd6e18f to
6c9b55b
Compare
|
@Seldaek all tests passed now. Branch is up to date with master. |
… add method to get installed packages by type Issue composer#9648
…hich do not have a shortest-path and require an absolute path to be addressed
…ta from the class
7ea71f2 to
284ec95
Compare
|
@ochorocho thanks for this, I rebased it again and squashed commits to clean up a little then reviewed in depth and did some changes (some of it are kinda unrelated to this PR, just other things I noticed needed tweaking before 2.1 for InstalledVersions while I was poking around). Have a look at my individual commits if you're interested in more details. I think this is mergeable now, but happy if someone else has a second to review again. |
ochorocho
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me.
Thank you! :-)

… add method to get installed packages by type
typeandinstall_pathgetInstalledPackagesByTypeto allow retrieval of of installed packages by a given type@Seldaek your feedbeack is very welcome :-)
#9648