homebrew-core/Formula/kibana.rb
2017-04-27 09:36:35 -07:00

99 lines
3.4 KiB
Ruby

require "language/node"
class Kibana < Formula
desc "Analytics and search dashboard for Elasticsearch"
homepage "https://www.elastic.co/products/kibana"
url "https://github.com/elastic/kibana.git",
:tag => "v5.3.2",
:revision => "6c330d3c77b0af1c5a29302e0a7a45f33fcb6869"
head "https://github.com/elastic/kibana.git"
bottle do
sha256 "a679d2d123fd8ed83dfd9e6db29388cede33d94f6c8f4d035acef721290905f5" => :sierra
sha256 "d7f6430c81be111ef5ee9707ff6d66b41db2f2cd030c58d64d4bc04d35262d6b" => :el_capitan
sha256 "09f799c9cf08dea35adcbcefe22b58b247e39eef5b3c8cb0286fe5eb8273d625" => :yosemite
end
resource "node" do
url "https://nodejs.org/dist/v6.10.2/node-v6.10.2.tar.xz"
sha256 "80aa11333da99813973a99646e2113c6be5b63f665c0731ed14ecb94cbe846b6"
end
def install
resource("node").stage do
system "./configure", "--prefix=#{libexec}/node"
system "make", "test"
system "make", "install"
end
# do not build packages for other platforms
platforms = Set.new(["darwin-x64", "linux-x64", "linux-x86", "windows-x86"])
if MacOS.prefer_64_bit?
platform = "darwin-x64"
else
raise "Installing Kibana via Homebrew is only supported on macOS x86_64"
end
platforms.delete(platform)
sub = platforms.to_a.join("|")
inreplace buildpath/"tasks/config/platforms.js", /('(#{sub})',?(?!;))/, "// \\1"
inreplace buildpath/"tasks/build/notice.js", /linux-x64/, "darwin-x64"
# trick the build into thinking we've already downloaded the Node.js binary
mkdir_p buildpath/".node_binaries/#{resource("node").version}/#{platform}"
# set npm env and fix cache edge case (https://github.com/Homebrew/brew/pull/37#issuecomment-208840366)
ENV.prepend_path "PATH", prefix/"libexec/node/bin"
Pathname.new("#{ENV["HOME"]}/.npmrc").write Language::Node.npm_cache_config
system "npm", "install", "--verbose"
system "npm", "run", "build", "--", "--release", "--skip-os-packages", "--skip-archives"
prefix.install Dir["build/kibana-#{version}-#{platform.sub("x64", "x86_64")}/{bin,config,node_modules,optimize,package.json,src,ui_framework,webpackShims}"]
inreplace "#{bin}/kibana", %r{/node/bin/node}, "/libexec/node/bin/node"
inreplace "#{bin}/kibana-plugin", %r{/node/bin/node}, "/libexec/node/bin/node"
cd prefix do
inreplace "config/kibana.yml", "/var/run/kibana.pid", var/"run/kibana.pid"
(etc/"kibana").install Dir["config/*"]
rm_rf "config"
end
end
def post_install
ln_s etc/"kibana", prefix/"config"
(prefix/"data").mkdir
(prefix/"plugins").mkdir
end
def caveats; <<-EOS.undent
Config: #{etc}/kibana/
If you wish to preserve your plugins upon upgrade, make a copy of
#{opt_prefix}/plugins before upgrading, and copy it into the
new keg location after upgrading.
EOS
end
plist_options :manual => "kibana"
def plist; <<-EOS.undent
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>#{plist_name}</string>
<key>Program</key>
<string>#{opt_bin}/kibana</string>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>
EOS
end
test do
ENV["BABEL_CACHE_PATH"] = testpath/".babelcache.json"
assert_match /#{version}/, shell_output("#{bin}/kibana -V")
end
end