From f136b81bb3a060ae7ea4fe17cd21634717c8e470 Mon Sep 17 00:00:00 2001 From: galachad Date: Thu, 21 Sep 2023 21:08:21 +0000 Subject: [PATCH] renv / codespaces update from pharmaverse/admiralci --- .Rprofile | 5 ++--- .devcontainer/4.1/devcontainer.json | 2 +- .devcontainer/4.2/devcontainer.json | 2 +- .devcontainer/devcontainer.json | 2 +- .devcontainer/postCreateCommand.sh | 6 ++++++ .devcontainer/rstudio.sh | 5 +++++ renv/profiles/4.1/renv/settings.json | 1 - renv/profiles/4.2/renv/settings.json | 1 - renv/profiles/4.3/renv/settings.json | 1 - renv/settings.json | 4 ++-- 10 files changed, 18 insertions(+), 11 deletions(-) create mode 100644 .devcontainer/rstudio.sh diff --git a/.Rprofile b/.Rprofile index d059c2fc..6d46e675 100644 --- a/.Rprofile +++ b/.Rprofile @@ -1,8 +1,7 @@ # Set renv profile base on R version. .get_dependencies <- function(project_dir) { - admdev_loc <- find.package("admiraldev", lib.loc = .libPaths(), quiet = TRUE) - adm_dev_suggests <- if(length(admdev_loc) != 0) { + adm_dev_suggests <- if (length(admdev_loc) != 0) { renv:::renv_dependencies_discover_description(admdev_loc, fields = c("Depends", "Imports", "LinkingTo", "Suggests")) } else { data.frame(Packages = character(0)) @@ -19,7 +18,7 @@ )) ) ) - packages[!(packages %in% c("admiral", "admiraldev", "admiralci", "admiral.test", "pharmaversesdtm", getwd()))] + packages[!(packages %in% c("admiral", "admiraldev", "admiralci", "pharmaversesdtm", getwd()))] } options(renv.snapshot.filter = .get_dependencies) diff --git a/.devcontainer/4.1/devcontainer.json b/.devcontainer/4.1/devcontainer.json index 1d05f7fd..ab6ddfee 100644 --- a/.devcontainer/4.1/devcontainer.json +++ b/.devcontainer/4.1/devcontainer.json @@ -31,7 +31,7 @@ "postCreateCommand": "bash ./.devcontainer/postCreateCommand.sh", - "postAttachCommand": "$BROWSER \"https://${CODESPACE_NAME}-8787.${GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN}/\"", + "postAttachCommand": "$BROWSER \"https://${CODESPACE_NAME}-8787.${GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN}/\"; echo 'To open rstudio in your browser, just type rstudio in the terminal'", "customizations": { "vscode": { diff --git a/.devcontainer/4.2/devcontainer.json b/.devcontainer/4.2/devcontainer.json index f30486e0..decbcca5 100644 --- a/.devcontainer/4.2/devcontainer.json +++ b/.devcontainer/4.2/devcontainer.json @@ -31,7 +31,7 @@ "postCreateCommand": "bash ./.devcontainer/postCreateCommand.sh", - "postAttachCommand": "$BROWSER \"https://${CODESPACE_NAME}-8787.${GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN}/\"", + "postAttachCommand": "$BROWSER \"https://${CODESPACE_NAME}-8787.${GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN}/\"; echo 'To open rstudio in your browser, just type rstudio in the terminal'", "customizations": { "vscode": { diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 4f49db8f..3f47589f 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -31,7 +31,7 @@ "postCreateCommand": "bash ./.devcontainer/postCreateCommand.sh", - "postAttachCommand": "$BROWSER \"https://${CODESPACE_NAME}-8787.${GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN}/\"", + "postAttachCommand": "$BROWSER \"https://${CODESPACE_NAME}-8787.${GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN}/\"; echo 'To open rstudio in your browser, just type rstudio in the terminal'", "customizations": { "vscode": { diff --git a/.devcontainer/postCreateCommand.sh b/.devcontainer/postCreateCommand.sh index 9b9db23a..8dfe4e23 100644 --- a/.devcontainer/postCreateCommand.sh +++ b/.devcontainer/postCreateCommand.sh @@ -1,5 +1,11 @@ #!/bin/bash +# move script rstudio into /usr/bin +sudo cp "$(pwd)/.devcontainer/rstudio.sh" /usr/bin/rstudio +sudo chmod +x /usr/bin/rstudio + +# Restore renv and install staged dependencies R -q -e 'renv::restore(lockfile = file.path("renv", "profiles", paste(R.version$major, substr(R.version$minor, 1, 1), sep = "."), "renv.lock")); staged.dependencies::install_deps(staged.dependencies::dependency_table(project = ".", verbose = 1), verbose = 1);' +# Define rstudio default working directory jq --arg folder "$(pwd)/" '. + { "initial_working_directory": $folder }' .devcontainer/rstudio-prefs.json > ~/.config/rstudio/rstudio-prefs.json diff --git a/.devcontainer/rstudio.sh b/.devcontainer/rstudio.sh new file mode 100644 index 00000000..053a247b --- /dev/null +++ b/.devcontainer/rstudio.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +$BROWSER "https://${CODESPACE_NAME}-8787.${GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN}" + +exit 1 diff --git a/renv/profiles/4.1/renv/settings.json b/renv/profiles/4.1/renv/settings.json index 4922677e..0c8943c5 100644 --- a/renv/profiles/4.1/renv/settings.json +++ b/renv/profiles/4.1/renv/settings.json @@ -4,7 +4,6 @@ "ignored.packages": [ "admiral", "admiraldev", - "admiral.test", "admiralci", "pharmaversesdtm" ], diff --git a/renv/profiles/4.2/renv/settings.json b/renv/profiles/4.2/renv/settings.json index 4922677e..0c8943c5 100644 --- a/renv/profiles/4.2/renv/settings.json +++ b/renv/profiles/4.2/renv/settings.json @@ -4,7 +4,6 @@ "ignored.packages": [ "admiral", "admiraldev", - "admiral.test", "admiralci", "pharmaversesdtm" ], diff --git a/renv/profiles/4.3/renv/settings.json b/renv/profiles/4.3/renv/settings.json index 4922677e..0c8943c5 100644 --- a/renv/profiles/4.3/renv/settings.json +++ b/renv/profiles/4.3/renv/settings.json @@ -4,7 +4,6 @@ "ignored.packages": [ "admiral", "admiraldev", - "admiral.test", "admiralci", "pharmaversesdtm" ], diff --git a/renv/settings.json b/renv/settings.json index 1db5da30..0c8943c5 100644 --- a/renv/settings.json +++ b/renv/settings.json @@ -4,8 +4,8 @@ "ignored.packages": [ "admiral", "admiraldev", - "pharmaversesdtm", - "admiralci" + "admiralci", + "pharmaversesdtm" ], "package.dependency.fields": [ "Imports",