-
Notifications
You must be signed in to change notification settings - Fork 129
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
Use graphQL to delete theme files #4799
base: main
Are you sure you want to change the base?
Conversation
Coverage report
Show new covered files 🐣
Show files with reduced coverage 🔻
Test suite run success1889 tests passing in 865 suites. Report generated by 🧪jest coverage report action from be5792f |
c8f17c5
to
b06f9d4
Compare
We detected some changes at packages/*/src and there are no updates in the .changeset. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no 🎩 yet but code part looks good, one small question about the progress bar
@@ -179,9 +179,13 @@ async function performFileReconciliation( | |||
) | |||
}) | |||
|
|||
const deleteRemoteFiles = remoteFilesToDelete.map((file) => deleteThemeAsset(targetTheme.id, file.key, session)) | |||
const deleteRemoteFiles = deleteThemeAssets( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be so much faster!
if (!success) { | ||
createSyncingCatchError(key, 'delete')(new Error(`Failed to delete ${key}`)) | ||
} | ||
progress.current++ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if there's any point to the progress tracking here now? By the time we're doing progress.current++
all of the remote calls have already been completed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, I wasn't sure about that either....
In the case where we have multiple batches, progress tracking could be useful....but the batching is being handled by the underlying function right now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I implemented batching in the uploader as well, so if we have multiple batches of files to delete we'll get progress.
I also hooked up the delete errors to the uploadResults
so that the CLI reports that the push finished with errors.
eb32a38
to
5ee226f
Compare
preserve error message. Fix up progress and presenting CLI errors on delete.
5ee226f
to
be5792f
Compare
Differences in type declarationsWe 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:
New type declarationspackages/cli-kit/dist/cli/api/graphql/admin/generated/theme_files_delete.d.tsimport * as Types from './types.js';
import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core';
export type ThemeFilesDeleteMutationVariables = Types.Exact<{
themeId: Types.Scalars['ID']['input'];
files: Types.Scalars['String']['input'][] | Types.Scalars['String']['input'];
}>;
export type ThemeFilesDeleteMutation = {
themeFilesDelete?: {
deletedThemeFiles?: {
filename: string;
}[] | null;
userErrors: {
filename?: string | null;
code?: Types.OnlineStoreThemeFilesUserErrorsCode | null;
message: string;
}[];
} | null;
};
export declare const ThemeFilesDelete: DocumentNode<ThemeFilesDeleteMutation, Types.Exact<{
themeId: Types.Scalars['ID']['input'];
files: Types.Scalars['String']['input'][] | Types.Scalars['String']['input'];
}>>;
Existing type declarationspackages/cli-kit/dist/public/node/themes/api.d.ts@@ -6,7 +6,7 @@ export declare function fetchTheme(id: number, session: AdminSession): Promise<T
export declare function fetchThemes(session: AdminSession): Promise<Theme[]>;
export declare function createTheme(params: ThemeParams, session: AdminSession): Promise<Theme | undefined>;
export declare function fetchThemeAssets(id: number, filenames: Key[], session: AdminSession): Promise<ThemeAsset[]>;
-export declare function deleteThemeAsset(id: number, key: Key, session: AdminSession): Promise<boolean>;
+export declare function deleteThemeAssets(id: number, filenames: Key[], session: AdminSession): Promise<Result[]>;
export declare function bulkUploadThemeAssets(id: number, assets: AssetParams[], session: AdminSession): Promise<Result[]>;
export declare function fetchChecksums(id: number, session: AdminSession): Promise<Checksum[]>;
export declare function themeUpdate(id: number, params: ThemeParams, session: AdminSession): Promise<Theme | undefined>;
|
WHY are these changes introduced?
Use graphQL to delete theme files. This gets us off REST, and also allows us to delete multiple files in one request, which should improve the developer experience.
Measuring impact
How do we know this change was effective? Please choose one:
Checklist