diff options
| author | Gabriel Schneider <[email protected]> | 2026-03-27 14:27:19 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-03-27 15:16:44 -0300 |
| commit | eeb2d880626c72b1f94e6d84838d8a0342bb99c7 (patch) | |
| tree | 510a7030fcbf29f49c6b313fe9602648de928e4f /build/jj-log.nu | |
| parent | 5d935263f828f8be1037484f22f9181aa9f734c5 (diff) | |
| download | 0x4200.cafe-eeb2d880626c72b1f94e6d84838d8a0342bb99c7.tar.gz 0x4200.cafe-eeb2d880626c72b1f94e6d84838d8a0342bb99c7.zip | |
Added jj metadata to page build, orchestrated with nushell and mise
Diffstat (limited to 'build/jj-log.nu')
| -rw-r--r-- | build/jj-log.nu | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/build/jj-log.nu b/build/jj-log.nu new file mode 100644 index 0000000..7d2aa92 --- /dev/null +++ b/build/jj-log.nu @@ -0,0 +1,34 @@ +#!/usr/bin/env nu + +# Generate JSON from jj log and compile a Typst document +# Usage: nu build/jj-log.nu [--revset '::@'] [--output build/jj-log.pdf] + +def main [ + --revset (-r): string = "::@" # jj revset expression + --output (-o): string = "build/jj-log.pdf" # output PDF path + --json-only (-j) # only generate JSON, skip typst compile +] { + let build_dir = ($env.FILE_PWD? | default ("build" | path expand)) + let tmpl = (open ([$build_dir "jj-log.tmpl"] | path join)) + let json_path = ($output | path parse | update extension "json" | path join) + + let trees_json = "trees/_data/jj-log.json" + mkdir trees/_data + + print $"generating log for revset: ($revset)" + let log_output = (jj log -r $revset --no-graph -T $tmpl) + $log_output | save -f $json_path + $log_output | save -f $trees_json + + let n = (open --raw $json_path | lines | where $it != "" | length) + print $"wrote ($n) entries to ($json_path), ($trees_json)" + + if not $json_only { + let typ_path = ([$build_dir "jj-log.typ"] | path join) + let json_abs = ($json_path | path expand) + let out_abs = ($output | path expand) + print $"compiling ($output)..." + typst compile $typ_path --root / --input $"data=($json_abs)" $out_abs + print $"done → ($output)" + } +} |
