<commit_before>fiftyfive_recipe :dotenv do
  during "provision", "update"
  prior_to "deploy:publishing", "update"
end

namespace :fiftyfive do
  namespace :dotenv do
    desc "Replace/create .env file with values provided at console"
    task :replace do
      set_up_secret_prompts

      on release_roles(:all) do
        update_dotenv_file
      end
    end

    desc "Update .env file with any missing values"
    task :update do
      set_up_secret_prompts

      on release_roles(:all), :in => :sequence do
        existing_env = if test("[ -f #{shared_dotenv_path} ]")
          download!(shared_dotenv_path)
        end
        update_dotenv_file(existing_env || "")
      end
    end

    def shared_dotenv_path
      "#{shared_path}/#{fetch(:fiftyfive_dotenv_filename)}"
    end

    def set_up_secret_prompts
      fetch(:fiftyfive_dotenv_keys).each { |k| ask_secretly(k) }
    end

    def update_dotenv_file(existing="")
      updated = existing.dup

      fetch(:fiftyfive_dotenv_keys).each do |key|
        next if existing =~ /^#{Regexp.escape(key.upcase)}=/
        updated << "\n" unless updated.end_with?("\n")
        updated << "#{key.upcase}=#{fetch(key)}\n"
      end

      unless existing == updated
        put(updated, shared_dotenv_path, :mode => "600")
      end
    end
  end
end
<commit_msg>Only using input masking for "secret" keys<commit_after>fiftyfive_recipe :dotenv do
  during "provision", "update"
  prior_to "deploy:publishing", "update"
end

namespace :fiftyfive do
  namespace :dotenv do
    desc "Replace/create .env file with values provided at console"
    task :replace do
      set_up_prompts

      on release_roles(:all) do
        update_dotenv_file
      end
    end

    desc "Update .env file with any missing values"
    task :update do
      set_up_prompts

      on release_roles(:all), :in => :sequence do
        existing_env = if test("[ -f #{shared_dotenv_path} ]")
          download!(shared_dotenv_path)
        end
        update_dotenv_file(existing_env || "")
      end
    end

    def shared_dotenv_path
      "#{shared_path}/#{fetch(:fiftyfive_dotenv_filename)}"
    end

    def set_up_prompts
      fetch(:fiftyfive_dotenv_keys).each do |key|
        if key.to_s =~ /key|token|secret|password/i
          ask_secretly(key)
        else
          ask(key, nil)
        end
      end
    end

    def update_dotenv_file(existing="")
      updated = existing.dup

      fetch(:fiftyfive_dotenv_keys).each do |key|
        next if existing =~ /^#{Regexp.escape(key.upcase)}=/
        updated << "\n" unless updated.end_with?("\n")
        updated << "#{key.upcase}=#{fetch(key)}\n"
      end

      unless existing == updated
        put(updated, shared_dotenv_path, :mode => "600")
      end
    end
  end
end

{'fraction_non_alphanumeric': 0.10691144708423327, 'fraction_numerical': 0.0021598272138228943, 'mean_word_length': 2.637434554973822, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5809495', 'n_tokens_mistral': 912, 'n_tokens_neox': 896, 'n_words': 217}