Inflate all your flat files


Inflate all your flat files at once

The inflate_all() function allows the user to inflate all the active flat files available in the “dev/” directory at once. This requires to inflate each new flat file individually at least once in order to register the inflate parameters.

Prior to be able to inflate all the flat files, some checks are performed, to assess whether the flat files are available to be used by inflate_all().

Store configuration of each flat file once

inflate_all() requires the existence of a complete {fusen} configuration file: “dev/config_fusen.yaml”. This file exists only from versions of {fusen} upper than v0.5.0:

Prevent some flat files to be inflated

When a flat file is listed in the configuration file, it will be inflated each time you run inflate_all().
If you do not want this flat file to be inflated anymore, you can deprecate it. Open the configuration file in “dev/config_fusen.yaml”. Find the section concerning the flat file. Change the state: active to state: deprecated. It will not be inflated during the following calls to inflate_all().

You may have a flat file that is a work in progress and is not inflated yet. This will not affect other flat files to be inflated. In this case you may see the following message. You can ignore it.

The flat file {flat} is not going to be inflated.
It was detected in your flats directory but it is absent from the config file.
Please inflate() it manually when you are ready, so that it is accounted the next time.

Wrapper around inflate_all()

There is a wrapper named inflate_all_no_check() that will prevent running devtools::check(). This is a short version of inflate_all(check = FALSE).

Register all other files to help clean your project

Note also that all files stored in R, tests and vignettes directories are checked to detect those not created from a flat file. They will need to be registered in the config file too, in order to help you keep your package clean of deprecated files. inflate_all() thus runs check_not_registered_files() behind the scene and informs about the procedure. Read vignette('register-files-in-config', package = 'fusen') to get more information.

Complete the process with your own code style

You can run your preferred styling functions just before the check of the package in inflate_all(). For instance, if you want {styler} package to clean your code during the inflate process, you can run inflate_all(stylers = styler::style_pkg). If you also would like to clean the “dev/” directory, you can run inflate_all(stylers = function() {styler::style_pkg(); styler::style_dir("dev")}).

#' \dontrun{
# Usually, in the current package run inflate_all() directly
# These functions change the current user workspace
# Or inflate_all_no_check() to prevent checks to run
# Or inflate with the styler you want
inflate_all(stylers = styler::style_pkg)
#' }

# You can also inflate_all flats of another package as follows
# Example with a dummy package with a flat file
dummypackage <- tempfile("inflateall.otherpkg")
fill_description(pkg = dummypackage, fields = list(Title = "Dummy Package"))
flat_files <- add_minimal_package(
  pkg = dummypackage,
  overwrite = TRUE,
  open = FALSE
flat_file <- flat_files[grep("flat", basename(flat_files))]
# Inflate the flat file once
usethis::with_project(dummypackage, {
  # if you are starting from a brand new package, inflate_all() will crash
  # it's because of the absence of a fusen config file
  # inflate_all() # will crash

  # Add licence
  usethis::use_mit_license("John Doe")

  # you need to inflate manually your flat file first
    pkg = dummypackage,
    flat_file = flat_file,
    vignette_name = "Get started",
    check = FALSE,
    open_vignette = FALSE,
    document = TRUE,
    overwrite = "yes"

  # your config file has been created
  config_yml_ref <-
    yaml::read_yaml(getOption("fusen.config_file", default = "dev/config_fusen.yaml"))

# Next time, you can run inflate_all() directly
usethis::with_project(dummypackage, {
  # now you can run inflate_all()
  inflate_all(check = FALSE, document = TRUE)

# Clean the temporary directory
unlink(dummypackage, recursive = TRUE)