yadecli 0.1.3 → 0.1.4

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.
Files changed (86) hide show
  1. checksums.yaml +4 -4
  2. data/.DS_Store +0 -0
  3. data/.gitignore +2 -3
  4. data/Gemfile +5 -0
  5. data/Gemfile.lock +44 -2
  6. data/lib/yadecli/cli/application.rb +19 -4
  7. data/lib/yadecli/cli/composer.rb +70 -14
  8. data/lib/yadecli/cli/host.rb +19 -5
  9. data/lib/yadecli/cli/module.rb +14 -3
  10. data/lib/yadecli/cli/project.rb +30 -8
  11. data/lib/yadecli/cli/response/project_start_response.rb +21 -0
  12. data/lib/yadecli/cli/task.rb +9 -5
  13. data/lib/yadecli/client/gitlab_client.rb +4 -6
  14. data/lib/yadecli/command/composer/composer_install_command.rb +166 -0
  15. data/lib/yadecli/command/composer/composer_list_command.rb +63 -0
  16. data/lib/yadecli/command/composer/composer_log_command.rb +53 -0
  17. data/lib/yadecli/command/composer/composer_setup_command.rb +28 -0
  18. data/lib/yadecli/command/composer/composer_start_command.rb +70 -0
  19. data/lib/yadecli/command/composer/composer_stop_command.rb +60 -0
  20. data/lib/yadecli/command/composer/composer_switch_command.rb +51 -0
  21. data/lib/yadecli/command/composer/composer_uninstall_command.rb +44 -0
  22. data/lib/yadecli/command/connect_command.rb +29 -0
  23. data/lib/yadecli/command/host/host_bootstrap_command.rb +132 -0
  24. data/lib/yadecli/command/host/host_list_command.rb +36 -0
  25. data/lib/yadecli/command/host/host_provision_command.rb +59 -0
  26. data/lib/yadecli/command/login_command.rb +26 -0
  27. data/lib/yadecli/command/module/module_install_command.rb +79 -0
  28. data/lib/yadecli/command/module/module_list_command.rb +47 -0
  29. data/lib/yadecli/command/project/project_install_command.rb +58 -0
  30. data/lib/yadecli/command/project/project_list_command.rb +50 -0
  31. data/lib/yadecli/command/project/project_setup_command.rb +66 -0
  32. data/lib/yadecli/command/project/project_start_command.rb +110 -0
  33. data/lib/yadecli/command/project/project_uninstall_command.rb +44 -0
  34. data/lib/yadecli/command/task/task_list_command.rb +56 -0
  35. data/lib/yadecli/io/user_input.rb +1 -1
  36. data/lib/yadecli/util/cli_util.rb +11 -1
  37. data/lib/yadecli/util/maven_util.rb +35 -0
  38. data/lib/yadecli/version.rb +1 -1
  39. data/lib/yadecli.rb +38 -41
  40. data/scripts/setup-terminal.sh +1 -1
  41. data/yadecli.gemspec +6 -2
  42. metadata +81 -46
  43. data/lib/.DS_Store +0 -0
  44. data/lib/yadecli/.DS_Store +0 -0
  45. data/lib/yadecli/client/authentication_client.rb +0 -24
  46. data/lib/yadecli/client/base_client.rb +0 -78
  47. data/lib/yadecli/client/composer_container_client.rb +0 -27
  48. data/lib/yadecli/client/composer_project_client.rb +0 -27
  49. data/lib/yadecli/client/composer_service_client.rb +0 -27
  50. data/lib/yadecli/client/domain_client.rb +0 -23
  51. data/lib/yadecli/client/host_client.rb +0 -45
  52. data/lib/yadecli/client/maven_build_step_client.rb +0 -23
  53. data/lib/yadecli/client/maven_build_task_client.rb +0 -23
  54. data/lib/yadecli/client/nvm_runtime_client.rb +0 -23
  55. data/lib/yadecli/client/project_client.rb +0 -28
  56. data/lib/yadecli/client/project_module_client.rb +0 -35
  57. data/lib/yadecli/client/pyenv_runtime_client.rb +0 -23
  58. data/lib/yadecli/client/role_client.rb +0 -23
  59. data/lib/yadecli/client/rvm_runtime_client.rb +0 -23
  60. data/lib/yadecli/client/sdk_package_client.rb +0 -28
  61. data/lib/yadecli/client/vcs_client.rb +0 -23
  62. data/lib/yadecli/config/app_config.rb +0 -70
  63. data/lib/yadecli/model/composer_container.rb +0 -19
  64. data/lib/yadecli/model/composer_project.rb +0 -37
  65. data/lib/yadecli/model/composer_service.rb +0 -19
  66. data/lib/yadecli/model/domain.rb +0 -24
  67. data/lib/yadecli/model/host.rb +0 -24
  68. data/lib/yadecli/model/ide_type.rb +0 -7
  69. data/lib/yadecli/model/maven_build_step.rb +0 -19
  70. data/lib/yadecli/model/maven_build_task.rb +0 -19
  71. data/lib/yadecli/model/nvm_runtime.rb +0 -18
  72. data/lib/yadecli/model/project.rb +0 -26
  73. data/lib/yadecli/model/project_module.rb +0 -29
  74. data/lib/yadecli/model/pyenv_runtime.rb +0 -18
  75. data/lib/yadecli/model/role.rb +0 -24
  76. data/lib/yadecli/model/rvm_runtime.rb +0 -18
  77. data/lib/yadecli/model/sdk_package.rb +0 -18
  78. data/lib/yadecli/model/vcs.rb +0 -19
  79. data/lib/yadecli/service/authentication_service.rb +0 -31
  80. data/lib/yadecli/service/build_step_service.rb +0 -24
  81. data/lib/yadecli/service/build_task_service.rb +0 -70
  82. data/lib/yadecli/service/composer_service.rb +0 -416
  83. data/lib/yadecli/service/connect_service.rb +0 -19
  84. data/lib/yadecli/service/host_service.rb +0 -191
  85. data/lib/yadecli/service/module_service.rb +0 -78
  86. data/lib/yadecli/service/project_service.rb +0 -205
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a44a9ea70d28da9ff038f8cdedebd2dd4bed6cbe675779ea04365b5fd125b153
4
- data.tar.gz: 383afa33fde904b3a921f64305c4a3dc83c8b6396d14872d6d0da0d05d5ec339
3
+ metadata.gz: 6709b5385d663fd644c167d3e225e8c0fa9909acabb9111f572b71f7baf26887
4
+ data.tar.gz: ad6776bb1dff0d7d8f0fc1124637d10df6768cd0f3e4591f64106ae328ae62a7
5
5
  SHA512:
6
- metadata.gz: aa291dc050459a4712674344e72bc34b759c72e9e70baaac7b4bd2be36a26a67ec2ed191db5e31efb71ce8de48ad18bbed945c04efb0d28860aff7294c347e82
7
- data.tar.gz: d6152e28590b6b2bffb1c7e29fdb403864d352f61dffb126cddc2cc85411f1ca3508e906d8aa48a46d118901bd6633f1c5813bc78fed79799dd38265c93bd4d3
6
+ metadata.gz: 98a614da2705e764cdce869d5bf396181af93995546196c796e074846a149dd9e60c84b4080dc4cfbc3c7517a73b3721766d5148749b1c33b02ee50d34885d89
7
+ data.tar.gz: f1af5277f437d9369b9ce05c9ec3536ee5497cddbe6c1b255ee5539e44fba87e4839f1ca1a7da2fe10f8de93943fbc5566c13943b185b07843264c98d0d6b24b
data/.DS_Store CHANGED
Binary file
data/.gitignore CHANGED
@@ -6,8 +6,7 @@
6
6
  /pkg/
7
7
  /spec/reports/
8
8
  /tmp/
9
-
10
9
  # rspec failure tracking
11
10
  .rspec_status
12
-
13
- *.log
11
+ *.log
12
+ .DS_Store
data/Gemfile CHANGED
@@ -4,3 +4,8 @@ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
4
 
5
5
  # Specify your gem's dependencies in yadecli.gemspec
6
6
  gemspec
7
+
8
+ gem 'yade-common', :path => "#{ENV['HOME']}/projekte/yade/src/yade-common"
9
+ gem 'yade-composer-rest-client', :path => "#{ENV['HOME']}/projekte/yade/src/yade-composer-rest-client"
10
+ gem 'yade-domain-rest-client', :path => "#{ENV['HOME']}/projekte/yade/src/yade-domain-rest-client"
11
+ gem 'yade-project-rest-client', :path => "#{ENV['HOME']}/projekte/yade/src/yade-project-rest-client"
data/Gemfile.lock CHANGED
@@ -1,13 +1,14 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- yadecli (0.1.3)
4
+ yadecli (0.1.4)
5
5
  activemodel (~> 5.2)
6
6
  artii (~> 2.1)
7
7
  colorize (~> 0.8)
8
8
  dotenv (~> 2.5)
9
9
  gitlab (~> 3.6)
10
10
  httparty (~> 0.13)
11
+ mutations (~> 0.8)
11
12
  net-ssh (~> 5.0)
12
13
  rest-client (~> 2.0)
13
14
  settingslogic (~> 2.0)
@@ -15,6 +16,41 @@ PATH
15
16
  tty-command (~> 0.8)
16
17
  tty-prompt (~> 0.16)
17
18
  tty-table (~> 0.10)
19
+ yade-composer-rest-client (~> 0.1)
20
+ yade-domain-rest-client (~> 0.1)
21
+ yade-project-rest-client (~> 0.1)
22
+
23
+ PATH
24
+ remote: /Users/seba/projekte/yade/src/yade-common
25
+ specs:
26
+ yade-common (0.1.2)
27
+ activemodel (~> 5.2)
28
+ httparty (~> 0.15)
29
+ settingslogic (~> 2.0)
30
+
31
+ PATH
32
+ remote: /Users/seba/projekte/yade/src/yade-composer-rest-client
33
+ specs:
34
+ yade-composer-rest-client (0.1.2)
35
+ activemodel (~> 5.2)
36
+ httparty (~> 0.15)
37
+ yade-common (~> 0.1)
38
+
39
+ PATH
40
+ remote: /Users/seba/projekte/yade/src/yade-domain-rest-client
41
+ specs:
42
+ yade-domain-rest-client (0.1.2)
43
+ activemodel (~> 5.2)
44
+ httparty (~> 0.15)
45
+ yade-common (~> 0.1)
46
+
47
+ PATH
48
+ remote: /Users/seba/projekte/yade/src/yade-project-rest-client
49
+ specs:
50
+ yade-project-rest-client (0.1.2)
51
+ activemodel (~> 5.2)
52
+ httparty (~> 0.15)
53
+ yade-common (~> 0.1)
18
54
 
19
55
  GEM
20
56
  remote: https://rubygems.org/
@@ -83,6 +119,8 @@ GEM
83
119
  multi_json (1.13.1)
84
120
  multi_test (0.1.2)
85
121
  multi_xml (0.6.0)
122
+ mutations (0.8.3)
123
+ activesupport
86
124
  necromancer (0.4.0)
87
125
  net-ssh (5.0.2)
88
126
  netrc (0.11.0)
@@ -123,7 +161,7 @@ GEM
123
161
  unicode-display_width (~> 1.0, >= 1.0.1)
124
162
  ruby-progressbar (1.10.0)
125
163
  settingslogic (2.0.9)
126
- strings (0.1.3)
164
+ strings (0.1.4)
127
165
  strings-ansi (~> 0.1.0)
128
166
  unicode-display_width (~> 1.4.0)
129
167
  unicode_utils (~> 1.4.0)
@@ -174,6 +212,10 @@ DEPENDENCIES
174
212
  rspec (~> 3.0)
175
213
  rspec-json_expectations (~> 2.1)
176
214
  rubocop (~> 0.58.0)
215
+ yade-common!
216
+ yade-composer-rest-client!
217
+ yade-domain-rest-client!
218
+ yade-project-rest-client!
177
219
  yadecli!
178
220
 
179
221
  BUNDLED WITH
@@ -11,14 +11,29 @@ module Yadecli
11
11
 
12
12
  class_option 'verbose', type: :boolean, default: false
13
13
 
14
- desc 'connect NAME', 'Connect to a yade backend'
15
- def connect(url)
16
- Yadecli::Service::ConnectService.new.connect url
14
+ desc 'version', 'Print Version'
15
+ def version
16
+ puts Yadecli::VERSION
17
+ end
18
+
19
+ desc 'connect URL', 'Connect to a yade backend'
20
+ def connect(yade_url)
21
+ CliUtil.print_header('Yade Connect',
22
+ ["Going to connect to yade backend", ''])
23
+
24
+ outcome = Yadecli::Command::ConnectCommand.run(yade_url: yade_url)
25
+
26
+ CliUtil.print_command_outcome(outcome)
17
27
  end
18
28
 
19
29
  desc 'login AUTH_URL USERNAME PASSWORD', 'Login to a yade'
20
30
  def login(auth_url, username, password)
21
- Yadecli::Service::AuthenticationService.new.login auth_url, username, password
31
+ CliUtil.print_header('Yade Login',
32
+ ["Going to log in user #{username}", ''])
33
+
34
+ outcome = Yadecli::Command::LoginCommand.run(auth_url: auth_url, auth_username: username, auth_password: password)
35
+
36
+ CliUtil.print_command_outcome(outcome)
22
37
  end
