Skip to content
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions Casks/jsonschema.rb
Original file line number Diff line number Diff line change
@@ -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: "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"
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"]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need this on the formula on macOS, otherwise the systen complains the binary is not code signed

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Im definitely mac clueless.

# 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!"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we also keep this little note?

puts " Open in VS Code: vscode:extension/sourcemeta.sourcemeta-studio"
Expand Down
60 changes: 60 additions & 0 deletions Formula/jsonschema.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
class Jsonschema < Formula
desc "CLI for working with JSON Schema"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
desc "CLI for working with JSON Schema"
desc "The CLI for working with JSON Schema"

Just to match the old one?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Random consistency edit...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consistency with what? Is this a Homebrew convention?

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"
end

on_intel do
url "https://github.com/sourcemeta/jsonschema/releases/download/v#{version}/jsonschema-#{version}-darwin-x86_64.zip"
sha256 "dc6b99a44a1e9d002e7c534cec452fe351ae63791dfdd65e147a327c64974d51"
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"
end

on_intel do
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

url "https://github.com/sourcemeta/jsonschema/releases/download/v#{version}/jsonschema-#{version}-linux-x86_64.zip"
sha256 "6473ee098c77d93afa15f4237c6e0fd2ce6cf3105d00ddb097cad1cf8b2f368e"
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,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this comment can go away too

# 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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add the xattr -c for macOS in this part?

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 sourcemeta/apps/jsonschema
EOS
end

test do
system bin/"jsonschema", "--version"
end
end
Loading