From e264778d3d1678e63ba0ad4e2f5f0a2a858efcff Mon Sep 17 00:00:00 2001 From: Chase Clark Date: Sat, 20 Jun 2020 11:33:07 -0500 Subject: [PATCH 01/19] Update install_user_app.R --- R/install_user_app.R | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/R/install_user_app.R b/R/install_user_app.R index be0d3c67..9c01b26e 100644 --- a/R/install_user_app.R +++ b/R/install_user_app.R @@ -234,7 +234,8 @@ system_install_pkgs <- function(rscript_path){ if (identical(os, "win")) { system2(rscript_path, - paste0("-e ", + paste0("-vanilla ", + "-e ", "electricShine::install_package()"), wait = TRUE, stdout = "") @@ -242,7 +243,8 @@ system_install_pkgs <- function(rscript_path){ if (identical(os, "mac")) { system2(rscript_path, - paste0("-e ", + paste0("-vanilla ", + "-e ", "'", "electricShine::install_package()", "'"), @@ -250,4 +252,4 @@ system_install_pkgs <- function(rscript_path){ stdout = "") } -} \ No newline at end of file +} From c1f2e504a4f84768d70339e0e319e295e86176ff Mon Sep 17 00:00:00 2001 From: Chase Clark Date: Sat, 20 Jun 2020 11:34:24 -0500 Subject: [PATCH 02/19] Update background.js --- inst/template/src/background.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inst/template/src/background.js b/inst/template/src/background.js index 0819c59c..4d8462cd 100644 --- a/inst/template/src/background.js +++ b/inst/template/src/background.js @@ -153,7 +153,7 @@ const tryStartWebserver = async (attempt, progressCallback, onErrorStartup, let shinyProcessAlreadyDead = false rShinyProcess = execa(NODER, - ['-e', '?>(options = list(port = ' + srv.address().port + '))'], { + ['-vanilla -e', '?>(options = list(port = ' + srv.address().port + '))'], { env: { //Necessary for letting R know where it is and ensure we're not using another R 'WITHIN_ELECTRON': 'T', // can be used within an app to implement specific behaviour From 37a8a715a49a0ff3845d5393e4941a1ccbd22601 Mon Sep 17 00:00:00 2001 From: Chase Clark Date: Mon, 29 Jun 2020 20:57:22 -0500 Subject: [PATCH 03/19] Update check_for_nodejs_npm.R --- R/check_for_nodejs_npm.R | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/R/check_for_nodejs_npm.R b/R/check_for_nodejs_npm.R index 7dd941e5..2ea78e67 100644 --- a/R/check_for_nodejs_npm.R +++ b/R/check_for_nodejs_npm.R @@ -103,9 +103,6 @@ "/", mustWork = FALSE) - npm_path <- file.path(npm_path, - "npm") - npm_exists <- file.exists(npm_path) if (!npm_exists) { @@ -118,10 +115,13 @@ # Check that the npm version is the same as what we expect + npm_path <- file.path(npm_path, + "node") + quoted_npm_path <- shQuote(npm_path) command <- paste0(quoted_npm_path, - " -v") + "npm -v") result <- tryCatch(system(command, intern = T), From bb5625515e87e9824e9778f58eac48f34a4ca350 Mon Sep 17 00:00:00 2001 From: Chase Clark Date: Thu, 6 Aug 2020 08:21:47 -0500 Subject: [PATCH 04/19] Fix webpack-merge Fix breaking change in webpack-merge update: https://github.com/survivejs/webpack-merge/blob/master/CHANGELOG.md#503--2020-07-06 --- inst/template/build/webpack.app.config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inst/template/build/webpack.app.config.js b/inst/template/build/webpack.app.config.js index a291ad1a..c16004b0 100644 --- a/inst/template/build/webpack.app.config.js +++ b/inst/template/build/webpack.app.config.js @@ -1,5 +1,5 @@ const path = require("path"); -const merge = require("webpack-merge"); +const { merge } = require("webpack-merge"); const base = require("./webpack.base.config"); module.exports = env => { From 629863a6860430f3c1ca63f69dd5cca598fa984c Mon Sep 17 00:00:00 2001 From: Chase Clark Date: Thu, 6 Aug 2020 08:22:22 -0500 Subject: [PATCH 05/19] Fix breaking change in webpack-merge update Fix breaking change in webpack-merge update: https://github.com/survivejs/webpack-merge/blob/master/CHANGELOG.md#503--2020-07-06 --- inst/template/build/webpack.e2e.config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inst/template/build/webpack.e2e.config.js b/inst/template/build/webpack.e2e.config.js index 95ec3055..32cffe2e 100644 --- a/inst/template/build/webpack.e2e.config.js +++ b/inst/template/build/webpack.e2e.config.js @@ -1,4 +1,4 @@ -const merge = require("webpack-merge"); +const { merge } = require("webpack-merge"); const jetpack = require("fs-jetpack"); const base = require("./webpack.base.config"); From 217e9ae282976454f3f602bd577f587553b79f6e Mon Sep 17 00:00:00 2001 From: Chase Clark Date: Thu, 6 Aug 2020 08:23:10 -0500 Subject: [PATCH 06/19] Fix breaking change in webpack-merge update: Fix breaking change in webpack-merge update: --- inst/template/build/webpack.unit.config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inst/template/build/webpack.unit.config.js b/inst/template/build/webpack.unit.config.js index c34a5a80..e82b3957 100644 --- a/inst/template/build/webpack.unit.config.js +++ b/inst/template/build/webpack.unit.config.js @@ -1,4 +1,4 @@ -const merge = require("webpack-merge"); +const { merge } = require("webpack-merge"); const jetpack = require("fs-jetpack"); const base = require("./webpack.base.config"); From 90ecc1beee76554f5fa34a4c5102dede1fe3677e Mon Sep 17 00:00:00 2001 From: Renovate Bot Date: Fri, 9 Oct 2020 13:45:08 +0000 Subject: [PATCH 07/19] Update dependency style-loader to v2 --- inst/template/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inst/template/package.json b/inst/template/package.json index 540627fc..acc9df1c 100644 --- a/inst/template/package.json +++ b/inst/template/package.json @@ -18,7 +18,7 @@ "mocha": "8.1.2", "source-map-support": "0.5.19", "spectron": "11.1.0", - "style-loader": "1.3.0", + "style-loader": "2.0.0", "webpack": "4.44.2", "webpack-cli": "3.3.12", "webpack-merge": "5.2.0", From 394551b3e3284face0f09c3a35025095b46c8866 Mon Sep 17 00:00:00 2001 From: Renovate Bot Date: Mon, 30 Nov 2020 19:25:06 +0000 Subject: [PATCH 08/19] Update dependency spectron to v13 --- inst/template/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inst/template/package.json b/inst/template/package.json index e8d9fdf5..cc8ed1a1 100644 --- a/inst/template/package.json +++ b/inst/template/package.json @@ -17,7 +17,7 @@ "friendly-errors-webpack-plugin": "1.7.0", "mocha": "8.2.1", "source-map-support": "0.5.19", - "spectron": "11.1.0", + "spectron": "13.0.0", "style-loader": "1.3.0", "webpack": "4.44.2", "webpack-cli": "3.3.12", From 17349dd59fc337d67fa204ebefbe32193d427769 Mon Sep 17 00:00:00 2001 From: Renovate Bot Date: Fri, 4 Dec 2020 12:02:45 +0000 Subject: [PATCH 09/19] Update dependency electron-mocha to v10 --- inst/template/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inst/template/package.json b/inst/template/package.json index e349c15f..911f5af1 100644 --- a/inst/template/package.json +++ b/inst/template/package.json @@ -13,7 +13,7 @@ "css-loader": "3.6.0", "electron": "9.3.5", "electron-builder": "22.9.1", - "electron-mocha": "9.3.3", + "electron-mocha": "10.0.0", "friendly-errors-webpack-plugin": "1.7.0", "mocha": "8.2.1", "source-map-support": "0.5.19", From 66e4093e77b76670f55f04af3a5107ed81e7213b Mon Sep 17 00:00:00 2001 From: Renovate Bot Date: Sat, 12 Dec 2020 06:30:35 +0000 Subject: [PATCH 10/19] Update dependency css-loader to v5 --- inst/template/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inst/template/package.json b/inst/template/package.json index e345654d..57f086f5 100644 --- a/inst/template/package.json +++ b/inst/template/package.json @@ -10,7 +10,7 @@ "babel-loader": "8.2.2", "babel-plugin-transform-object-rest-spread": "6.26.0", "chai": "4.2.0", - "css-loader": "3.6.0", + "css-loader": "5.0.1", "electron": "9.4.0", "electron-builder": "22.9.1", "electron-mocha": "9.3.3", From 3b1e5ec495424b1bfb7c5ee44419a618ad83426e Mon Sep 17 00:00:00 2001 From: Renovate Bot Date: Mon, 14 Dec 2020 23:41:04 +0000 Subject: [PATCH 11/19] Update dependency execa to v5 --- inst/template/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inst/template/package.json b/inst/template/package.json index 3277e57e..65485530 100644 --- a/inst/template/package.json +++ b/inst/template/package.json @@ -2,7 +2,7 @@ "dependencies": { "fs-jetpack": "3.2.0", "electron-log": "4.3.1", - "execa": "4.1.0" + "execa": "5.0.0" }, "devDependencies": { "@babel/core": "7.12.10", From f832cb7fe79581c576dafa43458c27f2a488be12 Mon Sep 17 00:00:00 2001 From: Renovate Bot Date: Mon, 14 Dec 2020 23:41:10 +0000 Subject: [PATCH 12/19] Update dependency fs-jetpack to v4 --- inst/template/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inst/template/package.json b/inst/template/package.json index 3277e57e..fc81db0d 100644 --- a/inst/template/package.json +++ b/inst/template/package.json @@ -1,6 +1,6 @@ { "dependencies": { - "fs-jetpack": "3.2.0", + "fs-jetpack": "4.1.0", "electron-log": "4.3.1", "execa": "4.1.0" }, From 58ab080b244f9a51fb389af83ae4fb7054061a24 Mon Sep 17 00:00:00 2001 From: Renovate Bot Date: Thu, 17 Dec 2020 16:27:43 +0000 Subject: [PATCH 13/19] Update dependency webpack to v5 --- inst/template/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inst/template/package.json b/inst/template/package.json index 23db811d..9d261c4e 100644 --- a/inst/template/package.json +++ b/inst/template/package.json @@ -19,7 +19,7 @@ "source-map-support": "0.5.19", "spectron": "11.1.0", "style-loader": "1.3.0", - "webpack": "4.44.2", + "webpack": "5.11.0", "webpack-cli": "3.3.12", "webpack-merge": "5.7.2", "webpack-node-externals": "2.5.2" From 7f7075a12156dc39192e777b7094e8dfbe4c562b Mon Sep 17 00:00:00 2001 From: Renovate Bot Date: Mon, 21 Dec 2020 22:52:36 +0000 Subject: [PATCH 14/19] Update dependency electron to v11 --- inst/template/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inst/template/package.json b/inst/template/package.json index 23db811d..73f945c7 100644 --- a/inst/template/package.json +++ b/inst/template/package.json @@ -11,7 +11,7 @@ "babel-plugin-transform-object-rest-spread": "6.26.0", "chai": "4.2.0", "css-loader": "3.6.0", - "electron": "9.4.0", + "electron": "11.1.1", "electron-builder": "22.9.1", "electron-mocha": "9.3.3", "friendly-errors-webpack-plugin": "1.7.0", From 736c6ded9c1b6ce3ef3ff51b600d4ad8b34e500c Mon Sep 17 00:00:00 2001 From: Renovate Bot Date: Fri, 25 Dec 2020 18:31:48 +0000 Subject: [PATCH 15/19] Update dependency webpack-cli to v4 --- inst/template/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inst/template/package.json b/inst/template/package.json index 8cb28444..ba931010 100644 --- a/inst/template/package.json +++ b/inst/template/package.json @@ -20,7 +20,7 @@ "spectron": "11.1.0", "style-loader": "1.3.0", "webpack": "4.44.2", - "webpack-cli": "3.3.12", + "webpack-cli": "4.3.0", "webpack-merge": "5.7.3", "webpack-node-externals": "2.5.2" } From bd89dee3de868bc900201f68592c11995e1336a7 Mon Sep 17 00:00:00 2001 From: Renovate Bot Date: Mon, 28 Dec 2020 19:43:07 +0000 Subject: [PATCH 16/19] Update dependency webpack to v5 --- inst/template/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inst/template/package.json b/inst/template/package.json index 8cb28444..07256922 100644 --- a/inst/template/package.json +++ b/inst/template/package.json @@ -19,7 +19,7 @@ "source-map-support": "0.5.19", "spectron": "11.1.0", "style-loader": "1.3.0", - "webpack": "4.44.2", + "webpack": "5.11.1", "webpack-cli": "3.3.12", "webpack-merge": "5.7.3", "webpack-node-externals": "2.5.2" From 6ae82aa87da7e78ead8f4123232146d934e6d446 Mon Sep 17 00:00:00 2001 From: Renovate Bot Date: Thu, 31 Dec 2020 18:06:42 +0000 Subject: [PATCH 17/19] Update dependency webpack-cli to v4 --- inst/template/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inst/template/package.json b/inst/template/package.json index 8cb28444..0a4dfa22 100644 --- a/inst/template/package.json +++ b/inst/template/package.json @@ -20,7 +20,7 @@ "spectron": "11.1.0", "style-loader": "1.3.0", "webpack": "4.44.2", - "webpack-cli": "3.3.12", + "webpack-cli": "4.3.1", "webpack-merge": "5.7.3", "webpack-node-externals": "2.5.2" } From c2dea54d031546cc9c302958bfe704a3cf6a9884 Mon Sep 17 00:00:00 2001 From: chase clark Date: Fri, 1 Jan 2021 19:59:06 -0600 Subject: [PATCH 18/19] WIP --- R/check_for_nodejs_npm.R | 148 +++++++++++++++----------------- R/install_nodejs.R | 106 +++++++++++------------ R/install_user_app.R | 177 ++++++++++++++++++++------------------- R/utils.R | 38 ++++++--- 4 files changed, 238 insertions(+), 231 deletions(-) diff --git a/R/check_for_nodejs_npm.R b/R/check_for_nodejs_npm.R index 2ea78e67..8c4da0c5 100644 --- a/R/check_for_nodejs_npm.R +++ b/R/check_for_nodejs_npm.R @@ -8,77 +8,73 @@ #' @return path of nodejs executable if found and functional, otherwise: FALSE .check_node_works <- function(node_top_dir, expected_version) { - - message("Checking if the provided nodejs path already contains nodejs...") - - if (!grepl("v", expected_version)) { - expected_version <- paste0("v", - expected_version) - } - + + message("Looking for nodejs...") + + expected_version <- .check_node_version_format(expected_version) + os <- electricShine::get_os() - + node_path <- normalizePath(node_top_dir, "/", mustWork = FALSE) - + if (os == "win") { - + node_path <- file.path(node_path, "node.exe") - + } else { - + node_path <- file.path(node_path, - "node") + "node") } - + node_exists <- file.exists(node_path) - + if (!node_exists) { - - message("nodejs executable not found.") + + message("...nodejs executable not found") node_path <- FALSE return(node_path) - + } else { - - message("Found nodejs executable.") - + + message("...found nodejs executable.") + message("Checking if nodejs executable is functional...") + # Check that the node version is the same as what we expect and nodejs is functional quoted_node_path <- shQuote(node_path) - - command <- paste0(quoted_node_path, + + command <- paste0(quoted_node_path, " -v") - + nodejs_response <- tryCatch(system(command, intern = T), - error = function(e) FALSE, + error = function(e) FALSE, warning = function(e) FALSE) - - + if (nodejs_response == FALSE) { - - message(glue::glue("nodejs at {node_path} seems not to be functional.")) - node_path <- FALSE - return(node_path) - - - # TODO: Use "base::as.numeric_version()" and "base::compareVersion()" - # so e.g. "10.6.0" == "10.6" is TRUE - + + message(glue::glue("...nodejs at {node_path} seems not to be functional.")) + return(FALSE) + } else if (nodejs_response != expected_version) { - - message(glue::glue("Found nodejs {node_path} is version {nodejs_response}, expected {expected_version}.")) - node_path <- FALSE - return(node_path) + + message(glue::glue("...found nodejs {node_path} \n but it is version {nodejs_response}, expected {expected_version}.")) + return(FALSE) + } else if (nodejs_response == expected_version) { - - message(glue::glue("Found nodejs {nodejs_response} at: {node_path}.")) + + message(glue::glue("...found a functional nodejs {nodejs_response} at: {node_path}.")) return(node_path) - - } + + } else { + + stop("Unexpected error when looking for nodejs") + + } } } @@ -94,51 +90,41 @@ #' #' @return path of npm executable if found and functional, otherwise: FALSE .check_npm_works <- function(node_top_dir) { - - message("Checking if given nodejs path already contains nodejs.") - + + message("Looking for npm...") + os <- electricShine::get_os() - - npm_path <- normalizePath(node_top_dir, - "/", - mustWork = FALSE) - - npm_exists <- file.exists(npm_path) - + + npm_exists <- file.exists(file.path(node_top_dir, "npm")) + if (!npm_exists) { - - message(glue::glue("npm seems not be installed.")) - npm_path <- FALSE - return(npm_path) - + # If nopm isn't found- let other functions stop if desired, only notify here + message(glue::glue("...npm not found")) + return(FALSE) + } else { - + # Check that the npm version is the same as what we expect - - npm_path <- file.path(npm_path, - "node") - - quoted_npm_path <- shQuote(npm_path) - - command <- paste0(quoted_npm_path, - "npm -v") - + npm_path <- file.path(node_top_dir, + "npm", + fsep = "/") + command <- shQuote(npm_path) + + command <- paste0(command, " -v") + result <- tryCatch(system(command, intern = T), - error = function(e) FALSE, + error = function(e) FALSE, warning = function(e) FALSE) - - if(isFALSE(result)) { - - message(glue::glue("npm executable was found but seems not to be functional.")) - npm_path <- FALSE - return(npm_path) - + + if(isFALSE(result)) { + message(glue::glue("...npm executable was found but seems not to be functional")) + return(FALSE) } else { - message(glue::glue("Found npm at: {npm_path}")) + message(glue::glue("Found npm v{result} at: {npm_path}")) return(npm_path) - } - + } + } } diff --git a/R/install_nodejs.R b/R/install_nodejs.R index c4b341fd..96d814c1 100644 --- a/R/install_nodejs.R +++ b/R/install_nodejs.R @@ -12,46 +12,50 @@ install_nodejs <- function(node_url = "https://nodejs.org/dist", nodejs_path = file.path(system.file(package = "electricShine"), "nodejs"), force_install = FALSE, - nodejs_version = "v12.16.2", + nodejs_version = "v15.5.0", permission_to_install = FALSE){ - - - if (!grepl("v", nodejs_version)) { - # Node version format is "v10.16.0", not "10.16.0" - # add "v" if needed - nodejs_version <- paste0("v", - nodejs_version) - } - + + nodejs_version <- .check_node_version_format(nodejs_version) + # Check if node and npm are already installed - - - node_exists <- .check_node_works(node_top_dir = nodejs_path, - expected_version = nodejs_version) - + nodejs_path <- normalizePath(nodejs_path, winslash = "/") + + subfolder <- file.path(nodejs_path, + glue::glue("node-{nodejs_version}-{platform}-{arch}"), + fsep = "/") + # check within given folder first + if (dir.exists(subfolder)) { + nodejs_path <- subfolder + node_exists <- .check_node_works(node_top_dir = nodejs_path, + expected_version = nodejs_version) + } else { + node_exists <- .check_node_works(node_top_dir = nodejs_path, + expected_version = nodejs_version) + } + npm_exists <- .check_npm_works(node_top_dir = nodejs_path) - - + + if (!base::isFALSE(node_exists) && !base::isFALSE(npm_exists)) { - + message("Skipping install_nodejs(), nodejs alreagy installed.") - + } else { - + if (permission_to_install == FALSE) { - + permission_to_install <- .prompt_install_nodejs(nodejs_path) - + } - + if (permission_to_install == FALSE) { - message("nodejs is required for electricShine to work. Please point nodejs_path + message("nodejs is required for electricShine to work. Please point nodejs_path to a valid nodejs path or select 'yes' when prompted to install") } else { - + # Get operating system: os <- electricShine::get_os() - + if (identical(os, "win")) { platform <- "win" ext <- "zip" @@ -62,8 +66,8 @@ install_nodejs <- function(node_url = "https://nodejs.org/dist", platform <- "linux" ext <- "tar.xz" } - - + + if (base::version$arch[[1]] == "x86_64") { arch <- "x64" } else { @@ -75,34 +79,32 @@ install_nodejs <- function(node_url = "https://nodejs.org/dist", node_url <- file.path(node_url, nodejs_version, binary_name) - + # Download to temporary directory - temp <- base::file.path(tempdir(), + temp <- base::file.path(tempdir(), base::basename(node_url)) - + utils::download.file(node_url, destfile = temp, mode = 'wb') - + # Download sha file and parse online_sha <- glue::glue("https://nodejs.org/dist/{nodejs_version}/SHASUMS256.txt") - - - online_sha <- utils::read.delim(online_sha, sep = "", header = FALSE) - online_sha <- as.character(online_sha[grepl(binary_name, online_sha[,2]), 1]) - + # Calculate SHA of downloaded nodejs local_sha <- as.character(openssl::sha256(file(temp, raw = TRUE))) + # as.character() leaves class as "hash" "sha256" + # change to character class(local_sha) <- "character" - + if (!identical(online_sha, local_sha)) { - stop("Downloaded sha didn't match online sha") + stop("Downloaded SHA didn't match online sha") } - message("Downloaded sha matches expected sha") - message("Decompressing node.js files, might take a few minutes...") + message("Downloaded SHA matches expected sha") message(glue::glue("All node.js files will be installed into: \n {nodejs_path}")) - + message("Decompressing node.js files, might take a few minutes...") + if (base::grepl("zip$", base::basename(node_url))) { base::try( utils::unzip(zipfile = temp, @@ -116,7 +118,7 @@ install_nodejs <- function(node_url = "https://nodejs.org/dist", ) } - + if (identical(os, "win")) { nodejs_path <- file.path(nodejs_path, tools::file_path_sans_ext(basename(temp), @@ -131,23 +133,23 @@ install_nodejs <- function(node_url = "https://nodejs.org/dist", ext <- "tar.xz" } - + node_exists <- .check_node_works(node_top_dir = nodejs_path, expected_version = nodejs_version) - + npm_exists <- .check_npm_works(node_top_dir = nodejs_path) - + if (base::isFALSE(node_exists) || base::isFALSE(npm_exists)) { - + stop("Was unable to successfully install nodejs/npm executable.") - + } - + } } - - nodejs_path <- normalizePath(nodejs_path, - winslash = "/", + + nodejs_path <- normalizePath(nodejs_path, + winslash = "/", mustWork = TRUE) return(nodejs_path) } diff --git a/R/install_user_app.R b/R/install_user_app.R index 9c01b26e..20604713 100644 --- a/R/install_user_app.R +++ b/R/install_user_app.R @@ -3,7 +3,7 @@ #' @param library_path path to the new Electron app's R's library folder #' @param repo_location {remotes} package function, one of c("github", "gitlab", "bitbucket", "local") #' @param repo e.g. if repo_location is github: "chasemc/demoApp" ; if repo_location is local: "C:/Users/chase/demoApp" -#' @param repos cran like repository package dependencies will be retrieved from +#' @param repos cran like repository package dependencies will be retrieved from #' @param package_install_opts further arguments to remotes::install_github, install_gitlab, install_bitbucket, or install_local #' #' @return App name @@ -11,121 +11,121 @@ #' @export #' #' @examples -#' +#' #'\dontrun{ #' -#' install_user_app(repo_location = "github", +#' install_user_app(repo_location = "github", #' repo = "chasemc/demoApp@@d81fff0") -#' -#' install_user_app(repo_location = "github", +#' +#' install_user_app(repo_location = "github", #' repo = "chasemc/demoApp@@d81fff0", -#' auth_token = "my_secret_token") -#' -#' install_user_app(repo_location = "bitbucket", +#' auth_token = "my_secret_token") +#' +#' install_user_app(repo_location = "bitbucket", #' repo = "chasemc/demoApp", -#' auth_user = bitbucket_user(), -#' password = bitbucket_password()) -#' -#' install_user_app(repo_location = "gitlab", +#' auth_user = bitbucket_user(), +#' password = bitbucket_password()) +#' +#' install_user_app(repo_location = "gitlab", #' repo = "chasemc/demoApp", -#' auth_token = "my_secret_token") +#' auth_token = "my_secret_token") -#' install_user_app(repo_location = "local", +#' install_user_app(repo_location = "local", #' repo = "C:/Users/chase/demoApp", -#' build_vignettes = TRUE) +#' build_vignettes = TRUE) #' } -#' +#' install_user_app <- function(library_path = NULL, repo_location = "github", repo = "chasemc/IDBacApp", repos = cran_like_url, package_install_opts = NULL){ - + accepted_sites <- c("github", "gitlab", "bitbucket", "local") - - + + if (is.null(library_path)) { stop("install_user_app() requires library_path to be set.") } - + if (!dir.exists(library_path)) { stop("install_user_app() library_path wasn't found.") } - + if (length(repo_location) != 1L) { stop(glue::glue("install_user_app(repo_location) must be character vector of length 1")) } - + if (!repo_location %in% accepted_sites) { stop(glue::glue("install_user_app(repo_location) must be one of: {accepted_sites}")) } - + if (!nchar(repo) > 0) { # TODO: Maybe make this a regex? stop("install_user_app(repo) must be character with > 0 characters") } - - if (!is.null(package_install_opts)) { + + if (!is.null(package_install_opts)) { if (!is.list(package_install_opts)) { stop("package_install_opts must be a list of arguments.") } } - + remotes_code <- as.character(glue::glue("install_{repo_location}")) - - - + + + repo <- as.list(repo) - + passthr <- c(repo, repos = repos, - c(package_install_opts, + c(package_install_opts, list(force = TRUE, lib = library_path) ) ) - - os <- electricShine::get_os() - + + os <- electricShine::get_os() + if (identical(os, "win")) { rscript_path <- file.path(dirname(library_path), "bin", "Rscript.exe") } - + if (identical(os, "mac")) { rscript_path <- file.path(dirname(library_path), "bin", "R") } - + if (identical(os, "unix")) { stop("electricShine is still under development for linux systems") - + } - + if (identical(os, "unix")) { stop("electricShine is still under development for linux systems") - + } - - + + tmp_file <- tempfile() save(list = c("remotes_code", "passthr"), file = tmp_file) - - - + + + remotes_library <- copy_remotes_package() - + copy_electricshine_package() - - + + old_R_LIBS <- Sys.getenv("R_LIBS") old_R_LIBS_USER <- Sys.getenv("R_LIBS_USER") old_R_LIBS_SITE <- Sys.getenv("R_LIBS_SITE") - + Sys.setenv(R_LIBS=library_path) Sys.setenv(R_LIBS_USER=remotes_library) Sys.setenv(R_LIBS_SITE=remotes_library) @@ -135,23 +135,23 @@ install_user_app <- function(library_path = NULL, tmp_file2 <- tempfile() file.create(tmp_file2) Sys.setenv(ESHINE_package_return=tmp_file2) - + message("Installing your Shiny package into electricShine framework.") - + system_install_pkgs(rscript_path) - + on.exit({ - Sys.setenv(R_LIBS=old_R_LIBS) - Sys.setenv(R_LIBS_USER=old_R_LIBS_USER) - Sys.setenv(R_LIBS_SITE=old_R_LIBS_SITE) - Sys.setenv(ESHINE_PASSTHRUPATH="") - Sys.setenv(ESHINE_remotes_code="") -}) + Sys.setenv(R_LIBS=old_R_LIBS) + Sys.setenv(R_LIBS_USER=old_R_LIBS_USER) + Sys.setenv(R_LIBS_SITE=old_R_LIBS_SITE) + Sys.setenv(ESHINE_PASSTHRUPATH="") + Sys.setenv(ESHINE_remotes_code="") + }) message("Finshed: Installing your Shiny package into electricShine framework") - + # TODO: break into unit-testable function user_pkg <- readLines(tmp_file2) - + return(user_pkg) } @@ -164,22 +164,22 @@ install_user_app <- function(library_path = NULL, #' @return path of new {remotes}-only library copy_remotes_package <- function(){ remotes_path <- system.file(package = "remotes") - - new_path <- file.path(tempdir(), + + new_path <- file.path(tempdir(), "electricShine") dir.create(new_path) - - new_path <- file.path(tempdir(), + + new_path <- file.path(tempdir(), "electricShine", "templib") dir.create(new_path) - + file.copy(remotes_path, - new_path, + new_path, recursive = TRUE, copy.mode = F) - - test <- file.path(new_path, + + test <- file.path(new_path, "remotes") if (!file.exists(test)) { stop("Wasn't able to copy remotes package.") @@ -196,22 +196,22 @@ copy_remotes_package <- function(){ #' @return path of new {electricShine}-only library copy_electricshine_package <- function(){ remotes_path <- system.file(package = "electricShine") - - new_path <- file.path(tempdir(), + + new_path <- file.path(tempdir(), "electricShine") dir.create(new_path) - - new_path <- file.path(tempdir(), + + new_path <- file.path(tempdir(), "electricShine", "templib") dir.create(new_path) - + file.copy(remotes_path, - new_path, + new_path, recursive = TRUE, copy.mode = F) - - test <- file.path(new_path, + + test <- file.path(new_path, "electricShine") if (!file.exists(test)) { stop("Wasn't able to copy electricShine package.") @@ -229,27 +229,28 @@ copy_electricshine_package <- function(){ #' @return nothing #' system_install_pkgs <- function(rscript_path){ - - os <- electricShine::get_os() - + + os <- electricShine::get_os() + if (identical(os, "win")) { system2(rscript_path, - paste0("-vanilla ", - "-e ", - "electricShine::install_package()"), + c( + "-e", + "electricShine::install_package()"), wait = TRUE, stdout = "") } - + if (identical(os, "mac")) { system2(rscript_path, - paste0("-vanilla ", - "-e ", - "'", - "electricShine::install_package()", - "'"), + c( + " -vanilla ", + "-e ", + "'", + "electricShine::install_package()", + "'"), wait = TRUE, stdout = "") } - + } diff --git a/R/utils.R b/R/utils.R index ca193ec0..eb2b1a22 100644 --- a/R/utils.R +++ b/R/utils.R @@ -11,23 +11,23 @@ write_text <- function(text, filename, path){ - + path <- base::file.path(path, filename) - - path <- normalizePath(path, - winslash = "/", + + path <- normalizePath(path, + winslash = "/", mustWork = FALSE) - + base::writeLines(text, path) - + if (file.exists(path)) { base::message(glue::glue("Successfully created {path}")) } else { base::warning(glue::glue("Did not create {path}")) } - + } @@ -39,14 +39,32 @@ write_text <- function(text, #' @export #' create_folder <- function(app_root_path){ - + name <- base::basename(app_root_path) - + if (file.exists(app_root_path)) { stop(glue::glue("electricShine::create_folder(app_root_path, name) already exists, choose a path that doesn't already contain a directory named '{name}'")) } else { dir.create(app_root_path) } - + } + +#' Add "v" to nodejs version if needed +#' +#' @param node_version nodejs version stringsss +#' +#' @return nodejs version in format "v10.16.0" not "10.16.0" +#' +.check_node_version_format <- function(node_version) + # Node version format is "v10.16.0", not "10.16.0" + # add "v" if needed + if (!grepl("v", node_version)) { + node_version <- paste0("v", + node_version) + } else { + return(node_version) + } + + From b6b6c709a436a3c145bc70d103f50d46fd2bde03 Mon Sep 17 00:00:00 2001 From: chase clark Date: Fri, 1 Jan 2021 20:23:25 -0600 Subject: [PATCH 19/19] turn off renovate.js --- renovate.json | 11 ----------- 1 file changed, 11 deletions(-) delete mode 100644 renovate.json diff --git a/renovate.json b/renovate.json deleted file mode 100644 index 6356b96c..00000000 --- a/renovate.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "extends": [ - "config:base" - ], - "prHourlyLimit": 0, - "automerge": true, - "major": { - "automerge": false - } -} -