refactor: split update_dotslash into individual rake tasks
Allows updating a single binary (`rake dotslash:jq`) instead
of all at once. Also drops Open3 in favor of backticks and
folds nvim into the shared helper via a `tag:` parameter.

Assisted-by: Claude Opus 4.6 (1M context) via Claude Code
change quzymkyyzwxmqlzzkrnmptyrrltxmlkm
commit 9abef2bc4b965970c5754f706704bb8e58cff9e9
author Alpha Chen <alpha@kejadlen.dev>
date
parent smzqnouq
diff --git a/Rakefile b/Rakefile
index 6e77fe82..2935743c 100644
--- a/Rakefile
+++ b/Rakefile
@@ -44,41 +44,61 @@ namespace :sync do
   end
 end
 
-require "json"
-require "open3"
-
-def update_dotslash_release(name:, repo:, path: name, &asset)
-  release_json, = Open3.capture2("gh", "release", "view", "--repo", repo, "--json", "tagName")
-  tag = JSON.parse(release_json)["tagName"]
-  asset_name = asset.call(tag)
-
-  url = "https://github.com/#{repo}/releases/download/#{tag}/#{asset_name}"
-  entry_json, = Open3.capture2("dotslash", "--", "create-url-entry", url)
-  entry = JSON.parse(entry_json)
-
-  platform = {
-    size: entry["size"],
-    hash: "blake3",
-    digest: entry["digest"],
-    path: path,
-    providers: [
-      { url: url },
-      { type: "github-release", repo: "https://github.com/#{repo}", tag: tag, name: asset_name },
-    ],
-  }
-  platform[:format] = entry["format"] if entry["format"] && !entry["format"].start_with?("TODO")
-
-  dotslash = { name: name, platforms: { "macos-aarch64" => platform } }
-  File.write("bin/#{name}", "#!/usr/bin/env dotslash\n\n#{JSON.pretty_generate(dotslash)}\n")
-end
+namespace :dotslash do
+  def update_dotslash_release(name:, repo:, path: name, tag: nil, &asset)
+    require "json"
+
+    unless tag
+      tag = JSON.parse(`gh release view --repo #{repo} --json tagName`)["tagName"]
+    end
+    asset_name = asset.call(tag)
+
+    url = "https://github.com/#{repo}/releases/download/#{tag}/#{asset_name}"
+    entry = JSON.parse(`dotslash -- create-url-entry #{url}`)
+
+    platform = {
+      size: entry["size"],
+      hash: "blake3",
+      digest: entry["digest"],
+      path: path,
+      providers: [
+        { url: url },
+        { type: "github-release", repo: "https://github.com/#{repo}", tag: tag, name: asset_name },
+      ],
+    }
+    platform[:format] = entry["format"] if entry["format"] && !entry["format"].start_with?("TODO")
+
+    dotslash = { name: name, platforms: { "macos-aarch64" => platform } }
+    File.write("bin/#{name}", "#!/usr/bin/env dotslash\n\n#{JSON.pretty_generate(dotslash)}\n")
+  end
 
-desc "Update dotslash files from their GitHub releases"
-task :update_dotslash do
-  sh "gh release download --repo kejadlen/pinch --pattern pinch --output bin/pinch --clobber"
+  desc "Update pinch"
+  task :pinch do
+    sh "gh release download --repo kejadlen/pinch --pattern pinch --output bin/pinch --clobber"
+  end
+
+  desc "Update jq"
+  task(:jq) do
+    update_dotslash_release(name: "jq", repo: "jqlang/jq") { "jq-macos-arm64" }
+  end
+
+  desc "Update jj"
+  task(:jj) do
+    update_dotslash_release(name: "jj", repo: "jj-vcs/jj") { |tag| "jj-#{tag}-aarch64-apple-darwin.tar.gz" }
+  end
+
+  desc "Update just"
+  task(:just) do
+      update_dotslash_release(name: "just", repo: "casey/just") { |tag| "just-#{tag}-aarch64-apple-darwin.tar.gz" }
+  end
+
+  desc "Update nvim (nightly)"
+  task(:nvim) do
+    update_dotslash_release(name: "nvim", repo: "neovim/neovim", tag: "nightly", path: "nvim-macos-arm64/bin/nvim") { "nvim-macos-arm64.tar.gz" }
+  end
 
-  update_dotslash_release(name: "jq", repo: "jqlang/jq") { "jq-macos-arm64" }
-  update_dotslash_release(name: "jj", repo: "jj-vcs/jj") { |tag| "jj-#{tag}-aarch64-apple-darwin.tar.gz" }
-  update_dotslash_release(name: "just", repo: "casey/just") { |tag| "just-#{tag}-aarch64-apple-darwin.tar.gz" }
+  desc "Update all dotslash files"
+  task all: [:pinch, :jq, :jj, :just, :nvim]
 end
 
 desc "Upgrade neovim"
diff --git a/bin/nvim b/bin/nvim
new file mode 100755
index 00000000..e2113316
--- /dev/null
+++ b/bin/nvim
@@ -0,0 +1,25 @@
+#!/usr/bin/env dotslash
+
+{
+  "name": "nvim",
+  "platforms": {
+    "macos-aarch64": {
+      "size": 9685709,
+      "hash": "blake3",
+      "digest": "d255fbaddf8f6c8f25c5dd07c49a0d2886e0f7457f3af8408f00a368ac726c3c",
+      "path": "nvim-macos-arm64/bin/nvim",
+      "providers": [
+        {
+          "url": "https://github.com/neovim/neovim/releases/download/nightly/nvim-macos-arm64.tar.gz"
+        },
+        {
+          "type": "github-release",
+          "repo": "https://github.com/neovim/neovim",
+          "tag": "nightly",
+          "name": "nvim-macos-arm64.tar.gz"
+        }
+      ],
+      "format": "tar.gz"
+    }
+  }
+}