| Title: | Facilitate Reproducible and Archived Projects |
|---|---|
| Description: | Facilitate reproducible and archived projects. |
| Authors: | Miguel Rodo [aut, cre] (ORCID: <https://orcid.org/0000-0002-2036-4878>) |
| Maintainer: | Miguel Rodo <[email protected]> |
| License: | file LICENSE |
| Version: | 0.5.1 |
| Built: | 2026-06-04 11:03:22 UTC |
| Source: | https://github.com/SATVILab/projr |
projr settings and do no checkA list of the active projr settings,
without doing any error checking.
Gets active projr settings, which merges settings and resolves conflicts
between local (_projr-local.yml), profile (_projr-<projr>.yml or as
_projr.yml)
and default (_projr.yml) settings.
Where there are conflicts, local settings has highest precedence
(i.e. are always preferred) and default settings have lowest precedence
(i.e. are never preferred).
.yml_get(profile).yml_get(profile)
profile |
character.
If supplied, the specific profile file to read in.
"default" loads |
A named list.
.yml_get.yml_check
.build_output' Builds project to output, which means recording the input and output data hashes, building the actual bookdown document and saving and archiving selected output.
.build_major, .build_minor and .build_patch are wrappers around .build_output with the version component
bumped set automatically, e.g. projr_build_major() is equivalent projr_build(bump_component = "major").
projr_build( bump_component, msg = NULL, args_engine = list(), profile = NULL, archive_github = FALSE, archive_local = FALSE, always_archive = TRUE, clear_output = NULL ) projr_build_major( msg = NULL, args_engine = list(), profile = NULL, archive_github = FALSE, archive_local = FALSE, always_archive = TRUE, clear_output = NULL ) projr_build_minor( msg = NULL, args_engine = list(), profile = NULL, archive_github = FALSE, archive_local = FALSE, always_archive = TRUE, clear_output = NULL ) projr_build_patch( msg = NULL, args_engine = list(), profile = NULL, archive_github = FALSE, archive_local = FALSE, always_archive = TRUE, clear_output = NULL )projr_build( bump_component, msg = NULL, args_engine = list(), profile = NULL, archive_github = FALSE, archive_local = FALSE, always_archive = TRUE, clear_output = NULL ) projr_build_major( msg = NULL, args_engine = list(), profile = NULL, archive_github = FALSE, archive_local = FALSE, always_archive = TRUE, clear_output = NULL ) projr_build_minor( msg = NULL, args_engine = list(), profile = NULL, archive_github = FALSE, archive_local = FALSE, always_archive = TRUE, clear_output = NULL ) projr_build_patch( msg = NULL, args_engine = list(), profile = NULL, archive_github = FALSE, archive_local = FALSE, always_archive = TRUE, clear_output = NULL )
bump_component |
"major", "minor", "patch" or missing. Specifies version component to increment. If missing, then is set equal to the lowest version component in used version format. No default (i.e. is missing by default). |
msg |
character.
Message to append to Git commit messages.
Default is |
args_engine |
list.
Arguments passed to the
rendering engine
( |
profile |
character.
|
archive_github |
|
archive_local |
|
always_archive |
logical.
If |
clear_output |
character. When to clear output directories: "pre" (before build, default), "post" (after build), or "never". Can also be set via PROJR_CLEAR_OUTPUT environment variable. |
Checks if all packages required for the current project build are installed. Returns structured information about missing packages and installation commands.
This is particularly useful in CI/CD environments where the installation commands need to be captured and executed programmatically.
projr_build_check_packages(profile = NULL)projr_build_check_packages(profile = NULL)
profile |
character.
|
A list with the following elements:
Logical. TRUE if all required packages are installed, FALSE otherwise.
Character vector of missing package names. Empty if all packages are available.
Character vector of R commands to install missing packages. Empty if all packages are available.
Character. Human-readable message about package status.
## Not run: # Check packages for current project pkg_status <- projr_build_check_packages() if (!pkg_status$available) { cat("Missing packages:", paste(pkg_status$missing, collapse = ", "), "\n") cat("Install commands:\n") cat(paste(pkg_status$install_cmds, collapse = "\n"), "\n") # In CI/CD, you could execute: # for (cmd in pkg_status$install_cmds) { # eval(parse(text = cmd)) # } } ## End(Not run)## Not run: # Check packages for current project pkg_status <- projr_build_check_packages() if (!pkg_status$available) { cat("Missing packages:", paste(pkg_status$missing, collapse = ", "), "\n") cat("Install commands:\n") cat(paste(pkg_status$install_cmds, collapse = "\n"), "\n") # In CI/CD, you could execute: # for (cmd in pkg_status$install_cmds) { # eval(parse(text = cmd)) # } } ## End(Not run)
Builds project to output, which means recording the input and output data hashes, building the actual bookdown document and saving and archiving selected output.
projr_build_dev( file = NULL, bump = FALSE, old_dev_remove = TRUE, args_engine = list(), profile = NULL, clear_output = "never" )projr_build_dev( file = NULL, bump = FALSE, old_dev_remove = TRUE, args_engine = list(), profile = NULL, clear_output = "never" )
file |
character vector. Paths to files to build. Paths may be relative to project root, or absolute. Default is NULL, in which case all files are built. |
bump |
logical.
Whether to increment dev version for build.
Default is |
old_dev_remove |
logical.
If |
args_engine |
list.
Arguments passed to the
rendering engine
( |
profile |
character.
|
clear_output |
character. When to clear output directories: "pre" (before build), "post" (after build), or "never" (default for dev builds). Can also be set via PROJR_CLEAR_OUTPUT environment variable. |
Cat useful information. .cat_changelog':
projr_cat_changelog(n_row = 10)projr_cat_changelog(n_row = 10)
n_row |
integer. Number of rows to cat. |
Activate environment variables by reading default values from a set of files.
If file is NULL,
all existing files are used in order of decreasing priority:
first _environment.local (machine-specific overrides),
then any _environment-<profile> files (profile-specific),
and finally _environment (global defaults).
The profiles activated are those set in the QUARTO_PROFILE
and the PROJR_PROFILE environment variables, with
QUARTO_PROFILE priorities.
The QUARTO_PROFILE variable can specify multiple profiles,
separated by commas.
The PROJR_PROFILE variable can also specify multiple profiles,
separated by either commas or semi-colons.
In both cases, the earlier profile takes precedence, e.g.
QUARTO_PROFILE=test,basic will activate the test profile first.
projr_env_set(file = NULL)projr_env_set(file = NULL)
file |
character vector.
Paths to files with environment variables to activate.
If provided, only these files will be read; otherwise the default set
( |
Invisibly returns TRUE if any files were successfully activated,
or FALSE if none existed.
# Activate only the local overrides ## Not run: projr_env_set("_environment.local") ## End(Not run) # Activate all available defaults in the standard order ## Not run: projr_env_set() ## End(Not run)# Activate only the local overrides ## Not run: projr_env_set("_environment.local") ## End(Not run) # Activate all available defaults in the standard order ## Not run: projr_env_set() ## End(Not run)
.gitignore and .Rbuildignore
These functions allow manual addition of files and directories to the
.gitignore and .Rbuildignore files, outside of the automatic management
provided by the projr package.
projr_ignore: General function to add both files and directories
to both .gitignore and .Rbuildignore. If a path does not exist, it is
treated as a file.
projr_ignore_dir: Specifically adds directories to both .gitignore
and .Rbuildignore.
projr_ignore_file: Specifically adds files to both .gitignore
and .Rbuildignore.
projr_ignore_dir_git and projr_ignore_file_git: Add
directories or files explicitly to .gitignore.
projr_ignore_dir_rbuild and projr_ignore_file_rbuild: Add
directories or files explicitly to .Rbuildignore.
projr_ignore(ignore, force_create = TRUE) projr_ignore_dir(ignore, force_create = TRUE) projr_ignore_file(ignore) projr_ignore_file_git(ignore, force_create = TRUE) projr_ignore_dir_git(ignore, force_create = TRUE) projr_ignore_file_rbuild(ignore, force_create = TRUE) projr_ignore_dir_rbuild(ignore, force_create = TRUE)projr_ignore(ignore, force_create = TRUE) projr_ignore_dir(ignore, force_create = TRUE) projr_ignore_file(ignore) projr_ignore_file_git(ignore, force_create = TRUE) projr_ignore_dir_git(ignore, force_create = TRUE) projr_ignore_file_rbuild(ignore, force_create = TRUE) projr_ignore_dir_rbuild(ignore, force_create = TRUE)
ignore |
A character vector of file or directory paths to be ignored. Paths must be valid non-empty strings. |
force_create |
logical.
If |
These functions provide fine-grained control for cases where users want to
manually ignore specific paths permanently. They do not interact with the
automated ignore management system of projr.
Non-existent paths provided to projr_ignore are assumed to be files.
For .gitignore, directories are automatically appended with /** if
missing, ensuring proper Git ignore syntax.
For .Rbuildignore, paths are converted to regular expressions using
glob2rx for compatibility with R's build tools.
Invisibly returns TRUE if the operation succeeds, or FALSE if the input
contains invalid (empty) paths.
projr_ignore_auto for dynamically managed ignore entries, and projr_unignore_manual
for forcing certain paths to not be ignored.
# Manually ignore files and directories projr_ignore(c("output", "tempfile.log")) # Specifically ignore directories projr_ignore_dir("data") # Specifically ignore files projr_ignore_file("README.md")# Manually ignore files and directories projr_ignore(c("output", "tempfile.log")) # Specifically ignore directories projr_ignore_dir("data") # Specifically ignore files projr_ignore_file("README.md")
.gitignore and .Rbuildignore with projr-managed ignoresThe projr_ignore_auto()function updates the project’s.gitignoreand.Rbuildignore' files to reflect directories and files managed by
projr, as well as
other directories and files that should
clearly be ignored.
They are kept up-to-date with the project's configuration,
and are written within a demarcated section of the file.
projr_ignore_auto()projr_ignore_auto()
Called primarily for its side effects (modifying
.gitignore and/or .Rbuildignore). Returns TRUE invisibly.
.ignore_add.ignore_add_git.ignore_add_rbuild
## Not run: projr_ignore_auto() ## End(Not run)## Not run: projr_ignore_auto() ## End(Not run)
This function performs a full initialization of a projr project. It sets up the project structure by creating directories, generating a README (in Markdown or R Markdown format), configuring a renv environment, writing a DESCRIPTION file, applying a license (if provided), setting up citation files, creating a projr configuration YAML file, establishing literate documentation, and configuring both Git and GitHub repositories.
projr_init_github( user = NULL, org = NULL, public = FALSE, create_repo = TRUE, git_commit = TRUE ) projr_init( git = TRUE, git_commit = TRUE, github = TRUE, github_public = FALSE, github_user = NULL, github_org = NULL, dir = TRUE, readme = TRUE, readme_rmd = TRUE, desc = FALSE, license = NULL, projr_yml = FALSE, lit_doc = NULL ) projr_init_all( github = TRUE, github_org = NULL, license = NULL, lit_doc = NULL ) projr_init_renv(bioc = TRUE) projr_init_cite() projr_init_git(commit = TRUE) projr_init_license(license, first_name, last_name) projr_init_ignore()projr_init_github( user = NULL, org = NULL, public = FALSE, create_repo = TRUE, git_commit = TRUE ) projr_init( git = TRUE, git_commit = TRUE, github = TRUE, github_public = FALSE, github_user = NULL, github_org = NULL, dir = TRUE, readme = TRUE, readme_rmd = TRUE, desc = FALSE, license = NULL, projr_yml = FALSE, lit_doc = NULL ) projr_init_all( github = TRUE, github_org = NULL, license = NULL, lit_doc = NULL ) projr_init_renv(bioc = TRUE) projr_init_cite() projr_init_git(commit = TRUE) projr_init_license(license, first_name, last_name) projr_init_ignore()
user |
Character or \codeNULL (for \codeprojr_init_github). GitHub username to use when creating the remote; if \codeNULL the token owner is used. Defaults to \codeNULL. |
org |
Character or \codeNULL (for \codeprojr_init_github). GitHub organisation to use when creating the remote. Defaults to \codeNULL. |
public |
Logical (for |
create_repo |
Logical. If |
git_commit |
Logical. If |
git |
Logical. If |
github |
Logical. If |
github_public |
Logical. If |
github_user, github_org
|
Character or |
dir |
Logical. If |
readme |
Logical. If |
readme_rmd |
Logical. If |
desc |
Logical. If |
license |
Character or |
projr_yml |
Logical. If |
lit_doc |
Character or |
bioc |
Logical (for \codeprojr_init_renv). If \codeTRUE, includes Bioconductor packages in the renv setup. Defaults to \codeTRUE. |
commit |
Logical (for \codeprojr_init_git). If \codeTRUE, commits the initial changes to the Git repository. Defaults to \codeTRUE. |
first_name |
Character (for |
last_name |
Character (for |
username |
Character or |
The projr_init function is a wrapper that calls several helper functions to
perform the following tasks:
Prevent working directory errors by ensuring the usethis project is set.
Create project directories.
Generate a README file (in Markdown or R Markdown format).
Initialize a renv environment, optionally with Bioconductor support.
Write a DESCRIPTION file for project metadata.
Apply a specified license.
Configure citation files (if a DESCRIPTION file exists).
Create a projr configuration YAML file.
Set up literate documentation in the chosen format.
Initialize Git (and optionally commit initial changes).
Create a GitHub repository if requested.
Invisibly returns TRUE if initialization is successful, or FALSE if
a particular step is skipped.
Initialise project
projr_init_prompt( yml_path_from = NULL, renv_force = FALSE, renv_bioconductor = TRUE, public = FALSE )projr_init_prompt( yml_path_from = NULL, renv_force = FALSE, renv_bioconductor = TRUE, public = FALSE )
yml_path_from |
character.
Path to YAML file to use as |
renv_force |
Logical.
Passed to |
renv_bioconductor |
Logical.
Whether |
public |
logical.
Whether the GitHub repo created (if any)
is public or not.
Default is |
.init_renviron
Set environment variables for projr_init.
When set, projr_init will use these variables
to provide options to populate the metadata.
This function creates the .Renviron file
for the user if it does not exist.
It then adds the variables to the .Renviron file
without any values set.
projr_init_renviron()projr_init_renviron()
Print easy-to-follow, step-by-step instructions for authorisation to GitHub.
projr_instr_auth_github()projr_instr_auth_github()
Creates LICENSE files in directories without adding license configuration
to _projr.yml. This allows manual editing of licenses without them being
overwritten during builds. If a license configuration exists in the YAML
for a directory, it will take precedence and overwrite the manual license.
projr_license_create_manual( type, labels = NULL, authors = NULL, year = NULL, profile = "default" )projr_license_create_manual( type, labels = NULL, authors = NULL, year = NULL, profile = "default" )
type |
character. License type. Supported types: "CC-BY", "CC0", "Apache-2.0", "MIT", "Proprietary". |
labels |
character vector. Directory labels to create licenses for. If NULL, creates for all raw data directories (raw-data, cache). |
authors |
character vector. Authors or copyright holders. If NULL, attempts to get from DESCRIPTION file or uses "Project Authors" as default. |
year |
integer. Copyright year. If NULL, uses current year. |
profile |
character. Profile to use. Default is "default". |
Invisible character vector of labels where licenses were created.
## Not run: # Create MIT license in raw-data directory projr_license_create_manual("MIT", "raw-data") # Create CC-BY license in all raw data directories projr_license_create_manual("CC-BY") # Create with custom authors projr_license_create_manual( "Apache-2.0", "raw-data", authors = c("Jane Doe", "John Smith"), year = 2024 ) ## End(Not run)## Not run: # Create MIT license in raw-data directory projr_license_create_manual("MIT", "raw-data") # Create CC-BY license in all raw data directories projr_license_create_manual("CC-BY") # Create with custom authors projr_license_create_manual( "Apache-2.0", "raw-data", authors = c("Jane Doe", "John Smith"), year = 2024 ) ## End(Not run)
Delete build logs based on specified criteria.
projr_log_clear( build_type = "all", history = TRUE, output = TRUE, before_date = NULL, before_version = NULL )projr_log_clear( build_type = "all", history = TRUE, output = TRUE, before_date = NULL, before_version = NULL )
build_type |
Character. Either "output", "dev", or "all". Default is "all". |
history |
Logical. Clear history files. Default is TRUE. |
output |
Logical. Clear output log files. Default is TRUE. |
before_date |
Character. Clear logs before this date (YYYY-MM-DD). Default is NULL (no date filter). |
before_version |
Character. Clear logs before this version. Default is NULL (no version filter). |
Display the last N lines of a detailed build log file.
projr_log_view( log_file = NULL, build_type = "auto", n_lines = 10, show_header = TRUE )projr_log_view( log_file = NULL, build_type = "auto", n_lines = 10, show_header = TRUE )
log_file |
Character. Path to a log file. If NULL, the most recent log file across both output and dev builds will be used. To view a specific build type, use the build_type parameter. |
build_type |
Character. Either "output", "dev", or "auto" (default). When "auto", selects the most recent log across both types. When "output" or "dev", selects the most recent log of that specific type. |
n_lines |
Integer. Number of lines to show from the end of the file. Default is 10. Set to NULL or NA to show the entire file. |
show_header |
Logical. Whether to print a short header including the logfile path and last modification time. Default is TRUE. |
Query which files changed between two project versions based on the manifest. Returns files that were added, modified, or removed between the versions.
Query which files changed across a range of versions. For each file, shows the version where it last changed.
Query when files in each directory last changed. Shows the most recent version where any file in the directory was modified.
projr_manifest_changes(version_from = NULL, version_to = NULL, label = NULL) projr_manifest_range(version_start = NULL, version_end = NULL, label = NULL) projr_manifest_last_change(version = NULL)projr_manifest_changes(version_from = NULL, version_to = NULL, label = NULL) projr_manifest_range(version_start = NULL, version_end = NULL, label = NULL) projr_manifest_last_change(version = NULL)
version_from |
character. Starting version (e.g., "0.0.1" or "v0.0.1"). If NULL, uses the earliest version in the manifest. |
version_to |
character. Ending version (e.g., "0.0.2" or "v0.0.2"). If NULL, uses the current project version. |
label |
character. Optional directory label to filter by. |
version_start |
character. Starting version (inclusive). If NULL, uses earliest version. |
version_end |
character. Ending version (inclusive). If NULL, uses current version. |
version |
character. Version to query. If NULL, uses current project version. |
A data.frame with columns:
Directory label
File path relative to directory
Type of change: "added", "modified", or "removed"
File hash in version_from (NA for added files)
File hash in version_to (NA for removed files)
Returns a 0-row data.frame if no changes found.
A data.frame with columns:
Directory label
File path relative to directory
First version where file appeared
Last version where file was modified
Current file hash
A data.frame with columns:
Directory label
Most recent version with changes
Number of files in directory at this version
## Not run: # Query changes between v0.0.1 and v0.0.2 projr_manifest_changes("0.0.1", "0.0.2") # Query changes in output directory only projr_manifest_changes("0.0.1", "0.0.2", label = "output") # Query changes from earliest version to current projr_manifest_changes() ## End(Not run) ## Not run: # Query all changes from v0.0.1 to current projr_manifest_range("0.0.1") # Query changes in a specific range projr_manifest_range("0.0.1", "0.0.5") ## End(Not run) ## Not run: # Query last changes for current version projr_manifest_last_change() # Query last changes as of v0.0.5 projr_manifest_last_change("0.0.5") ## End(Not run)## Not run: # Query changes between v0.0.1 and v0.0.2 projr_manifest_changes("0.0.1", "0.0.2") # Query changes in output directory only projr_manifest_changes("0.0.1", "0.0.2", label = "output") # Query changes from earliest version to current projr_manifest_changes() ## End(Not run) ## Not run: # Query all changes from v0.0.1 to current projr_manifest_range("0.0.1") # Query changes in a specific range projr_manifest_range("0.0.1", "0.0.5") ## End(Not run) ## Not run: # Query last changes for current version projr_manifest_last_change() # Query last changes as of v0.0.5 projr_manifest_last_change("0.0.5") ## End(Not run)
Query when a specific file last changed in the manifest. Returns the most recent version where the file's hash was different from the previous version, or when it first appeared.
Check if a specific file changed between two versions. Returns TRUE if the file's hash is different between the versions, was added, or was removed.
Get all versions where a specific file changed or appeared. Returns a chronological list of all versions in the manifest where the file's hash is different from the previous version.
Get the version when a specific file first appeared in the manifest.
projr_manifest_file_last_change(fn, label = NULL, version_end = NULL) projr_manifest_file_changed( fn, label = NULL, version_from = NULL, version_to = NULL ) projr_manifest_file_history(fn, label = NULL) projr_manifest_file_first(fn, label = NULL)projr_manifest_file_last_change(fn, label = NULL, version_end = NULL) projr_manifest_file_changed( fn, label = NULL, version_from = NULL, version_to = NULL ) projr_manifest_file_history(fn, label = NULL) projr_manifest_file_first(fn, label = NULL)
fn |
character. File path relative to the directory (e.g., "data.csv", "subdir/file.txt"). |
label |
character. Directory label (e.g., "output", "raw-data"). If NULL, searches all directories for the file. |
version_end |
character. End version to search up to. If NULL, uses current project version. |
version_from |
character. Starting version (e.g., "0.0.1" or "v0.0.1"). If NULL, uses the earliest version in the manifest. |
version_to |
character. Ending version (e.g., "0.0.2" or "v0.0.2"). If NULL, uses the current project version. |
A data.frame with columns:
Directory label
File path
Version when file last changed
Current file hash at that version
Returns a 0-row data.frame if file not found.
A data.frame with columns:
Directory label
File path
Logical - TRUE if file changed
Type of change: "added", "modified", "removed", or "unchanged"
File hash in version_from (NA for added files)
File hash in version_to (NA for removed files)
Returns a 0-row data.frame if file not found in either version.
A data.frame with columns:
Directory label
File path
Version where file changed or appeared
File hash at this version
Type of change: "first_appearance", "modified", or "current"
Returns a 0-row data.frame if file not found.
A data.frame with columns:
Directory label
File path
Version when file first appeared
File hash at first appearance
Returns a 0-row data.frame if file not found.
## Not run: # Query when a specific file last changed projr_manifest_file_last_change("data.csv", label = "output") # Search all directories for a file projr_manifest_file_last_change("report.pdf") ## End(Not run) ## Not run: # Check if a file changed between versions projr_manifest_file_changed("data.csv", "output", "0.0.1", "0.0.2") # Check against current version projr_manifest_file_changed("data.csv", "output", "0.0.1") ## End(Not run) ## Not run: # Get full history for a file projr_manifest_file_history("data.csv", label = "output") # Search all directories projr_manifest_file_history("config.yml") ## End(Not run) ## Not run: # Get when a file first appeared projr_manifest_file_first("data.csv", label = "output") # Search all directories projr_manifest_file_first("README.md") ## End(Not run)## Not run: # Query when a specific file last changed projr_manifest_file_last_change("data.csv", label = "output") # Search all directories for a file projr_manifest_file_last_change("report.pdf") ## End(Not run) ## Not run: # Check if a file changed between versions projr_manifest_file_changed("data.csv", "output", "0.0.1", "0.0.2") # Check against current version projr_manifest_file_changed("data.csv", "output", "0.0.1") ## End(Not run) ## Not run: # Get full history for a file projr_manifest_file_history("data.csv", label = "output") # Search all directories projr_manifest_file_history("config.yml") ## End(Not run) ## Not run: # Get when a file first appeared projr_manifest_file_first("data.csv", label = "output") # Search all directories projr_manifest_file_first("README.md") ## End(Not run)
Get project parameters from param key
in projr configuration.
projr_par_get(..., profile = NULL) projr_param_get(..., profile = NULL)projr_par_get(..., profile = NULL) projr_param_get(..., profile = NULL)
... |
character.
Sequential names to specify path in list.
For example, .param_get("a", "b") |
profile |
character.
If |
Returns path to projr profile-specific directory.
Differs from projr_dir_get in that it does not assume
that the path is to a directory.
Will create the parent directory of the specified
path if it does not exist, and ignore it
if requested by _projr.yml.
projr_path_get( label, ..., create = TRUE, relative = FALSE, absolute = FALSE, safe = TRUE )projr_path_get( label, ..., create = TRUE, relative = FALSE, absolute = FALSE, safe = TRUE )
label |
character.
One of |
... |
Specifies sub-path of directory returned. |
create |
logical.
If |
relative |
logical.
If |
absolute |
logical.
If |
safe |
logical.
If |
DETAILS
Character. Path to directory requested.
## Not run: if (interactive()) { # EXAMPLE1 } ## End(Not run)## Not run: if (interactive()) { # EXAMPLE1 } ## End(Not run)
projr build cache directoryGet the cache directory for projr builds.
It is a sub-directory of the cache directory.
For development builds (.build_dev), this is the final directory for outputanddocs items. For output builds (.build_output), this is the staging
directory. After the documents are rendered, they are copied
to their final directories.
.path_get_cache_build assumes the path is to a file, whereas .path_get_cache_build_dir assumes the path
is to a directory.
This distinctiion is only relevant when create = TRUE, as it
determines what directory is attempted to be created.
projr_path_get_cache_build_dir(..., create = FALSE, profile) projr_path_get_cache_build(..., create = FALSE, profile)projr_path_get_cache_build_dir(..., create = FALSE, profile) projr_path_get_cache_build(..., create = FALSE, profile)
... |
comma-separated strings specified initially the
label (e.g. |
create |
logical.
If |
profile |
character.
The name of the |
character.
Path to the cache (sub-)directory for projr builds.
.path_get.path_get_dir
Returns path to projr profile-specific directory.
Also creates the directory if it does not exist, and
ignores it if requested by _projr.yml.
projr_path_get_dir( label, ..., create = TRUE, relative = FALSE, absolute = FALSE, safe = TRUE )projr_path_get_dir( label, ..., create = TRUE, relative = FALSE, absolute = FALSE, safe = TRUE )
label |
character.
One of |
... |
Specifies sub-directory of directory returned.
Passed to |
create |
logical.
If |
relative |
logical.
If |
absolute |
logical.
If |
safe |
logical.
If |
Character. Path to directory requested.
Creates a new projr profile that can override
settings in _projr.yml.
If the associated file does not exists, it
creates a blank file.
The file is ignored from the R build process and, if
it is the local profile, from Git as well.
projr_profile_create(profile)projr_profile_create(profile)
profile |
character.
Name of the profile.
If not supplied, then the profile is named |
Invisibly returns TRUE if the file was created,
and FALSE if the file already exists.
.profile_create_local.profile_get
projr profileCreate a projr profile with highest precedence
(i.e. its settings overwrite any others) that is
ignored by Git.
projr_profile_create_local()projr_profile_create_local()
Note that if any setting in _projr-local.yml is empty,
then a lower-precendence file's setting
(i.e. from _projr-<profile>.yml or _projr.yml) is used.
Empty settings are by default indicated by ~.
.profile_create_local.yml_get
Deletes a projr profile from _projr.yml
and/or its corresponding _projr-<profile>.yml file.
projr_profile_delete(profile)projr_profile_delete(profile)
profile |
character.
|
invisible(TRUE).
projr settings file.Deletes _projr-local.yml file.
projr_profile_delete_local()projr_profile_delete_local()
Get active projr profile(s).
projr_profile_get()projr_profile_get()
Note that local and default are not returned, but are always active (if
they exist).
local corresponds to _projr-local.yml and default to _projr.yml.
Character vector of length equal to number of active profiles.
Functions to manage the restoration and updating of packages specified in the renv lockfile.
.renv_restore()': Restores packages from the lockfile, attempting to install the lockfile versions.
.renv_update()': Updates packages to their latest available versions, ignoring the lockfile versions.
.renv_restore_and_update()': First restores packages from the lockfile, then updates them to the latest versions.
projr_renv_restore( github = TRUE, non_github = TRUE, biocmanager_install = FALSE ) projr_renv_update( github = TRUE, non_github = TRUE, biocmanager_install = FALSE ) projr_renv_restore_and_update( github = TRUE, non_github = TRUE, biocmanager_install = FALSE )projr_renv_restore( github = TRUE, non_github = TRUE, biocmanager_install = FALSE ) projr_renv_update( github = TRUE, non_github = TRUE, biocmanager_install = FALSE ) projr_renv_restore_and_update( github = TRUE, non_github = TRUE, biocmanager_install = FALSE )
github |
Logical. Whether to process GitHub packages. Default is |
non_github |
Logical. Whether to process non-GitHub packages (CRAN and Bioconductor). Default is |
biocmanager_install |
Logical.
If |
Control whether to process GitHub packages, non-GitHub packages (CRAN and Bioconductor), or both using the github and non_github arguments.
Invisibly returns TRUE upon successful completion.
## Not run: # Restore all packages projr_renv_restore() # Update all packages projr_renv_update() # Restore and then update all packages projr_renv_restore_and_update() # Only restore non-GitHub packages projr_renv_restore(github = FALSE) # Only update GitHub packages projr_renv_update(non_github = FALSE) ## End(Not run)## Not run: # Restore all packages projr_renv_restore() # Update all packages projr_renv_update() # Restore and then update all packages projr_renv_restore_and_update() # Only restore non-GitHub packages projr_renv_restore(github = FALSE) # Only update GitHub packages projr_renv_update(non_github = FALSE) ## End(Not run)
Tests renv::restore() without using the cache in
a clean, temporary environment.
Automatically creates a temporary project directory, initializes renv,
copies required files, disables the cache via
.Rprofile, and then performs renv::restore().
Afterwards, it deletes the first library path where renv restored packages.
Note:
To ensure isolation, the test runs in a directory that is completely separate
from the parent project and executes Rscript with the --vanilla option.
The --vanilla flag seems essential to prevent the project
renv settings from being affected by testing.
projr_renv_test(files_to_copy = NULL, delete_lib = TRUE)projr_renv_test(files_to_copy = NULL, delete_lib = TRUE)
files_to_copy |
character vector.
Paths to files to copy into the temporary directory before restoring.
Note that |
delete_lib |
Logical.
If |
TRUE if renv::restore() succeeds, FALSE otherwise.
Use projr_content_update() to restore all artefacts needed for the current project.
If the project isn't available locally yet,
projr_restore_repo() will clone it and then restore its artefacts.
projr_restore_repo( repo, path = NULL, label = NULL, pos = NULL, type = NULL, title = NULL ) projr_restore_repo_wd( repo, label = NULL, pos = NULL, type = NULL, title = NULL ) projr_content_update( label = NULL, pos = NULL, type = NULL, title = NULL, clear = FALSE )projr_restore_repo( repo, path = NULL, label = NULL, pos = NULL, type = NULL, title = NULL ) projr_restore_repo_wd( repo, label = NULL, pos = NULL, type = NULL, title = NULL ) projr_content_update( label = NULL, pos = NULL, type = NULL, title = NULL, clear = FALSE )
repo |
character. GitHub repository ( |
path |
character or NULL. Local path for cloning the repository. Default is |
label |
character vector or NULL. Specifies labels of artefacts to restore.
Default is |
pos |
character vector or NULL. Specifies preferred source: |
type |
character or NULL. Remote type: |
title |
character or NULL. Remote title as specified in |
clear |
logical. If |
These functions restore artefact directories from remote sources:
projr_content_update() restores artefacts in an existing local project without any cloning required.
Requires a manifest.csv file in the project root.
projr_restore_repo() clones a GitHub repository into a subdirectory (or specified path),
then restores artefacts from that repository's remote sources.
projr_restore_repo_wd() clones directly into the current working directory, then restores artefacts.
Input Validation: All parameters are validated before execution:
label: Must be NULL or a non-empty character vector of valid directory labels
pos: Must be NULL or contain only "source" and/or "dest"
type: Must be NULL or one of "local" or "github"
title: Must be NULL or a single character string
repo: Must be a single non-empty character string
path: Must be NULL or a single non-empty character string
Error Handling: The functions handle errors gracefully:
Missing manifest.csv triggers an informative error
Invalid labels or missing remote sources result in warning messages and skipped restoration
Git clone failures are caught and reported
Errors during restoration are caught per label, allowing partial success
Invisibly returns TRUE if all restorations are successful, FALSE otherwise.
For projr_content_update(), returns FALSE if no labels are found to restore or if any
restoration fails. For projr_restore_repo(), returns FALSE if cloning or
restoration fails.
## Not run: # Restore all raw artefacts in existing local project projr_content_update() # Restore specific labels projr_content_update(label = c("raw-data", "cache")) # Restore from specific source type projr_content_update(type = "local", title = "archive") # Clone repository into subdirectory and restore artefacts projr_restore_repo("owner/repo") # Clone to specific path projr_restore_repo("owner/repo", path = "my-project") # Clone repository into current directory and restore artefacts projr_restore_repo_wd("owner/repo") ## End(Not run)## Not run: # Restore all raw artefacts in existing local project projr_content_update() # Restore specific labels projr_content_update(label = c("raw-data", "cache")) # Restore from specific source type projr_content_update(type = "local", title = "archive") # Clone repository into subdirectory and restore artefacts projr_restore_repo("owner/repo") # Clone to specific path projr_restore_repo("owner/repo", path = "my-project") # Clone repository into current directory and restore artefacts projr_restore_repo_wd("owner/repo") ## End(Not run)
.gitignore and .Rbuildignore
These functions allow manual addition of files and directories to the
.gitignore and .Rbuildignore files after the projr-managed block,
thereby forcing them to be not ignored.
.unignore_manual: General function to unignore both files and directories in both .gitignoreand.Rbuildignore'. If a path does not
exist, it is treated as a file.
.unignore_manual_dir: Specifically unignores directories in both .gitignoreand.Rbuildignore'.
.unignore_manual_file: Specifically unignores files in both .gitignoreand.Rbuildignore'.
.unignore_manual_dir_git and .unignore_manual_file_git: Add
directories or files explicitly (with a ! prefix) to .gitignore.
.unignore_manual_dir_rbuild and .unignore_manual_file_rbuild:
Add directories or files explicitly (with a ! prefix) to .Rbuildignore.
projr_unignore_manual(unignore) projr_unignore_manual_dir(unignore) projr_unignore_manual_file(unignore) projr_unignore_manual_file_git(unignore) projr_unignore_manual_dir_git(unignore) projr_unignore_manual_file_rbuild(unignore) projr_unignore_manual_dir_rbuild(unignore)projr_unignore_manual(unignore) projr_unignore_manual_dir(unignore) projr_unignore_manual_file(unignore) projr_unignore_manual_file_git(unignore) projr_unignore_manual_dir_git(unignore) projr_unignore_manual_file_rbuild(unignore) projr_unignore_manual_dir_rbuild(unignore)
unignore |
A character vector of file or directory paths to be unignored. Paths must be valid non-empty strings. |
These functions provide fine-grained control for cases where users want to
undo any ignoring behavior for specific paths permanently. They do not
interact with the automated ignore management system of projr.
Non-existent paths provided to .unignore_manual' are assumed to be files.
For .gitignore, unignored directories are automatically appended with
/** if missing, then prepended with !, ensuring proper Git unignore
syntax.
For .Rbuildignore, paths are converted to regular expressions using
glob2rx(), and then prepended with ! for compatibility with R's build
tools.
Invisibly returns TRUE if the operation succeeds, or FALSE if the input
contains invalid (empty) paths.
.ignore_manual for manually ignoring paths, and .ignore_auto for
dynamically managed ignore entries.
# Manually unignore files and directories projr_unignore_manual(c("output", "tempfile.log")) # Specifically unignore directories projr_unignore_manual_dir("data") # Specifically unignore files projr_unignore_manual_file("README.md")# Manually unignore files and directories projr_unignore_manual(c("output", "tempfile.log")) # Specifically unignore directories projr_unignore_manual_dir("data") # Specifically unignore files projr_unignore_manual_file("README.md")
projr drop-in replacement for usethis::use_datausethis::use_data always saves data to data/, which
conflicts with the temporary directories used by .build_dev'
and makes it difficult to restore after failed output builds.
.use_datais a drop-in replacement forusethis::use_data, which saves data to the temporary directory when safe = TRUE'.
This makes it easier to restore the project after a failed output build.
The only other difference is that .use_datainvisibly returns the path to the saved data file, whereasusethis::use_datareturnsTRUE'.
projr_use_data( ..., internal = FALSE, overwrite = FALSE, compress = "bzip2", version = 2, ascii = FALSE, safe = TRUE )projr_use_data( ..., internal = FALSE, overwrite = FALSE, compress = "bzip2", version = 2, ascii = FALSE, safe = TRUE )
... |
Unquoted names of existing objects to save. |
internal |
If If |
overwrite |
By default, .use_data() |
compress |
Choose the type of compression used by |
version |
The serialization format version to use. The default, 2, was the default format from R 1.4.0 to 3.5.3. Version 3 became the default from R 3.6.0 and can only be read by R versions 3.5.0 and higher. |
ascii |
if |
safe |
logical.
Whether to save data to a temporary directory
(in |
Taken directly from the documentation for the original
usethis function, and adjusted slightly.
The data chapter of R Packages.
## Not run: x <- 1:10 y <- 1:100 projr_use_data(x, y) # For external use projr_use_data(x, y, internal = TRUE) # For internal use ## End(Not run)## Not run: x <- 1:10 y <- 1:100 projr_use_data(x, y) # For external use projr_use_data(x, y, internal = TRUE) # For internal use ## End(Not run)
Returns project version
projr_version_get()projr_version_get()
Character.
Sets the project version manually in the DESCRIPTION file and optionally in a VERSION file.
This is useful in cases where you need to increment the version manually, for example,
if a collaborator has pushed changes and you want to manually set your version before merging.
projr_version_set(version, only_if_exists = TRUE)projr_version_set(version, only_if_exists = TRUE)
version |
A character string specifying the version to set. It may include a development component (e.g., "1.2.3-dev") or just the stable version (e.g., "1.2.3"). |
only_if_exists |
A logical flag indicating whether to update the |
Invisibly returns TRUE if successful.
projr settings.Checks correctness of active projr settings.
projr_yml_check(profile = NULL)projr_yml_check(profile = NULL)
profile |
character(). Profile whose file needs to be checked. If not supplied, then the merged profile is used. Default is NULL. |
Returns TRUE if all checks pass.
Otherwise throws an error.
.yml_cite_setsets the citation options in_projr.yml'.
The options are:
codemeta: whether to generate a codemeta.json file.
cff: whether to generate a CITATION.cff file. Indexable by GitHub and Zenodo.
inst-citation:
whether to generate a CITATION file in the inst/ directory.
If the project is installed as an R package,
then citation data can be generated by
citation(package = <project_name>).
The default is to leave all the settings unchanged.
If these settings are not setting in _projr.yml,
then the default is to not generate any citation files.
.yml_cite_set_default sets all citation options to default (FALSE').
projr_yml_cite_set( all = NULL, codemeta = NULL, cff = NULL, inst_citation = NULL, simplify_identical = TRUE, simplify_default = TRUE, profile = "default" ) projr_yml_cite_set_default( profile = "default", simplify_identical = TRUE, simplify_default = TRUE )projr_yml_cite_set( all = NULL, codemeta = NULL, cff = NULL, inst_citation = NULL, simplify_identical = TRUE, simplify_default = TRUE, profile = "default" ) projr_yml_cite_set_default( profile = "default", simplify_identical = TRUE, simplify_default = TRUE )
all |
logical.
If not |
codemeta |
logical.
Whether to generate a codemeta.json file.
If |
cff |
logical.
Whether to generate a CITATION.cff file.
If |
inst_citation |
logical.
Whether to generate a CITATION file in the inst/ directory.
If |
simplify_identical |
logical.
If |
simplify_default |
logical.
If |
profile |
character.
The profile to write to.
Default is "default", in which case it writes to |
## Not run: # set all to TRUE projr_yml_cite_set(all = TRUE) # set all to FALSE projr_yml_cite_set(all = FALSE) # set only cff to FALSE projr_yml_cite_set(cff = FALSE) # revert to defaults projr_yml_cite_set() ## End(Not run)## Not run: # set all to TRUE projr_yml_cite_set(all = TRUE) # set all to FALSE projr_yml_cite_set(all = FALSE) # set only cff to FALSE projr_yml_cite_set(cff = FALSE) # revert to defaults projr_yml_cite_set() ## End(Not run)
Add a GitHub release as a destination to a _projr.yml file.
projr_yml_dest_add_github( title, content, structure = NULL, overwrite = TRUE, send_cue = NULL, send_strategy = NULL, send_inspect = NULL, profile = "default" )projr_yml_dest_add_github( title, content, structure = NULL, overwrite = TRUE, send_cue = NULL, send_strategy = NULL, send_inspect = NULL, profile = "default" )
title |
character.
Title of the GitHub release.
Can use title as |
content |
character vector.
Labels of directories to include in the upload.
Options are the labels of directories
in the active |
structure |
"latest" or "archive". Structure of the remote. Default is NULL. |
overwrite |
logical. Whether to rewrite an existing entry. Default is TRUE. |
send_cue |
"always", "if-change" or "never". When to send to the remote. Default is NULL. |
send_strategy |
"upload-all", "upload-missing", "sync-purge" or "sync-diff". How to synchronise to the remote. Default is NULL. |
send_inspect |
"manifest" , "file" or "none". What to look at to find files on the remote. Default is NULL. |
profile |
character. Profile to write the settings to. Default is "default". |
Add a local directory as a destination to a _projr.yml file.
projr_yml_dest_add_local( title, content, path, structure = NULL, overwrite = TRUE, send_cue = NULL, send_strategy = NULL, send_inspect = NULL, profile = "default" )projr_yml_dest_add_local( title, content, path, structure = NULL, overwrite = TRUE, send_cue = NULL, send_strategy = NULL, send_inspect = NULL, profile = "default" )
title |
character.
The name of the directory.
Has no effect besides helping structure |
content |
character vector.
Labels of directories to include in the upload.
Options are the labels of directories
in the active |
path |
character. Path to the directory. If a relative path is given, then it is taken as relative to the project home directory. Must be supplied. |
structure |
"latest" or "archive".
Structure of the remote.
If "latest", then |
overwrite |
logical.
Whether to rewrite an existing entry of the same
title in the specified |
send_cue |
"always", "if-change" or "never". When to send to the remote. Default is NULL. |
send_strategy |
"upload-all", "upload-missing", "sync-purge" or "sync-diff". How to synchronise to the remote. Default is NULL. |
send_inspect |
"manifest" , "file" or "none". What to look at to find what are the files on the remote, and their versions. Default is NULL. |
profile |
character.
Profile to write the settings to.
If "default", then written to |
Get license configuration for a specific directory label from _projr.yml.
projr_yml_dir_license_get(label, profile = "default")projr_yml_dir_license_get(label, profile = "default")
label |
character. Directory label (e.g., "output", "raw-data", "docs", "cache"). |
profile |
character. Profile to use. Default is "default". |
License configuration (character or list) or NULL if no license is configured.
## Not run: # Get license for output directory projr_yml_dir_license_get("output") ## End(Not run)## Not run: # Get license for output directory projr_yml_dir_license_get("output") ## End(Not run)
Remove license configuration for a specific directory label from _projr.yml.
projr_yml_dir_license_rm(label, profile = "default")projr_yml_dir_license_rm(label, profile = "default")
label |
character. Directory label (e.g., "output", "raw-data", "docs", "cache"). |
profile |
character. Profile to use. Default is "default". |
Invisible TRUE if license configuration was removed.
## Not run: # Remove license configuration for output directory projr_yml_dir_license_rm("output") ## End(Not run)## Not run: # Remove license configuration for output directory projr_yml_dir_license_rm("output") ## End(Not run)
Set license configuration for a specific directory label in _projr.yml.
Licenses are automatically generated during builds.
projr_yml_dir_license_set( type, label, authors = NULL, year = NULL, profile = "default" )projr_yml_dir_license_set( type, label, authors = NULL, year = NULL, profile = "default" )
type |
character. License type. Supported types: "CC-BY", "CC0", "Apache-2.0", "MIT", "Proprietary". Common variations are also accepted (e.g., "ccby", "apache", "mit"). |
label |
character. Directory label (e.g., "output", "raw-data", "docs", "cache"). |
authors |
character vector. Authors or copyright holders. If NULL, attempts to get from DESCRIPTION file or uses "Project Authors" as default. |
year |
integer. Copyright year. If NULL, uses current year. |
profile |
character. Profile to use. Default is "default". |
Invisible TRUE if license was set successfully.
## Not run: # Simple format - just license type projr_yml_dir_license_set("CC-BY", "output") # Full format with custom authors and year projr_yml_dir_license_set( "MIT", "raw-data", authors = c("Jane Doe", "John Smith"), year = 2024 ) # Set license for multiple directories projr_yml_dir_license_set("Apache-2.0", "output") projr_yml_dir_license_set("Apache-2.0", "docs") ## End(Not run)## Not run: # Simple format - just license type projr_yml_dir_license_set("CC-BY", "output") # Full format with custom authors and year projr_yml_dir_license_set( "MIT", "raw-data", authors = c("Jane Doe", "John Smith"), year = 2024 ) # Set license for multiple directories projr_yml_dir_license_set("Apache-2.0", "output") projr_yml_dir_license_set("Apache-2.0", "docs") ## End(Not run)
Regenerates LICENSE files for directories with existing license configurations, using authors from the DESCRIPTION file. This is useful after updating package authors or for propagating authors to raw data directories.
projr_yml_dir_license_update(labels = NULL, profile = "default")projr_yml_dir_license_update(labels = NULL, profile = "default")
labels |
character vector. Directory labels to update. If NULL (default), updates all directories with license configurations. |
profile |
character. Profile to use. Default is "default". |
Invisible character vector of labels that were updated.
## Not run: # Update all directories with license configurations projr_yml_dir_license_update() # Update specific directories projr_yml_dir_license_update(c("raw-data", "output")) ## End(Not run)## Not run: # Update all directories with license configurations projr_yml_dir_license_update() # Update specific directories projr_yml_dir_license_update(c("raw-data", "output")) ## End(Not run)
projr_yml_dir_path_set sets the path for a directory label in the project.
projr_yml_dir_path_rm removes the custom path setting for a directory,
reverting to default behavior.
projr_yml_dir_path_set(label, path, profile = "default") projr_yml_dir_path_rm(label, profile = "default")projr_yml_dir_path_set(label, path, profile = "default") projr_yml_dir_path_rm(label, profile = "default")
label |
character. Directory label to configure (e.g., "output", "raw-data", "cache"). Must be a valid directory label. |
path |
character. Path to the directory. |
profile |
character.
Profile to modify.
If |
## Not run: # Set path for output directory projr_yml_dir_path_set("output", "_my_output") # Set path for cache directory projr_yml_dir_path_set("cache", "_my_cache") # Revert to default path projr_yml_dir_path_rm("output") ## End(Not run)## Not run: # Set path for output directory projr_yml_dir_path_set("output", "_my_output") # Set path for cache directory projr_yml_dir_path_set("cache", "_my_cache") # Revert to default path projr_yml_dir_path_rm("output") ## End(Not run)
projr settings and checks for validityGets active projr settings, which merges settings and resolves conflicts
between local (_projr-local.yml), profile (_projr-<projr>.yml or as
_projr.yml)
and default (_projr.yml) settings.
Where there are conflicts, local settings has highest precedence
(i.e. are always preferred) and default settings have lowest precedence
(i.e. are never preferred).
Note that an error is thrown if the active settings are invalid.
projr_yml_get(profile = NULL, check = FALSE)projr_yml_get(profile = NULL, check = FALSE)
profile |
character.
|
check |
logical.
Whether to check the validity of the settings.
Default is |
A named list, if the settings are valid.
.yml_get_unchecked.yml_check
.yml_git_set' sets Git options for the project.
The options are:
commit: whether to commit changes automatically upon project builds.
add_untracked: whether to add untracked files automatically upon project builds.
push: whether to push changes automatically upon project builds.
The default is to leave all the settings unchanged.
If these settings are not setting in _projr.yml,
then the default is to commit, add untracked files and push.
.yml_git_set_default sets all Git options to default (TRUE').
projr_yml_git_set( all = NULL, commit = NULL, add_untracked = NULL, push = NULL, simplify_identical = TRUE, simplify_default = TRUE, profile = "default" ) projr_yml_git_set_default( profile = "default", simplify_identical = TRUE, simplify_default = TRUE )projr_yml_git_set( all = NULL, commit = NULL, add_untracked = NULL, push = NULL, simplify_identical = TRUE, simplify_default = TRUE, profile = "default" ) projr_yml_git_set_default( profile = "default", simplify_identical = TRUE, simplify_default = TRUE )
all |
logical.
Whether to set all the options
to |
commit |
logical.
Whether to commit changes automatically upon
project builds.
If |
add_untracked |
logical.
Whether to add untracked files automatically upon
project builds.
If |
push |
logical.
Whether to push changes automatically upon
project builds.
If |
simplify_identical |
logical.
If |
simplify_default |
logical.
If |
profile |
character.
Profile to add the script to.
If |
## Not run: # set all to TRUE projr_yml_git_set(all = TRUE) # set all to FALSE projr_yml_git_set(all = FALSE) # set only add_untracked to FALSE projr_yml_git_set(add_untracked = FALSE) # revert to defaults projr_yml_git_set_default() ## End(Not run)## Not run: # set all to TRUE projr_yml_git_set(all = TRUE) # set all to FALSE projr_yml_git_set(all = FALSE) # set only add_untracked to FALSE projr_yml_git_set(add_untracked = FALSE) # revert to defaults projr_yml_git_set_default() ## End(Not run)
Convenience functions to add or remove hooks to run before or after the build.
projr_yml_hooks_add: Add hook script(s) to run before or after the build.
projr_yml_hooks_rm_all: Remove all hooks.
projr_yml_hooks_add_pre: Add hook(s) to run before the build.
projr_yml_hooks_add_post: Add hook(s) to run after the build.
projr_yml_hooks_add(path, stage, overwrite = TRUE, profile = "default") projr_yml_hooks_rm_all(profile = "default") projr_yml_hooks_add_pre(path, overwrite = TRUE, profile = "default") projr_yml_hooks_add_post(path, overwrite = TRUE, profile = "default")projr_yml_hooks_add(path, stage, overwrite = TRUE, profile = "default") projr_yml_hooks_rm_all(profile = "default") projr_yml_hooks_add_pre(path, overwrite = TRUE, profile = "default") projr_yml_hooks_add_post(path, overwrite = TRUE, profile = "default")
path |
character vector. Path(s) to hook scripts, relative to project root (if not absolute). |
stage |
"pre", "post", or "both".
Whether to run the hook before the build ("pre"),
after the build ("post"), or in both stages ("both").
Hooks with stage "pre" are stored under |
overwrite |
logical.
Whether to overwrite existing hooks or append to them.
Default is |
profile |
character.
Profile to add the hook to.
If |
Within a stage (pre- or post-build), hooks
are run in the order specified in _projr.yml.
They are not run in the same environment as the
build process.
The pre-build hooks are run immediately after
bumping the project version (if that is done) and immediately
before committing the present state of the code to Git.
The post-build hooks are run immediately after
committing the present state of the code to Git,
and before distributing project artifacts to the remotes.
Hooks are stored as simple character vectors in the YAML:
build:
hooks:
pre: ["pre-hook.R"]
post: ["post-hook.R"]
both: ["both-hook.R"]
parameters keyAdd the parameters key to the projr configuration.
projr_yml_par_add(profile = "default")projr_yml_par_add(profile = "default")
profile |
character.
If |
projr_yml_renv_set sets renv snapshot options for the project.
The option controls whether renv::snapshot() is called
before and after project builds.
If the setting is not present in _projr.yml,
then the default is TRUE (renv snapshots are performed).
projr_yml_renv_set(renv = NULL, simplify_default = TRUE, profile = "default")projr_yml_renv_set(renv = NULL, simplify_default = TRUE, profile = "default")
renv |
logical.
Whether to snapshot renv before and after builds.
If |
simplify_default |
logical.
If |
profile |
character.
Profile to add the setting to.
If |
## Not run: # enable renv snapshots (default) projr_yml_renv_set(TRUE) # disable renv snapshots projr_yml_renv_set(FALSE) # revert to default (removes setting from YAML) projr_yml_renv_set(TRUE, simplify_default = TRUE) ## End(Not run)## Not run: # enable renv snapshots (default) projr_yml_renv_set(TRUE) # disable renv snapshots projr_yml_renv_set(FALSE) # revert to default (removes setting from YAML) projr_yml_renv_set(TRUE, simplify_default = TRUE) ## End(Not run)
projr_yml_restrictions_set sets build restrictions in _projr.yml.
The options are:
branch: controls which branches can perform builds.
If TRUE (default), builds are allowed on any branch.
If a character vector, builds are only allowed on matching branches.
If FALSE, builds are restricted (treated as empty character vector).
not_behind: whether to check if branch is behind remote upstream.
If TRUE (default), build fails if branch is behind remote.
If FALSE, no check is performed.
projr_yml_restrictions_set( branch = NULL, not_behind = NULL, profile = "default" )projr_yml_restrictions_set( branch = NULL, not_behind = NULL, profile = "default" )
branch |
logical or character.
Controls which branches can perform builds.
If |
not_behind |
logical.
Controls whether to check if branch is behind remote upstream.
If |
profile |
character.
The profile to write to.
Default is "default", in which case it writes to |
## Not run: # Allow builds on any branch (default) projr_yml_restrictions_set(branch = TRUE) # Allow builds only on main and dev branches projr_yml_restrictions_set(branch = c("main", "dev")) # Restrict builds on all branches projr_yml_restrictions_set(branch = FALSE) # Disable check for being behind remote projr_yml_restrictions_set(not_behind = FALSE) # Enable check for being behind remote (default) projr_yml_restrictions_set(not_behind = TRUE) ## End(Not run)## Not run: # Allow builds on any branch (default) projr_yml_restrictions_set(branch = TRUE) # Allow builds only on main and dev branches projr_yml_restrictions_set(branch = c("main", "dev")) # Restrict builds on all branches projr_yml_restrictions_set(branch = FALSE) # Disable check for being behind remote projr_yml_restrictions_set(not_behind = FALSE) # Enable check for being behind remote (default) projr_yml_restrictions_set(not_behind = TRUE) ## End(Not run)
Convenience functions to add or remove scripts to run before or after the build.
.yml_script_add': Add a script to run before or after the build.
.yml_script_rm': Remove scripts to run.
.yml_script_add_pre and .yml_script_add_post
are wrappers around .yml_script_addthat set thestageargument to"pre"or"post", respectively. .yml_script_rm_all removes all scripts.
projr_yml_script_add( path, title, stage, cue = NULL, overwrite = TRUE, profile = "default" ) projr_yml_script_rm(title, path = NULL, profile = "default") projr_yml_script_rm_all(profile = "default") projr_yml_script_add_pre( path, title, cue = NULL, overwrite = TRUE, profile = "default" ) projr_yml_script_add_post( path, title, cue = NULL, overwrite = TRUE, profile = "default" )projr_yml_script_add( path, title, stage, cue = NULL, overwrite = TRUE, profile = "default" ) projr_yml_script_rm(title, path = NULL, profile = "default") projr_yml_script_rm_all(profile = "default") projr_yml_script_add_pre( path, title, cue = NULL, overwrite = TRUE, profile = "default" ) projr_yml_script_add_post( path, title, cue = NULL, overwrite = TRUE, profile = "default" )
path |
character vector. Path(s) to scripts, relative to project root (if not absolute). |
title |
character.
Title for set of scripts.
Initial and trailing spaces are removed, and
the middle spaces are converted to dashes.
For example, |
stage |
"pre" or "post". Whether to run the script before or after the build. |
cue |
"build", "dev", "patch", "minor" or "major". Which minimum build level triggers the scripts. "build" and "dev" are equivalent, and always trigger the scripts. |
overwrite |
logical.
Whether to overwrite any script settings
of the same title in the |
profile |
character.
Profile to add the script to.
If |
Within a stage (pre- or post-build), scripts
are run in the order set in _projr.yml.
They are not run in the same environment as the
build process.
The pre-build scripts are run immediately after
bumping the project version (if that is done) and immediately
before committing the present state of the code to Git.
The post-build scripts are run immediately after
committing the present state of the code to Git,
and before distributing project artefacts to the remotes.