-
Notifications
You must be signed in to change notification settings - Fork 143
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7a1c90c
commit 276b93c
Showing
4 changed files
with
27 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import fetch from 'node-fetch' | ||
import Conf from 'conf' | ||
|
||
async function fetchNotifications() { | ||
try { | ||
const url = process.env.SHOPIFY_CLI_NOTIFICATIONS_URL ?? 'https://cdn.shopify.com/static/cli/notifications.json' | ||
const response = await fetch(url, {signal: AbortSignal.timeout(3 * 1000)}) | ||
if (response.status === 200) { | ||
storeNotifications(url, await response.text()) | ||
console.log(`Notifications from ${url} cached successfully`) | ||
} | ||
} catch (error) { | ||
const errorMessage = `Error fetching notifications: ${error.message}` | ||
console.error(errorMessage) | ||
} | ||
} | ||
|
||
function storeNotifications(url, notifications) { | ||
const config = new Conf({projectName: 'shopify-cli-kit'}) | ||
const cache = config.get('cache') || {} | ||
cache[`notifications-${url}`] = {value: notifications, timestamp: Date.now()} | ||
config.set('cache', cache) | ||
} | ||
|
||
await fetchNotifications() |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters