diff --git a/NAMESPACE b/NAMESPACE index 564ab81..316a9c7 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -1,5 +1,6 @@ export(accountInfo) export(accounts) +export(appDependencies) export(applications) export(deployApp) export(removeAccount) diff --git a/R/dependencies.R b/R/dependencies.R index e39b602..dd7b20c 100644 --- a/R/dependencies.R +++ b/R/dependencies.R @@ -1,7 +1,38 @@ -# detect all package dependencies for an application (recursively discovers -# dependencies for all .R files in the app directory) -appDependencies <- function(appDir) { + +#' Detect Application Dependencies +#' +#' Recursively detect all package dependencies for an application. This function +#' parses all .R files in the applicaition directory to determine what packages +#' the application depends on; and for each of those packages what other +#' packages they depend on. +#' @param appDir Directory containing application. Defaults to current working +#' directory. +#' @return Chracter vector with a list of recursive package dependencies for the +#' application. +#' @details +#' Dependencies are determined by parsing application source code and looking +#' for calls to \code{library}, \code{require}, \code{::}, and \code{:::}. +#' +#' If your application has a package dependency that is not detected you can +#' ensure that it is detected by inserting a call to \code{library} or +#' \code{require} with the appropriate package(s). +#' +#' Recursive dependencies are detected by examining the \code{Depends}, +#' \code{Imports}, \code{LinkingTo}, and \code{Suggests} fields of the +#' packages immediately dependend on by the application. +#' @examples +#' \dontrun{ +#' +#' # dependencies for the app in the current working dir +#' appDependencies() +#' +#' # dependencies for an app in another directory +#' appDependencies("~/projects/shiny/app1") +#' } +#' @seealso \link[shinyapps:shinyappsPackages]{Using Packages with ShinyApps} +#' @export +appDependencies <- function(appDir = getwd()) { # first get the packages referred to in source code pkgs <- character() diff --git a/R/deployApp.R b/R/deployApp.R index e54801a..4df720e 100644 --- a/R/deployApp.R +++ b/R/deployApp.R @@ -13,7 +13,7 @@ #' #' For details on options that affect the behavior of \code{deployApp} see the #' article on \link[shinyapps:shinyappsOptions]{package options}. -#' @param appDir Directory containing application source code. Defaults to +#' @param appDir Directory containing application. Defaults to #' current working directory. #' @param appName Name of application (names must be unique with ShinyApps #' accounts). Defaults to the base name of the specified \code{appDir}. diff --git a/man/appDependencies.Rd b/man/appDependencies.Rd new file mode 100644 index 0000000..10c37e1 --- /dev/null +++ b/man/appDependencies.Rd @@ -0,0 +1,51 @@ +\name{appDependencies} +\alias{appDependencies} +\title{Detect Application Dependencies} +\usage{ + appDependencies(appDir = getwd()) +} +\arguments{ + \item{appDir}{Directory containing application. Defaults + to current working directory.} +} +\value{ + Chracter vector with a list of recursive package + dependencies for the application. +} +\description{ + Recursively detect all package dependencies for an + application. This function parses all .R files in the + applicaition directory to determine what packages the + application depends on; and for each of those packages + what other packages they depend on. +} +\details{ + Dependencies are determined by parsing application source + code and looking for calls to \code{library}, + \code{require}, \code{::}, and \code{:::}. + + If your application has a package dependency that is not + detected you can ensure that it is detected by inserting + a call to \code{library} or \code{require} with the + appropriate package(s). + + Recursive dependencies are detected by examining the + \code{Depends}, \code{Imports}, \code{LinkingTo}, and + \code{Suggests} fields of the packages immediately + dependend on by the application. +} +\examples{ +\dontrun{ + +# dependencies for the app in the current working dir +appDependencies() + +# dependencies for an app in another directory +appDependencies("~/projects/shiny/app1") +} +} +\seealso{ + \link[shinyapps:shinyappsPackages]{Using Packages with + ShinyApps} +} + diff --git a/man/deployApp.Rd b/man/deployApp.Rd index 44af865..340f212 100644 --- a/man/deployApp.Rd +++ b/man/deployApp.Rd @@ -8,8 +8,8 @@ quiet = FALSE) } \arguments{ - \item{appDir}{Directory containing application source - code. Defaults to current working directory.} + \item{appDir}{Directory containing application. Defaults + to current working directory.} \item{appName}{Name of application (names must be unique with ShinyApps accounts). Defaults to the base name of diff --git a/man/packages.Rd b/man/packages.Rd index 58859c6..f3bbd07 100644 --- a/man/packages.Rd +++ b/man/packages.Rd @@ -4,17 +4,30 @@ \title{Using Packages with ShinyApps} \description{ -description +Applications deployed to ShinyApps can depend on any package available on \href{http://cran.rstudio.com/}{CRAN} as well as any package hosted in a public \href{https://www.github.com}{GitHub} repository. + +When an application is \link[shinyapps:deployApp]{deployed} it's source code is scanned for dependencies using the \code{\link{appDependencies}} function. The list of dependencies is sent to the ShinyApps service along with the application source code and these dependencies are then installed alongside the application. } -\details{ -details +\section{CRAN Packages}{ +When sastisfying CRAN package dependencies, the ShinyApps service will build the exact versions of packages that were installed on the system from which the application is deployed. + +If a locally installed package was not obtained from CRAN (e.g. was installed from R-Forge) and as a result doesn't have a version that matches a version previously published to CRAN then an error will occur. It's therefore important that you run against packages installed directly from CRAN in your local configuration. } -\examples{ -\dontrun{ +\section{GitHub Packages}{ +It's also possible to depend on packages hosted in public GitHub repositories, so long as they are installed via the \link[devtools:install_github]{install_github} function from the \pkg{devtools} package. + +This works because \code{install_github} records the exact Github commit that was installed locally, making it possible to download and install the same source code on the ShinyApps service. -library(plyr) +Note that in order for this to work correctly you need to install the very latest version of \code{devtools} from Github. You can do this as follows: + +\preformatted{ +library(devtools) +install_github("devtools", "hadley") } } +\seealso{ +\code{\link{appDependencies}} +}