Package 'cynkrathis'

Title: Simplify Project Scaffolding and Common 'renv' Related Tasks
Description: Opionionated {renv} helper package by cynkra GmbH.
Authors: Patrick Schratz [aut, cre] , Kirill Müller [aut]
Maintainer: Patrick Schratz <[email protected]>
License: MIT + file LICENSE
Version: 0.3.4
Built: 2024-09-07 02:37:09 UTC
Source: https://github.com/cynkra/cynkrathis

Help Index


Deployment helpers for internal minicran packages

Description

[Experimental]

Builds and deploys a local package to a git repository in a CRAN like structure.

The resulting git repository can then be served via RStudio Connect and accessed as an additional repository next to the main CRAN repository (by setting it via options(repos = )). RStudio Connect can crawl the repository in a defined internal when deploying the git repository via "Import from git". Changes (i.e. new package versions) are picked up automatically.

This is an alternative to hosting and using a private instance of RStudio Package Manager.

The function executes the following tasks:

  • Build a tarball of the package via pkgbuild::build().

  • Add the built package in a CRAN like structure to a temporary git clone of the upstream git repository via drat. “

  • Render (and create if missing) the drat package website.

  • Commit and push the changes to the git repository.

Usage

deploy_minicran_package(drat_repo, commit_message = NULL, dry_run = FALSE)

Arguments

drat_repo

⁠[character]⁠
The git repository to deploy to. Can be any git vendor.

commit_message

⁠[character]⁠
An optional git commit message. If not supplied, the message will be of the form ⁠Update <pkg> to version <version>⁠ with the values inferred from the DESCRIPTION file.

dry_run

⁠[logical]⁠
When TRUE, the final git commit/push steps are skipped.

Examples

## Not run: 

deploy_minicran_package(drat_repo = "https://github.com/myuser/mydratrepo.git")

## End(Not run)

Return metadata for cynkra RSPM snapshots

Description

A list of curated cynkra RStudio Package Manager snapshot IDs and their metadata.

Usage

get_snapshots()

Write fully equipped gitignore files

Description

By making use of the gitignore.io API.

Usage

init_gitignore(commit = TRUE)

Arguments

commit

⁠[logical]⁠
Whether to automatically commit the newly created files.


Initialize lintr config

Description

Initialize lintr config

Usage

init_lintr()

Use precommit with that project

Description

Use precommit with that project

Usage

init_precommit(commit = TRUE)

Arguments

commit

⁠[logical]⁠
Whether to automatically commit the newly created files.


Initialize renv infrastructure (cynkra way)

Description

[Experimental]

Initializes renv setup by setting a predefined RStudio Package Manager (RSPM) snapshot. Custom RSPM Snapshots can be configured via snapshot_date.

Usage

init_renv(snapshot_date = NULL, exclude = NULL, convenience_pkgs = FALSE)

Arguments

snapshot_date

⁠[Date]⁠
A valid RSPM snapshot date. By default the "recommended" date from get_snapshots() for the respective R version is chosen.

exclude

⁠[character]⁠
Packages to exclude from renv::install(). Useful if a package is not available in the available repositories (check with ⁠getOption("repos"⁠) to prevent init_renv() to fail. This should only be a temporary workaround - consider making local packages available in a minicran-like repository.

convenience_pkgs

⁠[logical]⁠
Install additional opinionated convenience packages? The following packages would be installed:

  • usethis

  • styler

  • gert

  • krlmlr/fledge

Details

During the process, the latest CRAN version of renv will be installed, regardless of the chosen snapshot ID.

The heuristic for setting the correct RSPM binary repo currently only supports Windows, macOS and Ubuntu 20.04.

The initialization mostly runs in clean vanilla sessions started with callr::r_vanilla().

Examples

## Not run: 
init_renv()

## End(Not run)

Initialize tic CI structure

Description

Initialize tic CI structure

Usage

init_tic(commit = TRUE)

Arguments

commit

⁠[logical]⁠
Whether to automatically commit the newly created files.


Downgrade an renv project to a specific RSPM snapshot

Description

[Experimental]

This functions aims to be used within a "snapshot-centered project workflow" and can be used to downgrade all packages to an RSPM snapshot listed in renv.lock.

While the main purpose is downgrade packages which exist in a higher version, this function can also be used to restore a clean state of the project library outside of a downgrade scenario. Be aware of the handling of packages installed from remote sources (see section "Downgrading behavior").

Under the hood, it records all packages installed in the renv project library and restores these with the RSPM snapshot found in Line 7 of renv.lock.

Usage

renv_downgrade()

Value

Called for its side-effect.

Downgrading behavior 🚧️

There are important differences to be aware of when downgrading packages with respect to their installation source:

  1. If a package is not available on CRAN, renv_downgrade() will restore the version from the remote source just fine.

  2. If a package is available on CRAN and a remote snapshot (e.g. from GitHub) was referenced in renv.lock, renv_downgrade() will downgrade this package to its CRAN version of the respective snapshot and not keep the remote snapshot version.

See Also

renv_switch_r_version()

Examples

## Not run: 
renv_downgrade()

## End(Not run)

Build a local package and install it into an renv project

Description

[Experimental]

This is a wrapper around pkgbuild::build() and renv::install() to more easily make local packages available within renv projects.

The following steps are performed:

  1. Building the package found at argument path via pkgbuild::build().

  2. Moving the built source into the renv cache. The cache location is determined by Sys.getenv("RENV_PATHS_LOCAL").

  3. Installing the package from the cache location via renv::install().

Usage

renv_install_local(path = ".", quiet = FALSE, ...)

Arguments

path

⁠[character]⁠
The path to the package which should be built and installed.

quiet

⁠[logical]⁠
Whether to suppress console output.

...


Passed down to pkgbuild::build().


Switch between R versions in renv projects

Description

This function switches between R versions in renv projects which follow the 'cynkra RSPM snapshot' logic. This means that each R version is tied to a specific RSPM snapshot.

The function executes the following tasks:

  • Replace the R Version in renv.lock.

  • Replace the RSPM snapshot in renv.lock with the one associated with the selected R Version.

  • (optional) execution of renv::update().

  • (optional) execution of renv::snapshot().

Usage

renv_switch_r_version(version = NULL)

Arguments

version

⁠[character]⁠
The R version to upgrade to.

Value

TRUE (invisibly)

See Also

get_snapshots

Examples

## Not run: 
renv_switch_r_version("4.0.4")

## End(Not run)

Install Aviator for a repository

Description

Aviator is a GitHub app that provides a merge queue. Compared to GitHub's native merge queue, it does not require branch protection.

This function:

  • installs the Aviator app for a repository (FIXME)

  • creates a default configuraton and pushes it to the main branch

Usage

use_aviator()