dogids-cli 0.0.27 → 0.0.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
 - data/.gitignore +1 -0
 - data/lib/dogids/deploy.rb +4 -0
 - data/lib/dogids/deploy/backend.rb +79 -0
 - data/lib/dogids/deploy/testing.rb +57 -0
 - data/lib/dogids/version.rb +1 -1
 - metadata +4 -2
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA1:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: f743e46965fa916cc7f6557dac0b012d6e291072
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 2e0476139077a7e00c0a20f89507c110294baa58
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: ffeb21a0433b7ea13f4d9c9d1fd32a2d416dd4aab8c47ee791309271146d27adc7c42bf5f14e8c15a65018b90a51c648c79c38a0d2b944235fbbe9fcc6f4d662
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 6f5a87c2d58e0ca6cd0150c7ec211e06c31fadf258e245ff04d415f3e0073c6fd1710ae2bd635317318a10e27fbf308825a460fd450fe6316e32aeb17aa00a50
         
     | 
    
        data/.gitignore
    CHANGED
    
    
    
        data/lib/dogids/deploy.rb
    CHANGED
    
    | 
         @@ -1,5 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            require "thor"
         
     | 
| 
      
 2 
     | 
    
         
            +
            require_relative "deploy/backend"
         
     | 
| 
       2 
3 
     | 
    
         
             
            require_relative "deploy/staging"
         
     | 
| 
      
 4 
     | 
    
         
            +
            require_relative "deploy/testing"
         
     | 
| 
       3 
5 
     | 
    
         
             
            require_relative "deploy/web"
         
     | 
| 
       4 
6 
     | 
    
         
             
            require_relative "deploy/worker"
         
     | 
| 
       5 
7 
     | 
    
         | 
| 
         @@ -11,7 +13,9 @@ module Dogids 
     | 
|
| 
       11 
13 
     | 
    
         
             
                  return self.send(deploy_command) if self.respond_to?(deploy_command)
         
     | 
| 
       12 
14 
     | 
    
         | 
| 
       13 
15 
     | 
    
         
             
                  puts "Deployment Commands:"
         
     | 
| 
      
 16 
     | 
    
         
            +
                  puts "  dogids deploy backend # Deploy the new backend"
         
     | 
| 
       14 
17 
     | 
    
         
             
                  puts "  dogids deploy staging # Deploy the staging.dogids.com storefront"
         
     | 
| 
      
 18 
     | 
    
         
            +
                  puts "  dogids deploy testing # Deploy the new backend to testing"
         
     | 
| 
       15 
19 
     | 
    
         
             
                  puts "  dogids deploy web     # Deploy the dogids.com storefront"
         
     | 
| 
       16 
20 
     | 
    
         
             
                  puts "  dogids deploy worker  # Deploy the dogids-backgrounder app"
         
     | 
| 
       17 
21 
     | 
    
         
             
                  puts " "
         
     | 
| 
         @@ -0,0 +1,79 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require "net/ssh"
         
     | 
| 
      
 2 
     | 
    
         
            +
            require "thor"
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
            module Dogids
         
     | 
| 
      
 5 
     | 
    
         
            +
              class Cli < Thor
         
     | 
| 
      
 6 
     | 
    
         
            +
                no_commands do
         
     | 
| 
      
 7 
     | 
    
         
            +
                  def deploy_backend
         
     | 
| 
      
 8 
     | 
    
         
            +
                    print_heading("Deploying backend to admin.dogids.com")
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
                    server_addresses = [
         
     | 
| 
      
 11 
     | 
    
         
            +
                      "admin"
         
     | 
| 
      
 12 
     | 
    
         
            +
                    ]
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
                    server_addresses.each do |server_address|
         
     | 
| 
      
 15 
     | 
    
         
            +
                      ssh_address = get_config_url("production","#{server_address}")
         
     | 