23
38
 
24
39
  desc 'host TYPE', 'Manage hosts'
@@ -11,57 +11,113 @@ module Yadecli
11
11
  # setup command
12
12
  desc 'setup', 'Setup yade composer on this host'
13
13
  def setup
14
- Yadecli::Service::ComposerService.new.setup
14
+ CliUtil.print_header('YadeCli Composer Setup',
15
+ ['Answer the following questions to setup Composer on this host:', ''])
16
+
17
+ outcome = Yadecli::Command::Composer::ComposerSetupCommand.run
18
+
19
+ CliUtil.print_command_outcome(outcome)
15
20
  end
16
21
 
17
22
  # list command
18
23
  desc 'list', 'List the available Yade composer projects'
19
24
  def list
20
- Yadecli::Service::ComposerService.new.list
25
+ CliUtil.print_header('YadeCli Composer List',
26
+ ['This are the available Yade composer projects you can install', ''])
27
+
28
+ outcome = Yadecli::Command::Composer::ComposerListCommand.run
29
+
30
+ CliUtil.print_command_outcome(outcome)
31
+
32
+ puts ''
33
+ puts 'You can install any of the listed project with the following command:'
34
+ puts ''
35
+ puts ' bin/yadecli composer install <name> <branch> [--pull] [--setup] [--clean]'.colorize(:mode => :bold)
36
+ puts ''
21
37
  end
22
38
 
23
39
  # install command
24
40
  desc 'install', 'Install a Yade composer project'
25
41
  method_option :clean, default: false, aliases: '-c', desc: 'Clean install, will delete a existing composer project'
26
42
  method_option :yes, default: false, aliases: '-y', desc: 'Will answer yes to all questions, This will run a git pull on installed projects without asking'
27
- method_option :pull, default: false, aliases: '-p', desc: 'Will run a git pull on a already installed project'
43
+ method_option :pull, default: false, aliases: '-p', desc: 'Will pull the container belonging to the project'
28
44
  def install(project_name, branch_name = nil)
29
- Yadecli::Service::ComposerService.new.install(project_name, branch_name, options)
45
+ CliUtil.print_header('YadeCli Composer Install',
46
+ ["Going to install Yade composer project #{project_name}", ''])
47
+
48
+ outcome = Yadecli::Command::Composer::ComposerInstallCommand.run(project_name: project_name,
49
+ branch_name: branch_name,
50
+ options: options)
51
+ CliUtil.print_command_outcome(outcome)
30
52
  end
31
53
 
32
54
  # switch branch command
33
55
  desc 'switch', 'Switch the branch of a installed Composer project'
34
56
  method_option :pull, default: false, aliases: '-p', desc: 'Will run a git pull after switching the branch'
35
57
  def switch(project_name, target_branch)
36
- Yadecli::Service::ComposerService.new.switch(project_name, target_branch, options)
58
+ CliUtil.print_header('Composer Switch',
59
+ ["Going to switch branch of composer project #{project_name} to #{target_branch}", ''])
60
+
61
+ outcome = Yadecli::Command::Composer::ComposerSwitchCommand.run(project_name: project_name,
62
+ target_branch: target_branch,
63
+ options: options)
64
+ CliUtil.print_command_outcome(outcome)
37
65
  end
38
66
 
39
67
  # uninstall command
40
68
  desc 'uninstall', 'Uninstall a Yade composer project'
41
69
  method_option :yes, default: false, aliases: '-y', desc: 'Will answer yes to all questions, This will uninstall the project without asking'
42
- def uninstall(name)
43
- Yadecli::Service::ComposerService.new.uninstall(name, options)
70
+ def uninstall(project_name)
71
+ CliUtil.print_header('YadeCli Composer Uninstall',
72
+ ["Going to uninstall composer project #{project_name}", ''])
73
+
74
+ outcome = Yadecli::Command::Composer::ComposerUninstallCommand.run(project_name: project_name,
75
+ options: options)
76
+ CliUtil.print_command_outcome(outcome)
44
77
  end
45
78
 
46
79
  # start command
47
- desc 'start', 'Start a Yade Composer service'
48
- def start(project_name = nil, service_name = nil)
49
- Yadecli::Service::ComposerService.new.start_service(project_name, service_name)
80
+ desc 'start', 'Start a Yade composer service'
81
+ def start(project_name, service_name)
82
+ CliUtil.print_header('YadeCli Composer Start',
83
+ ['Going to start composer service:',
84
+ " ↳ Composer Project : #{project_name}",
85
+ " ↳ Service Name : #{service_name}"])
86
+
87
+ outcome = Yadecli::Command::Composer::ComposerStartCommand.run(project_name: project_name,
88
+ service_name: service_name,
89
+ options: options)
90
+ CliUtil.print_command_outcome(outcome)
50
91
  end
