JSON API
Lightweight JSON edits are now practical inside Dagger pipelines. Instead of shelling out to jq, read, modify, and write JSON through typed APIs.
@func()
async setPackageManager(src: Directory): Promise<Directory> {
const updated = src
.file("package.json")
.asJSON()
.withField(["packageManager"], dag.json().newString("pnpm@10.5.2"))
return src.withFile(
"package.json",
dag.file("package.json", await updated.contents({ pretty: true })),
)
}