| 
      
 16 
     | 
    
         
            +
                      next if ssh_address == false
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
                      print_command("Server(#{server_address}): #{ssh_address}")
         
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
      
 20 
     | 
    
         
            +
                      Net::SSH.start(ssh_address, "dogids") do |ssh|
         
     | 
| 
      
 21 
     | 
    
         
            +
                        print_command("Checking the current git status")
         
     | 
| 
      
 22 
     | 
    
         
            +
                        ssh.exec!(backend_git_status_command) do |_channel, _stream, data|
         
     | 
| 
      
 23 
     | 
    
         
            +
                          print_command(data)
         
     | 
| 
      
 24 
     | 
    
         
            +
                        end
         
     | 
| 
      
 25 
     | 
    
         
            +
             
     | 
| 
      
 26 
     | 
    
         
            +
                        if yes?("-----> Continue with deployment? [no]")
         
     | 
| 
      
 27 
     | 
    
         
            +
                          print_command("Pulling latest from master")
         
     | 
| 
      
 28 
     | 
    
         
            +
                          ssh.exec!(backend_git_pull_command) do |_channel, _stream, data|
         
     | 
| 
      
 29 
     | 
    
         
            +
                            print_command(data)
         
     | 
| 
      
 30 
     | 
    
         
            +
                          end
         
     | 
| 
      
 31 
     | 
    
         
            +
                          
         
     | 
| 
      
 32 
     | 
    
         
            +
                          ssh.exec!(backend_composer_commands) do |_channel, _stream, data|
         
     | 
| 
      
 33 
     | 
    
         
            +
                            print_command(data)
         
     | 
| 
      
 34 
     | 
    
         
            +
                          end
         
     | 
| 
      
 35 
     | 
    
         
            +
             
     | 
| 
      
 36 
     | 
    
         
            +
                          ssh.exec!(backend_deployment_commands) do |_channel, _stream, data|
         
     | 
| 
      
 37 
     | 
    
         
            +
                            print_command(data)
         
     | 
| 
      
 38 
     | 
    
         
            +
                          end
         
     | 
| 
      
 39 
     | 
    
         
            +
                        end
         
     | 
| 
      
 40 
     | 
    
         
            +
                      end
         
     | 
| 
      
 41 
     | 
    
         
            +
                    end
         
     | 
| 
      
 42 
     | 
    
         
            +
                    print_heading("Done.")
         
     | 
| 
      
 43 
     | 
    
         
            +
                  end
         
     | 
| 
      
 44 
     | 
    
         
            +
                end
         
     | 
| 
      
 45 
     | 
    
         
            +
             
     | 
| 
      
 46 
     | 
    
         
            +
              private
         
     | 
| 
      
 47 
     | 
    
         
            +
              
         
     | 
| 
      
 48 
     | 
    
         
            +
                def backend_deployment_commands
         
     | 
| 
      
 49 
     | 
    
         
            +
                  commands = []
         
     | 
| 
      
 50 
     | 
    
         
            +
                  commands << "cd /home/dogids/apps/dogids-backend"
         
     | 
| 
      
 51 
     | 
    
         
            +
                  commands << "php artisan deploy --progress"
         
     | 
| 
      
 52 
     | 
    
         
            +
                  commands.join(" && ")
         
     | 
| 
      
 53 
     | 
    
         
            +
                end
         
     | 
| 
      
 54 
     | 
    
         
            +
                
         
     | 
| 
      
 55 
     | 
    
         
            +
                def backend_composer_commands
         
     | 
| 
      
 56 
     | 
    
         
            +
                  commands = []
         
     | 
| 
      
 57 
     | 
    
         
            +
                  commands << "cd /home/dogids/apps/dogids-backend"
         
     | 
| 
      
 58 
     | 
    
         
            +
                  commands << "composer install --no-dev --optimize-autoloader"
         
     | 
| 
      
 59 
     | 
    
         
            +
                  commands.join(" && ")
         
     | 
