write out a codemeta.json file for a given package. This function is basically a wrapper around create_codemeta() to both create the codemeta object and write it out to a JSON-LD-formatted file in one command. It can also be used simply to write out to JSON-LD any existing object created with create_codemeta().

write_codemeta(pkg = ".", path = "codemeta.json", root = ".",
  id = NULL, use_filesize = FALSE,
  force_update = getOption("codemeta_force_update", TRUE),
  use_git_hook = FALSE, verbose = TRUE, ...)

Arguments

pkg

package path to package root, or package name, or description file (character), or a codemeta object (list)

path

file name of the output, leave at default "codemeta.json"

root

if pkg is a codemeta object, optionally give the path to package root. Default guess is current dir.

id

identifier for the package, e.g. a DOI (or other resolvable URL)

use_filesize

whether to try to estimating and adding a filesize by using base::files.ize(). Files in .Rbuildignore are ignored.

force_update

Update guessed fields even if they are defined in an existing codemeta.json file

use_git_hook

Whether to create a pre-commit hook requiring codemeta.json to be updated when DESCRIPTION is changed. Default is FALSE to avoid an unwanted alteration of the user's git environment.

verbose

Whether to print messages indicating opinions e.g. when DESCRIPTION has no URL. See give_opinions.

...

additional arguments to write_json

Value

writes out the codemeta.json file

Details

If pkg is a codemeta object, the function will attempt to update any fields it can guess (i.e. from the DESCRIPTION file), overwriting any existing data in that block. In this case, the package root directory should be the current working directory.

When creating and writing a codemeta.json for the first time, the function adds "codemeta.json" to .Rbuildignore and, if the project uses git, adds a pre-commit hook ensuring that if DESCRIPTION changes, the codemeta.json will be updated as well unless the DESCRIPTION change is committed with 'git commit --no-verify'.

Examples

write_codemeta("codemetar", path = "example_codemetar_codemeta.json")
#> Error: File `/home/travis/build/ropensci/codemetar/inst/DESCRIPTION' does not exist