From 9dfccd3642724741f072480c5237de7168dea536 Mon Sep 17 00:00:00 2001 From: John Cavanaugh <59479+cavanaug@users.noreply.github.com> Date: Wed, 11 Mar 2026 13:29:43 -0700 Subject: [PATCH 1/5] Add jsonschema formula with Linux and macOS support Adds a Formula for the jsonschema CLI to replace the existing macOS-only Cask. The Cask uses arm:/intel: sha256 keys which resolve to nil on Linux, causing an immediate install failure. The new Formula uses on_macos/on_linux + on_arm/on_intel blocks (all four combinations) so the install works correctly on both platforms. Closes sourcemeta/jsonschema#683 --- Formula/jsonschema.rb | 62 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 Formula/jsonschema.rb diff --git a/Formula/jsonschema.rb b/Formula/jsonschema.rb new file mode 100644 index 0000000..13104be --- /dev/null +++ b/Formula/jsonschema.rb @@ -0,0 +1,62 @@ +class Jsonschema < Formula + desc "The CLI for working with JSON Schema" + homepage "https://github.com/sourcemeta/jsonschema" + version "14.14.2" + license "AGPL-3.0-only" + + on_macos do + on_arm do + url "https://github.com/sourcemeta/jsonschema/releases/download/v#{version}/jsonschema-#{version}-darwin-arm64.zip" + sha256 "ae73b90e79a7e587f05d722de502b31eeb701b072e2563c38d717388a5c6e785" + + def install + dir = "jsonschema-#{version}-darwin-arm64" + bin.install "#{dir}/bin/jsonschema" + bash_completion.install "#{dir}/share/bash-completion/completions/jsonschema" + zsh_completion.install "#{dir}/share/zsh/site-functions/_jsonschema" + end + end + + on_intel do + url "https://github.com/sourcemeta/jsonschema/releases/download/v#{version}/jsonschema-#{version}-darwin-x86_64.zip" + sha256 "dc6b99a44a1e9d002e7c534cec452fe351ae63791dfdd65e147a327c64974d51" + + def install + dir = "jsonschema-#{version}-darwin-x86_64" + bin.install "#{dir}/bin/jsonschema" + bash_completion.install "#{dir}/share/bash-completion/completions/jsonschema" + zsh_completion.install "#{dir}/share/zsh/site-functions/_jsonschema" + end + end + end + + on_linux do + on_arm do + url "https://github.com/sourcemeta/jsonschema/releases/download/v#{version}/jsonschema-#{version}-linux-arm64.zip" + sha256 "cb8fd293ead5bb68be931d23b81c8d2278d047defb91b27e2d2892704211c198" + + def install + dir = "jsonschema-#{version}-linux-arm64" + bin.install "#{dir}/bin/jsonschema" + bash_completion.install "#{dir}/share/bash-completion/completions/jsonschema" + zsh_completion.install "#{dir}/share/zsh/site-functions/_jsonschema" + end + end + + on_intel do + url "https://github.com/sourcemeta/jsonschema/releases/download/v#{version}/jsonschema-#{version}-linux-x86_64.zip" + sha256 "6473ee098c77d93afa15f4237c6e0fd2ce6cf3105d00ddb097cad1cf8b2f368e" + + def install + dir = "jsonschema-#{version}-linux-x86_64" + bin.install "#{dir}/bin/jsonschema" + bash_completion.install "#{dir}/share/bash-completion/completions/jsonschema" + zsh_completion.install "#{dir}/share/zsh/site-functions/_jsonschema" + end + end + end + + test do + system "#{bin}/jsonschema", "--version" + end +end From a22a70a17eff9cd5b3c3e52e07f7605299fa1f53 Mon Sep 17 00:00:00 2001 From: John Cavanaugh <59479+cavanaug@users.noreply.github.com> Date: Wed, 11 Mar 2026 13:33:05 -0700 Subject: [PATCH 2/5] Fix install paths: use flat paths after Homebrew auto-chdir Homebrew automatically chdirs into the single top-level subdirectory of a zip archive before running the install block. The initial version incorrectly used full subdirectory prefixes (e.g. jsonschema-14.14.2-linux-x86_64/bin/jsonschema) which don't exist relative to that chdir'd location. Also consolidate the four identical install blocks into one shared method at the formula level. Tested: brew install + brew test pass on Linux x86_64. --- Formula/jsonschema.rb | 36 ++++++++---------------------------- 1 file changed, 8 insertions(+), 28 deletions(-) diff --git a/Formula/jsonschema.rb b/Formula/jsonschema.rb index 13104be..d7486db 100644 --- a/Formula/jsonschema.rb +++ b/Formula/jsonschema.rb @@ -8,25 +8,11 @@ class Jsonschema < Formula on_arm do url "https://github.com/sourcemeta/jsonschema/releases/download/v#{version}/jsonschema-#{version}-darwin-arm64.zip" sha256 "ae73b90e79a7e587f05d722de502b31eeb701b072e2563c38d717388a5c6e785" - - def install - dir = "jsonschema-#{version}-darwin-arm64" - bin.install "#{dir}/bin/jsonschema" - bash_completion.install "#{dir}/share/bash-completion/completions/jsonschema" - zsh_completion.install "#{dir}/share/zsh/site-functions/_jsonschema" - end end on_intel do url "https://github.com/sourcemeta/jsonschema/releases/download/v#{version}/jsonschema-#{version}-darwin-x86_64.zip" sha256 "dc6b99a44a1e9d002e7c534cec452fe351ae63791dfdd65e147a327c64974d51" - - def install - dir = "jsonschema-#{version}-darwin-x86_64" - bin.install "#{dir}/bin/jsonschema" - bash_completion.install "#{dir}/share/bash-completion/completions/jsonschema" - zsh_completion.install "#{dir}/share/zsh/site-functions/_jsonschema" - end end end @@ -34,28 +20,22 @@ def install on_arm do url "https://github.com/sourcemeta/jsonschema/releases/download/v#{version}/jsonschema-#{version}-linux-arm64.zip" sha256 "cb8fd293ead5bb68be931d23b81c8d2278d047defb91b27e2d2892704211c198" - - def install - dir = "jsonschema-#{version}-linux-arm64" - bin.install "#{dir}/bin/jsonschema" - bash_completion.install "#{dir}/share/bash-completion/completions/jsonschema" - zsh_completion.install "#{dir}/share/zsh/site-functions/_jsonschema" - end end on_intel do url "https://github.com/sourcemeta/jsonschema/releases/download/v#{version}/jsonschema-#{version}-linux-x86_64.zip" sha256 "6473ee098c77d93afa15f4237c6e0fd2ce6cf3105d00ddb097cad1cf8b2f368e" - - def install - dir = "jsonschema-#{version}-linux-x86_64" - bin.install "#{dir}/bin/jsonschema" - bash_completion.install "#{dir}/share/bash-completion/completions/jsonschema" - zsh_completion.install "#{dir}/share/zsh/site-functions/_jsonschema" - end end end + def install + # Homebrew auto-chdirs into the single top-level directory of the zip, + # so bin/, share/, etc. are directly accessible here. + bin.install "bin/jsonschema" + bash_completion.install "share/bash-completion/completions/jsonschema" + zsh_completion.install "share/zsh/site-functions/_jsonschema" + end + test do system "#{bin}/jsonschema", "--version" end From 3f166a717c55453791cc043383fe671af00712fb Mon Sep 17 00:00:00 2001 From: John Cavanaugh <59479+cavanaug@users.noreply.github.com> Date: Wed, 11 Mar 2026 13:52:16 -0700 Subject: [PATCH 3/5] Add post_install cask migration warning and deprecate cask - Add deprecate! stanza to Casks/jsonschema.rb so existing cask users see a deprecation warning at brew upgrade time (:moved_to_formula) - Add post_install block to Formula/jsonschema.rb that detects a lingering Caskroom/jsonschema installation and prints explicit remediation commands to guide users through the migration - Fix style: strip leading article from desc in both files (brew style) - Fix style: correct stanza ordering and grouping in cask (brew style) --- Casks/jsonschema.rb | 11 +++++++---- Formula/jsonschema.rb | 24 +++++++++++++++++++++--- 2 files changed, 28 insertions(+), 7 deletions(-) diff --git a/Casks/jsonschema.rb b/Casks/jsonschema.rb index bf4eb57..25c0f8a 100644 --- a/Casks/jsonschema.rb +++ b/Casks/jsonschema.rb @@ -1,23 +1,26 @@ cask "jsonschema" do - version "14.14.2" - arch arm: "arm64", intel: "x86_64" + version "14.14.2" sha256 arm: "ae73b90e79a7e587f05d722de502b31eeb701b072e2563c38d717388a5c6e785", intel: "dc6b99a44a1e9d002e7c534cec452fe351ae63791dfdd65e147a327c64974d51" url "https://github.com/sourcemeta/jsonschema/releases/download/v#{version}/jsonschema-#{version}-darwin-#{arch}.zip" name "JSON Schema CLI" - desc "The CLI for working with JSON Schema" + desc "CLI for working with JSON Schema" homepage "https://github.com/sourcemeta/jsonschema" + + deprecate! date: "2026-03-11", because: :moved_to_formula + binary "jsonschema-#{version}-darwin-#{arch}/bin/jsonschema" bash_completion "jsonschema-#{version}-darwin-#{arch}/share/bash-completion/completions/jsonschema" zsh_completion "jsonschema-#{version}-darwin-#{arch}/share/zsh/site-functions/_jsonschema" + postflight do system_command "xattr", args: ["-c", "#{staged_path}/jsonschema-#{version}-darwin-#{arch}/bin/jsonschema"] # As a test system_command "#{staged_path}/jsonschema-#{version}-darwin-#{arch}/bin/jsonschema" - + puts "" puts "Tip: Try the Sourcemeta Studio VS Code extension for an enhanced experience!" puts " Open in VS Code: vscode:extension/sourcemeta.sourcemeta-studio" diff --git a/Formula/jsonschema.rb b/Formula/jsonschema.rb index d7486db..2d0c409 100644 --- a/Formula/jsonschema.rb +++ b/Formula/jsonschema.rb @@ -1,5 +1,5 @@ class Jsonschema < Formula - desc "The CLI for working with JSON Schema" + desc "CLI for working with JSON Schema" homepage "https://github.com/sourcemeta/jsonschema" version "14.14.2" license "AGPL-3.0-only" @@ -28,15 +28,33 @@ class Jsonschema < Formula end end + # jsonschema was previously distributed as a cask. The conflicts_with stanza + # blocks installation if the cask is still present, with a clear error telling + # the user to run: + # brew uninstall --cask sourcemeta/apps/jsonschema + conflicts_with cask: "sourcemeta/apps/jsonschema", because: "both install a `jsonschema` binary" + def install # Homebrew auto-chdirs into the single top-level directory of the zip, - # so bin/, share/, etc. are directly accessible here. + # so bin/ and share/ are directly accessible here. bin.install "bin/jsonschema" bash_completion.install "share/bash-completion/completions/jsonschema" zsh_completion.install "share/zsh/site-functions/_jsonschema" end + def post_install + caskroom = HOMEBREW_CASKROOM/"jsonschema" + return unless caskroom.exist? + + opoo <<~EOS + A Cask installation of jsonschema was detected at #{caskroom}. + The cask has been superseded by this formula. To complete migration, run: + brew uninstall --cask sourcemeta/apps/jsonschema + brew install --formula sourcemeta/apps/jsonschema + EOS + end + test do - system "#{bin}/jsonschema", "--version" + system bin/"jsonschema", "--version" end end From 7599f5d9e6fd42db4f7876a514ae05ca9b164194 Mon Sep 17 00:00:00 2001 From: John Cavanaugh <59479+cavanaug@users.noreply.github.com> Date: Wed, 11 Mar 2026 13:57:36 -0700 Subject: [PATCH 4/5] Use actionable deprecate! message and drop --formula flag from remediation The deprecate! reason now includes an explicit uninstall command so the warning shown at brew upgrade time is immediately actionable. The --formula flag is unnecessary since brew install prefers formulae over casks when both exist in the same tap. --- Casks/jsonschema.rb | 2 +- Formula/jsonschema.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Casks/jsonschema.rb b/Casks/jsonschema.rb index 25c0f8a..e93454b 100644 --- a/Casks/jsonschema.rb +++ b/Casks/jsonschema.rb @@ -10,7 +10,7 @@ desc "CLI for working with JSON Schema" homepage "https://github.com/sourcemeta/jsonschema" - deprecate! date: "2026-03-11", because: :moved_to_formula + deprecate! date: "2026-03-11", because: "it moved to a formula; uninstall with: brew uninstall --cask jsonschema" binary "jsonschema-#{version}-darwin-#{arch}/bin/jsonschema" bash_completion "jsonschema-#{version}-darwin-#{arch}/share/bash-completion/completions/jsonschema" diff --git a/Formula/jsonschema.rb b/Formula/jsonschema.rb index 2d0c409..5a9fc0d 100644 --- a/Formula/jsonschema.rb +++ b/Formula/jsonschema.rb @@ -50,7 +50,7 @@ def post_install A Cask installation of jsonschema was detected at #{caskroom}. The cask has been superseded by this formula. To complete migration, run: brew uninstall --cask sourcemeta/apps/jsonschema - brew install --formula sourcemeta/apps/jsonschema + brew install sourcemeta/apps/jsonschema EOS end From 0c21d673fb0d5c1a967b0ef4ff858e8e356569e0 Mon Sep 17 00:00:00 2001 From: John Cavanaugh <59479+cavanaug@users.noreply.github.com> Date: Thu, 12 Mar 2026 11:27:56 -0700 Subject: [PATCH 5/5] Address PR review feedback - Fix conflicts_with cask: token to use short name 'jsonschema' (not tap-qualified) since the cask lives in the same tap - Update comment above conflicts_with to clarify it is cosmetic-only at runtime; post_install is the actual warning mechanism - Fix post_install message: remove redundant 'brew install' line since the formula is already installed when post_install runs - Fix deprecate! message: use tap-qualified 'sourcemeta/apps/jsonschema' for consistency with the formula messaging, rephrase to fit 118 chars --- Casks/jsonschema.rb | 2 +- Formula/jsonschema.rb | 10 ++++------ 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/Casks/jsonschema.rb b/Casks/jsonschema.rb index e93454b..81ff056 100644 --- a/Casks/jsonschema.rb +++ b/Casks/jsonschema.rb @@ -10,7 +10,7 @@ desc "CLI for working with JSON Schema" homepage "https://github.com/sourcemeta/jsonschema" - deprecate! date: "2026-03-11", because: "it moved to a formula; uninstall with: brew uninstall --cask jsonschema" + deprecate! date: "2026-03-11", because: "now a formula; run: brew uninstall --cask sourcemeta/apps/jsonschema" binary "jsonschema-#{version}-darwin-#{arch}/bin/jsonschema" bash_completion "jsonschema-#{version}-darwin-#{arch}/share/bash-completion/completions/jsonschema" diff --git a/Formula/jsonschema.rb b/Formula/jsonschema.rb index 5a9fc0d..66078f4 100644 --- a/Formula/jsonschema.rb +++ b/Formula/jsonschema.rb @@ -28,11 +28,10 @@ class Jsonschema < Formula end end - # jsonschema was previously distributed as a cask. The conflicts_with stanza - # blocks installation if the cask is still present, with a clear error telling - # the user to run: - # brew uninstall --cask sourcemeta/apps/jsonschema - conflicts_with cask: "sourcemeta/apps/jsonschema", because: "both install a `jsonschema` binary" + # jsonschema was previously distributed as a cask. Note: conflicts_with cask: + # is cosmetic metadata for brew audit only — it does not raise an error at + # runtime. The post_install block below is the actual runtime warning. + conflicts_with cask: "jsonschema", because: "both install a `jsonschema` binary" def install # Homebrew auto-chdirs into the single top-level directory of the zip, @@ -50,7 +49,6 @@ def post_install A Cask installation of jsonschema was detected at #{caskroom}. The cask has been superseded by this formula. To complete migration, run: brew uninstall --cask sourcemeta/apps/jsonschema - brew install sourcemeta/apps/jsonschema EOS end