| 
      
 60 
     | 
    
         
            +
                end
         
     | 
| 
      
 61 
     | 
    
         
            +
             
     | 
| 
      
 62 
     | 
    
         
            +
                def backend_git_pull_command(branch = "master")
         
     | 
| 
      
 63 
     | 
    
         
            +
                  commands = []
         
     | 
| 
      
 64 
     | 
    
         
            +
                  commands << "cd /home/dogids/apps/dogids-backend"
         
     | 
| 
      
 65 
     | 
    
         
            +
                  commands << "git fetch origin #{branch}"
         
     | 
| 
      
 66 
     | 
    
         
            +
                  commands << "git checkout #{branch}"
         
     | 
| 
      
 67 
     | 
    
         
            +
                  commands << "git pull origin #{branch}"
         
     | 
| 
      
 68 
     | 
    
         
            +
                  commands.join(" && ")
         
     | 
| 
      
 69 
     | 
    
         
            +
                end
         
     | 
| 
      
 70 
     | 
    
         
            +
                
         
     | 
| 
      
 71 
     | 
    
         
            +
                def backend_git_status_command
         
     | 
| 
      
 72 
     | 
    
         
            +
                  commands = []
         
     | 
| 
      
 73 
     | 
    
         
            +
                  commands << "cd /home/dogids/apps/dogids-backend"
         
     | 
| 
      
 74 
     | 
    
         
            +
                  commands << "git status -s"
         
     | 
| 
      
 75 
     | 
    
         
            +
                  commands.join(" && ")
         
     | 
| 
      
 76 
     | 
    
         
            +
                end
         
     | 
| 
      
 77 
     | 
    
         
            +
             
     | 
| 
      
 78 
     | 
    
         
            +
              end
         
     | 
| 
      
 79 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,57 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require "net/ssh"
         
     | 
| 
      
 2 
     | 
    
         
            +
            require "thor"
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
            module Dogids
         
     | 
| 
      
 5 
     | 
    
         
            +
              class Cli < Thor
         
     | 
| 
      
 6 
     | 
    
         
            +
                no_commands do
         
     | 
| 
      
 7 
     | 
    
         
            +
                  def deploy_testing
         
     | 
| 
      
 8 
     | 
    
         
            +
                    print_heading("Deploying backend to testing.dogids.com")
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
                    server_addresses = [
         
     | 
| 
      
 11 
     | 
    
         
            +
                      "testing"
         
     | 
| 
      
 12 
     | 
    
         
            +
                    ]
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
                    server_addresses.each do |server_address|
         
     | 
| 
      
 15 
     | 
    
         
            +
                      ssh_address = get_config_url("staging","#{server_address}")
         
     | 
| 
      
 16 
     | 
    
         
            +
                      next if ssh_address == false
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
                      print_command("Server(#{server_address}): #{ssh_address}")
         
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
      
 20 
     | 
    
         
            +
                      Net::SSH.start(ssh_address, "dogids") do |ssh|
         
     | 
| 
      
 21 
     | 
    
         
            +
                        print_command("Checking the current git status")
         
     | 
| 
      
 22 
     | 
    
         
            +
                        ssh.exec!(backend_git_status_command) do |_channel, _stream, data|
         
     | 
| 
      
 23 
     | 
    
         
            +
                          print_command(data)
         
     | 
| 
      
 24 
     | 
    
         
            +
                        end
         
     | 
| 
      
 25 
     | 
    
         
            +
             
     | 
| 
      
 26 
     | 
    
         
            +
                        current_branch = ssh.exec!("cd /home/dogids/apps/dogids-backend && git rev-parse --abbrev-ref HEAD").strip
         
     | 
| 
      
 27 
     | 
    
         
            +
                        print_heading("Current Branch: #{current_branch}")
         
     | 
| 
      
 28 
     | 
    
         
            +
             
     | 
