Other files ignored by Codecov
Showing 1 of 4 files from the diff.
@@ -212,6 +212,98 @@
Loading
212 | 212 | pkg_deps_explain(ref, deps, upgrade, dependencies) |
|
213 | 213 | } |
|
214 | 214 | ||
215 | + | #' Create a lock file for the dependencies of a package tree |
|
216 | + | #' |
|
217 | + | #' The lock file can be used later, possibly in a new R session, to carry |
|
218 | + | #' out the installation of the dependencies, with |
|
219 | + | #' [local_install_lockfile()]. |
|
220 | + | #' |
|
221 | + | #' Note, since the URLs of CRAN and most CRAN-like repositories change |
|
222 | + | #' over time, in practice you cannot use the lock file _much_ later. |
|
223 | + | #' For example, binary packages of older package version |
|
224 | + | #' might be deleted from the repository, breaking the URLs in the |
|
225 | + | #' lock file. |
|
226 | + | #' |
|
227 | + | #' Currently the intended use case of lock files in on CI systems, to |
|
228 | + | #' facilitate caching. The (hash of the) lock file provides a good key |
|
229 | + | #' for caching systems. |
|
230 | + | #' |
|
231 | + | #' @param lockfile Path to the lock file. |
|
232 | + | #' @param lib Library to base the lock file on. In most cases (e.g. on a |
|
233 | + | #' CI system, or at deployment), this is an empty library. Supply |
|
234 | + | #' `tempfile()` to make sure the lock file is based on an empty library. |
|
235 | + | #' @inheritParams local_install |
|
236 | + | #' @family lock files |
|
237 | + | #' @export |
|
238 | + | ||
239 | + | local_create_lockfile <- function(root = ".", lockfile = "pkg.lock", |
|
240 | + | lib = .libPaths()[1], upgrade = TRUE, |
|
241 | + | dependencies = TRUE) { |
|
242 | + | ret <- remote( |
|
243 | + | function(...) { |
|
244 | + | get("local_create_lockfile_internal", asNamespace("pak"))(...) |
|
245 | + | }, |
|
246 | + | list(root = root, lockfile = lockfile, lib = lib, upgrade = upgrade, |
|
247 | + | dependencies = dependencies) |
|
248 | + | ) |
|
249 | + | ||
250 | + | invisible(ret) |
|
251 | + | } |
|
252 | + | ||
253 | + | local_create_lockfile_internal <- function(root, lockfile, lib, upgrade, |
|
254 | + | dependencies) { |
|
255 | + | root <- rprojroot::find_package_root_file(path = root) |
|
256 | + | prop <- pkgdepends::new_pkg_installation_proposal( |
|
257 | + | paste0("deps::", root), |
|
258 | + | config = list(library = lib, dependencies = dependencies) |
|
259 | + | ) |
|
260 | + | prop$set_solve_policy(if (upgrade) "upgrade" else "lazy") |
|
261 | + | prop$solve() |
|
262 | + | prop$stop_for_solution_error() |
|
263 | + | prop$create_lockfile(lockfile) |
|
264 | + | invisible() |
|
265 | + | } |
|
266 | + | ||
267 | + | #' Install packages based on a lock file |
|
268 | + | #' |
|
269 | + | #' Install a lock file that was created with [local_create_lockfile()]. |
|
270 | + | #' |
|
271 | + | #' @param lockfile Path to the lock file. |
|
272 | + | #' @param lib Library to carry out the installation on. |
|
273 | + | #' @family lock files |
|
274 | + | #' @export |
|
275 | + | ||
276 | + | local_install_lockfile <- function(lockfile = "pkg.lock", |
|
277 | + | lib = .libPaths()[1]) { |
|
278 | + | ||
279 | + | start <- Sys.time() |
|
280 | + | ret <- remote( |
|
281 | + | function(...) { |
|
282 | + | get("local_install_lockfile_internal", asNamespace("pak"))(...) |
|
283 | + | }, |
|
284 | + | list(lockfile = lockfile, lib = lib, start = start) |
|
285 | + | ) |
|
286 | + | ||
287 | + | invisible(ret) |
|
288 | + | } |
|
289 | + | ||
290 | + | local_install_lockfile_internal <- function(lockfile, lib, start) { |
|
291 | + | config <- list(library = lib) |
|
292 | + | plan <- pkgdepends::new_pkg_installation_plan(lockfile, config = config) |
|
293 | + | plan$download() |
|
294 | + | inst <- plan$install() |
|
295 | + | attr(inst, "total_time") <- Sys.time() - start |
|
296 | + | class(inst) <- c("pkg_install_result", class(inst)) |
|
297 | + | ||
298 | + | ## Remove some largeish columns that we don't really need any more |
|
299 | + | inst$extra <- NULL |
|
300 | + | ||
301 | + | ## One line summary of the install |
|
302 | + | print_install_summary(inst) |
|
303 | + | ||
304 | + | inst |
|
305 | + | } |
|
306 | + | ||
215 | 307 | ## ---------------------------------------------------------------------- |
|
216 | 308 | ||
217 | 309 | ## Almost the same as a "regular" install, but need to set dependencies |
Files | Coverage |
---|---|
R | 19.04% |
Project Totals (23 files) | 19.04% |
Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file.
The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files.
The size and color of each slice is representing the number of statements and the coverage, respectively.