Unify the generation of gh package descriptions
All checks were successful
Build / audit (push) Successful in 9s
Build / test (push) Successful in 14m28s

This commit is contained in:
Eugen Wissner 2024-11-13 22:20:19 +01:00
parent bb0748b400
commit c7e300dc91
Signed by: belka
GPG Key ID: A27FDC1E8EE902C0

View File

@ -31,93 +31,47 @@ import System.Console.ANSI
, Color(..) , Color(..)
, ConsoleLayer(..) , ConsoleLayer(..)
) )
import Data.Maybe (fromJust) import Data.Maybe (fromJust, mapMaybe)
findUpdatable :: Text -> [PackageSettings] -> DownloaderSettings findUpdatable :: Text -> [PackageSettings] -> DownloaderSettings
findUpdatable packageName = getField @"downloader" . fromJust findUpdatable packageName = getField @"downloader" . fromJust
. find ((== packageName) . getField @"name" . getField @"downloader") . find ((== packageName) . getField @"name" . getField @"downloader")
autoUpdatable :: [PackageSettings] -> [PackageDescription] githubAutoUpdatables :: [PackageSettings] -> [PackageDescription]
autoUpdatable packageSettings = githubAutoUpdatables = mapMaybe go
[ PackageDescription where
go PackageSettings{ downloader = setting }
| Just githubSettings <- getField @"github" setting = Just
$ PackageDescription
{ latest = { latest =
let setting = findUpdatable "universal-ctags" packageSettings let ghArguments = uncurry PackageOwner githubSettings
ghArguments = uncurry PackageOwner $ fromJust $ getField @"github" setting
template = Package.DownloadTemplate $ getField @"template" setting template = Package.DownloadTemplate $ getField @"template" setting
in Package.Updater in Package.Updater
{ detectLatest = latestGitHub ghArguments (getField @"version" setting) { detectLatest = latestGitHub ghArguments (getField @"version" setting)
, getVersion = repackageWithTemplate (getField @"repackage" setting) template , getVersion = repackageWithTemplate (getField @"repackage" setting) template
, is64 = getField @"is64" setting , is64 = getField @"is64" setting
} }
, name = "universal-ctags" , name = getField @"name" setting
, downloaders = mempty , downloaders = mempty
} }
, PackageDescription | Just packagistSettings <- getField @"packagist" setting = Just
$ PackageDescription
{ latest = { latest =
let setting = findUpdatable "composer" packageSettings let packagistArguments = uncurry PackageOwner packagistSettings
packagistArguments = uncurry PackageOwner $ fromJust $ getField @"packagist" setting
template = Package.DownloadTemplate $ getField @"template" setting template = Package.DownloadTemplate $ getField @"template" setting
in Package.Updater in Package.Updater
{ detectLatest = latestPackagist packagistArguments { detectLatest = latestPackagist packagistArguments
, getVersion = repackageWithTemplate (getField @"repackage" setting) template , getVersion = repackageWithTemplate (getField @"repackage" setting) template
, is64 = getField @"is64" setting , is64 = getField @"is64" setting
} }
, name = "composer" , name = getField @"name" setting
, downloaders = mempty , downloaders = mempty
} }
, PackageDescription | otherwise = Nothing
{ latest =
let setting = findUpdatable "jitsi-meet-desktop" packageSettings autoUpdatable :: [PackageSettings] -> [PackageDescription]
ghArguments = uncurry PackageOwner $ fromJust $ getField @"github" setting autoUpdatable packageSettings = githubAutoUpdatables packageSettings ++
template = Package.DownloadTemplate $ getField @"template" setting [ PackageDescription
in Package.Updater
{ detectLatest = latestGitHub ghArguments (getField @"version" setting)
, getVersion = repackageWithTemplate (getField @"repackage" setting) template
, is64 = getField @"is64" setting
}
, name = "jitsi-meet-desktop"
, downloaders = mempty
}
, PackageDescription
{ latest =
let setting = findUpdatable "php82" packageSettings
ghArguments = uncurry PackageOwner $ fromJust $ getField @"github" setting
template = Package.DownloadTemplate $ getField @"template" setting
in Package.Updater
{ detectLatest = latestGitHub ghArguments (getField @"version" setting)
, getVersion = repackageWithTemplate (getField @"repackage" setting) template
, is64 = getField @"is64" setting
}
, name = "php82"
, downloaders = mempty
}
, PackageDescription
{ latest =
let setting = findUpdatable "kitty" packageSettings
ghArguments = uncurry PackageOwner $ fromJust $ getField @"github" setting
template = Package.DownloadTemplate $ getField @"template" setting
in Package.Updater
{ detectLatest = latestGitHub ghArguments (getField @"version" setting)
, getVersion = repackageWithTemplate (getField @"repackage" setting) template
, is64 = getField @"is64" setting
}
, name = "kitty"
, downloaders = mempty
}
, PackageDescription
{ latest =
let setting = findUpdatable "rdiff-backup" packageSettings
ghArguments = uncurry PackageOwner $ fromJust $ getField @"github" setting
template = Package.DownloadTemplate $ getField @"template" setting
in Package.Updater
{ detectLatest = latestGitHub ghArguments (getField @"version" setting)
, getVersion = repackageWithTemplate (getField @"repackage" setting) template
, is64 = getField @"is64" setting
}
, name = "rdiff-backup"
, downloaders = mempty
}
, PackageDescription
{ latest = { latest =
let setting = findUpdatable "webex" packageSettings let setting = findUpdatable "webex" packageSettings
textArguments = uncurry TextArguments $ fromJust $ getField @"text" setting textArguments = uncurry TextArguments $ fromJust $ getField @"text" setting
@ -130,19 +84,6 @@ autoUpdatable packageSettings =
, name = "webex" , name = "webex"
, downloaders = mempty , downloaders = mempty
} }
, PackageDescription
{ latest =
let setting = findUpdatable "librsync" packageSettings
ghArguments = uncurry PackageOwner $ fromJust $ getField @"github" setting
template = Package.DownloadTemplate $ getField @"template" setting
in Package.Updater
{ detectLatest = latestGitHub ghArguments (getField @"version" setting)
, getVersion = repackageWithTemplate (getField @"repackage" setting) template
, is64 = getField @"is64" setting
}
, name = "librsync"
, downloaders = mempty
}
, PackageDescription , PackageDescription
{ latest = { latest =
let setting = findUpdatable "dmd" packageSettings let setting = findUpdatable "dmd" packageSettings
@ -195,32 +136,6 @@ autoUpdatable packageSettings =
, ("DCD", latestDcd) , ("DCD", latestDcd)
] ]
} }
, PackageDescription
{ latest =
let setting = findUpdatable "simde" packageSettings
ghArguments = uncurry PackageOwner $ fromJust $ getField @"github" setting
template = Package.DownloadTemplate $ getField @"template" setting
in Package.Updater
{ detectLatest = latestGitHub ghArguments (getField @"version" setting)
, getVersion = repackageWithTemplate (getField @"repackage" setting) template
, is64 = getField @"is64" setting
}
, name = "simde"
, downloaders = mempty
}
, PackageDescription
{ latest =
let setting = findUpdatable "nginx" packageSettings
ghArguments = uncurry PackageOwner $ fromJust $ getField @"github" setting
template = Package.DownloadTemplate $ getField @"template" setting
in Package.Updater
{ detectLatest = latestGitHub ghArguments (getField @"version" setting)
, getVersion = repackageWithTemplate (getField @"repackage" setting) template
, is64 = getField @"is64" setting
}
, name = "nginx"
, downloaders = mempty
}
] ]
up2Date :: Maybe Text -> SlackBuilderT () up2Date :: Maybe Text -> SlackBuilderT ()