woocommerce icon indicating copy to clipboard operation
woocommerce copied to clipboard

Add `wc com connect` command

Open rcstr opened this issue 2 years ago • 5 comments

All Submissions:

Changes proposed in this Pull Request:

PR adds wc com connect command which allows stores to be connected to WCCOM via CLI script

Closes https://github.com/Automattic/woocommerce.com/issues/13888.

How to test the changes in this Pull Request:

  1. Generate an application password following instructions from https://github.com/Automattic/woocommerce.com/pull/13974. Save the password for later use
  2. From your tes site, be sure you're connecting to a local instance of 'woocommerce.com' using woocommerce_helper_api_base filter
add_filter( 'woocommerce_helper_api_base', function () {
	return 'https://woocommerce.test/wp-json/helper/1.0';
} );
  1. From the terminal, run: wc com connect

  2. When asked, past the application password from step 1. Screen Shot 2022-07-27 at 04 15 26

  3. Site should be connected now.

  4. Run wc com connect again, see an error message when the site is already connected

  5. Run wc com connect --force, check that site is disconnected and connected again

  6. Run wc com connect --password=APPLICATION_PASSWORD --force, password shouldn't be prompt

Other information:

  • [x] Have you added an explanation of what your changes do and why you'd like us to include them?
  • [ ] Have you written new tests for your changes, as applicable?
  • [x] Have you successfully run tests with your changes locally?
  • [x] Have you created a changelog file for each project being changed, ie pnpm changelog add --filter=<project>?

FOR PR REVIEWER ONLY:

  • [ ] I have reviewed that everything is sanitized/escaped appropriately for any SQL or XSS injection possibilities. I made sure Linting is not ignored or disabled.

rcstr avatar Jul 27 '22 09:07 rcstr

Test Results Summary

Commit SHA: 423dd78f3e9e4d6d0cbb2c44f6d49bfe81aaa254

Test :test_tube:Passed :white_check_mark:Failed :rotating_light:Broken :construction:Skipped :next_track_button:Unknown :grey_question:Total :bar_chart:Duration :stopwatch:
API Tests11500201170m 37s
E2E Tests186001018714m 29s
To view the full API test report, click here.
To view the full E2E test report, click here.
To view all test reports, visit the WooCommerce Test Reports Dashboard.

github-actions[bot] avatar Jul 27 '22 09:07 github-actions[bot]

I'm having trouble testing this. What I did:

  1. Add the woocommerce.com repo as a remote in my local WooCommerce repo, fetch
  2. Switch to branch add/13762-connect-endpoint-for-wc-connect-cli-command, tracking the same remote branch (for doing the testing instructions in 13885-gh-Automattic/woocommerce.com)
  3. Run the command to create the tables from that pr, then I get 'wccom' is not a registered wp command

Am I missing something?

Konamiman avatar Jul 28 '22 09:07 Konamiman

@rcstr I've left a few comments.

Also in order to make the command easier to be used by automated scripts, I think we should allow passing the password as an argument to the connect command.

thilinah avatar Jul 28 '22 12:07 thilinah

thanks @thilinah for the suggestion, I have added the --password flag, and another flag to --force in 423dd78

rcstr avatar Aug 10 '22 03:08 rcstr

I'm having trouble testing this. What I did:

  1. Add the woocommerce.com repo as a remote in my local WooCommerce repo, fetch
  2. Switch to branch add/13762-connect-endpoint-for-wc-connect-cli-command, tracking the same remote branch (for doing the testing instructions in 13885-gh-Automattic/woocommerce.com)
  3. Run the command to create the tables from that pr, then I get 'wccom' is not a registered wp command

Am I missing something?

@Konamiman, everything looks good from the instructions you followed. Could you try running npm run wp:cli -- wccom create-app-passwords-tables? This will run the command from the docker-machine

rcstr avatar Aug 10 '22 03:08 rcstr

@rcstr I tried what you suggested and I'm getting a Error response from daemon: Container (guid of woocommercecom_wp) is restarting, wait until the container is running. If I take a look at the logs (docker logs) I see the following repeated multiple times:

AH00526: Syntax error on line 32 of /etc/apache2/sites-enabled/default-ssl.conf:
SSLCertificateFile: file '/etc/ssl/certs/woocommerce.test.crt' does not exist or is empty

Do I need any additional setup?

Konamiman avatar Aug 11 '22 10:08 Konamiman

Hi @Konamiman, thanks for merging this pull request. Please take a look at these follow-up tasks you may need to perform:

  • [ ] Add the release: add testing instructions label

github-actions[bot] avatar Aug 17 '22 08:08 github-actions[bot]