sct 0.1.14 → 0.1.19

Sign up to get free protection for your applications and to get access to all the features.
Files changed (63) hide show
  1. checksums.yaml +4 -4
  2. data/bin/sct +3 -4
  3. data/{.DS_Store → cluster/lib/.DS_Store} +0 -0
  4. data/cluster/lib/cluster.rb +6 -0
  5. data/cluster/lib/cluster/commands_generator.rb +95 -0
  6. data/cluster/lib/cluster/module.rb +7 -0
  7. data/cluster/lib/cluster/runner.rb +239 -0
  8. data/{lib → sct/lib}/.DS_Store +0 -0
  9. data/sct/lib/sct.rb +17 -0
  10. data/sct/lib/sct/.DS_Store +0 -0
  11. data/sct/lib/sct/cli_tools_distributor.rb +46 -0
  12. data/{lib → sct/lib}/sct/command.rb +0 -0
  13. data/sct/lib/sct/commands/hostfile.rb +68 -0
  14. data/sct/lib/sct/commands/init.rb +37 -0
  15. data/sct/lib/sct/commands/mysqlproxy.rb +20 -0
  16. data/sct/lib/sct/commands_generator.rb +56 -0
  17. data/sct/lib/sct/tools.rb +12 -0
  18. data/sct/lib/sct/version.rb +3 -0
  19. data/sct_core/lib/.DS_Store +0 -0
  20. data/sct_core/lib/sct_core.rb +13 -0
  21. data/{lib/sct → sct_core/lib/sct_core}/.DS_Store +0 -0
  22. data/sct_core/lib/sct_core/command_executor.rb +104 -0
  23. data/{lib/sct → sct_core/lib/sct_core}/config.rb +3 -3
  24. data/sct_core/lib/sct_core/core_ext/string.rb +9 -0
  25. data/{lib/sct/setup/helpers.rb → sct_core/lib/sct_core/helper.rb} +2 -2
  26. data/sct_core/lib/sct_core/module.rb +0 -0
  27. data/sct_core/lib/sct_core/sct_pty.rb +53 -0
  28. data/sct_core/lib/sct_core/ui/implementations/shell.rb +129 -0
  29. data/sct_core/lib/sct_core/ui/interface.rb +120 -0
  30. data/sct_core/lib/sct_core/ui/ui.rb +26 -0
  31. data/shell/README.md +0 -0
  32. data/shell/lib/shell.rb +3 -0
  33. data/{lib/sct → shell/lib/shell}/ClassLevelInheritableAttributes.rb +0 -0
  34. data/shell/lib/shell/commands_generator.rb +14 -0
  35. data/{lib/sct → shell/lib/shell}/docker/composer.rb +4 -3
  36. data/{lib/sct → shell/lib/shell}/docker/docker.rb +7 -10
  37. data/{lib/sct → shell/lib/shell}/docker/php.rb +3 -2
  38. data/{lib/sct → shell/lib/shell}/docker/yarn.rb +4 -3
  39. data/shell/lib/shell/module.rb +9 -0
  40. data/shell/lib/shell/runner.rb +34 -0
  41. data/shell/lib/shell/tools.rb +7 -0
  42. metadata +92 -54
  43. data/.gitignore +0 -12
  44. data/.rspec +0 -3
  45. data/.travis.yml +0 -7
  46. data/CODE_OF_CONDUCT.md +0 -74
  47. data/Gemfile +0 -4
  48. data/Gemfile.lock +0 -48
  49. data/LICENSE.txt +0 -21
  50. data/README.md +0 -134
  51. data/Rakefile +0 -6
  52. data/lib/sct.rb +0 -61
  53. data/lib/sct/command_interface.rb +0 -18
  54. data/lib/sct/command_option.rb +0 -14
  55. data/lib/sct/commands/cluster.rb +0 -121
  56. data/lib/sct/commands/composer.rb +0 -29
  57. data/lib/sct/commands/hostfile.rb +0 -125
  58. data/lib/sct/commands/init.rb +0 -51
  59. data/lib/sct/commands/mysqlproxy.rb +0 -38
  60. data/lib/sct/commands/php.rb +0 -37
  61. data/lib/sct/commands/yarn.rb +0 -26
  62. data/lib/sct/version.rb +0 -3
  63. data/sct.gemspec +0 -40
