Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide solution for two-way sync #161

Open
jeffreyguenther opened this issue Jan 20, 2025 · 2 comments
Open

Provide solution for two-way sync #161

jeffreyguenther opened this issue Jan 20, 2025 · 2 comments
Assignees

Comments

@jeffreyguenther
Copy link
Contributor

jeffreyguenther commented Jan 20, 2025

Notes

Related to #142.

Important

This proposal is a work in progress and will be updated.

There are number of scenarios where treating the admin as the source of truth is not desired. The purpose of the CLI is to "do the right thing" ™️ and always treating the Shopify servers as the source of truth is not right. In practice, the workflow is more nuanced than that.

Developer create a new JSON template for a page locally and need to push it live.

Store your new template in the bucket.

shopkeeper bucket save --bucket <bucket name>

In your preview workflow run:

shopkeeper bucket restore --bucket <bucket name>
shopkeeper theme deploy

In your blue/green deploy workflow:

shopkeeper theme deploy --nodelete

App creates or modifies the theme.

I would pull down the files created by apps. To detect these files, I would probably do a hack with .gitignore. I would list all the files in assets after build in the .gitignore temporarily and use that to detect new files. I think something like this would be the lightest touch way of detecting files not from the repo originally. OR maybe the .shopifyignore.

Locales

@nboliver-ventureweb wrote:

I think the main challenge with the locale files is that we kind of need a way to handle them both ways:

Developer builds a new feature, adds strings to locale file(s), pushes to GitHub, creates a PR, merges PR, triggers deployment (changes are pushed from GitHub to theme).

Merchant / app / developer needs to make changes to locales file from Shopify admin, or perhaps needs different strings per store that share the same theme (maybe more of an edge use-case). Checkout text string changes are generated from Shopify admin, and pulling changes down from Shopify admin is needed for that.

Because of the single file uses, we need a clear merge strategy.

  1. Download locales from production
  2. Save in temporary bucket
  3. Restore locales from bucket (so you have locales in theme)
  4. Merge live locales "over" bucket locales.

Using https://github.com/TehShrike/deepmerge which is included in @shopify/cli-kit, we can do a UNION merge. We would include all keys from both files. Any key that is present in the local file that is also present in the remote file will be updated to the remote file's value.

This would preserve keys specific to the Shopify Admin. They would always be updated with the latest values. Developer added keys would be preserved. Pre-existing keys would preserved.

To delete keys in the locale file, special work would need to be done I think. Need to explore more.

In terms of letting repos opt into locale tracking in the bucket, I think this is straightforward. We'll only restore the locales that exist it the bucket, if they exist. And we'll require locales to be stored with their own command. It can be done.

@jeffreyguenther jeffreyguenther changed the title Provide solution better handle settings merges Provide solution for two-way settings sync Jan 27, 2025
@jeffreyguenther jeffreyguenther changed the title Provide solution for two-way settings sync Provide solution for two-way sync Jan 27, 2025
@jeffreyguenther jeffreyguenther self-assigned this Jan 27, 2025
@jeffreyguenther
Copy link
Contributor Author

@nboliver-ventureweb What do you think of my proposed approach for Locales?

@nboliver-ventureweb
Copy link

@nboliver-ventureweb What do you think of my proposed approach for Locales?

This approach sounds good to me. I think it addresses the need to modify locale files alongside liquid (ie. within a pull request workflow), while supporting customizations made by the merchant. In the event there is a desire to track a merchant's changes in git, the CLI shopify theme pull --only locales/ command could be used manually, or incorporated into a backup Action.

I like the opt-in approach for tracking in a bucket. Most stores may not need this, but in the event there are multiple stores running off the same theme, and something like unique checkout string customizations are required, this will be invaluable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

No branches or pull requests

2 participants