<commit_before>require 'inquirer'
require 'colorize'
require 'negroku'

module Negroku::Modes
  module App
    def install

      check_version

      data = {}
      data[:application_name] = ask_name
      data[:repo_url] = select_repo

      ask_features

      custom_capify data

    end

    def update

      puts I18n.t :updating_capfile, scope: :negroku

      capfilePath = AppDirectory.root.join('Capfile')
      capfile = File.read(capfilePath)

      build_capfile

      capfile_new = File.read(capfilePath)

      if capfile_new != capfile
        puts I18n.t :updated_capfile, scope: :negroku
      else
        puts I18n.t :no_change_capfile, scope: :negroku
      end

    end

    # This code was exatracted from capistrano to be used with our own templates
    # https://github.com/capistrano/capistrano/blob/68e7632c5f16823a09c324d556a208e096abee62/lib/capistrano/tasks/install.rake
    def custom_capify(data={}, config=nil)
      # defaults
      data[:server_url] = ""
      data[:branch] = "master"

      FileUtils.mkdir_p AppDirectory.deploy

      build_capfile

      deploy_rb = AppDirectory.config.join('deploy.rb')
      build_template("templates/deploy.rb.erb", deploy_rb, binding)

      FileUtils.mkdir_p AppDirectory.tasks

      puts I18n.t :capified, scope: :negroku

    end

    def build_capfile
      # Default Config
      config ||= Negroku::Config

      capfile = AppDirectory.root.join('Capfile')
      build_template('templates/Capfile.erb', capfile, binding)
    end

    # Ask the application name<commit_msg>feat(app): run bundle binstub on app creation<commit_after>require 'inquirer'
require 'colorize'
require 'negroku'

module Negroku::Modes
  module App
    def install

      check_version

      data = {}
      data[:application_name] = ask_name
      data[:repo_url] = select_repo

      ask_features

      custom_capify data
      install_binstubs

    end

    def update

      puts I18n.t :updating_capfile, scope: :negroku

      capfilePath = AppDirectory.root.join('Capfile')
      capfile = File.read(capfilePath)

      build_capfile

      capfile_new = File.read(capfilePath)

      if capfile_new != capfile
        puts I18n.t :updated_capfile, scope: :negroku
      else
        puts I18n.t :no_change_capfile, scope: :negroku
      end

    end

    def install_binstubs
      `bundle binstub capistrano negroku`
    end

    # This code was exatracted from capistrano to be used with our own templates
    # https://github.com/capistrano/capistrano/blob/68e7632c5f16823a09c324d556a208e096abee62/lib/capistrano/tasks/install.rake
    def custom_capify(data={}, config=nil)
      # defaults
      data[:server_url] = ""
      data[:branch] = "master"

      FileUtils.mkdir_p AppDirectory.deploy

      build_capfile

      deploy_rb = AppDirectory.config.join('deploy.rb')
      build_template("templates/deploy.rb.erb", deploy_rb, binding)

      FileUtils.mkdir_p AppDirectory.tasks

      puts I18n.t :capified, scope: :negroku

    end

    def build_capfile
      # Default Config
      config ||= Negroku::Config

      capfile = AppDirectory.root.join('Capfile')
      build_template('templates/Capfile.erb', capfile, binding)
    end

    # Ask the application name
{'fraction_non_alphanumeric': 0.08587257617728532, 'fraction_numerical': 0.0221606648199446, 'mean_word_length': 2.8507109004739335, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, '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': '6505546', 'n_tokens_mistral': 1131, 'n_tokens_neox': 1039, 'n_words': 223}