@@ -0,0 +1,120 @@
1
+ module SctCore
2
+ # Abstract super class
3
+ class Interface
4
+ #####################################################
5
+ # @!group Messaging: show text to the user
6
+ #####################################################
7
+
8
+ # Level Error: Can be used to show additional error
9
+ # information before actually raising an exception
10
+ # or can be used to just show an error from which
11
+ #
12
+ # By default those messages are shown in red
13
+ def error(_message)
14
+ not_implemented(__method__)
15
+ end
16
+
17
+ # Level Important: Can be used to show warnings to the user
18
+ # not necessarily negative, but something the user should
19
+ # be aware of.
20
+ #
21
+ # By default those messages are shown in yellow
22
+ def important(_message)
23
+ not_implemented(__method__)
24
+ end
25
+
26
+ # Level Success: Show that something was successful
27
+ #
28
+ # By default those messages are shown in green
29
+ def success(_message)
30
+ not_implemented(__method__)
31
+ end
32
+
33
+ # Level Message: Show a neutral message to the user
34
+ #
35
+ # By default those messages shown in white/black
36
+ def message(_message)
37
+ not_implemented(__method__)
38
+ end
39
+
40
+ # Level Deprecated: Show that a particular function is deprecated
41
+ #
42
+ # By default those messages shown in strong blue
43
+ def deprecated(_message)
44
+ not_implemented(__method__)
45
+ end
46
+
47
+ # Level Command: Print out a terminal command that is being
48
+ # executed.
49
+ #
50
+ # By default those messages shown in cyan
51
+ def command(_message)
52
+ not_implemented(__method__)
53
+ end
54
+
55
+ # Level Command Output: Print the output of a command with
56
+ # this method
57
+ #
58
+ # By default those messages shown in magenta
59
+ def command_output(_message)
60
+ not_implemented(__method__)
61
+ end
62
+
63
+ # Level Verbose: Print out additional information for the
64
+ # users that are interested. Will only be printed when
65
+ #
66
+ # By default those messages are shown in white
67
+ def verbose(_message)
68
+ not_implemented(__method__)
69
+ end
70
+
71
+ # Print a header = a text in a box
72
+ # use this if this message is really important
73
+ def header(_message)
74
+ not_implemented(__method__)
75
+ end
76
+
77
+ # Print lines of content around specific line where
78
+ # failed to parse.
79
+ #
80
+ # This message will be shown as error
81
+ def content_error(content, error_line)
82
+ not_implemented(__method__)
83
+ end
84
+
85
+ #####################################################
86
+ # @!group Errors: Inputs
87
+ #####################################################
88
+
89
+ # Is is possible to ask the user questions?
90
+ def interactive?
91
+ not_implemented(__method__)
92
+ end
93
+
94
+ # get a standard text input (single line)
95
+ def input(_message)
96
+ not_implemented(__method__)
97
+ end
98
+
99
+ # A simple yes or no question
100
+ def confirm(_message)
101
+ not_implemented(__method__)
102
+ end
103
+
104
+ # Let the user select one out of x items
105
+ # return value is the value of the option the user chose
106
+ def select(_message, _options)
107
+ not_implemented(__method__)
108
+ end
109
+
110
+ # Password input for the user, text field shouldn't show
111
+ # plain text
112
+ def password(_message)
113
+ not_implemented(__method__)
114
+ end
115
+
116
+ def user_error!(error_message, options = {})
117
+ not_implemented(__method__)
118
+ end
119
+ end
120
+ end
@@ -0,0 +1,26 @@
1
+ module SctCore
2
+ class UI
3
+ class << self
4
+ attr_accessor(:ui_object)
5
+
6
+ def ui_object
7
+ require_relative 'implementations/shell'
8
+ @ui_object ||= Shell.new
9
+ end
10
+
11
+ def method_missing(method_sym, *args, &_block)
12
+ # not using `responds` because we don't care about methods like .to_s and so on
13
+ require_relative 'interface'
14
+ interface_methods = SctCore::Interface.instance_methods - Object.instance_methods
15
+ UI.user_error!("Unknown method '#{method_sym}', supported #{interface_methods}") unless interface_methods.include?(method_sym)
16
+
17
+ self.ui_object.send(method_sym, *args)
18
+ end
19
+ end
20
+ end
21
+ end
22
+
23
+ # Import all available implementations
24
+ Dir[File.dirname(__FILE__) + '/implementations/*.rb'].each do |file|
25
+ require_relative file
26
+ end
File without changes
@@ -0,0 +1,3 @@
1
+ require_relative 'shell/tools'
2
+ require_relative 'shell/runner'
3
+ require_relative 'shell/module'
@@ -0,0 +1,14 @@
1
+ require_relative 'runner'
2
+
3
+ module Shell
4
+ class CommandsGenerator
5
+
6
+ def self.start
7
+ self.new.run
8
+ end
9
+
10
+ def run
11
+ Shell::Runner.new.launch
12
+ end
13
+ end
14
+ end
@@ -1,13 +1,14 @@
1
- require "sct/docker/docker"
1
+ require "sct_core"
2
+ require_relative "docker"
2
3
 
