211 lines
18 KiB
HTML
211 lines
18 KiB
HTML
|
<!DOCTYPE html>
|
|||
|
|
|||
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
|||
|
|
|||
|
<head>
|
|||
|
|
|||
|
<meta charset="utf-8" />
|
|||
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
|||
|
<meta name="generator" content="pandoc" />
|
|||
|
|
|||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|||
|
|
|||
|
<meta name="author" content="Jonathan M. Hill" />
|
|||
|
|
|||
|
<meta name="date" content="2018-09-21" />
|
|||
|
|
|||
|
<title>Continuous Installation</title>
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<style type="text/css">code{white-space: pre;}</style>
|
|||
|
<style type="text/css">
|
|||
|
div.sourceCode { overflow-x: auto; }
|
|||
|
table.sourceCode, tr.sourceCode, td.lineNumbers, td.sourceCode {
|
|||
|
margin: 0; padding: 0; vertical-align: baseline; border: none; }
|
|||
|
table.sourceCode { width: 100%; line-height: 100%; }
|
|||
|
td.lineNumbers { text-align: right; padding-right: 4px; padding-left: 4px; color: #aaaaaa; border-right: 1px solid #aaaaaa; }
|
|||
|
td.sourceCode { padding-left: 5px; }
|
|||
|
code > span.kw { color: #007020; font-weight: bold; } /* Keyword */
|
|||
|
code > span.dt { color: #902000; } /* DataType */
|
|||
|
code > span.dv { color: #40a070; } /* DecVal */
|
|||
|
code > span.bn { color: #40a070; } /* BaseN */
|
|||
|
code > span.fl { color: #40a070; } /* Float */
|
|||
|
code > span.ch { color: #4070a0; } /* Char */
|
|||
|
code > span.st { color: #4070a0; } /* String */
|
|||
|
code > span.co { color: #60a0b0; font-style: italic; } /* Comment */
|
|||
|
code > span.ot { color: #007020; } /* Other */
|
|||
|
code > span.al { color: #ff0000; font-weight: bold; } /* Alert */
|
|||
|
code > span.fu { color: #06287e; } /* Function */
|
|||
|
code > span.er { color: #ff0000; font-weight: bold; } /* Error */
|
|||
|
code > span.wa { color: #60a0b0; font-weight: bold; font-style: italic; } /* Warning */
|
|||
|
code > span.cn { color: #880000; } /* Constant */
|
|||
|
code > span.sc { color: #4070a0; } /* SpecialChar */
|
|||
|
code > span.vs { color: #4070a0; } /* VerbatimString */
|
|||
|
code > span.ss { color: #bb6688; } /* SpecialString */
|
|||
|
code > span.im { } /* Import */
|
|||
|
code > span.va { color: #19177c; } /* Variable */
|
|||
|
code > span.cf { color: #007020; font-weight: bold; } /* ControlFlow */
|
|||
|
code > span.op { color: #666666; } /* Operator */
|
|||
|
code > span.bu { } /* BuiltIn */
|
|||
|
code > span.ex { } /* Extension */
|
|||
|
code > span.pp { color: #bc7a00; } /* Preprocessor */
|
|||
|
code > span.at { color: #7d9029; } /* Attribute */
|
|||
|
code > span.do { color: #ba2121; font-style: italic; } /* Documentation */
|
|||
|
code > span.an { color: #60a0b0; font-weight: bold; font-style: italic; } /* Annotation */
|
|||
|
code > span.cv { color: #60a0b0; font-weight: bold; font-style: italic; } /* CommentVar */
|
|||
|
code > span.in { color: #60a0b0; font-weight: bold; font-style: italic; } /* Information */
|
|||
|
</style>
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<link href="data:text/css;charset=utf-8,body%20%7B%0Abackground%2Dcolor%3A%20%23fff%3B%0Amargin%3A%201em%20auto%3B%0Amax%2Dwidth%3A%20700px%3B%0Aoverflow%3A%20visible%3B%0Apadding%2Dleft%3A%202em%3B%0Apadding%2Dright%3A%202em%3B%0Afont%2Dfamily%3A%20%22Open%20Sans%22%2C%20%22Helvetica%20Neue%22%2C%20Helvetica%2C%20Arial%2C%20sans%2Dserif%3B%0Afont%2Dsize%3A%2014px%3B%0Aline%2Dheight%3A%201%2E35%3B%0A%7D%0A%23header%20%7B%0Atext%2Dalign%3A%20center%3B%0A%7D%0A%23TOC%20%7B%0Aclear%3A%20both%3B%0Amargin%3A%200%200%2010px%2010px%3B%0Apadding%3A%204px%3B%0Awidth%3A%20400px%3B%0Aborder%3A%201px%20solid%20%23CCCCCC%3B%0Aborder%2Dradius%3A%205px%3B%0Abackground%2Dcolor%3A%20%23f6f6f6%3B%0Afont%2Dsize%3A%2013px%3B%0Aline%2Dheight%3A%201%2E3%3B%0A%7D%0A%23TOC%20%2Etoctitle%20%7B%0Afont%2Dweight%3A%20bold%3B%0Afont%2Dsize%3A%2015px%3B%0Amargin%2Dleft%3A%205px%3B%0A%7D%0A%23TOC%20ul%20%7B%0Apadding%2Dleft%3A%2040px%3B%0Amargin%2Dleft%3A%20%2D1%2E5em%3B%0Amargin%2Dtop%3A%205px%3B%0Amargin%2Dbottom%3A%205px%3B%0A%7D%0A%23TOC%20ul%20ul%20%7B%0Amargin%2Dleft%3A%20%2D2em%3B%0A%7D%0A%23TOC%20li%20%7B%0Aline%2Dheight%3A%2016px%3B%0A%7D%0Atable%20%7B%0Amargin%3A%201em%20auto%3B%0Aborder%2Dwidth%3A%201px%3B%0Aborder%2Dcolor%3A%20%23DDDDDD%3B%0Aborder%2Dstyle%3A%20outset%3B%0Aborder%2Dcollapse%3A%20collapse%3B%0A%7D%0Atable%20th%20%7B%0Aborder%2Dwidth%3A%202px%3B%0Apadding%3A%205px%3B%0Aborder%2Dstyle%3A%20inset%3B%0A%7D%0Atable%20td%20%7B%0Aborder%2Dwidth%3A%201px%3B%0Aborder%2Dstyle%3A%20inset%3B%0Aline%2Dheight%3A%2018px%3B%0Apadding%3A%205px%205px%3B%0A%7D%0Atable%2C%20table%20th%2C%20table%20td%20%7B%0Aborder%2Dleft%2Dstyle%3A%20none%3B%0Aborder%2Dright%2Dstyle%3A%20none%3B%0A%7D%0Atable%20thead%2C%20table%20tr%2Eeven%20%7B%0Abackground%2Dcolor%3A%20%23f7f7f7%3B%0A%7D%0Ap%20%7B%0Amargin%3A%200%2E5em%200%3B%0A%7D%0Ablockquote%20%7B%0Abackground%2Dcolor%3A%20%23f6f6f6%3B%0Apadding%3A%200%2E25em%200%2E75em%3B%0A%7D%0Ahr%20%7B%0Aborder%2Dstyle%3A%20solid%3B%0Aborder%3A%20none%3B%0Aborder%2Dtop%3A%201px%20solid%20%23777%3B%0Amargin%3A%2028px%200%3B%0A%7D%0Adl%20%7B%0Amargin%2Dleft%3A%200%3B%0A%7D%0Adl%20dd%20%7B%0Amargin%2Dbottom%3A%2013px%3B%0Amargin%2Dleft%3A%2013px%3B%0A%7D%0Adl%20dt%20%7B%0Afont%2Dweight%3A%20bold%3B%0A%7D%0Aul%20%7B%0Amargin%2Dtop%3A%200%3B%0A%7D%0Aul%20li%20%7B%0Alist%2Dstyle%3A%20circle%20outside%3B%0A%7D%0Aul%20ul%20%7B%0Amargin%2Dbottom%3A%200%3B%0A%7D%0Apre%2C%20code%20%7B%0Abackground%2Dcolor%3A%20%23f7f7f7%3B%0Aborder%2Dradius%3A%203px%3B%0Acolor%3A%20%23333%3B%0Awhite%2Dspace%3A%20pre%2Dwrap%3B%20%0A%7D%0Apre%20%7B%0Aborder%2Dradius%3A%203px%3B%0Amargin%3A%205px%200px%2010px%200px%3B%0Apadding%3A%2010px%3B%0A%7D%0Apre%3Anot%28%5Bclass%5D%29%20%7B%0Abackground%2Dcolor%3A%20%23f7f7f7%3B%0A%7D%0Acode%20%7B%0Afont%2Dfamily%3A%20Consolas%2C%20Monaco%2C%20%27Courier%20New%27%2C%20monospace%3B%0Afont%2Dsize%3A%2085%25%3B%0A%7D%0Ap%20%3E%20code%2C%20li%20%3E%20code%20%7B%0Apadding%3A%202px%200px%3B%0A%7D%0Adiv%2Efigure%20%7B%0Atext%2Dalign%3A%20center%3B%0A%7D%0Aimg%20%7B%0Abackground%2Dcolor%3A%20%23FFFFFF%3B%0Apadding%3A%202px%3B%0Aborder%3A%201px%20solid%20%23DDDDDD%3B%0Aborder%2Dradius%3A%203px%3B%0Aborder%3A%201px%20solid%20%23CCCCCC%3B%0Amargin%3A%200%205px%3B%0A%7D%0Ah1%20%7B%0Amargin%2Dtop%3A%200%3B%0Afont%2Dsize%3A%2035px%3B%0Aline%2Dheight%3A%2040px%3B%0A%7D%0Ah2%20%7B%0Aborder%2Dbottom%3A%204px%20solid%20%23f7f7f7%3B%0Apadding%2Dtop%3A%2010px%3B%0Apadding%2Dbottom%3A%202px%3B%0Afont%2Dsize%3A%20145%25%3B%0A%7D%0Ah3%20%7B%0Aborder%2Dbottom%3A%202px%20solid%20%23f7f7f7%3B%0Apadding%2Dtop%3A%2010px%3B%0Afont%2Dsize%3A%20120%25%3B%0A%7D%0Ah4%20%7B%0Aborder%2Dbottom%3A%201px%20solid%20%23f7f7f7%3B%0Amargin%2Dleft%3A%208px%3B%0Afont%2Dsize%3A%20105%25%3B%0A%7D%0Ah5%2C%20h6%20%7B%0Aborder%2Dbottom%3A%201px%20solid%20%23ccc%3B%0Afont%2Dsize%3A%20105%25%3B%0A%7D%0Aa%20%7B%0Acolor%3A%20%230033dd%3B%0Atext%2Ddecoration%3A%20none%3B%0A%7D%0Aa%3Ahover%20%7B%0Acolor%3A%20%236666ff%3B%20%7D%0Aa%3Avisited%20%7B%0Acolor%3A%20%23800080%3B%20%7D%0Aa%3Avisited%3Ahover%20%7B%0Acolor%3A%20%23BB00BB%3B%20%7D%0Aa%5Bhref%5E%3D%22http
|
|||
|
|
|||
|
</head>
|
|||
|
|
|||
|
<body>
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<h1 class="title toc-ignore">Continuous Installation</h1>
|
|||
|
<h4 class="author"><em>Jonathan M. Hill</em></h4>
|
|||
|
<h4 class="date"><em>2018-09-21</em></h4>
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<p>RInno supports continuous installation of shiny apps through APIs to public/private BitBucket and GitHub repos. If you follow the directions in this vignette, RInno apps will call your repository each time a user clicks their icon. If there have been any hotfixes or releases since installation, the app automatically updates, letting its user know through a windows progress bar, and then opens normally.</p>
|
|||
|
<p>This feature requires:</p>
|
|||
|
<ol style="list-style-type: decimal">
|
|||
|
<li>A URL to the app’s repo, <code>app_repo_url</code>. This should be the full URL like, <a href="https://github.com/Dripdrop12/RInnoApp" class="uri">https://github.com/Dripdrop12/RInnoApp</a>.</li>
|
|||
|
<li>A release tag on GitHub, or a version on BitBucket. If you forget to create a release, your app will error when it calls <code>get_remote_version</code> and <code>parsed_response</code>’s subscript will be “out of bounds.”</li>
|
|||
|
<li>An R package structure that can be installed via <code>remotes::install_github</code> or <code>remotes::install_bitbucket</code>. I recommend testing this before compiling your RInno .exe.</li>
|
|||
|
</ol>
|
|||
|
<p>The release tag or version is compared with the package DESCRIPTION file, i.e. <code>0.0.0.9000</code>, to determine if the app should call <code>remotes::install_github</code> or <code>remotes::install_bitbucket</code> respectively. So update the app’s version in both places (2 & 3 above) with each new version, otherwise the app will re-install every time its icon is clicked.</p>
|
|||
|
<div id="r-package-structure" class="section level2">
|
|||
|
<h2>R Package Structure</h2>
|
|||
|
<p>To connect a shiny app to a remote repository, the app must be on Github or Bitbucket, and it must be in the <code>inst/app</code> directory of an R package. The easiest way to do this is by creating a new project in RStudio and selecting R Package. See Dean Attali’s <a href="http://deanattali.com/2015/04/21/r-package-shiny-app/">Blog</a> for a detailed tutorial on including shiny apps in an R package.</p>
|
|||
|
<table>
|
|||
|
<thead>
|
|||
|
<tr class="header">
|
|||
|
<th align="right">package/</th>
|
|||
|
<th align="left"></th>
|
|||
|
<th align="left"></th>
|
|||
|
</tr>
|
|||
|
</thead>
|
|||
|
<tbody>
|
|||
|
<tr class="odd">
|
|||
|
<td align="right"></td>
|
|||
|
<td align="left">inst/app/</td>
|
|||
|
<td align="left"></td>
|
|||
|
</tr>
|
|||
|
<tr class="even">
|
|||
|
<td align="right"></td>
|
|||
|
<td align="left"></td>
|
|||
|
<td align="left">ui.R</td>
|
|||
|
</tr>
|
|||
|
<tr class="odd">
|
|||
|
<td align="right"></td>
|
|||
|
<td align="left"></td>
|
|||
|
<td align="left">server.R</td>
|
|||
|
</tr>
|
|||
|
<tr class="even">
|
|||
|
<td align="right"></td>
|
|||
|
<td align="left">R</td>
|
|||
|
<td align="left"></td>
|
|||
|
</tr>
|
|||
|
<tr class="odd">
|
|||
|
<td align="right"></td>
|
|||
|
<td align="left">…</td>
|
|||
|
<td align="left"></td>
|
|||
|
</tr>
|
|||
|
<tr class="even">
|
|||
|
<td align="right"></td>
|
|||
|
<td align="left">DESCRIPTION</td>
|
|||
|
<td align="left"></td>
|
|||
|
</tr>
|
|||
|
<tr class="odd">
|
|||
|
<td align="right"></td>
|
|||
|
<td align="left">…</td>
|
|||
|
<td align="left"></td>
|
|||
|
</tr>
|
|||
|
</tbody>
|
|||
|
</table>
|
|||
|
<p>The package should be called <code>app_name</code>, and within the DESCRIPTION file, <code>Package: app_name</code>. Make sure your app can be installed as a package by typing <code>ctrl</code>+<code>shift</code>+<code>B</code>.</p>
|
|||
|
</div>
|
|||
|
<div id="bitbucket" class="section level2">
|
|||
|
<h2>Bitbucket</h2>
|
|||
|
<p>On Bitbucket, enable issue tracking in the repo’s settings. This will add Versions to the Issues section and make it accessible via BitBucket’s API. Add <code>0.0.0.9000</code> to Versions and within the package’s DESCRIPTION file, <code>Version: 0.0.0.9000</code>.</p>
|
|||
|
<p>Then create an RInno installer:</p>
|
|||
|
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r"><span class="kw">create_app</span>(
|
|||
|
<span class="dt">app_name =</span> <span class="st">"myapp"</span>,
|
|||
|
<span class="dt">app_repo_url =</span> <span class="st">"https://bitbucket.org/fi_consulting/myapp"</span>,
|
|||
|
<span class="dt">pkgs =</span> <span class="kw">c</span>(<span class="st">"magrittr"</span>, <span class="st">"httr"</span>, <span class="st">"shiny"</span>, <span class="st">"myapp"</span>),
|
|||
|
<span class="dt">auth_user =</span> <span class="st">"<read_only_username>"</span>,
|
|||
|
<span class="dt">auth_pw =</span> <span class="st">"<password>"</span>)
|
|||
|
|
|||
|
<span class="kw">compile_iss</span>()</code></pre></div>
|
|||
|
<p>Or for custom installers, directly through <code>create_config</code>:</p>
|
|||
|
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r"><span class="kw">create_config</span>(
|
|||
|
<span class="dt">app_name =</span> <span class="st">"myapp"</span>,
|
|||
|
<span class="dt">R_version =</span> <span class="st">"3.3.2"</span>,
|
|||
|
<span class="dt">app_dir =</span> <span class="st">"app"</span>,
|
|||
|
<span class="dt">pkgs =</span> <span class="kw">c</span>(<span class="st">"magrittr"</span>, <span class="st">"httr"</span>, <span class="st">"shiny"</span>, <span class="st">"myapp"</span>),
|
|||
|
<span class="dt">app_repo_url =</span> <span class="st">"https://bitbucket.org/fi_consulting/myapp"</span>,
|
|||
|
<span class="dt">auth_user =</span> <span class="st">"<read_only_username>"</span>,
|
|||
|
<span class="dt">auth_pw =</span> <span class="st">"<password>"</span>)
|
|||
|
|
|||
|
<span class="co"># -------------------------------------------------- Many steps later</span>
|
|||
|
<span class="kw">compile_iss</span>()</code></pre></div>
|
|||
|
<p>Shiny apps compiled/installed this way will call the BitBucket API on start up, and re-install every time there is an update to the BitBucket repo’s version. For public repos, you do not need to provide <code>auth_user</code> and <code>auth_pw</code>.</p>
|
|||
|
</div>
|
|||
|
<div id="github" class="section level2">
|
|||
|
<h2>GitHub</h2>
|
|||
|
<p>On GitHub, create a release for the app. The release(s) tab is located on the repo’s homepage next to branch(es) just before contributor(s). Add <code>0.0.0.9000</code> to the release tag and within the package’s DESCRIPTION file, <code>Version: 0.0.0.9000</code>. This will make the release tag accessible via GitHub’s API. For private repos, you will need to create an app <a href="https://github.com/settings/tokens">token</a>.</p>
|
|||
|
<p>Then create an RInno installer:</p>
|
|||
|
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r"><span class="kw">create_app</span>(
|
|||
|
<span class="dt">app_name =</span> <span class="st">"myapp"</span>,
|
|||
|
<span class="dt">app_repo_url =</span> <span class="st">"https://github.com/fi_consulting/myapp"</span>,
|
|||
|
<span class="dt">pkgs =</span> <span class="kw">c</span>(<span class="st">"magrittr"</span>, <span class="st">"httr"</span>, <span class="st">"shiny"</span>, <span class="st">"myapp"</span>),
|
|||
|
<span class="dt">auth_token =</span> <span class="st">"<app_token>"</span>)
|
|||
|
|
|||
|
<span class="kw">compile_iss</span>()</code></pre></div>
|
|||
|
<p>Or for custom installers, directly through <code>create_config</code>:</p>
|
|||
|
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r"><span class="kw">create_config</span>(
|
|||
|
<span class="dt">app_name =</span> <span class="st">"myapp"</span>,
|
|||
|
<span class="dt">R_version =</span> <span class="st">"3.3.2"</span>,
|
|||
|
<span class="dt">app_dir =</span> <span class="st">"app"</span>,
|
|||
|
<span class="dt">app_repo_url =</span> <span class="st">"https://github.com/fi_consulting/myapp"</span>,
|
|||
|
<span class="dt">pkgs =</span> <span class="kw">c</span>(<span class="st">"magrittr"</span>, <span class="st">"httr"</span>, <span class="st">"shiny"</span>, <span class="st">"myapp"</span>),
|
|||
|
<span class="dt">auth_token =</span> <span class="st">"<app_token>"</span>)
|
|||
|
|
|||
|
<span class="co"># -------------------------------------------------- Many steps later</span>
|
|||
|
<span class="kw">compile_iss</span>()</code></pre></div>
|
|||
|
<p>Shiny apps compiled/installed this way will call the GitHub API on start up, and re-install every time there is an update to the GitHub repo’s most recent release tag. For public repos, you do not need to provide <code>auth_token</code>.</p>
|
|||
|
<div id="a-note-on-versions" class="section level3">
|
|||
|
<h3>A Note on Versions</h3>
|
|||
|
<p>A released version number consists of three numbers, <code>major.minor.patch</code>. <a href="http://semver.org/">Semantic Versioning 2.0.0</a> is a good specification to follow because <code>numeric_version</code> will interpret it correctly:</p>
|
|||
|
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r"><span class="kw">numeric_version</span>(<span class="st">"0.1.0"</span>) <span class="op">==</span><span class="st"> </span><span class="kw">numeric_version</span>(<span class="st">"0.1"</span>)</code></pre></div>
|
|||
|
<pre><code>## [1] TRUE</code></pre>
|
|||
|
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r"><span class="co"># First release!</span>
|
|||
|
<span class="kw">numeric_version</span>(<span class="st">"0.0.1"</span>) <span class="op">></span><span class="st"> </span><span class="kw">numeric_version</span>(<span class="st">"0.0.0.9000"</span>)</code></pre></div>
|
|||
|
<pre><code>## [1] TRUE</code></pre>
|
|||
|
<p>This is important because RInno determines the <code>local_version</code> of the app via <code>installed.packages()</code>. If R cannot parse the version correctly, the continuous installation will be… nonstop. Users will love you.</p>
|
|||
|
</div>
|
|||
|
</div>
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<!-- dynamically load mathjax for compatibility with self-contained -->
|
|||
|
<script>
|
|||
|
(function () {
|
|||
|
var script = document.createElement("script");
|
|||
|
script.type = "text/javascript";
|
|||
|
script.src = "https://mathjax.rstudio.com/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML";
|
|||
|
document.getElementsByTagName("head")[0].appendChild(script);
|
|||
|
})();
|
|||
|
</script>
|
|||
|
|
|||
|
</body>
|
|||
|
</html>
|