Skip to content

Commit

Permalink
Merge pull request #12 from KWB-R/dev
Browse files Browse the repository at this point in the history
Prepare next release
  • Loading branch information
hsonne authored May 5, 2024
2 parents e73075e + 4a4c250 commit e55bce9
Show file tree
Hide file tree
Showing 146 changed files with 2,747 additions and 476 deletions.
7 changes: 4 additions & 3 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,16 @@ jobs:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
R_REMOTES_NO_ERRORS_FROM_WARNINGS: true
RSPM: ${{ matrix.config.rspm }}
SERVERNAME: 'kwb-servername'

steps:
- uses: actions/checkout@v2

- uses: r-lib/actions/setup-r@master
- uses: r-lib/actions/setup-r@v2
with:
r-version: ${{ matrix.config.r }}

- uses: r-lib/actions/setup-pandoc@master
- uses: r-lib/actions/setup-pandoc@v2

- name: Query dependencies
run: |
Expand Down Expand Up @@ -76,7 +77,7 @@ jobs:

- name: Upload check results
if: failure()
uses: actions/upload-artifact@master
uses: actions/upload-artifact@v3
with:
name: ${{ runner.os }}-r${{ matrix.config.r }}-results
path: check
4 changes: 2 additions & 2 deletions .github/workflows/pkgdown.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ jobs:
steps:
- uses: actions/checkout@v2

- uses: r-lib/actions/setup-r@master
- uses: r-lib/actions/setup-r@v2

- uses: r-lib/actions/setup-pandoc@master
- uses: r-lib/actions/setup-pandoc@v2

- name: Query dependencies
run: |
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test-coverage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ jobs:
steps:
- uses: actions/checkout@v2

- uses: r-lib/actions/setup-r@master
- uses: r-lib/actions/setup-r@v2

- uses: r-lib/actions/setup-pandoc@master
- uses: r-lib/actions/setup-pandoc@v2

