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.8.3", :revision => "c814843540abb9dedf0f89bddc61bee364527743" head "https://github.com/elastic/kibana.git" bottle do cellar :any_skip_relocation sha256 "f8634e98d1d8ed79f691e7bf6faa4365741011f01d4be389b8ae00305baf67cd" => :mojave sha256 "6e79191708e71fecf8d6a7c7757d45237af992e64fd0f15f16e1f124c61749be" => :high_sierra sha256 "a4186dcb4f9a6e57614b0b7c03d297f845f91c6e1e914078c5d491750b43734b" => :sierra end resource "node" do url "https://nodejs.org/dist/v10.15.2/node-v10.15.2.tar.xz" sha256 "b8bb2da7cb016e895bc2f70009a420f6b8d519e66548624b6130bbfbd5118c59" end resource "yarn" do url "https://yarnpkg.com/downloads/1.16.0/yarn-v1.16.0.tar.gz" sha256 "df202627d9a70cf09ef2fb11cb298cb619db1b958590959d6f6e571b50656029" 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" inreplace "package.json", /"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 .glob("build/oss/kibana-#{version}-darwin-x86_64/**") .reject { |f| File.fnmatch("build/oss/kibana-#{version}-darwin-x86_64/{node, data, plugins}", f) } 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