Learn R Programming

multideploy (version 0.1.0)

file_mapping: Create a file mapping for multi-repository deployment

Description

This function builds a mapping between local files and their target paths in repositories, supporting both individual file mapping and bulk directory processing.

Usage

file_mapping(
  ...,
  dir = NULL,
  pattern = NULL,
  target_prefix = "",
  preserve_structure = FALSE,
  quiet = FALSE
)

Value

Returns an object of class "file_mapping" (which is just a marked up "list") containing:

  • A named list where each entry maps a local file path (name) to a target repository path (value)

  • Each key is the full path to a local file

  • Each value is the corresponding path where the file should be placed in repositories

Arguments

...

Named arguments where names are local file paths and values are repository paths

dir

Character string specifying a directory to search for files. Default is NULL.

pattern

Character string with a regular expression pattern to match files in dir. Default is NULL.

target_prefix

Character string to prefix to all target paths. Default is "".

preserve_structure

Logical indicating whether to preserve directory structure in target. Default is FALSE.

quiet

Logical; if TRUE, suppresses information messages. Default is FALSE.

Details

The dir argument requires a valid directory path currently on the local filesystem. This directory is scanned for files matching the pattern regular expression, and each file is mapped to a target path in repositories. If the directory is not found, an error is thrown.

See Also

print.file_mapping() to display the mapping in a formatted way.

Examples

Run this code
# Map individual files with explicit source-to-target paths
mapping <- file_mapping(
  "local/path/ci.yml" = ".github/workflows/ci.yml",
  "local/path/lint.R" = ".lintr"
)

# Automatically map all R files from a directory to backup/R2/
workflow_mapping <- file_mapping(
  dir = system.file(package = "multideploy"),
  pattern = "\\.R$",
  target_prefix = "backup/R2/"
)

# Preserve directory structure when mapping files
template_mapping <- file_mapping(
  dir = system.file(package = "multideploy"),
  preserve_structure = TRUE
)

# Combine explicit mappings with directory-based mappings
combined_mapping <- file_mapping(
  "specific/file.R" = "R/functions.R",
  dir = system.file(package = "multideploy"),
  target_prefix = ".github/"
)

Run the code above in your browser using DataLab