#!/usr/bin/env ruby require "souls" begin begin require "./config/initializers/souls" unless ARGV[0] == "new" || ARGV[0] == "init" rescue Souls::Init.config_init end case ARGV[0] when "new" if ARGV[1].nil? puts "you need to specify your app name \n `souls new app_name`" exit end puts "Which framework: \n 1. SOULs GraphQL API \n 2. SOULs GraphQL API gRPC compatible \n 3. SOULs gRPC Service \n 4. SOULs Media Web \n 5. SOULs Admin Web \n Enter Number: " strain = STDIN.gets.chomp.to_i (1..5).include?(strain) ? puts("Generating SOULs.. \n") : raise(StandardError, "Choose Number 1..5") Souls::Init.create_souls strain: strain, app_name: ARGV[1] when "s", "server" strain = Souls.configuration.strain case strain when "media", "admin" system "yarn dev" when "service" system "bundle exec rake run_server" else system "foreman start -f Procfile.dev" end when "c", "console" strain = Souls.configuration.strain case strain when "media", "admin" system "yarn dev" else case ARGV[1] when "RACK_ENV=production" system "bundle exec irb RACK_ENV=production" else system "bundle exec irb" end end when "i", "infra" Souls.send ARGV[1] when "p", "proto" Souls::Init.proto proto_package_name: "souls", service: ARGV[1] when "init" Souls::Init.config_init when "-v", "--version" puts Souls::VERSION when "add" case ARGV[1] when "mutation" Souls::Init.add_mutation class_name: "user", file_name: "hoi" when "type" Souls::Init.add_type class_name: "user", file_name: "hoi" when "connection" Souls::Init.add_connection class_name: "user", file_name: "hoi" when "edge" Souls::Init.add_edge class_name: "user", file_name: "hoi" when "rspec_mutation" Souls::Init.add_rspec_mutation class_name: "user", file_name: "hoi" else puts "HOI!" end when "g", "generate" case ARGV[1] when "test_dir" Souls::Init.test_dir when "node_type" Souls::Init.node_type class_name: ARGV[2] when "resolver" Souls::Init.resolver class_name: ARGV[2] when "job" Souls::Init.job class_name: ARGV[2] when "model" Souls::Init.model class_name: ARGV[2] when "mutation" Souls::Init.mutation class_name: ARGV[2] when "query" Souls::Init.query class_name: ARGV[2] when "type" Souls::Init.type class_name: ARGV[2] when "migrate" Souls::Init.single_migrate class_name: ARGV[2] when "migrate_all" Souls::Init.migrate_all when "migration" system "rake db:create_migration NAME=create_#{ARGV[2]}" when "rspec_factory" Souls::Init.rspec_factory class_name: ARGV[2] when "rspec_model" Souls::Init.rspec_model class_name: ARGV[2] when "rspec_mutation" Souls::Init.rspec_mutation class_name: ARGV[2] when "rspec_query" Souls::Init.rspec_query class_name: ARGV[2] when "rspec_type" Souls::Init.rspec_type class_name: ARGV[2] when "rspec_resolver" Souls::Init.rspec_resolver class_name: ARGV[2] else "SOULs!" end when "d" Souls::Init.delete_all class_name: ARGV[1] when "db:create" system "rake db:create && rake db:create RACK_ENV=test" when "db:migrate" case ARGV[1] when "RACK_ENV=production" system "rake db:migrate RACK_ENV=production" else system "rake db:migrate && rake db:migrate RACK_ENV=test" end when "db:seed" system "rake db:seed" when "db:migrate:reset" case ARGV[1] when "RACK_ENV=production" system "rake db:migrate:reset RACK_ENV=production DISABLE_DATABASE_ENVIRONMENT_CHECK=1" else system "rake db:migrate:reset && rake db:migrate:reset RACK_ENV=test" end when "t", "test" system "rubocop -a" system "bundle exec rspec" when "run" system "docker build . -t souls:latest" system "docker run --rm -p 3000:3000 souls:latest" when "deploy" project_id = Souls.configuration.project_id system "gcloud builds submit --config=cloudbuild.yml --project #{project_id}" else puts "Welcome to SOULs!" end rescue StandardError => error puts error.backtrace puts "Thank you!!" puts "SOULs" end