- name: Query dependencies
run: |
Expand Down
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@
.Rhistory
.RData
.Ruserdata
R/\.*
R/\.*
inst/doc
tests/testthat/Rplots.pdf
14 changes: 9 additions & 5 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: kwb.package
Title: Install / Unstall KWB Packages and Show Package Dependencies
Version: 0.3.0
Version: 0.4.0
Authors@R: c(
person("Hauke", "Sonnenberg", , "[email protected]", role = c("aut", "cre"),
comment = c(ORCID = "0000-0001-9134-2871")),
Expand All @@ -19,19 +19,23 @@ License: MIT + file LICENSE
URL: https://github.com/kwb-r/kwb.package
BugReports: https://github.com/kwb-r/kwb.package/issues
Imports:
devtools,
gh,
jsonlite,
kwb.utils (>= 0.5.0),
magrittr,
mvbutils,
networkD3,
remotes,
withr
Suggests:
covr,
pkgmeta
knitr,
pkgmeta,
rmarkdown,
testthat (>= 3.0.0)
Remotes:
github::kwb-r/kwb.utils,
github::kwb-r/pkgmeta
Encoding: UTF-8
RoxygenNote: 7.1.2
RoxygenNote: 7.3.1
VignetteBuilder: knitr
Config/testthat/edition: 3
28 changes: 24 additions & 4 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,35 +1,45 @@
# Generated by roxygen2: do not edit by hand

export("%>%")
export(addNodeLabels)
export(anglesToPoints)
export(archivedCranVersions)
export(compareInstalledVersions)
export(copyBasePackages)
export(cranVersions)
export(detachAllNonSystemPackages)
export(detachRecursively)
export(downloadGitHubPackage)
export(downloadPackagesFromSnapshot)
export(drawDependencies)
export(drawLink)
export(equidistantAngles)
export(exampleLinksAndNodes)
export(getAuthors)
export(getCranPackageDatabase)
export(getDependencyData)
export(getPackageFilesToInstall)
export(getPackageLicences)
export(getRVersionMajorMinor)
export(githubVersions)
export(gradToRad)
export(hasGplLicence)
export(initLocalCRAN)
export(installGithubPackages)
export(installRemotes)
export(installedDependencies)
export(installedKwbPackages)
export(packageDependencies)
export(packageDependenciesByType)
export(packageString)
export(plotAllDependencies)
export(plotDependencies)
export(plotNodes)
export(plotPackageVersions)
export(plotSankeyNetwork)
export(provideInLocalCRAN)
export(setOptionsForPackrat)
export(sortedDependencies)
export(stopIfNotInstalled)
export(systemPackages)
export(toLinksAndNodes)
export(toNodes)
Expand All @@ -38,23 +48,33 @@ importFrom(gh,gh)
importFrom(grDevices,rainbow)
importFrom(graphics,arrows)
importFrom(graphics,plot)
importFrom(kwb.utils,assignPackageObjects)
importFrom(kwb.utils,catAndRun)
importFrom(kwb.utils,catIf)
importFrom(kwb.utils,createDirectory)
importFrom(kwb.utils,defaultIfNA)
importFrom(kwb.utils,defaultIfNULL)
importFrom(kwb.utils,excludeNULL)
importFrom(kwb.utils,extractSubstring)
importFrom(kwb.utils,fullySorted)
importFrom(kwb.utils,getAttribute)
importFrom(kwb.utils,hsRenameColumns)
importFrom(kwb.utils,moveColumnsToFront)
importFrom(kwb.utils,get_homedir)
importFrom(kwb.utils,hsRestoreAttributes)
importFrom(kwb.utils,lastElement)
importFrom(kwb.utils,noFactorDataFrame)
importFrom(kwb.utils,noSuchElements)
importFrom(kwb.utils,orderBy)
importFrom(kwb.utils,rbindAll)
importFrom(kwb.utils,removeColumns)
importFrom(kwb.utils,renameColumns)
importFrom(kwb.utils,resetRowNames)
importFrom(kwb.utils,resolve)
importFrom(kwb.utils,runInDirectory)
importFrom(kwb.utils,safePath)
importFrom(kwb.utils,safeRowBind)
importFrom(kwb.utils,selectColumns)
importFrom(kwb.utils,selectElements)
importFrom(kwb.utils,stopFormatted)
importFrom(magrittr,"%>%")
importFrom(mvbutils,foodweb)
importFrom(networkD3,sankeyNetwork)
importFrom(remotes,github_remote)
Expand Down
54 changes: 54 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,57 @@
# Current Development

# [kwb.package 0.4.0](https://github.com/KWB-R/kwb.package/releases/tag/v0.4.0) <small>2024-05-05</small>

The following public functions were added:

- getAuthors()
- getCranPackageDatabase()
- getDependencyData()
- getPackageLicences()
- hasGplLicence()
- packageDependenciesByType()
- plotPackageVersions()
- sortedDependencies(): Was private before. The argument "pattern" is no longer
supported.
- stopIfNotInstalled()

The following public functions were modified:

- packageDependencies: add arguments "db", "which", "verbose"

The following public functions were deleted:

- drawLink(): It was a one-liner and only used once within the package

The following private functions were added:

- allDeps()
- draw_circles()
- map_to_range()
- pathDescription()
- polar_to_xy()
- readDescription()
- remotes_github_pat() -> remotes:::github_pat()
- remotes_parse_deps() -> remotes:::parse_deps()
- remotes_read_dcf() -> remotes:::read_dcf()
- remotes_untar_description() -> remotes:::untar_description()
- seq_rad_len()
- untarDescriptionFromUrl()

The following private functions were modified:

- cranVersions(): add argument "dbg"
- loadDescriptionFromArchiveUrl(): add argument "path"
- loadDescriptionFromWeb(): add arguments "path", "cache"
- readGithubPackageDescription: add argument "destdir"
- stop_(): rename to cleanStop()

Further changes:

- Add Tests
- Add vignette "Tutorial"
- Update GitHub action files (e.g. master -> v2)

# [kwb.package 0.3.0](https://github.com/KWB-R/kwb.package/releases/tag/v0.3.0) <small>2022-06-11</small>

* Harmonise with R package [kwb.pkgbuild](https://kwb-r.github.io/kwb.pkgbuild)
Expand Down
41 changes: 41 additions & 0 deletions R/allDeps.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# allDeps ----------------------------------------------------------------------
allDeps <- function(
name,
version = NA,
depth = 1L,
max_depth = 9L,
cache = list()
)
{
pkg <- loadDescriptionFromWeb(name, version)

stopifnot(is.na(version) || identical(version, pkg$version))

deps <- parsePackageDeps(pkg)

if (inherits(deps, "try-error") || nrow(deps) == 0L) {
return(NULL)
}

message("depth: ", depth)

deps$depth <- depth
deps$namever <- paste(name, version, sep = ":")

if (depth == max_depth) {
message("maximum depth (", max_depth, ") reached.")
return(deps)
}

child_deps <- lapply(seq_len(nrow(deps)), function(i) {
allDeps(deps$name[i], deps$version[i], depth + 1L, max_depth)
})

child_deps <- excludeNull(child_deps, dbg = FALSE)

if (length(child_deps) > 0L) {
deps <- rbind(deps, do.call(rbind, child_deps))
}

deps
}
75 changes: 4 additions & 71 deletions R/archivedCranVersions.R
Original file line number Diff line number Diff line change
@@ -1,76 +1,10 @@
# isOnCran ---------------------------------------------------------------------
isOnCran <- function(name)
{
nrow(currentCranVersion(name)) > 0L
}

# cranVersions -----------------------------------------------------------------
#' @noMd
#' @noRd
#' @keywords internal
#' @importFrom kwb.utils removeColumns safeRowBind
cranVersions <- function(name)
{
current <- currentCranVersion(name)

if (nrow(current) == 0L) {
message(sprintf("Package '%s' does not seem to be on CRAN.", name))
return(NULL)
}

archived <- archivedCranVersions(name)

current$package_source_url <- getUrl(
"cran_package_file", package = name, version = current$version
)

archived$package_source_url <- sprintf(
getUrl("cran_archive_file", package = name, package_filename = "%s"),
archived$archive_file
)

result <- kwb.utils::safeRowBind(archived, current)

kwb.utils::removeColumns(result, "archive_file")
}

# currentCranVersion -----------------------------------------------------------
#' @noMd
#' @noRd
#' @keywords internal
#' @importFrom kwb.utils noFactorDataFrame
currentCranVersion <- function(name)
{
src <- readLinesFromUrl(getUrl("cran_package", package = name))

if (is.null(src)) {
return(kwb.utils::noFactorDataFrame(
package = character(0L),
version = character(0L),
date = as.Date(character(0L)),
date_type = character(0L)
))
}

extract <- function(x) {
gsub("<td>|</td>", "", src[grep(sprintf("<td>%s:</td>", x), src) + 1L])
}

kwb.utils::noFactorDataFrame(
package = name,
version = extract("Version"),
date = as.Date(extract("Published")),
date_type = "published"
)
}
# archivedCranVersions ---------------------------------------------------------

#' archivedCranVersions --------------------------------------------------------
#' Archived CRAN versions
#'
#' @param package package name
#' @param ref_date default: NULL
#' @export
#' @importFrom kwb.utils extractSubstring noFactorDataFrame
#' @examples
#' packages <- c("ggplot2", "swmmr", "kwb.hantush")
#' archivedCranVersions(packages)
Expand All @@ -86,7 +20,7 @@ archivedCranVersions <- function(package, ref_date = NULL)
src <- readLinesFromUrl(getUrl("cran_archive", package = package))

if (is.null(src)) {
return(kwb.utils::noFactorDataFrame(
return(noFactorDataFrame(
package = character(0L),
version = character(0L),
date = as.Date(character(0L)),
Expand All @@ -99,7 +33,7 @@ archivedCranVersions <- function(package, ref_date = NULL)
"href=\"(%s_(.*)\\.tar\\.gz)\".*(\\d{4}-\\d{2}-\\d{2}) ", package
)

versions <- cbind(package = package, kwb.utils::extractSubstring(
versions <- cbind(package = package, extractSubstring(
pattern = pattern,
x = grep(pattern, src, value = TRUE),
index = c(
Expand All @@ -124,12 +58,11 @@ archivedCranVersions <- function(package, ref_date = NULL)
#' @noRd
#' @keywords internal
#' @importFrom utils tail
#' @importFrom kwb.utils resetRowNames
getLastVersionBefore <- function(version_dates, ref_date)
{
X = unname(split(version_dates, version_dates$package))

last_before <- function(x) utils::tail(x[x$date <= ref_date, ], 1L)

kwb.utils::resetRowNames(do.call(rbind, lapply(X, last_before)))
resetRowNames(do.call(rbind, lapply(X, last_before)))
}
Loading

0 comments on commit e55bce9

Please sign in to comment.