Unify the generation of gh package descriptions
This commit is contained in:
parent
bb0748b400
commit
c7e300dc91
153
src/Main.hs
153
src/Main.hs
@ -31,93 +31,47 @@ import System.Console.ANSI
|
||||
, Color(..)
|
||||
, ConsoleLayer(..)
|
||||
)
|
||||
import Data.Maybe (fromJust)
|
||||
import Data.Maybe (fromJust, mapMaybe)
|
||||
|
||||
findUpdatable :: Text -> [PackageSettings] -> DownloaderSettings
|
||||
findUpdatable packageName = getField @"downloader" . fromJust
|
||||
. find ((== packageName) . getField @"name" . getField @"downloader")
|
||||
|
||||
githubAutoUpdatables :: [PackageSettings] -> [PackageDescription]
|
||||
githubAutoUpdatables = mapMaybe go
|
||||
where
|
||||
go PackageSettings{ downloader = setting }
|
||||
| Just githubSettings <- getField @"github" setting = Just
|
||||
$ PackageDescription
|
||||
{ latest =
|
||||
let ghArguments = uncurry PackageOwner githubSettings
|
||||
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 = getField @"name" setting
|
||||
, downloaders = mempty
|
||||
}
|
||||
| Just packagistSettings <- getField @"packagist" setting = Just
|
||||
$ PackageDescription
|
||||
{ latest =
|
||||
let packagistArguments = uncurry PackageOwner packagistSettings
|
||||
template = Package.DownloadTemplate $ getField @"template" setting
|
||||
in Package.Updater
|
||||
{ detectLatest = latestPackagist packagistArguments
|
||||
, getVersion = repackageWithTemplate (getField @"repackage" setting) template
|
||||
, is64 = getField @"is64" setting
|
||||
}
|
||||
, name = getField @"name" setting
|
||||
, downloaders = mempty
|
||||
}
|
||||
| otherwise = Nothing
|
||||
|
||||
autoUpdatable :: [PackageSettings] -> [PackageDescription]
|
||||
autoUpdatable packageSettings =
|
||||
autoUpdatable packageSettings = githubAutoUpdatables packageSettings ++
|
||||
[ PackageDescription
|
||||
{ latest =
|
||||
let setting = findUpdatable "universal-ctags" 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 = "universal-ctags"
|
||||
, downloaders = mempty
|
||||
}
|
||||
, PackageDescription
|
||||
{ latest =
|
||||
let setting = findUpdatable "composer" packageSettings
|
||||
packagistArguments = uncurry PackageOwner $ fromJust $ getField @"packagist" setting
|
||||
template = Package.DownloadTemplate $ getField @"template" setting
|
||||
in Package.Updater
|
||||
{ detectLatest = latestPackagist packagistArguments
|
||||
, getVersion = repackageWithTemplate (getField @"repackage" setting) template
|
||||
, is64 = getField @"is64" setting
|
||||
}
|
||||
, name = "composer"
|
||||
, downloaders = mempty
|
||||
}
|
||||
, PackageDescription
|
||||
{ latest =
|
||||
let setting = findUpdatable "jitsi-meet-desktop" 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 = "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 =
|
||||
let setting = findUpdatable "webex" packageSettings
|
||||
textArguments = uncurry TextArguments $ fromJust $ getField @"text" setting
|
||||
@ -130,19 +84,6 @@ autoUpdatable packageSettings =
|
||||
, name = "webex"
|
||||
, 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
|
||||
{ latest =
|
||||
let setting = findUpdatable "dmd" packageSettings
|
||||
@ -195,32 +136,6 @@ autoUpdatable packageSettings =
|
||||
, ("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 ()
|
||||
|
Loading…
Reference in New Issue
Block a user