51
92
 
52
93
  # stop command
53
94
  desc 'stop', 'Stop a Yade Composer service'
54
- method_option :rm, default: false, aliases: '-r', desc: 'Remoce the docker container after stopping'
95
+ method_option :rm, default: false, aliases: '-r', desc: 'Remove the docker container after stopping'
55
96
  method_option :down, default: false, aliases: '-r', desc: 'Run docker-compose down -v'
56
- def stop(project_name = nil, service_name = nil)
57
- Yadecli::Service::ComposerService.new.stop_service(project_name, service_name, options)
97
+ def stop(project_name, service_name)
98
+ CliUtil.print_header('Composer Service Stop',['Going to stop composer service:',
99
+ " ↳ Composer Project : #{project_name}",
100
+ " ↳ Service Name : #{service_name}"])
101
+
102
+ outcome = Yadecli::Command::Composer::ComposerStopCommand.run(project_name: project_name,
103
+ service_name: service_name,
104
+ options: options)
105
+
106
+ CliUtil.print_command_outcome(outcome)
58
107
  end
59
108
 
60
109
  # log container output of service
61
110
  desc 'log', 'Stop a Yade Composer service'
62
111
  method_option :follow, default: false, aliases: '-f', desc: 'Log the docker containers output of the service'
63
112
  def log(project_name, service_name)
64
- Yadecli::Service::ComposerService.new.log_service(project_name, service_name, options)
113
+ CliUtil.print_header('Composer Service Log',["Going to show logs for composer service #{service_name}.",
114
+ 'Hit ctrl + c to stop when you use the -f option'])
115
+
116
+ outcome = Yadecli::Command::Composer::ComposerLogCommand.run(project_name: project_name,
117
+ service_name: service_name,
118
+ options: options)
119
+
120
+ CliUtil.print_command_outcome(outcome)
65
121
  end
66
122
  end
67
123
  end
@@ -4,24 +4,38 @@ require 'thor'
4
4
 
5
5
  module Yadecli
6
6
  module Cli
7
-
8
- # Build
7
+ # Host
9
8
  class Host < Thor
10
9
 
11
10
  desc 'list', 'List available Yade hosts'
12
11
  def list
13
- Yadecli::Service::HostService.new.list
12
+ CliUtil.print_header'Yade list hosts',
13
+ ['This are the available hosts', '']
14
+
15
+ outcome = Yadecli::Command::Host::HostListCommand.run
16
+
17
+ CliUtil.print_command_outcome(outcome)
14
18
  end
15
19
 
16
20
  desc 'bootstrap', 'Bootstrap a Yade host to prepare it for provisioning'
17
21
  method_option :setup, default: true, aliases: '-s', desc: 'Setup Yade bootstrap repository on host and install plugins'
18
22
  def bootstrap(host_fqdn)
19
- Yadecli::Service::HostService.new.bootstrap(host_fqdn, options)
23
+ CliUtil.print_header'Yade bootstrap host',
24
+ ["Going to bootstrap Yade host #{host_fqdn}", '']
25
+
26
+ outcome = Yadecli::Command::Host::HostBootstrapCommand.run(host_fqdn: host_fqdn, options: options)
27
+
28
+ CliUtil.print_command_outcome(outcome)
20
29
  end
21
30
 
22
31
  desc 'provision', 'Provision a Yade host'
23
32
  def provision(host_fqdn)
24
- Yadecli::Service::HostService.new.provision(host_fqdn, options)
33
+ CliUtil.print_header'Yade provision host',
34
+ ["Going to provision Yade host #{host_fqdn}", '']
35
+
36
+ outcome = Yadecli::Command::Host::HostProvisionCommand.run(host_fqdn: host_fqdn, options: options)
37
+
38
+ CliUtil.print_command_outcome(outcome)
25
39
  end
26
40
  end
27
41
  end
@@ -10,13 +10,24 @@ module Yadecli
10
10
 
11
11
  desc 'list', 'List available modules'
12
12
  def list(project_name)
13
- Yadecli::Service::ModuleService.new.list(project_name)
13
+ CliUtil.print_header'YadeCli List Modules', ["This are the available modules for the Yade project #{project_name}", '']
14
+
15
+ outcome = Yadecli::Command::Module::ModuleListCommand.run(project_name: project_name)
16
+
17
+ CliUtil.print_command_outcome(outcome)
14
18
  end
