Skip to contents

Refreshes the files in a deployment project that are safe to overwrite without losing any user customisations. Call this after upgrading the shinyplanr package to pick up changes to the install script, app entry point, deployment script, and any new content template files.

Usage

update_shinyplanr_template(project_dir = ".", country = NULL, oceandatr = TRUE)

Arguments

project_dir

Character. Path to the deployment project root (the directory containing app.R and the setup/ folder). Defaults to the current working directory.

country

Character. The country/region name used when the project was created. Used to re-stamp deploy.R with the correct appName. If NULL (default), the function attempts to infer it from the existing deploy.R file; if that fails it uses "MyRegion" and emits a warning.

oceandatr

Logical. Whether the project uses oceandatr. Passed to 1_setup_enviro.R to include the oceandatr/spatialgridr install lines. Defaults to TRUE.

Value

Invisibly returns the path to the project directory.

What is updated

setup/1_setup_enviro.R

Always overwritten. Contains the package install list, which changes when shinyplanr adds or removes dependencies. Any extra packages you need should be in setup/packages_extra.R (never overwritten).

app.R

Always overwritten. This is a 3-line thin wrapper that calls load_config() and run_app(). It should never need user edits.

deploy.R

Always overwritten. Contains deployment instructions and the rsconnect::deployApp() call. The appName is re-stamped from country.

setup/content/*.md

New template files only. Existing files are never overwritten, preserving your edited text content.

What is NEVER updated

setup/2_setup_data.R

Your spatial data pipeline.

setup/3_setup_app.R

Your app configuration (options, Dict path, logos, module switches, CRS, etc.). If a shinyplanr upgrade changes the config schema, load_config() will print a changelog describing exactly what to add manually.

setup/Dict_Feature.csv

Your feature dictionary.

setup/packages_extra.R

Your additional package installs.

setup/logos/

Your logo image files.

setup/content/*.md (existing)

Your edited text content.

config/shinyplanr_config.rds

Regenerated by 3_setup_app.R, not by this function.

Examples

if (FALSE) { # \dontrun{
# From inside the deployment project (e.g. after opening Fiji.Rproj):
shinyplanr::update_shinyplanr_template()

# From outside the project:
shinyplanr::update_shinyplanr_template(
  project_dir = "../shinyplanr_Fiji",
  country     = "Fiji"
)
} # }