require "language/node" class KibanaAT56 < Formula desc "Analytics and search dashboard for Elasticsearch" homepage "https://www.elastic.co/products/kibana" url "https://github.com/elastic/kibana.git", :tag => "v5.6.12", :revision => "a07347478b7a3b1661cfb77c149fd15bdeb8921d" bottle do sha256 "25b60e1afd2cbdbd01a61f46ec620af7c94280eeae677da6283575f067a3b9ce" => :mojave sha256 "cd12bca1bb794724a50dfa60122b63883c3b043dfb24eed3004b979daaa6ca3a" => :high_sierra sha256 "6f44dc9fb908caa817d5266bb4c4c4b2a67e197597056fab2c38b02474fae0bc" => :sierra sha256 "1a8bc314a1fcf867c63ab700ffda0b3593f524c3038d684445d603b8204fbab0" => :el_capitan end keg_only :versioned_formula resource "node" do url "https://nodejs.org/dist/v6.14.4/node-v6.14.4.tar.xz" sha256 "9a4bfc99787f8bdb07d5ae8b1f00ec3757e7b09c99d11f0e8a5e9a16a134ec0f" end def install resource("node").stage do system "./configure", "--prefix=#{libexec}/node" system "make", "install" end # do not build packages for other platforms inreplace buildpath/"tasks/config/platforms.js", /('(linux-x64|windows-x64)',?(?!;))/, "// \\1" # trick the build into thinking we've already downloaded the Node.js binary mkdir_p buildpath/".node_binaries/#{resource("node").version}/darwin-x64" # 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" system "npm", "install", "-ddd", "--build-from-source", "--#{Language::Node.npm_cache_config}" system "npm", "run", "build", "--", "--release", "--skip-os-packages", "--skip-archives" prefix.install Dir["build/kibana-#{version}-darwin-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 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 Label #{plist_name} Program #{opt_bin}/kibana RunAtLoad EOS end test do ENV["BABEL_CACHE_PATH"] = testpath/".babelcache.json" assert_match /#{version}/, shell_output("#{bin}/kibana -V") end end