Skip to content

Instantly share code, notes, and snippets.

@BroVic
Created January 12, 2023 16:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BroVic/02e359e3610c9ab24e455ded9d3efbd0 to your computer and use it in GitHub Desktop.
Save BroVic/02e359e3610c9ab24e455ded9d3efbd0 to your computer and use it in GitHub Desktop.
A PowerShell script for controlling various actions relating to the RQDAassist project
<#
.SYNOPSIS
Control various actions to be taken on the RQDAassist repository/package.
.DESCRIPTION
The RQDAassist package repository in more complicated that some regular CRAN-compatible packages.
For instance, the RQDA packages and its dependencies have to be regularly cleaned up for tests
to be carried out on both binary and source installation options. Also, at this point, the package
is only working with R versions lower than 4.2. So when developing, one has to always remember to
use that version, when it's not the one pointed to by PATH. This script makes it easy to carry out
these and other related tasks.
.PARAMETER Type
One of 'Binary' (the default) or 'Source'.
.PARAMETER CleanOnly
Uninstall RQDA and its dependencies
.PARAMETER Install
Install RQDA and its dependencies.
.PARAMETER Check
Run R CMD check only, using the latest version of the package. No installation is performed
.LINK
https://github.com/BroVic/RQDAassist
.NOTES
Author: Victor A. Ordu
Last Edit: 2023-01-12
Version 1.0.0 - Initial release
#>
param (
[string]$Type = "Binary",
[Parameter(HelpMessage = "Uninstall RQDA and its dependencies to start afresh")]
[switch]$CleanOnly,
[Parameter(HelpMessage = "Run R CMD check on the package")]
[switch]$Check,
[Parameter(HelpMessage = "Install RQDA and dependencies via the helper package")]
[switch]$Install
)
# Path to executable of R version to use
$Rpath = "C:/Program Files/R/R-4.1.3/bin/x64"
$Rexec = Join-Path -Path $Rpath -ChildPath "Rscript.exe"
$Rcmd = Join-Path -Path $Rpath -ChildPath "Rcmd.exe"
if (-not (Test-Path $Rexec)) {
Write-Host "R 4.1.3 does not exist on this system"
exit
}
if ($CleanOnly) {
& $Rexec -e "pp <- c('cairoDevice', 'gWidgets', 'RGtk2', 'gWidgetsRGtk2', 'igraph', 'RQDA')" `
-e "avail <- pp %in% .packages(all = TRUE); if (any(avail)) remove.packages(pp[avail])"
}
if ($Install) {
$arg = $Type.ToLower()
& $Rexec -e "if (!requireNamespace('remotes')) install.packages('remotes', repos = 'https://cran.rstudio.com')" `
-e "if (!requireNamespace('RQDAassist')) remotes::install_github('BroVic/RQDAassist')" `
-e "RQDAassist::install(type = '$arg', verbose = TRUE)"
}
if ($Check) {
& $Rcmd check --as-cran --no-manual RQDAassist_0.5.3.9004.tar.gz
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment