Ce n’est pas un rhinocéros
An installation framework for Shiny apps
A script-driven installation system written in Delphi Pascal by Jordan Russell
[Setup]
AppName=My Program
DefaultDirName={pf}\My Program
Compression=lzma2
[Files]
Source: "MyProg.exe"; DestDir: "{app}"
[Icons]
Name: "{group}\My Program"; Filename: "{app}\MyProg.exe"
install.packages("RInno")
require(RInno)
RInno::install_inno()
example_app(app_dir = "app")
## Example: C:/Users/jhill/Documents/Internal Projects/Full Stack Data Science/app
You can start simple with default settings:
create_app(
app_name = "RInnoApp",
app_dir = "app")
compile_iss()
Incrementally add one feature at a time:
create_app(
app_name = "RInnoApp",
app_dir = "app",
include_R = TRUE)
compile_iss()
create_app(
app_name = "RInnoApp",
app_dir = "app",
pkgs = c("shiny", "dplyr", "plotly", "ggplot2", "xkcd"),
remotes = c("talgalili/installr", "daattali/shinyjs"))
compile_iss()
pkgs
and Github for remotes
.create_app(
app_name = "RInnoApp",
app_dir = "app",
app_repo_url = "https://github.com/Dripdrop12/RInnoApp")
compile_iss()
Through a json file called config.cfg
{
"appname": "RInnoApp",
"r_bindir": "C:\\Program Files\\R\\R-3.3.3\\bin",
"pkgs": {
"pkgs": ["jsonlite", "shiny", "magrittr", "httr"],
"cran": {
"repo": "http://cran.rstudio.com"
}
},
"logging": {
"error_log": "error.log"
},
"host": "github",
"app_repo": "Dripdrop12/RInnoApp",
"auth_user": {
"auth_user": "none"
},
"auth_pw": {
"auth_pw": "none"
},
"remotes": {
"remotes": "none"
},
"user_browser": "chrome"
}
… with JScript:
var oFSO = WScript.CreateObject("Scripting.FileSystemObject");
var oShell = WScript.CreateObject("WScript.Shell");
var fConfig = oFSO.OpenTextFile('utils\\config.cfg', 1);
… with R:
# Load config.cfg
config <- jsonlite::fromJSON(file.path(appwd, "utils/config.cfg"))
# Package dependencies
pkgs <- config$pkgs$pkgs; remotes <- config$remotes
# Custom messaging with your appname
title = sprintf("Starting %s ...", config$appname)
# If you provided an app_repo, RInno uses a different startup sequence
if (config$app_repo != "none") {
# Which involves an API call to your app_repo
api_response <- get_remote_version(
app_repo = config$app_repo,
host = config$host,
auth_user = config$auth_user,
auth_pw = config$auth_pw)
# A local version check
local_version <- packageVersion(config$appname)
# And a conditional statement like this
if (local_version != api_response) {
if (config$host == "bitbucket") {
devtools::install_bitbucket(config$app_repo)
} else if (config$host == "github") {
devtools::install_github(config$app_repo)
} else {
"Host error message"
}
}
}
This Delphi Pascal script is run during installation to determine if each user needs R. It only provides a copy if R is not detected on the machine
[Code]
# Is R installed?
function RDetected(): boolean;
var
success: boolean;
begin
success := RegKeyExists(HKLM, 'Software\R-Core\R\{#RVersion}');
begin
Result := success;
end;
end;
# If R is not detected, it is needed
function RNeeded(): Boolean;
begin
Result := (RDetected = false);
end;