fix(patches): validator portability, clearer docs, broader hook trigger
This commit is contained in:
parent
a826a27246
commit
f3f3bfa20d
2 changed files with 2428 additions and 8 deletions
|
|
@ -34,10 +34,10 @@ To add a new patch entry:
|
|||
## Validation
|
||||
|
||||
The registry is validated and applied by bincraft during the build process.
|
||||
For manual validation, use:
|
||||
For manual validation, run the validator from the repo root:
|
||||
|
||||
```r
|
||||
x <- jsonlite::fromJSON("local/patches/registry.json", simplifyVector = FALSE)
|
||||
```bash
|
||||
Rscript local/validate-patches.R
|
||||
```
|
||||
|
||||
This loads the registry; inspect the structure to verify correctness.
|
||||
This validates the schema, referenced patch-file existence, and checks for duplicate entries across platforms and versions.
|
||||
|
|
|
|||
|
|
@ -9,6 +9,8 @@ if (!file.exists(registry_file)) {
|
|||
quit(status = 0L)
|
||||
}
|
||||
|
||||
or_q <- function(x) if (is.null(x)) "?" else x
|
||||
|
||||
reg <- jsonlite::fromJSON(registry_file, simplifyVector = FALSE)
|
||||
required <- c("package", "versions", "platforms", "reason")
|
||||
errs <- character(0L)
|
||||
|
|
@ -36,9 +38,9 @@ for (i in seq_along(reg)) {
|
|||
keys <- vapply(reg, function(e) {
|
||||
sprintf(
|
||||
"%s|%s|%s",
|
||||
e$package %||% "?",
|
||||
or_q(e$package),
|
||||
paste(sort(as.character(unlist(e$platforms))), collapse = ","),
|
||||
e$versions %||% "?"
|
||||
or_q(e$versions)
|
||||
)
|
||||
}, character(1L))
|
||||
dups <- keys[duplicated(keys)]
|
||||
|
|
@ -51,4 +53,4 @@ if (length(errs) > 0L) {
|
|||
cat(paste0(" - ", errs, "\n"))
|
||||
quit(status = 1L)
|
||||
}
|
||||
cat(sprintf("Patch registry OK (%d entrie(s)).\n", length(reg)))
|
||||
cat(sprintf("Patch registry OK (%d %s).\n", length(reg), if (length(reg) == 1L) "entry" else "entries"))
|
||||
|
|
|
|||
Loading…
Reference in a new issue