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(..)
|
, 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")
|
||||||
|
|
||||||
|
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] -> [PackageDescription]
|
||||||
autoUpdatable packageSettings =
|
autoUpdatable packageSettings = githubAutoUpdatables packageSettings ++
|
||||||
[ PackageDescription
|
[ 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 =
|
{ 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 ()
|
||||||
|
Loading…
Reference in New Issue
Block a user