All commands that you use to use when developing packages...

First time just after creating the project

# Describe your package
fusen::fill_description(
  pkg = here::here(),
  fields = list(
    Title = "Build A {ggplot} Maquette From Figma File",
    Description = "Use a Figma file -a free online UI/UX design tool- to build a theme for your graphics created with {ggplot2}. Create a theme, palettes and scale functions easily.",
    `Authors@R` = c(
      person("Margot", "Brard", email = "margot@thinkr.fr", role = c("aut", "cre"), comment = c(ORCID = "0000-0001-6754-0659")),
      person(given = "ThinkR", role = "cph")
    )
  )
)
# Define License with use_*_license()
usethis::use_mit_license("Margot Brard")

Start using git

usethis::use_git()
# Deal with classical files to ignore
# usethis::git_vaccinate()
usethis::use_git_ignore(c(".DS_Store", ".Rproj.user", ".Rdata", ".Rhistory", ".httr-oauth"))

Add data

# For example data
usethis::use_data_raw()

# For dev data
dir.create(here::here("inst"))

Set extra sources of documentation

# README
usethis::use_readme_rmd()
# Code of Conduct
usethis::use_code_of_conduct("contact@fake.com")
# NEWS
usethis::use_news_md()

From now, you will need to "inflate" your package at least once to be able to use the following commands. Let's go to your flat template, and come back here later if/when needed.

Package development tools

Use once

# Pipe
usethis::use_pipe()

# package-level documentation
usethis::use_package_doc()

# Set CI
# _GitHub
usethis::use_github_action_check_standard()
usethis::use_github_action("pkgdown")
usethis::use_github_action("test-coverage")
# _GitLab
gitlabr::use_gitlab_ci(type = "check-coverage-pkgdown")

# Add new flat template
fusen::add_flat_template("add")

Use everytime needed

# Simulate package installation
pkgload::load_all()

# Inflate all flat files
inflate_a_given_flat <- function(name_flat_rmd) {

  flat_in_line <- readLines(file.path("dev", name_flat_rmd))

  start_inflate_chunk_in_code <- which(stringr::str_detect(flat_in_line, "fusen::inflate\\(flat_file ="))

  inflate_code <- flat_in_line[start_inflate_chunk_in_code : (start_inflate_chunk_in_code + 4)] %>% stringr::str_c(collapse = "")

  eval(parse(text = inflate_code))

  return(message(glue::glue("{name_flat_rmd} inflate ok")))

}
list.files("dev")[list.files("dev") %>% stringr::str_detect("^flat")] %>%
  purrr::walk(inflate_a_given_flat)

# Generate documentation and deal with dependencies
attachment::att_amend_desc()

# Check the package
devtools::check()

Share the package

# set and try pkgdown documentation website
usethis::use_pkgdown()
pkgdown::build_site()

# build the tar.gz to share with others
devtools::build()


ThinkR-open/swatch documentation built on April 7, 2022, 6:08 p.m.