Skip to content
Framework

Project Management

upgrade()

Bring an Older Framework Project Up to the Current Layout

upgrade() updates a project made by an earlier version of Framework so it works like a new one, without touching your code, data, or notes. It first prints a plan; with dry_run = FALSE it backs up every file it rewrites to .framework/backups/<timestamp>/ (which git ignores) and applies the plan. Running it again changes nothing.

Usage

upgrade(
  path = ".",
  dry_run = TRUE,
  backup = TRUE,
  type = NULL,
  move_settings = FALSE
)

Arguments

Name Default Description
path "."

The project folder (default: the working directory).

dry_run TRUE

If TRUE (default), print the plan and change nothing.

backup TRUE

If TRUE (default), copy every file before it is rewritten or removed. Skills replaced by an update are always backed up, to .framework/skills-backups/.

type NULL

Change the project's type: "project", "project_sensitive", "course", "presentation", or "bare". NULL (default) keeps it. Making a project project_sensitive sets security: sensitive: true, adds the private and public folders of that layout it lacks (folders it has keep their keys and paths), and then gets the sensitive .gitignore rules, agent guards, and skill like any sensitive project. The plan says where save_table(), save_figure(), save_model(), and save_report() will write from then on (outputs/private/...), and lists the data and render folders that aren't private. A sensitive project made another type stays sensitive.

move_settings FALSE

If TRUE, move top-level keys of the settings file that no environment reads (ehr_source: beside default:) into settings/<key>.yml, keeping their text and comments, and name each file under default: (ehr_source: settings/ehr_source.yml), so settings_read() and settings() read them. FALSE (default) reports them.

Value

Invisibly, a list with actions (a data frame: step, path, change), notes, applied, and backup_location.

Details

The plan covers:

  • Settings: a 1.x config.yml becomes settings.yml. Missing current sections are added: tools: (Quarto and renv, from the files present) and security:. A project_sensitive project, or one with the private folder layout, gets security: sensitive: true. Keys outside default:, which Framework ignores, are reported, or moved into settings/ with move_settings = TRUE.
  • Connections: the old layouts (options: default_connection: with connections listed flat, or the empty hybrid of both) are rewritten as connections: with default_database, databases, and storage_buckets. A password written into the settings is reported (by key, never by value) and left where it is. The spec refers to it as env("NAME"), NAME being the variable the project already uses for it (in .env, an example .env, or the code), else one made from the connection's name; the plan names it and says to set it.
  • Spec: .framework/spec.json is written from the settings when it is missing, and refreshed when its folders, type, author, security, tools, connections, or copy of .gitignore no longer match, so fw project push-spec and cloud_register() work. It holds only what spec.v1 allows (see inst/schema/spec.v1.json), so keys an earlier upgrade() wrote that Framework Cloud refuses (scaffold.positron, source.upgraded_from) are dropped.
  • .gitignore: the rules of the current template for the project's type that it lacks (Quarto's /.quarto/ and **/*.quarto_ipynb, framework.db, private folders) and folder publishing destinations are appended in one block. No line is ever removed, and a rule that would ignore files git tracks is left out and reported.
  • AI files: AGENTS.md becomes the canonical context file, with CLAUDE.md a one-line @AGENTS.md pointer, when CLAUDE.md held the full guide; the marked sections are regenerated. A hand-written AGENTS.md is left alone and reported. Sensitive projects get the Claude Code guards (.claude/settings.json) that keep agents out of private folders, whatever the AI settings say: folders with a private (or *_private) segment, folders whose key marks them private (inputs_private_raw: inputs/raw), and private render folders. The plan says when git ignores .claude/, so the guards would stay on one computer.
  • Skills: Framework skills that match a version the package has shipped are updated, in the assistants' skills folders and in .agents/skills; missing ones for the project type are added; locally edited ones are kept and listed. A project with no skills folder gets none, except that a sensitive project gets framework-sensitive-data (in its assistants' skills folder, or .claude/skills).
  • Quarto: missing Quarto files are created, and an existing _quarto.yml at most gains missing keys (see quarto_regenerate()). Custom Quarto configuration is never replaced, and per-folder _quarto.yml files are kept and listed.

Examples

Not run

if (FALSE) {
upgrade("~/projects/old-study")                  # print the plan
upgrade("~/projects/old-study", dry_run = FALSE) # apply it
upgrade("~/projects/old-study", type = "project_sensitive") # plan making it sensitive
}

Related reference

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