Skip to content

Commit c1e3c90

Browse files
Copilotdlebauer
andauthored
move datapackage.json to repo root following Frictionless spec
Agent-Logs-Url: https://github.com/PecanProject/betydata/sessions/57bbceb9-4e27-48ae-926f-a76673577fbb Co-authored-by: dlebauer <464871+dlebauer@users.noreply.github.com>
1 parent 997385a commit c1e3c90

3 files changed

Lines changed: 9 additions & 8 deletions

File tree

.Rbuildignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,4 @@
2121
^_freeze$
2222
^index\.qmd$
2323
^_publish\.yml$
24+
^datapackage\.json$

data-raw/make-data.R

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,7 @@ if (!is.null(managements_treatments)) usethis::use_data(managements_treatments,
158158
if (!is.null(cultivars_pfts)) usethis::use_data(cultivars_pfts, overwrite = TRUE, compress = "xz")
159159

160160
# --- Generate datapackage.json ---
161-
log_info("Generating inst/metadata/datapackage.json...")
162-
dir.create("inst/metadata", showWarnings = FALSE, recursive = TRUE)
161+
log_info("Generating datapackage.json at repo root (Frictionless spec)...")
163162

164163
# Helper to infer Frictionless type from R class
165164
r_to_frictionless_type <- function(x) {
@@ -185,10 +184,11 @@ datasets <- c("traitsview", "species", "sites", "variables", "citations",
185184
"managements", "entities", "pfts_species", "pfts_priors",
186185
"managements_treatments", "cultivars_pfts")
187186

188-
# NOTE: paths are relative to the repo root, not installed package.
189-
# data-raw/ is excluded from the built package via .Rbuildignore.
190-
# These paths are for provenance, they point to the source CSVs
191-
# in the repository, not files shipped with installed package.
187+
# datapackage.json lives at the repo root (Frictionless spec requires the
188+
# descriptor at the root of the data package). Paths are relative to the repo
189+
# root. data-raw/ is excluded from the built R package via .Rbuildignore, as
190+
# is datapackage.json itself; this descriptor is for the repository / data
191+
# release, not for the installed R package.
192192
resources <- lapply(datasets, function(nm) {
193193
df <- get(nm)
194194
base <- list(
@@ -224,6 +224,6 @@ datapackage <- list(
224224
resources = resources
225225
)
226226

227-
jsonlite::write_json(datapackage, "inst/metadata/datapackage.json",
227+
jsonlite::write_json(datapackage, "datapackage.json",
228228
auto_unbox = TRUE, pretty = TRUE)
229-
log_info(" datapackage.json written")
229+
log_info(" datapackage.json written to repo root")

0 commit comments

Comments
 (0)