@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.
- package/dist/__tests__/dev.test.js +7 -47
- package/dist/__tests__/downloadTargetMint.test.js +6 -40
- package/dist/__tests__/silentUpdateClient.test.d.ts +1 -0
- package/dist/__tests__/silentUpdateClient.test.js +142 -0
- package/dist/constants.d.ts +2 -0
- package/dist/constants.js +2 -0
- package/dist/index.d.ts +3 -2
- package/dist/index.js +3 -2
- package/dist/local-preview/client.d.ts +9 -1
- package/dist/local-preview/client.js +41 -20
- package/dist/local-preview/index.js +11 -22
- package/dist/local-preview/run.d.ts +3 -1
- package/dist/local-preview/run.js +4 -1
- package/dist/local-preview/types.d.ts +6 -0
- package/dist/local-preview/types.js +1 -0
- package/dist/local-preview/update.d.ts +8 -0
- package/dist/local-preview/update.js +36 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
|
@@ -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
|
+
};
|