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

[Themes] Feat: Poll for JSON changes when the themeEditorSync flag is passed to the dev command #3894

Merged
merged 1 commit into from
May 22, 2024

Conversation

jamesmengo
Copy link
Contributor

@jamesmengo jamesmengo commented May 13, 2024

WHY are these changes introduced?

WHAT is this pull request doing?

  • Fetches checksums from the remote theme
  • Performs reconciliations
  • Schedules another call the fetch checksums after 3 seconds

How to test your changes?

  1. pnpm shopify theme dev --path=<PATH_TO_THEME> --dev-preview --theme-editor-sync

Remote Changes -> should automatically propagate locally


deleting a file in your editor -> should delete locally
modifying a file in your editor -> should update local theme
creating a file in your editor -> should download locally

Local Changes (No-op)


delete/modify/create a file in your local theme -> do nothing (this will be handled by FS Watcher)

Remote + local Changes


delete/modify/create a file in your local theme that is also changed on remote -> Abort the entire process

Code.-.cli.packages_theme_src_cli_utilities_asset-file-syncer.ts.cli.Workspace.mp4

Measuring impact

How do we know this change was effective? Please choose one:

  • n/a - this doesn't need measurement, e.g. a linting rule or a bug-fix
  • Existing analytics will cater for this addition
  • PR includes analytics changes to measure impact

Checklist

  • I've considered possible cross-platform impacts (Mac, Linux, Windows)
  • I've considered possible documentation changes
  • I've made sure that any changes to dev or deploy have been reflected in the internal flowchart.

@jamesmengo jamesmengo changed the base branch from main to jmeng/theme_env_themeflag May 13, 2024 21:14
Copy link
Contributor

Thanks for your contribution!

Depending on what you are working on, you may want to request a review from a Shopify team:

  • Themes: @shopify/advanced-edits
  • UI extensions: @shopify/ui-extensions-cli
    • Checkout UI extensions: @shopify/checkout-ui-extensions-api-stewardship
  • Hydrogen: @shopify/hydrogen
  • Other: @shopify/app-management

Copy link
Contributor

github-actions bot commented May 13, 2024

Coverage report

St.
Category Percentage Covered / Total
🟡 Statements
71.96% (+0.02% 🔼)
7033/9774
🟡 Branches
68.79% (-0.12% 🔻)
3483/5063
🟡 Functions
71.44% (-0.01% 🔻)
1881/2633
🟡 Lines
73.27% (+0.03% 🔼)
6631/9050
Show files with reduced coverage 🔻
St.
File Statements Branches Functions Lines
🟢
... / app.test-data.ts
93.06% (-0.04% 🔻)
92.94% (-0.16% 🔻)
83.56%
92.55% (-0.05% 🔻)
🟢
... / identifiers.ts
100% (+4.08% 🔼)
88.24% (-0.34% 🔻)
100% 100%
🟢
... / extension-instance.ts
85.71% (-0.21% 🔻)
77.55% (-0.88% 🔻)
91.11%
87.1% (-0.2% 🔻)
🟢
... / id-matching.ts
98.77% (-0.18% 🔻)
75% (-9.62% 🔻)
100% 100%
🟢
... / extension.ts
91.21% (-0.1% 🔻)
74.51% (+0.92% 🔼)
91.67%
90.91% (-0.1% 🔻)

Test suite run success

1650 tests passing in 766 suites.

Report generated by 🧪jest coverage report action from 1a52026

@jamesmengo jamesmengo marked this pull request as ready for review May 13, 2024 22:21
Copy link
Contributor