3
- module Sct
4
+ module Shell
4
5
  class Composer < Docker
5
6
 
6
7
  # Configure the Yarn command
7
8
  def self.config
8
9
  self.setImage("eu.gcr.io/dev-pasc-vcdm/helpers-composer:latest", true)
9
10
  self.setPwdAsVolume("/app")
10
- self.addVolume(Sct::Helpers.convertWSLToWindowsPath("#{Sct::Helpers.windowsHomePath || Sct::Helpers.homePath}/.composer") , "/tmp")
11
+ self.addVolume(SctCore::Helper.convertWSLToWindowsPath("#{SctCore::Helper.windowsHomePath || SctCore::Helper.homePath}/.composer") , "/tmp")
11
12
  self.setCurrentUserAndGroup()
12
13
  self.setEntrypoint("composer")
13
14
  end
@@ -1,6 +1,7 @@
1
- require "sct/ClassLevelInheritableAttributes"
1
+ require "sct_core"
2
+ require "shell/ClassLevelInheritableAttributes"
2
3
 
3
- module Sct
4
+ module Shell
4
5
  class Docker
5
6
  include ClassLevelInheritableAttributes
6
7
  inheritable_attributes :image, :is_private_registry, :entrypoint, :volumes, :ports, :extra_arguments
@@ -26,9 +27,7 @@ module Sct
26
27
  ###
27
28
  def self.exec(cli_arguments)
28
29
 
29
- cli_arguments.each do | argument |
30
- self.addExtraArgument(argument)
31
- end
30
+ self.addExtraArgument(cli_arguments)
32
31
 
33
32
  self.config()
34
33
 
@@ -60,8 +59,8 @@ module Sct
60
59
  def self.setPwdAsVolume(volume_path)
61
60
  pwd = `pwd -P`
62
61
 
63
- if Sct::Helpers.operatingSystem == Sct::Helpers::WINDOWS
64
- pwd=Sct::Helpers.convertWSLToWindowsPath(pwd)
62
+ if SctCore::Helper.operatingSystem == SctCore::Helper::WINDOWS
63
+ pwd=SctCore::Helper.convertWSLToWindowsPath(pwd)
65
64
  end
66
65
 
67
66
  addVolume(pwd, volume_path)
@@ -141,9 +140,7 @@ module Sct
141
140
  def self.runCommand()
142
141
  command = self.compileCommand()
143
142
 
144
- system(command)
145
-
146
- return $?.success?
143
+ SctCore::CommandExecutor.execute(command: command, print_all: true, suppress_output: false)
147
144
  end
148
145
 
149
146
  ###
@@ -1,6 +1,7 @@
1
- require "sct/docker/docker"
1
+ require "sct_core"
2
+ require_relative "docker"
2
3
 
3
- module Sct
4
+ module Shell
4
5
  class Php < Docker
5
6
 
6
7
  # Configure the Yarn command
@@ -1,13 +1,14 @@
1
- require "sct/docker/docker"
1
+ require "sct_core"
2
+ require_relative "docker"
2
3
 
3
- module Sct
4
+ module Shell
4
5
  class Yarn < Docker
5
6
 
6
7
  # Configure the Yarn command
7
8
  def self.config
8
9
  self.setImage("eu.gcr.io/dev-pasc-vcdm/helpers-yarn:latest", true)
9
10
  self.setPwdAsVolume("/app")
10
- self.addVolume(Sct::Helpers.convertWSLToWindowsPath("#{Sct::Helpers.windowsHomePath || Sct::Helpers.homePath}/.cache") , "/.cache")
11
+ self.addVolume(SctCore::Helper.convertWSLToWindowsPath("#{SctCore::Helper.windowsHomePath || SctCore::Helper.homePath}/.cache") , "/.cache")
11
12
  self.mapPort(8081, 8080)
12
13
  self.mapPort(9001)
13
14
  self.setCurrentUserAndGroup()
