homebrew-core/Formula/kibana.rb
2018-09-20 14:52:13 +02:00

96 lines
3.3 KiB
Ruby

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 => "v6.4.1",
:revision => "2872c74872c54d91e3e00b67c7bbc61659df0ba7"
head "https://github.com/elastic/kibana.git"
bottle do
sha256 "4592014baeec58962946a94deaf108c9c0c58670205ce0930aacd4f9e2b72aee" => :mojave
sha256 "0bf531fe125f35eaba50902916e3c469220f66a402c83c6802f9cfd90e85b209" => :high_sierra
sha256 "75b3a83605396fe8bb347fca5c9bd00279e8fa39b65e837994db309644c329a7" => :sierra
sha256 "99bc5bb7e1e01216dfbf49357794fb87423ef27eee539050bd3901c955e4e021" => :el_capitan
end
resource "node" do
url "https://nodejs.org/dist/v8.11.4/node-v8.11.4.tar.xz"
sha256 "fbce7de6d96b0bcb0db0bf77f0e6ea999b6755e6930568aedaab06847552a609"
end
resource "yarn" do
url "https://yarnpkg.com/downloads/1.9.4/yarn-v1.9.4.tar.gz"
sha256 "7667eb715077b4bad8e2a832e7084e0e6f1ba54d7280dc573c8f7031a7fb093e"
end
def install
resource("node").stage do
system "./configure", "--prefix=#{libexec}/node"
system "make", "install"
end
# remove non open source files
rm_rf "x-pack"
# trick the build into thinking we've already downloaded the Node.js binary
mkdir_p buildpath/".node_binaries/#{resource("node").version}/darwin-x64"
# run yarn against the bundled node version and not our node formula
(buildpath/"yarn").install resource("yarn")
(buildpath/".brew_home/.yarnrc").write "build-from-source true\n"
ENV.prepend_path "PATH", buildpath/"yarn/bin"
ENV.prepend_path "PATH", prefix/"libexec/node/bin"
system "yarn", "kbn", "bootstrap"
system "yarn", "build", "--oss", "--release", "--skip-os-packages", "--skip-archives"
prefix.install Dir["build/oss/kibana-#{version}-darwin-x86_64/{bin,config,node_modules,optimize,package.json,src,ui_framework,webpackShims}"]
mv "licenses/APACHE-LICENSE-2.0.txt", "LICENSE.txt" # install OSS license
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
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
<?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