Class: Souls::CLI
- Inherits:
-
Thor
- Object
- Thor
- Souls::CLI
- Defined in:
- lib/souls/cli.rb,
lib/souls/cli/init/index.rb,
lib/souls/cli/server/index.rb,
lib/souls/cli/console/index.rb,
lib/souls/cli/release/release.rb
Class Method Summary collapse
Instance Method Summary collapse
- #check ⇒ Object
- #console ⇒ Object
-
#initialize(*_args) ⇒ CLI
constructor
A new instance of CLI.
- #new(app_name) ⇒ Object
- #release ⇒ Object
- #release_local ⇒ Object
- #server ⇒ Object
- #test ⇒ Object
- #version ⇒ Object
Constructor Details
Class Method Details
.exit_on_failure? ⇒ Boolean
73 74 75 |
# File 'lib/souls/cli.rb', line 73 def self.exit_on_failure? false end |
Instance Method Details
#check ⇒ Object
67 68 69 70 71 |
# File 'lib/souls/cli.rb', line 67 def check Dir.chdir(Souls.get_mother_path.to_s) do system("steep check") end end |
#console ⇒ Object
5 6 7 8 9 |
# File 'lib/souls/cli/console/index.rb', line 5 def console return system("RACK_ENV=production bundle exec irb") if [:env].eql?("production") system("bundle exec irb") end |
#new(app_name) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/souls/cli/init/index.rb', line 9 def new(app_name) if app_name.nil? puts(Paint["you need to specify your app name", :red]) puts(Paint["`souls new souls-app`", :yellow]) exit end file_dir = "./#{app_name}" raise(StandardError, "Directory already exists and is not empty") if Dir.exist?(file_dir) && !Dir.empty?(file_dir) service_name = "api" download_souls(app_name: app_name, service_name: service_name) mother_config_init(app_name: app_name) download_github_actions(app_name: app_name) initial_config_init(app_name: app_name, service_name: service_name) system("cd #{app_name} && git init --initial-branch=main") system( " cd #{app_name} && git submodule add -f https://github.com/ruby/gem_rbs_collection.git vendor/rbs/gem_rbs_collection " ) souls_api_credit(app_name) end |
#release ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/souls/cli/release/release.rb', line 6 def release Souls::Painter.error("hey! It's Broken!") unless system("rspec") system("gem install souls") sleep(3) current_souls_ver = Souls::VERSION.strip.split(".").map(&:to_i) prompt = TTY::Prompt.new choices = [ "1. Patch(#{Souls.version_detector(current_ver: current_souls_ver, update_kind: 'patch')})", "2. Minor(#{Souls.version_detector(current_ver: current_souls_ver, update_kind: 'minor')})", "3. Major(#{Souls.version_detector(current_ver: current_souls_ver, update_kind: 'major')})" ] choice_num = prompt.select("Select Version: ", choices)[0].to_i update_kinds = %w[patch minor major] update_kind = update_kinds[choice_num - 1] souls_new_ver = Souls.version_detector(current_ver: current_souls_ver, update_kind: update_kind) status = Paint["Saving Repo...", :yellow] Whirly.start(spinner: "clock", interval: 420, stop: "🎉") do Whirly.status = status %w[api worker].each do |s_name| update_service_gemfile(service_name: s_name, version: souls_new_ver) result = Paint[update_repo(service_name: s_name, version: souls_new_ver), :green] Whirly.status = result end overwrite_version(new_version: souls_new_ver) puts("before add") system("git add .") puts("before commit") system("git commit -m 'souls update v#{souls_new_ver}'") puts("before build") system("rake build") system("rake release") write_changelog(current_souls_ver: current_souls_ver) system("gh release create v#{souls_new_ver} -t v#{souls_new_ver} -F ./CHANGELOG.md") system("gsutil -m -q -o 'GSUtil:parallel_process_count=1' cp -r coverage gs://souls-bucket/souls-coverage") system("bundle exec rake upload:init_files") Whirly.status = Paint["soul-v#{souls_new_ver} successfully updated!"] end end |
#release_local ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/souls/cli/release/release.rb', line 47 def release_local unless `git status`.include?("nothing to commit") raise( StandardError, "You can only release to local with a clean working directory. Please commit your changes." ) end local_dir = "~/.local_souls/" system("mkdir -p #{local_dir}") souls_local_ver = generate_local_version status = Paint["Saving Repo...", :yellow] Whirly.start(spinner: "clock", interval: 420, stop: "🎉") do Whirly.status = status %w[api worker].each do |s_name| update_service_gemfile(service_name: s_name, version: souls_local_ver, local: true) result = Paint[update_repo(service_name: s_name, version: souls_local_ver), :green] Whirly.status = result end Whirly.status = Paint["Creating local gem..."] overwrite_version(new_version: souls_local_ver) system("gem build souls.gemspec --output #{local_dir}souls-#{souls_local_ver}.gem") system("bundle exec rake upload:init_files") Whirly.status = Paint["Done. Created gem at #{local_dir}souls-#{souls_local_ver}.gem"] Whirly.status = Paint["Removing previous versions...", :white] system("gem uninstall souls -x --force") Whirly.status = Paint["Installing local gem..."] system("gem install #{local_dir}souls-#{souls_local_ver}.gem") Whirly.status = Paint["Cleaning up..."] system("git checkout .") end end |
#server ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/souls/cli/server/index.rb', line 5 def server if [:all] Dir.chdir(Souls.get_mother_path.to_s) do front_path = "apps/console/package.json" system("foreman start -f Procfile.dev") system("cd apps/console && yarn dev") if File.exist?(front_path) end else package_json_path = "package.json" if File.exist?(package_json_path) system("yarn dev") else system("foreman start -f Procfile.dev") end end end |
#test ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/souls/cli.rb', line 51 def test if [:all] Dir.chdir(Souls.get_mother_path.to_s) do system("steep check") end Dir.chdir(Souls.get_api_path.to_s) do system("rubocop -A") system("bundle exec rspec") end else system("rubocop -A") system("bundle exec rspec") end end |