15
19
 
16
20
  desc 'install', 'Install a module for the project given by name'
17
21
  method_option :yes, aliases: '-y', desc: 'Answering yes to all question, will do a update if module already installed'
18
- def install(project_name, module_name)
19
- Yadecli::Service::ModuleService.new.install(project_name, module_name, options)
22
+ method_option :all, aliases: '-a', desc: 'Install all modules of the project'
23
+ def install(project_name, *module_names)
24
+ CliUtil.print_header'YadeCli Install Module',
25
+ ["Going to install module #{module_names.join(', ')} for Yade project #{project_name}"]
26
+
27
+ outcome = Yadecli::Command::Module::ModuleInstallCommand.run(project_name: project_name,
28
+ module_names: module_names, options: options)
29
+
30
+ CliUtil.print_command_outcome(outcome)
20
31
  end
21
32
 
22
33
  end
@@ -10,31 +10,53 @@ module Yadecli
10
10
 
11
11
  desc 'list', 'List available projects'
12
12
  def list
13
- Yadecli::Service::ProjectService.new.list
13
+ CliUtil.print_header'YadeCli Projects', ['This are the available Yade projects', '']
14
+
15
+ outcome = Yadecli::Command::Project::ProjectListCommand.run
16
+
17
+ CliUtil.print_command_outcome(outcome)
14
18
  end
15
19
 
16
20
  desc 'install', 'Install a project'
17
21
  method_option :yes, aliases: '-y', desc: 'Answering yes to all question, will do a update if project already installed'
18
22
  def install(project_name)
19
- Yadecli::Service::ProjectService.new.install(project_name, options)
23
+ CliUtil.print_header'YadeCli Install Project',
24
+ ["Going to install Yade project #{project_name}", '']
25
+
26
+ outcome = Yadecli::Command::Project::ProjectInstallCommand.run(project_name: project_name, options: options)
27
+
28
+ CliUtil.print_command_outcome(outcome)
20
29
  end
21
30
 
22
31
  desc 'uninstall', 'Uninstall a project'
23
32
  method_option :yes, aliases: '-y', desc: 'Answering yes to all question, will do a unattended uninstall'
24
33
  def uninstall(project_name)
25
- Yadecli::Service::ProjectService.new.uninstall(project_name, options)
34
+ CliUtil.print_header'YadeCli Uninstall Project',
35
+ ["Going to uninstall Yade project #{project_name}", '']
36
+
37
+ outcome = Yadecli::Command::Project::ProjectUninstallCommand.run(project_name: project_name, options: options)
38
+
39
+ CliUtil.print_command_outcome(outcome)
26
40
  end
27
41
 
28
42
  desc 'setup', 'Setup a project'
29
- #method_option :yes, aliases: '-y', desc: 'Answering yes to all question, will do a unattended uninstall'
30
43
  def setup(project_name)
31
- Yadecli::Service::ProjectService.new.setup(project_name, options)
44
+ CliUtil.print_header'YadeCli Project Setup',
45
+ ["Going to setup Yade project #{project_name}"]
46
+
47
+ outcome = Yadecli::Command::Project::ProjectSetupCommand.run(project_name: project_name, options: options)
48
+
49
+ CliUtil.print_command_outcome(outcome)
32
50
  end
33
51
 
34
52
  desc 'start', 'Start a project'
35
- #method_option :yes, aliases: '-y', desc: 'Answering yes to all question, will do a unattended uninstall'
36
- def start(project_name)
37
- Yadecli::Service::ProjectService.new.start(project_name, options)
53
+ def start(project_name, selection = nil)
54
+ CliUtil.print_header'YadeCli Project Start',['Going to start Yade Project']
55
+
56
+ outcome = Yadecli::Command::Project::ProjectStartCommand.run(project_name: project_name, selection: selection,
57
+ options: options)
58
+
59
+ CliUtil.print_command_outcome(outcome)
38
60
  end
39
61
 
40
62
  end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'json'
4
+
5
+ # project start response
6
+ class ProjectStartResponse
7
+ include ActiveModel::Model
8
+ include ActiveModel::Serializers::JSON
9
+
10
+ attr_accessor :project, :project_home, :selection
11
+
12
+ validates_presence_of 'project', 'project_home', 'selection'
13
+
14
+ def attributes
15
+ instance_values
16
+ end
17
+
18
+ def write(path)
19
+ File.open(path, 'w') { |file| file.write(self.as_json(include: :project).to_json) }
20
+ end
21
+ end
@@ -8,13 +8,17 @@ module Yadecli
8
8
  class Task < Thor
