@mintlify/previewing 4.0.630 → 4.0.631

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,36 @@
1
+ import { getLatestClientVersion, tryDownloadTargetMint, getCompatibleClientVersion } from "./client.js";
2
+ import { LOCAL_LINKED_CLI_VERSION } from "../constants.js";
3
+ export const silentUpdateClient = async ({ versionString, clientVersion, cliVersion }) => {
4
+ const latestClientVersion = await getLatestClientVersion();
5
+ const hasLatestClientVersion = latestClientVersion && versionString && versionString.trim() === latestClientVersion.trim();
6
+ if (clientVersion) {
7
+ // always download specific client version if provided
8
+ const error = await tryDownloadTargetMint({ targetVersion: clientVersion, existingVersion: versionString });
9
+ return { needsUpdate: false, error };
10
+ }
11
+ else if ((!versionString || cliVersion === LOCAL_LINKED_CLI_VERSION) && latestClientVersion) {
12
+ // if no version exists, download latest
13
+ const error = await tryDownloadTargetMint({ targetVersion: latestClientVersion, existingVersion: null });
14
+ return { needsUpdate: false, error };
15
+ }
16
+ else if (cliVersion && !hasLatestClientVersion) {
17
+ // if not on latest, check whether to download latest or max
18
+ const maxClientVersion = await getCompatibleClientVersion({ cliVersion });
19
+ const hasMaxClientVersion = maxClientVersion && versionString && versionString.trim() === maxClientVersion.trim();
20
+ if (maxClientVersion === "latest" && latestClientVersion) {
21
+ // if latest, download latest
22
+ const error = await tryDownloadTargetMint({ targetVersion: latestClientVersion, existingVersion: versionString });
23
+ return { needsUpdate: false, error };
24
+ }
25
+ else if (maxClientVersion && !hasMaxClientVersion) {
26
+ // if maxxed out, needs update
27
+ const error = await tryDownloadTargetMint({ targetVersion: maxClientVersion, existingVersion: versionString });
28
+ return { needsUpdate: true, error };
29
+ }
30
+ else {
31
+ // if compatible client version not found, needs update
32
+ return { needsUpdate: true, error: undefined };
33
+ }
34
+ }
35
+ return { needsUpdate: false, error: undefined };
36
+ };