Coder Social home page Coder Social logo

Comments (21)

javorszky avatar javorszky commented on August 17, 2024

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.

gitlost avatar gitlost commented on August 17, 2024

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.

javorszky avatar javorszky commented on August 17, 2024

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.

gitlost avatar gitlost commented on August 17, 2024

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.

javorszky avatar javorszky commented on August 17, 2024

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.

javorszky avatar javorszky commented on August 17, 2024

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.

gitlost avatar gitlost commented on August 17, 2024

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.

javorszky avatar javorszky commented on August 17, 2024

Okies. I summon @schlessera / @danielbachhuber to take a glance at this if they have a moment :)

from package-command.

gitlost avatar gitlost commented on August 17, 2024

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.

javorszky avatar javorszky commented on August 17, 2024

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.

gitlost avatar gitlost commented on August 17, 2024

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.

javorszky avatar javorszky commented on August 17, 2024

Will do! I'll keep an eye out for the new versions of wp-cli! Thank you for looking into this!

from package-command.

gitlost avatar gitlost commented on August 17, 2024

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.

javorszky avatar javorszky commented on August 17, 2024

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?

screen shot 2017-11-03 at 15 02 23

This is using wpcli 1.4.0

from package-command.

javorszky avatar javorszky commented on August 17, 2024

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.

danielbachhuber avatar danielbachhuber commented on August 17, 2024

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.

gitlost avatar gitlost commented on August 17, 2024

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.

gitlost avatar gitlost commented on August 17, 2024

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.

schlessera avatar schlessera commented on August 17, 2024

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.

javorszky avatar javorszky commented on August 17, 2024

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.

schlessera avatar schlessera commented on August 17, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.