9
9
 
10
10
  desc 'list', 'List the available tasks of a xxx'
11
- def list(module_name = nil)
12
- Yadecli::Service::BuildTaskService.new.list(module_name)
11
+ def list(project_name, module_name = nil)
12
+ CliUtil.print_header'YadeCli Tasks', ['This are the available Yade tasks', '']
13
+
14
+ Yadecli::Command::Task::TaskListCommand.run(project_name: project_name, module_name: module_name)
15
+
16
+ #CliUtil.print_command_outcome(outcome)
13
17
  end
14
18
 
15
- # desc 'pdf', 'Build html output'
16
- # def pdf
17
- # p 'Building pdf...'
19
+ # desc 'exec', 'Execute a module task'
20
+ # def exec(module_name, task_name)
21
+ # #Yadecli::Service::BuildTaskService.new.exec(module_name, task_name)
18
22
  # end
19
23
  end
20
24
  end
@@ -12,16 +12,14 @@ module Yadecli
12
12
  # request yade token
13
13
  def initialize
14
14
  Gitlab.configure do |config|
15
- config.endpoint = AppConfig[:git_api_url] # API endpoint URL, default: ENV['GITLAB_API_ENDPOINT']
16
- config.private_token = AppConfig[:git_token] # user's private token or OAuth2 access token, default: ENV['GITLAB_API_PRIVATE_TOKEN']
15
+ config.endpoint = Yade::Common::Config::ComposerConfig[:git_api_url]
16
+ config.private_token = Yade::Common::Config::ComposerConfig[:git_token]
17
17
  end
18
-
19
- #Gitlab.http_proxy('squid.dzbw.de', 3128)
20
18
  end
21
19
 
22
20
  # get branch names from gitlab project given by name
23
21
  def get_branch_names(repository_name)
24
- projects = Gitlab.projects
22
+ projects = Gitlab.projects(search: repository_name)
25
23
 
26
24
  project = projects.select { |p| repository_name == p.name }.first
27
25
 
@@ -32,7 +30,7 @@ module Yadecli
32
30
 
33
31
  # get branch names from gitlab project given by name
34
32
  def get_default_branch(repository_name)
35
- projects = Gitlab.projects
33
+ projects = Gitlab.projects(search: repository_name)
36
34
 
37
35
  project = projects.select { |p| repository_name == p.name }.first
38
36
 