@@ -0,0 +1,9 @@
1
+ require 'sct_core/helper'
2
+
3
+ module Shell
4
+
5
+ # import the helper functionality from SCT
6
+ Helpers = Sct::Helper
7
+ UI = Sct::UI
8
+
9
+ end
@@ -0,0 +1,34 @@
1
+ module Shell
2
+ class Runner
3
+ # define launch work
4
+ def launch
5
+
6
+ tool_name = ARGV.first ? ARGV.first.downcase : nil
7
+
8
+ if tool_name && Shell::TOOLS.include?(tool_name.to_sym)
9
+
10
+ require_relative "docker/#{tool_name}"
11
+ command = "#{ARGV[1..(ARGV.length+1)].join(" ")}"
12
+
13
+ case ARGV.first
14
+ when 'php'
15
+ Shell::Php.exec(command)
16
+ when 'composer'
17
+ Shell::Composer.exec(command)
18
+ when 'yarn'
19
+ Shell::Yarn.exec(command)
20
+ else
21
+ show_error
22
+ end
23
+
24
+ else
25
+ show_error
26
+ end
27
+ end
28
+
29
+ def show_error
30
+ tools = Shell::TOOLS.map { |tool| tool.to_s }.join(", ")
31
+ UI.error("Tool not found. Try one of these: #{tools}")
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,7 @@
1
+ module Shell
2
+ TOOLS = [
3
+ :yarn,
4
+ :composer,
5
+ :php
6
+ ]
7
+ end
metadata CHANGED
@@ -1,85 +1,111 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sct
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.14
4
+ version: 0.1.19
5
5
  platform: ruby
6
6
  authors:
7
7
  - Reshad Farid
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-02-26 00:00:00.000000000 Z
11
+ date: 2020-03-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: class_interface
14
+ name: colored
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 0.1.1
19
+ version: '1.2'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 0.1.1
26
+ version: '1.2'
27
27
  - !ruby/object:Gem::Dependency
28
- name: colored
28
+ name: commander
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '1.2'
33
+ version: 4.4.7
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '1.2'
40
+ version: 4.4.7
41
41
  - !ruby/object:Gem::Dependency
42
- name: hosts
42
+ name: highline
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "~>"
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: 0.1.1
47
+ version: 1.7.2
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - "~>"
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
- version: 0.1.1
54
+ version: 1.7.2
55
55
  - !ruby/object:Gem::Dependency
56
- name: commander
56
+ name: terminal-table
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 4.4.7
61
+ version: '1.8'
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: 4.4.7
68
+ version: '1.8'
69
69
  - !ruby/object:Gem::Dependency
70
- name: highline
70
+ name: tty-screen
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - ">="
74
74
  - !ruby/object:Gem::Version
75
- version: 1.7.2
75
+ version: 0.6.3
76
+ - - "<"
77
+ - !ruby/object:Gem::Version
78
+ version: 1.0.0
76
79
  type: :runtime
77
80
  prerelease: false
78
81
  version_requirements: !ruby/object:Gem::Requirement
79
82
  requirements:
80
83
  - - ">="
81
84
  - !ruby/object:Gem::Version
82
- version: 1.7.2
85
+ version: 0.6.3
86
+ - - "<"
87
+ - !ruby/object:Gem::Version
88
+ version: 1.0.0
89
+ - !ruby/object:Gem::Dependency
90
+ name: tty-spinner
91
+ requirement: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - ">="
94
+ - !ruby/object:Gem::Version
95
+ version: 0.8.0
96
+ - - "<"
97
+ - !ruby/object:Gem::Version
98
+ version: 1.0.0
99
+ type: :runtime
100
+ prerelease: false
101
+ version_requirements: !ruby/object:Gem::Requirement
102
+ requirements:
103
+ - - ">="
104
+ - !ruby/object:Gem::Version
105
+ version: 0.8.0
106
+ - - "<"
107
+ - !ruby/object:Gem::Version
108
+ version: 1.0.0
83
109
  - !ruby/object:Gem::Dependency
84
110
  name: bundler
85
111
  requirement: !ruby/object:Gem::Requirement
@@ -127,45 +153,54 @@ description: Spend Cloud Tool enables to setup a local development environment f
127
153
  email:
128
154
  - reshad.farid@visma.com
129
155
  executables:
156
+ - console
130
157
  - sct
158
+ - setup
131
159
  extensions: []
132
160
  extra_rdoc_files: []
133
161
  files:
134
- - ".DS_Store"
135
- - ".gitignore"
136
- - ".rspec"
137
- - ".travis.yml"
138
- - CODE_OF_CONDUCT.md
139
- - Gemfile
140
- - Gemfile.lock
141
- - LICENSE.txt
142
- - README.md
143
- - Rakefile
144
162
  - bin/console
