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
- #build ⇒ Object
- #console ⇒ Object
- #deploy ⇒ Object
-
#initialize(*_args) ⇒ CLI
constructor
A new instance of CLI.
- #new(app_name) ⇒ Object
- #push ⇒ Object
- #release ⇒ Object
- #release_local ⇒ Object
- #secret ⇒ Object
- #server ⇒ Object
- #tag ⇒ Object
- #test ⇒ Object
- #version ⇒ Object
Constructor Details
Class Method Details
.exit_on_failure? ⇒ Boolean
83 84 85 |
# File 'lib/souls/cli.rb', line 83 def self.exit_on_failure? false end |
Instance Method Details
#build ⇒ Object
64 65 66 |
# File 'lib/souls/cli.rb', line 64 def build system("bundle exec rake build") 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 |
#deploy ⇒ Object
79 80 81 |
# File 'lib/souls/cli.rb', line 79 def deploy system("bundle exec rake deploy") 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 |
# 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}" if Dir.exist?(file_dir) && !Dir.empty?(file_dir) SOULs::Painter.error("Directory already exists and is not empty") return end service_name = "api" download_souls(app_name:, service_name:) mother_config_init(app_name:) download_github_actions(app_name:) initial_config_init(app_name:, service_name:) system("cd #{app_name}/apps/api && mv .env.sample .env") system("cd #{app_name} && git init --initial-branch=main") souls_api_credit(app_name) end |
#push ⇒ Object
74 75 76 |
# File 'lib/souls/cli.rb', line 74 def push system("bundle exec rake push") 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 45 46 |
# File 'lib/souls/cli/release/release.rb', line 6 def release SOULs::Painter.error("hey! It's Broken!") unless system("rspec") FileUtils.rm("apps/api/Gemfile.lock") if File.exist?("apps/api/Gemfile.lock") FileUtils.rm("apps/worker/Gemfile.lock") if File.exist?("apps/worker/Gemfile.lock") 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:) 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:) 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
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 86 87 |
# File 'lib/souls/cli/release/release.rb', line 49 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 |
#secret ⇒ Object
59 60 61 |
# File 'lib/souls/cli.rb', line 59 def secret puts(SecureRandom.alphanumeric(85)) 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 |
#tag ⇒ Object
69 70 71 |
# File 'lib/souls/cli.rb', line 69 def tag system("bundle exec rake tag") end |
#test ⇒ Object
53 54 55 56 |
# File 'lib/souls/cli.rb', line 53 def test system("rubocop -A") system("bundle exec rspec") end |