From b776fc7019f959847f201bf27c494ed7ca5e027f Mon Sep 17 00:00:00 2001 From: Craig Williams Date: Thu, 28 Sep 2023 09:44:06 +0100 Subject: [PATCH] Latest build --- .gitignore | 3 + DESCRIPTION | 4 +- NAMESPACE | 13 +++++ R/activate.R | 15 +++++ R/add_package.R | 67 +++++++++++++++++++++++ R/compile_imports.R | 33 ++++++++++- R/fetch_available_archives.R | 2 +- R/fetch_available_packages.R | 2 +- R/init.R | 8 +++ R/install_package_source.R | 9 +-- R/isolate.R | 7 +++ R/list_depends.R | 28 ++++++++-- R/list_imports.R | 3 +- R/request_package_source.R | 1 + R/restore.R | 100 ++++++++++++++++++++++++++++++++++ R/snapshot.R | 9 ++- R/snapshot_create.R | 6 +- R/snapshot_history.R | 1 + R/snapshot_latest.R | 1 + R/utils.R | 5 +- man/activate.Rd | 17 ++++++ man/add_package.Rd | 21 +++++++ man/compile_imports.Rd | 28 ++++++++++ man/empty_sources.Rd | 14 +++++ man/format_str.Rd | 23 ++++++++ man/install_package_source.Rd | 23 ++++++++ man/isolate.Rd | 11 ++++ man/restore.Rd | 25 +++++++++ man/snapshot.Rd | 18 ++++++ man/snapshot_create.Rd | 18 ++++++ man/snapshot_history.Rd | 14 +++++ man/snapshot_latest.Rd | 14 +++++ man/stop_quietly.Rd | 14 +++++ 33 files changed, 527 insertions(+), 30 deletions(-) create mode 100644 R/activate.R create mode 100644 R/add_package.R create mode 100644 R/init.R create mode 100644 R/isolate.R create mode 100644 R/restore.R create mode 100644 man/activate.Rd create mode 100644 man/add_package.Rd create mode 100644 man/compile_imports.Rd create mode 100644 man/empty_sources.Rd create mode 100644 man/format_str.Rd create mode 100644 man/install_package_source.Rd create mode 100644 man/isolate.Rd create mode 100644 man/restore.Rd create mode 100644 man/snapshot.Rd create mode 100644 man/snapshot_create.Rd create mode 100644 man/snapshot_history.Rd create mode 100644 man/snapshot_latest.Rd create mode 100644 man/stop_quietly.Rd diff --git a/.gitignore b/.gitignore index d061803..5f80bfb 100644 --- a/.gitignore +++ b/.gitignore @@ -48,3 +48,6 @@ po/*~ .Rproj.user .Rdata .DS_Store + +# pacman - package management folder +.pacman/ diff --git a/DESCRIPTION b/DESCRIPTION index 0157d12..8126cb2 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,11 +1,11 @@ Package: Rpacman Type: Package Title: Very simple package manager for R -Version: 1.0.0 +Version: 1.0.3 Date: 2022-05-31 Authors@R: person("Craig", "Williams", email = "craig@avsdev.uk", role = c("aut", "cre")) URL: https://avsdev.uk/R/Rpacman Description: Very simple package manager for R which allows scanning for used packages, finding their dependencies and versions, creating a lock file and installing the packages on a new build. License: GPL (>= 3) -Depends: R (>= 3.1.0), dplyr, magrittr, renv +Depends: R (>= 3.1.0), renv, jsonlite, remotes RoxygenNote: 7.1.1 diff --git a/NAMESPACE b/NAMESPACE index a8344ce..1aa7d45 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -1,6 +1,19 @@ # Generated by roxygen2: do not edit by hand +export(activate) +export(compile_imports) export(fetch_available_archives) export(fetch_available_packages) +export(install_package_source) +export(isolate) export(list_depends) export(list_imports) +export(restore) +export(snapshot) +export(snapshot_create) +export(snapshot_history) +export(snapshot_latest) +import(jsonlite) +import(parallel) +import(remotes) +import(renv) diff --git a/R/activate.R b/R/activate.R new file mode 100644 index 0000000..db5ca68 --- /dev/null +++ b/R/activate.R @@ -0,0 +1,15 @@ + +#' Adds the pacman library path to the .libPaths variable, either as an extra +#' library or as the only library +#' +#' @param totalIsolation boolean Only refer to the pacman library, do not use +#' any user library paths +#' +#' @export +activate <- function(totalIsolation = FALSE) { + if (totalIsolation) { + environment(.libPaths)$.lib.loc <- c(file.path(getwd(), ".pacman/library"), .Library) + } else { + .libPaths(c(file.path(getwd(), ".pacman/library"), .libPaths())) + } +} \ No newline at end of file diff --git a/R/add_package.R b/R/add_package.R new file mode 100644 index 0000000..bee15d1 --- /dev/null +++ b/R/add_package.R @@ -0,0 +1,67 @@ + + +#' Add a package to the project. +#' +#' @param packageName boolean Only refer to the pacman library, do not use +#' any user library paths +#' @param installOpts boolean Only refer to the pacman library, do not use +#' any user library paths +#' +add_package <- function(packageName = NULL, installOpts = list(Ncpus = parallel::detectCores())) { + if (is.null(packageName)) { + repeat { + packageName <- trimws(readline("Please specify the name of the package you wish to add: ")) + if (nchar(packageName) > 0) { + break + } + } + } + + cranPackages <- fetch_available_packages() + archivePackages <- fetch_available_archives() + + if (packageName %in% cranPackages$package) { + repeat({ + installCRAN <- trimws(readline("Found package in CRAN, proceed with install? [Yn]: ")) + if (nchar(installCRAN) == 0) { + installCRAN <- "Y" + } + if (nchar(installCRAN) == 1 && installCRAN %in% c("Y", "y", "N", "n")) { + break + } + }) + if (installCRAN %in% c("Y", "y")) { + do.call(utils::install.packages, c(package, installOpts)) + return(TRUE) + } + } else { + cat("Package not found on CRAN.\n") + } + + repeat({ + installCustom <- trimws(readline("Would you like to provide a source? [Yn]: ")) + if (nchar(installCustom) == 0) { + installCustom <- "Y" + } + if (nchar(installCustom) == 1 && installCustom %in% c("Y", "y", "N", "n")) { + break + } + }) + + if (installCustom %in% c("N", "n")) { + cat("Package installation cancelled.\n") + return(FALSE) + } + + source <- request_package_source(package) + + if (is.null(source)) { + cat("Package installation cancelled.\n") + return(FALSE) + } + + package <- install_package_source(c(package = packageName, source), installOpts) + + return(TRUE) +} + diff --git a/R/compile_imports.R b/R/compile_imports.R index 71f6e85..b20379b 100644 --- a/R/compile_imports.R +++ b/R/compile_imports.R @@ -5,6 +5,7 @@ # Requires fetch_available_packages.R # Requires fetch_available_archives.R +#' @import parallel .solve_missing_imports <- function(missingImports, installOpts = list(Ncpus = parallel::detectCores())) { importsFormat <- data.frame(list( package_name = unlist(lapply(missingImports$package, format_str, width = 35)), @@ -37,7 +38,7 @@ if ("Update to latest CRAN version" %in% actions) { newPackages <- which("Update to latest CRAN version" == actions) newPackages <- unique(missingImports[newPackages,"package"]) - do.call(install.packages, c(list(newPackages), installOpts)) + do.call(utils::install.packages, c(list(newPackages), installOpts)) cat("\n") cat("One or more new packages were installed. Please re-run the command.\n") stop_quietly() @@ -67,6 +68,25 @@ do.call(rbind, fixedImports) } +.install_order <- function(dependsTree) { + dependsPackages <- lapply(unique(dependsTree$package), function(p) { + package <- dependsTree[dependsTree$package == p,] + package <- package[package$generation == max(package$generation),] + package <- package[1,c("package", "version", "generation")] + return(package) + }) + dependsPackages <- do.call(rbind, dependsPackages) + + dependsOrder <- sort(dependsPackages$generation, index.return = T, decreasing = T)$ix + dependsOrder <- dependsPackages[dependsOrder,] + + installOrder <- lapply(unique(dependsOrder$generation), function(g) { + return(dependsOrder[dependsOrder$generation == g,"package"]) + }) + + return(installOrder) +} + #' Compile a structure containing the current state of the imports for the #' project. #' @@ -86,7 +106,12 @@ compile_imports <- function(custom_sources = empty_sources(), installOpts = list ) imports <- list_imports() - depends <- list_depends(unique(imports$package)) + dependsTree <- list_depends(unique(imports$package), TRUE) + + depends <- dependsTree[,c("package", "version")] + depends <- unique(depends) + depends <- depends[sort(depends$package, index.return = TRUE)$ix,] + row.names(depends) <- 1:nrow(depends) cranPackages <- fetch_available_packages() archivePackages <- fetch_available_archives() @@ -152,11 +177,13 @@ compile_imports <- function(custom_sources = empty_sources(), installOpts = list coreDeps <- dependsSources[dependsSources$in_core,] directDeps <- dependsSources[dependsSources$is_direct & !dependsSources$in_core & !missingImports,] indirectDeps <- dependsSources[!dependsSources$is_direct & !dependsSources$in_core & !missingImports,] + installOrder <- .install_order(dependsTree[!(dependsTree$package %in% coreDeps$package),]) return(list( core_depends = coreDeps[,c("package", "version")], direct_depends = directDeps[,c("package", "version")], indirect_depends = indirectDeps[,c("package", "version")], - custom_sources = customImports + custom_sources = customImports, + install_order = installOrder )) } \ No newline at end of file diff --git a/R/fetch_available_archives.R b/R/fetch_available_archives.R index 181b2d5..001e820 100644 --- a/R/fetch_available_archives.R +++ b/R/fetch_available_archives.R @@ -31,7 +31,7 @@ } } if (!file.exists(dist_fn)) { - download.file(sprintf("%s/src/contrib/Meta/archive.rds", get_cran_repo()), dist_fn) + utils::download.file(sprintf("%s/src/contrib/Meta/archive.rds", get_cran_repo()), dist_fn) .process_dist_archive(dist_fn, fn) } con <- gzfile(fn, "rb") diff --git a/R/fetch_available_packages.R b/R/fetch_available_packages.R index 71d0624..7579d41 100644 --- a/R/fetch_available_packages.R +++ b/R/fetch_available_packages.R @@ -10,7 +10,7 @@ } } if (!file.exists(fn)) { - download.file(sprintf("%s/src/contrib/PACKAGES.rds", get_cran_repo()), fn) + utils::download.file(sprintf("%s/src/contrib/PACKAGES.rds", get_cran_repo()), fn) } con <- gzfile(fn, "rb") on.exit(close(con), add = TRUE) diff --git a/R/init.R b/R/init.R new file mode 100644 index 0000000..0d5b027 --- /dev/null +++ b/R/init.R @@ -0,0 +1,8 @@ + +# init <- function(reInit = FALSE) { +# if (file.exists("pacman.lock") && !reInit) { +# return() +# } +# snapshot <- .makeSnapshot() +# jsonlite::write_json(snapshot, path = "pacman.lock", pretty = TRUE) +# } \ No newline at end of file diff --git a/R/install_package_source.R b/R/install_package_source.R index 44123c7..2d9f075 100644 --- a/R/install_package_source.R +++ b/R/install_package_source.R @@ -6,6 +6,7 @@ #' packages #' #' @return invisible return of the current snapshot +#' @import parallel remotes #' @export install_package_source <- function(packageSource, installOpts = list(Ncpus = parallel::detectCores())) { packageRemote <- switch( @@ -18,19 +19,13 @@ install_package_source <- function(packageSource, installOpts = list(Ncpus = par Bioconductor = remotes:::bio_remote(packageSource$src) ) - print(dput(c(list(packageRemote), dependencies = NA, upgrade = "default", - force = FALSE, quiet = FALSE, build = TRUE, build_opts = c("--no-resave-data", "--no-manual", - "--no-build-vignettes"), - build_manual = FALSE, build_vignettes = FALSE, - repos = getOption("repos"), type = getOption("pkgType"), installOpts))) - remotes:::install_remote(packageRemote, dependencies = NA, upgrade = "default", force = FALSE, quiet = FALSE, build = TRUE, build_opts = c("--no-resave-data", "--no-manual", "--no-build-vignettes"), build_manual = FALSE, build_vignettes = FALSE, repos = getOption("repos"), type = getOption("pkgType"), installOpts) - allPackages <- installed.packages() + allPackages <- utils::installed.packages() allPackages <- as.data.frame(allPackages) allPackages <- allPackages[allPackages$Package %in% packageSource$package,] package <- data.frame( diff --git a/R/isolate.R b/R/isolate.R new file mode 100644 index 0000000..1e6804a --- /dev/null +++ b/R/isolate.R @@ -0,0 +1,7 @@ + +#' Isolates the current environment to only the pacman library +#' +#' @export +isolate <- function() { + environment(.libPaths)$.lib.loc <- c(file.path(getwd(), ".pacman/library"), .Library) +} \ No newline at end of file diff --git a/R/list_depends.R b/R/list_depends.R index ac7eacd..b2bf90e 100644 --- a/R/list_depends.R +++ b/R/list_depends.R @@ -1,15 +1,33 @@ .list_depends <- function(packages, gen) { - allPackages <- installed.packages() + allPackages <- utils::installed.packages() allPackages <- as.data.frame(allPackages) packages <- allPackages[allPackages$Package %in% packages,] - packages <- packages[,c("Package", "Version", "Imports")] + packages <- packages[,c("Package", "Version", "Imports", "Depends", "LinkingTo")] + packages$Imports <- gsub(packages$Imports, pattern = "\n", replacement = " ") packages$Imports <- strsplit(packages$Imports, ", ") + #packages$Imports[is.na(packages$Imports)] <- list(NULL) + + packages$LinkingTo <- gsub(packages$LinkingTo, pattern = "\n", replacement = " ") + packages$LinkingTo <- strsplit(packages$LinkingTo, ", ") + packages$LinkingTo[is.na(packages$LinkingTo)] <- list(NULL) + + packages$Depends <- gsub(packages$Depends, pattern = "R \\([^\\)]+\\)", replacement = "") + packages$Depends <- gsub(packages$Depends, pattern = "^, ", replacement = "") + packages$Depends <- gsub(packages$Depends, pattern = ", *$", replacement = "") + packages$Depends[nchar(packages$Depends) == 0] <- NA + packages$Depends <- gsub(packages$Depends, pattern = "\n", replacement = " ") + packages$Depends <- strsplit(packages$Depends, ", ") + packages$Depends[is.na(packages$Depends)] <- list(NULL) + + nDepends <- lengths(packages$Imports) + lengths(packages$LinkingTo) + lengths(packages$Depends) packages <- data.frame( - package = rep(packages$Package, lengths(packages$Imports)), - version = rep(packages$Version, lengths(packages$Imports)), - imports = unlist(packages$Imports) + package = rep(packages$Package, nDepends), + version = rep(packages$Version, nDepends), + imports = unlist(lapply(seq_along(packages$Package), function(idx) { + c(packages$Imports[[idx]], packages$LinkingTo[[idx]], packages$Depends[[idx]]) + })) ) packages$min_version <- gsub(packages$imports, pattern = "[^ ]*( \\([=> ]*([^)]+)\\))?", replacement = "\\2") packages$min_version = ifelse(nchar(packages$min_version) == 0, NA_character_, packages$min_version) diff --git a/R/list_imports.R b/R/list_imports.R index a89658e..b047e16 100644 --- a/R/list_imports.R +++ b/R/list_imports.R @@ -3,11 +3,12 @@ #' versions. #' #' @return A data frame with the directly required packages +#' @import renv #' @export list_imports <- function() { packages <- renv::dependencies(progress = FALSE)$Package packages <- sort(unique(packages)) - allPackages <- installed.packages() + allPackages <- utils::installed.packages() allPackages <- as.data.frame(allPackages) allPackages <- allPackages[allPackages$Package %in% packages,] packages <- data.frame( diff --git a/R/request_package_source.R b/R/request_package_source.R index 3d4c7a4..bd8a547 100644 --- a/R/request_package_source.R +++ b/R/request_package_source.R @@ -7,6 +7,7 @@ #' @return invisible NULL on cancel #' @return List containing the type of the source, the source URI and an #' optional reference +#' @import remotes request_package_source <- function(package) { source <- NULL repeat { diff --git a/R/restore.R b/R/restore.R new file mode 100644 index 0000000..2335784 --- /dev/null +++ b/R/restore.R @@ -0,0 +1,100 @@ +# Requires activate.R + +.install_if_missing <- function(packages, installOpts, lockVersion = TRUE, parallel = FALSE) { + installedPackages <- as.data.frame(utils::installed.packages()[,c("Package","Version")]) + if (lockVersion) { + packageMatch <- merge( + packages, + cbind(installedPackages, matched = TRUE), + by.x = c("package", "version"), + by.y = c("Package", "Version"), + all.x = TRUE + ) + } else { + packageMatch <- merge( + packages, + cbind(installedPackages, matched = TRUE), + by.x = "package", by.y = "Package", + all.x = TRUE + ) + } + missingPackages <- packageMatch[is.na(packageMatch$matched),] + if (parallel) { + cl <- parallel::makeCluster(parallel::detectCores() - 1) + parallel::parLapply(cl, seq_along(missingPackages$package), function(ridx, missingPackages, installOpts, repos) { + options(repos = repos) + do.call(remotes::install_version, c( + missingPackages$package[[ridx]], + missingPackages$version[[ridx]], + upgrade = "never", + dependencies = FALSE, + installOpts + )) + }, missingPackages, installOpts, getOption("repos")) + parallel::stopCluster(cl) + } else { + lapply(seq_along(missingPackages$package), function(ridx) { + cat("Installing", missingPackages$package[[ridx]], "now...\n") + do.call(remotes::install_version, c( + missingPackages$package[[ridx]], + missingPackages$version[[ridx]], + upgrade = "never", + dependencies = FALSE, + installOpts + )) + }) + } +} + +#' Restores the project from a pacman snapshot file. Installs any missing +#' packages. This can be done into the user library or the packman library +#' (see totalIsolation) +#' +#' @param totalIsolation boolean Only refer to the pacman library, do not use +#' any user library paths +#' @param installOpts list Settings to be passed to install.packages etc. +#' Defaults to installing with multiple cores. +#' +#' @import parallel +#' @export +restore <- function(totalIsolation = FALSE, installOpts = list(Ncpus = parallel::detectCores())) { + activate(totalIsolation) + + get_cran_repo() + + lastSnapshot <- snapshot_latest() + + requiredPackages <- lastSnapshot$packages + if (is.null(requiredPackages$direct)) { + requiredPackages$direct <- list() + } + if (is.null(requiredPackages$indirect)) { + requiredPackages$indirect <- list() + } + if (is.null(requiredPackages$custom)) { + requiredPackages$custom <- list() + } + simplePackages <- as.data.frame(apply(rbind( + do.call(rbind, requiredPackages$direct), + do.call(rbind, requiredPackages$indirect) + ), 2, unlist)) + customPackages <- as.data.frame(do.call(rbind, requiredPackages$custom)) + + # corePackages <- as.data.frame(apply(do.call(rbind, lastSnapshot$packages$core), 2, unlist)) + + installGroups <- 1:length(lastSnapshot$packages$install_order) + for(grpIdx in installGroups) { + installGroup <- lastSnapshot$packages$install_order[[grpIdx]] + + groupCustomPackages <- customPackages[customPackages$package %in% installGroup,] + lapply(seq_along(groupCustomPackages$package), function(pkgIdx) { + install_package_source(groupCustomPackages[pkgIdx,], installOpts) + }) + + groupPackages <- simplePackages[simplePackages$package %in% installGroup,] + groupPackages <- groupPackages[!(groupPackages$package %in% groupCustomPackages$package),] + if (nrow(groupPackages) > 0) { + .install_if_missing(groupPackages, installOpts) + } + } +} \ No newline at end of file diff --git a/R/snapshot.R b/R/snapshot.R index b2a2cff..8000603 100644 --- a/R/snapshot.R +++ b/R/snapshot.R @@ -7,15 +7,14 @@ #' packages #' #' @return invisible return of the current snapshot +#' @import parallel jsonlite #' @export -snapshot_save <- function(installOpts = list(Ncpus = parallel::detectCores()), snapshot = NULL) { - if (is.null(snapshot)) { - snapshot <- snapshot_create(installOpts) - } +snapshot <- function(installOpts = list(Ncpus = parallel::detectCores())) { + snapshot <- snapshot_create(installOpts) history <- snapshot_history() history <- c(list(snapshot), history) snapshot$history <- history - jsonlite::write_json(snapshot, "pacman.lock") + jsonlite::write_json(snapshot, "pacman.lock", pretty = TRUE, auto_unbox = TRUE) snapshot$history <- NULL return(snapshot) } diff --git a/R/snapshot_create.R b/R/snapshot_create.R index 181e075..2794c46 100644 --- a/R/snapshot_create.R +++ b/R/snapshot_create.R @@ -8,6 +8,7 @@ #' packages #' #' @return A list containing the current state of the project packages +#' @import parallel #' @export snapshot_create <- function(installOpts = list(Ncpus = parallel::detectCores())) { lastSnapshot <- snapshot_latest() @@ -16,7 +17,7 @@ snapshot_create <- function(installOpts = list(Ncpus = parallel::detectCores())) customSources <- rbind(customSources, lastSnapshot$packages$custom) } packages <- compile_imports(customSources, installOpts) - names(packages) <- c("core", "direct", "indirect", "custom") + names(packages) <- c("core", "direct", "indirect", "custom", "install_order") if (nrow(packages$core) == 0) { packages$core <- NULL } @@ -30,9 +31,6 @@ snapshot_create <- function(installOpts = list(Ncpus = parallel::detectCores())) packages$custom <- NULL } description <- trimws(readline("Please provide a description for the snapshot (optional): ")) - if (nchar(description) == 0) { - description <- NULL - } return(list( timestamp = Sys.time(), description = description, diff --git a/R/snapshot_history.R b/R/snapshot_history.R index f9dc767..7691ad9 100644 --- a/R/snapshot_history.R +++ b/R/snapshot_history.R @@ -2,6 +2,7 @@ #' Load the existing snapshot history of the project #' #' @return A list containing the previous snapshots +#' @import jsonlite #' @export snapshot_history <- function() { if (!file.exists("pacman.lock")) { diff --git a/R/snapshot_latest.R b/R/snapshot_latest.R index 25cec55..c2cae61 100644 --- a/R/snapshot_latest.R +++ b/R/snapshot_latest.R @@ -2,6 +2,7 @@ #' Load the latest snapshot state from the lock file #' #' @return A list containing the last saved snapshot of the project state +#' @import jsonlite #' @export snapshot_latest <- function() { if (!file.exists("pacman.lock")) { diff --git a/R/utils.R b/R/utils.R index 69f4f81..43e2354 100644 --- a/R/utils.R +++ b/R/utils.R @@ -29,7 +29,7 @@ check_pacman_dir <- function() { get_cran_repo <- function() { repo <- getOption("repos")[[1]] if (repo == "@CRAN@") { - chooseCRANmirror() + utils::chooseCRANmirror() repo <- getOption("repos")[[1]] } repo @@ -84,6 +84,7 @@ empty_sources <- function() { #' @param str A character vector of strings to format #' @param width An optional width of the string to pad to #' @param justify "left" or "right" justification +#' @param ... formattable objects #' #' @return A formatted (padded) character vector format_str <- function (str, width = NULL, justify = "left", ...) { @@ -99,6 +100,8 @@ format_str <- function (str, width = NULL, justify = "left", ...) { } #' Calls stop() returning to the top level but masks the message +#' +#' @param ... ignored stop_quietly <- function(...) { blankMsg <- sprintf("\r%s\r", paste(rep(" ", getOption("width") - 1L), collapse = " ")) stop(simpleError(blankMsg)) diff --git a/man/activate.Rd b/man/activate.Rd new file mode 100644 index 0000000..f873ff3 --- /dev/null +++ b/man/activate.Rd @@ -0,0 +1,17 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/activate.R +\name{activate} +\alias{activate} +\title{Adds the pacman library path to the .libPaths variable, either as an extra +library or as the only library} +\usage{ +activate(totalIsolation = FALSE) +} +\arguments{ +\item{totalIsolation}{boolean Only refer to the pacman library, do not use +any user library paths} +} +\description{ +Adds the pacman library path to the .libPaths variable, either as an extra +library or as the only library +} diff --git a/man/add_package.Rd b/man/add_package.Rd new file mode 100644 index 0000000..40b5c72 --- /dev/null +++ b/man/add_package.Rd @@ -0,0 +1,21 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/add_package.R +\name{add_package} +\alias{add_package} +\title{Add a package to the project.} +\usage{ +add_package( + packageName = NULL, + installOpts = list(Ncpus = parallel::detectCores()) +) +} +\arguments{ +\item{packageName}{boolean Only refer to the pacman library, do not use +any user library paths} + +\item{installOpts}{boolean Only refer to the pacman library, do not use +any user library paths} +} +\description{ +Add a package to the project. +} diff --git a/man/compile_imports.Rd b/man/compile_imports.Rd new file mode 100644 index 0000000..a14b9d4 --- /dev/null +++ b/man/compile_imports.Rd @@ -0,0 +1,28 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/compile_imports.R +\name{compile_imports} +\alias{compile_imports} +\title{Compile a structure containing the current state of the imports for the +project.} +\usage{ +compile_imports( + custom_sources = empty_sources(), + installOpts = list(Ncpus = parallel::detectCores()) +) +} +\arguments{ +\item{custom_sources}{datatable A table containing any previously known +custom data sources} + +\item{installOpts}{list Installer options for use when installing CRAN +packages} +} +\value{ +A list containing R base imports, directly imported/used packages, + indirectly imported/used packages (aka dependencies) and any custom + import sources. +} +\description{ +Compile a structure containing the current state of the imports for the +project. +} diff --git a/man/empty_sources.Rd b/man/empty_sources.Rd new file mode 100644 index 0000000..f7f1048 --- /dev/null +++ b/man/empty_sources.Rd @@ -0,0 +1,14 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/utils.R +\name{empty_sources} +\alias{empty_sources} +\title{Structure of the imports data table} +\usage{ +empty_sources() +} +\value{ +datatable Empty table with the imports column structure +} +\description{ +Structure of the imports data table +} diff --git a/man/format_str.Rd b/man/format_str.Rd new file mode 100644 index 0000000..de57af0 --- /dev/null +++ b/man/format_str.Rd @@ -0,0 +1,23 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/utils.R +\name{format_str} +\alias{format_str} +\title{Re-formats a string to fix the width by padding with spaces} +\usage{ +format_str(str, width = NULL, justify = "left", ...) +} +\arguments{ +\item{str}{A character vector of strings to format} + +\item{width}{An optional width of the string to pad to} + +\item{justify}{"left" or "right" justification} + +\item{...}{formattable objects} +} +\value{ +A formatted (padded) character vector +} +\description{ +Re-formats a string to fix the width by padding with spaces +} diff --git a/man/install_package_source.Rd b/man/install_package_source.Rd new file mode 100644 index 0000000..b08c982 --- /dev/null +++ b/man/install_package_source.Rd @@ -0,0 +1,23 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/install_package_source.R +\name{install_package_source} +\alias{install_package_source} +\title{Installs a package from a custom source} +\usage{ +install_package_source( + packageSource, + installOpts = list(Ncpus = parallel::detectCores()) +) +} +\arguments{ +\item{packageSource}{The custom source information for a package} + +\item{installOpts}{list Installer options for use when installing CRAN +packages} +} +\value{ +invisible return of the current snapshot +} +\description{ +Installs a package from a custom source +} diff --git a/man/isolate.Rd b/man/isolate.Rd new file mode 100644 index 0000000..6a81c59 --- /dev/null +++ b/man/isolate.Rd @@ -0,0 +1,11 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/isolate.R +\name{isolate} +\alias{isolate} +\title{Isolates the current environment to only the pacman library} +\usage{ +isolate() +} +\description{ +Isolates the current environment to only the pacman library +} diff --git a/man/restore.Rd b/man/restore.Rd new file mode 100644 index 0000000..9a2e9e1 --- /dev/null +++ b/man/restore.Rd @@ -0,0 +1,25 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/restore.R +\name{restore} +\alias{restore} +\title{Restores the project from a pacman snapshot file. Installs any missing +packages. This can be done into the user library or the packman library +(see totalIsolation)} +\usage{ +restore( + totalIsolation = FALSE, + installOpts = list(Ncpus = parallel::detectCores()) +) +} +\arguments{ +\item{totalIsolation}{boolean Only refer to the pacman library, do not use +any user library paths} + +\item{installOpts}{list Settings to be passed to install.packages etc. +Defaults to installing with multiple cores.} +} +\description{ +Restores the project from a pacman snapshot file. Installs any missing +packages. This can be done into the user library or the packman library +(see totalIsolation) +} diff --git a/man/snapshot.Rd b/man/snapshot.Rd new file mode 100644 index 0000000..e7ea16f --- /dev/null +++ b/man/snapshot.Rd @@ -0,0 +1,18 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/snapshot.R +\name{snapshot} +\alias{snapshot} +\title{Save the current state of the project into the lock file as a snapshot} +\usage{ +snapshot(installOpts = list(Ncpus = parallel::detectCores())) +} +\arguments{ +\item{installOpts}{list Installer options for use when installing CRAN +packages} +} +\value{ +invisible return of the current snapshot +} +\description{ +Save the current state of the project into the lock file as a snapshot +} diff --git a/man/snapshot_create.Rd b/man/snapshot_create.Rd new file mode 100644 index 0000000..994b9e8 --- /dev/null +++ b/man/snapshot_create.Rd @@ -0,0 +1,18 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/snapshot_create.R +\name{snapshot_create} +\alias{snapshot_create} +\title{Create a snapshot of the project packages. Does not save the snapshot (see snapshot_save)} +\usage{ +snapshot_create(installOpts = list(Ncpus = parallel::detectCores())) +} +\arguments{ +\item{installOpts}{list Installer options for use when installing CRAN +packages} +} +\value{ +A list containing the current state of the project packages +} +\description{ +Create a snapshot of the project packages. Does not save the snapshot (see snapshot_save) +} diff --git a/man/snapshot_history.Rd b/man/snapshot_history.Rd new file mode 100644 index 0000000..ebe774f --- /dev/null +++ b/man/snapshot_history.Rd @@ -0,0 +1,14 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/snapshot_history.R +\name{snapshot_history} +\alias{snapshot_history} +\title{Load the existing snapshot history of the project} +\usage{ +snapshot_history() +} +\value{ +A list containing the previous snapshots +} +\description{ +Load the existing snapshot history of the project +} diff --git a/man/snapshot_latest.Rd b/man/snapshot_latest.Rd new file mode 100644 index 0000000..61df1e1 --- /dev/null +++ b/man/snapshot_latest.Rd @@ -0,0 +1,14 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/snapshot_latest.R +\name{snapshot_latest} +\alias{snapshot_latest} +\title{Load the latest snapshot state from the lock file} +\usage{ +snapshot_latest() +} +\value{ +A list containing the last saved snapshot of the project state +} +\description{ +Load the latest snapshot state from the lock file +} diff --git a/man/stop_quietly.Rd b/man/stop_quietly.Rd new file mode 100644 index 0000000..d8d8d85 --- /dev/null +++ b/man/stop_quietly.Rd @@ -0,0 +1,14 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/utils.R +\name{stop_quietly} +\alias{stop_quietly} +\title{Calls stop() returning to the top level but masks the message} +\usage{ +stop_quietly(...) +} +\arguments{ +\item{...}{ignored} +} +\description{ +Calls stop() returning to the top level but masks the message +}