Skip to content

Refactor preview site updating to depend on CLI #1223

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

Merged
merged 35 commits into from
Apr 22, 2025

Conversation

fredrikekelund
Copy link
Contributor

Related issues

Proposed Changes

  • Refactor preview site updating functionality to depend on CLI.
  • Persist changes to appdata file when preview sites are renamed.

Testing Instructions

  1. Ensure that updating a preview site works as expected.
  2. Ensure that preview site renamings are persisted when reloading the app.

Pre-merge Checklist

  • Have you checked for TypeScript, React or other console errors?

@fredrikekelund fredrikekelund requested review from bcotrim and a team April 17, 2025 07:58
@fredrikekelund fredrikekelund self-assigned this Apr 17, 2025
@@ -14,7 +14,6 @@ import { PromptUsageProvider } from 'src/hooks/use-prompt-usage';
import { SiteDetailsProvider } from 'src/hooks/use-site-details';
import { SnapshotProvider } from 'src/hooks/use-snapshots';
import { ThemeDetailsProvider } from 'src/hooks/use-theme-details';
import { DemoSiteUpdateProvider } from 'src/hooks/use-update-demo-site';
Copy link
Contributor

Choose a reason for hiding this comment

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

😍

thunkAPI
) => {
const state = thunkAPI.getState() as RootState;
const snapshot = state.snapshot.snapshots.find(
Copy link
Contributor

@nightnei nightnei Apr 18, 2025

Choose a reason for hiding this comment

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

state.snapshot.snapshots.find(

NIT but I am thinking - maybe we should use a less generic slice name, instead of snapshot, maybe to add some postfix, to simplify reading code. WDYT?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

snapshot.snapshots could be somewhat confusing at first glance, but changing the store name to something like snapshotStore or snapshotSlice seems redundant to me, and for consistency's sake, it would also require us to change the other slice names (adding even more redundant naming). Given that, I would prefer to keep the name as-is.

Copy link
Contributor

@nightnei nightnei left a comment

Choose a reason for hiding this comment

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

LGTM and updating works es expected 👍

Copy link
Contributor

@bcotrim bcotrim left a comment

Choose a reason for hiding this comment

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

Tested as described
LGTM 👍

@@ -0,0 +1,79 @@
import crypto from 'crypto';
import { z } from 'zod';
import { CreateLoggerAction } from 'cli/commands/preview/logger-actions';
Copy link
Contributor

Choose a reason for hiding this comment

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

Now that we have the common folder let's try to move code there.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in #1230 👍

Base automatically changed from f26d/depend-on-cli-preview-site-creation to trunk April 22, 2025 10:12
@fredrikekelund fredrikekelund merged commit 69a43e0 into trunk Apr 22, 2025
7 of 8 checks passed
@fredrikekelund fredrikekelund deleted the f26d/depend-on-cli-preview-site-updating branch April 22, 2025 10:26
bgrgicak pushed a commit that referenced this pull request Apr 23, 2025
* [WIP] Refactor Studio to depend on CLI for preview site creation

* More changes

* Fix

* Use node's child_process module to fork CLI process

* Tests

* useGetSnapshotUsage

* Build CLI before starting dev version of app

* Tweaks

* Fixes

* preview ➡️ snapshot

* Improved progress bar

* Display notice when operation completes

* Update zod

* Remove useArchiveSite hook

* Fix test

* Modify exitCode in Logger::reportError

* Set exit code on error and fix outputFormat parsing

* Shorten

* Fix outputFormat parsing

* Clarify naming

* Refactor preview site updating to depend on CLI

* Clean up

* Tweak

* Tweaks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants