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

Fix --nodelete behaviour on dev command #4662

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

EvilGenius13
Copy link
Contributor

@EvilGenius13 EvilGenius13 commented Oct 16, 2024

WHY are these changes introduced?

Fixes: https://github.com/Shopify/develop-advanced-edits/issues/370
While fixing up some of the documentation relating to using the --nodelete flag, I noticed that files were still being deleted remotely when using theme dev --nodelete.

WHAT is this pull request doing?

The mountThemeFileSystem was not receiving the --nodelete flag if it was being used. I added it to the ThemeFileSystemOptions type and now we check if it present in the handleFileDelete method. If it is, we return early.

How to test your changes?

Run the current build and use the command theme dev --nodelete
Make a file.
Delete the file.
You should see it be deleted remotely.


Pull down this branch
Build this branch
Run theme dev --nodelete
Make a file
Delete the file
You will see it keeps the remote file.

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

Copy link
Contributor

github-actions bot commented Oct 18, 2024

Coverage report

St.
Category Percentage Covered / Total
🟡 Statements 72.52% 8393/11574
🟡 Branches 69.03% 4115/5961
🟡 Functions 71.96% 2194/3049
🟡 Lines 72.79% 7937/10904
Show files with reduced coverage 🔻
St.
File Statements Branches Functions Lines
🟢
... / ConcurrentOutput.tsx
98.39% (-1.61% 🔻)
90.91% (-4.55% 🔻)
100%
98.33% (-1.67% 🔻)

Test suite run success

1917 tests passing in 871 suites.

Report generated by 🧪jest coverage report action from e97fb51

@EvilGenius13 EvilGenius13 changed the title [WIP] Change --nodelete behaviour on dev command Fix --nodelete behaviour on dev command Oct 18, 2024
@EvilGenius13 EvilGenius13 marked this pull request as ready for review October 18, 2024 15:39
@EvilGenius13 EvilGenius13 requested review from a team as code owners October 18, 2024 15:39

This comment has been minimized.

This fixes an issue where the --nodelete flag was not being respected when
running the dev command. This was due to the fact that the flag was not
being passed to the theme-fs utility function.
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/node/themes/types.d.ts
@@ -28,6 +28,7 @@ export interface ThemeFileSystemOptions {
         only?: string[];
     };
     notify?: string;
+    noDelete?: boolean;
 }
 /**
  * Represents a theme on the file system.

@@ -178,7 +178,7 @@ export function mountThemeFileSystem(root: string, options?: ThemeFileSystemOpti
}

const handleFileDelete = (themeId: string, adminSession: AdminSession, fileKey: string) => {
if (isFileIgnored(fileKey)) return
if (isFileIgnored(fileKey) || options?.noDelete) return
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe we can add a test case for this?

Copy link
Contributor

@jamesmengo jamesmengo left a comment

Choose a reason for hiding this comment

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

🎩 LGTM! We could probably use a test to solidify this in the contract, imo, but I'll leave that up to you and Guilherme

@@ -178,7 +178,7 @@ export function mountThemeFileSystem(root: string, options?: ThemeFileSystemOpti
}

const handleFileDelete = (themeId: string, adminSession: AdminSession, fileKey: string) => {
if (isFileIgnored(fileKey)) return
if (isFileIgnored(fileKey) || options?.noDelete) return
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we add a test for this? Maybe for the ignore as well ❤️

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