<commit_before>class Kibana < Formula
  desc "Analytics and search dashboard for Elasticsearch"
  homepage "https://www.elastic.co/products/kibana"
  # NOTE: Do not bump version to one with a non-open-source license
  url "https://github.com/elastic/kibana.git",
      tag:      "v7.10.2",
      revision: "a0b793698735eb1d0ab1038f8e5d7a951524e929"
  license "Apache-2.0"
  head "https://github.com/elastic/kibana.git"

  bottle do
    sha256 cellar: :any_skip_relocation, monterey: "3ada496bcdff84e29654d2bf0f35195cc6df7f3686b7a51b49c77138930958cf"
    sha256 cellar: :any_skip_relocation, big_sur:  "c218ab10fca2ebdddd11ab27326d0a6d0530a7f26bc2adc26d1751e4326b0198"
    sha256 cellar: :any_skip_relocation, catalina: "c1ee01e41c34677dba144152142808d469db2855658fdd3e4fcafbae77a10774"
    sha256 cellar: :any_skip_relocation, mojave:   "fb818924d852b07ab0417e8ff52899400b98f25bd24714f77a8c472224269690"
  end

  # elasticsearch will be relicensed before v7.11.
  # https://www.elastic.co/blog/licensing-change
  deprecate! date: "2021-01-14", because: "is switching to an incompatible license"

  depends_on "python@3.9" => :build
  depends_on "yarn" => :build
  depends_on "node@10"

  def install
    inreplace "package.json", /"node": "10\.\d+\.\d+"/, %Q("node": "#{Formula["node@10"].version}")

    # prepare project after checkout
    system "yarn", "kbn", "bootstrap"

    # build open source only
    system "node", "scripts/build", "--oss", "--release", "--skip-os-packages", "--skip-archives"

    # remove non open source files
    rm_rf "x-pack"

    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

    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<commit_msg>kibana: migrate to python@3.10<commit_after>class Kibana < Formula
  desc "Analytics and search dashboard for Elasticsearch"
  homepage "https://www.elastic.co/products/kibana"
  # NOTE: Do not bump version to one with a non-open-source license
  url "https://github.com/elastic/kibana.git",
      tag:      "v7.10.2",
      revision: "a0b793698735eb1d0ab1038f8e5d7a951524e929"
  license "Apache-2.0"
  head "https://github.com/elastic/kibana.git"

  bottle do
    sha256 cellar: :any_skip_relocation, monterey: "3ada496bcdff84e29654d2bf0f35195cc6df7f3686b7a51b49c77138930958cf"
    sha256 cellar: :any_skip_relocation, big_sur:  "c218ab10fca2ebdddd11ab27326d0a6d0530a7f26bc2adc26d1751e4326b0198"
    sha256 cellar: :any_skip_relocation, catalina: "c1ee01e41c34677dba144152142808d469db2855658fdd3e4fcafbae77a10774"
    sha256 cellar: :any_skip_relocation, mojave:   "fb818924d852b07ab0417e8ff52899400b98f25bd24714f77a8c472224269690"
  end

  # elasticsearch will be relicensed before v7.11.
  # https://www.elastic.co/blog/licensing-change
  deprecate! date: "2021-01-14", because: "is switching to an incompatible license"

  depends_on "python@3.10" => :build
  depends_on "yarn" => :build
  depends_on "node@10"

  def install
    inreplace "package.json", /"node": "10\.\d+\.\d+"/, %Q("node": "#{Formula["node@10"].version}")

    # prepare project after checkout
    system "yarn", "kbn", "bootstrap"

    # build open source only
    system "node", "scripts/build", "--oss", "--release", "--skip-os-packages", "--skip-archives"

    # remove non open source files
    rm_rf "x-pack"

    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

    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
{'fraction_non_alphanumeric': 0.1386161757830762, 'fraction_numerical': 0.11360448807854137, 'mean_word_length': 3.9929988331388566, 'pattern_counts': {'":': 4, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 8, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5170061', 'n_tokens_mistral': 1918, 'n_tokens_neox': 1646, 'n_words': 302}