homebrew-core/Formula/sqlc.rb

53 lines
1.8 KiB
Ruby

class Sqlc < Formula
desc "Generate type safe Go from SQL"
homepage "https://sqlc.dev/"
url "https://github.com/kyleconroy/sqlc/archive/v1.14.0.tar.gz"
sha256 "833217a40920b5f1551da8a24ddd80d3af91ec45730862654257c54e37403e32"
license "MIT"
head "https://github.com/kyleconroy/sqlc.git", branch: "main"
bottle do
sha256 cellar: :any_skip_relocation, arm64_monterey: "85fb3f959894a184890481dec9fbe3a3c1c23fbbc09f190eb33c1cd887bd3d51"
sha256 cellar: :any_skip_relocation, arm64_big_sur: "87a9f08d4bb8bdf4ef4a9d5353444db9a81cac32b96d05fcbcba6c3e1aa53ced"
sha256 cellar: :any_skip_relocation, monterey: "59de3681ad3b3961e0d07b862541558f2806b9d8a9814bceef60b29d3caf23f4"
sha256 cellar: :any_skip_relocation, big_sur: "8a4bef936939effac4e2fc4ccf63764b4b0e2ab5f56b540391a39115a73112ba"
sha256 cellar: :any_skip_relocation, catalina: "de763d8f6442cf845fba9c570663ebbc64d639f3ad8988e6803ac287a20d1e1e"
sha256 cellar: :any_skip_relocation, x86_64_linux: "fd986be0bcd6c82e9e018c2e07c5dd03a4ec80a0abdded132a9201e716b03a3e"
end
depends_on "go" => :build
def install
system "go", "build", *std_go_args, "-ldflags", "-s -w", "./cmd/sqlc"
end
test do
(testpath/"sqlc.json").write <<~SQLC
{
"version": "1",
"packages": [
{
"name": "db",
"path": ".",
"queries": "query.sql",
"schema": "query.sql",
"engine": "postgresql"
}
]
}
SQLC
(testpath/"query.sql").write <<~EOS
CREATE TABLE foo (bar text);
-- name: SelectFoo :many
SELECT * FROM foo;
EOS
system bin/"sqlc", "generate"
assert_predicate testpath/"db.go", :exist?
assert_predicate testpath/"models.go", :exist?
assert_match "// Code generated by sqlc. DO NOT EDIT.", File.read(testpath/"query.sql.go")
end
end