Add jsonschema formula (Linux + macOS) and deprecate cask#5
Add jsonschema formula (Linux + macOS) and deprecate cask#5cavanaug wants to merge 5 commits intosourcemeta:mainfrom
Conversation
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
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.
- 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)
…ation 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.
Upgrade behavior for existing macOS cask usersFor users who currently have the cask installed, here is the exact sequence of events after this PR is merged:
|
There was a problem hiding this comment.
Pull request overview
This PR introduces a cross-platform Homebrew formula for jsonschema (Linux + macOS) and deprecates the existing macOS-only cask to provide a clearer migration path for users.
Changes:
- Added
Formula/jsonschema.rbwith platform/arch-specific release artifacts plus completion installs. - Deprecated
Casks/jsonschema.rbto guide existing cask users toward the new formula.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
Formula/jsonschema.rb |
New formula installing the jsonschema binary and shell completions across macOS/Linux and architectures, with migration guidance. |
Casks/jsonschema.rb |
Deprecates the existing cask and adjusts metadata/style to support migration messaging. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
- 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
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
| desc "CLI for working with JSON Schema" | ||
| homepage "https://github.com/sourcemeta/jsonschema" | ||
|
|
||
| deprecate! date: "2026-03-11", because: "now a formula; run: brew uninstall --cask sourcemeta/apps/jsonschema" |
There was a problem hiding this comment.
Seems like this is the only real relevant change. The rest of changes in this file are just noise?
There was a problem hiding this comment.
Its trying to provide some comments about what is happening and to hopefully lead the user to the right next step if they encounter a problem.
There was a problem hiding this comment.
Yes, I mean the rest of the edits in this file are blank lines getting added, the version field getting re-ordered, etc?
| 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"] |
There was a problem hiding this comment.
You need this on the formula on macOS, otherwise the systen complains the binary is not code signed
| @@ -0,0 +1,58 @@ | |||
| class Jsonschema < Formula | |||
| desc "CLI for working with JSON Schema" | |||
There was a problem hiding this comment.
| desc "CLI for working with JSON Schema" | |
| desc "The CLI for working with JSON Schema" |
Just to match the old one?
There was a problem hiding this comment.
Consistency with what? Is this a Homebrew convention?
| end | ||
| end | ||
|
|
||
| # jsonschema was previously distributed as a cask. Note: conflicts_with cask: |
There was a problem hiding this comment.
I think the conflicts_with line is obvious enough that we can remove this whole comment?
There was a problem hiding this comment.
The comment was to highlight this distinction between brew documentation and reality. You would think conflicts_with would have an impact during upgrade/etc, but its been my observation that it is only relevant for brew audit.
There was a problem hiding this comment.
I think let's remove the comment. The conflicts_with line, even for a casual reader, is readable enough?
| conflicts_with cask: "jsonschema", because: "both install a `jsonschema` binary" | ||
|
|
||
| def install | ||
| # Homebrew auto-chdirs into the single top-level directory of the zip, |
There was a problem hiding this comment.
I think this comment can go away too
| sha256 "cb8fd293ead5bb68be931d23b81c8d2278d047defb91b27e2d2892704211c198" | ||
| end | ||
|
|
||
| on_intel do |
There was a problem hiding this comment.
BTW note that we offer a musl x86 binary. Is there a way to correctly use it on musl systems? Not a blocker, as its more of a bonus thing, but I wonder if it is possible
There was a problem hiding this comment.
Im honestly not sure how you specify a musl variant in brew. Brew itself would have to have dependencies on musl libraries being available I think, either that or the OS itself needs to ensure they are there.
|
|
||
| puts "" | ||
| puts "Tip: Try the Sourcemeta Studio VS Code extension for an enhanced experience!" |
There was a problem hiding this comment.
Can we also keep this little note?
|
TODO to self: after this PR is merged, might be worth configuring GitHub Actions here so we test the formula builds across Linux and macOS |
|
So admittedly one the problems I had with this is that I dont have a mac to test it on. Also some of the brew documentation regarding things like conflicts_with doesnt actually match the behavior observed. I tried to simulate the actual experience of going from Cask to Formula by creating a synthetic Linux cask and then switching to formula. But Im honestly not positive that was a faithful representation of reality. I was trying to coerce brew to tell an existing cask based user effectively what needs to be done if they get a messages about conflicts etc. I didnt want to leave the user in a state where things are conflicted and we didnt tell them exactly how to fix it. Any situation where it looks like things are broken/conflicted and the user has to go google how to fix it, is not the desired experience. If someone has a mac and can test this directly that would be immensely helpful. |
| zsh_completion.install "share/zsh/site-functions/_jsonschema" | ||
| end | ||
|
|
||
| def post_install |
There was a problem hiding this comment.
Can we add the xattr -c for macOS in this part?
Summary
This PR adds a Homebrew formula for
jsonschemathat works on both Linux and macOS, and deprecates the existing macOS-only cask in favour of it.Motivation
The existing
Casks/jsonschema.rbonly works on macOS. Linux users attemptingbrew install sourcemeta/apps/jsonschemaget a cask-not-supported error with no fallback. Issue: sourcemeta/jsonschema#683Changes
Formula/jsonschema.rb(new)darwin-arm64,darwin-x86_64,linux-arm64,linux-x86_64post_installblock that detects a lingering Caskroom installation and prints explicit migration commandsbrew install,brew test,brew audit --strict,brew style, and a functional smoke test on LinuxCasks/jsonschema.rb(updated)deprecate!stanza so existing cask users see an actionable warning atbrew upgradetime:desc, trailing whitespace) caught bybrew styleMigration path for existing cask users
brew upgradebrew install sourcemeta/apps/jsonschema(while cask present)post_installwarning with full two-step migration instructionsTesting
Tested on Linux x86_64: