require "language/node" class KibanaAT41 < Formula desc "Analytics and search dashboard for Elasticsearch" homepage "https://www.elastic.co/products/kibana" url "https://github.com/elastic/kibana.git", :tag => "v4.1.8", :revision => "e4f4c5bef5fbec91f0890bd08f6a622f6c4648ad" head "https://github.com/elastic/kibana.git" bottle do sha256 "ec28125079c89536ba4a20be57b82de931cc486ab7a1ab64769a1f57cddd5a02" => :sierra sha256 "55e4b928b6ec55c40fb32fb5efe12a445741d3dad2716ab9b5eb7850b3da71b4" => :el_capitan sha256 "2ecc450f936d0b2507b25a7d8ed89bb0eef16f9f6e88d6ae6c51b48dc227addf" => :yosemite end keg_only :versioned_formula resource "node" do url "https://nodejs.org/dist/v4.4.4/node-v4.4.4.tar.gz" sha256 "53c694c203ee18e7cd393612be08c61ed6ab8b2a165260984a99c014d1741414" end def install resource("node").stage buildpath/"node" cd buildpath/"node" do system "./configure", "--prefix=#{libexec}/node" system "make", "install" end # do not download binary installs of Node.js inreplace buildpath/"tasks/build.js", /('download_node_binaries',)/, "// \\1" # do not build packages for other platforms if MacOS.prefer_64_bit? platform = "darwin-x64" else raise "Installing Kibana via Homebrew is only supported on macOS x86_64" end inreplace buildpath/"Gruntfile.js", /^(\s+)platforms: .*/, "\\1platforms: [ '#{platform}' ]," # do not build zip packages inreplace buildpath/"tasks/config/compress.js", /(build_zip: .*)/, "// \\1" ENV.prepend_path "PATH", prefix/"libexec/node/bin" Pathname.new("#{ENV["HOME"]}/.npmrc").write Language::Node.npm_cache_config system "npm", "install", "grunt-cli", "bower" system "npm", "install" system "node_modules/.bin/bower", "install" system "node_modules/.bin/grunt", "build" mkdir "tar" do system "tar", "--strip-components", "1", "-xf", Dir[buildpath/"target/kibana-*-#{platform}.tar.gz"].first rm_f Dir["bin/*.bat"] prefix.install "bin", "config", "plugins", "src" end inreplace "#{bin}/kibana", %r{/node/bin/node}, "/libexec/node/bin/node" cd prefix do inreplace "config/kibana.yml", %r{/var\/run\/kibana.pid}, var/"run/kibana.pid" (etc/"kibana").install Dir["config/*"] rm_rf "config" (var/"kibana/plugins").install Dir["plugins/*"] rm_rf "plugins" end end def post_install ln_s etc/"kibana", prefix/"config" ln_s var/"kibana/plugins", prefix/"plugins" end def caveats; <<-EOS.undent Plugins: #{var}/kibana/plugins/ Config: #{etc}/kibana/ EOS end plist_options :manual => "kibana" def plist; <<-EOS.undent 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