| 
      
 29 
     | 
    
         
            +
                        branch = ask("-----> Which branch would you like to deploy? [#{current_branch}]").strip
         
     | 
| 
      
 30 
     | 
    
         
            +
                        
         
     | 
| 
      
 31 
     | 
    
         
            +
                        break print_command("Fine, be that way.") if branch.downcase == "cancel"
         
     | 
| 
      
 32 
     | 
    
         
            +
                        
         
     | 
| 
      
 33 
     | 
    
         
            +
                        branch = current_branch if branch.length == 0
         
     | 
| 
      
 34 
     | 
    
         
            +
             
     | 
| 
      
 35 
     | 
    
         
            +
                        print_command("Pulling latest from #{branch}")
         
     | 
| 
      
 36 
     | 
    
         
            +
                        ssh.exec!(backend_git_pull_command(branch)) do |_channel, _stream, data|
         
     | 
| 
      
 37 
     | 
    
         
            +
                          print_command(data)
         
     | 
| 
      
 38 
     | 
    
         
            +
                        end
         
     | 
| 
      
 39 
     | 
    
         
            +
                        
         
     | 
| 
      
 40 
     | 
    
         
            +
                        ssh.exec!(backend_composer_commands) do |_channel, _stream, data|
         
     | 
| 
      
 41 
     | 
    
         
            +
                          print_command(data)
         
     | 
| 
      
 42 
     | 
    
         
            +
                        end
         
     | 
| 
      
 43 
     | 
    
         
            +
             
     | 
| 
      
 44 
     | 
    
         
            +
                        ssh.exec!(backend_deployment_commands) do |_channel, _stream, data|
         
     | 
| 
      
 45 
     | 
    
         
            +
                          print_command(data)
         
     | 
| 
      
 46 
     | 
    
         
            +
                        end
         
     | 
| 
      
 47 
     | 
    
         
            +
                      end
         
     | 
| 
      
 48 
     | 
    
         
            +
                    end
         
     | 
| 
      
 49 
     | 
    
         
            +
             
     | 
| 
      
 50 
     | 
    
         
            +
                    print_heading("Done.")
         
     | 
| 
      
 51 
     | 
    
         
            +
                  end
         
     | 
| 
      
 52 
     | 
    
         
            +
                end
         
     | 
| 
      
 53 
     | 
    
         
            +
             
     | 
| 
      
 54 
     | 
    
         
            +
              private
         
     | 
| 
      
 55 
     | 
    
         
            +
             
     | 
| 
      
 56 
     | 
    
         
            +
              end
         
     | 
| 
      
 57 
     | 
    
         
            +
            end
         
     | 
    
        data/lib/dogids/version.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | 
         @@ -1,14 +1,14 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: dogids-cli
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0.0. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.0.28
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Jaryd Krishnan
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date: 2017-05- 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2017-05-16 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: net-ssh
         
     | 
| 
         @@ -75,7 +75,9 @@ files: 
     | 
|
| 
       75 
75 
     | 
    
         
             
            - lib/dogids/cache/staging.rb
         
     | 
| 
       76 
76 
     | 
    
         
             
            - lib/dogids/config.rb
         
     | 
| 
       77 
77 
     | 
    
         
             
            - lib/dogids/deploy.rb
         
     | 
| 
      
 78 
     | 
    
         
            +
            - lib/dogids/deploy/backend.rb
         
     | 
| 
       78 
79 
     | 
    
         
             
            - lib/dogids/deploy/staging.rb
         
     | 
| 
      
 80 
     | 
    
         
            +
            - lib/dogids/deploy/testing.rb
         
     | 
| 
       79 
81 
     | 
    
         
             
            - lib/dogids/deploy/web.rb
         
     | 
| 
       80 
82 
     | 
    
         
             
            - lib/dogids/deploy/worker.rb
         
     | 
| 
       81 
83 
     | 
    
         
             
            - lib/dogids/reload.rb
         
     |