-
Notifications
You must be signed in to change notification settings - Fork 143
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
Fetch notifications in background #5020
Conversation
/snapit |
This comment was marked as outdated.
This comment was marked as outdated.
Coverage report
Show files with reduced coverage 🔻
Test suite run success1992 tests passing in 899 suites. Report generated by 🧪jest coverage report action from 2375a3f |
8e9a3be
to
7a1c90c
Compare
/snapit |
This comment was marked as outdated.
This comment was marked as outdated.
38b5420
to
98e144d
Compare
/snapit |
This comment was marked as outdated.
This comment was marked as outdated.
/snapit |
🫰✨ Thanks @gonzaloriestra! Your snapshot has been published to npm. Test the snapshot by intalling your package globally: pnpm i -g @shopify/cli@0.0.0-snapshot-20241216120051
|
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 declarationsWe found no new type declarations in this PR Existing type declarationspackages/cli-kit/dist/public/node/notifications-system.d.ts@@ -167,11 +167,25 @@ export type Notifications = zod.infer<typeof NotificationsSchema>;
*/
export declare function showNotificationsIfNeeded(currentSurfaces?: string[], environment?: NodeJS.ProcessEnv): Promise<void>;
/**
- * Get notifications list from cache (refreshed every hour) or fetch it if not present.
+ * Get notifications list from cache, that is updated in the background from bin/fetch-notifications.json.
*
* @returns A Notifications object.
*/
export declare function getNotifications(): Promise<Notifications>;
+/**
+ * Fetch notifications from the CDN and chache them.
+ *
+ * @returns A string with the notifications.
+ */
+export declare function fetchNotifications(): Promise<Notifications>;
+/**
+ * Fetch notifications in background as a detached process.
+ *
+ * @param currentCommand - The current Shopify command being run.
+ * @param argv - The arguments passed to the current process.
+ * @param environment - Process environment variables.
+ */
+export declare function fetchNotificationsInBackground(currentCommand: string, argv?: string[], environment?: NodeJS.ProcessEnv): void;
/**
* Filters notifications based on the version of the CLI.
*
packages/cli-kit/dist/public/node/system.d.ts@@ -13,6 +13,7 @@ export interface ExecOptions {
input?: string;
signal?: AbortSignal;
externalErrorHandler?: (error: unknown) => Promise<void>;
+ background?: boolean;
}
/**
* Opens a URL in the user's default browser.
|
WHY are these changes introduced?
We are fetching the notifications at the beginning of each command and caching the result for 1 hour. That approach has two disadvantages:
WHAT is this pull request doing?
demo.mp4
How to test your changes?
Install the snapshot from this branch:
npm i -g @shopify/cli@0.0.0-snapshot-20241216120051
shopify cache clear
shopify version
=> the notifications are downloaded when the command finishesshopify version
=> notification should be shownshopify version
=> no more notificationsThe cache in Mac is stored here:
~/Library/Preferences/shopify-cli-kit-nodejs/config.json
Measuring impact
How do we know this change was effective? Please choose one:
Checklist