Comments (21)
From the looks of it, this piece of code should handle the mismatch:
https://github.com/wp-cli/package-command/blob/master/src/Package_Command.php#L221-L227
But for some reason doesn't.
from package-command.
Thanks for the excellent example and diagnostics @javorszky.
this piece of code should handle the mismatch
Composer is doing strtolower()
s all over the place for some reason so the package name gets "corrected" to its lowercase version.
A way around might be to do $installed_package_keys = array_map( 'strtolower', $installed_package_keys );
in get_installed_packages()
, and also to lowercase the $package_name
arg in get_installed_package_by_name()
and (for the BC check only) get_package_by_shortened_identifier()
.
from package-command.
I think the install script is wrong. It compares the package name in the composer.json in the repo with the name of the repo, and if the two don't match, it uses the name in the composer.json.
Or at least should. If you look in the composer.json of the example command, that one is all lowercase because composer complains otherwise.
Yet what does get installed / recorded is the repo name, so the comparison goes wrong there. I think. I don't have wpcli set up for dev on my computer, so can't double check this with debugging statements.
from package-command.
I think the install script is wrong. It compares the package name in the composer.json in the repo with the name of the repo, and if the two don't match, it uses the name in the composer.json.
Ah maybe it shouldn't then. If I change that check to if ( strtolower( $package_name ) !== $package_name_on_repo ) {
then things kind of work okay, ie the require
etc keys in ~/wp.cli/packages/composer.json
all have the non-lowercased name.
And with the strtolower()
hacks mentioned earlier can uninstall okay as long as I specify the correct case.
The listing is wrongly in lowercase though.
from package-command.
What I mean is that if the github is CapitalWPCLI/examplecommand
, and the composer json has capitalwpcli/examplecommand
as the name, it should save as capitalwpcli/examplecommand
.
Currently it saves as CapitalWPCLI/examplecommand
.
from package-command.
To be fair, I expect the ~/.wp-cli/package/composer.json
would have the name of the package as it's declared in the composer.json
of the package.
from package-command.
Okay, ta. It's very confusing and messy. I'll leave it to the Composer experts, of which I'm most definitely not. Related wp-cli/wp-cli#4232 and #31
from package-command.
Okies. I summon @schlessera / @danielbachhuber to take a glance at this if they have a moment :)
from package-command.
Mystery solved - just noticed the 4292472 in your stat of wp - that's the size of wp-cli 1.3.0 - and #31 is only in 1.4.0, so that's why the mixed case git user name is ending up in your composer.json, as it's not getting corrected by mismatch check in the lines you highlighted.
I'll add a test anyway to clarify this situation (for myself mostly, given the confusion I got myself into above).
from package-command.
Ooh, okay. That makes sense! Thank you. An uh... sorry for not checking the versions! Should I leave this open until the tests are added?
from package-command.
Hi, thanks for getting back. Please leave it open yes, as I've found out that there is an issue after all with mixed-case names with the current version, though not in your particular case (but when the name in composer.json
is mixed-case anyway).
I'm going to do a PR very soon with a fix for that case, and also with tests for that case and your case. The tests will use your test example https://github.com/CapitalWPCLI/examplecommand if that's alright. Also if and when you have the time if you could confirm that updating to the latest wp-cli fixes your issue it'd be much appreciated.
from package-command.
Will do! I'll keep an eye out for the new versions of wp-cli! Thank you for looking into this!
from package-command.
Ta - just in case to clarify, the current version 1.4.0 should fix your issue so you don't have to wait to confirm it!
from package-command.
Hi,
So it didn't work... seemingly it did. Also, if I'm installing a specific package, it shouldn't update all the others, right?
This is using wpcli 1.4.0
from package-command.
Nope, ignore the above. Once I removed the package manually (delete files, delete composer.lock, edit composer.json), and tried again, it installed the package correctly.
However I can no longer test updating other packages when I'm installing one...
from package-command.
Also, if I'm installing a specific package, it shouldn't update all the others, right?
Incorrect. This is expected behavior, as WP-CLI uses Composer under the hood.
from package-command.
Once I removed the package manually (delete files, delete composer.lock, edit composer.json)
Yes, that's the sort of thing I ended up doing too, which I thought was probably just my system having got messed up.
from package-command.
This is expected behavior
Maybe it shouldn't though?! It seems odd to me that installing a package causes a full install using ~/.wp-cli/packages/composer.json
rather than just the package's composer.json
(but I'll have to think about it and come up with something less half-formed - and this probably isn't the best place to discuss it anyway).
from package-command.
Also, if I'm installing a specific package, it shouldn't update all the others, right?
Incorrect. This is expected behavior, as WP-CLI uses Composer under the hood.
Actually, you can do a selective update with Composer.
So, composer update my/package
will only update that individual package, not the rest.
from package-command.
Actually, you can do a selective update with Composer.
So, composer update my/package will only update that individual package, not the rest.
That's fine, but if I'm just installing a package, I don't expect all other packages to be touched unless I explicitly tell them to be touched.
Dunno, maybe it's just me and not knowing what to expect of composer.
from package-command.
No, you're right, I think. I would also expect that if I add a package, that that package will get installed in its latest matching version, but the rest just stays as is. I should need to run wp package update
to get updates to the rest of the packages.
from package-command.
Related Issues (20)
- installing package on Intranet HOT 3
- Unable to install packages on Windows and PHP7.3.1 HOT 13
- Adopt and enforce new `WP_CLI_CS` standard HOT 2
- Allow install from a Git repository specific branch HOT 1
- check_git_package_name hardcode reference to GitHub HOT 2
- Commands Cookbook link goes to a 404 HOT 1
- Lock framework to stable version again before release
- Compatibility with Composer 2 HOT 7
- Legacy package index prevents installation of current release of a package HOT 2
- Allow composer ^2.0 HOT 6
- SSL certificate problem: certificate has expired HOT 9
- Declaration of WP_CLI\ComposerIO::isVerbose() and others not compatible with Composer\IO\NullIO::isVerbose(): bool HOT 2
- Restore 'Install a package with a dependency' test
- Support for Composer 2.5 HOT 8
- Errors installing command into development environment HOT 3
- Add command to get information about single package HOT 4
- Move command over to new v2 structure
- Prefer packagist.org over Github
- Automatically rerun failed scenarios
- Broke composer commands when used with phpcodesniffer-composer-installer HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from package-command.