mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-26 02:11:53 +00:00
fix version sorting and icon display for marketplace
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@start9labs/marketplace",
|
||||
"version": "0.3.27",
|
||||
"version": "0.3.28",
|
||||
"peerDependencies": {
|
||||
"@angular/common": ">=13.2.0",
|
||||
"@angular/core": ">=13.2.0",
|
||||
|
||||
@@ -39,7 +39,21 @@ export class ReleaseNotesComponent {
|
||||
}
|
||||
|
||||
asIsOrder(a: KeyValue<string, string>, b: KeyValue<string, string>) {
|
||||
return a.key > b.key ? -1 : b.key > a.key ? 1 : 0
|
||||
const a1 = a.key.split('.')
|
||||
const b1 = b.key.split('.')
|
||||
// contingency in case there's a 4th or 5th version
|
||||
const len = Math.min(a1.length, b1.length)
|
||||
// look through each version number and compare.
|
||||
for (let i = 0; i < len; i++) {
|
||||
const a2 = +a1[i] || 0
|
||||
const b2 = +b1[i] || 0
|
||||
|
||||
if (a2 !== b2) {
|
||||
// sort descending
|
||||
return a2 > b2 ? -1 : 1
|
||||
}
|
||||
}
|
||||
return a1.length - b1.length
|
||||
}
|
||||
|
||||
async showReleaseNotes(content: PolymorpheusContent<TuiDialogContext>) {
|
||||
|
||||
@@ -125,13 +125,15 @@ export class MarketplaceDepItemComponent {
|
||||
|
||||
getImage(key: string, marketplace: StoreIdentity | null) {
|
||||
const icon = this.pkg.dependencyMetadata[key]?.icon
|
||||
const camelToSnakeCase = (str: string) =>
|
||||
str.replace(/[A-Z]/g, letter => `-${letter.toLowerCase()}`)
|
||||
|
||||
if (icon) {
|
||||
try {
|
||||
const iconUrl = new URL(icon)
|
||||
return iconUrl.href
|
||||
} catch (e) {
|
||||
return `${marketplace?.url}package/v0/icon/${key}`
|
||||
return `${marketplace?.url}package/v0/icon/${camelToSnakeCase(key)}`
|
||||
}
|
||||
} else {
|
||||
return key.substring(0, 2)
|
||||
|
||||
Reference in New Issue
Block a user