yadecli 0.1.1

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 (83) hide show
  1. checksums.yaml +7 -0
  2. data/.DS_Store +0 -0
  3. data/.gitignore +13 -0
  4. data/.rspec +3 -0
  5. data/.travis.yml +7 -0
  6. data/CODE_OF_CONDUCT.md +74 -0
  7. data/Gemfile +6 -0
  8. data/Gemfile.lock +172 -0
  9. data/LICENSE.txt +21 -0
  10. data/README.md +43 -0
  11. data/Rakefile +13 -0
  12. data/bin/yadecli +10 -0
  13. data/config-example.yml +14 -0
  14. data/lib/.DS_Store +0 -0
  15. data/lib/yadecli/.DS_Store +0 -0
  16. data/lib/yadecli/cli/application.rb +40 -0
  17. data/lib/yadecli/cli/composer.rb +68 -0
  18. data/lib/yadecli/cli/host.rb +28 -0
  19. data/lib/yadecli/cli/module.rb +24 -0
  20. data/lib/yadecli/cli/project.rb +42 -0
  21. data/lib/yadecli/cli/task.rb +21 -0
  22. data/lib/yadecli/client/authentication_client.rb +24 -0
  23. data/lib/yadecli/client/base_client.rb +78 -0
  24. data/lib/yadecli/client/composer_container_client.rb +27 -0
  25. data/lib/yadecli/client/composer_project_client.rb +27 -0
  26. data/lib/yadecli/client/composer_service_client.rb +27 -0
  27. data/lib/yadecli/client/domain_client.rb +23 -0
  28. data/lib/yadecli/client/host_client.rb +45 -0
  29. data/lib/yadecli/client/maven_build_step_client.rb +23 -0
  30. data/lib/yadecli/client/maven_build_task_client.rb +23 -0
  31. data/lib/yadecli/client/nvm_runtime_client.rb +23 -0
  32. data/lib/yadecli/client/project_client.rb +28 -0
  33. data/lib/yadecli/client/project_module_client.rb +35 -0
  34. data/lib/yadecli/client/pyenv_runtime_client.rb +23 -0
  35. data/lib/yadecli/client/role_client.rb +23 -0
  36. data/lib/yadecli/client/rvm_runtime_client.rb +23 -0
  37. data/lib/yadecli/client/sdk_package_client.rb +28 -0
  38. data/lib/yadecli/client/vcs_client.rb +23 -0
  39. data/lib/yadecli/config/app_config.rb +69 -0
  40. data/lib/yadecli/io/user_input.rb +21 -0
  41. data/lib/yadecli/model/composer_container.rb +19 -0
  42. data/lib/yadecli/model/composer_project.rb +30 -0
  43. data/lib/yadecli/model/composer_service.rb +19 -0
  44. data/lib/yadecli/model/domain.rb +24 -0
  45. data/lib/yadecli/model/git_status.rb +8 -0
  46. data/lib/yadecli/model/host.rb +24 -0
  47. data/lib/yadecli/model/ide_type.rb +7 -0
  48. data/lib/yadecli/model/installation_status.rb +7 -0
  49. data/lib/yadecli/model/maven_build_step.rb +19 -0
  50. data/lib/yadecli/model/maven_build_task.rb +19 -0
  51. data/lib/yadecli/model/nvm_runtime.rb +18 -0
  52. data/lib/yadecli/model/project.rb +26 -0
  53. data/lib/yadecli/model/project_module.rb +29 -0
  54. data/lib/yadecli/model/pyenv_runtime.rb +18 -0
  55. data/lib/yadecli/model/role.rb +24 -0
  56. data/lib/yadecli/model/rvm_runtime.rb +18 -0
  57. data/lib/yadecli/model/sdk_package.rb +18 -0
  58. data/lib/yadecli/model/vcs.rb +19 -0
  59. data/lib/yadecli/service/authentication_service.rb +31 -0
  60. data/lib/yadecli/service/build_step_service.rb +24 -0
  61. data/lib/yadecli/service/build_task_service.rb +70 -0
  62. data/lib/yadecli/service/composer_service.rb +395 -0
  63. data/lib/yadecli/service/connect_service.rb +19 -0
  64. data/lib/yadecli/service/host_service.rb +191 -0
  65. data/lib/yadecli/service/module_service.rb +78 -0
  66. data/lib/yadecli/service/project_service.rb +198 -0
  67. data/lib/yadecli/util/cli_util.rb +22 -0
  68. data/lib/yadecli/util/file_util.rb +46 -0
  69. data/lib/yadecli/util/nvm_util.rb +14 -0
  70. data/lib/yadecli/util/pyenv_util.rb +14 -0
  71. data/lib/yadecli/util/rvm_util.rb +38 -0
  72. data/lib/yadecli/util/sdk_util.rb +23 -0
  73. data/lib/yadecli/util/system_util.rb +22 -0
  74. data/lib/yadecli/version.rb +3 -0
  75. data/lib/yadecli.rb +69 -0
  76. data/scripts/nvm-install-node.sh +6 -0
  77. data/scripts/rvm-gemset-import.sh +8 -0
  78. data/scripts/rvm-install-ruby.sh +6 -0
  79. data/scripts/sdk-install-candidate.sh +6 -0
  80. data/scripts/setup-terminal.sh +3 -0
  81. data/scripts/start-ide.sh +3 -0
  82. data/yadecli.gemspec +55 -0
  83. metadata +379 -0
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'active_model'
4
+
5
+ # Host
6
+ class Host
7
+ include ActiveModel::Model
8
+ include ActiveModel::Validations
9
+ include ActiveModel::Serializers::JSON
10
+
11
+ attr_accessor :id, :name, :hostName, :ip, :datacenter, :zone, :environmentType, :osType, :isMaster, :domainId, :roleId
12
+
13
+ validates_presence_of 'id', 'name', 'hostName', 'ip', 'datacenter', 'zone', 'environmentType', 'osType', 'domainId', 'roleId'
14
+
15
+ def attributes=(hash)
16
+ hash.each do |key, value|
17
+ send("#{key}=", value)
18
+ end
19
+ end
20
+
21
+ def attributes
22
+ instance_values
23
+ end
24
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ # installation status
4
+ class IdeType
5
+ RUBYMINE = 'mine'
6
+ IDEA = 'idea'
7
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ # installation status
4
+ class InstallationStatus
5
+ INSTALLED = 'y'
6
+ NOT_INSTALLED = 'n'
7
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'active_model'
4
+
5
+ # MavenBuildStep
6
+ class MavenBuildStep
7
+ include ActiveModel::Model
8
+ include ActiveModel::Validations
9
+ include ActiveModel::Serializers::JSON
10
+
11
+ attr_accessor :id, :command, :profiles, :parameters, :mavenBuildTaskId
12
+
13
+ validates_presence_of 'id', 'command', 'mavenBuildTaskId'
14
+
15
+ def attributes
16
+ instance_values
17
+ end
18
+
19
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'active_model'
4
+
5
+ # MavenBuildTask
6
+ class MavenBuildTask
7
+ include ActiveModel::Model
8
+ include ActiveModel::Validations
9
+ include ActiveModel::Serializers::JSON
10
+
11
+ attr_accessor :id, :name, :desc, :profiles, :parameters, :projectModuleId
12
+
13
+ validates_presence_of 'id', 'name', 'projectModuleId'
14
+
15
+ def attributes
16
+ instance_values
17
+ end
18
+
19
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'active_model'
4
+
5
+ # NvmRuntime
6
+ class NvmRuntime
7
+ include ActiveModel::Model
8
+ include ActiveModel::Validations
9
+ include ActiveModel::Serializers::JSON
10
+
11
+ attr_accessor :id, :version, :packages
12
+
13
+ validates_presence_of 'id', 'version',
14
+
15
+ def attributes
16
+ instance_values
17
+ end
18
+ end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'active_model'
4
+
5
+ # Project
6
+ class Project
7
+ include ActiveModel::Model
8
+ include ActiveModel::Validations
9
+ include ActiveModel::Serializers::JSON
10
+
11
+ attr_accessor :id, :name, :ideType, :vcsId, :nvmRuntimeId, :rvmRuntimeId, :pyenvRuntimeId
12
+
13
+ validates_presence_of 'id', 'name', 'ideType', 'vcsId'
14
+
15
+ def attributes
16
+ instance_values
17
+ end
18
+
19
+ def home
20
+ "#{File.expand_path('~')}/yade/projects/#{name}"
21
+ end
22
+
23
+ def installed?
24
+ File.directory?(home)
25
+ end
26
+ end
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'active_model'
4
+
5
+ # Module
6
+ class ProjectModule
7
+ include ActiveModel::Model
8
+ include ActiveModel::Validations
9
+ include ActiveModel::Serializers::JSON
10
+
11
+ attr_accessor :id, :name, :enabled, :languageType, :buildToolType, :vcsId, :projectId
12
+
13
+ validates_presence_of 'id', 'name', 'languageType', 'buildToolType', 'vcsId', 'projectId'
14
+
15
+ def attributes
16
+ instance_values
17
+ end
18
+
19
+ def home
20
+ project_client = Yadecli::Client::ProjectClient.new('yadeproject', 'project')
21
+ project = project_client.get(projectId)
22
+
23
+ "#{project.home}/src/#{name}"
24
+ end
25
+
26
+ def installed?
27
+ File.directory?(home)
28
+ end
29
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'active_model'
4
+
5
+ # PyenvRuntime
6
+ class PyenvRuntime
7
+ include ActiveModel::Model
8
+ include ActiveModel::Validations
9
+ include ActiveModel::Serializers::JSON
10
+
11
+ attr_accessor :id, :version, :packages
12
+
13
+ validates_presence_of 'id', 'version',
14
+
15
+ def attributes
16
+ instance_values
17
+ end
18
+ end
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'active_model'
4
+
5
+ # Role
6
+ class Role
7
+ include ActiveModel::Model
8
+ include ActiveModel::Validations
9
+ include ActiveModel::Serializers::JSON
10
+
11
+ attr_accessor :id, :name
12
+
13
+ validates_presence_of 'id', 'name'
14
+
15
+ def attributes=(hash)
16
+ hash.each do |key, value|
17
+ send("#{key}=", value)
18
+ end
19
+ end
20
+
21
+ def attributes
22
+ instance_values
23
+ end
24
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'active_model'
4
+
5
+ # RvmRuntime
6
+ class RvmRuntime
7
+ include ActiveModel::Model
8
+ include ActiveModel::Validations
9
+ include ActiveModel::Serializers::JSON
10
+
11
+ attr_accessor :id, :version, :packages
12
+
13
+ validates_presence_of 'id', 'version',
14
+
15
+ def attributes
16
+ instance_values
17
+ end
18
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'active_model'
4
+
5
+ # SdkPackage
6
+ class SdkPackage
7
+ include ActiveModel::Model
8
+ include ActiveModel::Validations
9
+ include ActiveModel::Serializers::JSON
10
+
11
+ attr_accessor :id, :name, :projectId, :version
12
+
13
+ validates_presence_of 'id', 'name', 'projectId', 'version'
14
+
15
+ def attributes
16
+ instance_values
17
+ end
18
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'active_model'
4
+
5
+ # Vcs
6
+ class Vcs
7
+ include ActiveModel::Model
8
+ include ActiveModel::Validations
9
+ include ActiveModel::Serializers::JSON
10
+
11
+ attr_accessor :id, :vcsType, :url
12
+
13
+ validates_presence_of 'id', 'vcsType', 'url'
14
+
15
+ def attributes
16
+ instance_values
17
+ end
18
+
19
+ end
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ # yadecli cli
4
+ module Yadecli
5
+ module Service
6
+
7
+ # connect
8
+ class AuthenticationService
9
+
10
+ def initialize
11
+ @authentication_client = Yadecli::Client::AuthenticationClient.new
12
+ end
13
+
14
+ def login(auth_url, username, password)
15
+ CliUtil.print_header('Yade Login',
16
+ ["Going to log in user #{username}, password: *** against uaa at #{auth_url}", ''])
17
+
18
+ response = @authentication_client.request_token(auth_url, username, password)
19
+
20
+ AppConfig[:auth_url] = auth_url
21
+ AppConfig[:username] = username
22
+ AppConfig[:password] = password
23
+ AppConfig[:access_token] = response['access_token']
24
+ AppConfig[:refresh_token] = response['refresh_token']
25
+ AppConfig[:expiration_time] = Time.now + response['expires_in']
26
+
27
+ AppConfig.write!
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ # yadecli cli
4
+ module Yadecli
5
+ module Service
6
+
7
+ # list
8
+ class BuildStepService
9
+
10
+ def initialize
11
+ @maven_build_step_client = Yadecli::Client::MavenBuildStepClient.new
12
+ end
13
+
14
+ # build
15
+ def maven_build_steps
16
+ @maven_build_step_client.list
17
+ end
18
+
19
+ def maven_build_steps_for_task(maven_build_task_id)
20
+ maven_build_steps.select {|mbs| mbs.mavenBuildTaskId == maven_build_task_id}
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,70 @@
1
+ # frozen_string_literal: true
2
+
3
+ # yadecli cli
4
+ module Yadecli
5
+ module Service
6
+
7
+ # list
8
+ class BuildTaskService
9
+
10
+ def initialize
11
+ @module_client = Yadecli::Client::ProjectModuleClient.new
12
+ @maven_build_task_client = Yadecli::Client::MavenBuildTaskClient.new
13
+ @maven_build_step_service = Yadecli::Service::BuildStepService.new
14
+ end
15
+
16
+ # build
17
+ def maven_build_tasks
18
+ @maven_build_task_client.list
19
+ end
20
+
21
+ def list(module_name = nil)
22
+ CliUtil.print_header'YadeCli Tasks List',
23
+ ['Going to list Yade tasks', '']
24
+
25
+ puts 'You can run any of these tasks with `yade task run <name>`'
26
+ puts ''
27
+
28
+ if module_name
29
+ tasks_to_list = maven_build_tasks.select do |mbt|
30
+ tmodule = @module_client.get(mbt.moduleId)
31
+ tmodule.name == module_name
32
+ end
33
+ else
34
+ tasks_to_list = maven_build_tasks
35
+ end
36
+
37
+ tasks_to_list.each do |maven_build_task|
38
+
39
+ tmodule = @module_client.get(maven_build_task.moduleId)
40
+
41
+ print "Task: #{maven_build_task.name}".colorize(:mode => :bold)
42
+ puts " - #{maven_build_task.desc}"
43
+ puts " ▶ Module : #{tmodule.name}"
44
+ puts " ▶ Profiles : #{maven_build_task.profiles}"
45
+ puts " ▶ Parameters: #{maven_build_task.parameters}"
46
+
47
+ puts ''
48
+ puts 'Build Steps:'
49
+
50
+ maven_build_steps = @maven_build_step_service.maven_build_steps_for_task(maven_build_task.id)
51
+
52
+ rows = []
53
+ maven_build_steps.each do |mbs|
54
+ profiles = mbs.profiles || '-'
55
+ command = mbs.command
56
+ parameters = mbs.parameters || '-'
57
+
58
+ rows << [profiles, command, parameters]
59
+ end
60
+
61
+ table = TTY::Table.new header: ['Profiles', 'Command', 'Parameters'], rows: rows
62
+
63
+ puts table.render(:ascii, width: 80, resize: true, padding: [0, 1])
64
+ puts ''
65
+ end
66
+ end
67
+
68
+ end
69
+ end
70
+ end