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.5.4", :revision => "2d4c9c3fd9afd81ded3ac2e686bc1f7204078f14" head "https://github.com/elastic/kibana.git" bottle do cellar :any_skip_relocation sha256 "b3831c6f6f2ecb5208d5b09290c38fae4ef265f39f459d225233eff9ecfc340e" => :mojave sha256 "b574c3450a1eabf0ea1e5f225b562386753eb74a9c04296d41b51ecdbaf86419" => :high_sierra sha256 "101bb42677e25f8e9a998036034317c1cb5658d4b72db2de2e757caaf68c3b87" => :sierra end resource "node" do url "https://nodejs.org/dist/v8.14.0/node-v8.14.0.tar.xz" sha256 "8ce252913c9f6aaa9871f2d9661b6e54858dae2f0064bd3c624676edb09083c4" end resource "yarn" do url "https://yarnpkg.com/downloads/1.12.3/yarn-v1.12.3.tar.gz" sha256 "02cd4b589ec22c4bdbd2bc5ebbfd99c5e99b07242ad68a539cb37896b93a24f2" 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" # patch build to not try to read tsconfig.json's from the removed x-pack folder inreplace "src/dev/typescript/projects.ts" do |s| s.gsub! "new Project(resolve(REPO_ROOT, 'x-pack/tsconfig.json')),", "" s.gsub! "new Project(resolve(REPO_ROOT, 'x-pack/test/tsconfig.json'), 'x-pack/test'),", "" end # 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 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