145
163
  - bin/sct
146
164
  - bin/setup
147
- - lib/.DS_Store
148
- - lib/sct.rb
149
- - lib/sct/.DS_Store
150
- - lib/sct/ClassLevelInheritableAttributes.rb
151
- - lib/sct/command.rb
152
- - lib/sct/command_interface.rb
153
- - lib/sct/command_option.rb
154
- - lib/sct/commands/cluster.rb
155
- - lib/sct/commands/composer.rb
156
- - lib/sct/commands/hostfile.rb
157
- - lib/sct/commands/init.rb
158
- - lib/sct/commands/mysqlproxy.rb
159
- - lib/sct/commands/php.rb
160
- - lib/sct/commands/yarn.rb
161
- - lib/sct/config.rb
162
- - lib/sct/docker/composer.rb
163
- - lib/sct/docker/docker.rb
164
- - lib/sct/docker/php.rb
165
- - lib/sct/docker/yarn.rb
166
- - lib/sct/setup/helpers.rb
167
- - lib/sct/version.rb
168
- - sct.gemspec
165
+ - cluster/lib/.DS_Store
166
+ - cluster/lib/cluster.rb
167
+ - cluster/lib/cluster/commands_generator.rb
168
+ - cluster/lib/cluster/module.rb
169
+ - cluster/lib/cluster/runner.rb
170
+ - sct/lib/.DS_Store
171
+ - sct/lib/sct.rb
172
+ - sct/lib/sct/.DS_Store
173
+ - sct/lib/sct/cli_tools_distributor.rb
174
+ - sct/lib/sct/command.rb
175
+ - sct/lib/sct/commands/hostfile.rb
176
+ - sct/lib/sct/commands/init.rb
177
+ - sct/lib/sct/commands/mysqlproxy.rb
178
+ - sct/lib/sct/commands_generator.rb
179
+ - sct/lib/sct/tools.rb
180
+ - sct/lib/sct/version.rb
181
+ - sct_core/lib/.DS_Store
182
+ - sct_core/lib/sct_core.rb
183
+ - sct_core/lib/sct_core/.DS_Store
184
+ - sct_core/lib/sct_core/command_executor.rb
185
+ - sct_core/lib/sct_core/config.rb
186
+ - sct_core/lib/sct_core/core_ext/string.rb
187
+ - sct_core/lib/sct_core/helper.rb
188
+ - sct_core/lib/sct_core/module.rb
189
+ - sct_core/lib/sct_core/sct_pty.rb
190
+ - sct_core/lib/sct_core/ui/implementations/shell.rb
191
+ - sct_core/lib/sct_core/ui/interface.rb
192
+ - sct_core/lib/sct_core/ui/ui.rb
193
+ - shell/README.md
194
+ - shell/lib/shell.rb
195
+ - shell/lib/shell/ClassLevelInheritableAttributes.rb
196
+ - shell/lib/shell/commands_generator.rb
197
+ - shell/lib/shell/docker/composer.rb
198
+ - shell/lib/shell/docker/docker.rb
199
+ - shell/lib/shell/docker/php.rb
200
+ - shell/lib/shell/docker/yarn.rb
201
+ - shell/lib/shell/module.rb
202
+ - shell/lib/shell/runner.rb
203
+ - shell/lib/shell/tools.rb
169
204
  homepage: https://gitlab.com/proactive-software/packages/sct
170
205
  licenses:
171
206
  - MIT
@@ -176,19 +211,22 @@ metadata:
176
211
  post_install_message:
177
212
  rdoc_options: []
178
213
  require_paths:
179
- - lib
214
+ - cluster/lib
215
+ - shell/lib
216
+ - sct/lib
217
+ - sct_core/lib
180
218
  required_ruby_version: !ruby/object:Gem::Requirement
181
219
  requirements:
182
220
  - - ">="
183
221
  - !ruby/object:Gem::Version
184
- version: '0'
222
+ version: 2.0.0
185
223
  required_rubygems_version: !ruby/object:Gem::Requirement
186
224
  requirements:
187
225
  - - ">="
188
226
  - !ruby/object:Gem::Version
189
227
  version: '0'
190
228
  requirements: []
191
- rubygems_version: 3.0.6
229
+ rubygems_version: 3.0.8
192
230
  signing_key:
193
231
  specification_version: 4
194
232
  summary: Spend Cloud Tool.