Sha256: 7577667b00773da395d6e2f04b7620aad38556ec009be9db3021a01f75e9581a

Contents?: true

Size: 1.23 KB

Versions: 107

Compression:

Stored size: 1.23 KB

Contents

module Souls
  class Upgrade < Thor
    desc "config", "Update config/souls.rb"
    def config
      souls = Souls.configuration
      prompt = TTY::Prompt.new
      regions = `gcloud app regions list | awk '{print $1}'`.split("\n")
      regions.shift
      project_id = prompt.ask("Project ID:", default: souls.project_id)
      region = prompt.select("Region:", regions, default: souls.region)
      endpoint = prompt.ask("Endpoint:", default: souls.endpoint)

      Dir.chdir(Souls.get_mother_path.to_s) do
        mother_conf_path = "config/souls.rb"
        api_conf_path = "apps/api/config/souls.rb"
        mother_conf = File.readlines(mother_conf_path)
        api_conf = File.readlines(api_conf_path)
        mother_conf[2] = "  config.project_id = \"#{project_id}\"\n"
        mother_conf[3] = "  config.region = \"#{region}\"\n"
        mother_conf[4] = "  config.endpoint = \"#{endpoint}\"\n"
        api_conf[2] = "  config.project_id = \"#{project_id}\"\n"
        api_conf[3] = "  config.region = \"#{region}\"\n"
        api_conf[4] = "  config.endpoint = \"#{endpoint}\"\n"
        File.open(mother_conf_path, "w") { |f| f.write(mother_conf.join) }
        File.open(api_conf_path, "w") { |f| f.write(api_conf.join) }
      end
    end
  end
end

Version data entries

107 entries across 107 versions & 1 rubygems

Version Path
souls-1.12.2 lib/souls/cli/upgrade/config.rb
souls-1.12.1 lib/souls/cli/upgrade/config.rb
souls-1.12.0 lib/souls/cli/upgrade/config.rb
souls-1.11.7 lib/souls/cli/upgrade/config.rb
souls-1.11.6 lib/souls/cli/upgrade/config.rb
souls-1.11.5 lib/souls/cli/upgrade/config.rb
souls-1.11.4 lib/souls/cli/upgrade/config.rb
souls-1.11.3 lib/souls/cli/upgrade/config.rb
souls-1.11.2 lib/souls/cli/upgrade/config.rb
souls-1.11.1 lib/souls/cli/upgrade/config.rb
souls-1.11.0 lib/souls/cli/upgrade/config.rb
souls-1.10.8 lib/souls/cli/upgrade/config.rb
souls-1.10.7 lib/souls/cli/upgrade/config.rb
souls-1.10.6 lib/souls/cli/upgrade/config.rb
souls-1.10.5 lib/souls/cli/upgrade/config.rb
souls-1.10.4 lib/souls/cli/upgrade/config.rb
souls-1.10.3 lib/souls/cli/upgrade/config.rb
souls-1.10.2 lib/souls/cli/upgrade/config.rb
souls-1.10.1 lib/souls/cli/upgrade/config.rb
souls-1.10.0 lib/souls/cli/upgrade/config.rb