@@ -0,0 +1,166 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'mutations'
4
+ require 'uri'
5
+
6
+ module Yadecli
7
+ module Command
8
+ module Composer
9
+ class ComposerInstallCommand < Mutations::Command
10
+
11
+ required do
12
+ string :project_name, empty: false
13
+ end
14
+
15
+ optional do
16
+ string :branch_name, empty: false
17
+ hash :options do
18
+ string :* # Allows any key to pass through. Useful for dynamic key / value objects
19
+ end
20
+ end
21
+
22
+ #
23
+ def execute
24
+ composer_project_client = Yade::Composer::Rest::Client::ComposerProjectClient.new
25
+ composer_service_client = Yade::Composer::Rest::Client::ComposerServiceClient.new
26
+
27
+ composer_project = composer_project_client.get_by_name(self.project_name)
28
+
29
+ # delete already installed when option --clean given
30
+ FileUtils.rm_rf(composer_project.install_dir) if options[:clean]
31
+
32
+ # check preconditions
33
+ check_install_preconditions(options)
34
+
35
+ # check already installed
36
+ already_installed = composer_project.installed?
37
+
38
+ # ask for branch if not given from commandline
39
+ branch_name = UserInput.select_branch(composer_project.git_repo_name) if branch_name == nil && !already_installed && !options[:yes]
40
+
41
+ if already_installed
42
+ puts "Composer project #{project_name} already installed.".colorize(color: :blue, mode: :bold)
43
+ puts ' ↳ Doing a git pull.'
44
+
45
+ pull_repository(composer_project, options)
46
+ else
47
+ puts "Composer project #{project_name} will be installed.".colorize(color: :blue, mode: :bold)
48
+ puts ' ↳ Doing a git clone.'
49
+
50
+ clone_repository(composer_project, branch_name)
51
+ end
52
+
53
+ puts ''
54
+ if already_installed
55
+ puts " Successfully updated '#{composer_project.name}' at #{composer_project.install_dir}."
56
+ else
57
+ puts " Successfully installed '#{composer_project.name}' to #{composer_project.install_dir}."
58
+ end
59
+
60
+ composer_services = composer_service_client.get_by_composer_project_id(composer_project.id)
61
+ service_names = composer_services.collect(&:name).join(' | ')
62
+
63
+ pull_container(composer_project) if options[:pull]
64
+
65
+ """
66
+ Use the following commands to manage the service(s)
67
+ Start : bin/yadecli composer start #{composer_project.name} #{service_names}
68
+ Stop : bin/yadecli composer stop #{composer_project.name} #{service_names}
69
+ """
70
+ end
71
+
72
+ private
73
+
74
+ # check install preconditions
75
+ def check_install_preconditions(options)
76
+ cmd = TTY::Command.new(output: Yadecli.LOGGER)
77
+
78
+ cmd.run('test -x /usr/bin/docker') if SystemUtil.os == 'linux'
79
+ cmd.run('test -x /usr/local/bin/docker') if SystemUtil.os == 'macosx'
80
+
81
+ cmd.run('test -x /usr/local/bin/docker-compose')
82
+ end
83
+
84
+ # clone repository
85
+ def clone_repository(composer_project, branch_name)
86
+ username = Yade::Common::Config::ComposerConfig[:git_username]
87
+ password = Yade::Common::Config::ComposerConfig[:git_password]
88
+
89
+ git_url = URI.parse(composer_project.gitUrl)
90
+
91
+ scheme = git_url.scheme
92
+ host = git_url.host
93
+ path = git_url.path
94
+
95
+ url_with_auth = "#{scheme}://#{username}:#{password}@#{host}#{path}"
96
+
97
+ cmd = TTY::Command.new(output: Yadecli.LOGGER)
98
+ cmdline = "git clone --depth=1 "
99
+ cmdline += "-b #{branch_name} " if branch_name != nil
100
+ cmdline += "#{url_with_auth} #{composer_project.install_dir}"
101
+
102
+ cmd.run(cmdline, only_output_on_error: true)
103
+ end
104
+
105
+ # pull repository
106
+ def pull_repository(composer_project, options)
107
+ if options[:yes]
108
+ answer = true
109
+ else
110
+ puts ''
111
+ answer = TTY::Prompt.new.yes?('Do you want to pull the changes for the repository?')
112
+ end
113
+
114
+ if answer
115
+ cmd = TTY::Command.new(output: Yadecli.LOGGER)
116
+ cmd.run('git pull', only_output_on_error: true, chdir: composer_project.install_dir)
117
+ else
118
+ puts 'There is nothing more I can do for you. Bye.'
119
+ exit(1)
120
+ end
121
+ end
122
+
123
+ # pull container
124
+ def pull_container(composer_project)
125
+ # make shure we are logged in to the docker registry
126
+ docker_login
127
+
128
+ cmd = TTY::Command.new(output: Yadecli.LOGGER)
129
+
130
+ puts ''
131
+ puts 'Pulling docker images:'.colorize(color: :blue)
132
+
133
+ doco = YAML.load_file("#{composer_project.install_dir}/docker-compose.yml")
134
+
135
+ has_failed_pulls = false
136
+ doco['services'].each do |k, v|
137
+ cmdline = "docker-compose pull #{k}"
138
+
139
+ print " ↳ #{cmdline}... "
140
+ begin
141
+ cmd.run(cmdline, chdir: composer_project.install_dir)
142
+
143
+ puts 'done'.colorize(:green)
144
+ rescue TTY::Command::ExitError => e
145
+ puts 'failed'.colorize(:red)
146
+ has_failed_pulls = true
147
+ end
148
+ end
149
+
150
+ puts ''
151
+ puts 'Successfully pulled all docker containers.'.colorize(:green) unless has_failed_pulls
152
+ puts "Failed to pull for at least on container. See log at #{Dir.pwd}/composer.log".colorize(:red) if has_failed_pulls
153
+ end
154
+
155
+ # docker login
156
+ def docker_login
157
+ cmd = TTY::Command.new(output: Yadecli.LOGGER)
158
+
159
+ cmdline = "docker login #{Yade::Common::Config::ComposerConfig[:docker_registry_url]} -u #{Yade::Common::Config::ComposerConfig[:docker_registry_username]} -p #{Yade::Common::Config::ComposerConfig[:docker_registry_password]}"
160
+
161
+ cmd.run(cmdline, only_output_on_error: true)
162
+ end
163
+ end
164
+ end
165
+ end
166
+ end