Skip to content
Framework

Workflow

spec_resolve()

Resolve a Project Spec from Layers

Merges spec layers into one complete project spec, the input to project_create(). This is the only implementation of the merge: the framework.pub cloud and the fw CLI send unmerged layers, and R resolves them.

Usage

spec_resolve(layers = list(), name, author = NULL, check = TRUE)

Arguments

Name Default Description
layers list()

A list of layers, bottom to top. Each element is either a layer (a named list in spec shape) or a list with kind, key, version, and layer, as in .framework/layers.json.

name

Project name. Overrides any name in the layers.

author NULL

Optional author list (name, email, affiliation, and optionally orcid, url, and affiliations). Non-empty fields override the layers' author; affiliations replaces the whole list.

check TRUE

If TRUE (default), stop when the resolved spec is invalid.

Value

The resolved spec as a named list. Attribute "conflicts" holds a data frame of keys set by more than one layer (path, layers).

Details

The package defaults for the project type are always the bottom layer. The given layers are applied on top, in order. The project type is taken from the last layer that sets type (default "project").

Merge rules:

  • Objects merge by key, and a later layer wins.
  • A key set to NULL (JSON null) removes it.
  • Entries of files, skills, extra_directories, packages$default_packages, connections$databases, and connections$storage_buckets are replaced whole, never merged field by field.
  • git$gitignore_content is concatenated, with a comment naming the layer each block came from. The base gitignore template is chosen after merging, from the project type and security$sensitive.
  • Empty lists are no-ops, so an empty JSON object and an empty JSON array mean the same thing.

Examples

spec <- spec_resolve(
  list(list(security = list(sensitive = TRUE))),
  name = "My study"
)
spec$security$sensitive

Search guides and reference for R, Python, Stata, the CLI, and Framework Cloud.