Sha256: b71c4113e35f5293284f29f4f14e7dabeda7e991dabe450df4369a8be9ddd1d4

Contents?: true

Size: 1.98 KB

Versions: 5

Compression:

Stored size: 1.98 KB

Contents

module Souls
  module Init
    def self.get_version(repository_name: "souls_api")
      data = JSON.parse(
        `curl \
      -H "Accept: application/vnd.github.v3+json" \
      -s https://api.github.com/repos/elsoul/#{repository_name}/releases`
      )
      data[0]["tag_name"]
    end

    def self.initial_config_init(app_name: "souls", strain: "api")
      FileUtils.touch("./#{app_name}/config/souls.rb")
      file_path = "./#{app_name}/config/souls.rb"
      File.open(file_path, "w") do |f|
        f.write(<<~TEXT)
          Souls.configure do |config|
            config.app = "#{app_name}"
            config.strain = "#{strain}"
          end
        TEXT
      end
    rescue StandardError => e
      puts(e)
    end

    def self.download_souls(app_name: "souls", repository_name: "souls_api ")
      version = get_version(repository_name: repository_name)
      system("curl -OL https://github.com/elsoul/#{repository_name}/archive/#{version}.tar.gz")
      system("tar -zxvf ./#{version}.tar.gz")
      system("mkdir #{app_name}")
      folder = version.delete("v")
      `cp -r #{repository_name}-#{folder}/. #{app_name}/`
      `rm -rf #{version}.tar.gz && rm -rf #{repository_name}-#{folder}`
      line = Paint["====================================", :yellow]
      puts("\n")
      puts(line)
      txt = <<~TEXT
           _____ ____  __  ____#{'        '}
          / ___// __ \\/ / / / /   _____
          \\__ \\/ / / / / / / /   / ___/
         ___/ / /_/ / /_/ / /___(__  )#{' '}
        /____/\\____/\\____/_____/____/#{'  '}
      TEXT
      message = Paint[txt, :blue]
      puts(message)
      puts(line)
      welcome = Paint["Welcome to SOULs!", :white]
      puts(welcome)
      souls_ver = Paint["SOULs Version: #{Souls::VERSION}", :white]
      puts(souls_ver)
      puts(line)
      cd = Paint["Easy to Run\n$ cd #{app_name}\n$ bundle\n$ souls s\nGo To : http://localhost:3000\n\nDoc: https://souls.elsoul.nl",
                 :white]
      puts(cd)
      puts(line)
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
souls-0.24.0 lib/souls/init.rb
souls-0.23.9 lib/souls/init.rb
souls-0.23.8 lib/souls/init.rb
souls-0.23.7 lib/souls/init.rb
souls-0.23.6 lib/souls/init.rb