diff --git a/.hof/shadow/AdhocGen/hof.rb b/.hof/shadow/AdhocGen/hof.rb new file mode 100644 index 0000000..ca0ba3b --- /dev/null +++ b/.hof/shadow/AdhocGen/hof.rb @@ -0,0 +1,34 @@ +class Hof < Formula + desc "Flexible data modeling & code generation system" + homepage "https://hofstadter.io/" + version "0.6.6" + url "https://github.com/hofstadter-io/hof.git", + tag: "v0.6.6", + revision: "0f49b4d71a66788b006daacf905a2b138768beca" + license "BSD-3-Clause" + head "https://github.com/hofstadter-io/hof.git", branch: "_dev" + + depends_on "go" => :build + depends_on "docker" => :test + + def install + arch = Hardware::CPU.intel? ? "amd64" : Hardware::CPU.arch.to_s + os = OS.kernel_name.downcase + + ldflags = %W[ -s -w -X github.com/hofstadter-io/hof/cmd/hof/verinfo.Version=#{version} -X github.com/hofstadter-io/hof/cmd/hof/verinfo.Commit=#{Utils.git_head} -X github.com/hofstadter-io/hof/cmd/hof/verinfo.BuildDate=#{time.iso8601} -X github.com/hofstadter-io/hof/cmd/hof/verinfo.GoVersion=#{Formula["go"].version} -X github.com/hofstadter-io/hof/cmd/hof/verinfo.BuildOS=#{os} -X github.com/hofstadter-io/hof/cmd/hof/verinfo.BuildArch=#{arch} ] + + ENV["CGO_ENABLED"] = "0" + system "go", "build", *std_go_args(ldflags: ldflags), "./cmd/hof" + + bash_output = Utils.safe_popen_read(bin/"hof", "completion", "bash") + (bash_completion/"hof").write bash_output + zsh_output = Utils.safe_popen_read(bin/"hof", "completion", "zsh") + (zsh_completion/"_hof").write zsh_output + fish_output = Utils.safe_popen_read(bin/"hof", "completion", "fish") + (fish_completion/"hof.fish").write fish_output + end + + test do + assert_match "v#{version}", shell_output("#{bin}/hof version") + end +end diff --git a/Makefile b/Makefile index 6a9708d..49a39a7 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ .PHONY: gen gen-src gen-bin gen: gen-src gen-src: - hof gen hof.cue -T templates/from-git-source.rb=hof.rb --no-format + hof gen hof.cue -T templates/from-git-source.rb=hof.rb --no-format --diff3 gen-bin: hof gen hof.cue -T templates/from-gh-release.rb=hof.rb --no-format diff --git a/templates/core.rb b/templates/core.rb new file mode 100644 index 0000000..9f8764e --- /dev/null +++ b/templates/core.rb @@ -0,0 +1,34 @@ +class {{ title .name }} < Formula + desc "{{ .desc }}" + homepage "{{ .homepage }}" + url "{{ .url }}", + tag: "{{ .tag }}", + revision: "{{ .commit }}" + license "{{ .license }}" + head "{{ .url }}", branch: "{{ .branch }}" + + depends_on "go" => :build + depends_on "docker" => :test + + def install + arch = Hardware::CPU.intel? ? "amd64" : Hardware::CPU.arch.to_s + os = OS.kernel_name.downcase + + ldflags = %W[ {{ .ldflags }} ] + + ENV["CGO_ENABLED"] = "0" + system "go", "build", *std_go_args(ldflags: ldflags), "./{{ .cmddir }}" + + bash_output = Utils.safe_popen_read(bin/"{{ .name }}", "completion", "bash") + (bash_completion/"{{ .name }}").write bash_output + zsh_output = Utils.safe_popen_read(bin/"{{ .name }}", "completion", "zsh") + (zsh_completion/"_{{ .name }}").write zsh_output + fish_output = Utils.safe_popen_read(bin/"{{ .name }}", "completion", "fish") + (fish_completion/"{{ .name }}.fish").write fish_output + end + + test do + assert_match "v#{version}", shell_output("#{bin}/{{ .name }} version") + end +end + diff --git a/templates/from-git-source.rb b/templates/from-git-source.rb index ad2ae21..f02219f 100644 --- a/templates/from-git-source.rb +++ b/templates/from-git-source.rb @@ -8,15 +8,6 @@ class {{ title .name }} < Formula license "{{ .license }}" head "{{ .url }}", branch: "{{ .branch }}" - bottle do - sha256 cellar: :any_skip_relocation, arm64_monterey: "da7fa63d18da0c17f4bd2b4d1ddef8a1fa6bf9409ad32646db184e2da74a4472" - sha256 cellar: :any_skip_relocation, arm64_big_sur: "da7fa63d18da0c17f4bd2b4d1ddef8a1fa6bf9409ad32646db184e2da74a4472" - sha256 cellar: :any_skip_relocation, monterey: "0b9a77f9209c943caabd4cbb896a8cd31690d474735998df1a30ce777b7cee19" - sha256 cellar: :any_skip_relocation, big_sur: "0b9a77f9209c943caabd4cbb896a8cd31690d474735998df1a30ce777b7cee19" - sha256 cellar: :any_skip_relocation, catalina: "0b9a77f9209c943caabd4cbb896a8cd31690d474735998df1a30ce777b7cee19" - sha256 cellar: :any_skip_relocation, x86_64_linux: "7386d7a1f88d925e4621e1950e1edbca8361d813f68084eee7d53d185ad0da49" - end - depends_on "go" => :build depends_on "docker" => :test @@ -29,21 +20,15 @@ def install ENV["CGO_ENABLED"] = "0" system "go", "build", *std_go_args(ldflags: ldflags), "./{{ .cmddir }}" - bash_output = Utils.safe_popen_read(bin/"hof", "completion", "bash") - (bash_completion/"hof").write bash_output - zsh_output = Utils.safe_popen_read(bin/"hof", "completion", "zsh") - (zsh_completion/"_hof").write zsh_output - fish_output = Utils.safe_popen_read(bin/"hof", "completion", "fish") - (fish_completion/"hof.fish").write fish_output + bash_output = Utils.safe_popen_read(bin/"{{ .name }}", "completion", "bash") + (bash_completion/"{{ .name }}").write bash_output + zsh_output = Utils.safe_popen_read(bin/"{{ .name }}", "completion", "zsh") + (zsh_completion/"_{{ .name }}").write zsh_output + fish_output = Utils.safe_popen_read(bin/"{{ .name }}", "completion", "fish") + (fish_completion/"{{ .name }}.fish").write fish_output end test do - assert_match "v#{version}", shell_output("#{bin}/hof version") - - system bin/"hof", "mod", "init", "cue", "brew.sh/brewtest" - assert_predicate testpath/"cue.mods", :exist? - assert_equal "module: \"brew.sh/brewtest\"", (testpath/"cue.mod/module.cue").read.chomp - - assert_match version.to_s, shell_output(bin/"hof version") + assert_match "v#{version}", shell_output("#{bin}/{{ .name }} version") end end