Default update-check and install functions for GitHub-hosted extensions
Source:R/default_update_functions.R
default_github_update.RdFactory functions that produce the two functions an extension must export
to opt in to ntrd's in-app update mechanism (ntrd_update_available() and
ntrd_update_extension()). Extensions hosted on GitHub can use these
directly; extensions hosted elsewhere (GitLab, CRAN, internal repos)
should provide their own implementations following the same contract.
Arguments
- repo
A GitHub repository specification of the form
"user/repo". May optionally include a ref ("user/repo@ref"); the ref is stripped for purposes of deriving the package name but preserved in the install call.- package
Optional package name. If
NULL(the default), it is derived fromrepoby taking the part after"/"and stripping any@refsuffix. Provide explicitly when the repository name differs from the R package name.
Value
For default_github_update_available(): a function taking no arguments
that returns an update_result S7 object.
For default_github_update_extension(): a function taking no arguments
that performs the install and returns invisibly.
Details
default_github_update_available() returns a function that fetches the
DESCRIPTION file from the GitHub repository's default branch, parses out
the Version: field, and compares it against the locally installed
version. The result is wrapped in an update_result object.
default_github_update_extension() returns a function that calls
remotes::install_github() with upgrade = "always" and
dependencies = TRUE, so dependencies (including ntrd itself) are also
brought up to date.
Both factories call force() on their arguments so that captured values
are safe to use even if the factory is ever called in a loop.