nuxtseo-layer-devtools 5.0.1 → 5.0.2
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/composables/update-check.ts +17 -1
- package/package.json +2 -2
|
@@ -7,6 +7,22 @@ export interface ModuleUpdateInfo {
|
|
|
7
7
|
hasUpdate: boolean
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
+
function parseSemver(version: string): [number, number, number] {
|
|
11
|
+
// eslint-disable-next-line e18e/prefer-static-regex
|
|
12
|
+
const parts = version.replace(/^v/, '').split('.').map(Number)
|
|
13
|
+
return [parts[0] || 0, parts[1] || 0, parts[2] || 0]
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function isNewerVersion(latest: string, current: string): boolean {
|
|
17
|
+
const [lMajor, lMinor, lPatch] = parseSemver(latest)
|
|
18
|
+
const [cMajor, cMinor, cPatch] = parseSemver(current)
|
|
19
|
+
if (lMajor !== cMajor)
|
|
20
|
+
return lMajor > cMajor
|
|
21
|
+
if (lMinor !== cMinor)
|
|
22
|
+
return lMinor > cMinor
|
|
23
|
+
return lPatch > cPatch
|
|
24
|
+
}
|
|
25
|
+
|
|
10
26
|
const updateCache = ref<Record<string, ModuleUpdateInfo>>({})
|
|
11
27
|
|
|
12
28
|
export function useModuleUpdate(npmPackage: string | undefined, currentVersion: string | undefined): { hasUpdate: ComputedRef<boolean>, latestVersion: ComputedRef<string | undefined>, info: ComputedRef<ModuleUpdateInfo | undefined> } {
|
|
@@ -29,7 +45,7 @@ export function useModuleUpdate(npmPackage: string | undefined, currentVersion:
|
|
|
29
45
|
updateCache.value[npmPackage] = {
|
|
30
46
|
currentVersion,
|
|
31
47
|
latestVersion: latest,
|
|
32
|
-
hasUpdate: latest
|
|
48
|
+
hasUpdate: isNewerVersion(latest, currentVersion),
|
|
33
49
|
}
|
|
34
50
|
})
|
|
35
51
|
.catch(() => {})
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nuxtseo-layer-devtools",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "5.0.
|
|
4
|
+
"version": "5.0.2",
|
|
5
5
|
"description": "Shared Nuxt layer for Nuxt SEO devtools clients.",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "Harlan Wilton",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"ofetch": "^1.5.1",
|
|
48
48
|
"shiki": "^4.0.2",
|
|
49
49
|
"ufo": "^1.6.3",
|
|
50
|
-
"nuxtseo-shared": "5.0.
|
|
50
|
+
"nuxtseo-shared": "5.0.2"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
53
|
"nuxt": "^4.4.2",
|