feat: added version check and banner. verbose version can be activated with global variabel on launch.

This commit is contained in:
Andreas Gammelgaard Damsbo 2026-03-23 14:06:49 +01:00
commit cfbee14dcb
No known key found for this signature in database
8 changed files with 495 additions and 0 deletions

72
man/check_app_version.Rd Normal file
View file

@ -0,0 +1,72 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/version_check.R
\name{check_app_version}
\alias{check_app_version}
\title{Run a startup version check and return a banner UI element}
\usage{
check_app_version(
github_user,
github_repo,
app_version = NULL,
verbose = FALSE
)
}
\arguments{
\item{github_user}{GitHub username or organisation that owns the repository.}
\item{github_repo}{Repository name. Also used as the package name for
\code{utils::packageVersion()}.}
\item{app_version}{Optional fallback version string for environments where
the package is not installed (e.g. shinyapps.io). Pass the result of your
\code{app_version()} function here. Ignored when \code{packageVersion()}
succeeds.}
\item{verbose}{Logical; if \code{TRUE} a banner is always returned.
Defaults to \code{FALSE}.}
}
\value{
A \code{shinyWidgets::alert()} UI element, or \code{NULL} when there
is nothing to show (up to date in non-verbose mode).
}
\description{
Call this \strong{outside} \code{server()} -- typically in
\code{global.R} or at the top of \code{app.R} -- and embed the returned
value directly in your UI definition. Because the check runs at startup
the banner is present on first render with no loading delay, and no
\code{uiOutput()} / \code{renderUI()} wiring is needed.
}
\details{
\strong{Normal mode} (\code{verbose = FALSE}): returns a banner only when
a newer version is available or when the check fails. Returns \code{NULL}
when the app is up to date (Shiny silently ignores \code{NULL} in the UI).
\strong{Verbose / debug mode} (\code{verbose = TRUE}): always returns a
banner -- including a success banner when up to date -- so you can confirm
the check ran and inspect both version strings during development.
}
\examples{
\dontrun{
# global.R or top of app.R
source("version_check.R")
version_banner <- check_app_version(
github_user = "my-org",
github_repo = "my-shiny-app",
app_version = app_version() # fallback for shinyapps.io
)
# ui.R
fluidPage(
version_banner,
# ... rest of UI
)
# Verbose mode for development
version_banner <- check_app_version(
github_user = "my-org",
github_repo = "my-shiny-app",
app_version = app_version(),
verbose = TRUE
)
}
}