We detected some changes at either packages/*/src or packages/cli-kit/assets/cli-ruby/** and there are no updates in the .changeset.
If the changes are user-facing, run "pnpm changeset add" to track your changes and include them in the next release CHANGELOG.

@jamesmengo jamesmengo self-assigned this May 13, 2024
@jamesmengo jamesmengo force-pushed the jmeng/theme_sync_poll_clean branch from e6599fd to 86bfbbd Compare May 13, 2024 22:55
Copy link
Contributor

Differences in type declarations

We detected differences in the type declarations generated by Typescript for this branch compared to the baseline ('main' branch). Please, review them to ensure they are backward-compatible. Here are some important things to keep in mind:

  • Some seemingly private modules might be re-exported through public modules.
  • If the branch is behind main you might see odd diffs, rebase main into this branch.

New type declarations

We found no new type declarations in this PR

Existing type declarations

packages/cli-kit/dist/public/common/version.d.ts
@@ -1 +1 @@
-export declare const CLI_KIT_VERSION = "3.60.0";
\ No newline at end of file
+export declare const CLI_KIT_VERSION = "3.59.0";
\ No newline at end of file
packages/cli-kit/dist/private/node/ui/components/TextPrompt.d.ts
@@ -11,7 +11,6 @@ export interface TextPromptProps {
     emptyDisplayedValue?: string;
     abortSignal?: AbortSignal;
     preview?: (value: string) => TokenItem<InlineToken>;
-    initialAnswer?: string;
 }
 declare const TextPrompt: FunctionComponent<TextPromptProps>;
 export { TextPrompt };
\ No newline at end of file

Base automatically changed from jmeng/theme_env_themeflag to main May 14, 2024 16:27
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 this PR, @jamesmengo! 🚀 Please, let me know what you think about them :)

packages/theme/src/cli/utilities/asset-file-syncer.ts Outdated Show resolved Hide resolved
packages/theme/src/cli/utilities/asset-file-syncer.ts Outdated Show resolved Hide resolved
@jamesmengo jamesmengo force-pushed the jmeng/theme_sync_poll_clean branch 2 times, most recently from edc69e5 to 95407dd Compare May 15, 2024 00:39
@karreiro karreiro added the #gsd:40767 Fortify local development experience for Liquid themes label May 15, 2024
@jamesmengo jamesmengo force-pushed the jmeng/theme_sync_poll_clean branch 4 times, most recently from f1ba15a to 77d53ed Compare May 15, 2024 23:57
}

await uploadTheme(theme, ctx.session, ctx.remoteChecksums, ctx.localThemeFileSystem, {})
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since we are handling theme upload here, I added a comment here to clarify that the remote-theme-watcher does not upload files

expect(initializeThemeEditorSync).toHaveBeenCalled()
expect(uploadTheme).not.toHaveBeenCalled()
expect(reconcileAndPollThemeEditorChanges).toHaveBeenCalled()
expect(uploadTheme).toHaveBeenCalled()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Handling upload in theme-environment now :)

@jamesmengo jamesmengo changed the title [Themes] Add Polling to the 2 Way Sync Module [Themes] Feat: Poll for JSON changes when the themeEditorSync flag is passed to the dev command May 15, 2024
@jamesmengo jamesmengo requested a review from karreiro May 16, 2024 00:01
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, @jamesmengo! Really expressive code! I've left some minor comments; please let me know what you think about them :)

@jamesmengo jamesmengo force-pushed the jmeng/theme_sync_poll_clean branch 4 times, most recently from e37611e to f57c353 Compare May 21, 2024 18:22
Initiate polling for theme editor changes

Update local theme file system after reconciling files

Modify theme polling reconciliation strategy

Fix: Exit process when local and remote values are both changed

Move Theme Upload to Theme-Environment instead of AssetFileSyncer

Refactor - file reconciliation strategy to accept callbacks

Add user-facing message when initiating asset synchronization and polling

Handle AbortError properly when multiple source changes are detected

Extract Theme Polling logic to separate file

Extract Theme Reconciliation logic to its own file

Render warning to users when there is a non-fatal error when polling remote changes

Throw all errors when polling remote changes instead of retrying on non-fatal errors

Refactor theme reconciliation to handle only JSON files

Refactor theme polling to handle only JSON files

Rename asset-file-syncer to remote-theme-watcher

Remove call to fetchChecksums by updating remote checksums locally

Move theme-environment.ts under the theme-environment folder

Convert to JSDOC

Revert "Remove call to fetchChecksums by updating remote checksums locally"

This reverts commit fc5a1fa.

Rename test describe block

Create new themeFileSystem object for theme polling

Render polling error to UI
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, @jamesmengo!

@jamesmengo jamesmengo added this pull request to the merge queue May 22, 2024
Merged via the queue into main with commit 63a174c May 22, 2024
32 checks passed
@jamesmengo jamesmengo deleted the jmeng/theme_sync_poll_clean branch May 22, 2024 16:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
#gsd:40767 Fortify local development experience for Liquid themes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants