Skip to content

Sync package composer repository on install#3276

Merged
danielbachhuber merged 8 commits into
wp-cli:masterfrom
aaemnnosttv:pr/synchronize-package-index-on-install
Aug 15, 2016
Merged

Sync package composer repository on install#3276
danielbachhuber merged 8 commits into
wp-cli:masterfrom
aaemnnosttv:pr/synchronize-package-index-on-install

Conversation

@aaemnnosttv
Copy link
Copy Markdown
Contributor

Right now, older installs of WP-CLI error when trying to install a new package due to the package index url not being updated from http to https. This fails when composer goes to query the package index over http, since secure_http is being set to true (I believe this is also the default now). Some users may not know how to correct this manually, and they shouldn't really have to.

This PR performs a simple check when preparing to install a package. If the current package index isn't found in the composer config file, then it will refresh the definition for the package index repository.

fixes #3275

Comment thread php/commands/package.php Outdated
$json_manipulator->addConfigSetting( 'secure-http', true );

// If the composer file does not contain the current package index url, refresh the repository definition.
if ( false === strpos( $composer_backup, self::PACKAGE_INDEX_URL ) ) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a bit too blunt.

We should specifically check the repository definition, and only replace http://wp-cli.org/package-index/

@danielbachhuber
Copy link
Copy Markdown
Member

@aaemnnosttv Can you add a functional test case for this?

@aaemnnosttv
Copy link
Copy Markdown
Contributor Author

aaemnnosttv commented Aug 11, 2016

I was thinking about that, but I'm not sure what the best way to handle that would be. I would need to modify the packages composer.json that the wp-cli tests use. Can you point me in the right direction there?

@danielbachhuber
Copy link
Copy Markdown
Member

I would need to modify the packages composer.json that the wp-cli tests use. Can you point me in the right direction there?

You could modify the composer.json with sed. Here's an example: https://github.com/wp-cli/wp-cli/blob/master/features/core-verify-checksums.feature#L15

@aaemnnosttv
Copy link
Copy Markdown
Contributor Author

Hey Daniel, see what you think about the test I added. It's a little more verbose with the scripting in the scenario, but it works. You have any ideas as to how to clean that up, or you think it's ok?

Comment thread features/package-install.feature Outdated
"""
When I run `rm -rf /tmp/wp-cli-package-install-test/ && mkdir /tmp/wp-cli-package-install-test/ && mv composer.json /tmp/wp-cli-package-install-test/`
Then the /tmp/wp-cli-package-install-test/composer.json file should exist
When I run `WP_CLI_PACKAGES_DIR=/tmp/wp-cli-package-install-test/ wp --info`
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of depending on /tmp/, can't we just put WP_CLI_PACKAGES_DIR in a directory relative to the test directory? This way, we don't have to clean up the temp directory at the end of the test run either.

@danielbachhuber
Copy link
Copy Markdown
Member

It's a little more verbose with the scripting in the scenario, but it works. You have any ideas as to how to clean that up, or you think it's ok?

You're headed in the right direction! I've left some comments.

@aaemnnosttv
Copy link
Copy Markdown
Contributor Author

Not sure why this failed...

No output has been received in the last 10 minutes, this potentially indicates a stalled build or something wrong with the build itself.

Retry?

@danielbachhuber
Copy link
Copy Markdown
Member

Not sure why this failed...

Do the tests pass locally?

@aaemnnosttv
Copy link
Copy Markdown
Contributor Author

All of the assertions of the test are passing, but it's just hanging there at the end, which is what happened on Travis too. Really strange.. any idea why it would be locked up like that? I've tried it a bunch of different ways but it keeps getting stuck at the end and I have to ctrl-c it to stop it, and then it goes to the next scenario.

image

Changing the package directory to a sub directory doesn't change anything either.

You seen anything like that before?

@danielbachhuber
Copy link
Copy Markdown
Member

Have you verified the installation process completes successfully?

Comment thread features/package-install.feature Outdated
"""
WP-CLI packages dir: .
"""
When I run `WP_CLI_PACKAGES_DIR=. wp package install runcommand/hook`
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we include an assertion that the "Updating package index repository URL" string is a part of the output?

- removed the subdirectory for the packages/composer.json which caused the test to hang indefinitely.
- setup a local dummy package to “install” instead of the real one making the test a bit faster as well.
@aaemnnosttv
Copy link
Copy Markdown
Contributor Author

Success!

@aaemnnosttv
Copy link
Copy Markdown
Contributor Author

Anything more here before we can merge this one?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Your configuration does not allow connections to http://wp-cli.org/package-index/packages.json

2 participants