Skip to content
This repository was archived by the owner on Jun 1, 2023. It is now read-only.

Enable Theme Kit Access passwords#2558

Merged
gonzaloriestra merged 4 commits intomainfrom
enable-theme-access-passwords
Aug 24, 2022
Merged

Enable Theme Kit Access passwords#2558
gonzaloriestra merged 4 commits intomainfrom
enable-theme-access-passwords

Conversation

@gonzaloriestra
Copy link
Contributor

@gonzaloriestra gonzaloriestra commented Aug 19, 2022

WHY are these changes introduced?

First step for https://github.com/Shopify/shopify-cli-planning/issues/332
Fixes https://github.com/Shopify/shopify-cli-planning/issues/365

WHAT is this pull request doing?

  • Enable Theme Kit Access passwords through env variable. When SHOPIFY_CLI_ADMIN_AUTH_TOKEN contains a Theme Kit Access password, the theme requests will go through Theme Kit Access API instead of Admin API, so the password is validated. As the login is not required, it also requires passing the store URL through SHOPIFY_SHOP.
  • Rename SHOPIFY_CLI_STORE to SHOPIFY_SHOP, which was already existing. It was added recently to be used from the CLI3. I'll update the CLI3 as well to use SHOPIFY_SHOP.

How to test your changes?

Check that theme commands work the same way when logged in (by using the Admin API):

  • bin/shopify login
  • DEBUG=1 bin/shopify theme list

Check that they also work with a Theme Kit Access password (by using Theme Access Kit API):

  • Install Theme Kit Access app and generate a new password
  • bin/shopify logout
  • DEBUG=1 SHOPIFY_SHOP=your-shop.myshopify.com SHOPIFY_CLI_ADMIN_AUTH_TOKEN=your-password bin/shopify theme list

Update checklist

  • I've added a CHANGELOG entry for this PR (if the change is public-facing)
  • I've considered possible cross-platform impacts (Mac, Linux, Windows).
  • I've left the version number as is (we'll handle incrementing this when releasing).
  • I've included any post-release steps in the section above (if needed).

@gonzaloriestra gonzaloriestra marked this pull request as ready for review August 19, 2022 08:07
@gonzaloriestra gonzaloriestra requested review from a team August 19, 2022 08:07
@karreiro karreiro self-requested a review August 19, 2022 08:20
@pepicrft
Copy link
Contributor

Rename SHOPIFY_CLI_STORE to SHOPIFY_SHOP, which was already existing. It was #2269 to be used from the CLI3. I'll update the CLI3 as well to use SHOPIFY_SHOP.

AFAIK Shopify would like to reserve "Shop" for the Shop product so I'd recommend sticking to the store convention.

Copy link
Contributor

@pepicrft pepicrft left a comment

Choose a reason for hiding this comment

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

Tophatted and works as expected 👏🏼

Copy link
Contributor Author

@gonzaloriestra gonzaloriestra left a comment

Choose a reason for hiding this comment

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

@pepicrft thanks for the review! Regarding your suggestion about SHOPIFY_SHOP, while I agree it's not the best name, it was already being used for the login (so dropping it would be a breaking change):

shop = (options.flags[:shop] || @ctx.getenv("SHOPIFY_SHOP" || nil))

So we had two variables for the same thing: SHOPIFY_SHOP and SHOPIFY_CLI_STORE. I decided to remove the latter because it's only used by the CLI3 and we can change it.

What do you think?

@pepicrft
Copy link
Contributor

So we had two variables for the same thing: SHOPIFY_SHOP and SHOPIFY_CLI_STORE. I decided to remove the latter because it's only used by the CLI3 and we can change it.
What do you think?

Since it's already being used and it's a breaking change I agree. In CLI 3.0 we can make sure we align with the new naming convention. Thanks for clarifying it 🙏🏼

Copy link
Contributor

@karreiro karreiro left a comment

Choose a reason for hiding this comment

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

Thank you, @gonzaloriestra! Great stuff! The code looks really elegant :)

The theme list command works fine, however, I've noticed the theme push gets freezed.

I wonder if the backend of the Theme Kit Access maybe doesn't support the /assets/bulk.json requests (that upload many assets in a single request).

@gonzaloriestra
Copy link
Contributor Author

gonzaloriestra commented Aug 22, 2022

@karreiro good catch! Sorry, I hadn't tested all the use cases carefully yet... All the theme commands should work properly now (except the hot reload with theme serve, that will be supported later).

I've finally disabled the bulk mode when pushing with a Theme Access password until I find out how to fix it (I've created an issue: https://github.com/Shopify/shopify-cli-planning/issues/367). But it seems to be some kind of limitation of the Theme Access API.

Copy link
Contributor

@karreiro karreiro left a comment

Choose a reason for hiding this comment

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

Thank you for the fix and for raising the issue, @gonzaloriestra! Awesome stuff 🚀 :)

@curiouscrusher
Copy link

If I'm reading this correctly, does this mean we can finally use Shopify CLI v2.x for proper theme deployment in a CI/CD environment?? 🙏 🙏

@gonzaloriestra
Copy link
Contributor Author

@curiouscrusher yes, it does! 🙂

@gonzaloriestra gonzaloriestra merged commit 9aad86c into main Aug 24, 2022
@gonzaloriestra gonzaloriestra deleted the enable-theme-access-passwords branch August 24, 2022 07:56
@curiouscrusher
Copy link

This is amazing, thank you very much @gonzaloriestra for adding this much needed functionality! 🎉 🚀

@gonzaloriestra gonzaloriestra restored the enable-theme-access-passwords branch August 29, 2022 07:11
@shopify-shipit shopify-shipit bot temporarily deployed to rubygems August 29, 2022 11:12 Inactive
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants