vikingio 0.0.7 → 0.0.8
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 +22 -22
 - data/Gemfile +4 -4
 - data/LICENSE.txt +22 -22
 - data/Output/VikingIOInstaller.exe +0 -0
 - data/README.md +13 -13
 - data/Rakefile +2 -2
 - data/bin/vikingio +10 -10
 - data/dlls/VikingIO.Network.Client.dll +0 -0
 - data/dlls/VikingIO.Network.dll +0 -0
 - data/lib/vikingio/cli.rb +53 -49
 - data/lib/vikingio/cli/client.rb +157 -157
 - data/lib/vikingio/cli/commands.rb +539 -512
 - data/lib/vikingio/cli/helpers.rb +115 -115
 - data/lib/vikingio/cli/version.rb +5 -5
 - data/lib/vikingio/cli/zip.vbs +16 -0
 - data/templates/MessageTemplate.cs +25 -25
 - data/templates/NetworkManager.cs +33 -33
 - data/templates/Program.cs +21 -21
 - data/templates/ServerNodeTemplate.cs +39 -39
 - data/templates/VikingIO.Config.cs +8 -8
 - data/vikingio-cli.gemspec +26 -23
 - data/vikingio.iss +13 -0
 - metadata +48 -3
 
| 
         @@ -1,512 +1,539 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            module VikingIO
         
     | 
| 
       2 
     | 
    
         
            -
              module CLI
         
     | 
| 
       3 
     | 
    
         
            -
                module Commands    
         
     | 
| 
       4 
     | 
    
         
            -
                                                                                   
         
     | 
| 
       5 
     | 
    
         
            -
                  BASE_PATH = "http://build1.vikingio.com/"
         
     | 
| 
       6 
     | 
    
         
            -
                  UNITY_COMPILER_PATH_OSX = "/Applications/Unity/Unity.app/Contents/Frameworks/MonoBleedingEdge/bin/gmcs"
         
     | 
| 
       7 
     | 
    
         
            -
                  UNITY_MONO_PATH_OSX = "/Applications/Unity/Unity.app/Contents/Frameworks/MonoBleedingEdge/bin/mono"  
         
     | 
| 
       8 
     | 
    
         
            -
                  UNITY_MONO_DLL_PATH_OSX = "/Applications/Unity/Unity.app/Contents/Frameworks/MonoBleedingEdge/lib/"
         
     | 
| 
       9 
     | 
    
         
            -
                  TEMPLATES_DIR = File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "..", "templates")) #File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "..", "templates"))
         
     | 
| 
       10 
     | 
    
         
            -
                  CSC_V35_64_PATH = File.expand_path("c:/Windows/Microsoft.Net/Framework64/v3.5/csc.exe") 
         
     | 
| 
       11 
     | 
    
         
            -
             
     | 
| 
       12 
     | 
    
         
            -
                  COMMANDS = [ 
         
     | 
| 
       13 
     | 
    
         
            -
                      ["help", {:short => "", :full => ""}],
         
     | 
| 
       14 
     | 
    
         
            -
                      ["login", {:short => "Authenticate with VikingIO", :full => ""}],
         
     | 
| 
       15 
     | 
    
         
            -
                      ["logout", {:short => "Clear your authentication credentials", :full => ""}],
         
     | 
| 
       16 
     | 
    
         
            -
                      ["create", {:short => "Create a new VikingIO application", :full => "Ex: vikingio create [app-name]"}], 
         
     | 
| 
       17 
     | 
    
         
            -
                      ["generate", {:short => "Generate a VikingIO node", :full => "Ex: vikingio generate node GameServer"}],
         
     | 
| 
       18 
     | 
    
         
            -
                      #["link", {:short => "Link the current directory with an existing VikingIO application", :full => "Ex: vikingio link [app-name]"}],
         
     | 
| 
       19 
     | 
    
         
            -
                      ["unlink", {:short => "Unlink the current directory with it's VikingIO application", :full => "Ex: vikingio unlink"}],
         
     | 
| 
       20 
     | 
    
         
            -
                      #["compile", {:short => "Compile your application on the server.", :full => "Once compiled, your application is ready to deploy."}],
         
     | 
| 
       21 
     | 
    
         
            -
                      ["deploy", {:short => "Deploy your application", :full => "The latest build will be deployed to our cloud infrastructure. [NOTE: Billing will begin immediately after your application is deployed.]"}],
         
     | 
| 
       22 
     | 
    
         
            -
                      #["destroy", {:short => "Destroy all production nodes in the VikingIO cloud", :full => "This will completely shut down and remove all of your production nodes for this application."}],
         
     | 
| 
       23 
     | 
    
         
            -
                      ["run", {:short => "Compile and run your application locally", :full => ""}],
         
     | 
| 
       24 
     | 
    
         
            -
                      #["status", {:short => "Get status of nodes", :full => ""}],
         
     | 
| 
       25 
     | 
    
         
            -
                      #[""]
         
     | 
| 
       26 
     | 
    
         
            -
                  ]                                         
         
     | 
| 
       27 
     | 
    
         
            -
                  
         
     | 
| 
       28 
     | 
    
         
            -
                  def self.run(command, args) 
         
     | 
| 
       29 
     | 
    
         
            -
                    puts "VikingIO Version: #{VikingIO::CLI::VERSION}"
         
     | 
| 
       30 
     | 
    
         
            -
             
     | 
| 
       31 
     | 
    
         
            -
                    case command
         
     | 
| 
       32 
     | 
    
         
            -
                      when "help"
         
     | 
| 
       33 
     | 
    
         
            -
                        help(args)
         
     | 
| 
       34 
     | 
    
         
            -
                      when "login"
         
     | 
| 
       35 
     | 
    
         
            -
                        login(args) 
         
     | 
| 
       36 
     | 
    
         
            -
                      when "logout"
         
     | 
| 
       37 
     | 
    
         
            -
                        logout(args)
         
     | 
| 
       38 
     | 
    
         
            -
                      when "create"
         
     | 
| 
       39 
     | 
    
         
            -
                        create(args)
         
     | 
| 
       40 
     | 
    
         
            -
                      when "generate"
         
     | 
| 
       41 
     | 
    
         
            -
                        generate(args)
         
     | 
| 
       42 
     | 
    
         
            -
                      when "link"
         
     | 
| 
       43 
     | 
    
         
            -
                        link(args)
         
     | 
| 
       44 
     | 
    
         
            -
                      when "unlink"
         
     | 
| 
       45 
     | 
    
         
            -
                        unlink(args)  
         
     | 
| 
       46 
     | 
    
         
            -
                      when "run"
         
     | 
| 
       47 
     | 
    
         
            -
                        compile_and_run(args)  
         
     | 
| 
       48 
     | 
    
         
            -
                      when "deploy"
         
     | 
| 
       49 
     | 
    
         
            -
                        deploy(args)   
         
     | 
| 
       50 
     | 
    
         
            -
                      #when "compile"
         
     | 
| 
       51 
     | 
    
         
            -
                      #  compile_on_server(args)  
         
     | 
| 
       52 
     | 
    
         
            -
                      when "destroy"
         
     | 
| 
       53 
     | 
    
         
            -
                        destroy(args) 
         
     | 
| 
       54 
     | 
    
         
            -
                      when "status"
         
     | 
| 
       55 
     | 
    
         
            -
                        status(args)
         
     | 
| 
       56 
     | 
    
         
            -
                      else
         
     | 
| 
       57 
     | 
    
         
            -
                        help(args)
         
     | 
| 
       58 
     | 
    
         
            -
                    end
         
     | 
| 
       59 
     | 
    
         
            -
                  end               
         
     | 
| 
       60 
     | 
    
         
            -
                  
         
     | 
| 
       61 
     | 
    
         
            -
                  def self.status(*args) 
         
     | 
| 
       62 
     | 
    
         
            -
                    app_data = VikingIO::CLI.get_app_data
         
     | 
| 
       63 
     | 
    
         
            -
                    user_key = VikingIO::CLI.get_netrc_key
         
     | 
| 
       64 
     | 
    
         
            -
                    puts VikingIO::CLI::Client.get_status(user_key, app_data["key"])
         
     | 
| 
       65 
     | 
    
         
            -
                  end 
         
     | 
| 
       66 
     | 
    
         
            -
                  
         
     | 
| 
       67 
     | 
    
         
            -
                  def self.destroy(*args)
         
     | 
| 
       68 
     | 
    
         
            -
                    
         
     | 
| 
       69 
     | 
    
         
            -
                    puts ""
         
     | 
| 
       70 
     | 
    
         
            -
                    puts "****** WARNING *******"
         
     | 
| 
       71 
     | 
    
         
            -
                    puts "This will shut down all of the server node instances for this application. You will have to re-deploy from scratch."
         
     | 
| 
       72 
     | 
    
         
            -
                    puts ""
         
     | 
| 
       73 
     | 
    
         
            -
                    
         
     | 
| 
       74 
     | 
    
         
            -
                    puts "Proceed? (y/n)" 
         
     | 
| 
       75 
     | 
    
         
            -
                    y_or_n = STDIN.gets.chomp.downcase
         
     | 
| 
       76 
     | 
    
         
            -
                    
         
     | 
| 
       77 
     | 
    
         
            -
                    if ["y", "yes"].include?(y_or_n)
         
     | 
| 
       78 
     | 
    
         
            -
                        
         
     | 
| 
       79 
     | 
    
         
            -
                    else
         
     | 
| 
       80 
     | 
    
         
            -
                      puts "Aborting."
         
     | 
| 
       81 
     | 
    
         
            -
                    end
         
     | 
| 
       82 
     | 
    
         
            -
                    
         
     | 
| 
       83 
     | 
    
         
            -
                  end
         
     | 
| 
       84 
     | 
    
         
            -
                  
         
     | 
| 
       85 
     | 
    
         
            -
                  # def self.compile_on_server(*args)
         
     | 
| 
       86 
     | 
    
         
            -
                  #   args.flatten!
         
     | 
| 
       87 
     | 
    
         
            -
                  #   
         
     | 
| 
       88 
     | 
    
         
            -
                  #   app_data = VikingIO::CLI.get_app_data
         
     | 
| 
       89 
     | 
    
         
            -
                  #   user_key = VikingIO::CLI.get_netrc_key
         
     | 
| 
       90 
     | 
    
         
            -
                  #                                        
         
     | 
| 
       91 
     | 
    
         
            -
                  #   puts "Synchronizing '#{app_data["name"]}' files..." 
         
     | 
| 
       92 
     | 
    
         
            -
                  #   
         
     | 
| 
       93 
     | 
    
         
            -
                  #   VikingIO::CLI::Client.request_build_job(user_key, app_data["key"])
         
     | 
| 
       94 
     | 
    
         
            -
                  #    
         
     | 
| 
       95 
     | 
    
         
            -
                  #   Dir.chdir(File.join(Dir.pwd, "Assets", "VikingIO")) do
         
     | 
| 
       96 
     | 
    
         
            -
                  #     files = Dir.glob("**/**/**").reject {|x| x.start_with?("Client") }.reject {|x| Dir.exist?(x) }.reject {|x| x.end_with?(".meta") }
         
     | 
| 
       97 
     | 
    
         
            -
                  #     files.each do |file|         
         
     | 
| 
       98 
     | 
    
         
            -
                  #       puts file + "..."
         
     | 
| 
       99 
     | 
    
         
            -
                  #       VikingIO::CLI::Client.synchronize_file(user_key, app_data["key"], file)
         
     | 
| 
       100 
     | 
    
         
            -
                  #     end
         
     | 
| 
       101 
     | 
    
         
            -
                  #   end           
         
     | 
| 
       102 
     | 
    
         
            -
                  #   
         
     | 
| 
       103 
     | 
    
         
            -
                  #   puts "Compiling..."
         
     | 
| 
       104 
     | 
    
         
            -
                  #   
         
     | 
| 
       105 
     | 
    
         
            -
                  #   VikingIO::CLI::Client.compile_server(user_key, app_data["key"], app_data["name"])
         
     | 
| 
       106 
     | 
    
         
            -
                  #   
         
     | 
| 
       107 
     | 
    
         
            -
                  #   puts "done."
         
     | 
| 
       108 
     | 
    
         
            -
                  # end     
         
     | 
| 
       109 
     | 
    
         
            -
                                   
         
     | 
| 
       110 
     | 
    
         
            -
                  def self.deploy(*args)
         
     | 
| 
       111 
     | 
    
         
            -
                    args.flatten!
         
     | 
| 
       112 
     | 
    
         
            -
                    
         
     | 
| 
       113 
     | 
    
         
            -
                    app_data = VikingIO::CLI.get_app_data
         
     | 
| 
       114 
     | 
    
         
            -
                    user_key = VikingIO::CLI.get_netrc_key  
         
     | 
| 
       115 
     | 
    
         
            -
                    node_data = VikingIO::CLI.get_node_data
         
     | 
| 
       116 
     | 
    
         
            -
                    
         
     | 
| 
       117 
     | 
    
         
            -
                    tmp_dir = File.join(Dir.tmpdir, "vikingio")    
         
     | 
| 
       118 
     | 
    
         
            -
                    
         
     | 
| 
       119 
     | 
    
         
            -
                    compile = !args.include?("--skip-compilation")
         
     | 
| 
       120 
     | 
    
         
            -
                    compilation_success = true 
         
     | 
| 
       121 
     | 
    
         
            -
                    
         
     | 
| 
       122 
     | 
    
         
            -
                    if args.include?("--check")
         
     | 
| 
       123 
     | 
    
         
            -
                      new_node_ct = VikingIO::CLI::Client.deploy_check(user_key, app_data["key"]).to_i
         
     | 
| 
       124 
     | 
    
         
            -
                      
         
     | 
| 
       125 
     | 
    
         
            -
                      if new_node_ct == 0
         
     | 
| 
       126 
     | 
    
         
            -
                        puts "No new nodes will be created."
         
     | 
| 
       127 
     | 
    
         
            -
                      else
         
     | 
| 
       128 
     | 
    
         
            -
                        puts "#{new_node_ct} new node(s) will be created."
         
     | 
| 
       129 
     | 
    
         
            -
                      end
         
     | 
| 
       130 
     | 
    
         
            -
                      return
         
     | 
| 
       131 
     | 
    
         
            -
                    end    
         
     | 
| 
       132 
     | 
    
         
            -
                    
         
     | 
| 
       133 
     | 
    
         
            -
                    if compile
         
     | 
| 
       134 
     | 
    
         
            -
                      if !self.compile_nodes(tmp_dir, node_data)
         
     | 
| 
       135 
     | 
    
         
            -
                        compilation_success = false 
         
     | 
| 
       136 
     | 
    
         
            -
                      else
         
     | 
| 
       137 
     | 
    
         
            -
             
     | 
| 
       138 
     | 
    
         
            -
                         
     | 
| 
       139 
     | 
    
         
            -
             
     | 
| 
       140 
     | 
    
         
            -
             
     | 
| 
       141 
     | 
    
         
            -
             
     | 
| 
       142 
     | 
    
         
            -
             
     | 
| 
       143 
     | 
    
         
            -
             
     | 
| 
       144 
     | 
    
         
            -
             
     | 
| 
       145 
     | 
    
         
            -
             
     | 
| 
       146 
     | 
    
         
            -
             
     | 
| 
       147 
     | 
    
         
            -
             
     | 
| 
       148 
     | 
    
         
            -
                          
         
     | 
| 
       149 
     | 
    
         
            -
             
     | 
| 
       150 
     | 
    
         
            -
             
     | 
| 
       151 
     | 
    
         
            -
             
     | 
| 
       152 
     | 
    
         
            -
             
     | 
| 
       153 
     | 
    
         
            -
             
     | 
| 
       154 
     | 
    
         
            -
             
     | 
| 
       155 
     | 
    
         
            -
             
     | 
| 
       156 
     | 
    
         
            -
             
     | 
| 
       157 
     | 
    
         
            -
             
     | 
| 
       158 
     | 
    
         
            -
             
     | 
| 
       159 
     | 
    
         
            -
             
     | 
| 
       160 
     | 
    
         
            -
             
     | 
| 
       161 
     | 
    
         
            -
             
     | 
| 
       162 
     | 
    
         
            -
             
     | 
| 
       163 
     | 
    
         
            -
             
     | 
| 
       164 
     | 
    
         
            -
             
     | 
| 
       165 
     | 
    
         
            -
             
     | 
| 
       166 
     | 
    
         
            -
             
     | 
| 
       167 
     | 
    
         
            -
                      
         
     | 
| 
       168 
     | 
    
         
            -
             
     | 
| 
       169 
     | 
    
         
            -
             
     | 
| 
       170 
     | 
    
         
            -
             
     | 
| 
       171 
     | 
    
         
            -
             
     | 
| 
       172 
     | 
    
         
            -
             
     | 
| 
       173 
     | 
    
         
            -
             
     | 
| 
       174 
     | 
    
         
            -
             
     | 
| 
       175 
     | 
    
         
            -
             
     | 
| 
       176 
     | 
    
         
            -
                       
     | 
| 
       177 
     | 
    
         
            -
                       
     | 
| 
       178 
     | 
    
         
            -
             
     | 
| 
       179 
     | 
    
         
            -
                      if  
     | 
| 
       180 
     | 
    
         
            -
                         
     | 
| 
       181 
     | 
    
         
            -
             
     | 
| 
       182 
     | 
    
         
            -
             
     | 
| 
       183 
     | 
    
         
            -
             
     | 
| 
       184 
     | 
    
         
            -
             
     | 
| 
       185 
     | 
    
         
            -
             
     | 
| 
       186 
     | 
    
         
            -
             
     | 
| 
       187 
     | 
    
         
            -
             
     | 
| 
       188 
     | 
    
         
            -
                       
     | 
| 
       189 
     | 
    
         
            -
                       
     | 
| 
       190 
     | 
    
         
            -
                      
         
     | 
| 
       191 
     | 
    
         
            -
             
     | 
| 
       192 
     | 
    
         
            -
             
     | 
| 
       193 
     | 
    
         
            -
                       
     | 
| 
       194 
     | 
    
         
            -
                      
         
     | 
| 
       195 
     | 
    
         
            -
                       
     | 
| 
       196 
     | 
    
         
            -
             
     | 
| 
       197 
     | 
    
         
            -
                       
     | 
| 
       198 
     | 
    
         
            -
             
     | 
| 
       199 
     | 
    
         
            -
             
     | 
| 
       200 
     | 
    
         
            -
             
     | 
| 
       201 
     | 
    
         
            -
             
     | 
| 
       202 
     | 
    
         
            -
             
     | 
| 
       203 
     | 
    
         
            -
                       
     | 
| 
       204 
     | 
    
         
            -
                       
     | 
| 
       205 
     | 
    
         
            -
             
     | 
| 
       206 
     | 
    
         
            -
                       
     | 
| 
       207 
     | 
    
         
            -
             
     | 
| 
       208 
     | 
    
         
            -
                       
     | 
| 
       209 
     | 
    
         
            -
             
     | 
| 
       210 
     | 
    
         
            -
             
     | 
| 
       211 
     | 
    
         
            -
             
     | 
| 
       212 
     | 
    
         
            -
             
     | 
| 
       213 
     | 
    
         
            -
                       
     | 
| 
       214 
     | 
    
         
            -
             
     | 
| 
       215 
     | 
    
         
            -
             
     | 
| 
       216 
     | 
    
         
            -
             
     | 
| 
       217 
     | 
    
         
            -
             
     | 
| 
       218 
     | 
    
         
            -
                      
         
     | 
| 
       219 
     | 
    
         
            -
             
     | 
| 
       220 
     | 
    
         
            -
             
     | 
| 
       221 
     | 
    
         
            -
             
     | 
| 
       222 
     | 
    
         
            -
             
     | 
| 
       223 
     | 
    
         
            -
             
     | 
| 
       224 
     | 
    
         
            -
             
     | 
| 
       225 
     | 
    
         
            -
             
     | 
| 
       226 
     | 
    
         
            -
             
     | 
| 
       227 
     | 
    
         
            -
                         
     | 
| 
       228 
     | 
    
         
            -
             
     | 
| 
       229 
     | 
    
         
            -
             
     | 
| 
       230 
     | 
    
         
            -
             
     | 
| 
       231 
     | 
    
         
            -
             
     | 
| 
       232 
     | 
    
         
            -
             
     | 
| 
       233 
     | 
    
         
            -
             
     | 
| 
       234 
     | 
    
         
            -
             
     | 
| 
       235 
     | 
    
         
            -
             
     | 
| 
       236 
     | 
    
         
            -
             
     | 
| 
       237 
     | 
    
         
            -
             
     | 
| 
       238 
     | 
    
         
            -
             
     | 
| 
       239 
     | 
    
         
            -
             
     | 
| 
       240 
     | 
    
         
            -
             
     | 
| 
       241 
     | 
    
         
            -
             
     | 
| 
       242 
     | 
    
         
            -
             
     | 
| 
       243 
     | 
    
         
            -
                        
         
     | 
| 
       244 
     | 
    
         
            -
             
     | 
| 
       245 
     | 
    
         
            -
             
     | 
| 
       246 
     | 
    
         
            -
                             
     | 
| 
       247 
     | 
    
         
            -
             
     | 
| 
       248 
     | 
    
         
            -
                         
     | 
| 
       249 
     | 
    
         
            -
             
     | 
| 
       250 
     | 
    
         
            -
             
     | 
| 
       251 
     | 
    
         
            -
             
     | 
| 
       252 
     | 
    
         
            -
             
     | 
| 
       253 
     | 
    
         
            -
                        
         
     | 
| 
       254 
     | 
    
         
            -
             
     | 
| 
       255 
     | 
    
         
            -
             
     | 
| 
       256 
     | 
    
         
            -
             
     | 
| 
       257 
     | 
    
         
            -
             
     | 
| 
       258 
     | 
    
         
            -
                         
     | 
| 
       259 
     | 
    
         
            -
             
     | 
| 
       260 
     | 
    
         
            -
                         
     | 
| 
       261 
     | 
    
         
            -
             
     | 
| 
       262 
     | 
    
         
            -
             
     | 
| 
       263 
     | 
    
         
            -
                           
     | 
| 
       264 
     | 
    
         
            -
                           
     | 
| 
       265 
     | 
    
         
            -
             
     | 
| 
       266 
     | 
    
         
            -
             
     | 
| 
       267 
     | 
    
         
            -
             
     | 
| 
       268 
     | 
    
         
            -
             
     | 
| 
       269 
     | 
    
         
            -
             
     | 
| 
       270 
     | 
    
         
            -
             
     | 
| 
       271 
     | 
    
         
            -
             
     | 
| 
       272 
     | 
    
         
            -
             
     | 
| 
       273 
     | 
    
         
            -
             
     | 
| 
       274 
     | 
    
         
            -
             
     | 
| 
       275 
     | 
    
         
            -
             
     | 
| 
       276 
     | 
    
         
            -
             
     | 
| 
       277 
     | 
    
         
            -
             
     | 
| 
       278 
     | 
    
         
            -
             
     | 
| 
       279 
     | 
    
         
            -
             
     | 
| 
       280 
     | 
    
         
            -
             
     | 
| 
       281 
     | 
    
         
            -
             
     | 
| 
       282 
     | 
    
         
            -
             
     | 
| 
       283 
     | 
    
         
            -
             
     | 
| 
       284 
     | 
    
         
            -
             
     | 
| 
       285 
     | 
    
         
            -
             
     | 
| 
       286 
     | 
    
         
            -
             
     | 
| 
       287 
     | 
    
         
            -
                        
         
     | 
| 
       288 
     | 
    
         
            -
                       
     | 
| 
       289 
     | 
    
         
            -
                         
     | 
| 
       290 
     | 
    
         
            -
             
     | 
| 
       291 
     | 
    
         
            -
                           
     | 
| 
       292 
     | 
    
         
            -
                         
     | 
| 
       293 
     | 
    
         
            -
             
     | 
| 
       294 
     | 
    
         
            -
             
     | 
| 
       295 
     | 
    
         
            -
             
     | 
| 
       296 
     | 
    
         
            -
                       
     | 
| 
       297 
     | 
    
         
            -
             
     | 
| 
       298 
     | 
    
         
            -
                       
     | 
| 
       299 
     | 
    
         
            -
             
     | 
| 
       300 
     | 
    
         
            -
             
     | 
| 
       301 
     | 
    
         
            -
             
     | 
| 
       302 
     | 
    
         
            -
             
     | 
| 
       303 
     | 
    
         
            -
             
     | 
| 
       304 
     | 
    
         
            -
             
     | 
| 
       305 
     | 
    
         
            -
             
     | 
| 
       306 
     | 
    
         
            -
             
     | 
| 
       307 
     | 
    
         
            -
             
     | 
| 
       308 
     | 
    
         
            -
             
     | 
| 
       309 
     | 
    
         
            -
                     
     | 
| 
       310 
     | 
    
         
            -
             
     | 
| 
       311 
     | 
    
         
            -
             
     | 
| 
       312 
     | 
    
         
            -
             
     | 
| 
       313 
     | 
    
         
            -
                   
     | 
| 
       314 
     | 
    
         
            -
             
     | 
| 
       315 
     | 
    
         
            -
             
     | 
| 
       316 
     | 
    
         
            -
             
     | 
| 
       317 
     | 
    
         
            -
             
     | 
| 
       318 
     | 
    
         
            -
             
     | 
| 
       319 
     | 
    
         
            -
             
     | 
| 
       320 
     | 
    
         
            -
             
     | 
| 
       321 
     | 
    
         
            -
             
     | 
| 
       322 
     | 
    
         
            -
             
     | 
| 
       323 
     | 
    
         
            -
             
     | 
| 
       324 
     | 
    
         
            -
             
     | 
| 
       325 
     | 
    
         
            -
             
     | 
| 
       326 
     | 
    
         
            -
             
     | 
| 
       327 
     | 
    
         
            -
             
     | 
| 
       328 
     | 
    
         
            -
             
     | 
| 
       329 
     | 
    
         
            -
             
     | 
| 
       330 
     | 
    
         
            -
             
     | 
| 
       331 
     | 
    
         
            -
             
     | 
| 
       332 
     | 
    
         
            -
             
     | 
| 
       333 
     | 
    
         
            -
             
     | 
| 
       334 
     | 
    
         
            -
                    
         
     | 
| 
       335 
     | 
    
         
            -
             
     | 
| 
       336 
     | 
    
         
            -
             
     | 
| 
       337 
     | 
    
         
            -
             
     | 
| 
       338 
     | 
    
         
            -
             
     | 
| 
       339 
     | 
    
         
            -
             
     | 
| 
       340 
     | 
    
         
            -
             
     | 
| 
       341 
     | 
    
         
            -
             
     | 
| 
       342 
     | 
    
         
            -
             
     | 
| 
       343 
     | 
    
         
            -
                    
         
     | 
| 
       344 
     | 
    
         
            -
                     
     | 
| 
       345 
     | 
    
         
            -
             
     | 
| 
       346 
     | 
    
         
            -
             
     | 
| 
       347 
     | 
    
         
            -
                   
     | 
| 
       348 
     | 
    
         
            -
             
     | 
| 
       349 
     | 
    
         
            -
             
     | 
| 
       350 
     | 
    
         
            -
                     
     | 
| 
       351 
     | 
    
         
            -
             
     | 
| 
       352 
     | 
    
         
            -
             
     | 
| 
       353 
     | 
    
         
            -
                     
     | 
| 
       354 
     | 
    
         
            -
                     
     | 
| 
       355 
     | 
    
         
            -
                    
         
     | 
| 
       356 
     | 
    
         
            -
             
     | 
| 
       357 
     | 
    
         
            -
                       
     | 
| 
       358 
     | 
    
         
            -
             
     | 
| 
       359 
     | 
    
         
            -
             
     | 
| 
       360 
     | 
    
         
            -
             
     | 
| 
       361 
     | 
    
         
            -
             
     | 
| 
       362 
     | 
    
         
            -
             
     | 
| 
       363 
     | 
    
         
            -
             
     | 
| 
       364 
     | 
    
         
            -
             
     | 
| 
       365 
     | 
    
         
            -
                      puts "" 
     | 
| 
       366 
     | 
    
         
            -
                      
         
     | 
| 
       367 
     | 
    
         
            -
             
     | 
| 
       368 
     | 
    
         
            -
             
     | 
| 
       369 
     | 
    
         
            -
             
     | 
| 
       370 
     | 
    
         
            -
             
     | 
| 
       371 
     | 
    
         
            -
             
     | 
| 
       372 
     | 
    
         
            -
             
     | 
| 
       373 
     | 
    
         
            -
             
     | 
| 
       374 
     | 
    
         
            -
             
     | 
| 
       375 
     | 
    
         
            -
             
     | 
| 
       376 
     | 
    
         
            -
             
     | 
| 
       377 
     | 
    
         
            -
             
     | 
| 
       378 
     | 
    
         
            -
             
     | 
| 
       379 
     | 
    
         
            -
             
     | 
| 
       380 
     | 
    
         
            -
             
     | 
| 
       381 
     | 
    
         
            -
                       
     | 
| 
       382 
     | 
    
         
            -
             
     | 
| 
       383 
     | 
    
         
            -
             
     | 
| 
       384 
     | 
    
         
            -
                      
         
     | 
| 
       385 
     | 
    
         
            -
             
     | 
| 
       386 
     | 
    
         
            -
                         
     | 
| 
       387 
     | 
    
         
            -
             
     | 
| 
       388 
     | 
    
         
            -
             
     | 
| 
       389 
     | 
    
         
            -
             
     | 
| 
       390 
     | 
    
         
            -
             
     | 
| 
       391 
     | 
    
         
            -
                       
     | 
| 
       392 
     | 
    
         
            -
                      
         
     | 
| 
       393 
     | 
    
         
            -
                       
     | 
| 
       394 
     | 
    
         
            -
                       
     | 
| 
       395 
     | 
    
         
            -
             
     | 
| 
       396 
     | 
    
         
            -
             
     | 
| 
       397 
     | 
    
         
            -
             
     | 
| 
       398 
     | 
    
         
            -
                       
     | 
| 
       399 
     | 
    
         
            -
                       
     | 
| 
       400 
     | 
    
         
            -
                      File. 
     | 
| 
       401 
     | 
    
         
            -
                       
     | 
| 
       402 
     | 
    
         
            -
             
     | 
| 
       403 
     | 
    
         
            -
             
     | 
| 
       404 
     | 
    
         
            -
             
     | 
| 
       405 
     | 
    
         
            -
             
     | 
| 
       406 
     | 
    
         
            -
                       
     | 
| 
       407 
     | 
    
         
            -
             
     | 
| 
       408 
     | 
    
         
            -
             
     | 
| 
       409 
     | 
    
         
            -
             
     | 
| 
       410 
     | 
    
         
            -
             
     | 
| 
       411 
     | 
    
         
            -
             
     | 
| 
       412 
     | 
    
         
            -
             
     | 
| 
       413 
     | 
    
         
            -
             
     | 
| 
       414 
     | 
    
         
            -
             
     | 
| 
       415 
     | 
    
         
            -
             
     | 
| 
       416 
     | 
    
         
            -
             
     | 
| 
       417 
     | 
    
         
            -
             
     | 
| 
       418 
     | 
    
         
            -
             
     | 
| 
       419 
     | 
    
         
            -
             
     | 
| 
       420 
     | 
    
         
            -
             
     | 
| 
       421 
     | 
    
         
            -
             
     | 
| 
       422 
     | 
    
         
            -
                     
     | 
| 
       423 
     | 
    
         
            -
                     
     | 
| 
       424 
     | 
    
         
            -
             
     | 
| 
       425 
     | 
    
         
            -
             
     | 
| 
       426 
     | 
    
         
            -
             
     | 
| 
       427 
     | 
    
         
            -
             
     | 
| 
       428 
     | 
    
         
            -
             
     | 
| 
       429 
     | 
    
         
            -
                     
     | 
| 
       430 
     | 
    
         
            -
             
     | 
| 
       431 
     | 
    
         
            -
                     
     | 
| 
       432 
     | 
    
         
            -
             
     | 
| 
       433 
     | 
    
         
            -
             
     | 
| 
       434 
     | 
    
         
            -
                     
     | 
| 
       435 
     | 
    
         
            -
                     
     | 
| 
       436 
     | 
    
         
            -
             
     | 
| 
       437 
     | 
    
         
            -
             
     | 
| 
       438 
     | 
    
         
            -
             
     | 
| 
       439 
     | 
    
         
            -
             
     | 
| 
       440 
     | 
    
         
            -
                     
     | 
| 
       441 
     | 
    
         
            -
                     
     | 
| 
       442 
     | 
    
         
            -
             
     | 
| 
       443 
     | 
    
         
            -
             
     | 
| 
       444 
     | 
    
         
            -
             
     | 
| 
       445 
     | 
    
         
            -
             
     | 
| 
       446 
     | 
    
         
            -
             
     | 
| 
       447 
     | 
    
         
            -
             
     | 
| 
       448 
     | 
    
         
            -
             
     | 
| 
       449 
     | 
    
         
            -
             
     | 
| 
       450 
     | 
    
         
            -
             
     | 
| 
       451 
     | 
    
         
            -
             
     | 
| 
       452 
     | 
    
         
            -
             
     | 
| 
       453 
     | 
    
         
            -
             
     | 
| 
       454 
     | 
    
         
            -
             
     | 
| 
       455 
     | 
    
         
            -
             
     | 
| 
       456 
     | 
    
         
            -
             
     | 
| 
       457 
     | 
    
         
            -
                       
     | 
| 
       458 
     | 
    
         
            -
             
     | 
| 
       459 
     | 
    
         
            -
                     
     | 
| 
       460 
     | 
    
         
            -
                    puts "" 
     | 
| 
       461 
     | 
    
         
            -
             
     | 
| 
       462 
     | 
    
         
            -
             
     | 
| 
       463 
     | 
    
         
            -
             
     | 
| 
       464 
     | 
    
         
            -
             
     | 
| 
       465 
     | 
    
         
            -
             
     | 
| 
       466 
     | 
    
         
            -
             
     | 
| 
       467 
     | 
    
         
            -
                     
     | 
| 
       468 
     | 
    
         
            -
                     
     | 
| 
       469 
     | 
    
         
            -
             
     | 
| 
       470 
     | 
    
         
            -
             
     | 
| 
       471 
     | 
    
         
            -
             
     | 
| 
       472 
     | 
    
         
            -
             
     | 
| 
       473 
     | 
    
         
            -
             
     | 
| 
       474 
     | 
    
         
            -
             
     | 
| 
       475 
     | 
    
         
            -
             
     | 
| 
       476 
     | 
    
         
            -
             
     | 
| 
       477 
     | 
    
         
            -
             
     | 
| 
       478 
     | 
    
         
            -
             
     | 
| 
       479 
     | 
    
         
            -
             
     | 
| 
       480 
     | 
    
         
            -
                    
         
     | 
| 
       481 
     | 
    
         
            -
             
     | 
| 
       482 
     | 
    
         
            -
             
     | 
| 
       483 
     | 
    
         
            -
                       
     | 
| 
       484 
     | 
    
         
            -
             
     | 
| 
       485 
     | 
    
         
            -
             
     | 
| 
       486 
     | 
    
         
            -
                     
     | 
| 
       487 
     | 
    
         
            -
             
     | 
| 
       488 
     | 
    
         
            -
             
     | 
| 
       489 
     | 
    
         
            -
             
     | 
| 
       490 
     | 
    
         
            -
             
     | 
| 
       491 
     | 
    
         
            -
             
     | 
| 
       492 
     | 
    
         
            -
             
     | 
| 
       493 
     | 
    
         
            -
                     
     | 
| 
       494 
     | 
    
         
            -
             
     | 
| 
       495 
     | 
    
         
            -
             
     | 
| 
       496 
     | 
    
         
            -
                     
     | 
| 
       497 
     | 
    
         
            -
                    
         
     | 
| 
       498 
     | 
    
         
            -
             
     | 
| 
       499 
     | 
    
         
            -
             
     | 
| 
       500 
     | 
    
         
            -
             
     | 
| 
       501 
     | 
    
         
            -
                     
     | 
| 
       502 
     | 
    
         
            -
             
     | 
| 
       503 
     | 
    
         
            -
             
     | 
| 
       504 
     | 
    
         
            -
             
     | 
| 
       505 
     | 
    
         
            -
             
     | 
| 
       506 
     | 
    
         
            -
                 
     | 
| 
       507 
     | 
    
         
            -
             
     | 
| 
       508 
     | 
    
         
            -
             
     | 
| 
       509 
     | 
    
         
            -
             
     | 
| 
       510 
     | 
    
         
            -
             
     | 
| 
       511 
     | 
    
         
            -
             
     | 
| 
       512 
     | 
    
         
            -
             
     | 
| 
      
 1 
     | 
    
         
            +
            module VikingIO
         
     | 
| 
      
 2 
     | 
    
         
            +
              module CLI
         
     | 
| 
      
 3 
     | 
    
         
            +
                module Commands    
         
     | 
| 
      
 4 
     | 
    
         
            +
                                                                                   
         
     | 
| 
      
 5 
     | 
    
         
            +
                  BASE_PATH = "http://build1.vikingio.com/"
         
     | 
| 
      
 6 
     | 
    
         
            +
                  UNITY_COMPILER_PATH_OSX = "/Applications/Unity/Unity.app/Contents/Frameworks/MonoBleedingEdge/bin/gmcs"
         
     | 
| 
      
 7 
     | 
    
         
            +
                  UNITY_MONO_PATH_OSX = "/Applications/Unity/Unity.app/Contents/Frameworks/MonoBleedingEdge/bin/mono"  
         
     | 
| 
      
 8 
     | 
    
         
            +
                  UNITY_MONO_DLL_PATH_OSX = "/Applications/Unity/Unity.app/Contents/Frameworks/MonoBleedingEdge/lib/"
         
     | 
| 
      
 9 
     | 
    
         
            +
                  TEMPLATES_DIR = File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "..", "templates")) #File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "..", "templates"))
         
     | 
| 
      
 10 
     | 
    
         
            +
                  CSC_V35_64_PATH = File.expand_path("c:/Windows/Microsoft.Net/Framework64/v3.5/csc.exe") 
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
                  COMMANDS = [ 
         
     | 
| 
      
 13 
     | 
    
         
            +
                      ["help", {:short => "", :full => ""}],
         
     | 
| 
      
 14 
     | 
    
         
            +
                      ["login", {:short => "Authenticate with VikingIO", :full => ""}],
         
     | 
| 
      
 15 
     | 
    
         
            +
                      ["logout", {:short => "Clear your authentication credentials", :full => ""}],
         
     | 
| 
      
 16 
     | 
    
         
            +
                      ["create", {:short => "Create a new VikingIO application", :full => "Ex: vikingio create [app-name]"}], 
         
     | 
| 
      
 17 
     | 
    
         
            +
                      ["generate", {:short => "Generate a VikingIO node", :full => "Ex: vikingio generate node GameServer"}],
         
     | 
| 
      
 18 
     | 
    
         
            +
                      #["link", {:short => "Link the current directory with an existing VikingIO application", :full => "Ex: vikingio link [app-name]"}],
         
     | 
| 
      
 19 
     | 
    
         
            +
                      ["unlink", {:short => "Unlink the current directory with it's VikingIO application", :full => "Ex: vikingio unlink"}],
         
     | 
| 
      
 20 
     | 
    
         
            +
                      #["compile", {:short => "Compile your application on the server.", :full => "Once compiled, your application is ready to deploy."}],
         
     | 
| 
      
 21 
     | 
    
         
            +
                      ["deploy", {:short => "Deploy your application", :full => "The latest build will be deployed to our cloud infrastructure. [NOTE: Billing will begin immediately after your application is deployed.]"}],
         
     | 
| 
      
 22 
     | 
    
         
            +
                      #["destroy", {:short => "Destroy all production nodes in the VikingIO cloud", :full => "This will completely shut down and remove all of your production nodes for this application."}],
         
     | 
| 
      
 23 
     | 
    
         
            +
                      ["run", {:short => "Compile and run your application locally", :full => ""}],
         
     | 
| 
      
 24 
     | 
    
         
            +
                      #["status", {:short => "Get status of nodes", :full => ""}],
         
     | 
| 
      
 25 
     | 
    
         
            +
                      #[""]
         
     | 
| 
      
 26 
     | 
    
         
            +
                  ]                                         
         
     | 
| 
      
 27 
     | 
    
         
            +
                  
         
     | 
| 
      
 28 
     | 
    
         
            +
                  def self.run(command, args) 
         
     | 
| 
      
 29 
     | 
    
         
            +
                    puts "VikingIO Version: #{VikingIO::CLI::VERSION}"
         
     | 
| 
      
 30 
     | 
    
         
            +
             
     | 
| 
      
 31 
     | 
    
         
            +
                    case command
         
     | 
| 
      
 32 
     | 
    
         
            +
                      when "help"
         
     | 
| 
      
 33 
     | 
    
         
            +
                        help(args)
         
     | 
| 
      
 34 
     | 
    
         
            +
                      when "login"
         
     | 
| 
      
 35 
     | 
    
         
            +
                        login(args) 
         
     | 
| 
      
 36 
     | 
    
         
            +
                      when "logout"
         
     | 
| 
      
 37 
     | 
    
         
            +
                        logout(args)
         
     | 
| 
      
 38 
     | 
    
         
            +
                      when "create"
         
     | 
| 
      
 39 
     | 
    
         
            +
                        create(args)
         
     | 
| 
      
 40 
     | 
    
         
            +
                      when "generate"
         
     | 
| 
      
 41 
     | 
    
         
            +
                        generate(args)
         
     | 
| 
      
 42 
     | 
    
         
            +
                      when "link"
         
     | 
| 
      
 43 
     | 
    
         
            +
                        link(args)
         
     | 
| 
      
 44 
     | 
    
         
            +
                      when "unlink"
         
     | 
| 
      
 45 
     | 
    
         
            +
                        unlink(args)  
         
     | 
| 
      
 46 
     | 
    
         
            +
                      when "run"
         
     | 
| 
      
 47 
     | 
    
         
            +
                        compile_and_run(args)  
         
     | 
| 
      
 48 
     | 
    
         
            +
                      when "deploy"
         
     | 
| 
      
 49 
     | 
    
         
            +
                        deploy(args)   
         
     | 
| 
      
 50 
     | 
    
         
            +
                      #when "compile"
         
     | 
| 
      
 51 
     | 
    
         
            +
                      #  compile_on_server(args)  
         
     | 
| 
      
 52 
     | 
    
         
            +
                      when "destroy"
         
     | 
| 
      
 53 
     | 
    
         
            +
                        destroy(args) 
         
     | 
| 
      
 54 
     | 
    
         
            +
                      when "status"
         
     | 
| 
      
 55 
     | 
    
         
            +
                        status(args)
         
     | 
| 
      
 56 
     | 
    
         
            +
                      else
         
     | 
| 
      
 57 
     | 
    
         
            +
                        help(args)
         
     | 
| 
      
 58 
     | 
    
         
            +
                    end
         
     | 
| 
      
 59 
     | 
    
         
            +
                  end               
         
     | 
| 
      
 60 
     | 
    
         
            +
                  
         
     | 
| 
      
 61 
     | 
    
         
            +
                  def self.status(*args) 
         
     | 
| 
      
 62 
     | 
    
         
            +
                    app_data = VikingIO::CLI.get_app_data
         
     | 
| 
      
 63 
     | 
    
         
            +
                    user_key = VikingIO::CLI.get_netrc_key
         
     | 
| 
      
 64 
     | 
    
         
            +
                    puts VikingIO::CLI::Client.get_status(user_key, app_data["key"])
         
     | 
| 
      
 65 
     | 
    
         
            +
                  end 
         
     | 
| 
      
 66 
     | 
    
         
            +
                  
         
     | 
| 
      
 67 
     | 
    
         
            +
                  def self.destroy(*args)
         
     | 
| 
      
 68 
     | 
    
         
            +
                    
         
     | 
| 
      
 69 
     | 
    
         
            +
                    puts ""
         
     | 
| 
      
 70 
     | 
    
         
            +
                    puts "****** WARNING *******"
         
     | 
| 
      
 71 
     | 
    
         
            +
                    puts "This will shut down all of the server node instances for this application. You will have to re-deploy from scratch."
         
     | 
| 
      
 72 
     | 
    
         
            +
                    puts ""
         
     | 
| 
      
 73 
     | 
    
         
            +
                    
         
     | 
| 
      
 74 
     | 
    
         
            +
                    puts "Proceed? (y/n)" 
         
     | 
| 
      
 75 
     | 
    
         
            +
                    y_or_n = STDIN.gets.chomp.downcase
         
     | 
| 
      
 76 
     | 
    
         
            +
                    
         
     | 
| 
      
 77 
     | 
    
         
            +
                    if ["y", "yes"].include?(y_or_n)
         
     | 
| 
      
 78 
     | 
    
         
            +
                        
         
     | 
| 
      
 79 
     | 
    
         
            +
                    else
         
     | 
| 
      
 80 
     | 
    
         
            +
                      puts "Aborting."
         
     | 
| 
      
 81 
     | 
    
         
            +
                    end
         
     | 
| 
      
 82 
     | 
    
         
            +
                    
         
     | 
| 
      
 83 
     | 
    
         
            +
                  end
         
     | 
| 
      
 84 
     | 
    
         
            +
                  
         
     | 
| 
      
 85 
     | 
    
         
            +
                  # def self.compile_on_server(*args)
         
     | 
| 
      
 86 
     | 
    
         
            +
                  #   args.flatten!
         
     | 
| 
      
 87 
     | 
    
         
            +
                  #   
         
     | 
| 
      
 88 
     | 
    
         
            +
                  #   app_data = VikingIO::CLI.get_app_data
         
     | 
| 
      
 89 
     | 
    
         
            +
                  #   user_key = VikingIO::CLI.get_netrc_key
         
     | 
| 
      
 90 
     | 
    
         
            +
                  #                                        
         
     | 
| 
      
 91 
     | 
    
         
            +
                  #   puts "Synchronizing '#{app_data["name"]}' files..." 
         
     | 
| 
      
 92 
     | 
    
         
            +
                  #   
         
     | 
| 
      
 93 
     | 
    
         
            +
                  #   VikingIO::CLI::Client.request_build_job(user_key, app_data["key"])
         
     | 
| 
      
 94 
     | 
    
         
            +
                  #    
         
     | 
| 
      
 95 
     | 
    
         
            +
                  #   Dir.chdir(File.join(Dir.pwd, "Assets", "VikingIO")) do
         
     | 
| 
      
 96 
     | 
    
         
            +
                  #     files = Dir.glob("**/**/**").reject {|x| x.start_with?("Client") }.reject {|x| Dir.exist?(x) }.reject {|x| x.end_with?(".meta") }
         
     | 
| 
      
 97 
     | 
    
         
            +
                  #     files.each do |file|         
         
     | 
| 
      
 98 
     | 
    
         
            +
                  #       puts file + "..."
         
     | 
| 
      
 99 
     | 
    
         
            +
                  #       VikingIO::CLI::Client.synchronize_file(user_key, app_data["key"], file)
         
     | 
| 
      
 100 
     | 
    
         
            +
                  #     end
         
     | 
| 
      
 101 
     | 
    
         
            +
                  #   end           
         
     | 
| 
      
 102 
     | 
    
         
            +
                  #   
         
     | 
| 
      
 103 
     | 
    
         
            +
                  #   puts "Compiling..."
         
     | 
| 
      
 104 
     | 
    
         
            +
                  #   
         
     | 
| 
      
 105 
     | 
    
         
            +
                  #   VikingIO::CLI::Client.compile_server(user_key, app_data["key"], app_data["name"])
         
     | 
| 
      
 106 
     | 
    
         
            +
                  #   
         
     | 
| 
      
 107 
     | 
    
         
            +
                  #   puts "done."
         
     | 
| 
      
 108 
     | 
    
         
            +
                  # end     
         
     | 
| 
      
 109 
     | 
    
         
            +
                                   
         
     | 
| 
      
 110 
     | 
    
         
            +
                  def self.deploy(*args)
         
     | 
| 
      
 111 
     | 
    
         
            +
                    args.flatten!
         
     | 
| 
      
 112 
     | 
    
         
            +
                    
         
     | 
| 
      
 113 
     | 
    
         
            +
                    app_data = VikingIO::CLI.get_app_data
         
     | 
| 
      
 114 
     | 
    
         
            +
                    user_key = VikingIO::CLI.get_netrc_key  
         
     | 
| 
      
 115 
     | 
    
         
            +
                    node_data = VikingIO::CLI.get_node_data
         
     | 
| 
      
 116 
     | 
    
         
            +
                    
         
     | 
| 
      
 117 
     | 
    
         
            +
                    tmp_dir = File.join(Dir.tmpdir, "vikingio")    
         
     | 
| 
      
 118 
     | 
    
         
            +
                    
         
     | 
| 
      
 119 
     | 
    
         
            +
                    compile = !args.include?("--skip-compilation")
         
     | 
| 
      
 120 
     | 
    
         
            +
                    compilation_success = true 
         
     | 
| 
      
 121 
     | 
    
         
            +
                    
         
     | 
| 
      
 122 
     | 
    
         
            +
                    if args.include?("--check")
         
     | 
| 
      
 123 
     | 
    
         
            +
                      new_node_ct = VikingIO::CLI::Client.deploy_check(user_key, app_data["key"]).to_i
         
     | 
| 
      
 124 
     | 
    
         
            +
                      
         
     | 
| 
      
 125 
     | 
    
         
            +
                      if new_node_ct == 0
         
     | 
| 
      
 126 
     | 
    
         
            +
                        puts "No new nodes will be created."
         
     | 
| 
      
 127 
     | 
    
         
            +
                      else
         
     | 
| 
      
 128 
     | 
    
         
            +
                        puts "#{new_node_ct} new node(s) will be created."
         
     | 
| 
      
 129 
     | 
    
         
            +
                      end
         
     | 
| 
      
 130 
     | 
    
         
            +
                      return
         
     | 
| 
      
 131 
     | 
    
         
            +
                    end    
         
     | 
| 
      
 132 
     | 
    
         
            +
                    
         
     | 
| 
      
 133 
     | 
    
         
            +
                    if compile
         
     | 
| 
      
 134 
     | 
    
         
            +
                      if !self.compile_nodes(tmp_dir, node_data)
         
     | 
| 
      
 135 
     | 
    
         
            +
                        compilation_success = false 
         
     | 
| 
      
 136 
     | 
    
         
            +
                      else
         
     | 
| 
      
 137 
     | 
    
         
            +
             
     | 
| 
      
 138 
     | 
    
         
            +
                        if IS_WINDOWS
         
     | 
| 
      
 139 
     | 
    
         
            +
                          directory = "#{File.join(tmp_dir, "VikingIO", "Data")}"
         
     | 
| 
      
 140 
     | 
    
         
            +
                          zipfile_name = "#{File.join(tmp_dir, "Data.zip")}"
         
     | 
| 
      
 141 
     | 
    
         
            +
             
     | 
| 
      
 142 
     | 
    
         
            +
                          Zip::File.open(zipfile_name, Zip::File::CREATE) do |zipfile|
         
     | 
| 
      
 143 
     | 
    
         
            +
                              Dir[File.join(directory, '**', '**')].each do |file|
         
     | 
| 
      
 144 
     | 
    
         
            +
                                zipfile.add(file.sub(directory, ''), file)
         
     | 
| 
      
 145 
     | 
    
         
            +
                              end
         
     | 
| 
      
 146 
     | 
    
         
            +
                          end
         
     | 
| 
      
 147 
     | 
    
         
            +
             
     | 
| 
      
 148 
     | 
    
         
            +
                          VikingIO::CLI::Client.deploy_data(user_key, app_data["key"], zipfile_name)
         
     | 
| 
      
 149 
     | 
    
         
            +
             
     | 
| 
      
 150 
     | 
    
         
            +
                          FileUtils.rm_rf(directory)
         
     | 
| 
      
 151 
     | 
    
         
            +
             
     | 
| 
      
 152 
     | 
    
         
            +
                          directory = "#{File.join(tmp_dir, "VikingIO", File::SEPARATOR)}"
         
     | 
| 
      
 153 
     | 
    
         
            +
                          zipfile_name = "#{File.join(tmp_dir, "VikingIO.zip")}"
         
     | 
| 
      
 154 
     | 
    
         
            +
             
     | 
| 
      
 155 
     | 
    
         
            +
                          Zip::File.open(zipfile_name, Zip::File::CREATE) do |zipfile|
         
     | 
| 
      
 156 
     | 
    
         
            +
                            Dir[File.join(directory, '**', '**')].each do |file|
         
     | 
| 
      
 157 
     | 
    
         
            +
                              zipfile.add(file.sub(directory, ''), file)
         
     | 
| 
      
 158 
     | 
    
         
            +
                            end
         
     | 
| 
      
 159 
     | 
    
         
            +
                          end
         
     | 
| 
      
 160 
     | 
    
         
            +
             
     | 
| 
      
 161 
     | 
    
         
            +
                          VikingIO::CLI::Client.deploy_servers(user_key, app_data["key"], zipfile_name)
         
     | 
| 
      
 162 
     | 
    
         
            +
                        else
         
     | 
| 
      
 163 
     | 
    
         
            +
                          `cd #{File.join(tmp_dir, "VikingIO")} && tar -zcvf Data.tar.gz Data`                            
         
     | 
| 
      
 164 
     | 
    
         
            +
                          puts "Deploying data..."
         
     | 
| 
      
 165 
     | 
    
         
            +
                          VikingIO::CLI::Client.deploy_data(user_key, app_data["key"], File.join(tmp_dir, "VikingIO", "Data.tar.gz"))      
         
     | 
| 
      
 166 
     | 
    
         
            +
                          `rm -rf #{File.join(tmp_dir, "VikingIO", "Data")}*`   
         
     | 
| 
      
 167 
     | 
    
         
            +
                          `cd #{File.join(tmp_dir, "VikingIO")} && tar -zcvf #{File.join(tmp_dir, "VikingIO.tar.gz")} .`          
         
     | 
| 
      
 168 
     | 
    
         
            +
                          puts "Deploying nodes..."
         
     | 
| 
      
 169 
     | 
    
         
            +
                          VikingIO::CLI::Client.deploy_servers(user_key, app_data["key"], File.join(tmp_dir, "VikingIO.tar.gz"))
         
     | 
| 
      
 170 
     | 
    
         
            +
                        end
         
     | 
| 
      
 171 
     | 
    
         
            +
                      end
         
     | 
| 
      
 172 
     | 
    
         
            +
                    end
         
     | 
| 
      
 173 
     | 
    
         
            +
                    
         
     | 
| 
      
 174 
     | 
    
         
            +
                    if compilation_success                           
         
     | 
| 
      
 175 
     | 
    
         
            +
                          
         
     | 
| 
      
 176 
     | 
    
         
            +
                      new_node_ct = VikingIO::CLI::Client.deploy_check(user_key, app_data["key"]).to_i
         
     | 
| 
      
 177 
     | 
    
         
            +
                      deploy = true
         
     | 
| 
      
 178 
     | 
    
         
            +
                      
         
     | 
| 
      
 179 
     | 
    
         
            +
                      if new_node_ct != 0
         
     | 
| 
      
 180 
     | 
    
         
            +
                        puts "#{new_node_ct} new node(s) will be created. Continue? (y/n)"
         
     | 
| 
      
 181 
     | 
    
         
            +
                        y_or_n = STDIN.gets.chomp.downcase
         
     | 
| 
      
 182 
     | 
    
         
            +
             
     | 
| 
      
 183 
     | 
    
         
            +
                        if !["y", "yes"].include?(y_or_n)
         
     | 
| 
      
 184 
     | 
    
         
            +
                          deploy = false
         
     | 
| 
      
 185 
     | 
    
         
            +
                          puts "Aborting."
         
     | 
| 
      
 186 
     | 
    
         
            +
                        end 
         
     | 
| 
      
 187 
     | 
    
         
            +
                        
         
     | 
| 
      
 188 
     | 
    
         
            +
                      end   
         
     | 
| 
      
 189 
     | 
    
         
            +
                      
         
     | 
| 
      
 190 
     | 
    
         
            +
                      if deploy
         
     | 
| 
      
 191 
     | 
    
         
            +
                        puts "Deploying"
         
     | 
| 
      
 192 
     | 
    
         
            +
                        puts VikingIO::CLI::Client.deploy(user_key, app_data["key"])
         
     | 
| 
      
 193 
     | 
    
         
            +
                      end
         
     | 
| 
      
 194 
     | 
    
         
            +
                      
         
     | 
| 
      
 195 
     | 
    
         
            +
            #          VikingIO::CLI::Client.deploy(user_key, app_data["key"], node_data.to_json)   
         
     | 
| 
      
 196 
     | 
    
         
            +
                    else
         
     | 
| 
      
 197 
     | 
    
         
            +
                      puts "Compilation failed. Aborting deploy."
         
     | 
| 
      
 198 
     | 
    
         
            +
                    end
         
     | 
| 
      
 199 
     | 
    
         
            +
                  end                       
         
     | 
| 
      
 200 
     | 
    
         
            +
                  
         
     | 
| 
      
 201 
     | 
    
         
            +
                  def self.compile_nodes(tmp_dir, node_data)   
         
     | 
| 
      
 202 
     | 
    
         
            +
                    begin                                       
         
     | 
| 
      
 203 
     | 
    
         
            +
                      FileUtils::rm_rf(tmp_dir)
         
     | 
| 
      
 204 
     | 
    
         
            +
                      FileUtils::mkdir_p(tmp_dir)  
         
     | 
| 
      
 205 
     | 
    
         
            +
             
     | 
| 
      
 206 
     | 
    
         
            +
                      if IS_WINDOWS  
         
     | 
| 
      
 207 
     | 
    
         
            +
                        working_directory =  `echo %cd%`.chomp 
         
     | 
| 
      
 208 
     | 
    
         
            +
                      else
         
     | 
| 
      
 209 
     | 
    
         
            +
                        working_directory = Dir.pwd
         
     | 
| 
      
 210 
     | 
    
         
            +
                      end  
         
     | 
| 
      
 211 
     | 
    
         
            +
             
     | 
| 
      
 212 
     | 
    
         
            +
                      puts "Copying project"
         
     | 
| 
      
 213 
     | 
    
         
            +
                      FileUtils::cp_r(File.join(File.expand_path(working_directory), "Assets", "VikingIO"), tmp_dir)
         
     | 
| 
      
 214 
     | 
    
         
            +
             
     | 
| 
      
 215 
     | 
    
         
            +
                      puts "Removing Client directory"
         
     | 
| 
      
 216 
     | 
    
         
            +
                      FileUtils::rm_rf(File.join(tmp_dir, "VikingIO", "Client"))
         
     | 
| 
      
 217 
     | 
    
         
            +
                      
         
     | 
| 
      
 218 
     | 
    
         
            +
                      puts "Removing meta files"
         
     | 
| 
      
 219 
     | 
    
         
            +
                      meta_files = Dir["#{tmp_dir}/VikingIO/**/*.meta"] 
         
     | 
| 
      
 220 
     | 
    
         
            +
                      meta_files.each {|x| FileUtils.rm_rf(x) }
         
     | 
| 
      
 221 
     | 
    
         
            +
                      
         
     | 
| 
      
 222 
     | 
    
         
            +
                      puts "Generating Main"
         
     | 
| 
      
 223 
     | 
    
         
            +
                      templates_dir = File.join(File.dirname(__FILE__), "..", "..", "..", "templates")
         
     | 
| 
      
 224 
     | 
    
         
            +
                      program_template = File.read(File.join(templates_dir, "Program.cs"))
         
     | 
| 
      
 225 
     | 
    
         
            +
             
     | 
| 
      
 226 
     | 
    
         
            +
                      app_data = VikingIO::CLI.get_app_data
         
     | 
| 
      
 227 
     | 
    
         
            +
                        
         
     | 
| 
      
 228 
     | 
    
         
            +
                      #puts "Loading App Data: #{app_data}"              
         
     | 
| 
      
 229 
     | 
    
         
            +
                      #dlls_dir = File.join(File.dirname(__FILE__), "../../../dlls")
         
     | 
| 
      
 230 
     | 
    
         
            +
                      #viking_dll_path = File.join(dlls_dir, "VikingIO.Network.dll") 
         
     | 
| 
      
 231 
     | 
    
         
            +
                      #FileUtils::cp(viking_dll_path, File.join(tmp_dir, "VikingIO"))
         
     | 
| 
      
 232 
     | 
    
         
            +
                     
         
     | 
| 
      
 233 
     | 
    
         
            +
                      cs_files = Dir["#{tmp_dir}/VikingIO/**/*.cs"]     
         
     | 
| 
      
 234 
     | 
    
         
            +
                    
         
     | 
| 
      
 235 
     | 
    
         
            +
                      references = Dir["#{tmp_dir}/VikingIO/Server/External/**/*.dll"]  
         
     | 
| 
      
 236 
     | 
    
         
            +
                      reference_str = references.map{|x| "-reference:#{x}" }.join(" ")      
         
     | 
| 
      
 237 
     | 
    
         
            +
                                                    
         
     | 
| 
      
 238 
     | 
    
         
            +
                      log_file = File.join(tmp_dir, "VikingIO", "log")    
         
     | 
| 
      
 239 
     | 
    
         
            +
                    
         
     | 
| 
      
 240 
     | 
    
         
            +
                      node_data.each do |node|               
         
     | 
| 
      
 241 
     | 
    
         
            +
                        @exit_status = nil
         
     | 
| 
      
 242 
     | 
    
         
            +
                        @exit_msg = ""
         
     | 
| 
      
 243 
     | 
    
         
            +
                        puts "Compiling '" + node["node_class"] + "' node"     
         
     | 
| 
      
 244 
     | 
    
         
            +
                        node_class = node["node_class"]
         
     | 
| 
      
 245 
     | 
    
         
            +
                      
         
     | 
| 
      
 246 
     | 
    
         
            +
                        program_path = File.join(tmp_dir, "VikingIO", node_class + ".Main.cs")                
         
     | 
| 
      
 247 
     | 
    
         
            +
                                                                                     
         
     | 
| 
      
 248 
     | 
    
         
            +
                        puts app_data["name"]
         
     | 
| 
      
 249 
     | 
    
         
            +
                        File.open(program_path, "w") do |f|
         
     | 
| 
      
 250 
     | 
    
         
            +
                          f << program_template.gsub("[MODULE_NAME]", node_class).gsub("[APP_NAME]", app_data["name"])
         
     | 
| 
      
 251 
     | 
    
         
            +
                        end              
         
     | 
| 
      
 252 
     | 
    
         
            +
                      
         
     | 
| 
      
 253 
     | 
    
         
            +
                        all_files = cs_files + [program_path] 
         
     | 
| 
      
 254 
     | 
    
         
            +
                        out_file = "#{tmp_dir}/VikingIO/#{node_class}.exe"  
         
     | 
| 
      
 255 
     | 
    
         
            +
             
     | 
| 
      
 256 
     | 
    
         
            +
             
     | 
| 
      
 257 
     | 
    
         
            +
                        library_path = File.join(tmp_dir, "VikingIO", "Server", "External") 
         
     | 
| 
      
 258 
     | 
    
         
            +
                        csc_path = "c:\\Windows\\Microsoft.Net\\Framework64\\v3.5\\csc.exe"
         
     | 
| 
      
 259 
     | 
    
         
            +
             
     | 
| 
      
 260 
     | 
    
         
            +
                        if IS_WINDOWS
         
     | 
| 
      
 261 
     | 
    
         
            +
                          references = Dir["#{tmp_dir}/VikingIO/Server/External/**/*.dll"]
         
     | 
| 
      
 262 
     | 
    
         
            +
                          reference_str = references.map {|x| "/r:#{File.expand_path(x)}" }.join(" ")
         
     | 
| 
      
 263 
     | 
    
         
            +
                          cs_files = Dir["#{tmp_dir}/VikingIO/**/*.cs"]
         
     | 
| 
      
 264 
     | 
    
         
            +
                          cs_files_str = cs_files.map {|x| File.expand_path(x) }.join(" ")
         
     | 
| 
      
 265 
     | 
    
         
            +
             
     | 
| 
      
 266 
     | 
    
         
            +
                          Open3.popen3("cd #{tmp_dir}/VikingIO && #{CSC_V35_64_PATH} #{reference_str} /out:#{node_class}.exe /recurse:Server\\*.cs /recurse:Shared\\.cs #{node_class}.Main.cs")  {|stdin, stdout, stderr, wait_thr|
         
     | 
| 
      
 267 
     | 
    
         
            +
                            pid = wait_thr.pid # pid of the started process.
         
     | 
| 
      
 268 
     | 
    
         
            +
             
     | 
| 
      
 269 
     | 
    
         
            +
                            @exit_status = wait_thr.value # Process::Status object returned.
         
     | 
| 
      
 270 
     | 
    
         
            +
                        
         
     | 
| 
      
 271 
     | 
    
         
            +
                            stderr.each do |x|
         
     | 
| 
      
 272 
     | 
    
         
            +
                              @exit_msg << x    
         
     | 
| 
      
 273 
     | 
    
         
            +
                            end
         
     | 
| 
      
 274 
     | 
    
         
            +
                          }   
         
     | 
| 
      
 275 
     | 
    
         
            +
                        else
         
     | 
| 
      
 276 
     | 
    
         
            +
                          Open3.popen3("#{UNITY_COMPILER_PATH_OSX} #{reference_str} -lib:#{library_path} -optimize #{all_files.join(" ")} -out:#{out_file}") {|stdin, stdout, stderr, wait_thr|
         
     | 
| 
      
 277 
     | 
    
         
            +
                            pid = wait_thr.pid # pid of the started process.
         
     | 
| 
      
 278 
     | 
    
         
            +
             
     | 
| 
      
 279 
     | 
    
         
            +
                            @exit_status = wait_thr.value # Process::Status object returned.
         
     | 
| 
      
 280 
     | 
    
         
            +
                        
         
     | 
| 
      
 281 
     | 
    
         
            +
                            stderr.each do |x|
         
     | 
| 
      
 282 
     | 
    
         
            +
                              @exit_msg << x    
         
     | 
| 
      
 283 
     | 
    
         
            +
                            end
         
     | 
| 
      
 284 
     | 
    
         
            +
                          }   
         
     | 
| 
      
 285 
     | 
    
         
            +
                        end
         
     | 
| 
      
 286 
     | 
    
         
            +
                                     
         
     | 
| 
      
 287 
     | 
    
         
            +
                        references.each {|x| FileUtils.cp x, File.join(tmp_dir, "VikingIO") }         
         
     | 
| 
      
 288 
     | 
    
         
            +
                      
         
     | 
| 
      
 289 
     | 
    
         
            +
                        if @exit_status.success? == false
         
     | 
| 
      
 290 
     | 
    
         
            +
                          puts "ERROR COMPILING: #{@exit_msg}"
         
     | 
| 
      
 291 
     | 
    
         
            +
                          return false;
         
     | 
| 
      
 292 
     | 
    
         
            +
                        end                                                                               
         
     | 
| 
      
 293 
     | 
    
         
            +
                      end 
         
     | 
| 
      
 294 
     | 
    
         
            +
                      
         
     | 
| 
      
 295 
     | 
    
         
            +
                      node_data.each {|x| FileUtils.rm_rf File.join(tmp_dir, "VikingIO", "#{x}.cs") } 
         
     | 
| 
      
 296 
     | 
    
         
            +
                      
         
     | 
| 
      
 297 
     | 
    
         
            +
                      src_files = Dir.glob("#{tmp_dir}/VikingIO/**").reject {|x| x.end_with?("exe") || x.end_with?("Data") || x.end_with?("dll") }
         
     | 
| 
      
 298 
     | 
    
         
            +
                      src_files.each {|x| FileUtils.rm_rf x }
         
     | 
| 
      
 299 
     | 
    
         
            +
                           
         
     | 
| 
      
 300 
     | 
    
         
            +
                    rescue Exception => e  
         
     | 
| 
      
 301 
     | 
    
         
            +
                      puts "Error compiling: #{e}"
         
     | 
| 
      
 302 
     | 
    
         
            +
                      return false
         
     | 
| 
      
 303 
     | 
    
         
            +
                    end           
         
     | 
| 
      
 304 
     | 
    
         
            +
                  end
         
     | 
| 
      
 305 
     | 
    
         
            +
                  
         
     | 
| 
      
 306 
     | 
    
         
            +
                  def self.compile_and_run(*args)
         
     | 
| 
      
 307 
     | 
    
         
            +
                                                               
         
     | 
| 
      
 308 
     | 
    
         
            +
                    tmp_dir = File.join(Dir.tmpdir, "vikingio")
         
     | 
| 
      
 309 
     | 
    
         
            +
                    node_data = VikingIO::CLI.get_node_data
         
     | 
| 
      
 310 
     | 
    
         
            +
                    default_port = 14242
         
     | 
| 
      
 311 
     | 
    
         
            +
                    
         
     | 
| 
      
 312 
     | 
    
         
            +
                    if self.compile_nodes(tmp_dir, node_data)
         
     | 
| 
      
 313 
     | 
    
         
            +
                      pids = []      
         
     | 
| 
      
 314 
     | 
    
         
            +
                        
         
     | 
| 
      
 315 
     | 
    
         
            +
                      node_data.each do |node|     
         
     | 
| 
      
 316 
     | 
    
         
            +
                        exe_file = "#{tmp_dir}/VikingIO/#{node["node_class"]}.exe" 
         
     | 
| 
      
 317 
     | 
    
         
            +
                        if IS_WINDOWS
         
     | 
| 
      
 318 
     | 
    
         
            +
                          pids << spawn("#{exe_file} #{default_port}")       
         
     | 
| 
      
 319 
     | 
    
         
            +
                        else       
         
     | 
| 
      
 320 
     | 
    
         
            +
                          pids << spawn("DYLD_LIBRARY_PATH=#{UNITY_MONO_DLL_PATH_OSX} #{UNITY_MONO_PATH_OSX} #{exe_file} #{default_port}")
         
     | 
| 
      
 321 
     | 
    
         
            +
                        end
         
     | 
| 
      
 322 
     | 
    
         
            +
                        default_port += 1
         
     | 
| 
      
 323 
     | 
    
         
            +
                      end 
         
     | 
| 
      
 324 
     | 
    
         
            +
                     
         
     | 
| 
      
 325 
     | 
    
         
            +
                      begin
         
     | 
| 
      
 326 
     | 
    
         
            +
                        puts "Press ctrl-C to stop"
         
     | 
| 
      
 327 
     | 
    
         
            +
                        while true do
         
     | 
| 
      
 328 
     | 
    
         
            +
                          sleep 0.1
         
     | 
| 
      
 329 
     | 
    
         
            +
                        end
         
     | 
| 
      
 330 
     | 
    
         
            +
                      rescue Interrupt => e  
         
     | 
| 
      
 331 
     | 
    
         
            +
                        pids.each {|pid| Process.kill("INT", pid) }
         
     | 
| 
      
 332 
     | 
    
         
            +
                        puts "Stopped processes: #{pids.join(",")}."
         
     | 
| 
      
 333 
     | 
    
         
            +
                      end
         
     | 
| 
      
 334 
     | 
    
         
            +
                    else
         
     | 
| 
      
 335 
     | 
    
         
            +
                      
         
     | 
| 
      
 336 
     | 
    
         
            +
                    end 
         
     | 
| 
      
 337 
     | 
    
         
            +
                  end   
         
     | 
| 
      
 338 
     | 
    
         
            +
                  
         
     | 
| 
      
 339 
     | 
    
         
            +
                  def self.link(*args)
         
     | 
| 
      
 340 
     | 
    
         
            +
                  end
         
     | 
| 
      
 341 
     | 
    
         
            +
                     
         
     | 
| 
      
 342 
     | 
    
         
            +
                  def self.unlink(*args)
         
     | 
| 
      
 343 
     | 
    
         
            +
                    VikingIO::CLI.unlink_app
         
     | 
| 
      
 344 
     | 
    
         
            +
                    puts "Application data cleared."
         
     | 
| 
      
 345 
     | 
    
         
            +
                  end
         
     | 
| 
      
 346 
     | 
    
         
            +
                  
         
     | 
| 
      
 347 
     | 
    
         
            +
                  def self.create(*args)     
         
     | 
| 
      
 348 
     | 
    
         
            +
                    args.flatten!
         
     | 
| 
      
 349 
     | 
    
         
            +
                    
         
     | 
| 
      
 350 
     | 
    
         
            +
                    if !VikingIO::CLI.authenticated?
         
     | 
| 
      
 351 
     | 
    
         
            +
                      puts "Please login first."
         
     | 
| 
      
 352 
     | 
    
         
            +
                      return       
         
     | 
| 
      
 353 
     | 
    
         
            +
                    end    
         
     | 
| 
      
 354 
     | 
    
         
            +
                    
         
     | 
| 
      
 355 
     | 
    
         
            +
                    if VikingIO::CLI.linked?
         
     | 
| 
      
 356 
     | 
    
         
            +
                      puts "A VikingIO application is already linked to this directory. Use 'vikingio unlink' to clear the application data for this directory."
         
     | 
| 
      
 357 
     | 
    
         
            +
                      return
         
     | 
| 
      
 358 
     | 
    
         
            +
                    end
         
     | 
| 
      
 359 
     | 
    
         
            +
                    
         
     | 
| 
      
 360 
     | 
    
         
            +
                    app_name = args.join(" ") rescue nil
         
     | 
| 
      
 361 
     | 
    
         
            +
                    
         
     | 
| 
      
 362 
     | 
    
         
            +
                    app = VikingIO::CLI::Client.create_app(app_name) 
         
     | 
| 
      
 363 
     | 
    
         
            +
             
     | 
| 
      
 364 
     | 
    
         
            +
                    if app["status"] == "error"
         
     | 
| 
      
 365 
     | 
    
         
            +
                      puts app["message"]
         
     | 
| 
      
 366 
     | 
    
         
            +
                      return;
         
     | 
| 
      
 367 
     | 
    
         
            +
                    end
         
     | 
| 
      
 368 
     | 
    
         
            +
             
     | 
| 
      
 369 
     | 
    
         
            +
                    VikingIO::CLI.link_app(app)             
         
     | 
| 
      
 370 
     | 
    
         
            +
                    
         
     | 
| 
      
 371 
     | 
    
         
            +
                    puts "Created application '#{app['name']}'."     
         
     | 
| 
      
 372 
     | 
    
         
            +
                    
         
     | 
| 
      
 373 
     | 
    
         
            +
                    self.generate("--force")
         
     | 
| 
      
 374 
     | 
    
         
            +
                  end     
         
     | 
| 
      
 375 
     | 
    
         
            +
                  
         
     | 
| 
      
 376 
     | 
    
         
            +
                  def self.generate(*args)
         
     | 
| 
      
 377 
     | 
    
         
            +
                    args.flatten!
         
     | 
| 
      
 378 
     | 
    
         
            +
                    
         
     | 
| 
      
 379 
     | 
    
         
            +
                    assets_path = File.join(Dir.pwd, "Assets")
         
     | 
| 
      
 380 
     | 
    
         
            +
                    viking_assets_path = File.join(assets_path, "VikingIO")           
         
     | 
| 
      
 381 
     | 
    
         
            +
                    app_data = VikingIO::CLI.get_app_data          
         
     | 
| 
      
 382 
     | 
    
         
            +
                    
         
     | 
| 
      
 383 
     | 
    
         
            +
                    if args[0] == "node"                                       
         
     | 
| 
      
 384 
     | 
    
         
            +
                      if args[1] == "" || args[1] == nil
         
     | 
| 
      
 385 
     | 
    
         
            +
                        puts "Please enter a camel cased name for your node. i.e. GameServer"
         
     | 
| 
      
 386 
     | 
    
         
            +
                        return
         
     | 
| 
      
 387 
     | 
    
         
            +
                      end
         
     | 
| 
      
 388 
     | 
    
         
            +
                      
         
     | 
| 
      
 389 
     | 
    
         
            +
                      node_data = VikingIO::CLI::Client.create_node(args[1], app_data["key"]) 
         
     | 
| 
      
 390 
     | 
    
         
            +
                      VikingIO::CLI.save_node_data(node_data["nodes"])
         
     | 
| 
      
 391 
     | 
    
         
            +
                      
         
     | 
| 
      
 392 
     | 
    
         
            +
                      puts ""  
         
     | 
| 
      
 393 
     | 
    
         
            +
                      
         
     | 
| 
      
 394 
     | 
    
         
            +
                      
         
     | 
| 
      
 395 
     | 
    
         
            +
                      if node_data["status"] == "error"       
         
     | 
| 
      
 396 
     | 
    
         
            +
                        puts node_data["msg"]
         
     | 
| 
      
 397 
     | 
    
         
            +
                        puts "\nIf you want to create a new node, delete your existing node with 'vikingio destroy node #{node_data["nodes"][0]["node_class"]}'. \nThis will shut down any deployed and running node instances.\n\n"
         
     | 
| 
      
 398 
     | 
    
         
            +
                      end 
         
     | 
| 
      
 399 
     | 
    
         
            +
                      
         
     | 
| 
      
 400 
     | 
    
         
            +
                      node_output_path = File.join(viking_assets_path, "Server", "#{args[1]}.cs")
         
     | 
| 
      
 401 
     | 
    
         
            +
                      if File.exist?(node_output_path)
         
     | 
| 
      
 402 
     | 
    
         
            +
                        puts "#{node_output_path} already exists. Ignoring template generation. Delete the file first if you want to override it."
         
     | 
| 
      
 403 
     | 
    
         
            +
                      else
         
     | 
| 
      
 404 
     | 
    
         
            +
                        server_node_template = File.read(File.join(TEMPLATES_DIR, "ServerNodeTemplate.cs")).gsub("[SERVER_NAME]", args[1])
         
     | 
| 
      
 405 
     | 
    
         
            +
                        File.open(node_output_path, 'w') { |file| file.write(server_node_template) }
         
     | 
| 
      
 406 
     | 
    
         
            +
                      end
         
     | 
| 
      
 407 
     | 
    
         
            +
                      
         
     | 
| 
      
 408 
     | 
    
         
            +
                      return                                                                     
         
     | 
| 
      
 409 
     | 
    
         
            +
                      
         
     | 
| 
      
 410 
     | 
    
         
            +
                      node_output_path = File.join(viking_assets_path, "Server", "#{args[1]}.cs")
         
     | 
| 
      
 411 
     | 
    
         
            +
                      
         
     | 
| 
      
 412 
     | 
    
         
            +
                      if !File.exist?(node_output_path)
         
     | 
| 
      
 413 
     | 
    
         
            +
                        server_node_template = File.read(File.join(TEMPLATES_DIR, "ServerNodeTemplate.cs")).gsub("[SERVER_NAME]", args[1])
         
     | 
| 
      
 414 
     | 
    
         
            +
                        File.open(node_output_path, 'w') { |file| file.write(server_node_template) } 
         
     | 
| 
      
 415 
     | 
    
         
            +
                        node_data = VikingIO::CLI.get_node_data
         
     | 
| 
      
 416 
     | 
    
         
            +
                        node_data << args[1]
         
     | 
| 
      
 417 
     | 
    
         
            +
                        VikingIO::CLI.save_node_data(node_data) 
         
     | 
| 
      
 418 
     | 
    
         
            +
                      end                      
         
     | 
| 
      
 419 
     | 
    
         
            +
                      
         
     | 
| 
      
 420 
     | 
    
         
            +
                      puts "Node '#{args[1]}' created."
         
     | 
| 
      
 421 
     | 
    
         
            +
                      return
         
     | 
| 
      
 422 
     | 
    
         
            +
                    end      
         
     | 
| 
      
 423 
     | 
    
         
            +
                    
         
     | 
| 
      
 424 
     | 
    
         
            +
                    if args[0] == "message"
         
     | 
| 
      
 425 
     | 
    
         
            +
                      puts "Message '#{args[1]}' created."
         
     | 
| 
      
 426 
     | 
    
         
            +
                      server_node_template = File.read(File.join(TEMPLATES_DIR, "MessageTemplate.cs")).gsub("[MESSAGE_NAME]", args[1])
         
     | 
| 
      
 427 
     | 
    
         
            +
                      File.open(File.join(viking_assets_path, "Shared", "Messages", "#{args[1]}.cs"), 'w') { |file| file.write(server_node_template) }
         
     | 
| 
      
 428 
     | 
    
         
            +
                      return
         
     | 
| 
      
 429 
     | 
    
         
            +
                    end
         
     | 
| 
      
 430 
     | 
    
         
            +
                    
         
     | 
| 
      
 431 
     | 
    
         
            +
                    if File.exist?(viking_assets_path) && !args.include?("--force")
         
     | 
| 
      
 432 
     | 
    
         
            +
                      puts "VikingIO already exists in your Assets folder. Run this command again with the --force command to overwrite."
         
     | 
| 
      
 433 
     | 
    
         
            +
                      return
         
     | 
| 
      
 434 
     | 
    
         
            +
                    end                   
         
     | 
| 
      
 435 
     | 
    
         
            +
                    
         
     | 
| 
      
 436 
     | 
    
         
            +
                    puts "Generating skeleton application"                  
         
     | 
| 
      
 437 
     | 
    
         
            +
                    
         
     | 
| 
      
 438 
     | 
    
         
            +
            #        puts "Generating folder structure..."
         
     | 
| 
      
 439 
     | 
    
         
            +
                    FileUtils::mkdir_p(File.join(viking_assets_path, "Client", "External"))
         
     | 
| 
      
 440 
     | 
    
         
            +
                    FileUtils::mkdir_p(File.join(viking_assets_path, "Server", "External"))
         
     | 
| 
      
 441 
     | 
    
         
            +
                    FileUtils::mkdir_p(File.join(viking_assets_path, "Shared", "Messages"))
         
     | 
| 
      
 442 
     | 
    
         
            +
                    FileUtils::mkdir_p(File.join(viking_assets_path, "Data"))     
         
     | 
| 
      
 443 
     | 
    
         
            +
                         
         
     | 
| 
      
 444 
     | 
    
         
            +
                    dlls_dir = File.join(File.dirname(__FILE__), "..", "..", "..", "dlls")   
         
     | 
| 
      
 445 
     | 
    
         
            +
                    
         
     | 
| 
      
 446 
     | 
    
         
            +
                    config_dest = File.join(viking_assets_path, "Client", "VikingIO.Config.cs")
         
     | 
| 
      
 447 
     | 
    
         
            +
                    
         
     | 
| 
      
 448 
     | 
    
         
            +
            #        puts "Copying template files..."                                                                                     
         
     | 
| 
      
 449 
     | 
    
         
            +
                    FileUtils.cp(File.join(TEMPLATES_DIR, "NetworkManager.cs"), File.join(viking_assets_path, "Client", "NetworkManager.cs")) 
         
     | 
| 
      
 450 
     | 
    
         
            +
                    FileUtils.cp(File.join(TEMPLATES_DIR, "VikingIO.Config.cs"), config_dest)                                                 
         
     | 
| 
      
 451 
     | 
    
         
            +
                                                                 
         
     | 
| 
      
 452 
     | 
    
         
            +
                    contents = File.read(config_dest).gsub("[APP_NAME]", app_data["name"]).gsub("[APP_ID]", app_data["id"].to_s)
         
     | 
| 
      
 453 
     | 
    
         
            +
                         
         
     | 
| 
      
 454 
     | 
    
         
            +
                    File.open(config_dest, 'w') { |file| file.write(contents) }
         
     | 
| 
      
 455 
     | 
    
         
            +
                    
         
     | 
| 
      
 456 
     | 
    
         
            +
                    File.open(File.join(viking_assets_path, "Nodefile"), "w") do |f|
         
     | 
| 
      
 457 
     | 
    
         
            +
                      f << [].to_json
         
     | 
| 
      
 458 
     | 
    
         
            +
                    end           
         
     | 
| 
      
 459 
     | 
    
         
            +
                    
         
     | 
| 
      
 460 
     | 
    
         
            +
            #        puts "Copying dlls..."
         
     | 
| 
      
 461 
     | 
    
         
            +
                    FileUtils.cp(File.join(dlls_dir, "VikingIO.Network.dll"), File.join(viking_assets_path, "Server", "External", "VikingIO.Network.dll")) 
         
     | 
| 
      
 462 
     | 
    
         
            +
                    FileUtils.cp(File.join(dlls_dir, "VikingIO.Network.Client.dll"), File.join(viking_assets_path, "Client", "External", "VikingIO.Network.Client.dll"))
         
     | 
| 
      
 463 
     | 
    
         
            +
                   puts "Done."
         
     | 
| 
      
 464 
     | 
    
         
            +
                  end
         
     | 
| 
      
 465 
     | 
    
         
            +
                  
         
     | 
| 
      
 466 
     | 
    
         
            +
                  def self.help(*args) 
         
     | 
| 
      
 467 
     | 
    
         
            +
                    args.flatten!
         
     | 
| 
      
 468 
     | 
    
         
            +
                    if args.size == 0
         
     | 
| 
      
 469 
     | 
    
         
            +
                      puts "\nCommands: \n\n"     
         
     | 
| 
      
 470 
     | 
    
         
            +
                      
         
     | 
| 
      
 471 
     | 
    
         
            +
                      COMMANDS.each do |cmd|   
         
     | 
| 
      
 472 
     | 
    
         
            +
                        if cmd[1][:short].nil?   
         
     | 
| 
      
 473 
     | 
    
         
            +
                          puts cmd[0]
         
     | 
| 
      
 474 
     | 
    
         
            +
                        else
         
     | 
| 
      
 475 
     | 
    
         
            +
                          puts "#{cmd[0]} - #{cmd[1][:short]}"
         
     | 
| 
      
 476 
     | 
    
         
            +
                        end
         
     | 
| 
      
 477 
     | 
    
         
            +
                      end
         
     | 
| 
      
 478 
     | 
    
         
            +
             
     | 
| 
      
 479 
     | 
    
         
            +
                      puts ""     
         
     | 
| 
      
 480 
     | 
    
         
            +
                    else
         
     | 
| 
      
 481 
     | 
    
         
            +
                      cmd = COMMANDS.find {|x| x[0] == args[0] }
         
     | 
| 
      
 482 
     | 
    
         
            +
             
     | 
| 
      
 483 
     | 
    
         
            +
                      puts "\n===========  " + cmd[0] + "  ===========\n\n"
         
     | 
| 
      
 484 
     | 
    
         
            +
                      puts cmd[1][:short] + "\n\n"                      
         
     | 
| 
      
 485 
     | 
    
         
            +
                      puts cmd[1][:full]
         
     | 
| 
      
 486 
     | 
    
         
            +
                    end   
         
     | 
| 
      
 487 
     | 
    
         
            +
                    puts ""              
         
     | 
| 
      
 488 
     | 
    
         
            +
                  end 
         
     | 
| 
      
 489 
     | 
    
         
            +
                  
         
     | 
| 
      
 490 
     | 
    
         
            +
                  def self.login(*args)   
         
     | 
| 
      
 491 
     | 
    
         
            +
                    email = ""
         
     | 
| 
      
 492 
     | 
    
         
            +
                    password = ""
         
     | 
| 
      
 493 
     | 
    
         
            +
                    
         
     | 
| 
      
 494 
     | 
    
         
            +
                    puts "Enter your email:"
         
     | 
| 
      
 495 
     | 
    
         
            +
                    email = STDIN.gets.chomp
         
     | 
| 
      
 496 
     | 
    
         
            +
                    
         
     | 
| 
      
 497 
     | 
    
         
            +
                    puts ""
         
     | 
| 
      
 498 
     | 
    
         
            +
                    puts "Enter your password:"
         
     | 
| 
      
 499 
     | 
    
         
            +
                    password = STDIN.noecho(&:gets).chomp
         
     | 
| 
      
 500 
     | 
    
         
            +
                                                              
         
     | 
| 
      
 501 
     | 
    
         
            +
                    if email.nil? || email == "" || password.nil? || password == ""
         
     | 
| 
      
 502 
     | 
    
         
            +
                      puts "Email or Password empty" 
         
     | 
| 
      
 503 
     | 
    
         
            +
                      return 
         
     | 
| 
      
 504 
     | 
    
         
            +
                    end           
         
     | 
| 
      
 505 
     | 
    
         
            +
                    
         
     | 
| 
      
 506 
     | 
    
         
            +
                    app_key = VikingIO::CLI::Client.authenticate(email, password)    
         
     | 
| 
      
 507 
     | 
    
         
            +
                    
         
     | 
| 
      
 508 
     | 
    
         
            +
                    if app_key.nil?
         
     | 
| 
      
 509 
     | 
    
         
            +
                      puts "Invalid authentication." 
         
     | 
| 
      
 510 
     | 
    
         
            +
                      return         
         
     | 
| 
      
 511 
     | 
    
         
            +
                    end
         
     | 
| 
      
 512 
     | 
    
         
            +
                    
         
     | 
| 
      
 513 
     | 
    
         
            +
                    if VikingIO::CLI.netrc_exist?
         
     | 
| 
      
 514 
     | 
    
         
            +
                      if VikingIO::CLI.in_netrc?
         
     | 
| 
      
 515 
     | 
    
         
            +
                        VikingIO::CLI.update_netrc_key(app_key)
         
     | 
| 
      
 516 
     | 
    
         
            +
                      else
         
     | 
| 
      
 517 
     | 
    
         
            +
                        VikingIO::CLI.add_netrc_key(email, app_key)
         
     | 
| 
      
 518 
     | 
    
         
            +
                      end                       
         
     | 
| 
      
 519 
     | 
    
         
            +
                      puts "Authenticated #{email}."
         
     | 
| 
      
 520 
     | 
    
         
            +
                    else
         
     | 
| 
      
 521 
     | 
    
         
            +
                      VikingIO::CLI.create_netrc(email, app_key)
         
     | 
| 
      
 522 
     | 
    
         
            +
                      puts "Authenticated #{email}."
         
     | 
| 
      
 523 
     | 
    
         
            +
                    end                       
         
     | 
| 
      
 524 
     | 
    
         
            +
                    
         
     | 
| 
      
 525 
     | 
    
         
            +
                  end
         
     | 
| 
      
 526 
     | 
    
         
            +
             
     | 
| 
      
 527 
     | 
    
         
            +
                  def self.logout(*args)           
         
     | 
| 
      
 528 
     | 
    
         
            +
                    VikingIO::CLI.remove_netrc_key 
         
     | 
| 
      
 529 
     | 
    
         
            +
                    
         
     | 
| 
      
 530 
     | 
    
         
            +
                    puts "Authentication cleared."
         
     | 
| 
      
 531 
     | 
    
         
            +
                  end
         
     | 
| 
      
 532 
     | 
    
         
            +
                  
         
     | 
| 
      
 533 
     | 
    
         
            +
                end
         
     | 
| 
      
 534 
     | 
    
         
            +
              end
         
     | 
| 
      
 535 
     | 
    
         
            +
            end
         
     | 
| 
      
 536 
     | 
    
         
            +
                                                                                                                          
         
     | 
| 
      
 537 
     | 
    
         
            +
             
     | 
| 
      
 538 
     | 
    
         
            +
             
     | 
| 
      
 539 
     | 
    
         
            +
             
     |