From 7711a37735d826a260fa15510fc9869b845bf807 Mon Sep 17 00:00:00 2001 From: Colin Fay Date: Fri, 2 May 2025 08:19:45 +0000 Subject: [PATCH 1/6] feat: make activate_js conditional --- R/bundle_resources.R | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/R/bundle_resources.R b/R/bundle_resources.R index 8756d708..94135102 100644 --- a/R/bundle_resources.R +++ b/R/bundle_resources.R @@ -14,6 +14,7 @@ #' Turn to NULL if you don't want this meta tag to be included. #' @inheritParams htmltools::htmlDependency #' @param with_sparkles C'est quand que tu vas mettre des paillettes dans ma vie Kevin? +#' @param activate_js Boolean to enable or disable the injection of JavaScript via activate_js(). #' #' @importFrom htmltools htmlDependency #' @export @@ -30,7 +31,8 @@ bundle_resources <- function( package = NULL, all_files = TRUE, app_builder = "golem", - with_sparkles = FALSE + with_sparkles = FALSE, + activate_js = TRUE # Nouveau paramètre ) { res <- list() if ( @@ -54,9 +56,13 @@ bundle_resources <- function( as.character( tags$title(app_title) ), - as.character( - golem::activate_js() - ), + { + if (activate_js){ + as.character( + golem::activate_js() + ) + } + }, head ), attachment = attachment, From 4b7bd8bcc5e973a5936b06d3aced3a28b2528ffa Mon Sep 17 00:00:00 2001 From: colin Date: Fri, 2 May 2025 10:48:03 +0200 Subject: [PATCH 2/6] doc: redoc --- man/bundle_resources.Rd | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/man/bundle_resources.Rd b/man/bundle_resources.Rd index 881213d9..049ce98d 100644 --- a/man/bundle_resources.Rd +++ b/man/bundle_resources.Rd @@ -15,7 +15,8 @@ bundle_resources( package = NULL, all_files = TRUE, app_builder = "golem", - with_sparkles = FALSE + with_sparkles = FALSE, + activate_js = TRUE ) } \arguments{ @@ -47,6 +48,8 @@ dependency files.} Turn to NULL if you don't want this meta tag to be included.} \item{with_sparkles}{C'est quand que tu vas mettre des paillettes dans ma vie Kevin?} + +\item{activate_js}{Boolean to enable or disable the injection of JavaScript via activate_js().} } \value{ an htmlDependency From 85fe2111b277527599a50aa05bdac269d0c8c5c5 Mon Sep 17 00:00:00 2001 From: colin Date: Fri, 2 May 2025 10:51:50 +0200 Subject: [PATCH 3/6] test: removing the repo in tests --- tests/testthat/test-install_dev_deps.R | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/testthat/test-install_dev_deps.R b/tests/testthat/test-install_dev_deps.R index 81d30b0e..beb2baed 100644 --- a/tests/testthat/test-install_dev_deps.R +++ b/tests/testthat/test-install_dev_deps.R @@ -1,8 +1,7 @@ test_that("install_dev_deps works", { withr::with_temp_libpaths({ install_dev_deps( - force_install = TRUE, - repos = "https://cran.rstudio.com" + force_install = TRUE ) paks <- unique( From e46f21f4d0c99fc1bbd3909aa37e6be1f4f021f7 Mon Sep 17 00:00:00 2001 From: colin Date: Fri, 2 May 2025 10:59:58 +0200 Subject: [PATCH 4/6] test: with expect_installed --- tests/testthat/test-install_dev_deps.R | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/tests/testthat/test-install_dev_deps.R b/tests/testthat/test-install_dev_deps.R index beb2baed..462d5b2f 100644 --- a/tests/testthat/test-install_dev_deps.R +++ b/tests/testthat/test-install_dev_deps.R @@ -1,3 +1,13 @@ +expect_installed <- function(pkg) { + expect( + rlang::is_installed(pkg), + failure_message = paste0( + "Package '", pkg, "' is not installed. Installed from ", + getOption("repos") + ) + ) +} + test_that("install_dev_deps works", { withr::with_temp_libpaths({ install_dev_deps( @@ -20,15 +30,13 @@ test_that("install_dev_deps works", { "processx", "rsconnect", "testthat", - "rstudioapi" + "rstudioapi", "piff" ) ) for ( pak in paks ) { - expect_true( - rlang::is_installed(pak) - ) + expect_installed(pak) } }) }) From c9a7c054f2bff88b2887e9b55916011ef7f6e167 Mon Sep 17 00:00:00 2001 From: colin Date: Fri, 2 May 2025 11:03:51 +0200 Subject: [PATCH 5/6] test: using the dev_deps vector instead --- tests/testthat/test-install_dev_deps.R | 22 +--------------------- 1 file changed, 1 insertion(+), 21 deletions(-) diff --git a/tests/testthat/test-install_dev_deps.R b/tests/testthat/test-install_dev_deps.R index 462d5b2f..796da646 100644 --- a/tests/testthat/test-install_dev_deps.R +++ b/tests/testthat/test-install_dev_deps.R @@ -13,28 +13,8 @@ test_that("install_dev_deps works", { install_dev_deps( force_install = TRUE ) - - paks <- unique( - c( - "usethis", - "pkgload", - "dockerfiler", - "devtools", - "roxygen2", - "attachment", - "rstudioapi", - "here", - "fs", - "desc", - "pkgbuild", - "processx", - "rsconnect", - "testthat", - "rstudioapi", "piff" - ) - ) for ( - pak in paks + pak in dev_deps ) { expect_installed(pak) } From bca30615d2c65c6aacf5b136b03d754cbbac0a1a Mon Sep 17 00:00:00 2001 From: colin Date: Fri, 2 May 2025 11:15:11 +0200 Subject: [PATCH 6/6] chore: unused com --- R/bundle_resources.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/R/bundle_resources.R b/R/bundle_resources.R index 94135102..fbf01223 100644 --- a/R/bundle_resources.R +++ b/R/bundle_resources.R @@ -32,7 +32,7 @@ bundle_resources <- function( all_files = TRUE, app_builder = "golem", with_sparkles = FALSE, - activate_js = TRUE # Nouveau paramètre + activate_js = TRUE ) { res <- list() if ( @@ -62,7 +62,7 @@ bundle_resources <- function( golem::activate_js() ) } - }, + }, head ), attachment = attachment,