Skip to content

Commit

Permalink
init version
Browse files Browse the repository at this point in the history
  • Loading branch information
jangorecki committed Oct 28, 2022
0 parents commit 14a9a8a
Show file tree
Hide file tree
Showing 9 changed files with 176 additions and 0 deletions.
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
^\.github$
55 changes: 55 additions & 0 deletions .github/workflows/pkgup.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# permissions and concurrency settings for GitHub Pages
permissions:
contents: read
pages: write
id-token: write
concurrency:
group: "pages"
cancel-in-progress: true

on: [push]
jobs:
build:
name: pkgup
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: r-lib/actions/setup-pandoc@v2
- uses: r-lib/actions/setup-r@v2
- name: build
run: |
R CMD build .
- name: check
run: |
R CMD check --as-cran $(ls -1t pkgup_*.tar.gz | head -n 1)
- name: manual
if: github.ref == 'refs/heads/master'
run: |
mkdir library
R_LIBS="library" R CMD INSTALL $(ls -1t pkgup_*.tar.gz | head -n 1) --html
mkdir -p doc/html
cp /usr/share/R/doc/html/{left.jpg,up.jpg,Rlogo.svg,R.css,index.html} doc/html
Rscript -e 'utils::make.packages.html("library", docdir="doc")'
sed -i "s|file://|../..|g" doc/html/packages.html
mkdir -p public
mv doc public
cp -r --parents library/*/{html,help,DESCRIPTION,README,NEWS,README.md,NEWS.md} public 2>/dev/null
echo '<!DOCTYPE html>\n<html><head><meta http-equiv="refresh" content="0; url=library/pkgup/html/00Index.html"><title>HTTP redirect</title></head><body></body></html>' > public/index.html
- name: repo
if: github.ref == 'refs/heads/master'
run: |
mkdir -p public/src/contrib
mv $(ls -1t pkgup_*.tar.gz | head -n 1) public/src/contrib
Rscript -e 'tools::write_PACKAGES("public/src/contrib")'
- name: upload
if: github.ref == 'refs/heads/master'
uses: actions/upload-pages-artifact@v1
with:
path: "public"
- name: deploy
if: github.ref == 'refs/heads/master'
id: deployment
uses: actions/deploy-pages@v1
10 changes: 10 additions & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Package: pkgup
Version: 0.0.1
Title: Package release
Authors@R: c(
person("Jan","Gorecki", role=c("aut","cre"), email="[email protected]"))
Description: Lightweight release of R packages on github.
License: GPL-2
URL: https://jangorecki.github.io/pkgup
BugReports: https://github.com/jangorecki/pkgup/issues

3 changes: 3 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export(installcmd)
S3method(print, installcmd)

22 changes: 22 additions & 0 deletions R/pkgup.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
dcf.field = function(dcf, field) {
if (field %in% colnames(dcf))
trimws(strsplit(gsub("\n", " ", dcf[,field][[1L]], fixed=TRUE), ",")[[1L]])
else
character()
}

installcmd = function(pkg = "pkgup") {
dcf = read.dcf(system.file("DESCRIPTION", package=pkg))
pkg = dcf[,"Package"][[1L]]
repos = grep("github.io", dcf.field(dcf, "URL"), value=TRUE)
if (length(repos) > 1L) repos = repos[1L] ## take first github.io url
repos = c(repos, dcf.field(dcf, "Additional_repositories"))
repos = unique(c(repos, getOption("repos"))) ## could omit if package.dcf returns length 0
x = sprintf('install.packages("%s", repos=c(%s))', pkg, paste0('"', repos, '"', collapse=","))
class(x) = "installcmd"
x
}

print.installcmd = function(x, ...) {
cat(unclass(x), "\n", sep="")
}
30 changes: 30 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
pkgup
----

Example package to present lightweight configuration for a complete R package release.
- [x] R package repository
- [x] html manual
- [ ] html vignettes

[R package website](https://jangorecki.github.io/pkgup)

----

Installation
----

```r
install.packages("pkgup", repos="https://jangorecki.github.io/pkgup")
```

Usage
----


```r
library(pkgup)

installcmd()
```

See `.github/workflows/pkgup.yaml`
20 changes: 20 additions & 0 deletions man/installcmd.Rd
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
\name{installcmd}
\alias{installcmd}
\title{ Installation command }
\description{
Function generates installation command for a given installed package. Installation command points to a github page of a package.
}
\usage{
installcmd(pkg = "pkgup")
}
\arguments{
\item{pkg}{ Character, default \code{"pkgup"}. A package name for which we want to generate installation command. }
}
\value{
Object of class \code{installcmd} is returned.
}
\seealso{\code{\link{print.installcmd}}}
\examples{
installcmd("pkgup")
}
\keyword{ data }
22 changes: 22 additions & 0 deletions man/print.installcmd.Rd
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
\name{print.installcmd}
\alias{print.installcmd}
\title{ susy installcmd method }
\description{
Prints installation command for \code{installcmd} object.
}
\usage{
\method{print}{installcmd}(x, \dots)
}
\arguments{
\item{x}{ An \code{installcmd} object. }
\item{\dots}{ Ignored. }
}
\value{
Returns \code{x} invisibly. Display output to console as a side effect.
}
\seealso{\code{\link{installcmd}}}
\examples{
cmd = installcmd("pkgup")
print(cmd)
}
\keyword{ data }
13 changes: 13 additions & 0 deletions tests/tests.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
library(pkgup)

cmd = installcmd()

stopifnot(all.equal(
unclass(cmd),
'install.packages("pkgup", repos=c("https://jangorecki.github.io/pkgup","https://cloud.r-project.org"))'
))

stopifnot(all.equal(
capture.output(print(cmd)),
'install.packages("pkgup", repos=c("https://jangorecki.github.io/pkgup","https://cloud.r-project.org"))'
))

0 comments on commit 14a9a8a

Please sign in to comment.