diff --git a/Casks/jsonschema.rb b/Casks/jsonschema.rb index bf4eb57..81ff056 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: "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" 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 new file mode 100644 index 0000000..66078f4 --- /dev/null +++ b/Formula/jsonschema.rb @@ -0,0 +1,58 @@ +class Jsonschema < Formula + desc "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" + 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 + 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. 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, + # 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 + EOS + end + + test do + system bin/"jsonschema", "--version" + end +end